/**
 *
 * Return all valid groups in the system
 * @param $parser
 */
function allgroups(&$parser, $includepredfined = false)
{
    $grps = array("");
    //$wikigroups=User::getAllGroups();
    $customgroups = MWUtil::allPageInNamespace(ACL_NS_USERGROUP);
    array_push($customgroups, ACL::$AllUser);
    $prefinedgroups = ACL::getPredefinedGroups();
    if (!$includepredfined) {
        $customgroups = array_diff($customgroups, $prefinedgroups);
    }
    //$grps=array_unique(array_merge($wikigroups, $customgroups));
    $grps = $customgroups;
    sort($grps);
    array_unshift($grps, "");
    return implode(",", $grps);
}
Ejemplo n.º 2
0
 /**
  *
  * @return a list . Each list has three props.
  * 	name: the group name.
  *  User: the user this group belongs to.  The value should be a list.
  *  Permission: default permission this group has. The value should be a list.
  *
  */
 public static function loadUserGroups()
 {
     if (self::$allGroups != null) {
         return self::$allGroups;
     }
     $tempgroups = array();
     wfRunHooks("aclLoadGroups", $tempgroups);
     self::$allGroups = array();
     $allpages = MWUtil::allPageInNamespace(ACL_NS_USERGROUP);
     foreach ($allpages as $pagename) {
         $props = SMWUtil::loadSemanticProperties($pagename, ACL_NS_USERGROUP, false);
         //------handle group leader.
         if (!array_key_exists(self::$USERGROUP_GROUPLEADER, $props)) {
             $props[self::$USERGROUP_GROUPLEADER] = "";
         }
         //--------load the users in groups.
         if (array_key_exists(self::$USERGROUP_USERS, $props)) {
             //if there is only one user, convert the string into element of one element.
             if (!is_array($props[self::$USERGROUP_USERS])) {
                 $props[self::$USERGROUP_USERS] = array($props[self::$USERGROUP_USERS]);
             }
         } else {
             $props[self::$USERGROUP_USERS] = array();
         }
         //merge group leader into users
         if ($props[self::$USERGROUP_GROUPLEADER]) {
             array_push($props[self::$USERGROUP_USERS], $props[self::$USERGROUP_GROUPLEADER]);
             $props[self::$USERGROUP_USERS] = array_unique($props[self::$USERGROUP_USERS]);
         }
         //merge the user loading externally.
         if (array_key_exists($pagename, $tempgroups)) {
             $props[self::$USERGROUP_USERS] = array_unique(array_merge($tempgroups[$pagename], $props[self::$USERGROUP_USERS]));
         }
         //handle permission
         $ps = SMWUtil::getSemanticInternalObjects(ACL_USERGROUP . ":" . $pagename, self::$USERGROUP_PERMISSIONS, ACL_NS_USERGROUP);
         $permissions = array();
         foreach ($ps as $p) {
             if (!$p) {
                 continue;
             }
             //convert ACL PERMISSIONS to an array
             if (array_key_exists(self::$PERMISSIONS, $p)) {
                 $p[self::$PERMISSIONS] = array_map("trim", explode(",", $p[self::$PERMISSIONS]));
                 $permissions[] = $p;
             }
         }
         $props[self::$USERGROUP_PERMISSIONS] = $permissions;
         $props['name'] = $pagename;
         self::$allGroups[$pagename] = $props;
     }
     return self::$allGroups;
 }