public function save(Task $task) { $events = $task->popEvents(); $this->eventStore->save($task->getId(), $events); foreach ($events as $event) { $this->eventDispatcher->dispatch(get_class($event), $event); } }
public function addTask() { $projectId = $this->request_stack["arguments"][0]; $task = new Task(); $taskId = $task->setProject(ProjectQuery::create()->findOneById($projectId))->setEmployee(EmployeeQuery::create()->findOneById((new Cookie())->get("employee_id")))->save(); $redirect = new Request(); $redirect->redirect("task", "edit", array("id" => $task->getId())); }
protected function buildDescription() { $description = 'type: ' . $this->identity->type . ', job_id: ' . $this->identity->getId(); $params = $this->identity->getParams(); foreach ($params as $key => $value) { $description .= ", {$key}: {$value}"; } return $description; }
function test_getId() { //Arrange $description = "Wash the dog"; $id = 1; $test_Task = new Task($description, $id); //Act $result = $test_Task->getId(); //Assert $this->assertEquals(1, $result); }
function test_find() { $description = "Wash the dog"; $description2 = "Water the lawn"; $test_Task = new Task($description); $test_Task->save(); $test_Task2 = new Task($description2); $test_Task2->save(); $id = $test_Task->getId(); $result = Task::find($id); $this->assertEquals($test_Task, $result); }
function test_find() { //Arrange $description = "Wash the Casey"; $description2 = "Eat the taco"; $test_Task = new Task($description); $test_Task->save(); $test_Task2 = new Task($description2); $test_Task2->save(); //Act $id = $test_Task->getId(); $result = Task::find($id); //Assert $this->assertEquals($test_Task, $result); }
/** * @inheritdoc */ public function remove(Task $task) { $task->close(); $taskId = $task->getId(); $taskSocketId = $task->getSocketId(); if (isset($this->sockets2tasks[$taskSocketId])) { unset($this->sockets2tasks[$taskSocketId]); } if (isset($this->tasksActive[$taskId])) { unset($this->tasksActive[$taskId]); } if (isset($this->tasks[$taskId])) { unset($this->tasks[$taskId]); } unset($task); }
function test_find() { //Arrange $name = "Home stuff"; $id = null; $test_category = new Category($name, $id); $test_category->save(); $description = "Wash the dog"; $date_due = "9/25/1990"; $time_due = "9:00am"; $category_id = $test_category->getId(); $test_task = new Task($id, $description, $date_due, $time_due, $category_id); $test_task->save(); $description2 = "Water the Lawn"; $date_due2 = "3/28/2000"; $time_due2 = "10:00am"; $test_task2 = new Task($id, $description2, $date_due2, $time_due2, $category_id); $test_task2->save(); $result = Task::find($test_task->getId()); $this->assertEquals($test_task, $result); }
/** * 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 }
/** * Send task over RPC to worker * Mark task as in progress nad worker as busy * @param Task $task * @param Worker $worker * @return void * @author Andraz <*****@*****.**> */ public function sendTaskToWorker(Task $task, Worker $worker) { $client = $this->newRpcClient($worker->getHost(), $worker->getport()); $parameters = [$worker->getId(), $task->getId(), $task->getParameters()]; $task->setStatus('in_progress'); $this->storage->saveTask($task); $worker->setStatus('busy'); $this->storage->saveWorker($worker); $success = $client->notify('run', $parameters); if ($success) { } return $success; }
function testFind() { //arrange $description = "Wash the dog"; $id = 1; $test_task = new Task($description, $id); $test_task->save(); $description2 = "Water the lawn"; $id2 = 2; $test_task2 = new Task($description2, $id); $test_task2->save(); //act $result = Task::find($test_task->getId()); //assert $this->assertEquals($test_task, $result); }
die; } try { if ($_POST['action'] == "new_task") { if (isset($_POST['task-desc'])) { if (empty(trim($_POST['task-desc']))) { echo json_encode(array('status' => 'validation', 'reason' => 'Your task description is empty!')); } else { if (strlen($_POST['task-desc']) > 80) { echo json_encode(array('status' => 'validation', 'reason' => 'Your task description is too long!')); } else { $task = new Task(); $task->setDescription($_POST['task-desc']); $task->setTaskListId($_POST['id']); $task->save(); echo json_encode(array('status' => 'success', 'task-id' => $task->getId())); } } } else { echo json_encode(array('status' => 'error', 'reason' => 'Task description not supplied.')); } } else { if ($_POST['action'] == "new_list") { if (isset($_POST['name'])) { if (empty(trim($_POST['name']))) { echo json_encode(array('status' => 'validation', 'reason' => 'Your task list name is empty!')); die; } /*if (strlen($_POST['name']) > 32) { echo json_encode(array('status'=>'validation', 'reason' => 'Your task list name is too long!'));
/** * Function to change the Task Owner * @param Integer $idcoworker * @param Integer $idtask */ function changeTaskOwner($idcoworker, $idtask) { $do_task = new Task(); $do_task->getId($idtask); $do_task->iduser = $idcoworker; $do_task->status = 'open'; $do_task->update(); $qobj = $this->getProjectTaskDetailsByTaskId($idtask); $this->sendEmailOnTaskOwnershipChange($idcoworker, $qobj); //sending ownership change alert }
/** * Do hourly tasks * * @param void * @return null */ function system_handle_on_hourly() { $cache =& Cache::instance(); if (instance_of($cache->backend, 'CacheBackend')) { $cache->backend->cleanup(); } // if //BOF:mod $time_current = $time_end = time() - 4 * 60 * 60; $time_start = $time_end - 60 * 60; $comment = 'Auto Reminder'; $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); //BOF:mod 20120816 /* //EOF:mod 20120816 $query = "select distinct a.object_id from healingcrystals_project_object_misc a inner join healingcrystals_project_objects b on a.object_id=b.id where b.type='Task' and b.state='" . STATE_VISIBLE . "' and (b.completed_on is null or b.completed_on='') and a.reminder_date is not null and a.reminder_date<>'0000-00-00' and a.auto_email_status='1' and ((a.reminder_date between '" . date('Y-m-d H:i:s', $time_start) . "' and '" . date('Y-m-d H:i:s', $time_end) . "') or (a.recurring_period_type = 'D' and recurring_period = '1' and recurring_period_condition = 'after_due_date' and (recurring_end_date > '".date('Y-m-d')."' or recurring_end_date = '0000-00-00') and date_format(a.reminder_date,'%H:%i:%s') between '" . date('H:i:s', $time_start) . "' and '" . date('H:i:s', $time_end) . "'))"; mysql_query("insert into testing (date_added, content) values (now(), '" . mysql_real_escape_string($query) . "')"); //BOF:mod 20120816 */ /* $query = "select distinct a.object_id, a.reminder_date from healingcrystals_project_object_misc a inner join healingcrystals_project_objects b on a.object_id=b.id where b.type='Task' and b.state='" . STATE_VISIBLE . "' and (b.completed_on is null or b.completed_on='') and a.reminder_date is not null and a.reminder_date<>'0000-00-00' and a.auto_email_status='1' and ((a.reminder_date between '" . date('Y-m-d H:i:s', $time_start) . "' and '" . date('Y-m-d H:i:s', $time_end) . "') or (a.recurring_period_type = 'D' and recurring_period = '1' and recurring_period_condition = 'after_due_date' and (recurring_end_date > '".date('Y-m-d')."' or recurring_end_date = '0000-00-00') and date_format(a.reminder_date,'%H:%i:%s') between '" . date('H:i:s', $time_start) . "' and '" . date('H:i:s', $time_end) . "'))"; */ $query = "select distinct \n\t\t\t\ta.object_id, \n\t\t\t\tcast(if(a.email_reminder_unit='D', \n\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period day), ' ', a.email_reminder_time), \n\t\t\t\t\tif(a.email_reminder_unit='W', \n\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period week), ' ', a.email_reminder_time), \n\t\t\t\t\t\tif(a.email_reminder_unit='M', \n\t\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period month), ' ', a.email_reminder_time), \n\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t) as datetime) as reminder \n\t\t\t from \n\t\t\t\thealingcrystals_project_object_misc a \n\t\t\t\tinner join healingcrystals_project_objects b on a.object_id=b.id \n\t\t\t where \n\t\t\t\tb.type='Task' and \n\t\t\t\tb.state='" . STATE_VISIBLE . "' and \n\t\t\t\t(b.completed_on is null or b.completed_on='') and \n\t\t\t\ta.auto_email_status='1' and \n\t\t\t\ta.email_reminder_unit is not null and \n\t\t\t\tb.due_on is not null and \n\t\t\t\t(a.snooze_datetime is null or a.snooze_datetime='0000-00-00 00:00:00' or a.snooze_datetime<'" . date('Y-m-d H:i:s', $time_current) . "') and \n\t\t\t\tcast(if(a.email_reminder_unit='D', \n\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period day), ' ', a.email_reminder_time), \n\t\t\t\t\tif(a.email_reminder_unit='W', \n\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period week), ' ', a.email_reminder_time), \n\t\t\t\t\t\tif(a.email_reminder_unit='M', \n\t\t\t\t\t\t\tconcat(DATE_SUB(b.due_on, interval a.email_reminder_period month), ' ', a.email_reminder_time), \n\t\t\t\t\t\t\tnull\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t) as datetime) between '" . date('Y-m-d H:i:s', $time_start) . "' and '" . date('Y-m-d H:i:s', $time_end) . "'\n\t\t\t "; //EOF:mod 20120816 $result = mysql_query($query, $link); while ($entry = mysql_fetch_assoc($result)) { $task_obj = new Task($entry['object_id']); $parent = $task_obj->getParent(); $project = $task_obj->getProject(); $assignees = $task_obj->getAssignees(); //BOF:mod 20120816 $priorities = array(PRIORITY_HIGHEST => lang('Highest'), PRIORITY_HIGH => lang('High'), PRIORITY_NORMAL => lang('Normal'), PRIORITY_LOW => lang('Low'), PRIORITY_LOWEST => lang('Lowest'), PRIORITY_ONGOING => lang('Ongoing'), PRIORITY_HOLD => lang('Hold')); $due_date = $task_obj->getDueOn(); if (!empty($due_date) && $due_date != '0000-00-00') { $due_date = date('m/d/Y', strtotime($due_date)); } else { $due_date = '--'; } $reminder_date = $entry['reminder']; //$reminder_date = $entry['reminder_date']; if (!empty($reminder_date) && $reminder_date != '0000-00-00 00:00:00') { $reminder_date = date('m/d/Y H:i', strtotime($reminder_date)); } else { $reminder_date = '--'; } foreach ($assignees as $assignee) { $assignees_string .= $assignee->getDisplayName() . ', '; } if (!empty($assignees_string)) { $assignees_string = substr($assignees_string, 0, -2); } else { $assignees_string = '--'; } //EOF:mod 20120816 $reminders_sent = array(); foreach ($assignees as $user) { //if ($user->getEmail()=='*****@*****.**'){ $reminder = new Reminder(); $reminder->setAttributes(array('user_id' => $user->getId(), 'object_id' => $task_obj->getId(), 'comment' => $comment)); //$reminder->setCreatedBy($this->logged_user); $save = $reminder->save(); if ($save && !is_error($save)) { $reminders_sent[] = $user->getDisplayName(); ApplicationMailer::send($user, 'system/reminder', array('reminded_by_name' => 'AutoReminder', 'reminded_by_url' => '', 'object_name' => $task_obj->getName(), 'object_url' => $task_obj->getViewUrl(), 'object_type' => strtolower($task_obj->getType()), 'comment_body' => $comment, 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl(), 'ticket_name' => $parent->getName(), 'ticket_url' => $parent->getViewUrl(), 'object_priority' => $priorities[(string) $task_obj->getPriority()], 'object_due_date' => $due_date, 'object_reminder_date_n_time' => $reminder_date, 'object_assignees' => $assignees_string, 'task_mark_complete_url' => $task_obj->getCompleteUrl() . '&auto=1', 'display_status_for_complete_url' => ''), $task_obj); } // if //} } // foreach } mysql_close($link); //EOF:mod }
/** * Creates a new Card in the Kanban Board. * This method has all the parameters specifying the board, lane and position where you want to add the new card. The request body contains the JSON for a new card. You must specify a valid TypeId that matches one of the Card Types for your board. See GetBoardIdentifiers for a listing of valid Card Type Ids and Class Of Service Ids for your board. * @param Object : EventControler * @see LeanKitKanban->addCard */ public function eventAddTaskToBoard(EventControler $evtcl) { $msg = ""; $this->getUserLoginCredentials(); if ($this->getNumRows()) { $username = $this->username; $password = $this->password; if ($evtcl->board) { //This is the default Type used for adding a Card. $card_type_id = $this->getCardTypeId($evtcl->board, "Task"); //This is the default Board User for adding a Card. $assigned_user_id = $this->getBoardUserId($evtcl->board, $username); //This is the default Lane used for adding a Card. $lane_id = $this->getCardLaneId($evtcl->board, "backlog"); $task = new Task(); $task->getId($evtcl->ofuz_task_id); // check for the first note for task description , if not found and task title as description $proj_discuss = new ProjectDiscuss(); $desc = $proj_discuss->getFirstNote($evtcl->ofuz_idprojecttask); if ($desc == '') { $desc = $task->task_description; } if ($task->due_date_dateformat == "" || $task->due_date_dateformat == "0000-00-00") { $due_date = ""; } else { $due_date = $this->convertMysqlDateToMMDDYYY($task->due_date_dateformat, "/"); } $array_card = array("Title" => $task->task_description, "Description" => $desc, "TypeId" => $card_type_id, "Priority" => 1, "Size" => "", "IsBlocked" => false, "BlockReason" => "", "DueDate" => $due_date, "ExternalSystemName" => "http://www.ofuz.net/Task/" . $evtcl->ofuz_idprojecttask, "ExternalSystemUrl" => "http://www.ofuz.net/Task/" . $evtcl->ofuz_idprojecttask, "Tags" => "", "ClassOfServiceId" => "", "ExternalCardID" => $evtcl->ofuz_idprojecttask, "AssignedUserIds" => array($assigned_user_id)); $leankitkanban = new LeanKitKanban($username, $password); $response = $leankitkanban->addCard($array_card, $evtcl->board, $lane_id, 1); if ($response->ReplyCode == '201') { $msg .= "The Card is added."; } else { $msg .= $response->ReplyText; } } else { $msg .= "You must select a Kanban Board to add this Task."; } } else { $msg .= "You have not set up your LeanKit Kanban Login Credentials."; } $_SESSION["ofuz_kanban_message"] = $msg; }
function test_find() { //Arrange $due_date = "2015-10-12"; $description = "Wash the dog"; $test_task = new Task($description, $due_date, 1); $test_task->save(); $description2 = "Water the lawn"; $test_task2 = new Task($description2, $due_date, 2); $test_task2->save(); //Act $result = Task::find($test_task->getId()); //Assert $this->assertEquals($test_task, $result); }
function snoozereminder() { $snooze = $this->request->post('snooze'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); if ($snooze) { /*mysql_query("update healingcrystals_project_object_misc set snooze_duration='" . (int)$snooze['duration'] . "', snooze_unit='" . $snooze['unit'] . "' where object_id='" . $this->active_task->getId() . "'"); $query = "select reminder_date from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'"; $result = mysql_query($query); if (mysql_num_rows($result)){ $info = mysql_fetch_assoc($result); if (!empty($info['reminder_date']) && $info['reminder_date']!='0000-00-00 00:00:00'){ $base_date = strtotime($info['reminder_date']); $modified_date = ''; if ($snooze['duration']>0){ switch($snooze['unit']){ case 'H': $modified_date = strtotime('+ ' . $snooze['duration'] . ' hours', $base_date); break; case 'D': $modified_date = strtotime('+ ' . $snooze['duration'] . ' days', $base_date); break; case 'W': $modified_date = strtotime('+ ' . $snooze['duration'] . ' weeks', $base_date); break; case 'M': $modified_date = strtotime('+ ' . $snooze['duration'] . ' months', $base_date); break; } if (!empty($modified_date)){ mysql_query("update healingcrystals_project_object_misc set reminder_date='" . date('Y-m-d H:i:s', $modified_date) . "' where object_id='" . $this->active_task->getId() . "'"); } } } }*/ //$query = mysql_query("select now() as cur_time"); //$info = mysql_fetch_assoc($query); //$base_date = strtotime($info['cur_time']); $base_date = new DateTimeValue(); $base_date->advance(get_system_gmt_offset($this->logged_user), true); //$base_date->advance(get_user_gmt_offset($this->logged_user), true); $modified_date = ''; if ($snooze['duration'] > 0) { switch ($snooze['unit']) { case 'I': $modified_date = strtotime('+ ' . $snooze['duration'] . ' minutes', $base_date->getTimestamp()); break; case 'H': $modified_date = strtotime('+ ' . $snooze['duration'] . ' hours', $base_date->getTimestamp()); break; case 'D': $modified_date = strtotime('+ ' . $snooze['duration'] . ' days', $base_date->getTimestamp()); break; case 'W': $modified_date = strtotime('+ ' . $snooze['duration'] . ' weeks', $base_date->getTimestamp()); break; case 'M': $modified_date = strtotime('+ ' . $snooze['duration'] . ' months', $base_date->getTimestamp()); break; } if (!empty($modified_date)) { $sql = "select object_id from " . TABLE_PREFIX . "project_object_misc where object_id='" . $this->active_task->getId() . "'"; $result = mysql_query($sql); if (mysql_num_rows($result)) { mysql_query("update healingcrystals_project_object_misc set last_modified=now(), snooze_datetime='" . date('Y-m-d H:i:s', $modified_date) . "' where object_id='" . $this->active_task->getId() . "'"); } else { mysql_query("insert into " . TABLE_PREFIX . "project_object_misc (object_id, date_added, snooze_datetime) values ('" . $this->active_task->getId() . "', now(), '" . date('Y-m-d H:i:s', $modified_date) . "')"); } } } $this->redirectToUrl($this->active_task->getViewUrl() . '#task' . $this->active_task->getId()); } else { /*$snooze = array('duration' => '', 'unit' => ''); $result = mysql_query("select snooze_duration, snooze_unit from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'"); if (mysql_num_rows($result)){ $info = mysql_fetch_assoc($result); if (!empty($info['snooze_duration'])) $snooze['duration'] = $info['snooze_duration']; if (!empty($info['snooze_unit'])) $snooze['unit'] = $info['snooze_unit']; }*/ $snooze_date = 'Not Set'; $result = mysql_query("select snooze_datetime from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'"); if (mysql_num_rows($result)) { $info = mysql_fetch_assoc($result); if (!empty($info['snooze_datetime'])) { $snooze_date = date('m-d-Y H:i', strtotime($info['snooze_datetime'])); } } } mysql_close($link); $this->smarty->assign(array('form_action_url' => assemble_url('project_task_snoozereminder', array('project_id' => $this->active_project->getId(), 'task_id' => $this->active_task->getId())), 'snooze_date' => $snooze_date)); }
function test_find() { //Arrange $task_name = "Wash the dog"; $due_date = "2015-08-22"; $id1 = 1; $test_Task = new Task($task_name, $id1, $due_date); $test_Task->save(); $task_name2 = "Water the lawn"; $due_date2 = "2015-08-25"; $id2 = 2; $test_Task2 = new Task($task_name2, $id2, $due_date2); $test_Task2->save(); //Act $id = $test_Task->getId(); $result = Task::find($id); //Assert $this->assertEquals($test_Task, $result); }
/** * Declares an association between this object and a Task object. * * @param Task $v * @return OverrideTask The current object (for fluent API support) * @throws PropelException */ public function setTaskRelatedByOverrideTaskId(Task $v = null) { if ($v === null) { $this->setOverrideTaskId(NULL); } else { $this->setOverrideTaskId($v->getId()); } $this->aTaskRelatedByOverrideTaskId = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Task object, it will not be re-added. if ($v !== null) { $v->addOverrideTaskRelatedByOverrideTaskId($this); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Task $value A Task object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Task $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
function test_find() { $name = "Home stuff"; $id = null; $due_date = '0000-00-00'; $test_category = new Category($name, $id); $test_category->save(); $description = "Wash the dog"; $category_id = $test_category->getId(); $test_task = new Task($description, $id, $category_id, $due_date); $test_task->save(); $description2 = "Water the lawn"; $test_task2 = new Task($description2, $id, $category_id, $due_date); $test_task2->save(); $result = Task::find($test_task->getId()); $this->assertEquals($test_task, $result); }
$Author = "PAS Pagebuilder"; $Keywords = "PAS Pagebuilder SQLFusion Web authoring tool"; $Description = "The best way to built rich web sites"; $background_color = "white"; $background_image = "none"; include_once "config.php"; include_once "includes/header.inc.php"; include_once "pb_globaldivs.sys.php"; ?> <DIV id="DRAG_script_Script" style="top:46px;left:237px;height:267px;width:451px;position:absolute;visibility:visible;z-index:5;"> <!--META metainfo="execorder:30;filename:includes/blank_script.script.inc.php;" --><?php $do_task = new Task($GLOBALS['conx']); $do_task->getTaskAddForm(); echo '<br><br><br> Following is just the edit example for the task id 1 <br><br>'; $TaskEdit = new Task($GLOBALS['conx']); $TaskEdit->getId(1); $TaskEdit->sessionPersistent("TaskEdit", "index.php", 120); // $TaskEdit->newUpdateForm("TaskEdit"); $e_task = new Event("TaskEdit->eventValuesFromForm"); $e_task->setLevel(1999); $e_task->addEventAction("TaskEdit->eventSetDateInFormat", 20); $e_task->addEventAction("TaskEdit->update", 2000); echo $e_task->getFormHeader(); echo $e_task->getFormEvent(); $_SESSION['TaskEdit']->setRegistry("task"); $_SESSION['TaskEdit']->setApplyRegistry(true, "Form"); echo $_SESSION['TaskEdit']->task_description; echo '<br><br>'; $_SESSION['TaskEdit']->due_date = $TaskEdit->convertDateToString($TaskEdit->getDateFormatForTask(1)); echo $_SESSION['TaskEdit']->due_date; echo '<br><br>';
function test_find() { //Arrange $id = 1; $description = "Wash the dog"; $date_due = "1990-12-11"; $time_due = "09:00:00"; $test_task = new Task($id, $description, $date_due, $time_due); $test_task->save(); $id2 = 2; $description2 = "Water the lawn"; $date_due2 = "1990-11-11"; $time_due2 = "09:01:00"; $test_task2 = new Task($id2, $description2, $date_due2, $time_due2); $test_task2->save(); //Act $result = Task::find($test_task->getId()); //Assert $this->assertEquals($test_task, $result); }
/** * Save or update task * @param Task $task * @return Task */ public function saveTask(Task $task) { if (is_null($task->getId())) { $query = $this->db->prepare("INSERT INTO tasks (name, parameters, status) VALUES (?, ?, ?)"); $query->execute([$task->getName(), $task->getParameters(), $task->getStatus()]); $task->setId($this->db->lastInsertId()); } else { $query = $this->db->prepare("UPDATE tasks SET name = ?, parameters = ?, status = ? WHERE id = ?"); $query->execute([$task->getName(), $task->getParameters(), $task->getStatus(), $task->getId()]); } return $task; }
function test_find() { //Arrange $name = "Home stuff"; $id = null; $test_category = new Category($name, $id); $test_category->save(); $description = "Wash the dog"; $user_date = "2015-08-18"; $category_id = $test_category->getId(); $test_task = new Task($description, $user_date, $id, $category_id); $test_task->save(); $description2 = "Water the lawn"; $user_date2 = "2015-08-18"; $test_task2 = new Task($description2, $user_date2, $id, $category_id); $test_task2->save(); //Act $result = Task::find($test_task->getId()); //Assert $this->assertEquals($test_task, $result); }
/** * Do daily taks * * @param void * @return null */ function system_handle_on_daily() { ProjectObjectViews::cleanUp(); $priorities_images = array(PRIORITY_URGENT => 'assets/images/icons/priority/urgent.png', PRIORITY_HIGHEST => 'assets/images/icons/priority/highest.gif', PRIORITY_HIGH => 'assets/images/icons/priority/high.gif', PRIORITY_NORMAL => 'assets/images/icons/priority/normal.gif', PRIORITY_LOW => 'assets/images/icons/priority/low.gif', PRIORITY_LOWEST => 'assets/images/icons/priority/lowest.gif', PRIORITY_HOLD => 'assets/images/icons/priority/hold.png', '-99' => 'assets/images/icons/priority/unknown.png'); $pages = array(); $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME); $sql = "select id, name from healingcrystals_project_objects where project_id='" . TASK_LIST_PROJECT_ID . "' and type='Page'"; $result = mysql_query($sql, $link); while ($entry = mysql_fetch_assoc($result)) { list($name, ) = explode('-', $entry['name']); $name = trim($name); $pages[$name] = $entry['id']; } $current_time = time(); $users = Users::findAll(); foreach ($users as $user) { $flag = 1; $message = ''; $name = $user->getName(); if (array_key_exists($name, $pages)) { $page = new Page($pages[$name]); if ($page) { $sql = "select id from healingcrystals_project_objects where parent_id='" . $pages[$name] . "' and parent_type='Page' and type='Task' and completed_on is null and priority is null and created_on>='" . date('Y-m-d H:i:s', $current_time - 1 * 24 * 60 * 60) . "' order by created_on"; $result = mysql_query($sql, $link); if (mysql_num_rows($result)) { $show_task_list = true; } else { $show_task_list = false; } if (date('N') == '1' || $show_task_list) { $message .= '<style> .odd {background-color:#ffffff;} .even{background-color:#eeeeee;} </style> <table> <tr> <td colspan="3">Task List: ' . $name . '</td> </tr> <tr> <td align="center">Priority</td> <td>Task</td> <td> </td> </tr>'; $tasks = Tasks::findOpenByObject($page); foreach ($tasks as $task) { $message .= ' <tr class="' . ($flag % 2 === 1 ? 'odd' : 'even') . '"> <td valign="top" align="center"><img src="http://projects.ffbh.org/public/' . $priorities_images[$task->getPriority()] . '"/></td> <td valign="top">' . $task->getName() . '</td> <td valign="top"><a href="' . $task->getViewUrl() . '">View</a></td> </tr>'; $flag++; } $message .= ' </table>'; $subject = 'projects: healingcrystals.com Task list'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; $headers .= 'From: FFBH Reminder <*****@*****.**>' . "\r\n"; mail($user->getEmail(), $subject, $message, $headers); } } } } $sql = "select po.id, cast(if( pom.recurring_period_type='D', DATE_ADD(po.due_on, interval pom.recurring_period day), if(pom.recurring_period_type='W', DATE_ADD(po.due_on, interval pom.recurring_period week), if(pom.recurring_period_type='M', DATE_ADD(po.due_on, interval pom.recurring_period month), null ) ) ) as Date) as next_due_date, cast(DATE_ADD(now(), interval 0 day) as Date) as cur_date, cast(if(isnull(pom.email_reminder_unit), null, if( pom.email_reminder_unit='D', DATE_ADD(po.due_on, interval pom.email_reminder_period day), if(pom.email_reminder_unit='W', DATE_ADD(po.due_on, interval pom.email_reminder_period week), if(pom.email_reminder_unit='M', DATE_ADD(po.due_on, interval pom.email_reminder_period month), null ) ) )\t) as Date) as reminder_date from healingcrystals_project_objects po inner join healingcrystals_project_object_misc pom on po.id=pom.object_id where po.type='Task' and po.due_on is not null and po.due_on<=now() and po.completed_on is null and pom.recurring_period_condition='after_due_date' and if(pom.recurring_end_date is not null and pom.recurring_end_date!='0000-00-00', if(pom.recurring_end_date>=now(), 1, 0), 1)=1 having next_due_date=cur_date"; $result = mysql_query($sql); while ($entry = mysql_fetch_assoc($result)) { $task = new Task($entry['id']); $action = $task->complete(new AnonymousUser('auto', '*****@*****.**')); if (!empty($entry['reminder_date']) && $entry['cur_date'] == $entry['reminder_date']) { $sql02 = "select id from " . TABLE_PREFIX . "project_objects where type='Task' and project_id='" . $task->getProjectId() . "' and milestone_id='" . $task->getMilestoneId() . "' and parent_id='" . $task->getParentId() . "' order by id desc limit 0, 1"; $result02 = mysql_query($sql02); if (mysql_num_rows($result02)) { $info = mysql_fetch_assoc($result02); $recurring_task = new Task($info['id']); $parent = $recurring_task->getParent(); $project = $recurring_task->getProject(); $assignees = $recurring_task->getAssignees(); $priorities = array(PRIORITY_HIGHEST => lang('Highest'), PRIORITY_HIGH => lang('High'), PRIORITY_NORMAL => lang('Normal'), PRIORITY_LOW => lang('Low'), PRIORITY_LOWEST => lang('Lowest'), PRIORITY_ONGOING => lang('Ongoing'), PRIORITY_HOLD => lang('Hold')); $due_date = $task->getDueOn(); $due_date = date('m/d/Y', strtotime($due_date)); $reminder_date = date('m/d/Y', strtotime($entry['reminder_date'])); foreach ($assignees as $assignee) { $assignees_string .= $assignee->getDisplayName() . ', '; } if (!empty($assignees_string)) { $assignees_string = substr($assignees_string, 0, -2); } else { $assignees_string = '--'; } $reminders_sent = array(); foreach ($assignees as $user) { //if ($user->getEmail()=='*****@*****.**'){ $reminder = new Reminder(); $reminder->setAttributes(array('user_id' => $user->getId(), 'object_id' => $recurring_task->getId(), 'comment' => $comment)); $save = $reminder->save(); if ($save && !is_error($save)) { $reminders_sent[] = $user->getDisplayName(); ApplicationMailer::send($user, 'system/reminder', array('reminded_by_name' => 'AutoReminder', 'reminded_by_url' => '', 'object_name' => $recurring_task->getName(), 'object_url' => $recurring_task->getViewUrl(), 'object_type' => strtolower($recurring_task->getType()), 'comment_body' => $comment, 'project_name' => $project->getName(), 'project_url' => $project->getOverviewUrl(), 'ticket_name' => $parent->getName(), 'ticket_url' => $parent->getViewUrl(), 'object_priority' => $priorities[(string) $recurring_task->getPriority()], 'object_due_date' => $due_date, 'object_reminder_date_n_time' => $reminder_date, 'object_assignees' => $assignees_string, 'task_mark_complete_url' => $recurring_task->getCompleteUrl() . '&auto=1', 'display_status_for_complete_url' => $recurring_task->is_action_request_task() ? '' : 'none'), $recurring_task); } //} } } } } mysql_close($link); }
function test_find() { //Arrange $description = "Wash the dog"; $due_date = '2015-01-01'; $id = 1; $test_task = new Task($description, $id, $due_date); $test_task->save(); $description2 = "Water the lawn"; $id2 = 2; $test_task2 = new Task($description2, $id2, $due_date); $test_task2->save(); //Act $result = Task::find($test_task->getId()); //Assert $this->assertEquals($test_task, $result); }
/** * 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; }