Static Public Member Functions | |
| static | getInstance () |
| static | log ($message, $source, $severity=GauffrLog::INFO, $attributes=array("category"=>"Gauffr")) |
| static | gauffrInitialization () |
| static | info ($as_array=false) |
| static | cryptPasswd ($password) |
| static | authenticationDatabase ($login, $password, $slave_identifier=false, $login_is_alt_login=false) |
Public Attributes | |
| const | APP_NAME = "Gauffr" |
| const | APP_VERSION = "0.4" |
| const | CONF_FILE = 'gauffr' |
| const | GAUFFR_DB_INSTANCE = 'gauffr' |
| $gauffrUserTable | |
| $gauffrTables | |
| $debugLevel | |
Static Public Attributes | |
| static | $gauffrPath |
| static | $gauffrMappingDir |
| static | $confDir |
Private Member Functions | |
| __construct () | |
| loadTableSchema () | |
| __clone () | |
| loadCallback () | |
| authenticationDatabaseFilter (&$authentication, &$filter, $login, $password, $login_is_alt_login=false) | |
Static Private Attributes | |
| static | $instance = null |
Gauffr main class.
The Gauffr classes called by all aplication using Gauffr.
Definition at line 17 of file gauffr.php.
| Gauffr::__construct | ( | ) | [private] |
Private constructor to prevent non-singleton use
Definition at line 83 of file gauffr.php.
References $confDir, $gauffrMappingDir, $gauffrPath, getInstance(), loadCallback(), and loadTableSchema().
{
/* Define path */
Gauffr::$gauffrPath = dirname( __FILE__ );
Gauffr::$confDir = Gauffr::$gauffrPath . '/conf';
Gauffr::$gauffrMappingDir = Gauffr::$gauffrPath . '/lib/persistentobjectmapping/';
$this->loadCallback(); // Load ezc Callback
$this->loadTableSchema(); // Load ini with ezcConfigurationManager
$cfg = ezcConfigurationManager::getInstance();
$this->debugLevel = constant( $cfg->getSetting( 'gauffr', 'GauffrSettings', 'LogLevel' ) );
}
| Gauffr::__clone | ( | ) | [private] |
Don't allow clone
| Exception | because Gauffr don't allow clone. |
Definition at line 133 of file gauffr.php.
{
throw new Exception ('Clone is not allowed');
}
| static Gauffr::authenticationDatabase | ( | $ | login, | |
| $ | password, | |||
| $ | slave_identifier = false, |
|||
| $ | login_is_alt_login = false | |||
| ) | [static] |
Process Gauffr authentication with a database
$user = Gauffr::authenticationDatabase( $_POST['login'], $_POST['password'], 'gauffradmin' true );
| string | $login | |
| string | $password | |
| string | $slave_identifier | |
| boolean | $login_is_alt_login The $login is an altLogin ? |
Definition at line 508 of file gauffr.php.
References getInstance(), and log().
{
$gauffr = self::getInstance();
$gauffr->authenticationDatabaseFilter( $authentication, $filter, $login, $password, $login_is_alt_login );
if ( !$authentication->run() )
{
Gauffr::log("Authentification failled for user \"$login\" (".$login_is_alt_login ? "AltLogin" : "Login" . ")", 'gauffr', GauffrLog::DEBUG, array( "category" => "AuthenticationDatabase", "file" => __FILE__, "line" => __LINE__ ) );
return false;
}
// Create an GauffrUser
$data = $filter->fetchData();
$user = new GauffrUser();
$user->setState( array(
'ID' => reset( $data[$gauffr->gauffrUserTable['ID']] ),
'GroupID' => reset( $data[$gauffr->gauffrUserTable['GroupID']] ),
'Login' => reset( $data[$gauffr->gauffrUserTable['Login']] ),
'Mail' => reset( $data[$gauffr->gauffrUserTable['Mail']] )
) );
// No slave_identifier control
if ( !$slave_identifier )
{
Gauffr::log("Authentification successful for user \"$login\"", 'gauffr', GauffrLog::DEBUG, array( "category" => "AuthenticationDatabase", "file" => __FILE__, "line" => __LINE__ ) );
return $user;
}
else
{
if ( $user->hasCredentialByIdentifier($slave_identifier) )
{
Gauffr::log("Authentification successful on \"$slave_identifier\" for user \"$login\"", 'gauffr', GauffrLog::DEBUG, array( "category" => "AuthenticationDatabase", "file" => __FILE__, "line" => __LINE__ ) );
return $user;
}
else
{
Gauffr::log("User \"$login\" don't have access to \"$slave_identifier\"", 'gauffr', GauffrLog::SYSTEM, array( "category" => "AuthenticationDatabase", "file" => __FILE__, "line" => __LINE__ ) );
return false;
}
}
}
| Gauffr::authenticationDatabaseFilter | ( | &$ | authentication, | |
| &$ | filter, | |||
| $ | login, | |||
| $ | password, | |||
| $ | login_is_alt_login = false | |||
| ) | [private] |
Create ezcAuthenticationDatabaseFilter
| ezcAuthentication | &$authentication | |
| ezcAuthenticationDatabaseFilter | &$filter | |
| string | $login | |
| string | $password | |
| boolean | $login_is_alt_login The $login is an altLogin ? |
Definition at line 457 of file gauffr.php.
References GauffrUser::fetchUserByAltLogin().
{
$db = ezcDbInstance::get(self::GAUFFR_DB_INSTANCE);
if ( $login_is_alt_login )
{
$user = GauffrUser::fetchUserByAltLogin($login);
if ( $user )
$login = $user->Login;
else
$login = false;
}
$credentials = new ezcAuthenticationPasswordCredentials( $login, self::cryptPasswd($password) );
$database = new ezcAuthenticationDatabaseInfo(
$db,
$this->gauffrUserTable['TableName'],
array( $this->gauffrUserTable['Login'], $this->gauffrUserTable['Password'] )
);
$authentication = new ezcAuthentication( $credentials );
$filter = new ezcAuthenticationDatabaseFilter( $database );
$authentication->addFilter( $filter );
$filter->registerFetchData( array(
$this->gauffrUserTable['ID'],
$this->gauffrUserTable['GroupID'],
$this->gauffrUserTable['Login'],
$this->gauffrUserTable['Mail']
) );
}
| static Gauffr::cryptPasswd | ( | $ | password | ) | [static] |
Crypt password with Gauffr method
Allow personnal method
| string | $password |
Definition at line 438 of file gauffr.php.
References getInstance().
{
$gauffr = self::getInstance();
$cryptoMethod = $gauffr->gauffrUserTable['CryptoMethod'];
return $cryptoMethod($password);
}
| static Gauffr::gauffrInitialization | ( | ) | [static] |
Gauffr initiation
Definition at line 198 of file gauffr.php.
References getInstance().
{
// Load eZ Components
if ( !defined( 'EZCBASE_ENABLED' ) )
{
$baseEnabled = @include 'ezc/Base/base.php';
if ( !$baseEnabled )
{
$baseEnabled = include 'Base/src/base.php';
}
define( 'EZCBASE_ENABLED', $baseEnabled );
}
// Load Gauffr
if ( !defined('GAUFFR_ENABLED') )
{
// autoload
spl_autoload_register( array( 'ezcBase', 'autoload' ) );
ezcBase::addClassRepository( dirname( __FILE__ ), dirname( __FILE__ ).'/autoloads' );
define( 'GAUFFR_ENABLED', true );
}
// Launch first instance of Gauffr
$gauffr = Gauffr::getInstance();
}
| static Gauffr::getInstance | ( | ) | [static] |
Returns an instance of the class Gauffr.
Definition at line 104 of file gauffr.php.
Referenced by __construct(), authenticationDatabase(), GauffrLazyLogConfiguration::configureObject(), cryptPasswd(), gauffrInitialization(), GauffrPersistentObject::getPersistentSessionInstance(), info(), loadTableSchema(), and log().
{
if ( is_null( self::$instance ) )
{
self::$instance = new Gauffr();
}
return self::$instance;
}
| static Gauffr::info | ( | $ | as_array = false |
) | [static] |
Return informations about Gauffr
| boolean | $as_array Return information as array |
Definition at line 237 of file gauffr.php.
References $confDir, $gauffrMappingDir, $gauffrPath, APP_NAME, APP_VERSION, GAUFFR_DB_INSTANCE, and getInstance().
{
$gauffr = Gauffr::getInstance();
$info = array(
'version' => Gauffr::APP_VERSION,
'info' => array(
'Variables' => array(
array(
'Variables' => 'Gauffr::APP_NAME',
'Description' => 'Application name',
'Value' => Gauffr::APP_NAME
),
array(
'Variables' => 'Gauffr::APP_VERSION',
'Description' => 'Application version',
'Value' => Gauffr::APP_VERSION
),
array(
'Variables' => 'Gauffr::GAUFFR_DB_INSTANCE',
'Description' => 'Database instance identifier',
'Value' => Gauffr::GAUFFR_DB_INSTANCE
),
array(
'Variables' => 'Gauffr::$debugLevel',
'Description' => 'Debug level',
'Value' => $gauffr->debugLevel
),
array(
'Variables' => 'Gauffr::$gauffrPath',
'Description' => 'Gauffr directory',
'Value' => Gauffr::$gauffrPath
),
array(
'Variables' => 'Gauffr::$confDir',
'Description' => 'Configuration directory',
'Value' => Gauffr::$confDir
),
array(
'Variables' => 'Gauffr::$gauffrMappingDir',
'Description' => 'Mapping directory',
'Value' => Gauffr::$gauffrMappingDir
),
),
'Database info' => array(
array(
'Name' => 'GauffrMaster',
'Table name' => $gauffr->gauffrUserTable['TableName']
),
array(
'Name' => 'GauffrSlave',
'Information' => $gauffr->gauffrTables['GauffrSlave']
),
array(
'Name' => 'GauffrLog',
'Information' => $gauffr->gauffrTables['GauffrLog']
),
),
'Dependancies' => array(
array(
'Tests' => 'eZC Authentication',
'Result' => (class_exists('ezcAuthentication')) ? 'Pass' : 'Failed'
),
array(
'Tests' => 'eZC AuthenticationDatabaseTiein',
'Result' => (class_exists('ezcAuthenticationDatabaseInfo')) ? 'Pass' : 'Failed'
),
array(
'Tests' => 'eZC Configuration',
'Result' => (class_exists('ezcConfiguration')) ? 'Pass' : 'Failed'
),
array(
'Tests' => 'eZC ConsoleTools',
'Result' => (class_exists('ezcConsoleOption')) ? 'Pass' : 'Failed'
),
array(
'Tests' => 'eZC Database',
'Result' => (class_exists('ezcDbInstance')) ? 'Pass' : 'Failed'
),
/*array(
'Tests' => 'eZC DatabaseSchema',
'Result' => (class_exists('ezcDbSchema')) ? 'Pass' : 'Failed'
),*/
array(
'Tests' => 'eZC EventLog',
'Result' => (class_exists('ezcLog')) ? 'Pass' : 'Failed'
),
array(
'Tests' => 'eZC EventLogDatabaseTiein',
'Result' => (class_exists('ezcLogDatabaseWriter')) ? 'Pass' : 'Failed'
),
array(
'Tests' => 'eZC PersistentObject',
'Result' => (class_exists('ezcPersistentSession')) ? 'Pass' : 'Failed'
)
)
)
);
if( $as_array )
return $info;
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}
pre {margin: 0px; font-family: monospace;}
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
a:hover {text-decoration: underline;}
table {border-collapse: collapse;}
.center {text-align: center;}
.center table { margin-left: auto; margin-right: auto; text-align: left;}
.center th { text-align: center !important; }
td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
h1 {font-size: 150%;}
h2 {font-size: 125%;}
.p {text-align: left;}
.e {background-color: #ccccff; font-weight: bold; color: #000000;}
.h {background-color: #9999cc; font-weight: bold; color: #000000;}
.v {background-color: #cccccc; color: #000000;}
.vr {background-color: #cccccc; text-align: right; color: #000000;}
img {float: right; border: 0px;}
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
</style>
<title>Gauffr::info()</title>
<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
</head>
<body>
<div id="gauffrinfo" class="center">
<table border="0" cellpadding="3" width="600">
<tr class="h">
<td>
<h1 class="p">Gauffr Version ' . Gauffr::APP_VERSION . '</h1>
</td>
</tr>
</table>
<br />';
foreach( $info['info'] as $title => $infos )
{
echo '<h2><a name="' . strtolower($title) . '">' . $title . '</a></h2>
<table width="600" cellpadding="3" border="0">
<thead>
<tr class="h">';
foreach( $infos as $info )
{
foreach( $info as $key => $value )
{
echo '<th>' . $key . '</th>';
}
break;
}
echo '</tr>
</thead>
<tbody>';
foreach( $infos as $info )
{
echo '<tr>';
$is_first = true;
foreach( $info as $key => $value )
{
if( $is_first )
{
$class = 'e';
$is_first = false;
}
else
{
$class = 'v';
}
echo '<td class="' . $class . '">' . $value . '</td>';
}
echo '</tr>';
}
echo '</tbody>
</table>
<br />';
}
echo '
</div>
</body>
</html>';
}
| Gauffr::loadCallback | ( | ) | [private] |
Add eZ Components callback.
Definition at line 173 of file gauffr.php.
Referenced by __construct().
{
ezcBaseInit::setCallback(
'ezcInitConfigurationManager',
'GauffrLazyConfigurationConfiguration'
);
ezcBaseInit::setCallback(
'ezcInitDatabaseInstance',
'GauffrLazyDatabaseConfiguration'
);
ezcBaseInit::setCallback(
'ezcInitLog',
'GauffrLazyLogConfiguration'
);
ezcBaseInit::setCallback(
'ezcInitPersistentSessionInstance',
'GauffrLazyPersistentSessionConfiguration'
);
}
| Gauffr::loadTableSchema | ( | ) | [private] |
Load database table schema from ini file.
Definition at line 118 of file gauffr.php.
References getInstance().
Referenced by __construct().
{
$cfg = ezcConfigurationManager::getInstance();
$this->gauffrUserTable = $cfg->getSettingsInGroup('gauffr', 'GauffrUserTable');
$this->gauffrTables = $cfg->getSettingsInGroup('gauffr', 'GauffrTables');
}
| static Gauffr::log | ( | $ | message, | |
| $ | source, | |||
| $ | severity = GauffrLog::INFO, |
|||
| $ | attributes = array( "category" => "Gauffr") | |||
| ) | [static] |
Log event in gauffr log system
Gauffr::log("Test", 'tutorial', GauffrLog::SYSTEM, array( "category" => "tutorial", "file" => __FILE__, "line" => __LINE__ ) );
| string | $message Message to log | |
| string | $source Source from log action | |
| int | $severity GauffrLog::INFO or GauffrLog::WARNING or GauffrLog::ERROR or GauffrLog::SYSTEM | |
| array | $attributes |
Definition at line 153 of file gauffr.php.
References getInstance().
Referenced by authenticationDatabase().
{
$gauffr = self::getInstance();
if ( $gauffr->debugLevel <= $severity )
{
$log = ezcLog::getInstance();
$log->source = $source;
$log->log( $message, $severity, $attributes );
}
}
Gauffr::$confDir [static] |
The Gauffr configuration path.
Definition at line 72 of file gauffr.php.
Referenced by __construct(), GauffrLazyConfigurationConfiguration::configureObject(), and info().
| Gauffr::$debugLevel |
The Gauffr debug level.
Definition at line 60 of file gauffr.php.
Gauffr::$gauffrMappingDir [static] |
The Gauffr mapping path.
Definition at line 68 of file gauffr.php.
Referenced by __construct(), GauffrLazyPersistentSessionConfiguration::configureObject(), and info().
Gauffr::$gauffrPath [static] |
| Gauffr::$gauffrTables |
The Gauffr database table name.
Definition at line 56 of file gauffr.php.
| Gauffr::$gauffrUserTable |
The GauffrUser database table Schema.
Definition at line 52 of file gauffr.php.
Gauffr::$instance = null [static, private] |
| Gauffr | Instance |
Definition at line 48 of file gauffr.php.
| const Gauffr::APP_NAME = "Gauffr" |
| const Gauffr::APP_VERSION = "0.4" |
| const Gauffr::CONF_FILE = 'gauffr' |
Gauffr global configuration file.
Definition at line 34 of file gauffr.php.
Referenced by GauffrLazyDatabaseConfiguration::configureObject().
| const Gauffr::GAUFFR_DB_INSTANCE = 'gauffr' |
Gauffr database instance identifier (for muliple usage of ezcDatabase).
Definition at line 38 of file gauffr.php.
Referenced by GauffrLazyPersistentSessionConfiguration::configureObject(), GauffrLazyLogConfiguration::configureObject(), GauffrLazyDatabaseConfiguration::configureObject(), GauffrPersistentObject::getPersistentSessionInstance(), and info().
1.7.1