Esempio n. 1
0
 function testDelete()
 {
     //Arrange
     $name = "Work stuff";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $description = "File reports";
     $id2 = 2;
     $test_task = new Task($description, $id2);
     $test_task->save();
     //Act
     $test_task->addCategory($test_category);
     $test_task->delete();
     //Assert
     $this->assertEquals([], $test_category->getTasks());
 }
<?php

require_once 'inc/init.php';
$task_id = $_GET['task-id'];
$task = new Task();
$task->load('id = ?', [$task_id]);
if ($task->delete()) {
    Response::write('message', 'Task deleted');
} else {
    Response::write('status', false);
    Response::write('message', 'Task failed to delete.');
}
Response::output();
 /**
  * Update an existing comment
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->wireframe->print_button = false;
     if ($this->active_comment->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_comment->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $parent = $this->active_comment->getParent();
     if (!instance_of($parent, 'ProjectObject')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $parent->prepareProjectSectionBreadcrumb($this->wireframe);
     $this->wireframe->addBreadCrumb($parent->getName(), $parent->getViewUrl());
     $comment_data = $this->request->post('comment');
     if (!is_array($comment_data)) {
         $comment_data = array('body' => $this->active_comment->getBody());
     }
     // if
     $this->smarty->assign('comment_data', $comment_data);
     //BOF:task_1260
     $active_object = ProjectObjects::findById($this->active_comment->getParentId());
     $this->smarty->assign('subscribers', $active_object->getSubscribers());
     $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
     mysql_select_db(DB_NAME);
     //$query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "'";
     $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "'";
     $request = mysql_query($query);
     $fyi_users = array();
     $action_request_users = array();
     while ($entry = mysql_fetch_array($request)) {
         //BOF:mod 20130429
         /*
         //EOF:mod 20130429
         	  	if ($entry['is_action_request']=='1'){
         //BOF:mod 20130429
         */
         if (!empty($entry['is_action_request'])) {
             //EOF:mod 20130429
             $action_request_users[] = $entry['user_id'];
         }
         //BOF:mod 20130429
         /*
         //EOF:mod 20130429
         	  	if ($entry['is_fyi']=='1'){
         	  		$fyi_users[] = $entry['user_id'];
         	  	}
         //BOF:mod 20130429
         */
         //EOF:mod 20130429
     }
     $this->smarty->assign('fyi_users', $fyi_users);
     $this->smarty->assign('action_request_users', $action_request_users);
     $this->smarty->assign('logged_user', $this->logged_user);
     //EOF:task_1260
     if ($this->request->isSubmitted()) {
         $this->active_comment->setAttributes($comment_data);
         $save = $this->active_comment->save();
         if ($save && !is_error($save)) {
             //BOF:task_1260
             //$subscribers_to_notify = array_var($comment_data, 'subscribers_to_notify');
             $action_request_user_id = array_var($comment_data, 'action_request');
             //mysql_query("update healingcrystals_assignments_action_request set is_action_request='0', is_fyi='0' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and is_action_request<>'-1' and is_fyi<>'-1'");
             //mysql_query("update healingcrystals_assignments_action_request set is_action_request='0', is_fyi='0' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and is_action_request<>'-1' and is_fyi<>'-1'");
             /*if (!empty($subscribers_to_notify)){
                 foreach ($subscribers_to_notify as $id){
                     $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'";
                     $result = mysql_query($query);
                     if (mysql_num_rows($result)){
                         $query = "update healingcrystals_assignments_action_request set is_fyi='1' where comment_id='" . $this->active_comment->getId() . "' and selected_by_user_id='" . $this->logged_user->getId() . "' and user_id='" . $id . "'";
                         mysql_query($query);
                     } else {
                         $query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added) values ('" . $id . "', '0', '1', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())";
                         mysql_query($query);
                     }
                 }
               }*/
             $existing_ar_users = array();
             $new_ar_users = array();
             if (!empty($action_request_user_id)) {
                 foreach ($action_request_user_id as $id) {
                     $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'";
                     $result = mysql_query($query);
                     if (mysql_num_rows($result)) {
                         $info = mysql_fetch_assoc($result);
                         if ($info['is_action_request'] == '1') {
                             $existing_ar_users[] = $id;
                         } else {
                             $query = "update healingcrystals_assignments_action_request set is_action_request='1' where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'";
                             mysql_query($query);
                             $new_ar_users[] = $id;
                         }
                     } else {
                         $query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added) values ('" . $id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())";
                         mysql_query($query);
                         $new_ar_users[] = $id;
                     }
                 }
                 $query = "update healingcrystals_assignments_action_request set is_action_request='0' where comment_id='" . $this->active_comment->getId() . "' and user_id not in (" . implode(', ', $action_request_user_id) . ")";
                 mysql_query($query);
             } else {
                 $query = "update healingcrystals_assignments_action_request set is_action_request='0' where comment_id='" . $this->active_comment->getId() . "'";
                 mysql_query($query);
             }
             mysql_query("delete from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and is_action_request='0' and is_fyi='0' and marked_for_email='0'");
             //EOF:task_1260
             foreach ($action_request_users as $id) {
                 if (!in_array($id, $existing_ar_users)) {
                     //unassign
                     $query = "select object_id from actionrequests_to_tasklist where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "' and type='Task'";
                     $result = mysql_query($query);
                     if (mysql_num_rows($result)) {
                         $info = mysql_fetch_assoc($result);
                         $task = new Task($info['object_id']);
                         $task->delete();
                         mysql_query("delete from actionrequests_to_tasklist where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "' and type='Task'");
                     }
                 }
             }
             foreach ($new_ar_users as $id) {
                 //assign
                 //BOF:mod 20130429
                 /*
                 //EOF:mod 20130429
                 			$priority = '0';
                       $query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'";
                 			$result = mysql_query($query, $link);
                       if (mysql_num_rows($result)){
                 				$query1 = "update healingcrystals_assignments_action_request set is_action_request='1', priority_actionrequest='" . $priority . "' where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'";
                 				mysql_query($query1, $link);
                 			} else {
                 				$query1 = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added, priority_actionrequest) values ('" . $id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now(), '" . $priority . "')";
                 				mysql_query($query1, $link);
                 			}
                 //BOF:mod 20130429
                 */
                 //EOF:mod 20130429
                 $task = new Task();
                 $task->setProjectId(TASK_LIST_PROJECT_ID);
                 $task->setParentId(Page::getTaskPageIdForUser($id));
                 $task->setParentType('Page');
                 $task->setCreatedBy($this->logged_user);
                 $task->setVisibility(VISIBILITY_NORMAL);
                 $task->setState(STATE_VISIBLE);
                 $task_body = '';
                 $parent = $this->active_comment->getParent();
                 $url = $parent->getViewUrl() . '#comment' . $this->active_comment->getId();
                 $comment_body = $this->active_comment->getBody();
                 $comment_body = strip_tags($comment_body);
                 if (strlen($comment_body) > 525) {
                     $task_body .= substr($comment_body, 0, 525) . '..';
                 } else {
                     $task_body .= $comment_body;
                 }
                 $task_body .= '<br/><a href="' . $url . '">View Task in Full</a>';
                 $attachments = $this->active_comment->getAttachments();
                 if (is_foreachable($attachments)) {
                     $task_body .= '<br/>Attachments:<br/>';
                     foreach ($attachments as $attachment) {
                         $task_body .= '<a href="' . $attachment->getViewUrl() . '">' . $attachment->getName() . '</a><br/>';
                     }
                 }
                 $task->setBody($task_body);
                 $savetask = $task->save();
                 if ($savetask && !is_error($savetask)) {
                     $task->ready();
                     mysql_query("insert into actionrequests_to_tasklist (comment_id, user_id, type, object_id) values ('" . $this->active_comment->getId() . "', '" . $id . "', 'Task', '" . $task->getId() . "')");
                 }
             }
             if ($this->request->getFormat() == FORMAT_HTML) {
                 flash_success('Comment has been updated');
                 $this->redirectToUrl($this->active_comment->getRealViewUrl());
             } else {
                 $this->serveData($this->active_comment, 'comment');
             }
             // if
         } else {
             if ($this->request->getFormat() == FORMAT_HTML) {
                 $this->smarty->assign('errors', $save);
             } else {
                 $this->serveData($save);
             }
             // if
         }
         // if
     }
     // if
     //BOF:task_1260
     //mysql_close($link);
     //EOF:task_1260
 }
