From 4f0b753fa72e8cb389c5caf285c766a48881959c Mon Sep 17 00:00:00 2001 From: Laurent Opprecht Date: Thu, 12 Apr 2012 15:28:50 +0200 Subject: [PATCH] shibboleth authentication module #4554: add admin model --- .../auth/shibboleth/app/model/admin.class.php | 42 ++++++ .../app/model/scaffold/admin.class.php | 131 ++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 main/auth/shibboleth/app/model/admin.class.php create mode 100644 main/auth/shibboleth/app/model/scaffold/admin.class.php diff --git a/main/auth/shibboleth/app/model/admin.class.php b/main/auth/shibboleth/app/model/admin.class.php new file mode 100644 index 0000000000..59266aec3e --- /dev/null +++ b/main/auth/shibboleth/app/model/admin.class.php @@ -0,0 +1,42 @@ +, Nicolas Rod for the University of Geneva + */ +class Admin extends _Admin +{ + +} + +/** + * Store for Admin objects. Interact with the database. Allows to save and retrieve + * admin objects. + * + * Should be moved to the core. It only exists because it is not available through + * the API. + * + * The _AdminStore objet is generated by the scaffolder. This class inherits from it to allow + * modifications without touching the generated file. Don't modify the _ object as + * it may change in the future. Instead add modifications to this class. + * + * @copyright (c) 2012 University of Geneva + * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html + * @author Laurent Opprecht + */ +class AdminStore extends _AdminStore +{ + + +} \ No newline at end of file diff --git a/main/auth/shibboleth/app/model/scaffold/admin.class.php b/main/auth/shibboleth/app/model/scaffold/admin.class.php new file mode 100644 index 0000000000..8b33d95fd5 --- /dev/null +++ b/main/auth/shibboleth/app/model/scaffold/admin.class.php @@ -0,0 +1,131 @@ +, Nicolas Rod for the University of Geneva + */ +class _Admin +{ + + /** + * Store for Admin objects. Interact with the database. + * + * @return AdminStore + */ + public static function store() + { + static $result = false; + if (empty($result)) + { + $result = new AdminStore(); + } + return $result; + } + + /** + * + * @return Admin + */ + public static function create($data = null) + { + return self::store()->create_object($data); + } + + public $user_id = null; + + + /** + * + * @return bool + */ + public function save() + { + return self::store()->save($this); + } + +} + +/** + * Store for Admin objects. Interact with the database. + * + * @copyright (c) 2012 University of Geneva + * @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html + * @author Laurent Opprecht + */ +class _AdminStore extends Store +{ + + /** + * + * @return AdminStore + */ + public static function instance() + { + static $result = false; + if (empty($result)) + { + $result = new self(); + } + return $result; + } + + public function __construct() + { + parent::__construct('admin', 'Admin', 'user_id'); + } + + /** + * + * @return Admin + */ + public function get($w) + { + $args = func_get_args(); + $f = array('parent', 'get'); + return call_user_func_array($f, $args); + } + + /** + * + * @return Admin + */ + public function create_object($data) + { + return parent::create_object($data); + } + + /** + * + * @return Admin + */ + public function get_by_user_id($value) + { + return $this->get(array('user_id' => $value)); + } + + /** + * + * @return bool + */ + public function user_id_exists($value) + { + return $this->exist(array('user_id' => $value)); + } + + /** + * + * @return bool + */ + public function delete_by_user_id($value) + { + return $this->delete(array('user_id' => $value)); + } + + +} \ No newline at end of file