Ejemplo n.º 1
0
 /**
  * Removes Group from the list stored in the session and from 
  * the list of application-defined groups.
  *
  * @access private
  * @param mixed groupList List of groups (id => displayName) stored in session
  * @param mixed group_arg Array or string containing id of group to remove
  * @return TRUE if group successfully deleted
  * @see smdoc_group_user::deleteAll
  * @see smdoc_group_appext::getInstance
  */
 function _deleteGroup(&$groupList, $group_arg)
 {
     if (is_string($group_arg)) {
         $group = $group_arg;
         $group_arg = array();
         $group_arg[$group] = $group;
     } elseif (!is_array($group_arg)) {
         return FALSE;
     }
     // we don't know what this thing is, don't muck up the list.
     $app_defined =& smdoc_group_appext::getInstance($this->foowd);
     foreach ($group_arg as $id) {
         if (smdoc_group::checkGroup($this->foowd, $id)) {
             continue;
         }
         // can't reset system groups
         unset($groupList[$id]);
         if (isset($app_defined->groups[$id])) {
             smdoc_group_user::deleteAll($this->foowd, $id);
             unset($app_defined->groups[$id]);
             $app_defined->foowd_changed = TRUE;
         }
     }
     return $app_defined->foowd_changed;
 }
 /**
  * Adds User/Group pairs matching given userid and 
  * list of groups.
  *
  * @static
  * @param smdoc  foowd  Reference to the foowd environment object.
  * @param int userid Objectid of user
  * @param mixed groups array of group ids (strings)
  */
 function addUserToGroups(&$foowd, $userid, $groups)
 {
     if (!is_array($groups)) {
         return;
     }
     if (empty($groups)) {
         return;
     }
     foreach ($groups as $grp) {
         $smgrp = new smdoc_group_user($foowd, $grp, $userid);
         $smgrp->save();
     }
 }