Esempio n. 4
0
         		}*/
         $tasklist = new TaskList();
         $tasklist->setUserId(Authentication::getUserObject()->getId());
         $tasklist->setName($_POST['name']);
         $tasklist->setIcon($_POST['icon']);
         $tasklist->save();
         echo json_encode(array('status' => 'success', 'tasklist-id' => $tasklist->getId()));
     } else {
         echo json_encode(array('status' => 'error', 'reason' => 'List name not supplied.'));
     }
 } else {
     if ($_POST['action'] == "delete_list") {
         if (isset($_POST['id'])) {
             $list = TaskList::get($where = array('id' => $_POST['id']))[0];
             foreach (Task::get($where = array('list_id' => $list->getId())) as $task) {
                 $task->delete();
             }
             $list->delete();
             echo json_encode(array('status' => 'success'));
         }
     } else {
         if ($_POST['action'] == "delete_task") {
             if (isset($_POST['id'])) {
                 $task = Task::get($where = array('id' => $_POST['id']));
                 if (!empty($task)) {
                     $task[0]->delete();
                     echo json_encode(array('status' => 'success'));
                     die;
                 } else {
                     echo json_encode(array('status' => 'error', 'reason' => 'That task does not exist!'));
                     die;
Esempio n. 5
0
 public function delete()
 {
     $this->output->set_content_type('application/json');
     $url = $this->uri->ruri_to_assoc(3);
     $task_id = isset($url['task_id']) ? intval($url['task_id']) : 0;
     if ($task_id !== 0) {
         $this->_transaction_isolation();
         $this->db->trans_begin();
         $task = new Task();
         $task->get_by_id($task_id);
         $task->delete();
         $this->lang->delete_overlays('tasks', intval($task_id));
         if ($this->db->trans_status()) {
             $this->db->trans_commit();
             $this->output->set_output(json_encode(TRUE));
             $this->_action_success();
         } else {
             $this->db->trans_rollback();
             $this->output->set_output(json_encode(FALSE));
         }
     } else {
         $this->output->set_output(json_encode(FALSE));
     }
 }
Esempio n. 6
0
 function testDeleteTask()
 {
     // Arrange
     $name = "Home stuff";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $description = "Wash the dog";
     $id2 = 2;
     $due_date = "2016-02-29";
     $test_task = new Task($description, $id2, $due_date);
     $test_task->save();
     // Act
     $test_task->addCategory($test_category);
     $test_task->delete();
     // Assert
     $this->assertEquals([], $test_category->getTasks());
 }
Esempio n. 7
0
	}
}

if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->projet->supprimer)
{
	$task = new Task($db);
	if ($task->fetch($_GET["id"]) >= 0 )
	{
		$projet = new Project($db);
		$result=$projet->fetch($task->fk_projet);
		if (! empty($projet->socid))
		{
			$projet->societe->fetch($projet->socid);
		}

		if ($task->delete($user) > 0)
		{
			Header("Location: index.php");
			exit;
		}
		else
		{
			$langs->load("errors");
			$mesg='<div class="error">'.$langs->trans($task->error).'</div>';
			$_POST["action"]='';
		}
	}
}


/*
Esempio n. 8
0
<?php

$id = strip_tags($_POST['id']);
if (!empty($id)) {
    require '../Models/Task.php';
    Task::delete($id);
}
Esempio n. 9
0
	{
		$action='edit';
	}
}

if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer)
{
	if ($object->fetch($id) >= 0 )
	{
		$result=$projectstatic->fetch($object->fk_projet);
		if (! empty($projectstatic->socid))
		{
			$projectstatic->societe->fetch($projectstatic->socid);
		}

		if ($object->delete($user) > 0)
		{
			Header("Location: index.php");
			exit;
		}
		else
		{
			$langs->load("errors");
			$mesg='<div class="error">'.$langs->trans($object->error).'</div>';
			$action='';
		}
	}
}

// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
if (! empty($project_ref) && ! empty($withproject))
Esempio n. 10
0
 function testDelete()
 {
     $name = "Work stuff";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $description = "File reports";
     $id2 = 2;
     $due_date = "2000-01-01";
     $test_task = new Task($description, $id2, $due_date);
     $test_task->save();
     $test_task->addCategory($test_category);
     $test_task->delete();
     $this->assertEquals([], $test_category->getTasks());
 }
Esempio n. 11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Project $project, Task $task)
 {
     $task->delete();
     return Redirect::route('projects.show', $project->slug)->with('message', 'Task deleted.');
 }
 function test_delete()
 {
     //Arrange
     $name = "Work stuff";
     $test_category = new Category($name);
     $test_category->save();
     $description = "File reports";
     $due_date = "2014-09-08";
     $test_task = new Task($description, $due_date);
     $test_task->save();
     //Act
     $test_task->addCategory($test_category);
     $test_task->delete();
     //Assert
     $this->assertEquals([], $test_category->getTasks());
 }
Esempio n. 13
0
// Archive task
if (isset($_GET['archive'])) {
    $task_id = trim($_GET['archive']);
    $archive = Task::update_fields($task_id, array('archived' => 1));
    if ($archive) {
        $session->message('<p class="success">You have successfully archived that task.</p>');
        redirect_to($_SERVER['HTTP_REFERER']);
    } else {
        $session->message('<p class="error">There was an error archiving that task.</p>');
        redirect_to($_SERVER['HTTP_REFERER']);
    }
}
// Delete task
if (isset($_GET['delete'])) {
    $task_id = trim($_GET['delete']);
    $delete = Task::delete($_SESSION['user_id'] . '_Tasks', $task_id);
    $delete2 = Context::delete_by_task($task_id);
    if ($delete) {
        $session->message('<p class="success">You have successfully deleted that task.</p>');
        redirect_to($_SERVER['HTTP_REFERER']);
    } else {
        $session->message('<p class="error">There was an error deleting that task.</p>');
        redirect_to($_SERVER['HTTP_REFERER']);
    }
}
// Send password link
if (isset($_POST['reset_password'])) {
    include APP_DIR . DS . 'run' . DS . 'reset-password.php';
}
// Reset password
if (isset($_POST['new_password'])) {
Esempio n. 14
0
 function testDeleteTask()
 {
     //Arrange
     $name = "Work stuff";
     $id = 1;
     $test_category = new Category($name, $id);
     $test_category->save();
     $description2 = "Water the lawn";
     $id2 = 2;
     $due_date2 = "3094-09-21";
     $test_task2 = new Task($description2, $id2, $due_date2);
     $test_task2->save();
     //Act
     $test_task2->addCategory($test_category);
     $test_task2->delete();
     //Assert
     $this->assertEquals([], $test_category->getTasks());
 }
 function delete(&$PDOdb)
 {
     global $db, $user, $conf;
     $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'element_element WHERE fk_source = ' . (int) $this->rowid . ' AND sourcetype = "tassetworkstationof" AND (targettype = "user" OR targettype = "task")';
     $PDOdb->Execute($sql);
     if ($this->fk_project_task > 0) {
         require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
         require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php';
         require_once DOL_DOCUMENT_ROOT . '/core/modules/project/task/' . $conf->global->PROJECT_TASK_ADDON . '.php';
         if (!$user->id) {
             $user->id = GETPOST('user_id');
         }
         $projectTask = new Task($db);
         $projectTask->fetch($this->fk_project_task);
         $projectTask->delete($user);
     }
     parent::delete($PDOdb);
 }