Page MenuHomeDevCentral

No OneTemporary

diff --git a/workspaces/src/Engines/Auth/AuthenticationMethod.php b/workspaces/src/Engines/Auth/AuthenticationMethod.php
index c3c086f..f883431 100644
--- a/workspaces/src/Engines/Auth/AuthenticationMethod.php
+++ b/workspaces/src/Engines/Auth/AuthenticationMethod.php
@@ -1,288 +1,290 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* Authentication method class
*
* @package ObsidianWorkspaces
* @subpackage Auth
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*/
namespace Waystone\Workspaces\Engines\Auth;
use Waystone\Workspaces\Engines\Auth\Actions\AddToGroupUserAction;
use Waystone\Workspaces\Engines\Auth\Actions\GivePermissionUserAction;
use Waystone\Workspaces\Engines\Framework\Context;
use Waystone\Workspaces\Engines\Serialization\ArrayDeserializableWithContext;
+use Waystone\Workspaces\Engines\Users\User;
use Keruald\OmniTools\DataTypes\Option\None;
use Keruald\OmniTools\DataTypes\Option\Option;
use Keruald\OmniTools\DataTypes\Option\Some;
use Language;
use Message;
-use User;
use Exception;
use InvalidArgumentException;
/**
* Authentication method class
*
* This class has to be extended to implement custom authentication methods.
*/
abstract class AuthenticationMethod implements ArrayDeserializableWithContext {
/**
* @var User The local user matching the authentication
*/
public $localUser;
/**
* @var string The username
*/
public $name;
/**
* @var string The e-mail address
*/
public $email;
/**
* @var string The authentication method identifiant
*/
public $id;
/**
* @var string The remote identity provider user identifiant
*/
public $remoteUserId;
/**
* @var Message The localized authentication login message
*/
public $loginMessage;
/**
* @var boolean Determines if the authentication method could be used to
* register new users
*/
public $canCreateUser = false;
/**
* @var Array Actions to execute if a user is created, each instance a
* member of UserAction
*/
public $createUserActions = [];
/**
* @var Context The site context
*/
public $context;
/**
* @var Message The localized authentication error message
*/
public $loginError;
/**
* Gets authentication link for this method
*/
public abstract function getAuthenticationLink ();
/**
* Handles request
*/
public abstract function handleRequest ();
/**
* Runs actions planned on user create
*/
protected function runCreateUserActions () {
foreach ($this->createUserActions as $action) {
$action->context = $this->context;
$action->targetUser = $this->localUser;
$action->run();
}
}
/**
* Finds user from available data
*
* @return Option<User> the user if a user has been found; otherwise, false.
*/
private function findUser () : Option {
$users = $this->context->userRepository;
if ($this->remoteUserId != '') {
$user = $users->getUserFromRemoteIdentity(
$this->id, $this->remoteUserId,
);
if ($user->isSome()) {
return $user;
}
}
if ($this->email != '') {
$user = $users->getUserFromEmail($this->email);
if ($user->isSome()) {
return $user;
}
}
return new None;
}
/**
* Signs in or creates a new user
*
* @return boolean true if user has been successfully logged in; otherwise,
* false.
*/
public function signInOrCreateUser () {
// At this stage, if we don't already have a user instance,
// we're fetching it by remote user id or mail.
//
// If no result is returned, we're creating a new user if needed.
//
// Finally, we proceed to log in.
if ($this->localUser === null) {
$user = $this->findUser();
if ($user->isSome()) {
$this->localUser = $user->getValue();
}
}
if ($this->localUser === null) {
if (!$this->canCreateUser) {
$this->loginError =
Language::get("ExternalLoginCantCreateAccount");
return false;
} else {
$this->createUser();
if ($this->localUser === null) {
throw new Exception("Can't sign in: after correct remote authentication, an error occurred creating locally a new user.");
}
}
}
$this->signIn($this->localUser);
return true;
}
/**
* Signs in the specified user
*
* @param User The user to log in
*/
public function signIn (User $user) {
$this->context->session->user_login($user->id);
}
/**
* Creates a new user based on the authentication provisioning information
*
* @return User The user created
*/
public function createUser () {
if (!$this->canCreateUser) {
throw new Exception("Can't create user: the canCreateUser property is set at false.");
}
- $user = User::create($this->context->db);
+ $users = $this->context->userRepository;
+
+ $user = $users->create();
$user->name = $this->name;
$user->email = $this->email;
- $user->save_to_database();
+ $users->saveToDatabase($user);
- $user->setRemoteIdentity(
- $this->id, $this->remoteUserId,
+ $users->setRemoteIdentity(
+ $user, $this->id, $this->remoteUserId,
);
$this->localUser = $user;
$this->runCreateUserActions();
}
/**
* Gets authentication method from ID
*
* @param string $id The authentication method id
* @param Context $context The site context
*
* @return AuthenticationMethod The authentication method matching the id
*/
public static function getFromId ($id, $context) {
if ($context->workspace != null) {
foreach (
$context->workspace->configuration->authenticationMethods as
$authenticationMethod
) {
if ($authenticationMethod->id == $id) {
return $authenticationMethod;
}
}
}
return null;
}
/**
* Loads an AuthenticationMethod instance from a generic array.
* Typically used to deserialize a configuration.
*
* @param array $data The associative array to deserialize
* @param mixed $context The application context
*
* @return AuthenticationMethod The deserialized instance
* @throws InvalidArgumentException|Exception
*/
public static function loadFromArray (array $data, mixed $context) : self {
$instance = new static;
$instance->context = $context;
if (!array_key_exists("id", $data)) {
throw new InvalidArgumentException("Authentication method id is required.");
}
$instance->id = $data["id"];
$message = $data["loginMessage"] ?? Language::get("SignIn");
$instance->loginMessage = new Message($message);
if (array_key_exists("createUser", $data)) {
$createUser = $data["createUser"];
if (array_key_exists("enabled", $createUser)) {
$instance->canCreateUser = ($createUser["enabled"] === true);
}
$addToGroups = $createUser["addToGroups"] ?? [];
foreach ($addToGroups as $actionData) {
$instance->createUserActions[] =
AddToGroupUserAction::loadFromArray($actionData);
}
$givePermissions = $createUser["givePermissions"] ?? [];
foreach ($createUser["givePermissions"] as $actionData) {
$instance->createUserActions[] =
GivePermissionUserAction::loadFromArray($actionData);
}
}
return $instance;
}
}
diff --git a/workspaces/src/Engines/Auth/UserAction.php b/workspaces/src/Engines/Auth/UserAction.php
index adcd9ea..9c95365 100644
--- a/workspaces/src/Engines/Auth/UserAction.php
+++ b/workspaces/src/Engines/Auth/UserAction.php
@@ -1,50 +1,49 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* User action class
*
* @package ObsidianWorkspaces
* @subpackage Auth
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*
*/
namespace Waystone\Workspaces\Engines\Auth;
use Waystone\Workspaces\Engines\Framework\Context;
-
-use User;
+use Waystone\Workspaces\Engines\Users\User;
/**
* User action class, to be extended to implement an action related to user
*/
abstract class UserAction {
/**
* @var User the target action user
*/
public $targetUser;
public ?Context $context = null;
/**
* Initializes a new instance of an UserAction object
*
* @param User $targetUser the target action user
*/
public function __construct ($targetUser = null) {
$this->targetUser = $targetUser;
}
/**
* Executes the user action
*/
abstract public function run ();
}
diff --git a/workspaces/src/Engines/Exceptions/UserNotFoundException.php b/workspaces/src/Engines/Exceptions/UserNotFoundException.php
new file mode 100644
index 0000000..55e09ea
--- /dev/null
+++ b/workspaces/src/Engines/Exceptions/UserNotFoundException.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Waystone\Workspaces\Engines\Exceptions;
+
+use RuntimeException;
+
+class UserNotFoundException extends RuntimeException {
+
+}
diff --git a/workspaces/src/Engines/Framework/Context.php b/workspaces/src/Engines/Framework/Context.php
index 7ef609e..3c507a1 100644
--- a/workspaces/src/Engines/Framework/Context.php
+++ b/workspaces/src/Engines/Framework/Context.php
@@ -1,113 +1,113 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* Application context class
*
* @package ObsidianWorkspaces
* @subpackage Controller
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*/
namespace Waystone\Workspaces\Engines\Framework;
use Keruald\Database\DatabaseEngine;
use Smarty\Smarty;
-use User;
+use Waystone\Workspaces\Engines\Users\User;
use Waystone\Workspaces\Engines\Users\UserRepository;
use Waystone\Workspaces\Engines\Workspaces\WorkSpace;
/**
* Context class
*
* This class describes the site context.
*/
class Context {
/**
* @var ?WorkSpace the workspace currently enabled
*/
public ?WorkSpace $workspace = null;
/**
* @var DatabaseEngine the database
*/
public DatabaseEngine $db;
/**
* @var array the configuration
*/
public array $config;
/**
* @var UserRepository the users already loaded from database
*/
public UserRepository $userRepository;
public Resources $resources;
/**
- * @var User the user currently logged in
+ * @var ?User the user currently logged in
*/
- public User $user;
+ public ?User $user = null;
/**
* @var Session the current session
*/
public Session $session;
/**
* @var string[] the URL fragments
*/
public array $url;
/**
* @var Smarty the template engine
*/
public Smarty $templateEngine;
///
/// Helper methods
///
/**
* Gets application root directory
*
* @return string|false the application root directory
*/
public function getApplicationRootDirectory () : string|false {
return getcwd();
}
///
/// Templates
///
/**
* Initializes the template engine
*
* @param string $theme the theme for the templates
*/
public function initializeTemplateEngine (string $theme) : void {
$smarty = new Smarty();
$current_dir = static::getApplicationRootDirectory();
$smarty
->setTemplateDir("$current_dir/skins/$theme")
->setCacheDir($this->config["Content"]["Cache"])
->setCompileDir($this->config["Content"]["Cache"] . "/compiled")
->setConfigDir($current_dir);
$smarty->config_vars += [
"StaticContentURL" => $this->config["StaticContentURL"],
];
$this->templateEngine = $smarty;
}
}
diff --git a/workspaces/src/Engines/Framework/Session.php b/workspaces/src/Engines/Framework/Session.php
index eacaaf5..ffc0408 100755
--- a/workspaces/src/Engines/Framework/Session.php
+++ b/workspaces/src/Engines/Framework/Session.php
@@ -1,325 +1,327 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* Session
*
* This class uses a singleton pattern, as we only need one single instance.
* Cf. http://www.php.net/manual/en/language.oop5.patterns.php
*
* @package ObsidianWorkspaces
* @subpackage Keruald
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*
*/
namespace Waystone\Workspaces\Engines\Framework;
use Waystone\Workspaces\Engines\Errors\ErrorHandling;
+use Waystone\Workspaces\Engines\Users\User;
use Waystone\Workspaces\Engines\Users\UserRepository;
use Keruald\Database\DatabaseEngine;
-use User;
-
/**
* Session class
*/
class Session {
/**
* @var string session ID
*/
public $id;
/**
* @var string remote client IP
*/
public $ip;
public DatabaseEngine $db;
private UserRepository $users;
/*
* @var Session current session instance
*/
private static $instance;
/*
* Gets or initializes current session instance
*
* @return Session current session instance
*/
public static function load (
DatabaseEngine $db,
UserRepository $users,
) {
if (!isset(self::$instance)) {
self::$instance = new self($db, $users);
}
return self::$instance;
}
/**
* Initializes a new instance of Session object
*/
private function __construct (
DatabaseEngine $db,
UserRepository $users,
) {
$this->db = $db;
$this->users = $users;
//Starts PHP session, and gets id
session_start();
$_SESSION['ID'] = session_id();
$this->id = $_SESSION['ID'];
//Gets remote client IP
$this->ip = self::get_ip();
//Updates or creates the session in database
$this->update();
}
/**
* Gets remote client IP address
*
* @return string IP
*/
public static function get_ip () {
//mod_proxy + mod_rewrite (old pluton url scheme) will define 127.0.0.1
//in REMOTE_ADDR, and will store ip in HTTP_X_FORWARDED_FOR variable.
//Some ISP/orgz proxies also use this setting.
if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
//Standard cases
return $_SERVER['REMOTE_ADDR'];
}
/**
* Cleans up session
* i. deletes expired session
* ii. sets offline relevant sessions
*/
public function clean_old_sessions () {
global $Config;
$db = $this->db;
//Gets session and online status lifetime (in seconds)
//If not specified in config, sets default 5 and 120 minutes values
$onlineDuration = array_key_exists('OnlineDuration', $Config)
? $Config['OnlineDuration'] : 300;
$sessionDuration = array_key_exists('SessionDuration', $Config)
? $Config['SessionDuration'] : 7200;
$resource = array_key_exists('ResourceID', $Config) ? '\''
. $db->escape($Config['ResourceID'])
. '\''
: 'default';
//Deletes expired sessions
$sql = "DELETE FROM " . TABLE_SESSIONS
. " WHERE session_resource = $resource AND TIMESTAMPDIFF(SECOND, session_updated, NOW()) > $sessionDuration";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Can't delete expired sessions", '', __LINE__, __FILE__, $sql);
}
//Online -> offline
$sql = "UPDATE " . TABLE_SESSIONS
. " SET session_resource = $resource AND session_online = 0 WHERE TIMESTAMPDIFF(SECOND, session_updated, NOW()) > $onlineDuration";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
'Can\'t update sessions online statuses', '', __LINE__,
__FILE__, $sql);
}
}
/**
* Updates or creates a session in the database
*/
public function update () {
global $Config;
$db = $this->db;
//Cleans up session
//To boost SQL performances, try a random trigger
// e.g. if (rand(1, 100) < 3) self::clean_old_sessions();
//or comment this line and execute a cron script you launch each minute.
$this->clean_old_sessions();
//Saves session in database.
//If the session already exists, it updates the field online and updated.
$id = $db->escape($this->id);
$resource = array_key_exists('ResourceID', $Config) ? '\''
. $db->escape($Config['ResourceID'])
. '\''
: 'default';
$user_id = $db->escape(ANONYMOUS_USER);
$sql = "INSERT INTO " . TABLE_SESSIONS
. " (session_id, session_ip, session_resource, user_id) VALUES ('$id', '$this->ip', $resource, '$user_id') ON DUPLICATE KEY UPDATE session_online = 1";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
'Can\'t save current session', '', __LINE__, __FILE__, $sql);
}
}
/**
* Gets the number of online users
*
* @return int the online users count
*/
public function count_online () {
//Keeps result for later method call
static $count = -1;
if ($count == -1) {
//Queries sessions table
global $Config;
$db = $this->db;
$resource = array_key_exists('ResourceID', $Config) ? '\''
. $db->escape($Config['ResourceID'])
. '\''
: 'default';
$sql = "SELECT count(*) FROM " . TABLE_SESSIONS
. " WHERE session_resource = $resource AND session_online = 1";
$count =
(int)$db->queryScalar($sql, "Can't count online users");
}
//Returns number of users online
return $count;
}
/**
* Gets the value of a custom session table field
*
* @param string $info the field to get
*
* @return string the session specified field's value
*/
public function get_info ($info) {
$db = $this->db;
$id = $db->escape($this->id);
$sql = "SELECT `$info` FROM " . TABLE_SESSIONS
. " WHERE session_id = '$id'";
return $db->queryScalar($sql, "Can't get session $info info");
}
/**
* Sets the value of a custom session table field to the specified value
*
* @param string $info the field to update
* @param string $value the value to set
*/
public function set_info ($info, $value) {
$db = $this->db;
$value =
($value === null) ? 'NULL' : "'" . $db->escape($value) . "'";
$id = $db->escape($this->id);
$sql = "UPDATE " . TABLE_SESSIONS
. " SET `$info` = $value WHERE session_id = '$id'";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Can't set session $info info", '', __LINE__, __FILE__, $sql);
}
}
/**
* Gets logged user information
*
* @return User the logged user information
*/
public function get_logged_user () {
$db = $this->db;
//Gets session information
$id = $db->escape($this->id);
$sql = "SELECT * FROM " . TABLE_SESSIONS . " WHERE session_id = '$id'";
if (!$result = $db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Can't query session information", '', __LINE__, __FILE__,
$sql);
}
$row = $db->fetchRow($result);
//Gets user instance
- require_once('includes/objects/user.php');
- $user = new User($row['user_id'], $db);
+ $user_id = (int)$row['user_id'];
+ $user = match ($user_id) {
+ ANONYMOUS_USER => User::anonymous(),
+ default => $this->users->get($user_id),
+ };
//Adds session property to this user instance
$user->session = $row;
//Returns user instance
return $user;
}
/**
* Cleans session
*
* This method is to be called when an event implies a session destroy
*/
public function clean () {
//Destroys $_SESSION array values, help ID
foreach ($_SESSION as $key => $value) {
if ($key != 'ID') {
unset($_SESSION[$key]);
}
}
}
/**
* Updates the session in a user login context
*
* @param string $user_id the user ID
*/
public function user_login ($user_id) {
$db = $this->db;
//Sets specified user ID in sessions table
$user_id = $db->escape($user_id);
$id = $db->escape($this->id);
$sql = "UPDATE " . TABLE_SESSIONS
. " SET user_id = '$user_id' WHERE session_id = '$id'";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Can't set logged in status", '', __LINE__, __FILE__, $sql);
}
}
/**
* Updates the session in a user logout context
*/
public function user_logout () {
$db = $this->db;
//Sets anonymous user in sessions table
$user_id = $db->escape(ANONYMOUS_USER);
$id = $db->escape($this->id);
$sql = "UPDATE " . TABLE_SESSIONS
. " SET user_id = '$user_id' WHERE session_id = '$id'";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Can't set logged out status", '', __LINE__, __FILE__, $sql);
}
//Cleans session
$this->clean();
}
}
diff --git a/workspaces/src/includes/objects/user.php b/workspaces/src/Engines/Users/User.php
similarity index 63%
rename from workspaces/src/includes/objects/user.php
rename to workspaces/src/Engines/Users/User.php
index 21e5202..46bb184 100755
--- a/workspaces/src/includes/objects/user.php
+++ b/workspaces/src/Engines/Users/User.php
@@ -1,343 +1,260 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* User class
*
* @package ObsidianWorkspaces
* @subpackage Model
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*
*/
+namespace Waystone\Workspaces\Engines\Users;
+
use Waystone\Workspaces\Engines\Errors\ErrorHandling;
use Waystone\Workspaces\Engines\Workspaces\Workspace;
use Keruald\Database\DatabaseEngine;
+use UserGroup;
+
/**
* User class
*/
class User {
public ?int $id;
public $name;
public $password;
public $active = 0;
public $email;
public $regdate;
public array $session = [];
public string $lastError;
/**
* @var array|null An array of the workspaces the user has access to, each element an instance of the Workspace object. As long as the field hasn't been initialized by get_workspaces, null.
*/
private $workspaces = null;
private DatabaseEngine $db;
- /*
- * Initializes a new instance
+ ///
+ /// Constructors
+ ///
+
+ public static function fromRow (array $row) : self {
+ $user = new self;
+ $user->load_from_row($row);
+
+ return $user;
+ }
+
+ /**
+ * Create a new user instance with arbitrary user_id
+ *
+ * The created user is not saved in the database.
*
- * @param int $id the primary key
+ * @param int $user_id A unassigned user ID
+ * @return self
*/
- function __construct ($id = null, DatabaseEngine $db = null) {
- $this->id = $id;
- $this->db = $db;
+ public static function create (int $user_id) : self {
+ $user = new self;
- if ($id) {
- $this->load_from_database();
- }
+ $user->id = $user_id;
+ $user->active = true;
+ $user->regdate = time();
+
+ return $user;
+ }
+
+ /**
+ * Creates a new anonymous user instance
+ */
+ public static function anonymous () : User {
+ return User::create(ANONYMOUS_USER);
}
+ ///
+ /// Load data
+ ///
+
/**
* Loads the object User (ie fill the properties) from the $_POST array
*/
function load_from_form () {
if (array_key_exists('name', $_POST)) $this->name = $_POST['name'];
if (array_key_exists('password', $_POST)) $this->password = $_POST['password'];
if (array_key_exists('active', $_POST)) $this->active = $_POST['active'];
if (array_key_exists('actkey', $_POST)) $this->actkey = $_POST['actkey'];
if (array_key_exists('email', $_POST)) $this->email = $_POST['email'];
if (array_key_exists('regdate', $_POST)) $this->regdate = $_POST['regdate'];
}
- /**
- * Loads the object User (ie fill the properties) from the database
- */
- function load_from_database () {
- $db = $this->db;
-
- $id = $this->db->escape($this->id);
- $sql = "SELECT * FROM " . TABLE_USERS . " WHERE user_id = '" . $id . "'";
- if ( !($result = $db->query($sql)) ) ErrorHandling::messageAndDie(SQL_ERROR, "Unable to query users", '', __LINE__, __FILE__, $sql);
- if (!$row = $db->fetchRow($result)) {
- $this->lastError = "User unknown: " . $this->id;
- return false;
- }
-
- $this->load_from_row($row);
-
- return true;
- }
-
/**
* Loads the object User (ie fill the properties) from the database row
*/
function load_from_row ($row) {
$this->id = $row['user_id'];
$this->name = $row['username'];
$this->password = $row['user_password'];
$this->active = $row['user_active'] ? true : false;
$this->email = $row['user_email'];
$this->regdate = $row['user_regdate'];
}
- /**
- * Saves to database
- */
- function save_to_database () {
- $db = $this->db;
-
- $id = $this->id ? "'" . $db->escape($this->id) . "'" : 'NULL';
- $name = $db->escape($this->name);
- $password = $db->escape($this->password);
- $active = $this->active ? 1 : 0;
- $email = $db->escape($this->email);
- $regdate = $this->regdate ? "'" . $db->escape($this->regdate) . "'" : 'NULL';
-
- //Updates or inserts
- $sql = "REPLACE INTO " . TABLE_USERS . " (`user_id`, `username`, `user_password`, `user_active`, `user_email`, `user_regdate`) VALUES ($id, '$name', '$password', $active, '$email', $regdate)";
- if (!$db->query($sql)) {
- ErrorHandling::messageAndDie(SQL_ERROR, "Unable to save user", '', __LINE__, __FILE__, $sql);
- }
-
- if (!$this->id) {
- //Gets new record id value
- $this->id = $db->nextId();
- }
- }
-
- /**
- * Updates the specified field in the database record
- */
- function save_field ($field) {
- $db = $this->db;
-
- if (!$this->id) {
- ErrorHandling::messageAndDie(GENERAL_ERROR, "You're trying to update a record not yet saved in the database");
- }
- $id = $db->escape($this->id);
- $value = $db->escape($this->$field);
- $sql = "UPDATE " . TABLE_USERS . " SET `$field` = '$value' WHERE user_id = '$id'";
- if (!$db->query($sql)) {
- ErrorHandling::messageAndDie(SQL_ERROR, "Unable to save $field field", '', __LINE__, __FILE__, $sql);
- }
- }
-
//
- // USER MANAGEMENT FUNCTIONS
+ // User properties
//
- /**
- * Generates a unique user id
- */
- function generate_id () {
- $db = $this->db;
-
- do {
- $this->id = mt_rand(2001, 9999);
- $sql = "SELECT COUNT(*) FROM " . TABLE_USERS . " WHERE user_id = $this->id";
- if (!$result = $db->query($sql)) {
- ErrorHandling::messageAndDie(SQL_ERROR, "Can't check if a user id is free", '', __LINE__, __FILE__, $sql);
- }
- $row = $db->fetchRow($result);
- } while ($row[0]);
- }
-
/**
* Fills password field with encrypted version
* of the specified clear password
*/
- public function set_password ($newpassword) {
- $this->password = md5($newpassword);
- }
-
- /**
- * Initializes a new User instance ready to have its property filled
- *
- * @return User the new user instance
- */
- public static function create (DatabaseEngine $db) {
- $user = new User(null, $db);
- $user->generate_id();
- $user->active = true;
- $user->regdate = time();
- return $user;
- }
-
- //
- // REMOTE IDENTITY PROVIDERS
- //
-
- /**
- * Sets user's remote identity provider identifiant
- *
- * @param $authType The authentication method type
- * @param $remoteUserId The remote user identifier
- * */
- public function setRemoteIdentity ($authType, $remoteUserId, $properties = null) {
- $db = $this->db;
-
- $authType = $db->escape($authType);
- $remoteUserId = $db->escape($remoteUserId);
- $properties = ($properties === NULL) ? 'NULL' : "'" . $db->escape($properties) . "'";
- $sql = "INSERT INTO " . TABLE_USERS_AUTH . " (auth_type, auth_identity, auth_properties, user_id) "
- . "VALUES ('$authType', '$remoteUserId', $properties, $this->id)";
- if (!$db->query($sql)) {
- ErrorHandling::messageAndDie(SQL_ERROR, "Can't set user remote identity provider information", '', __LINE__, __FILE__, $sql);
- }
+ public function setPassword ($password) {
+ $this->password = md5($password);
}
//
- // INTERACTION WITH OTHER OBJECTS
+ // Interaction with groups and permissions
//
/**
* Gets the groups where the current user has access to.
*
* @return array an array containing group_id, matching groups the current user has access to.
*/
public function get_groups () {
return self::get_groups_from_user_id($this->id, $this->db);
}
/**
* Determines if the user is a member of the specified group
*
* @param UserGroup $group The group to check
*/
public function isMemberOfGroup (UserGroup $group) {
$db = $this->db;
$sql = "SELECT count(*) FROM users_groups_members WHERE group_id = $group->id AND user_id = $this->id";
if (!$result = $db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR, "Can't determine if the user belongs to the group", '', __LINE__, __FILE__, $sql);
}
$row = $db->fetchRow($result);
return $row[0] == 1;
}
/**
* Adds user to the specified group
*
* @param UserGroup $group The group where to add the user
* @parap boolean $isAdmin if true, set the user admin; otherwise, set it regular user.
*/
public function addToGroup (UserGroup $group, $isAdmin = false) {
$db = $this->db;
$isAdmin = $isAdmin ? 1 : 0;
$sql = "REPLACE INTO users_groups_members VALUES ($group->id, $this->id, $isAdmin)";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR, "Can't add user to group", '', __LINE__, __FILE__, $sql);
}
}
/**
* Gets the SQL permission clause to select resources where the user is the subject.
*
* @return string The SQL WHERE clause
*/
public function get_permissions_clause () {
return self::get_permissions_clause_from_user_id($this->id, $this->db);
}
/**
* Gets workspaces this user has access to.
*
* @return Array A list of workspaces
*/
public function get_workspaces () {
if ($this->workspaces === null) {
$this->workspaces = Workspace::get_user_workspaces($this->id);
}
return $this->workspaces;
}
/**
* Sets user permission
*
* @param string $resourceType The target resource type
* @param int $resourceId The target resource ID
* @param string $permissionName The permission name
* @param int $permissionFlag The permission flag (facultative; by default, 1)
*/
public function setPermission ($resourceType, $resourceId, $permissionName, $permissionFlag = 1) {
$db = $this->db;
$resourceType = $db->escape($resourceType);
if (!is_numeric($resourceId)) {
throw new Exception("Resource ID must be a positive or null integer, and not $resourceId.");
}
$permissionName = $db->escape($permissionName);
if (!is_numeric($permissionFlag)) {
throw new Exception("Permission flag must be a positive or null integer, and not $permissionFlag.");
}
$sql = "REPLACE INTO permissions
(subject_resource_type, subject_resource_id,
target_resource_type, target_resource_id,
permission_name, permission_flag)
VALUES
('U', $this->id,
'$resourceType', $resourceId,
'$permissionName', $permissionFlag)";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR, "Can't set user permission", '', __LINE__, __FILE__, $sql);
}
}
/**
* Gets the groups where a user has access to.
*
* @param int $user_id the user to get the groups list
* @return array an array containing group_id, matching groups the specified user has access to.
*/
public static function get_groups_from_user_id ($user_id, DatabaseEngine $db) {
$sql = "SELECT group_id FROM " . TABLE_UGROUPS_MEMBERS . " WHERE user_id = " . $user_id;
if (!$result = $db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR, "Can't get user groups", '', __LINE__, __FILE__, $sql);
}
$gids = array();
while ($row = $db->fetchRow($result)) {
$gids[] = $row['group_id'];
}
return $gids;
}
/**
* Gets the SQL permission clause to select resources where the specified user is the subject.
*
* @param $user_id The user ID
* @return string The SQL WHERE clause
*/
public static function get_permissions_clause_from_user_id ($user_id, DatabaseEngine $db) {
$clause = "subject_resource_type = 'U' AND subject_resource_id = $user_id";
if ($groups = self::get_groups_from_user_id ($user_id, $db)) {
$clause = "($clause) OR (subject_resource_type = 'G' AND subject_resource_id = ";
$clause .= join(") OR (subject_resource_type = 'G' AND subject_resource_id = ", $groups);
$clause .= ')';
}
return $clause;
}
}
diff --git a/workspaces/src/Engines/Users/UserRepository.php b/workspaces/src/Engines/Users/UserRepository.php
index d3315fc..1be0cc5 100644
--- a/workspaces/src/Engines/Users/UserRepository.php
+++ b/workspaces/src/Engines/Users/UserRepository.php
@@ -1,134 +1,255 @@
<?php
namespace Waystone\Workspaces\Engines\Users;
use Waystone\Workspaces\Engines\Errors\ErrorHandling;
+use Waystone\Workspaces\Engines\Exceptions\UserNotFoundException;
use Waystone\Workspaces\Engines\Framework\Repository;
use Keruald\Database\Exceptions\SqlException;
use Keruald\OmniTools\DataTypes\Option\None;
use Keruald\OmniTools\DataTypes\Option\Option;
use Keruald\OmniTools\DataTypes\Option\Some;
-use User;
+use RuntimeException;
class UserRepository extends Repository {
///
/// Find user in database
///
public function resolveUserID (string $expression) : Option {
return $this->getUserFromUsername($expression)
->orElse(fn() => $this->getUserFromEmail($expression))
->map(fn($user) => $user->id);
}
/**
* @return Option<User>
*/
private function getByProperty (string $property, mixed $value) : Option {
$value = $this->db->escape($value);
$sql = "SELECT * FROM " . TABLE_USERS . " WHERE $property = '$value'";
if (!$result = $this->db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR, "Can't get user", '', __LINE__, __FILE__, $sql);
}
$row = $this->db->fetchRow($result);
if (!$row) {
return new None;
}
- $user = new User(null, $this->db);
- $user->load_from_row($row);
+ $user = User::fromRow($row);
$this->table[$user->id] = $user;
return new Some($user);
}
/**
* Gets user from specified e-mail
*
* @return Option<User> the user matching the specified e-mail; None, if the mail were not found.
*/
public function getUserFromEmail (string $mail) : Option {
return $this->lookupInTable("email", $mail)
->orElse(fn () => $this->getByProperty("user_email", $mail));
}
/**
* @return Option<User>
*/
public function getUserFromUsername (string $username) : Option {
return $this->lookupInTable("name", $username)
->orElse(fn () => $this->getByProperty("username", $username));
}
/**
* Gets user from remote identity provider identifiant
*
* @param string $authType The authentication method type
* @param string $remoteUserId The remote user identifier
* @return Option<User> the user matching the specified identity provider and identifiant; None if no user were found.
*/
public function getUserFromRemoteIdentity (string $authType, string $remoteUserId) : Option {
$authType = $this->db->escape($authType);
$remoteUserId = $this->db->escape($remoteUserId);
$sql = "SELECT user_id FROM " . TABLE_USERS_AUTH . " WHERE "
. "auth_type = '$authType' AND auth_identity = '$remoteUserId'";
try {
$result = $this->db->queryScalar($sql);
} catch (SqlException $ex) {
ErrorHandling::messageAndDie(SQL_ERROR, $ex->getMessage(), "Can't get user", __LINE__, __FILE__, $sql);
}
return Option::from($result)
->map(fn($user_id) => $this->get($user_id));
}
///
/// Registration facilities
///
/**
* Checks if a username is still available
*/
public function isAvailableUsername (string $login) : bool {
$login = $this->db->escape($login);
$sql = "SELECT COUNT(*) FROM " . TABLE_USERS
. " WHERE username = '$login'";
try {
$result = $this->db->queryScalar($sql);
} catch (SqlException $ex) {
ErrorHandling::messageAndDie(SQL_ERROR, "Can't check if the specified login is available", '', __LINE__, __FILE__, $sql);
}
return $result == 0;
}
///
/// Load object
///
/**
* Gets an instance of the class from the table or loads it from database.
*
* @param int $id the user ID
+ *
* @return User the user instance
+ * @throws Exception when the user is not found
*/
public function get (int $id) : User {
if ($this->table->has($id)) {
return $this->table[$id];
}
- $user = new User($id, $this->db);
+ $user = $this->loadFromDatabase($id);
+ if ($user->isNone()) {
+ throw new UserNotFoundException;
+ }
+
+ $user = $user->getValue();
$this->table[$id] = $user;
return $user;
}
+ /**
+ * Loads the object User (ie fill the properties) from the database
+ *
+ * @return Option<User> the user instance, or None if not found
+ */
+ private function loadFromDatabase (int $id) : Option {
+ $db = $this->db;
+
+ $sql = "SELECT * FROM " . TABLE_USERS . " WHERE user_id = '" . $id . "'";
+ if (!$result = $db->query($sql)) {
+ ErrorHandling::messageAndDie(SQL_ERROR, "Unable to query users", '', __LINE__, __FILE__, $sql);
+ }
+
+ $row = $db->fetchRow($result);
+ if (!$row) {
+ return new None;
+ }
+
+ return new Some(User::fromRow($row));
+ }
+
+ ///
+ /// Create object
+ ///
+
+ /**
+ * Initializes a new User instance ready to have its property filled
+ *
+ * @return User the new user instance
+ */
+ public function create () : User {
+ $id = $this->generateId();
+
+ return User::create($id);
+ }
+
+ /**
+ * Generates a unique user id
+ */
+ private function generateId () : int {
+ $db = $this->db;
+
+ do {
+ $id = mt_rand(2001, 9999);
+ $sql = "SELECT COUNT(*) FROM " . TABLE_USERS . " WHERE user_id = $this->id";
+
+ try {
+ $result = $db->queryScalar($sql);
+ } catch (SqlException) {
+ ErrorHandling::messageAndDie(SQL_ERROR, "Can't check if a user id is free", '', __LINE__, __FILE__, $sql);
+ }
+ } while ($result);
+
+ return $id;
+ }
+
+ ///
+ /// Save object
+ ///
+
+ /**
+ * Saves to database
+ */
+ function saveToDatabase (User $user) : void {
+ $db = $this->db;
+
+ $id = $user->id ? "'" . $db->escape($user->id) . "'" : 'NULL';
+ $name = $db->escape($user->name);
+ $password = $db->escape($user->password);
+ $active = $user->active ? 1 : 0;
+ $email = $db->escape($user->email);
+ $regdate = $user->regdate ? "'" . $db->escape($user->regdate) . "'" : 'NULL';
+
+ //Updates or inserts
+ $sql = "REPLACE INTO " . TABLE_USERS . " (`user_id`, `username`, `user_password`, `user_active`, `user_email`, `user_regdate`) VALUES ($id, '$name', '$password', $active, '$email', $regdate)";
+ if (!$db->query($sql)) {
+ ErrorHandling::messageAndDie(SQL_ERROR, "Unable to save user", '', __LINE__, __FILE__, $sql);
+ }
+
+ if (!$user->id) {
+ //Gets new record id value
+ $user->id = $db->nextId();
+ }
+ }
+
+ //
+ // User authentication
+ //
+
+ /**
+ * Sets user's remote identity provider identifiant
+ *
+ * @param User $user
+ * @param string $authType The authentication method type
+ * @param string $remoteUserId The remote user identifier
+ * @param array $properties The authentication method properties
+ */
+ public function setRemoteIdentity (User $user, string $authType, string $remoteUserId, array $properties = []) : void {
+ $db = $this->db;
+
+ if ($properties != []) {
+ throw new RuntimeException("The remote identity provider properties have not been implemented yet.");
+ }
+
+ $authType = $db->escape($authType);
+ $remoteUserId = $db->escape($remoteUserId);
+ $properties = "NULL";
+ $sql = "INSERT INTO " . TABLE_USERS_AUTH . " (auth_type, auth_identity, auth_properties, user_id) "
+ . "VALUES ('$authType', '$remoteUserId', $properties, $user->id)";
+ if (!$db->query($sql)) {
+ ErrorHandling::messageAndDie(SQL_ERROR, "Can't set user remote identity provider information", '', __LINE__, __FILE__, $sql);
+ }
+ }
+
}
diff --git a/workspaces/src/Engines/Workspaces/Workspace.php b/workspaces/src/Engines/Workspaces/Workspace.php
index a68b265..4656c0f 100644
--- a/workspaces/src/Engines/Workspaces/Workspace.php
+++ b/workspaces/src/Engines/Workspaces/Workspace.php
@@ -1,280 +1,280 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* Workspace class
*
* @package ObsidianWorkspaces
* @subpackage Workspaces
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*/
namespace Waystone\Workspaces\Engines\Workspaces;
use Waystone\Workspaces\Engines\Errors\ErrorHandling;
use Waystone\Workspaces\Engines\Framework\Context;
+use Waystone\Workspaces\Engines\Users\User;
use Cache;
use Language;
-use User;
use Exception;
use LogicException;
/**
* Workspace class
*
* This class maps the workspaces table.
*/
class Workspace {
public $id;
public $code;
public $name;
public $created;
public $description;
/**
* @var WorkspaceConfiguration The workspace configuration
*/
public $configuration;
/**
* Initializes a new instance
*
* @param int $id the primary key
*/
function __construct ($id = null) {
if ($id) {
$this->id = $id;
$this->load_from_database();
}
}
/**
* Loads the object Workspace (ie fill the properties) from the $_POST array
*/
function load_from_form () {
if (array_key_exists('code', $_POST)) {
$this->code = $_POST['code'];
}
if (array_key_exists('name', $_POST)) {
$this->name = $_POST['name'];
}
if (array_key_exists('created', $_POST)) {
$this->created = $_POST['created'];
}
if (array_key_exists('description', $_POST)) {
$this->description = $_POST['description'];
}
}
/**
* Loads the object zone (ie fill the properties) from the $row array
*/
function load_from_row ($row) {
$this->id = $row['workspace_id'];
$this->code = $row['workspace_code'];
$this->name = $row['workspace_name'];
$this->created = $row['workspace_created'];
$this->description = $row['workspace_description'];
}
/**
* Loads the specified workspace from code
*
* @param string $code The workspace code
*
* @return Workspace The specified workspace instance
*/
public static function fromCode ($code) {
global $db;
$code = $db->escape($code);
$sql = "SELECT * FROM " . TABLE_WORKSPACES . " WHERE workspace_code = '"
. $code . "'";
if (!$result = $db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Unable to query workspaces", '', __LINE__, __FILE__, $sql);
}
if (!$row = $db->fetchRow($result)) {
throw new Exception("Workspace unknown: " . $code);
}
$workspace = new Workspace();
$workspace->load_from_row($row);
return $workspace;
}
/**
* Loads the object Workspace (ie fill the properties) from the database
*/
function load_from_database () {
global $db;
$id = $db->escape($this->id);
$sql = "SELECT * FROM " . TABLE_WORKSPACES . " WHERE workspace_id = '"
. $id . "'";
if (!$result = $db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Unable to query workspaces", '', __LINE__, __FILE__, $sql);
}
if (!$row = $db->fetchRow($result)) {
$this->lastError = "Workspace unknown: " . $this->id;
return false;
}
$this->load_from_row($row);
return true;
}
/**
* Saves to database
*/
function save_to_database () {
global $db;
$id = $this->id ? "'" . $db->escape($this->id) . "'" : 'NULL';
$code = $db->escape($this->code);
$name = $db->escape($this->name);
$created = $db->escape($this->created);
$description = $db->escape($this->description);
//Updates or inserts
$sql = "REPLACE INTO " . TABLE_WORKSPACES
. " (`workspace_id`, `workspace_code`, `workspace_name`, `workspace_created`, `workspace_description`) VALUES ('$id', '$code', '$name', '$created', '$description')";
if (!$db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR, "Unable to save", '',
__LINE__, __FILE__, $sql);
}
if (!$this->id) {
//Gets new record id value
$this->id = $db->nextId();
}
}
/**
* Determines if the specified user has access to the current workspace
*
* @param User $user The user to check
*
* @return boolean true if the user has access to the current workspace ;
* otherwise, false.
*/
public function userCanAccess (User $user) {
if ($this->id === false || $this->id === null || $this->id === '') {
throw new LogicException("The workspace must has a valid id before to call userCanAccess.");
}
foreach ($user->get_workspaces() as $workspace) {
if ($workspace->id == $this->id) {
return true;
}
}
return false;
}
/**
* Loads configuration
*
* @param Context $context The site context
*/
public function loadConfiguration (Context $context) {
global $Config;
$dir = $Config['Content']['Workspaces'] . '/' . $this->code;
// Load JSON configuration file
$file = $dir . '/workspace.conf';
if (file_exists($file)) {
$this->configuration =
WorkspaceConfiguration::loadFromFile($file, $context);
return;
}
// Load YAML configuration file
$file = $dir . '/workspace.yml';
if (file_exists($file)) {
$this->configuration =
WorkspaceConfiguration::loadFromYamlFile($file, $context);
return;
}
$exceptionMessage =
sprintf(Language::get('NotConfiguredWorkspace'), $file);
throw new Exception($exceptionMessage);
}
/**
* Gets workspaces specified user has access to.
*
* @param int $user_id The user to get his workspaces
*
* @return Workspace[] A list of workspaces
*/
public static function get_user_workspaces ($user_id) {
global $db;
//Gets the workspaces list from cache, as this complex request could take 100ms
//and is called on every page.
$cache = Cache::load();
if (!$workspaces = unserialize($cache->get("workspaces-$user_id"))) {
$clause = User::get_permissions_clause_from_user_id($user_id, $db);
$sql = "SELECT DISTINCT w.*
FROM " . TABLE_PERMISSIONS . " p, " . TABLE_WORKSPACES . " w
WHERE p.target_resource_type = 'W' AND
p.target_resource_id = w.workspace_id AND
p.permission_name = 'accessLevel' AND
p.permission_flag > 0 AND
($clause)";
if (!$result = $db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Can't get user workspaces", '', __LINE__, __FILE__, $sql);
}
$workspaces = [];
while ($row = $db->fetchRow($result)) {
$workspace = new Workspace();
$workspace->id = $row['workspace_id'];
$workspace->load_from_row($row);
$workspaces[] = $workspace;
}
$cache->set("workspaces-$user_id", serialize($workspaces));
}
return $workspaces;
}
/**
* Determines if a string matches an existing workspace code.
*
* @param string $code The workspace code to check
*
* @return boolean If the specified code matches an existing workspace,
* true; otherwise, false.
*/
public static function is_workspace ($code) {
global $db;
$code = $db->escape($code);
$sql = "SELECT count(*) FROM " . TABLE_WORKSPACES
. " WHERE workspace_code = '$code'";
if (!$result = $db->query($sql)) {
ErrorHandling::messageAndDie(SQL_ERROR,
"Can't check workspace code", '', __LINE__, __FILE__, $sql);
}
$row = $db->fetchRow($result);
return ($row[0] == 1);
}
}
diff --git a/workspaces/src/includes/autoload.php b/workspaces/src/includes/autoload.php
index ad368ce..e285a2f 100644
--- a/workspaces/src/includes/autoload.php
+++ b/workspaces/src/includes/autoload.php
@@ -1,66 +1,65 @@
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* Classes and interfaces auto loader
*
* @package ObsidianWorkspaces
* @filesource
*/
/**
* This SPL autoloader method is called when a class or an interface can't be loaded.
*/
function obsidian_autoload ($name) {
$dir = dirname(__DIR__);
///
/// Applications
///
if ($name == 'Document') { require $dir . '/apps/documents/Document.php'; return true; }
if ($name == 'DocumentsApplication') { require $dir . '/apps/documents/DocumentsApplication.php'; return true; }
if ($name == 'DocumentsApplicationConfiguration') { require $dir . '/apps/documents/DocumentsApplicationConfiguration.php'; return true; }
if ($name == 'DocumentType') { require $dir . '/apps/documents/DocumentType.php'; return true; }
if ($name == 'HelloWorldApplication') { require $dir . '/apps/helloworld/HelloWorldApplication.php'; return true; }
if ($name == 'MediaWikiMirrorApplication') { require $dir . '/apps/mediawikimirror/MediaWikiMirrorApplication.php'; return true; }
if ($name == 'MediaWikiMirrorApplicationConfiguration') { require $dir . '/apps/mediawikimirror/MediaWikiMirrorApplicationConfiguration.php'; return true; }
if ($name == 'StaticContentApplication') { require $dir . '/apps/staticcontent/StaticContentApplication.php'; return true; }
if ($name == 'StaticContentApplicationConfiguration') { require $dir . '/apps/staticcontent/StaticContentApplicationConfiguration.php'; return true; }
///
/// Core controllers
///
if ($name == 'ErrorPageController') { require $dir . '/controllers/errorpage.php'; return true; }
if ($name == 'FooterController') { require $dir . '/controllers/footer.php'; return true; }
if ($name == 'HeaderController') { require $dir . '/controllers/header.php'; return true; }
if ($name == 'HomepageController') { require $dir . '/controllers/home.php'; return true; }
///
/// Keruald and Obsidian Workspaces libraries
///
if ($name == 'Cache') { require $dir . '/includes/cache/cache.php'; return true; }
if ($name == 'CacheMemcached') { require $dir . '/includes/cache/memcached.php'; return true; }
if ($name == 'CacheVoid') { require $dir . '/includes/cache/void.php'; return true; }
if ($name == 'Language') { require $dir . '/includes/i18n/Language.php'; return true; }
if ($name == 'Message') { require $dir . '/includes/i18n/Message.php'; return true; }
if ($name == 'TextFileMessage') { require $dir . '/includes/i18n/TextFileMessage.php'; return true; }
if ($name == 'Disclaimer') { require $dir . '/includes/objects/Disclaimer.php'; return true; }
- if ($name == 'User') { require $dir . '/includes/objects/user.php'; return true; }
if ($name == 'UserGroup') { require $dir . '/includes/objects/usergroup.php'; return true; }
return false;
}
spl_autoload_register('obsidian_autoload');

File Metadata

Mime Type
text/x-diff
Expires
Wed, Mar 18, 12:51 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3539860
Default Alt Text
(57 KB)

Event Timeline