Example #1
0
    if ($formattedDeadline !== false) {
        $formattedDeadline = date("Y-m-d H:i:s", $formattedDeadline);
        $task->setDeadline($formattedDeadline);
    }
    if ($numNeeded != '') {
        $task->setNumNeeded($numNeeded);
    }
    $task->save();
    // save uploaded files to database
    foreach ($_POST['file'] as $stored => $orig) {
        $stored = Filter::text($stored);
        $orig = Filter::text($orig);
        Upload::saveToDatabase($orig, $stored, Upload::TYPE_TASK, $task->getID(), $project->getID());
    }
    // log it
    $logEvent = new Event(array('event_type_id' => 'create_task', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $task->getID(), 'data_1' => $task->getTitle(), 'data_2' => $task->getDescription()));
    $logEvent->save();
    // we're done here
    Session::setMessage('You created a new task.');
    $json = array('success' => '1', 'successUrl' => Url::task($task->getID()));
    echo json_encode($json);
} elseif ($action == 'edit') {
    // flag default is false; assume nothing is modified to start
    $modified = false;
    // is title modified?
    if ($title != $task->getTitle()) {
        // save changes
        $oldTitle = $task->getTitle();
        $task->setTitle($title);
        $task->save();
        // log it
Example #2
0
 /**
  * @test
  */
 public function shouldCreateNewTask()
 {
     $task = new Task('Sample Title', 'Sample Description');
     $this->assertEquals('Sample Title', $task->getTitle());
     $this->assertEquals('Sample Description', $task->getDescription());
 }
Example #3
0
    /**
     * Update the task clicked on
     * @param $userId the user editing
     * @param Task $task object containing task
     * @return bool true if updated
     */
    public function updateTask($userId, Task $task)
    {
        $sql = <<<SQL
UPDATE {$this->tableName}
SET title=?, notes=?, priority=?
WHERE userid=? AND id=?
SQL;
        $pdo = $this->pdo();
        $statement = $pdo->prepare($sql);
        $statement->execute(array($task->getTitle(), $task->getNotes(), $task->getPriority(), $userId, $task->getId()));
        if ($statement->rowCount() === 0) {
            return false;
        }
        return true;
    }
Example #4
0
 public function InsertNewTask(Task $task = null)
 {
     if ($task == null || !$task instanceof Task) {
         return null;
     }
     $props = array("UserID," => $task->getUserID(), "ProjectID," => $task->getProjectID(), "Title," => $task->getTitle(), "Date," => $task->getDate(), "TargetHours," => $task->getTargetHours(), "ActualHours," => $task->getActualHours(), "Description," => $task->getDescription(), "IsComplete" => $task->getIsComplete());
     foreach ($props as $k => $v) {
         if ($v != null) {
             if ($k == "IsComplete") {
                 $_props[$k] = "{$v}";
             } else {
                 if (gettype($v) == "string") {
                     $_props[$k] = "'" . $v . "', ";
                 } else {
                     $_props[$k] = "{$v}, ";
                 }
             }
         }
     }
     $this->_dbAdapt->IStatement($this->dbTbl, $_props);
     $tmp = $this->_dbAdapt->getLnk();
     $tmp->query($this->_dbAdapt->getQry());
     unset($tmp);
     return true;
 }
Example #5
0
 public function equals(Task $that)
 {
     return $this->getTitle() === $that->getTitle() && $this->getDescription() === $that->getDescription();
 }