Пример #1
0
 /**
  * void delete()
  * saves a new task in database
  * @return int id, if saving was successful, else false
  * @access public
  */
 function delete()
 {
     global $dbInst, $toolInst, $loginInst;
     if (!$loginInst->hasAccess("task.delete")) {
         return false;
     }
     $this->activate($this->id);
     if (!$this->id) {
         $toolInst->errorStatus("no record selected");
         return false;
     }
     if ($dbInst->getValue("select id from " . $dbInst->config['table_task'] . " where mount_id = '" . $this->id . "'")) {
         $toolInst->errorStatus("dependency check failed: unable to delete task with existing member tasks");
         return false;
     }
     if (count($this->attachments) > 0) {
         $toolInst->errorStatus("dependency check failed: there are existing attachments. Please delete them first.");
         return false;
     }
     # delete assigned jobs
     $jobInst = new job();
     $jobInst->deleteByTask($this->id);
     $this->activate($this->id);
     $result = $dbInst->query("delete from " . $dbInst->config['table_task'] . " where id = '" . $this->id . "'");
     $dbInst->status($result[1], "d");
     // logging
     $userInst = new user($this->userId);
     $this->logger->warn("deleted task (" . $this->subject . ") for " . $userInst->name);
     $this->clear();
 }