Ejemplo n.º 1
0
 /**
  * Remove groups from employee.
  *
  * This function can be used to remove a group from the current employee.
  * <br/>Example:
  * <code>
  * $employee = EfrontHcdUserFactory :: factory('jdoe');
  * $employee -> removeGroups(23);						  //Remove a signle group with id 23
  * $employee -> removeGroups(array(23,24,25));			 //Remove multiple groups using an array
  * </code>
  *
  * @param int $groupIds Either a single group id, or an array if ids
  * @return int The array of group ids.
  * @since 3.5.0
  * @access public
  */
 public function removeGroups($groupIds)
 {
     $this->groups or $this->getGroups();
     //Populate $this -> groups if it is not already filled in
     if (!is_array($groupIds)) {
         $groupIds = array($groupIds);
     }
     foreach ($groupIds as $key => $groupId) {
         if (eF_checkParameter($groupId, 'id') && isset($this->groups[$groupId])) {
             $group = new EfrontGroup($groupId);
             $group->removeUsers($this->user['login']);
             unset($this->groups[$key]);
             //Remove groups from cache array."
         }
     }
     return $this->groups;
 }
Ejemplo n.º 2
0
     echo "<message>Invalid login format</message>";
     echo "</xml>";
     exit;
 }
 try {
     $group = new EfrontGroup($_GET['group']);
     $user = EfrontUserFactory::factory($_GET['login']);
     $group_users = $group->getUsers();
     if (!in_array($_GET['login'], $group_users['student']) && !in_array($_GET['login'], $group_users['professor'])) {
         echo "<xml>";
         echo "<status>error</status>";
         echo "<message>User is not assigned to group</message>";
         echo "</xml>";
         exit;
     } else {
         $group->removeUsers(array($_GET['login']));
         echo "<xml>";
         echo "<status>ok</status>";
         echo "</xml>";
     }
 } catch (Exception $e) {
     if ($e->getCode() == EfrontUserException::USER_NOT_EXISTS) {
         echo "<xml>";
         echo "<status>error</status>";
         echo "<message>User does not exist</message>";
         echo "</xml>";
         exit;
     } else {
         echo "<xml>";
         echo "<status>error</status>";
         echo "<message>Some problem occured</message>";