summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/libraries')
-rw-r--r--modules/gallery/libraries/Identity.php34
-rw-r--r--modules/gallery/libraries/drivers/Identity.php196
2 files changed, 16 insertions, 214 deletions
diff --git a/modules/gallery/libraries/Identity.php b/modules/gallery/libraries/Identity.php
index 9e5f0bb5..e77fd2d2 100644
--- a/modules/gallery/libraries/Identity.php
+++ b/modules/gallery/libraries/Identity.php
@@ -133,37 +133,17 @@ class Identity_Core {
}
/**
- * @see Identity_Driver::hash_password.
- */
- static function hash_password($password) {
- return self::instance()->driver->hash_password($password);
- }
-
- /**
- * Look up a user by id.
- * @param integer $id the user id
- * @return User_Definition the user object, or null if the id was invalid.
+ * @see Identity_Driver::lookup_user.
*/
static function lookup_user($id) {
- return self::instance()->driver->lookup_user_by_field("id", $id);
+ return self::instance()->driver->lookup_user($id);
}
/**
- * Look up a user by name.
- * @param integer $name the user name
- * @return User_Definition the user object, or null if the name was invalid.
+ * @see Identity_Driver::lookup_user_by_name.
*/
static function lookup_user_by_name($name) {
- return self::instance()->driver->lookup_user_by_field("name", $name);
- }
-
- /**
- * Look up a user by hash.
- * @param string $name the user name
- * @return User_Definition the user object, or null if the name was invalid.
- */
- static function lookup_user_by_hash($hash) {
- return self::instance()->driver->lookup_user_by_field("hash", $hash);
+ return self::instance()->driver->lookup_user_by_name($name);
}
/**
@@ -188,12 +168,10 @@ class Identity_Core {
}
/**
- * Look up a group by name.
- * @param integer $id the group name
- * @return Group_Definition the group object, or null if the name was invalid.
+ * @see Identity_Driver::lookup_group_by_name.
*/
static function lookup_group_by_name($name) {
- return self::instance()->driver->lookup_group_by_field("name", $name);
+ return self::instance()->driver->lookup_group_by_name($name);
}
/**
diff --git a/modules/gallery/libraries/drivers/Identity.php b/modules/gallery/libraries/drivers/Identity.php
index a9e1a75b..6ab001cb 100644
--- a/modules/gallery/libraries/drivers/Identity.php
+++ b/modules/gallery/libraries/drivers/Identity.php
@@ -45,19 +45,18 @@ interface Identity_Driver {
public function is_correct_password($user, $password);
/**
- * Create the hashed passwords.
- * @param string $password a plaintext password
- * @return string hashed password
+ * Look up a user by id.
+ * @param integer id
+ * @return User_Definition the user object, or null if the name was invalid.
*/
- public function hash_password($password);
+ public function lookup_user($id);
/**
- * Look up a user by by search the specified field.
- * @param string search field
- * @param string search value
- * @return User_Definition the user object, or null if the name was invalid.
+ * Look up a user by name.
+ * @param string name
+ * @return User_Definition the user object, or null if the name was invalid.
*/
- public function lookup_user_by_field($field, $value);
+ public function lookup_user_by_name($name);
/**
* Create a new group.
@@ -90,181 +89,6 @@ interface Identity_Driver {
} // End Identity Driver Definition
-/**
- * User Data wrapper
- */
-abstract class User_Definition {
- protected $user;
- public function __get($column) {
- switch ($column) {
- case "id":
- case "name":
- case "full_name":
- case "password":
- case "login_count":
- case "last_login":
- case "email":
- case "admin":
- case "guest":
- case "hash":
- case "url":
- case "locale":
- case "groups":
- case "hashed_password":
- return $this->user->$column;
- default:
- throw new Exception("@todo UNSUPPORTED FIELD: $column");
- break;
- }
- }
-
- public function __set($column, $value) {
- switch ($column) {
- case "id":
- case "groups":
- throw new Exception("@todo READ ONLY FIELD: $column");
- break;
- case "name":
- case "full_name":
- case "hashed_password":
- case "password":
- case "login_count":
- case "last_login":
- case "email":
- case "admin":
- case "guest":
- case "hash":
- case "url":
- case "locale":
- $this->user->$column = $value;
- break;
- default:
- throw new Exception("@todo UNSUPPORTED FIELD: $column");
- break;
- }
- }
-
- public function __isset($column) {
- return isset($this->user->$column);
- }
-
- public function __unset($column) {
- switch ($column) {
- case "id":
- case "groups":
- throw new Exception("@todo READ ONLY FIELD: $column");
- break;
- case "name":
- case "full_name":
- case "password":
- case "login_count":
- case "last_login":
- case "email":
- case "admin":
- case "guest":
- case "hash":
- case "url":
- case "locale":
- case "hashed_password":
- unset($this->user->$column);
- break;
- default:
- throw new Exception("@todo UNSUPPORTED FIELD: $column");
- break;
- }
- }
-
- /**
- * Return a url to the user's avatar image.
- * @param integer $size the target size of the image (default 80px)
- * @return string a url
- */
- abstract public function avatar_url($size=80, $default=null);
-
- /**
- * Return the best version of the user's name. Either their specified full name, or fall back
- * to the user name.
- * @return string
- */
- abstract public function display_name();
-
- /**
- * Return the internal user object without the wrapper.
- * This method is used by implementing classes to access the internal user object.
- * Consider it pseudo private and only declared public as PHP as not internal or friend modifier
- */
- public function _uncloaked() {
- return $this->user;
- }
-
- abstract public function save();
- abstract public function delete();
-}
-
-/**
- * Group Data wrapper
- */
-abstract class Group_Definition {
- protected $group;
-
- public function __get($column) {
- switch ($column) {
- case "id":
- case "name":
- case "special":
- case "users":
- return $this->group->$column;
- default:
- throw new Exception("@todo UNSUPPORTED FIELD: $column");
- break;
- }
- }
-
- public function __set($column, $value) {
- switch ($column) {
- case "id":
- case "users":
- throw new Exception("@todo READ ONLY FIELD: $column");
- break;
- case "name":
- case "special":
- $this->group->$column = $value;
- default:
- throw new Exception("@todo UNSUPPORTED FIELD: $column");
- break;
- }
- }
-
- public function __isset($column) {
- return isset($this->group->$column);
- }
-
- public function __unset($column) {
- switch ($column) {
- case "id":
- case "users":
- throw new Exception("@todo READ ONLY FIELD: $column");
- break;
- case "name":
- case "special":
- unset($this->group->$column);
- default:
- throw new Exception("@todo UNSUPPORTED FIELD: $column");
- break;
- }
- }
-
- /**
- * Return the internal group object without the wrapper.
- * This method is used by implementing classes to access the internal group object.
- * Consider it pseudo private and only declared public as PHP as not internal or friend modifier
- */
- public function _uncloaked() {
- return $this->group;
- }
+interface Group_Definition {}
- abstract public function save();
- abstract public function delete();
- abstract public function add($user);
- abstract public function remove($user);
-}
+interface User_Definition {}