예제 #1
0
 /**
  * Deletes a user
  *
  * @param int $id
  * @return unknown
  */
 function DeleteUser()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error('Token does not match', E_USER_ERROR);
     }
     $db =& $this->db;
     $user =& $this->user;
     $response = new ResponseManager();
     $userid = Kit::GetParam('userid', _POST, _INT, 0);
     $groupID = $user->getGroupFromID($userid, true);
     // Can we delete this user? Dont even try if we cant. Check tables that have this userid or this groupid
     if ($this->db->GetCountOfRows(sprintf('SELECT LayoutID FROM layout WHERE UserID = %d', $userid)) > 0) {
         trigger_error(__('Cannot delete this user, they have layouts'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT MediaID FROM media WHERE UserID = %d', $userid)) > 0) {
         trigger_error(__('Cannot delete this user, they have media'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT EventID FROM schedule WHERE UserID = %d', $userid)) > 0) {
         trigger_error(__('Cannot delete this user, they have scheduled layouts'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT Schedule_DetailID FROM schedule_detail WHERE UserID = %d', $userid)) > 0) {
         trigger_error(__('Cannot delete this user, they have schedule detail records'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT TemplateID FROM template WHERE UserID = %d', $userid)) > 0) {
         trigger_error(__('Cannot delete this user, they have templates'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT osr_id FROM oauth_server_registry WHERE osr_usa_id_ref = %d', $userid)) > 0) {
         trigger_error(__('Cannot delete this user, they have applications'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT GroupID FROM lkdatasetgroup WHERE GroupID = %d', $groupID)) > 0) {
         trigger_error(__('Cannot delete this user, they have permissions to data sets'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT GroupID FROM lkdisplaygroupgroup WHERE GroupID = %d', $groupID)) > 0) {
         trigger_error(__('Cannot delete this user, they have permissions to display groups'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT GroupID FROM lklayoutgroup WHERE GroupID = %d', $groupID)) > 0) {
         trigger_error(__('Cannot delete this user, they have permissions to layouts'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT GroupID FROM lklayoutmediagroup WHERE GroupID = %d', $groupID)) > 0) {
         trigger_error(__('Cannot delete this user, they have permissions to media on layouts'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT GroupID FROM lklayoutregiongroup WHERE GroupID = %d', $groupID)) > 0) {
         trigger_error(__('Cannot delete this user, they have permissions to regions on layouts'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT GroupID FROM lkmediagroup WHERE GroupID = %d', $groupID)) > 0) {
         trigger_error(__('Cannot delete this user, they have permissions to media'), E_USER_ERROR);
     }
     if ($this->db->GetCountOfRows(sprintf('SELECT GroupID FROM lktemplategroup WHERE GroupID = %d', $groupID)) > 0) {
         trigger_error(__('Cannot delete this user, they have permissions to templates'), E_USER_ERROR);
     }
     // Firstly delete the group for this user
     $userGroupObject = new UserGroup($db);
     // Remove this user from all user groups (including their own)
     $userGroupObject->UnlinkAllGroups($userid);
     // Delete the user specific group
     if (!$userGroupObject->Delete($groupID)) {
         trigger_error($userGroupObject->GetErrorMessage(), E_USER_ERROR);
     }
     // Delete the user
     $sqldel = "DELETE FROM user";
     $sqldel .= " WHERE UserID = %d";
     if (!$db->query(sprintf($sqldel, $userid))) {
         trigger_error($db->error());
         trigger_error(__("This user has been active, you may only retire them."), E_USER_ERROR);
     }
     // We should delete this users sessions record.
     $SQL = "DELETE FROM session WHERE userID = %d ";
     if (!$db->query(sprintf($SQL, $userid))) {
         trigger_error($db->error());
         trigger_error(__("If logged in, this user will be deleted once they log out."), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('User Deleted.'));
     $response->Respond();
 }
예제 #2
0
 /**
  * Deletes a Group
  * @return 
  */
 function Delete()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error('Token does not match', E_USER_ERROR);
     }
     $db =& $this->db;
     $groupid = Kit::GetParam('groupid', _POST, _INT);
     $userGroupObject = new UserGroup($db);
     if (!$userGroupObject->Delete($groupid)) {
         trigger_error($userGroupObject->GetErrorMessage(), E_USER_ERROR);
     }
     $response = new ResponseManager();
     $response->SetFormSubmitResponse(__('User Group Deleted'), false);
     $response->Respond();
 }
예제 #3
0
 /**
  * Deletes a user
  */
 function DeleteUser()
 {
     // Check the token
     if (!Kit::CheckToken()) {
         trigger_error(__('Sorry the form has expired. Please refresh.'), E_USER_ERROR);
     }
     $response = new ResponseManager();
     $deleteAllItems = Kit::GetParam('deleteAllItems', _POST, _CHECKBOX) == 1;
     $userId = Kit::GetParam('userid', _POST, _INT, 0);
     $groupId = $this->user->getGroupFromID($userId, true);
     $user = new Userdata();
     $user->userId = $userId;
     $userGroup = new UserGroup();
     if (!$deleteAllItems) {
         // Can we delete this user? Don't even try if we cant.
         $children = $user->getChildTypes();
         if (count($children) > 0) {
             trigger_error(sprintf(__('Cannot delete user, they own %s'), implode(', ', $children)), E_USER_ERROR);
         }
         // Can we delete this group?
         $children = $userGroup->getChildTypes($groupId);
         if (count($children) > 0) {
             trigger_error(sprintf(__('Cannot delete user, they own %s'), implode(', ', $children)), E_USER_ERROR);
         }
     }
     // Delete all items has been selected, so call delete on the group, then the user
     $userGroup->UnlinkAllGroups($userId);
     // Delete the user specific group
     if (!$userGroup->Delete($groupId)) {
         trigger_error($userGroup->GetErrorMessage(), E_USER_ERROR);
     }
     // Delete the user
     if (!$user->Delete()) {
         trigger_error($user->GetErrorMessage(), E_USER_ERROR);
     }
     $response->SetFormSubmitResponse(__('User Deleted.'));
     $response->Respond();
 }