Index: deki_user.php
===================================================================
--- deki_user.php (revision 19997)
+++ deki_user.php (working copy)
@@ -58,8 +58,17 @@
// stores a list of the user's base permissions
private $permissions = array();
- // array of group objects
+ /**
+ * Stores an array of group ids to group
+ * @var DekiGroup[]
+ */
private $groups = array();
+ /**
+ * Internal lookup table. Translates a group name into a group id.
+ * @var int[]
+ */
+ private $groupNames = array();
+
// role object
private $Role = null;
// authentication service id & object
@@ -471,6 +480,7 @@
return $this->AuthService;
}
+
public function getGroupNames()
{
$groupNames = array();
@@ -483,6 +493,7 @@
return $groupNames;
}
+
public function getGroupIds()
{
$groupIds = array();
@@ -531,7 +542,19 @@
return $this->authServiceId == DekiAuthService::INTERNAL_AUTH_ID;
}
public function isAuthInvalid() { return $this->hasInvalidAuth; }
- public function isGroupMember($groupId) { return isset($this->groups[$groupId]); }
+
+ /**
+ * Determines if the user is a member of group by id or name.
+ *
+ * @param mixed $groupId
+ * @param bool $checkName - if true, groupdId is the group name
+ * @return bool
+ */
+ public function isGroupMember($groupId, $checkName = false)
+ {
+ return $checkName ? isset($this->groupNames[$groupId]) : isset($this->groups[$groupId]);
+ }
+
public function isAnonymous() { return strtolower($this->username) == strtolower(self::ANONYMOUS_USER); }
public function isDisabled() { return $this->status == self::STATUS_INACTIVE; }
@@ -823,8 +846,12 @@
if (isset($this->groups[$id]))
{
$Group = &$this->groups[$id];
+ $name = $Group->getName();
+
$success &= $Group->removeUser($this->getId());
+
unset($this->groups[$id]);
+ unset($this->groupNames[$name]);
}
}
@@ -836,8 +863,12 @@
if (!is_null($Group))
{
+ $name = $Group->getName();
+
$success &= $Group->addUser($this->getId());
+
$this->groups[$id] = $Group;
+ $this->groupNames[$name] = $id;
}
}
}
@@ -866,7 +897,12 @@
{
foreach ($groups as $group)
{
- $this->groups[$group['@id']] = DekiGroup::newFromArray($group);
+ $DekiGroup = DekiGroup::newFromArray($group);
+ $id = $DekiGroup->getId();
+ $name = $DekiGroup->getName();
+
+ $this->groups[$id] = $DekiGroup;
+ $this->groupNames[$name] = $id;
}
}
}
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by