Example #1
0
 public function getDeepChildren()
 {
     $children = $this->getChildren();
     if ($children) {
         $deep_children = array();
         $tempTask = new CTask();
         foreach ($children as $child) {
             $tempTask->peek($child);
             $deep_children = array_merge($deep_children, $tempTask->getDeepChildren());
         }
         return array_merge($children, $deep_children);
     }
     return array();
 }
 function getDeepChildren()
 {
     $q = new DBQuery();
     $q->addTable('tasks');
     $q->addQuery('task_id');
     $q->addWhere("task_id <> '" . $this->task_id . "' AND task_parent = '" . $this->task_id . "'");
     $sql = $q->prepare();
     $q->clear();
     $children = db_loadColumn($sql);
     if ($children) {
         $deep_children = array();
         $tempTask = new CTask();
         foreach ($children as $child) {
             $tempTask->peek($child);
             $deep_children = array_merge($deep_children, $tempTask->getDeepChildren());
         }
         return array_merge($children, $deep_children);
     }
     return array();
 }
Example #3
0
$q->addQuery('project_id, project_color_identifier, project_name' . ', project_start_date, project_end_date');
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
$q->addWhere('project_status != 7');
$q->addGroup('project_id');
$q->addOrder('project_name');
$project->setAllowedSQL($AppUI->user_id, $q);
$projects = $q->loadHashList('project_id');
$q->clear();
$caller = defVal(@$_REQUEST['caller'], null);
/**
 * if task filtering has been requested create the list of task_ids
 * which will be used to filter the query
 */
