Ejemplo n.º 1
0
 /**
  * Although called via Current_User, this functions gives
  * a group with edit permissions the right to edit this item.
  */
 public static function giveItemPermission($user_id, Key $key)
 {
     $user = new PHPWS_User($user_id);
     $groups = $user->getGroups();
     if (empty($groups) || !is_array($groups)) {
         return;
     }
     if (empty($key->_edit_groups)) {
         $key->_edit_groups = array();
     }
     PHPWS_Core::initModClass('users', 'Group.php');
     foreach ($groups as $group_id) {
         $group_obj = new PHPWS_Group($group_id, false);
         if (!in_array($group_id, $key->_edit_groups) && $group_obj->allow($key->module, $key->edit_permission)) {
             $key->_edit_groups[] = $group_id;
         }
     }
     return $key->savePermissions();
 }