function add_user_to_group($user_id, $group_id, $expire = false)
 {
     if (is_integer($user_id) && is_integer($group_id) && $user_id > 0 && $group_id > 0) {
         $gul = new group_user_list(null);
         $group_user = $gul->check_user_group($user_id, $group_id);
         if ($group_user === false) {
             $gu = new group_user(null);
             $gu->set_user_id($user_id);
             $gu->set_group_id($group_id);
             if ($expire !== false) {
                 $gu->set_expires($expire);
             }
             $pm =& $this->get_post_master();
             $pm->set_data_object($gu);
             return $pm->sql_insert();
         }
         return true;
     } else {
         return false;
     }
 }
示例#2
0
 function set_privileges()
 {
     //load gourp privilegies
     $gul = new group_user_list();
     $group_privilegies = $gul->get_user_groups($this->get_id());
     $group_privilegies = array_unique($group_privilegies);
     $gl = new group_list();
     $this->groups =& $gl->get_groups($group_privilegies);
     $this->privileges = $this->_merge_privileges($this->get_user_privileges(), $gl->merge_privileges($group_privilegies));
     if (isset($this->privileges['EDITOR']['Categories']) && is_array($this->privileges['EDITOR']['Categories']) && !empty($this->privileges['EDITOR']['Categories'])) {
         //merge EDITOR and WRITE
         if (isset($this->privileges['WRITE']['Categories']) && is_array($this->privileges['WRITE']['Categories'])) {
             $this->privileges['WRITE']['Categories'] = array_merge($this->privileges['WRITE']['Categories'], $this->privileges['EDITOR']['Categories']);
         }
         //merge EDITOR and READ
         if (isset($this->privileges['READ']['Categories']) && is_array($this->privileges['READ']['Categories'])) {
             $this->privileges['READ']['Categories'] = array_merge($this->privileges['READ']['Categories'], $this->privileges['EDITOR']['Categories']);
         }
     }
 }