summaryrefslogtreecommitdiff
path: root/manager/application/models/User.php
diff options
context:
space:
mode:
Diffstat (limited to 'manager/application/models/User.php')
-rw-r--r--manager/application/models/User.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/manager/application/models/User.php b/manager/application/models/User.php
index 27f8a44..b8285a4 100644
--- a/manager/application/models/User.php
+++ b/manager/application/models/User.php
@@ -406,4 +406,70 @@ class Default_Model_User {
$this->fixAssurerFlag();
}
+
+ /**
+ * Get the flags that are set
+ *
+ * @return array (string => boolean)
+ */
+ public function getFlags() {
+ $flags = $this->db->select()->from('users', self::flags())
+ ->where('`id` = ?', $this->id)->query()->fetch();
+
+ foreach ($flags as $key => $value) {
+ if ($value === '0') {
+ $flags[$key] = false;
+ } else {
+ $flags[$key] = true;
+ }
+ }
+
+ return $flags;
+ }
+
+ /**
+ * Set the flags - to know which flags exist you might want to call
+ * getFlags() first
+ *
+ * @param $flags array (string => boolean)
+ * Currently unknown flags are silently ignored
+ */
+ public function setFlags(array $flags) {
+ $newflags = array();
+
+ // filter values
+ foreach (self::flags() as $flag) {
+ if (isset($flags[$flag])) {
+ if ($flags[$flag]) {
+ $newflags[$flag] = 1;
+ } else {
+ $newflags[$flag] = 0;
+ }
+ }
+ }
+
+ $where = $this->db->quoteInto('`id` = ?', $this->id, Zend_Db::INT_TYPE);
+ $this->db->update('users', $newflags, $where);
+ }
+
+ /**
+ * The flags from the `users` table that might be set
+ */
+ private static function flags() {
+ return array(
+ 'verified',
+ 'listme',
+ 'codesign',
+ '1024bit',
+ 'admin',
+ 'orgadmin',
+ 'ttpadmin',
+ 'adadmin',
+ 'board',
+ 'tverify',
+ 'locadmin',
+ 'locked',
+ 'assurer',
+ 'assurer_blocked');
+ }
} \ No newline at end of file