function delete($oid = NULL)
 {
     $id = $this->user_id;
     $result = parent::delete($oid);
     if (!$result) {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->deleteLogin($id);
         $q = new DBQuery();
         $q->setDelete('user_preferences');
         $q->addWhere('pref_user = ' . $this->user_id);
         $q->exec();
         $q->clear();
     }
     return $result;
 }
 /**
  *	Overloaded delete method
  *
  *	@author gregorerhardt
  *	@return null|string null if successful otherwise returns and error message
  */
 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 = ' . $this->event_id);
         $deleted = !$q->exec() ? $AppUI->_('Could not delete Event-User relationship') . '. ' . db_error() : null;
         $q->clear;
     }
     return $deleted;
 }
 /**
  * @todo Parent store could be partially used
  * @todo Can't delete a task with children
  */
 function delete()
 {
     if (!$this->task_id) {
         return 'invalid task id';
     }
     $q = new DBQuery();
     if (dPgetConfig('check_task_empty_dynamic') && $this->task_parent != $this->task_id) {
         //Check that we are not deleting the only child of a dynamic parent task
         $task_test = new CTask();
         $task_test->load($this->task_parent);
         $siblings = $task_test->getChildren();
         if ($task_test->task_dynamic == 1 && count($siblings) <= 1) {
             return 'BadDyn_NoChild';
         }
     }
     //load task first because we need info on it to update the parent tasks later
     $task = new CTask();
     $task->load($this->task_id);
     //get child tasks so we can delete them too (no orphans)
     $childrenlist = $task->getDeepChildren();
     //delete task (if we're actually allowed to delete this task)
     $err_msg = parent::delete($task->task_id, $task->task_name, $task->task_project);
     if ($err_msg) {
         return $err_msg;
     }
     $this->_action = 'deleted';
     if ($task->task_parent != $task->task_id) {
         //Has parent, run the update sequence, this child will no longer be in the database
         $this->updateDynamics();
     }
     $q->clear();
     //delete children
     if (!empty($childrenlist)) {
         foreach ($childrenlist as $child_id) {
             $ctask = new CTask();
             $ctask->load($child_id);
             //ignore permissions on child tasks by deleteing task directly from the database
             $q->setDelete('tasks');
             $q->addWhere('task_id=' . $ctask->task_id);
             if (!$q->exec()) {
                 return db_error();
             }
             $q->clear();
             addHistory('tasks', $ctask->task_id, 'delete', $ctask->task_name, $ctask->task_project);
             $this->updateDynamics();
             //to update after children are deleted (see above)
         }
         $this->_action = 'deleted with children';
     }
     //delete affiliated task_logs (overrides any task_log permissions)
     $q->setDelete('task_log');
     if (!empty($childrenlist)) {
         $q->addWhere('task_log_task IN (' . implode(', ', $childrenlist) . ', ' . $this->task_id . ')');
     } else {
         $q->addWhere('task_log_task=' . $this->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     //delete affiliated task_dependencies
     $q->setDelete('task_dependencies');
     if (!empty($childrenlist)) {
         $q->addWhere('dependencies_task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
     } else {
         $q->addWhere('dependencies_task_id=' . $task->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     // delete linked user tasks
     $q->setDelete('user_tasks');
     if (!empty($childrenlist)) {
         $q->addWhere('task_id IN (' . implode(', ', $childrenlist) . ', ' . $task->task_id . ')');
     } else {
         $q->addWhere('task_id=' . $task->task_id);
     }
     if (!$q->exec()) {
         return db_error();
     }
     $q->clear();
     return NULL;
 }
 function delete($oid = null)
 {
     $oid = intval($oid ? $oid : $this->file_folder_id);
     return parent::delete($oid);
 }
 function delete($oid = NULL)
 {
     $id = $this->user_id;
     $result = parent::delete($oid);
     if (!$result) {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->deleteLogin($id);
     }
     return $result;
 }