$q =& new DBQuery(); $perms =& $AppUI->acl(); $q->addTable('tasks'); $q->leftJoin('users', 'u1', 'u1.user_id = task_owner'); $q->leftJoin('projects', 'p', 'p.project_id = task_project'); $q->leftJoin('task_log', 'tl', 'tl.task_log_task = task_id'); $q->addWhere('task_id = ' . $task_id); $q->addQuery('tasks.*'); $q->addQuery('project_name, project_color_identifier'); $q->addQuery('u1.user_username as username'); $q->addQuery('ROUND(SUM(task_log_hours),2) as log_hours_worked'); $q->addGroup('task_id'); // check if this record has dependencies to prevent deletion $msg = ''; $obj = new CTask(); $canDelete = $obj->canDelete($msg, $task_id); //$obj = null; $sql = $q->prepare(); $q->clear(); if (!db_loadObject($sql, $obj, true, false)) { $AppUI->setMsg('Task'); $AppUI->setMsg("invalidID", UI_MSG_ERROR, true); $AppUI->redirect(); } else { $AppUI->savePlace(); } if (!$obj->canAccess($AppUI->user_id)) { $AppUI->redirect("m=public&a=access_denied"); } // retrieve any state parameters if (isset($_GET['tab'])) {
<?php if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } // @todo convert to template $task_id = (int) w2PgetParam($_GET, 'task_id', 0); $task_log_id = (int) w2PgetParam($_GET, 'task_log_id', 0); $tab = $AppUI->processIntState('TaskLogVwTab', $_GET, 'tab', 0); $obj = new CTask(); if (!$obj->load($task_id)) { $AppUI->redirect(ACCESS_DENIED); } $canEdit = $obj->canEdit(); $canDelete = $obj->canDelete(); /** * Clear any reminders * @todo THIS SHOULD NOT HAPPEN HERE.. VIEWING SHOULD BE IDEMPOTENT */ $reminded = (int) w2PgetParam($_GET, 'reminded', 0); if ($reminded) { $obj->clearReminder(); } //check permissions for the associated project $canReadProject = canView('projects', $obj->task_project); $users = $obj->assignees($task_id); // setup the title block $titleBlock = new w2p_Theme_TitleBlock('View Task', 'icon.png', $m); $titleBlock->addCell(); if ($canReadProject) { $titleBlock->addCrumb('?m=projects&a=view&project_id=' . $obj->task_project, 'view this project');