diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /lib/models/LockRule.class.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/models/LockRule.class.php')
| -rw-r--r-- | lib/models/LockRule.class.php | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/lib/models/LockRule.class.php b/lib/models/LockRule.class.php deleted file mode 100644 index a3ef271..0000000 --- a/lib/models/LockRule.class.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * LockRule.class.php - * model class for table lock_rule - * this class represents one record of the lock_rules table - * the column attributes is converted to an ArrayObject and vice-versa, - * to allow array-like access - * - * e.g. - * @code - * $lockrule = LockRule::find($id); - * $lockrule['attributes']['name'] = 1; - * $lockrule->store(); - * @endcode - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * @author André Noack <noack@data-quest.de> - * @copyright 2011 Stud.IP Core-Group - * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 - * @category Stud.IP - * - * @property string $id alias column for lock_id - * @property string $lock_id database column - * @property string $permission database column - * @property string $name database column - * @property string $description database column - * @property JSONArrayObject $attributes database column - * @property string $object_type database column - * @property string $user_id database column - * @property int|null $mkdate database column - * @property int|null $chdate database column - */ - -class LockRule extends SimpleORMap -{ - protected static function configure($config = []) - { - $config['db_table'] = 'lock_rules'; - - $config['serialized_fields']['attributes'] = JSONArrayObject::class; - - parent::configure($config); - } - - /** - * returns the lockrule for a course - * - * @param string $seminar_id id of a course - * @return LockRule - */ - static function findBySeminar($seminar_id) - { - $db = DBManager::get(); - $lock_rule_id = $db->query("SELECT lock_rule FROM seminare WHERE seminar_id = " . $db->quote($seminar_id)) - ->fetchColumn(); - return self::find($lock_rule_id); - } - - /** - * returns the lockrule for an institute - * - * @param string $institute_id id of an institute - * @return LockRule - */ - static function findByInstitute($institute_id) - { - $db = DBManager::get(); - $lock_rule_id = $db->query("SELECT lock_rule FROM Institute WHERE Institut_id = " . $db->quote($institute_id)) - ->fetchColumn(); - return self::find($lock_rule_id); - } - - /** - * returns the lockrule for a user - * - * @param string $user_id id of a user - * @return LockRule - */ - static function findByUser($user_id) - { - $db = DBManager::get(); - $lock_rule_id = $db->query("SELECT lock_rule FROM user_info WHERE user_id = " . $db->quote($user_id)) - ->fetchColumn(); - return self::find($lock_rule_id); - } - - /** - * returns all exisiting lockrules for a given entity type - * - * @param string $type entity type, one of [sem,inst,user] - * @return array of LockRule objects - */ - static function findAllByType($type) - { - return self::findByObject_type($type, " ORDER BY name"); - } - /** - * @see SimpleORMap::delete() - */ - function delete() - { - $id = $this->getId(); - $object_type = $this->object_type; - $ret = parent::delete(); - - $db = DBManager::get(); - $tables['sem'] = 'seminare'; - $tables['inst'] = 'Institute'; - $tables['user'] = 'user_info'; - $db->exec("UPDATE " . $tables[$object_type] . " SET lock_rule='' WHERE lock_rule = " . $db->quote($id)); - return $ret; - } - - /** - * returns the number of uses for this lockrule - * - * @return integer - */ - function getUsage() - { - if (!$this->isNew()) { - $db = DBManager::get(); - $tables['sem'] = 'seminare'; - $tables['inst'] = 'Institute'; - $tables['user'] = 'user_info'; - return $db->query("SELECT COUNT(*) FROM " . $tables[$this->object_type] . " WHERE lock_rule = " . $db->quote($this->getId()))->fetchColumn(); - } else { - return 0; - } - } -} |
