Exemple #1
0
 public function delete()
 {
     $q = new DBQuery();
     $q->addQuery('task_log_task');
     $q->addTable('task_log');
     $q->addWhere('task_log_id = ' . (int) $this->task_log_id);
     $task_log_task = $q->loadResult();
     parent::delete();
     $this->updateHoursWorked($task_log_task);
 }
Exemple #2
0
 public function delete(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     /*
      * TODO: This should probably use the canDelete method from above too to
      *   not only check permissions but to check dependencies... luckily the
      *   previous version didn't check it either, so we're no worse off.
      */
     if ($perms->checkModuleItem('companies', 'delete', $this->company_id)) {
         if ($msg = parent::delete()) {
             return $msg;
         }
         addHistory('companies', 0, 'delete', 'Deleted', 0);
         return true;
     }
     return false;
 }
Exemple #3
0
 public function delete(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     if ($perms->checkModuleItem('links', 'delete', $this->link_id)) {
         if ($msg = parent::delete()) {
             return $msg;
         }
         addHistory('links', 0, 'delete', 'Deleted', 0);
         return true;
     }
     return false;
 }
Exemple #4
0
 /**
  *	Overloaded delete method
  *
  *	@author gregorerhardt
  *	@return null|string null if successful otherwise returns and error message
  */
 public function delete()
 {
     global $AppUI;
     // call default delete method first
     $deleted = parent::delete($this->event_id);
     // if object deletion succeeded then iteratively delete relationships
     if (empty($deleted)) {
         // delete user_events relationship
         $q = new DBQuery();
         $q->setDelete('user_events');
         $q->addWhere('event_id = ' . (int) $this->event_id);
         $deleted = !$q->exec() ? $AppUI->_('Could not delete Event-User relationship') . '. ' . db_error() : null;
         $q->clear;
     }
     return $deleted;
 }
Exemple #5
0
 public function delete(CAppUI $AppUI = null)
 {
     global $AppUI;
     if ($msg = parent::delete()) {
         return $msg;
     }
     addHistory('contacts', 0, 'delete', 'Deleted', 0);
     return true;
 }
Exemple #6
0
 public function delete($oid = null)
 {
     global $AppUI;
     $id = (int) $this->user_id;
     //check if the user is related to anything and disallow deletion if he is.
     //companies: is he a owner of any company?
     $q = new DBQuery();
     $q->addQuery('count(company_id)');
     $q->addTable('companies');
     $q->addWhere('company_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Companies') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //departments: is he a owner of any department?
     $q = new DBQuery();
     $q->addQuery('count(dept_id)');
     $q->addTable('departments');
     $q->addWhere('dept_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Departments') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //events: is he a owner of any event?
     $q = new DBQuery();
     $q->addQuery('count(event_id)');
     $q->addTable('events');
     $q->addWhere('event_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Events') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //files: is he a owner of any file?
     $q = new DBQuery();
     $q->addQuery('count(file_id)');
     $q->addTable('files');
     $q->addWhere('file_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Files') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a owner of any forum?
     $q = new DBQuery();
     $q->addQuery('count(forum_id)');
     $q->addTable('forums');
     $q->addWhere('forum_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forums') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a moderator of any forum?
     $q = new DBQuery();
     $q->addQuery('count(forum_id)');
     $q->addTable('forums');
     $q->addWhere('forum_moderated = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forums') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Forum Moderator') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a message creator on any forum?
     $q = new DBQuery();
     $q->addQuery('count(message_id)');
     $q->addTable('forum_messages');
     $q->addWhere('message_author = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forum Messages') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Author') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //forums: is he a message creator on any forum?
     $q = new DBQuery();
     $q->addQuery('count(message_id)');
     $q->addTable('forum_messages');
     $q->addWhere('message_editor = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Forum Messages') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Editor') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //links: is he a owner of any link?
     $q = new DBQuery();
     $q->addQuery('count(link_id)');
     $q->addTable('links');
     $q->addWhere('link_owner = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Links') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //projects: is he related to any project?
     $q = new DBQuery();
     $q->addQuery('count(project_id)');
     $q->addTable('projects');
     $q->addWhere('(project_owner = ' . $id . ' OR project_creator = ' . $id . ' OR project_updator = ' . $id . ')');
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Projects') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner, Creator or Updator') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //tasks: is he related to any task?
     $q = new DBQuery();
     $q->addQuery('count(task_id)');
     $q->addTable('tasks');
     $q->addWhere('(task_owner = ' . $id . ' OR task_creator = ' . $id . ' OR task_updator = ' . $id . ')');
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Tasks') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Owner, Creator or Updator') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //events: is he related to any event?
     $q = new DBQuery();
     $q->addQuery('count(event_id)');
     $q->addTable('user_events');
     $q->addWhere('user_id = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Events') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Attendee') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //tasks: is he related to any event?
     $q = new DBQuery();
     $q->addQuery('count(task_id)');
     $q->addTable('user_tasks');
     $q->addWhere('user_id = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Tasks') . ' ' . $AppUI->_('where he is') . ' ' . $AppUI->_('Assignee') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     //tasks: is he related to any pins?
     $q = new DBQuery();
     $q->addQuery('count(task_id)');
     $q->addTable('user_task_pin');
     $q->addWhere('user_id = ' . $id);
     $result = $q->loadResult();
     $q->clear();
     if ($result) {
         return $AppUI->_('Can not Delete Because This User has') . ' ' . $result . ' ' . $AppUI->_('Tasks') . ' ' . $AppUI->_('pinned') . '. ' . $AppUI->_('If you just want this user not to log in consider removing all his Roles. That would make the user Inactive.');
     }
     $result = parent::delete($oid);
     if (!$result) {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->deleteLogin($id);
         $q = new DBQuery();
         $q->setDelete('user_preferences');
         $q->addWhere('pref_user = ' . $id);
         $q->exec();
         $q->clear();
     }
     return $result;
 }