+ /**
+ * Adds properties to the object; this method does not allow the caller to
+ * update core properties (id, ...).
+ *
+ * @param $values An associative array of non-core properties.
+ */
+ public function addProperties(array $values)
+ {
+ foreach ($values as $key => $value) {
+ if (!property_exists($this, $key)) {
+ $this->data[$key] = $value;
+ }
+ }
+ }
+
+
+ /**
+ * Build the permissions flags for the user.
+ */
+ abstract protected function buildPerms();
+
+ /**
+ * Check wether the user got the given permission combination.
+ */
+ public function checkPerms($perms)
+ {
+ if (is_null($this->perm_flags)) {
+ $this->buildPerms();
+ }
+ if (is_null($this->perm_flags)) {
+ return false;
+ }
+ return $this->perm_flags->hasFlagCombination($perms);
+ }
+