Exemple #1
0
 /**
  * Function to remove a user from Joomla
  */
 function removeUsers($cid)
 {
     global $database, $acl, $my, $vmLogger, $VM_LANG;
     if (!is_array($cid)) {
         $cid = array($cid);
     }
     if (count($cid)) {
         $obj = new mosUser($database);
         foreach ($cid as $id) {
             // check for a super admin ... can't delete them
             //TODO: Find out the group name of the User to be deleted
             //				$groups 	= $acl->get_object_groups( 'users', $id, 'ARO' );
             //				$this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) );
             $obj->load($id);
             $this_group = strtolower($obj->get('usertype'));
             if ($this_group == 'super administrator') {
                 $vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_SUPERADMIN'));
                 return false;
             } else {
                 if ($id == $my->id) {
                     $vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_YOURSELF'));
                     return false;
                 } else {
                     if ($this_group == 'administrator' && $my->gid == 24) {
                         $vmLogger->err($VM_LANG->_('VM_USER_DELETE_ERR_ADMIN'));
                         return false;
                     } else {
                         $obj->delete($id);
                         $err = $obj->getError();
                         if ($err) {
                             $vmLogger->err($err);
                             return false;
                         }
                         return true;
                     }
                 }
             }
         }
     }
 }