if ($ganttTaskFilter > 0) {
    $task_child_search = new CTask();
    $task_child_search->peek($ganttTaskFilter);
    //$childrenlist[] = $ganttTaskFilter;
    //print_r($childrenlist);
    $childrenlist = $task_child_search->getDeepChildren();
    //print_r($childrenlist);
    $where .= ' t.task_id IN (' . $ganttTaskFilter . ', ' . implode(', ', $childrenlist) . ')';
}
//else {
//	$where = '';
//}
//echo '<pre> $where = ' . $where . '</pre>';
//die;
// gantt is called now by the todo page, too. There is a different filter approach in todo
// so we have to tweak a little bit, also we do not have a special project available
if ($caller == 'todo') {
    $user_id = defVal(@$_REQUEST['user_id'], 0);
Example #4
0
// get any specifically denied tasks
$task = new CTask();
$task->setAllowedSQL($AppUI->user_id, $q);
$proTasks_data = $q->loadHashList('task_id');
$q->clear();
$orrarr[] = array('task_id' => 0, 'order_up' => 0, 'order' => '');
$end_max = '0000-00-00 00:00:00';
$start_min = date('Y-m-d H:i:s');
//pull the tasks into an array
$criticalTasks = $project->getCriticalTasks($project_id);
$actual_end_date = new CDate($criticalTasks[0]['task_end_date']);
$p_end_date = $actual_end_date->after($project->project_end_date) ? $criticalTasks[0]['task_end_date'] : $project->project_end_date;
//filter out tasks denied based on task's access level
$proTasks = array();
foreach ($proTasks_data as $data_row) {
    $task->peek($data_row['task_id']);
    if ($task->canAccess($AppUI->user_id)) {
        $proTasks[] = $data_row;
    }
}
foreach ($proTasks as $row) {
    // calculate or set blank task_end_date if unset
    if ($row['task_end_date'] == '0000-00-00 00:00:00') {
        if ($row['task_duration'] && $row['task_start_date'] != '0000-00-00 00:00:00') {
            $start_date_unix_time = db_dateTime2unix($row['task_start_date']) + SECONDS_PER_DAY * convert2days($row['task_duration'], $row['task_duration_type']);
            $row['task_end_date'] = mb_substr(db_unix2dateTime($start_date_unix_time), 1, -1);
        } else {
            $row['task_end_date'] = $p_end_date;
        }
    }
    if ($row['task_start_date'] == '0000-00-00 00:00:00') {
Example #5
0
<?php

/* $Id$ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $task_id;
$task_id = intval(dPgetParam($_GET, 'task_id', 0));
$task_log_id = intval(dPgetParam($_GET, 'task_log_id', 0));
$reminded = intval(dPgetParam($_GET, 'reminded', 0));
$obj = new CTask();
$obj->peek($task_id);
//we need to peek at the task's data to determine its access level
$msg = '';
// check permissions for this record
$canAccess = getPermission($m, 'access', $task_id);
$canRead = getPermission($m, 'view', $task_id);
$canEdit = getPermission($m, 'edit', $task_id);
// check if this record has dependencies to prevent deletion
$canDelete = $obj->canDelete($msg, $task_id);
// check permissions for this record (module level)
$canReadModule = getPermission($m, 'view');
if (!($canRead && $obj->canAccess($AppUI->user_id))) {
    $AppUI->redirect('m=public&a=access_denied');
}
$q = new DBQuery();
$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);
Example #6
0
$f = $f ? $f : '';
$never_show_with_dots = array('');
//used when displaying tasks
switch ($f) {
    case 'all':
        break;
    case 'myfinished7days':
        $where .= ' AND user_tasks.user_id = ' . $user_id;
    case 'allfinished7days':
        // patch 2.12.04 tasks finished in the last 7 days
        $from = 'user_tasks, ' . $from;
        $where .= ' AND task_project = projects.project_id AND user_tasks.task_id = tasks.task_id ' . "AND task_percent_complete = 100 AND task_end_date >= '" . date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d') - 7, date('Y'))) . "'";
        break;
    case 'children':
        $task_child_search = new CTask();
        $task_child_search->peek($task_id);
        $childrenlist = $task_child_search->getDeepChildren();
        $where .= ' AND tasks.task_id IN (' . implode(',', $childrenlist) . ')';
        break;
    case 'myproj':
        $where .= ' AND project_owner = ' . $user_id;
        break;
    case 'mycomp':
        if (!$AppUI->user_company) {
            $AppUI->user_company = 0;
        }
        $where .= ' AND project_company = ' . $AppUI->user_company;
        break;
    case 'myunfinished':
        $from = 'user_tasks, ' . $from;
        // This filter checks all tasks that are not already in 100%
Example #7
0
 /**
  * @todo Parent store could be partially used
  */
 function store()
 {
     global $AppUI;
     $q =& new DBQuery();
     $this->dPTrimAll();
     $importing_tasks = false;
     $msg = $this->check();
     if ($msg) {
         $return_msg = array(get_class($this) . '::store-check', 'failed', '-');
         if (is_array($msg)) {
             return array_merge($return_msg, $msg);
         } else {
             array_push($return_msg, $msg);
             return $return_msg;
         }
     }
     if ($this->task_id) {
         addHistory('tasks', $this->task_id, 'update', $this->task_name, $this->task_project);
         $this->_action = 'updated';
         // Load and globalize the old, not yet updated task object
         // e.g. we need some info later to calculate the shifting time for depending tasks
         // see function update_dep_dates
         global $oTsk;
         $oTsk = new CTask();
         $oTsk->peek($this->task_id);
         // if task_status changed, then update subtasks
         if ($this->task_status != $oTsk->task_status) {
             $this->updateSubTasksStatus($this->task_status);
         }
         // Moving this task to another project?
         if ($this->task_project != $oTsk->task_project) {
             $this->updateSubTasksProject($this->task_project);
         }
         if ($this->task_dynamic == 1) {
             $this->updateDynamics(true);
         }
         // shiftDependentTasks needs this done first
         $this->check();
         $ret = db_updateObject('tasks', $this, 'task_id', false);
         // Milestone or task end date, or dynamic status has changed,
         // shift the dates of the tasks that depend on this task
         if ($this->task_end_date != $oTsk->task_end_date || $this->task_dynamic != $oTsk->task_dynamic || $this->task_milestone == '1') {
             $this->shiftDependentTasks();
         }
     } else {
         $this->_action = 'added';
         $ret = db_insertObject('tasks', $this, 'task_id');
         addHistory('tasks', $this->task_id, 'add', $this->task_name, $this->task_project);
         if (!$this->task_parent) {
             $q->addTable('tasks');
             $q->addUpdate('task_parent', $this->task_id);
             $q->addWhere('task_id = ' . $this->task_id);
             $q->exec();
             $q->clear();
         } else {
             // importing tasks do not update dynamics
             $importing_tasks = true;
         }
         // insert entry in user tasks
         $q->addTable('user_tasks');
         $q->addInsert('user_id', $AppUI->user_id);
         $q->addInsert('task_id', $this->task_id);
         $q->addInsert('user_type', '0');
         $q->exec();
         $q->clear();
     }
     //split out related departments and store them seperatly.
     $q->setDelete('task_departments');
     $q->addWhere('task_id=' . $this->task_id);
     $q->exec();
     $q->clear();
     // print_r($this->task_departments);
     if (!empty($this->task_departments)) {
         $departments = explode(',', $this->task_departments);
         foreach ($departments as $department) {
             $q->addTable('task_departments');
             $q->addInsert('task_id', $this->task_id);
             $q->addInsert('department_id', $department);
             $q->exec();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('task_contacts');
     $q->addWhere('task_id=' . $this->task_id);
     $q->exec();
     $q->clear();
     if (!empty($this->task_contacts)) {
         $contacts = explode(',', $this->task_contacts);
         foreach ($contacts as $contact) {
             $q->addTable('task_contacts');
             $q->addInsert('task_id', $this->task_id);
             $q->addInsert('contact_id', $contact);
             $q->exec();
             $q->clear();
         }
     }
     // if is child update parent task
     if ($this->task_parent != $this->task_id) {
         if (!$importing_tasks) {
             $this->updateDynamics(true);
         }
         $pTask = new CTask();
         $pTask->load($this->task_parent);
         $pTask->updateDynamics();
         if ($oTsk->task_parent != $this->task_parent) {
             $old_parent = new CTask();
             $old_parent->load($oTsk->task_parent);
             $old_parent->updateDynamics();
         }
     }
     // update dependencies
     if (!empty($this->task_id)) {
         $this->updateDependencies($this->getDependencies());
     } else {
         print_r($this);
     }
     if (!$ret) {
         return get_class($this) . '::store failed <br />' . db_error();
     } else {
         return NULL;
     }
 }