function projViewFiles()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "render/render_wiki.inc.php";
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    $project = Project::getVisibleById($id);
    if (!$project || !$project->id) {
        $PH->abortWarning(__("invalid project-id"));
        return;
    }
    ### define from-handle ###
    $PH->defineFromHandle(array('prj' => $project->id));
    ## is viewed by user ##
    $project->nowViewedByUser();
    ## next milestone ##
    $next = $project->getNextMilestone();
    $page = new Page();
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->cur_tab = 'projects';
    $page->title = $project->name;
    $page->title_minor = __("Downloads");
    if ($project->status == STATUS_TEMPLATE) {
        $page->type = __("Project Template");
    } else {
        if ($project->status >= STATUS_COMPLETED) {
            $page->type = __("Inactive Project");
        } else {
            $page->type = __("Project", "Page Type");
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    measure_stop('init2');
    measure_start('info');
    $block = new PageBlock(array('id' => 'support'));
    $block->render_blockStart();
    echo "<div class=text>";
    if ($task = Task::getVisibleById(3645)) {
        echo wikifieldAsHtml($task, 'description');
    }
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 2
0
/**
* test function for development @ingroup pages
*
* the output of this function could be requested with jquery like:
*
*       $('#sideboard div').load('index.php?go=taskAjax',{
*        go: 'taskAjax',
*        tsk: id
*       });
*/
function taskAjax()
{
    if ($task_id = intval(get('tsk'))) {
        require_once "render/render_wiki.inc.php";
        ### headline ###
        $editable = false;
        # flag, if this task can be edited
        if ($task = Task::getEditableById($task_id)) {
            $editable = true;
        } else {
            if (!($task = Task::getVisibleById($task_id))) {
                echo "Failure";
                return;
            }
        }
        echo "<h3>" . asHtml($task->name) . "</h3>";
        echo wikifieldAsHtml($task, 'description');
    }
}
Ejemplo n.º 3
0
/**
* list tasks of a project @ingroup pages
*/
function projViewTasks()
{
    global $PH;
    global $auth;
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    if (!($project = Project::getVisibleById($id))) {
        $PH->abortWarning("invalid project-id");
        return;
    }
    ### get upcoming or selected milestone ###
    /*
    pixtur: 2008-09-60
    WARNING: Selecting a milestone directly to limit the viewed tasks
    does not work because editing a task with a milestone will compromize
    the following task list. I have no idea, why this code is in here,
    or weather it is required at all.
    */
    $for_milestone = intval(get("for_milestone"));
    $milestone = NULL;
    if ($for_milestone) {
        $milestone = Task::getVisibleById($for_milestone);
    }
    #if($milestone= $project->getNextMilestone()) {
    #    $for_milestone= $milestone->id;
    #}
    $presets = array('all_tasks' => array('name' => __('all'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_NEW, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'tree'))), 'open_tasks' => array('name' => __('open'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED, STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'my_open_tasks' => array('name' => __('my open'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED), 'min' => STATUS_NEW, 'max' => STATUS_BLOCKED), 'assigned_to' => array('id' => 'assigned_to', 'visible' => true, 'active' => true, 'value' => $auth->cur_user->id)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('task_assign_to_0' => $auth->cur_user->id)), 'next_milestone' => array('name' => __('for milestone'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => false, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED, STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'for_milestone' => array('id' => 'for_milestone', 'visible' => true, 'active' => true, 'value' => $for_milestone)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('for_milestone' => $for_milestone)), 'needs_feedback' => array('name' => __('modified'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'not_modified_by' => $auth->cur_user->id), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'approve_tasks' => array('name' => __('needs approval'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_COMPLETED, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'without_milestone' => array('name' => __('without milestone'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'for_milestone' => array('id' => 'for_milestone', 'visible' => true, 'active' => true, 'value' => 0)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'closed_tasks' => array('name' => __('closed'), 'filter_empty_folders' => false, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_APPROVED, STATUS_CLOSED), 'min' => STATUS_APPROVED, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))));
    ## set preset location ##
    $preset_location = 'projViewTasks';
    $preset_id = 'open_tasks';
    # default value
    if ($tmp_preset_id = get('preset')) {
        if (isset($presets[$tmp_preset_id])) {
            $preset_id = $tmp_preset_id;
        }
        ### set cookie
        setcookie('STREBER_projViewTasks_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0);
    } else {
        if ($tmp_preset_id = get('STREBER_projViewTasks_preset')) {
            if (isset($presets[$tmp_preset_id])) {
                $preset_id = $tmp_preset_id;
            }
        }
    }
    if ($milestone) {
        ### create from handle ###
        $PH->defineFromHandle(array('prj' => $project->id, 'preset_id' => $preset_id, 'for_milestone' => $milestone->id));
    } else {
        ### create from handle ###
        $PH->defineFromHandle(array('prj' => $project->id, 'preset_id' => $preset_id));
    }
    $page = new Page();
    ### init known filters for preset ###
    $list = new ListBlock_tasks(array('active_block_function' => 'tree'));
    $list->filters[] = new ListFilter_category_in(array('value' => array(TCATEGORY_TASK, TCATEGORY_BUG)));
    $preset = $presets[$preset_id];
    foreach ($preset['filters'] as $f_name => $f_settings) {
        switch ($f_name) {
            case 'task_status':
                $list->filters[] = new ListFilter_status_min(array('value' => $f_settings['min']));
                $list->filters[] = new ListFilter_status_max(array('value' => $f_settings['max']));
                break;
            case 'assigned_to':
                $list->filters[] = new ListFilter_assigned_to(array('value' => $f_settings['value']));
                break;
            case 'for_milestone':
                $list->filters[] = new ListFilter_for_milestone(array('value' => $f_settings['value']));
                break;
            case 'not_modified_by':
                $list->filters[] = new ListFilter_not_modified_by(array('value' => $f_settings['value']));
                break;
            default:
                trigger_error("Unknown filter setting {$f_name}", E_USER_WARNING);
                break;
        }
    }
    $filter_empty_folders = isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'] ? true : NULL;
    $page->cur_tab = 'projects';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->title = $project->name;
    if (isset($preset['name'])) {
        $page->title_minor = $preset['name'];
        if ($preset_id == 'next_milestone' && isset($milestone) && isset($milestone->name)) {
            $page->title_minor = __('Milestone') . ' ' . $milestone->name;
        }
    } else {
        $page->title_minor = __("Tasks");
    }
    if ($project->status == STATUS_TEMPLATE) {
        $page->type = __("Project Template");
    } else {
        if ($project->status >= STATUS_COMPLETED) {
            $page->type = __("Inactive Project");
        } else {
            $page->type = __("Project", "Page Type");
        }
    }
    ### page functions ###
    $new_task_options = isset($preset['new_task_options']) ? $preset['new_task_options'] : array();
    if ($project->isPersonVisibleTeamMember($auth->cur_user)) {
        #$page->add_function(new PageFunctionGroup(array(
        #    'name'=>__('new'),
        #)));
        if ($preset_id != 'next_milestone') {
            $page->add_function(new PageFunction(array('target' => 'taskNewFolder', 'params' => array('prj' => $project->id) + $new_task_options, 'icon' => 'new', 'tooltip' => __('Create a new folder for tasks and files'))));
        }
        $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('prj' => $project->id) + $new_task_options, 'icon' => 'new', 'tooltip' => __('new subtask for this folder'))));
        if ($project->settings & PROJECT_SETTING_ENABLE_BUGS) {
            $page->add_function(new PageFunction(array('target' => 'taskNewBug', 'params' => array('prj' => $project->id, 'add_issue' => 1) + $new_task_options, 'icon' => 'new', 'tooltip' => __('Create task with issue-report'))));
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    ### list available presets ###
    if ($page->format != FORMAT_CSV) {
        $page->print_presets(array('target' => $preset_location, 'project_id' => $project->id, 'preset_id' => $preset_id, 'presets' => $presets, 'person_id' => ''));
    }
    if ($page->format == FORMAT_HTML) {
        $PH->go_submit = 'taskNew';
        echo '<input type="hidden" name="prj" value="' . $id . '">';
        /**
         * add preset specific options (like milestone,etc) as hidden fields
         * e.i. if we list tasks for a milestone, new tasks require to belong to this
         * milestone, otherwise they are not visible after creation
         */
        foreach ($new_task_options as $name => $value) {
            echo "<input type=hidden name='{$name}' value='{$value}'>";
        }
        ### Link to start cvs export ###
        $format = get('format');
        if ($format == FORMAT_HTML || $format == '') {
            $list->footer_links[] = $PH->getCSVLink();
        }
    }
    if ($for_milestone) {
        $list->filters[] = new ListFilter_for_milestone(array('value' => $for_milestone));
    }
    $list->show_project_folder = false;
    unset($list->columns['project']);
    unset($list->columns['planned_start']);
    /**
     * NOTE: pixtur 2006-10-13
     * for a clean version of this list with a AJAX-driven side board
     * following columns should be hidden:
     */
    if (confGet('TASKDETAILS_IN_SIDEBOARD')) {
        unset($list->columns['assigned_to']);
        #unset($list->columns['for_milestone']);
        unset($list->columns['estimate_complete']);
        unset($list->columns['pub_level']);
        #unset($list->columns['_select_col_']);
        unset($list->columns['label']);
    }
    if (!confGet('TASK_LIST_EFFORT_COLUMN')) {
        unset($list->columns['efforts']);
    }
    $list->no_items_html = __('No tasks');
    $list->print_automatic($project, NULL, $filter_empty_folders);
    #echo "<a href=\"javascript:document.my_form.go.value='tasksMoveToFolder';document.my_form.submit();\">move to task-folder</a>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 4
0
/**
* export selected efforts as a CSV ready for copy and paste into a spread-sheet  @ingroup pages
**
*/
function effortShowAsCSV()
{
    global $PH;
    global $g_effort_status_names;
    $effort_ids = getPassedIds('effort', 'efforts_*');
    if (!$effort_ids) {
        $PH->abortWarning(__("Select some efforts(s) to show"));
        exit;
    }
    $efforts = array();
    $different_fields = array();
    $edit_fields = array('status', 'pub_level', 'task');
    foreach ($effort_ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $efforts[] = $effort;
            ### check project for first task
            if (count($efforts) == 1) {
                ### make sure all are of same project ###
                if (!($project = Project::getVisibleById($effort->project))) {
                    $PH->abortWarning('could not get project');
                }
            } else {
                if ($effort->project != $efforts[0]->project) {
                    $PH->abortWarning(__("For editing all efforts must be of same project."));
                }
                foreach ($edit_fields as $field_name) {
                    if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
                        $different_fields[$field_name] = true;
                    }
                }
            }
        }
    }
    $page = new Page(array('use_jscalendar' => true));
    $page->cur_tab = 'projects';
    $page->options[] = new naviOption(array('target_id' => 'effortEdit'));
    $page->type = __("Edit multiple efforts", "Page title");
    $page->title = sprintf(__("%s efforts for copy and pasting into a spread-sheet", "Page title"), count($efforts));
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
    $block->render_blockStart();
    $format = "[Date][Weekday][Task][Comment][Duration]";
    preg_match_all("/\\[(.*?)\\]/", $format, $matches);
    $overallDuration = 0;
    echo "<textarea style='width:96%; height:300px;'>";
    echo join("\t", $matches[1]) . "\n";
    foreach ($efforts as $e) {
        preg_match_all("/\\[(.*?)\\]/", $format, $matches);
        $separator = "";
        foreach ($matches[1] as $matchedFormat) {
            echo $separator;
            switch ($matchedFormat) {
                case "Date":
                    echo gmstrftime("%Y-%m-%d", strToGMTime($e->time_start));
                    break;
                case "Weekday":
                    echo gmstrftime("%a", strToGMTime($e->time_start));
                    break;
                case "Task":
                    if ($t = Task::getVisibleById($e->task)) {
                        echo $t->name;
                    }
                    break;
                case "Comment":
                    echo $e->name;
                    break;
                case "Duration":
                    $durationInMinutes = round((strToGMTime($e->time_end) - strToGMTime($e->time_start)) / 60, 0);
                    $roundUpTo15 = ceil($durationInMinutes / 15) * 15 / 60;
                    $overallDuration += $roundUpTo15;
                    echo number_format($roundUpTo15, 2, $dec_point = ',', '');
                    break;
            }
            $separator = "\t";
        }
        echo "\n";
    }
    echo "</textarea>";
    echo "<br>";
    echo __("Overall Duration:") . $overallDuration . "h";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
    exit;
}
Ejemplo n.º 5
0
 function render_tr(&$item, $style = "")
 {
     global $PH;
     $str_url = "";
     $str_name = "";
     $str_addon = "";
     $isDone = "";
     $html_details = "";
     $link = "";
     if ($type = $item->type) {
         switch ($type) {
             case ITEM_TASK:
                 require_once "db/class_task.inc.php";
                 if ($task = Task::getVisibleById($item->id)) {
                     $str_name = asHtml($task->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $task->id));
                     if ($task->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($task->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                         if ($tmp = $task->getFolderLinks()) {
                             $html_details .= ' > ' . $tmp;
                         }
                     }
                 }
                 break;
             case ITEM_COMMENT:
                 require_once "db/class_comment.inc.php";
                 if ($comment = Comment::getVisibleById($item->id)) {
                     $str_name = asHtml($comment->name);
                     if ($comment->comment) {
                         $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                         $str_addon = __("(on comment)");
                     } else {
                         if ($comment->task) {
                             $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                             $str_addon = __("(on task)");
                         } else {
                             $str_url = $PH->getUrl('projView', array('prj' => $comment->project));
                             $str_addon = __("(on project)");
                         }
                     }
                 }
                 break;
             case ITEM_PERSON:
                 require_once "db/class_person.inc.php";
                 if ($person = Person::getVisibleById($item->id)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 break;
             case ITEM_EFFORT:
                 require_once "db/class_effort.inc.php";
                 if ($e = Effort::getVisibleById($item->id)) {
                     $str_name = asHtml($e->name);
                     $str_url = $PH->getUrl('effortEdit', array('effort' => $e->id));
                 }
                 if ($prj = Project::getVisibleById($e->project)) {
                     $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                     $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                 }
                 break;
             case ITEM_FILE:
                 require_once "db/class_file.inc.php";
                 if ($f = File::getVisibleById($item->id)) {
                     $str_name = asHtml($f->org_filename);
                     $str_url = $PH->getUrl('fileView', array('file' => $f->id));
                     if ($f->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($f->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                     }
                 }
                 break;
             case ITEM_PROJECT:
                 require_once "db/class_project.inc.php";
                 if ($prj = Project::getVisibleById($item->id)) {
                     $str_name = asHtml($prj->name);
                     $str_url = $PH->getUrl('projView', array('prj' => $prj->id));
                     if ($prj->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                 }
                 break;
             case ITEM_COMPANY:
                 require_once "db/class_company.inc.php";
                 if ($c = Company::getVisibleById($item->id)) {
                     $str_name = asHtml($c->name);
                     $str_url = $PH->getUrl('companyView', array('company' => $c->id));
                 }
                 break;
             case ITEM_VERSION:
                 require_once "db/class_task.inc.php";
                 if ($tsk = Task::getVisibleById($item->id)) {
                     $str_name = asHtml($tsk->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $tsk->id));
                     if ($tsk->status >= STATUS_COMPLETED) {
                         $isDone = "class=isDone";
                     }
                     if ($prj = Project::getVisibleById($task->project)) {
                         $link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
                     }
                 }
                 break;
             default:
                 break;
         }
         print "<td class='nowrap'><span {$isDone}><a href='{$str_url}'>{$str_name}</a> {$str_addon}</span>";
         if ($html_details) {
             print "<br><span class='sub who'>{$html_details}</span>";
         }
         print "</td>";
     } else {
         $PH->abortWarning("Could not get type of the element.", ERROR_BUG);
         print "<td>&nbsp;</td>";
     }
 }
Ejemplo n.º 6
0
 /**
  * returns visible object of correct type by an itemId
  *
  * this is useful, eg. if you when to access common parameters like name,
  * regardless of the object's type.
  *
  * DbProjectItem::getById() would only load to basic fields. Getting the
  * complete date required check for type.
  *
  * @NOTE: This function causes a awkward dependency to classes derived from
  * DbProjectItem. It's somehow weird, that this method is placed inside the
  * parent class.
  */
 public static function getObjectById($id)
 {
     $id = intval($id);
     if (!($item = DbProjectItem::getById($id))) {
         return NULL;
     }
     if ($type = $item->type) {
         switch ($type) {
             case ITEM_TASK:
                 require_once "db/class_task.inc.php";
                 $item_full = Task::getVisibleById($item->id);
                 break;
             case ITEM_COMMENT:
                 require_once "db/class_comment.inc.php";
                 $item_full = Comment::getVisibleById($item->id);
                 break;
             case ITEM_PERSON:
                 require_once "db/class_person.inc.php";
                 $item_full = Person::getVisibleById($item->id);
                 break;
             case ITEM_EFFORT:
                 require_once "db/class_effort.inc.php";
                 $item_full = Effort::getVisibleById($item->id);
                 break;
             case ITEM_FILE:
                 require_once "db/class_file.inc.php";
                 $item_full = File::getVisibleById($item->id);
                 break;
             case ITEM_PROJECT:
                 require_once "db/class_project.inc.php";
                 $item_full = Project::getVisibleById($item->id);
                 break;
             case ITEM_COMPANY:
                 require_once "db/class_company.inc.php";
                 $item_full = Company::getVisibleById($item->id);
                 break;
             case ITEM_VERSION:
                 require_once "db/class_task.inc.php";
                 $item_full = Task::getVisibleById($item->id);
                 break;
             default:
                 $item_full = NULL;
         }
         return $item_full;
     }
 }
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     if (!isset($obj) || !$obj instanceof Effort) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     $sum = 0.0;
     $diff_str = '';
     $estimated_str = '';
     $str = '';
     $percent = '';
     /*if($obj->getStatus()){
     			$sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task, 'status'=>$obj->status));
     		}
     		else{*/
     $sum_task = Effort::getSumEfforts(array('project' => $obj->project, 'task' => $obj->task));
     #}
     if ($sum_task) {
         $sum = $sum_task;
     }
     if ($task = Task::getVisibleById($obj->task)) {
         $estimated = $task->estimated;
         $estimated_max = $task->estimated_max;
         if ($estimated_max) {
             $estimated_str = round($estimated_max / 60 / 60, 1) . "h";
             $diff = $estimated_max - $sum;
         } else {
             $estimated_str = round($estimated / 60 / 60, 1) . "h";
             $diff = $estimated - $sum;
         }
         if ($diff) {
             $diff_str = "(" . round($diff / 60 / 60, 1) . "h)";
         }
         $str = $estimated_str . " / " . round($sum / 60 / 60, 1) . "h {$diff_str}";
         $percent = __('Completion:') . " " . $task->completion . "%";
     }
     print "<td class=nowrap title='" . __("Relation between estimated time and booked efforts") . "'>{$str}<br><span class='sub who'>{$percent}</span></td>";
 }
Ejemplo n.º 8
0
/**
* Submit changes to a task
*
* @ingroup pages
*/
function taskEditSubmit()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'db/class_taskperson.inc.php';
    /**
     * keep a list of items linking to this task, task is new
     * we have to change the linking id after(!) inserting the task
     */
    $link_items = array();
    ### temporary object or from database? ###
    $tsk_id = getOnePassedId('tsk', '', true, 'invalid id');
    if ($tsk_id == 0) {
        $task = new Task(array('id' => 0, 'project' => get('task_project')));
        $was_category = 0;
        # undefined category for new tasks
        $was_resolved_version = 0;
    } else {
        if (!($task = Task::getVisiblebyId($tsk_id))) {
            $PH->abortWarning("invalid task-id");
        }
        $was_category = $task->category;
        $was_resolved_version = $task->resolved_version;
        $task->validateEditRequestTime();
    }
    ### cancel? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('taskView', array('tsk' => $task->id));
        }
        exit;
    }
    ### Validate integrety ###
    if (!validateFormCrc()) {
        $PH->abortWarning(__('Invalid checksum for hidden form elements'));
    }
    validateFormCaptcha(true);
    $was_a_folder = $task->category == TCATEGORY_FOLDER ? true : false;
    $was_released_as = $task->is_released;
    ### get project ###
    if (!($project = Project::getVisiblebyId($task->project))) {
        $PH->abortWarning("task without project?");
    }
    /**
     * adding comment (from quick edit) does only require view right...
     */
    $added_comment = false;
    ### check for request feedback
    if ($request_feedback = get('request_feedback')) {
        $team_members_by_nickname = array();
        foreach ($project->getProjectPeople() as $pp) {
            $team_members_by_nickname[$pp->getPerson()->nickname] = $pp->getPerson();
        }
        $requested_people = array();
        foreach (explode('\\s*,\\s*', $request_feedback) as $nickname) {
            ### now check if this nickname is a team member
            if ($nickname = trim($nickname)) {
                if (isset($team_members_by_nickname[$nickname])) {
                    $person = $team_members_by_nickname[$nickname];
                    ### update to itemperson table...
                    if ($view = ItemPerson::getAll(array('person' => $person->id, 'item' => $task->id))) {
                        $view[0]->feedback_requested_by = $auth->cur_user->id;
                        $view[0]->update();
                    } else {
                        $new_view = new ItemPerson(array('item' => $task->id, 'person' => $person->id, 'feedback_requested_by' => $auth->cur_user->id));
                        $new_view->insert();
                    }
                    $requested_people[] = "<b>" . asHtml($nickname) . "</b>";
                } else {
                    new FeedbackWarning(sprintf(__("Nickname not known in this project: %s"), "<b>" . asHtml($nickname) . "</b>"));
                }
            }
        }
        if ($requested_people) {
            new FeedbackMessage(sprintf(__('Requested feedback from: %s.'), join($requested_people, ", ")));
        }
    }
    ### only insert the comment, when comment name or description are valid
    if (get('comment_name') || get('comment_description')) {
        require_once confGet('DIR_STREBER') . 'pages/comment.inc.php';
        $valid_comment = true;
        ### new object? ###
        $comment = new Comment(array('name' => get('comment_name'), 'description' => get('comment_description'), 'project' => $task->project, 'task' => $task->id));
        validateNotSpam($comment->name . $comment->description);
        ### write to db ###
        if ($valid_comment) {
            if (!$comment->insert()) {
                new FeedbackWarning(__("Failed to add comment"));
            } else {
                ### change task update modification date ###
                if (isset($task)) {
                    ### Check if now longer new ###
                    if ($task->status == STATUS_NEW) {
                        global $auth;
                        if ($task->created < $auth->cur_user->last_login) {
                            $task->status = STATUS_OPEN;
                        }
                    }
                    $task->update(array('modified', 'status'));
                }
                $added_comment = true;
            }
        }
    }
    if ($task->id != 0 && !Task::getEditableById($task->id)) {
        if ($added_comment) {
            ### display taskView ####
            if (!$PH->showFromPage()) {
                $PH->show('home', array());
            }
            exit;
        } else {
            $PH->abortWarning(__("Not enough rights to edit task"));
        }
    }
    $task->validateEditRequestTime();
    $status_old = $task->status;
    # retrieve all possible values from post-data (with field->view_in_forms == true)
    # NOTE:
    # - this could be an security-issue.
    # @@@ TODO: as some kind of form-edit-behaviour to field-definition
    foreach ($task->fields as $f) {
        $name = $f->name;
        $f->parseForm($task);
    }
    $task->fields['parent_task']->parseForm($task);
    ### category ###
    $was_of_category = $task->category;
    if (!is_null($c = get('task_category'))) {
        global $g_tcategory_names;
        if (isset($g_tcategory_names[$c])) {
            $task->category = $c;
        } else {
            trigger_error("ignoring unknown task category '{$c}'", E_USER_NOTICE);
        }
    }
    /**
     * @@@pixtur 2006-11-17: actually this has been depreciated. is_folder updated
     * for backward compatibility only.
     */
    $task->is_folder = $task->category == TCATEGORY_FOLDER ? 1 : 0;
    ### Check if now longer new ###
    if ($status_old == $task->status && $task->status == STATUS_NEW) {
        global $auth;
        if ($task->created < $auth->cur_user->last_login) {
            $task->status = STATUS_OPEN;
        }
    }
    $assigned_people = array();
    $task_assignments = array();
    if ($task->id) {
        foreach ($task->getAssignedPeople() as $p) {
            $assigned_people[$p->id] = $p;
        }
        foreach ($task->getAssignments() as $ta) {
            $task_assignments[$ta->person] = $ta;
        }
    }
    $team = array();
    foreach ($project->getPeople() as $p) {
        $team[$p->id] = $p;
    }
    $new_task_assignments = array();
    # store assigments after(!) validation
    $forwarded = 0;
    $forward_comment = '';
    $old_task_assignments = array();
    if (isset($task_assignments)) {
        foreach ($task_assignments as $id => $t_old) {
            $id_new = get('task_assigned_to_' . $id);
            $forward_state = get('task_forward_to_' . $id);
            if ($forward_state) {
                $forwarded = 1;
            } else {
                $forwarded = 0;
            }
            $forward_comment = get('task_forward_comment_to_' . $id);
            if ($id_new === NULL) {
                log_message("failure. Can't change no longer existing assigment (person-id={$id} item-id={$t_old->id})", LOG_MESSAGE_DEBUG);
                #$PH->abortWarning("failure. Can't change no longer existing assigment",ERROR_NOTE);
                continue;
            }
            if ($id == $id_new) {
                if ($tp = TaskPerson::getTaskPeople(array('person' => $id, 'task' => $task->id))) {
                    $tp[0]->forward = $forwarded;
                    $tp[0]->forward_comment = $forward_comment;
                    $old_task_assignments[] = $tp[0];
                }
                #echo " [$id] {$team[$id]->name} still assigned<br>";
                continue;
            }
            if ($id_new == 0) {
                if (!$t_old) {
                    continue;
                }
                #echo " [$id] {$team[$id]->name} unassigned<br>";
                $t_old->delete();
                continue;
            }
            #$t_new= $task_assignments[$id_new];
            $p_new = @$team[$id_new];
            if (!isset($p_new)) {
                $PH->abortWarning("failure during form-value passing", ERROR_BUG);
            }
            #echo " [$id] assignment changed from {$team[$id]->name} to {$team[$id_new]->name}<br>";
            $t_old->comment = sprintf(__("unassigned to %s", "task-assignment comment"), $team[$id_new]->name);
            $t_old->update();
            $t_old->delete();
            $new_assignment = new TaskPerson(array('person' => $team[$id_new]->id, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $team[$id]->name), 'project' => $project->id, 'forward' => $forwarded, 'forward_comment' => $forward_comment));
            $new_task_assignments[] = $new_assignment;
            $link_items[] = $new_assignment;
        }
    }
    ### check new assigments ###
    $count = 0;
    while ($id_new = get('task_assign_to_' . $count)) {
        $forward_state = get('task_forward_to_' . $count);
        if ($forward_state) {
            $forwarded = 1;
        } else {
            $forwarded = 0;
        }
        $forward_comment = get('task_forward_comment_to_' . $count);
        $count++;
        ### check if already assigned ###
        if (isset($task_assignments[$id_new])) {
            if ($tp = TaskPerson::getTaskPeople(array('person' => $id_new, 'task' => $task->id))) {
                $tp[0]->forward = $forwarded;
                $tp[0]->forward_comment = $forward_comment;
                $old_task_assignments[] = $tp[0];
            }
            #new FeedbackMessage(sprintf(__("task was already assigned to %s"),$team[$id_new]->name));
        } else {
            if (!isset($team[$id_new])) {
                $PH->abortWarning("unknown person id {$id_new}", ERROR_DATASTRUCTURE);
            }
            $new_assignment = new TaskPerson(array('person' => $team[$id_new]->id, 'task' => $task->id, 'comment' => "", 'project' => $project->id, 'forward' => $forwarded, 'forward_comment' => $forward_comment));
            /**
             * BUG?
             * - inserting the new assigment before sucessfully validating the
             *   task will lead to double-entries in the database.
             */
            $new_task_assignments[] = $new_assignment;
            #$new_assignment->insert();
            $link_items[] = $new_assignment;
        }
    }
    if ($task->isOfCategory(array(TCATEGORY_VERSION, TCATEGORY_MILESTONE))) {
        if ($is_released = get('task_is_released')) {
            if (!is_null($is_released)) {
                $task->is_released = $is_released;
            }
        }
    }
    ### pub level ###
    if ($pub_level = get('task_pub_level')) {
        if ($task->id) {
            if ($pub_level > $task->getValidUserSetPublicLevels()) {
                $PH->abortWarning('invalid data', ERROR_RIGHTS);
            }
        }
        #else {
        #    #@@@ check for person create rights
        #}
        $task->pub_level = $pub_level;
    }
    ### check project ###
    if ($task->id == 0) {
        if (!($task->project = get('task_project'))) {
            $PH->abortWarning("task requires project to be set");
        }
    }
    ### get parent_task ###
    $is_ok = true;
    $parent_task = NULL;
    if ($task->parent_task) {
        $parent_task = Task::getVisibleById($task->parent_task);
    }
    ### validate ###
    if (!$task->name) {
        new FeedbackWarning(__("Task requires name"));
        $task->fields['name']->required = true;
        $task->fields['name']->invalid = true;
        $is_ok = false;
    } else {
        if ($task->id == 0) {
            $other_tasks = array();
            if ($parent_task) {
                $other_tasks = Task::getAll(array('project' => $project->id, 'parent_task' => $parent_task->id, 'status_min' => STATUS_NEW, 'status_max' => STATUS_CLOSED, 'visible_only' => false));
            } else {
                $other_tasks = Task::getAll(array('project' => $project->id, 'parent_task' => 0, 'status_min' => STATUS_NEW, 'status_max' => STATUS_CLOSED, 'visible_only' => false));
            }
            foreach ($other_tasks as $ot) {
                if (!strcasecmp($task->name, $ot->name)) {
                    $is_ok = false;
                    new FeedbackWarning(sprintf(__('Task called %s already exists'), $ot->getLink(false)));
                    break;
                }
            }
        }
    }
    ### automatically close resolved tasks ###
    if ($task->resolve_reason && $task->status < STATUS_COMPLETED) {
        $task->status = STATUS_COMPLETED;
        new FeedbackMessage(sprintf(__('Because task is resolved, its status has been changed to completed.')));
    }
    ### Check if resolved tasks should be completed ###
    if ($task->resolved_version != 0 && $task->status < STATUS_COMPLETED) {
        new FeedbackWarning(sprintf(__('Task has resolved version but is not completed?')));
        $task->fields['resolved_version']->invalid = true;
        $task->fields['status']->invalid = true;
        $is_ok = false;
    }
    ### Check if completion should be 100% ###
    if ($task->status >= STATUS_COMPLETED) {
        $task->completion = 100;
    }
    ### repeat form if invalid data ###
    if (!$is_ok) {
        $PH->show('taskEdit', NULL, $task);
        exit;
    }
    #--- write to database -----------------------------------------------------------------------
    #--- be sure parent-task is folder ---
    if ($parent_task) {
        if ($parent_task->isMilestoneOrVersion()) {
            if ($parent_task->is_folder) {
                $parent_task->is_folder = 0;
                $parent_task->update(array('is_folder'), false);
            }
            $PH->abortWarning(__("Milestones may not have sub tasks"));
        } else {
            if ($parent_task->category != TCATEGORY_FOLDER) {
                $parent_task->category = TCATEGORY_FOLDER;
                $parent_task->is_folder = 1;
                if ($parent_task->update()) {
                    new FeedbackMessage(__("Turned parent task into a folder. Note, that folders are only listed in tree"));
                } else {
                    trigger_error(__("Failed, adding to parent-task"), E_USER_WARNING);
                    $PH->abortWarning(__("Failed, adding to parent-task"));
                }
            }
        }
    }
    ### ungroup child tasks? ###
    if ($was_a_folder && $task->category != TCATEGORY_FOLDER) {
        $num_subtasks = $task->ungroupSubtasks();
        # @@@ does this work???
        /**
         * note: ALSO invisible tasks should be updated, so do not check for visibility here.
         */
        $parent = Task::getById($task->parent_task);
        $parent_str = $parent ? $parent->name : __('Project');
        if ($num_subtasks) {
            new FeedbackMessage(sprintf(__("NOTICE: Ungrouped %s subtasks to <b>%s</b>"), $num_subtasks, $parent_str));
        }
    }
    if ($task->id && !get('task_issue_report')) {
        $task_issue_report = $task->issue_report;
    } else {
        if ($task->issue_report != get('task_issue_report')) {
            trigger_error("Requesting invalid issue report id for task!", E_USER_WARNING);
            $task_issue_report = get('task_issue_report');
        } else {
            $task_issue_report = 0;
        }
    }
    ### consider issue-report? ###
    #$task_issue_report= get('task_issue_report');
    if ($task->category == TCATEGORY_BUG || isset($task_issue_report) && $task_issue_report) {
        ### new report as / temporary ###
        if ($task_issue_report == 0 || $task_issue_report == -1) {
            $issue = new Issue(array('id' => 0, 'project' => $project->id, 'task' => $task->id));
            ### querry form-information ###
            foreach ($issue->fields as $f) {
                $name = $f->name;
                $f->parseForm($issue);
            }
            global $g_reproducibility_names;
            if (!is_null($rep = get('issue_reproducibility'))) {
                if (isset($g_reproducibility_names[$rep])) {
                    $issue->reproducibility = intval($rep);
                } else {
                    $issue->reproducibility = REPRODUCIBILITY_UNDEFINED;
                }
            }
            global $g_severity_names;
            if (!is_null($sev = get('issue_severity'))) {
                if (isset($g_severity_names[$sev])) {
                    $issue->severity = intval($sev);
                } else {
                    $issue->severity = SEVERITY_UNDEFINED;
                }
            }
            ### write to db ###
            if (!$issue->insert()) {
                trigger_error("Failed to insert issue to db", E_USER_WARNING);
            } else {
                $link_items[] = $issue;
                $task->issue_report = $issue->id;
            }
        } else {
            if ($issue = Issue::getById($task_issue_report)) {
                ### querry form-information ###
                foreach ($issue->fields as $f) {
                    $name = $f->name;
                    $f->parseForm($issue);
                }
                global $g_reproducibility_names;
                if (!is_null($rep = get('issue_reproducibility'))) {
                    if (isset($g_reproducibility_names[$rep])) {
                        $issue->reproducibility = intval($rep);
                    } else {
                        $issue->reproducibility = REPRODUCIBILITY_UNDEFINED;
                    }
                }
                global $g_severity_names;
                if (!is_null($sev = get('issue_severity'))) {
                    if (isset($g_severity_names[$sev])) {
                        $issue->severity = intval($sev);
                    } else {
                        $issue->severity = SEVERITY_UNDEFINED;
                    }
                }
                ### write to db ###
                if (!$issue->update()) {
                    trigger_error("Failed to write issue to DB (id={$issue->id})", E_USER_WARNING);
                }
                if ($task->issue_report != $issue->id) {
                    # additional check, actually not necessary
                    trigger_error("issue-report as invalid id ({$issue->id}). Should be ({$task->issue_report}) Please report this bug.", E_USER_WARNING);
                }
            } else {
                trigger_error("Could not get issue with id {$task->issue_report} from database", E_USER_WARNING);
            }
        }
    }
    ### write to db ###
    if ($task->id == 0) {
        $task->insert();
        ### write task-assigments ###
        foreach ($new_task_assignments as $nta) {
            $nta->insert();
        }
        ### now we now the id of the new task, link the other items
        foreach ($link_items as $i) {
            $i->task = $task->id;
            $i->update();
        }
        new FeedbackMessage(sprintf(__("Created %s %s with ID %s", "Created <type> <name> with ID <id>..."), $task->getLabel(), $task->getLink(false), $task->id));
    } else {
        ### write task-assigments ###
        foreach ($new_task_assignments as $nta) {
            $nta->insert();
        }
        foreach ($old_task_assignments as $ota) {
            $ota->update();
        }
        new FeedbackMessage(sprintf(__("Changed %s %s with ID %s", "type,link,id"), $task->getLabel(), $task->getLink(false), $task->id));
        $task->update();
        $project->update(array(), true);
    }
    ### add any recently resolved tasks if this is a just released version  ###
    if ($task->category == TCATEGORY_VERSION && $was_category != TCATEGORY_VERSION) {
        if ($resolved_tasks = Task::getAll(array('project' => $task->project, 'status_min' => 0, 'status_max' => 10, 'resolved_version' => RESOLVED_IN_NEXT_VERSION))) {
            foreach ($resolved_tasks as $rt) {
                $rt->resolved_version = $task->id;
                $rt->update(array('resolved_version'));
            }
            new FeedbackMessage(sprintf(__('Marked %s tasks to be resolved in this version.'), count($resolved_tasks)));
        }
    }
    ### notify on change ###
    $task->nowChangedByUser();
    ### create another task ###
    if (get('create_another')) {
        ### build dummy form ###
        $newtask = new Task(array('id' => 0, 'name' => __('Name'), 'project' => $task->project, 'state' => 1, 'prio' => $task->prio, 'label' => $task->label, 'parent_task' => $task->parent_task, 'for_milestone' => $task->for_milestone, 'category' => $task->category));
        $PH->show('taskEdit', array('tsk' => $newtask->id), $newtask);
    } else {
        ### go to task, if new
        if ($tsk_id == 0) {
            $PH->show('taskView', array('tsk' => $task->id));
            exit;
        } else {
            if (!$PH->showFromPage()) {
                $PH->show('home', array());
            }
        }
    }
}
Ejemplo n.º 9
0
 public function getNextMilestone()
 {
     global $auth;
     $prefix = confGet('DB_TABLE_PREFIX');
     $dbh = new DB_Mysql();
     $sth = $dbh->prepare("SELECT  i.id\r\n                 from {$prefix}item i,  {$prefix}task t\r\n                WHERE\r\n                        t.category = " . TCATEGORY_MILESTONE . "\r\n                    AND t.id= i.id\r\n                    AND i.state = '" . ITEM_STATE_OK . "'\r\n                    AND i.project= {$this->id}\r\n                    AND t.status < " . STATUS_COMPLETED . "\r\n                    ORDER BY t.name, t.id\r\n                ")->execute();
     $tmp = $sth->fetchall_assoc();
     if ($tmp) {
         $tmp_values = array_values($tmp[0]);
         $next_milestone = Task::getVisibleById($tmp_values[0]);
         return $next_milestone;
     } else {
         return false;
     }
 }
Ejemplo n.º 10
0
 function renderListCsv($list = NULL)
 {
     if (!count($list)) {
         return;
     }
     ## header ##
     $ids = array();
     $count = 0;
     foreach ($list[0]->fields as $field_name => $field) {
         if ($field->export) {
             switch ($field->type) {
                 case 'FieldString':
                 case 'FieldInt':
                 case 'FieldDatetime':
                 case 'FieldText':
                     $ids[] = $field_name;
                     $count++;
                     break;
                 case 'FieldInternal':
                     if ($field_name == 'task') {
                         $ids[] = 'task_id';
                         $ids[] = 'task_name';
                     } else {
                         if ($field_name == 'person') {
                             $ids[] = 'person_id';
                             $ids[] = 'person_name';
                         } else {
                             if ($field_name == 'project') {
                                 $ids[] = 'project_id';
                                 $ids[] = 'project_name';
                             } else {
                                 $ids[] = $field_name;
                             }
                         }
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     ## list ##
     $values = array();
     foreach ($list as $row) {
         foreach ($list[0]->fields as $field_name => $field) {
             if ($field->export) {
                 switch ($field->type) {
                     case 'FieldText':
                     case 'FieldString':
                         $values[] = $this->cleanForCSV($row->{$field_name});
                         break;
                     case 'FieldInternal':
                         if ($field_name == 'task') {
                             $values[] = $row->{$field_name};
                             if ($task = Task::getVisibleById($row->{$field_name})) {
                                 $values[] = $this->cleanForCSV($task->name);
                             } else {
                                 $values[] = '';
                             }
                         } else {
                             if ($field_name == 'person') {
                                 $values[] = $row->{$field_name};
                                 if ($person = Person::getVisibleById($row->{$field_name})) {
                                     $values[] = $this->cleanForCSV($person->name);
                                 } else {
                                     $values[] = '-';
                                 }
                             } else {
                                 if ($field_name == 'project') {
                                     $values[] = $row->{$field_name};
                                     if ($project = Project::getVisibleById($row->{$field_name})) {
                                         $values[] = $this->cleanForCSV($project->name);
                                     } else {
                                         $values[] = '';
                                     }
                                 } else {
                                     $values[] = $row->{$field_name};
                                 }
                             }
                         }
                         break;
                     case 'FieldInt':
                     case 'FieldDatetime':
                         #$values[] = addslashes($row->$field_name,"\0..\37");
                         $values[] = $row->{$field_name};
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     ## export function ##
     exportToCSV($ids, $values);
 }
Ejemplo n.º 11
0
 static function getForQuery($search_query, $project = NULL)
 {
     $count_overall = 0;
     $results = array();
     global $PH;
     require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
     $args = array('order_str' => NULL, 'has_id' => NULL, 'search' => $search_query);
     foreach ($companies = Company::getAll($args) as $company) {
         $rate = RATE_TYPE_COMPANY;
         $rate *= SearchResult::RateItem($company);
         $rate *= SearchResult::RateTitle($company, $search_query);
         $results[] = new SearchResult(array('name' => $company->name, 'rating' => $rate, 'type' => __('Company'), 'jump_id' => 'companyView', 'jump_params' => array('company' => $company->id, 'q' => $search_query), 'item' => $company));
     }
     require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
     foreach ($people = Person::getPeople(array('search' => $search_query)) as $person) {
         $rate = RATE_TYPE_PERSON;
         $rate *= SearchResult::RateItem($person);
         $rate *= SearchResult::RateTitle($person, $search_query);
         $results[] = new SearchResult(array('name' => $person->name, 'rating' => $rate, 'type' => __('Person'), 'jump_id' => 'personView', 'jump_params' => array('person' => $person->id, 'q' => $search_query), 'item' => $person));
     }
     require_once confGet('DIR_STREBER') . "db/class_project.inc.php";
     $projects = Project::getAll(array('status_min' => 0, 'status_max' => 10, 'search' => $search_query));
     if ($projects) {
         foreach ($projects as $project) {
             $rate = RATE_TYPE_PROJECT;
             if ($project->status == STATUS_TEMPLATE) {
                 $rate *= RATE_PROJECT_IS_TEMPLATE;
             } else {
                 if ($project->status < STATUS_COMPLETED) {
                     $rate *= RATE_PROJECT_IS_OPEN;
                 } else {
                     $rate *= RATE_PROJECT_IS_CLOSED;
                 }
             }
             if ($diz = SearchResult::getExtract($project, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             ### status ###
             global $g_status_names;
             $status = isset($g_status_names[$project->status]) ? $g_status_names[$project->status] : '';
             if ($project->status > STATUS_COMPLETED) {
                 $rate *= RATE_TASK_STATUS_CLOSED;
             } else {
                 if ($project->status >= STATUS_COMPLETED) {
                     $rate *= RATE_TASK_STATUS_COMPLETED;
                 }
             }
             ### for company ###
             $html_location = '';
             if ($company = Company::getVisibleById($project->company)) {
                 $html_location = __('for') . ' ' . $company->getLink();
             }
             $rate *= SearchResult::RateItem($project);
             $rate *= SearchResult::RateTitle($project, $search_query);
             $results[] = new SearchResult(array('name' => $project->name, 'rating' => $rate, 'item' => $project, 'type' => __('Project'), 'jump_id' => 'projView', 'jump_params' => array('prj' => $project->id, 'q' => $search_query), 'extract' => $diz, 'status' => $status, 'html_location' => $html_location));
         }
     }
     require_once confGet('DIR_STREBER') . "db/class_task.inc.php";
     $order_str = get('sort_' . $PH->cur_page->id . "_tasks");
     $tasks = Task::getAll(array('order_by' => $order_str, 'search' => $search_query, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED));
     if ($tasks) {
         foreach ($tasks as $task) {
             $rate = RATE_TYPE_TASK;
             $rate *= SearchResult::RateItem($task);
             $rate *= SearchResult::RateTitle($task, $search_query);
             if ($task->category == TCATEGORY_FOLDER) {
                 $rate *= RATE_TASK_IS_FOLDER;
             }
             if ($diz = SearchResult::getExtract($task, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             global $g_status_names;
             $status = isset($g_status_names[$task->status]) ? $g_status_names[$task->status] : '';
             if ($task->status > STATUS_COMPLETED) {
                 $rate *= RATE_TASK_STATUS_CLOSED;
             } else {
                 if ($task->status >= STATUS_COMPLETED) {
                     $rate *= RATE_TASK_STATUS_COMPLETED;
                 }
             }
             if ($project = Project::getVisibleById($task->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('in') . " <b>{$prj}</b> &gt; " . $task->getFolderLinks();
             $is_done = $task->status < STATUS_COMPLETED ? false : true;
             $results[] = new SearchResult(array('name' => $task->name, 'rating' => $rate, 'extract' => $diz, 'item' => $task, 'type' => $task->getLabel(), 'status' => $status, 'html_location' => $html_location, 'is_done' => $is_done, 'jump_id' => 'taskView', 'jump_params' => array('tsk' => $task->id, 'q' => $search_query)));
         }
     }
     require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
     $comments = Comment::getAll(array('search' => $search_query));
     if ($comments) {
         foreach ($comments as $comment) {
             $rate = RATE_TYPE_COMMENT;
             $rate *= SearchResult::RateItem($comment);
             $rate *= SearchResult::RateTitle($comment, $search_query);
             if ($diz = SearchResult::getExtract($comment, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             if ($project = Project::getVisibleById($comment->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('on') . " <b>{$prj}</b>";
             $is_done = false;
             if ($task = Task::getVisibleById($comment->task)) {
                 if ($folders = $task->getFolderLinks()) {
                     $html_location .= ' &gt; ' . $folders;
                 }
                 $html_location .= ' &gt; ' . $task->getLink(false);
                 if ($task->status >= STATUS_COMPLETED) {
                     $is_done = true;
                 }
             } else {
                 $html_location = '';
             }
             $results[] = new SearchResult(array('name' => $comment->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Comment'), 'html_location' => $html_location, 'jump_id' => 'commentView', 'jump_params' => array('comment' => $comment->id, 'q' => $search_query), 'item' => $comment, 'is_done' => $is_done));
         }
     }
     $count_overall += count($comments);
     require_once confGet('DIR_STREBER') . "db/class_effort.inc.php";
     $efforts = Effort::getAll(array('search' => $search_query));
     if ($efforts) {
         foreach ($efforts as $effort) {
             $rate = RATE_TYPE_EFFORT;
             $rate *= SearchResult::RateItem($effort);
             $rate *= SearchResult::RateTitle($effort, $search_query);
             if ($diz = SearchResult::getExtract($effort, $search_query)) {
                 $rate *= RATE_IN_DETAILS;
             }
             if ($project = Project::getVisibleById($effort->project)) {
                 $prj = $project->getLink();
             } else {
                 $prj = '';
             }
             $html_location = __('on') . " <b>{$prj}</b>";
             $is_done = false;
             if ($task = Task::getVisibleById($effort->task)) {
                 if ($folders = $task->getFolderLinks()) {
                     $html_location .= ' &gt; ' . $folders;
                 }
                 $html_location .= ' &gt; ' . $task->getLink(false);
                 if ($task->status >= STATUS_COMPLETED) {
                     $is_done = true;
                 }
             } else {
                 $html_location = '';
             }
             $results[] = new SearchResult(array('name' => $effort->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Effort'), 'html_location' => $html_location, 'jump_id' => 'effortView', 'jump_params' => array('effort' => $effort->id, 'q' => $search_query), 'item' => $effort, 'is_done' => $is_done));
         }
     }
     $count_overall += count($efforts);
     return $results;
 }
Ejemplo n.º 12
0
/**
* to tasks to folder...
*
* @ingroup pages
*
* NOTE: this works either...
* - directly by passing a target folder in 'folder' or 'folders_*'
* - in two steps, whereas
*   - the passed task-ids are keept as hidden fields,
*   - a list with folders in been rendered
*   - a flag 'from_selection' is set
*   - after submit, the kept tasks are moved to 'folders_*'
*
* Also check the java-script part for the ajax-functionality in js/task-move.js
*
*
*
*/
function TasksMoveToFolder()
{
    global $PH;
    $task_ids = getPassedIds('tsk', 'tasks_*');
    if (!$task_ids) {
        $PH->abortWarning(__("Select some tasks to move"));
        exit;
    }
    /**
     * by default render list of folders...
     */
    $target_task_id = -1;
    /**
     * ...but, if folder was given, directly move tasks...
     */
    $folder_ids = getPassedIds('folder', 'folders_*');
    if (count($folder_ids) == 1) {
        if ($folder_task = Task::getVisibleById($folder_ids[0])) {
            $target_task_id = $folder_task->id;
        }
    } else {
        if (get('from_selection')) {
            $target_task_id = 0;
            # if no folders was selected, move tasks to project root
        }
    }
    if ($target_task_id != -1) {
        $target_project_id = getOnePassedId("target_prj");
        foreach ($task_ids as $task_id) {
            _moveTask($task_id, $target_project_id, $target_task_id);
        }
        ### return to from-page? ###
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    /**
     * build page and folder lists...
     */
    if (!($task = Task::getVisibleById($task_ids[0]))) {
        $PH->abortWarning("could not get task", ERROR_BUG);
    }
    $project_id = getOnePassedId($name = 'prj', $wild = false, $abort_on_failure = false);
    if (!$project_id) {
        $project_id = $task->project;
    }
    if (!($project = Project::getVisibleById($project_id))) {
        $PH->abortWarning("task without project?", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => false));
    $page->cur_tab = 'projects';
    $page->type = __("Edit tasks");
    $page->title = $project->name;
    $page->title_minor = __("Select folder to move tasks into");
    $page->extra_header_html .= '<script type="text/javascript" src="js/task-move.js' . "?v=" . confGet('STREBER_VERSION') . '"></script>';
    $page->extra_onload_js .= 'getAjaxListProjectFolders(' . $project_id . ');initMoveTasksUI();';
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'tasksMoveToFolder'));
    echo new PageHeader();
    echo new PageContentOpen();
    ### write project-selector ###
    $prj_names = array();
    if ($projects = Project::getAll()) {
        foreach ($projects as $p) {
            $prj_names[$p->id] = $p->name;
        }
        ## assigne new person to ptoject ##
        $dropdown = new Form_Dropdown('target_prj', __('Target project', 'form label'), array_flip($prj_names), $project_id);
        echo $dropdown->render();
    }
    ### write tasks as hidden entry ###
    foreach ($task_ids as $id) {
        if ($task = Task::getEditableById($id)) {
            echo "<input type=hidden name='tasks_{$id}_chk' value='1'>";
        }
    }
    ### target container for lazy fetch with ajax ###
    echo "<div id='folder_list'></div>";
    echo "<input type=hidden name='from_selection' value='1'>";
    # keep flag to ungroup tasks
    $button_name = __("Move items");
    echo "<input class=button2 type=submit value='{$button_name}'>";
    $PH->go_submit = 'tasksMoveToFolder';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 13
0
 public function render_quickedit($task)
 {
     global $PH;
     $editable = false;
     ### make sure it's editable ###
     if (Task::getEditableById($task->id)) {
         $editable = true;
     } else {
         if (!Task::getVisibleById($task->id)) {
             return false;
         }
     }
     ### get parent project ####
     if (!($project = Project::getVisibleById($task->project))) {
         return;
     }
     $this->render_blockStart();
     require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
     global $REPRODUCIBILITY_VALUES;
     global $g_prio_names;
     global $g_status_names;
     $form = new PageForm();
     $form->button_cancel = false;
     $form->add($tab_group = new Page_TabGroup());
     $tab_group->add($tab = new Page_Tab("comment", __("Add comment")));
     ### Comment ###
     $comment_name = '';
     $comment = new Comment(array('id' => 0, 'name' => $comment_name));
     $tab->add($comment->fields['name']->getFormElement($comment, __('Comment')));
     $e = $comment->fields['description']->getFormElement($comment);
     $e->rows = 8;
     $tab->add($e);
     ### request feedback
     $tab->add(buildRequestFeedbackInput($project));
     ### update ###
     if ($editable && $task->isOfCategory(array(TCATEGORY_TASK, TCATEGORY_BUG))) {
         $tab_group->add($tab = new Page_Tab("update", __("Update")));
         #$tab->add(new Form_Dropdown('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
         $tab->add(new Form_DropdownGrouped('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
         $tab->add(new Form_DropdownGrouped('task_resolved_version', __('Resolved in'), $project->buildResolvedInList(), $task->resolved_version));
         global $g_resolve_reason_names;
         $tab->add(new Form_Dropdown('task_resolve_reason', __('Resolve reason'), array_flip($g_resolve_reason_names), $task->resolve_reason));
         ### for existing tasks, get already assigned
         if ($task->id) {
             $assigned_people = $task->getAssignedPeople();
         } else {
             trigger_error("view a task with zero id?");
         }
         $team = array(__('- select person -') => 0);
         ### create team-list ###
         foreach ($project->getPeople() as $p) {
             $team[$p->name] = $p->id;
         }
         ### create drop-down-lists ###
         $count_new = 0;
         $count_all = 0;
         if (isset($assigned_people)) {
             foreach ($assigned_people as $ap) {
                 if (!($p = Person::getVisibleById($ap->id))) {
                     continue;
                     # skip if invalid person
                 }
                 if ($task->id) {
                     $tab->add(new Form_Dropdown('task_assigned_to_' . $ap->id, __("Assigned to"), $team, $ap->id));
                 } else {
                     $tab->add(new Form_Dropdown('task_assign_to_' . $count_new, __("Assign to"), $team, $ap->id));
                     $count_new++;
                 }
                 $count_all++;
                 unset($team[$ap->name]);
             }
         }
         ### add empty drop-downlist for new assignments ###
         $str_label = $count_all == 0 ? __("Assign to", "Form label") : __("Also assign to", "Form label");
         $tab->add(new Form_Dropdown("task_assign_to_{$count_new}", $str_label, $team, 0));
         if (!$task->isMilestoneOrVersion()) {
             $tab->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio));
         }
         $ar = array(__('undefined') => 0, __('30 min') => 30 * 60, __('1 h') => 60 * 60, __('2 h') => 2 * 60 * 60, __('4 h') => 4 * 60 * 60, __('1 Day') => 1 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Days') => 2 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Days') => 3 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('4 Days') => 4 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('1 Week') => 1 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Weeks') => 2 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Weeks') => 3 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60);
         $tab->add(new Form_Dropdown('task_estimated', __("Estimated time"), $ar, $task->estimated));
         $tab->add(new Form_Dropdown('task_estimated_max', __("Estimated worst case"), $ar, $task->estimated_max));
         $ar = array(__('undefined') => -1, '0%' => 0, '10%' => 10, '20%' => 20, '30%' => 30, '40%' => 40, '50%' => 50, '60%' => 60, '70%' => 70, '80%' => 80, '90%' => 90, '95%' => 95, '98%' => 98, '99%' => 99, '100%' => 100);
         $tab->add(new Form_Dropdown('task_completion', __("Completed"), $ar, $task->completion));
         $tab->add($task->fields['parent_task']->getFormElement($task));
         $st = array();
         foreach ($g_status_names as $s => $n) {
             if ($s >= STATUS_NEW) {
                 $st[$s] = $n;
             }
         }
         if ($task->isMilestoneOrVersion()) {
             unset($st[STATUS_NEW]);
         }
         $tab->add(new Form_Dropdown('task_status', "Status", array_flip($st), $task->status));
     }
     /**
      * to reduce spam, enforce captcha test for guests
      */
     global $auth;
     if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
         $form->addCaptcha();
     }
     ### some required hidden fields for correct data passing ###
     $form->add(new Form_HiddenField('tsk', '', $task->id));
     $form->add(new Form_HiddenField('comment', '', $comment->id));
     if ($return = get('return')) {
         $form->add(new Form_HiddenField('return', '', asHtml($return)));
     }
     echo $form;
     $PH->go_submit = 'taskEditSubmit';
     $this->render_blockEnd();
 }
Ejemplo n.º 14
0
/**
* move files to folder...
*
* NOTE: this works either...
* - directly by passing a target folder in 'folder' or 'folders_*'
* - in two steps, whereas
*   - the passed task-ids are keept as hidden fields,
*   - a list with folders is been rendered
*   - a flag 'from_selection' is set
*   - after submit, the kept tasks are moved to 'folders_*'
*
*/
function FilesMoveToFolder()
{
    global $PH;
    $file_ids = getPassedIds('file', 'files_*');
    if (!$file_ids) {
        $PH->abortWarning(__("Select some files to move"));
        exit;
    }
    /**
     * by default render list of folders...
     */
    $target_id = -1;
    /**
     * ...but, if folder was given, directly move files...
     */
    $folder_ids = getPassedIds('folder', 'folders_*');
    if (count($folder_ids) == 1) {
        if ($folder_task = Task::getVisibleById($folder_ids[0])) {
            $target_id = $folder_task->id;
        }
    } else {
        if (get('from_selection')) {
            $target_id = 0;
        }
    }
    if ($target_id != -1) {
        if ($target_id != 0) {
            if (!($target_task = Task::getEditableById($target_id))) {
                $PH->abortWarning(__("insufficient rights"));
            }
            ### get path of target to check for cycles ###
            $parent_tasks = $target_task->getFolder();
            $parent_tasks[] = $target_task;
        } else {
            $parent_tasks = array();
        }
        $count = 0;
        foreach ($file_ids as $id) {
            if ($file = File::getEditableById($id)) {
                $file->parent_item = $target_id;
                $file->update();
            } else {
                $PH->messages[] = sprintf(__("Can not edit file %s"), $file->name);
            }
        }
        ### return to from-page? ###
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    #else if($target_id != -1) {
    #    $PH->abortWarning(__("insufficient rights to edit any of the selected items"));
    #}
    /**
     * build page folder lists...
     */
    ### get project ####
    if (!($file = File::getVisibleById($file_ids[0]))) {
        $PH->abortWarning("could not get file", ERROR_BUG);
    }
    if (!($project = Project::getVisibleById($file->project))) {
        $PH->abortWarning("file without project?", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'company_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit files");
    $page->title = "{$project->name}";
    $page->title_minor = __("Select folder to move files into");
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'filesMoveToFolder'));
    echo new PageHeader();
    echo new PageContentOpen();
    ### write files as hidden entry ###
    foreach ($file_ids as $id) {
        if ($file = File::getEditableById($id)) {
            echo "<input type=hidden name='files_{$id}_chk' value='1'>";
        }
    }
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    $list = new ListBlock_tasks();
    $list->query_options['show_folders'] = true;
    #$list->query_options['folders_only']= true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    $list->no_items_html = __('No folders available');
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    unset($list->columns['project']);
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project, NULL);
    echo __("(or select nothing to move to project root)") . "<br> ";
    echo "<input type=hidden name='from_selection' value='1'>";
    # keep flag to ungroup files
    echo "<input type=hidden name='project' value='{$project->id}'>";
    $button_name = __("Move items");
    echo "<input class=button2 type=submit value='{$button_name}'>";
    $PH->go_submit = 'filesMoveToFolder';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 15
0
 static function getChangeLines($query_options)
 {
     global $PH;
     global $auth;
     fillMissingValues($query_options, array('alive_only' => false));
     $date_compare = isset($query_options['date_min']) ? $query_options['date_min'] : "0000-00-00";
     /**
      * get list of items touched by other people
      */
     $changed_items = DbProjectItem::getAll($query_options);
     /**
      * go through list
      */
     $changes = array();
     foreach ($changed_items as $i) {
         $change_type = NULL;
         if (!isset($query_options['project'])) {
             $project = Project::getVisibleById($i->project);
         } else {
             $project = NULL;
         }
         /**
          * get item-change-type depeding on dates
          */
         if ($i->deleted >= $i->modified) {
             $change_type = ITEM_DELETED;
         } else {
             if ($i->modified > $i->created) {
                 $change_type = ITEM_MODIFIED;
             } else {
                 $change_type = ITEM_NEW;
             }
         }
         /**
          * build up change-list
          */
         switch ($change_type) {
             case ITEM_NEW:
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     if ($task->prio != PRIO_NORMAL && $task->prio != PRIO_UNDEFINED) {
                         global $g_prio_names;
                         $html_details .= ' / ' . $g_prio_names[$task->prio];
                     }
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => '<span class=new>' . __('new') . ' ' . $task->getLabel() . '</span>', 'txt_what' => __('new') . ' ' . $task->getLabel(), 'type' => ChangeLine::NEW_TASK, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('New file'), 'txt_what' => __('New file'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_MODIFIED:
                 $timestamp_last_change = $date_compare;
                 # make sure we use the last occured change type
                 /**
                  * modified tasks
                  */
                 $type = ChangeLine::UPDATED;
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $txt_what = $html_what = __('modified');
                     $type = ChangeLine::UPDATED;
                     $html_comment = '';
                     if ($comments = Comment::getAll(array('person' => $i->modified_by, 'task' => $task->id, 'date_min' => $timestamp_last_change, 'order_by' => 'created ASC'))) {
                         $last_comment = $comments[count($comments) - 1];
                         $timestamp_last_change = $last_comment->created;
                         if ($last_comment->name && $last_comment->name != __('New Comment')) {
                             # ignore default title
                             $html_comment = strip_tags($last_comment->name) . ': ';
                         }
                         $html_comment .= strip_tags($last_comment->description);
                         $html_comment = asHtml($html_comment);
                     }
                     ### get changed fields ###
                     $changed_fields_hash = array();
                     $html_functions = false;
                     if ($changed_fields_list = ItemChange::getItemChanges(array('item' => $i->id, 'person' => $i->modified_by, 'date_min' => $date_compare))) {
                         foreach ($changed_fields_list as $cf) {
                             $changed_fields_hash[$cf->field] = $cf;
                         }
                         if (isset($changed_fields_hash['status'])) {
                             $status_old = $changed_fields_hash['status']->value_old;
                             if ($task->status == STATUS_COMPLETED && $task->status > $status_old) {
                                 $txt_what = $html_what = __('completed') . ' ' . $task->getLabel();
                                 $html_functions = $PH->getLink('tasksApproved', __('Approve Task'), array('tsk' => $task->id));
                                 unset($changed_fields_hash['status']);
                             } else {
                                 if ($task->status == STATUS_APPROVED && $task->status > $status_old) {
                                     $txt_what = $html_what = __('approved');
                                     unset($changed_fields_hash['status']);
                                 } else {
                                     if ($task->status == STATUS_CLOSED && $task->status > $status_old) {
                                         $txt_what = $html_what = __('closed');
                                         unset($changed_fields_hash['status']);
                                     } else {
                                         if ($task->status == STATUS_OPEN && $task->status < $status_old) {
                                             $txt_what = $html_what = __('reopened');
                                             unset($changed_fields_hash['status']);
                                         } else {
                                             if ($task->status == STATUS_OPEN) {
                                                 unset($changed_fields_hash['status']);
                                             } else {
                                                 if ($task->status == STATUS_BLOCKED) {
                                                     $txt_what = $html_what = __('is blocked');
                                                     unset($changed_fields_hash['status']);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (isset($changed_fields_hash['parent_task'])) {
                         $txt_what = $html_what = __('moved');
                         $type = ChangeLine::MOVED;
                         unset($changed_fields_hash['parent_task']);
                     } else {
                         if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['name'])) {
                             $txt_what = $html_what = __('renamed');
                             $type = ChangeLine::RENAMED;
                         } else {
                             if (count($changed_fields_hash) == 1 && isset($changed_fields_hash['description'])) {
                                 $txt_what = $html_what = __('edit wiki');
                                 $type = ChangeLine::EDITED_WIKI;
                             } else {
                                 if (count($changed_fields_hash)) {
                                     # status does not count
                                     $html_details .= ' / ' . __('changed:') . ' ' . implode(', ', array_keys($changed_fields_hash));
                                 } else {
                                     if ($html_comment) {
                                         $txt_what = $html_what = __('commented');
                                         $type = ChangeLine::COMMENTED;
                                     }
                                 }
                             }
                         }
                     }
                     if ($html_comment) {
                         $html_details .= ' / ' . $html_comment;
                     }
                     /**
                      * any recents assignments ?
                      * - to avoid confusion only list assignmets if it was to last action,
                      *
                      */
                     require_once "db/class_taskperson.inc.php";
                     $count_assignments = 0;
                     if ($assignments = TaskPerson::getTaskPeople(array('task' => $task->id, 'project' => $task->project, 'date_min' => $task->modified))) {
                         $t_timestamp = '';
                         foreach ($assignments as $a) {
                             if ($a->person != $task->modified_by && $a->created_by == $task->modified_by && $a->assigntype != ASSIGNTYPE_INITIAL) {
                                 $t_timestamp = $a->created;
                                 $count_assignments++;
                             }
                         }
                         if ($count_assignments && $timestamp_last_change < $t_timestamp) {
                             $type = ChangeLine::ASSIGNED;
                             $txt_what = $html_what = __('assigned');
                             $timestamp_last_change = $t_timestamp;
                         }
                         if ($html_comment) {
                             $html_details .= ' / ' . $html_comment;
                         }
                     }
                     /**
                      * any recents attachments by last editor ?
                      */
                     require_once "db/class_file.inc.php";
                     if ($files = File::getAll(array('parent_item' => $task->id, 'project' => $task->project, 'date_min' => $date_compare, 'created_by' => $task->modified_by))) {
                         $count_attached_files = 0;
                         $html_attached = __("attached") . ": ";
                         $t_timestamp = '';
                         $separator = '';
                         foreach ($files as $f) {
                             if ($task->modified_by == $f->modified_by) {
                                 $t_timestamp = $f->created;
                                 $count_attached_files++;
                                 $html_attached .= $separator . $PH->getLink('fileView', $f->name, array('file' => $f->id));
                                 $separator = ', ';
                             }
                         }
                         if ($count_attached_files) {
                             $type = ChangeLine::ATTACHED_FILE;
                             $txt_what = $html_what = __('attached file to');
                             if ($timestamp_last_change < $t_timestamp) {
                                 $html_details .= ' / ' . $html_attached;
                                 $timestamp_last_change = $t_timestamp;
                             }
                         }
                     }
                     if (count($changed_fields_hash)) {
                         $html_details .= " / " . $PH->getLink('itemViewDiff', NULL, array('item' => $task->id, 'date1' => $date_compare, 'date2' => gmdate("Y-m-d H:i:s")));
                     }
                     if ($html_functions) {
                         $html_details .= " | " . $html_functions;
                     }
                     $change = new ChangeLine(array('person_by' => $i->modified_by, 'timestamp' => $i->modified, 'item_id' => $i->id, 'item' => $task, 'type' => $type, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('changed File'), 'txt_what' => __('changed File'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             case ITEM_DELETED:
                 /**
                  * deleted tasks
                  */
                 if ($i->type == ITEM_TASK) {
                     if (!($task = Task::getVisibleById($i->id))) {
                         continue;
                     }
                     if ($assigned_people = $task->getAssignedPeople()) {
                         $tmp = array();
                         foreach ($assigned_people as $ap) {
                             $tmp[] = $ap->getLink();
                         }
                         $html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
                     } else {
                         $html_assignment = '';
                     }
                     $html_details = '';
                     if ($tmp = $task->getFolderLinks(true, $project)) {
                         $html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
                     }
                     $html_details .= '|' . $PH->getLink('itemsRestore', __('restore'), array('item' => $task->id));
                     $txt_what = $html_what = __('deleted');
                     $change = new ChangeLine(array('item' => $task, 'person_by' => $i->deleted_by, 'timestamp' => $i->deleted, 'item_id' => $i->id, 'type' => ChangeLine::DELETED, 'txt_what' => $txt_what, 'html_what' => $html_what, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
                     $changes[] = $change;
                 } else {
                     if ($i->type == ITEM_FILE) {
                         require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
                         if ($file = File::getVisibleById($i->id)) {
                             $change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('deleted File'), 'txt_what' => ChangeLine::DELETED, 'html_details' => $file->name));
                             $changes[] = $change;
                         }
                     }
                 }
                 break;
             default:
                 trigger_error("unknown change-type {$change_type}", E_USER_WARNING);
                 break;
         }
     }
     return $changes;
 }
 function render_tr(&$obj, $style = "")
 {
     if (!isset($obj) || !$obj instanceof Effort) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     $sum = 0.0;
     $sum_sal = 0.0;
     $sum_all = 0.0;
     $sum_calc = 0.0;
     $diff_value = false;
     if ($obj->as_duration) {
         echo "<td>-</td>";
     } else {
         if ($person = Person::getVisibleById($obj->person)) {
             /*if($obj->getStatus()){
             			$sum_sal = Effort::getSumEfforts(array('project'=>$obj->project, 'person'=>$person->id, 'status'=>$obj->status));
             		}
             		else{*/
             $sum_sal = Effort::getSumEfforts(array('project' => $obj->project, 'person' => $person->id));
             #}
             if ($sum_sal) {
                 $sum = round($sum_sal / 60 / 60, 1) * 1.0;
                 if ($project = Project::getVisibleById($obj->project)) {
                     if ($pp = $project->getProjectPeople(array('person_id' => $person->id))) {
                         if ($pp[0]->salary_per_hour) {
                             $sum_all = $sum * $pp[0]->salary_per_hour;
                         } else {
                             $sum_all = $sum * $person->salary_per_hour;
                         }
                     } else {
                         $sum_all = $sum * $person->salary_per_hour;
                     }
                 }
                 //$sum_all = ($sum * $person->salary_per_hour);
             }
         }
         if ($effort_tasks = Effort::getEffortTasks(array('project' => $obj->project, 'person' => $obj->person))) {
             foreach ($effort_tasks as $et) {
                 if ($task = Task::getVisibleById($et->task)) {
                     if ($task->calculation) {
                         $sum_calc += $task->calculation;
                     }
                 }
             }
         }
         if ($sum_all && $sum_calc) {
             $max_length_value = 3;
             $get_percentage = $sum_all / $sum_calc * 100;
             if ($get_percentage > 100) {
                 $diff = $get_percentage - 100;
                 $get_percentage = 100;
                 $diff_value = true;
             }
             $show_rate = $get_percentage * $max_length_value;
             echo "<td>";
             echo "<nobr>";
             echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#f00;'>";
             if ($diff_value) {
                 $show_rate = $diff * $max_length_value;
                 echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$show_rate}px;height:12px;background-color:#ff9900;'>";
                 echo " " . round($get_percentage, 1) . "% / " . round($diff, 1) . " %";
             } else {
                 echo " " . round($get_percentage, 1) . "%";
             }
             echo "</nobr>";
             echo "</td>";
         } else {
             echo "<td>-</td>";
         }
     }
 }
Ejemplo n.º 17
0
/**
* Submit changes to several efforts @ingroup pages
*/
function effortEditMultipleSubmit()
{
    global $PH;
    global $auth;
    $ids = array();
    $count = 0;
    $error = 0;
    $changes = false;
    ### cancel ? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home', array());
        }
        exit;
    }
    $number = get('number');
    for ($i = 0; $i < $number; $i++) {
        $effort_id = get('effort_id_' . $i);
        $ids[] = $effort_id;
    }
    if (!$ids) {
        $PH->abortWarning(__("Select some efforts(s) to edit"), ERROR_NOTE);
        return;
    }
    foreach ($ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $status = get('effort_status');
            if (!is_null($status) && $status != -1 && $status != $effort->status) {
                $effort->status = $status;
                $changes = true;
            }
            $task_id = get('effort_task');
            if (!is_null($task_id) && $task_id != -1 && $task_id != $effort->task) {
                if ($task = Task::getVisibleById($task_id)) {
                    $effort->task = $task->id;
                    $changes = true;
                }
            }
            $pub_level = get('effort_pub_level');
            if (!is_null($pub_level) && $pub_level != -1 && $pub_level != $effort->pub_level) {
                if ($pub_level > $effort->getValidUserSetPublicLevels()) {
                    $PH->abortWarning('invalid data', ERROR_RIGHTS);
                }
                $effort->pub_level = $pub_level;
                $changes = true;
            }
        } else {
            $error++;
        }
        if ($changes) {
            $effort->update();
            $effort->nowChangedByUser();
            $count++;
        }
    }
    if ($count) {
        new FeedbackMessage(sprintf(__("Edited %s effort(s)."), $count));
    }
    if ($error) {
        new FeedbackWarning(sprintf(__('Error while editing %s effort(s).'), $error));
    }
    ### return to from-page? ###
    if (!$PH->showFromPage()) {
        $PH->show('home');
    }
}
Ejemplo n.º 18
0
function newEffortFromTimeTracking()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'db/class_effort.inc.php';
    $time_end = intval(get('effort_end_seconds'));
    if ($time_end == 0) {
        $time_end = null;
    }
    $new_effort = new Effort(array('id' => 0, 'time_start' => getGMTString(get('effort_start_seconds')), 'time_end' => getGMTString($time_end), 'name' => get('description'), 'billing' => get('billing'), 'productivity' => get('productivity')));
    ### get project ###
    $new_effort->project = get('effort_project_id');
    if (!($project = Project::getVisibleById($new_effort->project))) {
        $PH->abortWarning(__("Could not get project of effort"));
    }
    if (!$project->isPersonVisibleTeamMember($auth->cur_user)) {
        $PH->abortWarning("ERROR: Insufficient rights");
    }
    ### link to task ###
    $task_id = get('effort_task_id');
    if (!(is_null($task_id) || $task_id == 0)) {
        if ($task_id == 0) {
            $new_effort->task = 0;
        } else {
            if ($task = Task::getVisibleById($task_id)) {
                $new_effort->task = $task->id;
            }
        }
    } else {
        if (get('task_name') != "") {
            ### create new task
            $newtask = new Task(array('id' => 0, 'name' => get('task_name'), 'project' => $project->id));
            $newtask->insert();
            $new_effort->task = $newtask->id;
        }
    }
    ### get person ###
    $new_effort->person = $auth->cur_user->id;
    ### go back to from if validation fails ###
    $failure = false;
    if (strToGMTime($new_effort->time_end) - strToGMTime($new_effort->time_start) < 0) {
        $failure = true;
        new FeedbackWarning(__("Cannot start before end."));
    }
    ### write to db ###
    $new_effort->insert();
    ### display taskView ####
    if (!$PH->showFromPage()) {
        $PH->show('projView', array('prj' => $effort->project));
    }
}
Ejemplo n.º 19
0
/**
* renders a comparision between two versions of an item @ingroup pages
*/
function itemViewDiff()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
    ### get task ####
    $item_id = get('item');
    if (!($item = DbProjectItem::getObjectById($item_id))) {
        $PH->abortWarning("invalid item-id", ERROR_FATAL);
    }
    if (!($project = Project::getVisibleById($item->project))) {
        $PH->abortWarning("this item has an invalid project id", ERROR_DATASTRUCTURE);
    }
    require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php";
    $versions = ItemVersion::getFromItem($item);
    $date1 = get('date1');
    $date2 = get('date2');
    if (!$date1) {
        #if(count($versions) > 1) {
        #    if($auth->cur_user->last_logout < $versions[count($versions)-2]->date_to)
        #    {
        #        $date1 = $auth->cur_user->last_logout;
        #    }
        #    else {
        #        $date1 = $versions[count($versions)-2]->date_from;
        #    }
        #}
        #else {
        foreach (array_reverse($versions) as $v) {
            if ($v->author == $auth->cur_user->id) {
                $date1 = $v->date_from;
                break;
            }
        }
        #}
    }
    if (!$date2) {
        $date2 = getGMTString();
    }
    $page = new Page();
    $page->cur_tab = 'projects';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->title = $item->name;
    $page->title_minor = __('changes');
    $page->add_function(new PageFunction(array('target' => 'itemView', 'params' => array('item' => $item->id), 'icon' => 'edit', 'name' => __('View item'))));
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    if ($date1 > $date2) {
        new FeedbackMessage(__("date1 should be smaller than date2. Swapped"));
        $t = $date1;
        $date1 = $date2;
        $date2 = $t;
    }
    if (count($versions) == 1) {
        echo __("item has not been edited history");
    } else {
        $old_version = NULL;
        $version_right = NULL;
        $version_left = $versions[0];
        foreach ($versions as $v) {
            if ($v->date_from <= $date1) {
                $version_left = $v;
            }
            if ($v->date_from >= $date2) {
                if (isset($version_right)) {
                    if ($version_right->date_from > $v->date_from) {
                        $version_right = $v;
                    }
                } else {
                    $version_right = $v;
                }
            }
        }
        if (!isset($version_right)) {
            $version_right = $versions[count($versions) - 1];
        }
        $options_left = array();
        $options_right = array();
        ### list versions left ###
        for ($i = 0; $i < count($versions) - 1; $i++) {
            $v = $versions[$i];
            if ($person = Person::getVisibleById($v->author)) {
                $author = $person->name;
            } else {
                $author = __('unknown');
            }
            if ($v->version_number == $version_left->version_number) {
                $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                $name = ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . $v->date_from;
                $options_left[] = "<option selected=1 value='" . $str_link . "'>" . $name . "</option>";
            } else {
                if ($v->version_number > $version_left->version_number) {
                    if ($v->version_number < $version_right->version_number) {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                        $name = '&gt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    } else {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $version_right->date_to));
                        $name = '&gt;&gt;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    }
                    $options_left[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                } else {
                    $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $version_right->date_from));
                    $name = '&lt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    $options_left[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                }
            }
        }
        ### list versions right ###
        for ($i = 1; $i < count($versions); $i++) {
            $v = $versions[$i];
            if ($person = Person::getVisibleById($v->author)) {
                $author = $person->name;
            } else {
                $author = __('unknown');
            }
            if ($v->version_number == $version_right->version_number) {
                $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                $name = ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . $v->date_from;
                $options_right[] = "<option selected=1 value='" . $str_link . "'>" . $name . "</option>";
            } else {
                if ($v->version_number > $version_right->version_number) {
                    $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $version_left->date_from, 'date2' => $versions[$i]->date_from));
                    $name = '&gt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . ' -- ' . renderDate($v->date_from);
                    $options_right[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                } else {
                    if ($v->version_number > $version_left->version_number) {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $version_left->date_from, 'date2' => $versions[$i]->date_from));
                        $name = '&lt; &nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . " -- " . renderDate($v->date_from);
                    } else {
                        $str_link = $PH->getUrl('itemViewDiff', array('item' => $item->id, 'date1' => $versions[$i]->date_from, 'date2' => $versions[$i]->date_to));
                        $name = '&lt;&lt;&nbsp;&nbsp; v.' . $v->version_number . ' -- ' . $author . ' -- ' . renderDate($v->date_from);
                    }
                    $options_right[] = "<option  value='" . $str_link . "'>" . $name . "</option>";
                }
            }
        }
        ### prev ###
        if ($version_left->version_number > 1) {
            $link_prev = $PH->getLink('itemViewDiff', '&lt;&lt; ' . __('prev change'), array('item' => $item->id, 'date1' => $versions[$version_left->version_number - 2]->date_from, 'date2' => $versions[$version_left->version_number - 2]->date_to), NULL, true);
        } else {
            $link_prev = '';
        }
        ### next ###
        if ($version_right->version_number < count($versions)) {
            $link_next = $PH->getLink('itemViewDiff', __('next') . '&gt;&gt;', array('item' => $item->id, 'date1' => $versions[$version_right->version_number - 1]->date_from, 'date2' => $versions[$version_right->version_number - 1]->date_to), NULL, true);
        } else {
            $link_next = '';
        }
        ### summary ###
        $link_summary = $PH->getLink('itemViewDiff', __('summary'), array('item' => $item->id, 'date1' => $auth->cur_user->last_logout, 'date2' => getGMTString()), NULL, true);
        echo "<div class=diff>";
        echo "<table class=nav><tr>";
        echo "<td class=older>" . "<select onChange='location.href=this.options[this.selectedIndex].value'>" . join(array_reverse($options_left)) . "</select>" . '<br><b class=doclear></b>' . $link_prev . "</td>";
        echo "<td class=newer>" . "<select onChange='location.href=this.options[this.selectedIndex].value'>" . join(array_reverse($options_right)) . "</select>" . '<br><b class=doclear></b>' . $link_next . $link_summary . "</td>";
        echo "</table>";
        #if(!$date2 || !$date1) {
        #    echo sprintf(__("Item did not exists at %s"), renderTime($date2));
        #}
        if ($old_version == $version_right) {
            echo sprintf(__('no changes between %s and %s'), renderTime($date1), renderTime($date2));
        }
        ### collect changes ###
        $old_field_values = array();
        $new_field_values = array();
        foreach ($versions as $v) {
            if ($v->version_number <= $version_left->version_number) {
                foreach ($v->values as $name => $value) {
                    $old_field_values[$name] = $value;
                }
            }
            if ($v->version_number >= $version_left->version_number && $v->version_number < $version_right->version_number) {
                foreach ($v->values_next as $name => $value) {
                    $new_field_values[$name] = $value;
                }
            }
        }
        foreach ($new_field_values as $field_name => $value) {
            echo "<h2>{$field_name}</h2>";
            $old_value = isset($old_field_values[$field_name]) ? $old_field_values[$field_name] : "";
            $new_value = isset($new_field_values[$field_name]) ? $new_field_values[$field_name] : '';
            $field_type = $item->fields[$field_name]->type;
            if ($field_type == 'FieldText') {
                echo render_changes($old_value, $new_value);
            } else {
                if ($field_type == 'FieldOption') {
                    if ($field_name == 'status') {
                        global $g_status_names;
                        $old_value = isset($g_status_names[$old_value]) ? $g_status_names[$old_value] : __('undefined');
                        $new_value = isset($g_status_names[$new_value]) ? $g_status_names[$new_value] : __('undefined');
                    } else {
                        if ($field_name == 'label') {
                            if ($project = Project::getVisibleById($item->project)) {
                                $labels = explode(",", $project->labels);
                                $old_value = isset($labels[$old_value - 1]) ? $labels[$old_value - 1] : __('undefined');
                                $new_value = isset($labels[$new_value - 1]) ? $labels[$new_value - 1] : __('undefined');
                            }
                        }
                    }
                    echo render_changes($old_value, $new_value);
                } else {
                    if ($field_type == 'FieldInternal') {
                        if ($field_name == 'parent_item') {
                            if ($task_parent_old = Task::getVisibleById($old_value)) {
                                $ar = array();
                                foreach ($task_parent_old->getFolder() as $f) {
                                    $ar[] = $f->name;
                                }
                                $ar[] = $task_parent_old->name;
                                $old_value = join($ar, " > ");
                            }
                            if ($task_parent_new = Task::getVisibleById($new_value)) {
                                $ar = array();
                                foreach ($task_parent_new->getFolder() as $f) {
                                    $ar[] = $f->name;
                                }
                                $ar[] = $task_parent_new->name;
                                $new_value = join($ar, " > ");
                            }
                        } else {
                            if ($field_name == 'state') {
                                $old_value = $old_value == -1 ? __('deleted') : __('ok');
                                $new_value = $new_value == -1 ? __('deleted') : __('ok');
                            } else {
                                if ($field_name == 'pub_level') {
                                    global $g_pub_level_names;
                                    $old_value = isset($g_pub_level_names[$old_value]) ? $g_pub_level_names[$old_value] : __('undefined');
                                    $new_value = isset($g_pub_level_names[$new_value]) ? $g_pub_level_names[$new_value] : __('undefined');
                                }
                            }
                        }
                        echo render_changes($old_value, $new_value);
                    } else {
                        if ($field_type == 'FieldPercentage') {
                            echo render_changes($old_value, $new_value);
                        } else {
                            if ($field_type == 'FieldInt') {
                                echo render_changes($old_value, $new_value);
                            } else {
                                if ($field_type == 'FieldString') {
                                    echo render_changes($old_value, $new_value);
                                } else {
                                    if ($field_type == 'FieldDate') {
                                        echo render_changes(renderDate($old_value), renderDate($new_value));
                                    } else {
                                        if ($field_type == 'FieldDatetime') {
                                            echo render_changes(renderTimestamp($old_value), renderTimestamp($new_value));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    echo "</div>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 20
0
/**
* Submit changes to multiple tasks
*
* @ingroup pages
*/
function taskEditMultipleSubmit()
{
    global $PH;
    $ids = getPassedIds('tsk', 'tasks_*');
    if (!$ids) {
        $PH->abortWarning(__("Select some task(s) to mark as approved"), ERROR_NOTE);
        return;
    }
    $count = 0;
    $errors = 0;
    $number = get('number');
    ### cancel? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    foreach ($ids as $id) {
        if ($task = Task::getEditableById($id)) {
            $count++;
            $change = false;
            $status_old = $task->status;
            ### status ###
            if ($count == 1) {
                if (!($project = Project::getVisibleById($task->project))) {
                    $PH->abortWarning('could not get project');
                }
                $team = array();
                foreach ($project->getPeople() as $p) {
                    $team[$p->id] = $p;
                }
            }
            $task_assigned_people = array();
            $task_assignments = array();
            $task_people_overwrite = array();
            $task_people_new = array();
            $task_people_delete = array();
            ## previous assigend people ##
            if ($task_people = $task->getAssignedPeople(false)) {
                foreach ($task_people as $tp) {
                    $task_assigned_people[$tp->id] = $tp;
                }
            }
            ## previous assignements ##
            if ($task_assign = $task->getAssignments()) {
                foreach ($task_assign as $ta) {
                    $task_assignments[$ta->person] = $ta;
                }
            }
            ## different assigned people ##
            ## overwrite ?? ##
            $ass1 = get('task_assignement_diff');
            if ($ass1 && $ass1 != '__dont_change__') {
                $task_people_overwrite[] = $ass1;
                foreach ($task_assignments as $key => $value) {
                    $task_people_delete[] = $value;
                }
                $change = true;
            }
            ## new ?? ##
            $ass2 = get('task_assignement_also_diff');
            if ($ass2 && $ass2 != '__select_person__') {
                $task_people_new[] = $ass2;
                $change = true;
            }
            $different = get('different_ass');
            if (isset($different) && !$different) {
                if (isset($task_assignments) && count($task_assignments) != 0) {
                    foreach ($task_assignments as $tid => $t_old) {
                        $id_new = get('task_assign_to_' . $tid);
                        ## no changes ##
                        if ($tid == $id_new) {
                            continue;
                        }
                        if ($id_new == '__none__') {
                            if (!$t_old) {
                                continue;
                            }
                            $task_people_delete[] = $t_old;
                            continue;
                        }
                        $task_people_delete[] = $t_old;
                        $task_people_overwrite[] = $id_new;
                    }
                } else {
                    $id_new = get('task_assign_to___none__');
                    if ($id_new && $id_new != '__none__') {
                        $task_people_new[] = $id_new;
                    }
                }
                $id_new = get('task_assign_to_0');
                if ($id_new != '__select_person__') {
                    if (!isset($task_assignments[$id_new])) {
                        $task_people_new[] = $id_new;
                    }
                }
                $change = true;
            }
            ### category ###
            $v = get('task_category');
            if (!is_null($v) && $v != '__dont_change__' && $v != $task->category) {
                $task->category = $v;
                $change = true;
            }
            ### status ###
            $status = get('task_status');
            if ($status && $status != '__dont_change__' && $status != $task->status) {
                $task->status = $status;
                $change = true;
            }
            ### prio ###
            $prio = get('task_prio');
            if ($prio && $prio != '__dont_change__' && $prio != $task->prio) {
                $task->prio = $prio;
                $change = true;
            }
            ### pub level ###
            $pub_level = get('task_pub_level');
            if ($pub_level && $pub_level != '__dont_change__' && $pub_level != $task->pub_level) {
                if ($pub_level > $task->getValidUserSetPublicLevel()) {
                    $PH->abortWarning('invalid data', ERROR_RIGHTS);
                }
                $task->pub_level = $pub_level;
                $change = true;
            }
            ### label ###
            $label = get('task_label');
            if ($label && $label != '__dont_change__' && $label != $task->label) {
                $task->label = $label;
                $change = true;
            }
            ### for milestone ###
            $fm = get('task_for_milestone');
            if (!is_null($fm) && $fm != '__dont_change__' && $task->for_milestone != $fm) {
                if ($fm) {
                    if (($m = Task::getVisibleById($fm)) && $m->isMilestoneOrVersion()) {
                        $task->for_milestone = $fm;
                        $change = true;
                    } else {
                        continue;
                    }
                } else {
                    $task->for_milestone = 0;
                    $change = true;
                }
            }
            ### resolve version ###
            $rv = get('task_resolved_version');
            if (!is_null($rv) && $rv != '__dont_change__' && $task->resolved_version != $rv) {
                if ($rv && $rv != -1) {
                    if ($v = Task::getVisibleById($rv)) {
                        if ($v->isMilestoneOrVersion()) {
                            $task->resolved_version = $rv;
                            $change = true;
                        }
                    } else {
                        continue;
                    }
                } else {
                    if ($rv == -1) {
                        $task->resolved_version = $rv;
                        $change = true;
                    } else {
                        $task->resolved_version = 0;
                        $change = true;
                    }
                }
            }
            ### resolve reason ###
            $rs = get('task_resolve_reason');
            if ($rs && $rs != '__dont_change__' && $rs != $rs->resolve_reason) {
                $task->resolve_reason = $rs;
                $change = true;
            }
            if ($change) {
                ### Check if now longer new ###
                if ($status_old == $task->status && $task->status == STATUS_NEW) {
                    global $auth;
                    if ($task->created < $auth->cur_user->last_login) {
                        $task->status = STATUS_OPEN;
                    }
                }
                ## overwrite assigend people ##
                if (isset($task_people_overwrite)) {
                    if (isset($task_people_delete)) {
                        foreach ($task_people_delete as $tpd) {
                            $tpd->delete();
                        }
                    }
                    foreach ($task_people_overwrite as $tpo) {
                        $task_pers_over = new TaskPerson(array('person' => $team[$tpo]->id, 'task' => $task->id, 'comment' => '', 'project' => $project->id));
                        $task_pers_over->insert();
                    }
                }
                ## add new person ##
                if (isset($task_people_new)) {
                    foreach ($task_people_new as $tpn) {
                        if (!isset($task_assigned_people[$tpn])) {
                            $task_pers_new = new TaskPerson(array('person' => $team[$tpn]->id, 'task' => $task->id, 'comment' => '', 'project' => $project->id));
                            $task_pers_new->insert();
                        }
                    }
                }
                ##update##
                $task->update();
                $task->nowChangedByUser();
            }
        } else {
            $errors++;
        }
    }
    ### compose message ###
    if ($errors) {
        new FeedbackWarning(sprintf(__('%s tasks could not be written'), $errors));
    } else {
        if ($count) {
            new FeedbackMessage(sprintf(__('Updated %s tasks tasks'), $count));
        }
    }
    ### return to from-page? ###
    if (!$PH->showFromPage()) {
        $PH->show('taskView', array('tsk' => $task->id));
    }
}
Ejemplo n.º 21
0
/**
* edit several bookmarks @ingroup pages
*/
function itemBookmarkEditMultiple($thebookmarks = NULL)
{
    global $PH;
    global $auth;
    global $g_notitychange_period;
    $is_already_bookmark = array();
    $bookmarks = array();
    $items = array();
    $edit_fields = array('notify_if_unchanged', 'notify_on_change');
    $different_fields = array();
    # hash containing fieldnames which are different in bookmarks
    if (!$thebookmarks) {
        $item_ids = getPassedIds('bookmark', 'bookmarks_*');
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            }
        }
    } else {
        $item_ids = $thebookmarks;
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 0))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = false;
                }
            } elseif ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            } else {
                $date = getGMTString();
                $bookmark = new ItemPerson(array('id' => 0, 'item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1, 'notify_if_unchanged' => 0, 'notify_on_change' => 0, 'created' => $date));
                if ($item = DbProjectItem::getById($is)) {
                    $bookmarks[] = $bookmark;
                    $items[] = $item;
                    $is_already_bookmark[$bookmark->id] = false;
                }
            }
        }
    }
    if (!$items) {
        $PH->abortWarning(__("Please select some items"));
    }
    $page = new Page();
    $page->cur_tab = 'home';
    $page->options = array(new NaviOption(array('target_id' => 'itemBookmarkEdit', 'name' => __('Edit bookmarks'))));
    $page->type = __('Edit multiple bookmarks', 'page title');
    $page->title = sprintf(__('Edit %s bookmark(s)'), count($items));
    $page->title_minor = __('Edit');
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($items as $item) {
        ## get item name ##
        $str_link = '';
        if ($type = $item->type) {
            switch ($type) {
                case ITEM_TASK:
                    require_once "db/class_task.inc.php";
                    if ($task = Task::getVisibleById($item->id)) {
                        $str_link = $task->getLink(false);
                    }
                    break;
                case ITEM_COMMENT:
                    require_once "db/class_comment.inc.php";
                    if ($comment = Comment::getVisibleById($item->id)) {
                        $str_link = $comment->getLink(false);
                    }
                    break;
                case ITEM_PERSON:
                    require_once "db/class_person.inc.php";
                    if ($person = Person::getVisibleById($item->id)) {
                        $str_link = $person->getLink(false);
                    }
                    break;
                case ITEM_EFFORT:
                    require_once "db/class_effort.inc.php";
                    if ($e = Effort::getVisibleById($item->id)) {
                        $str_link = $e->getLink(false);
                    }
                    break;
                case ITEM_FILE:
                    require_once "db/class_file.inc.php";
                    if ($f = File::getVisibleById($item->id)) {
                        $str_link = $f->getLink(false);
                    }
                    break;
                case ITEM_PROJECT:
                    require_once "db/class_project.inc.php";
                    if ($prj = Project::getVisibleById($item->id)) {
                        $str_link = $prj->getLink(false);
                    }
                    break;
                case ITEM_COMPANY:
                    require_once "db/class_company.inc.php";
                    if ($c = Company::getVisibleById($item->id)) {
                        $str_link = $c->getLink(false);
                    }
                    break;
                case ITEM_VERSION:
                    require_once "db/class_task.inc.php";
                    if ($tsk = Task::getVisibleById($item->id)) {
                        $str_link = $tsk->getLink(false);
                    }
                    break;
                default:
                    break;
            }
        }
        echo "<li>" . $str_link . "</li>";
    }
    echo "</ol>";
    foreach ($bookmarks as $bookmark) {
        foreach ($edit_fields as $field_name) {
            if ($bookmark->{$field_name} != $bookmarks[0]->{$field_name}) {
                $different_fields[$field_name] = true;
            }
        }
    }
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $b = array();
    $b[0] = __('no');
    $b[1] = __('yes');
    if (isset($different_fields['notify_on_change'])) {
        $b[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), -1));
    } else {
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), $bookmarks[0]->notify_on_change));
    }
    $a = array();
    foreach ($g_notitychange_period as $key => $value) {
        $a[$key] = $value;
    }
    if (isset($different_fields['notify_if_unchanged'])) {
        $a[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), -1));
    } else {
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), $bookmarks[0]->notify_if_unchanged));
    }
    $number = 0;
    foreach ($bookmarks as $bm) {
        $form->add(new Form_HiddenField("bookmark_id_{$number}", '', $bm->id));
        $form->add(new Form_HiddenField("bookmark_item_{$number}", '', $bm->item));
        $form->add(new Form_HiddenField("is_already_bookmark_{$number}", '', $is_already_bookmark[$bm->id]));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'itemBookmarkEditMultipleSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 22
0
 /**
  * renders the location of the file as a html string with links to project and parent tasks
  *
  */
 public function renderLocation($project = NULL, $show_project = true)
 {
     if (is_null($project)) {
         if (!($project = Project::getVisibleById($this->project))) {
             trigger_error("file without visible project?", E_USER_NOTICE);
             $show_project = false;
         }
     }
     $html = __('in');
     if ($show_project) {
         $html .= " <b>" . $project->getLink() . " </b>";
     }
     if ($this->parent_item) {
         if ($task = Task::getVisibleById($this->parent_item)) {
             if ($folders = $task->getFolderLinks()) {
                 $html .= ' &gt; ' . $folders;
             }
             $html .= ' &gt; ' . $task->getLink(false);
         }
     }
     return $html;
 }
Ejemplo n.º 23
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     if (!isset($obj) || !$obj instanceof File) {
         return;
     }
     if ($task = Task::getVisibleById($obj->parent_item)) {
         print '<td>' . $task->getLink(false) . '</td>';
     } else {
         print '<td></td>';
     }
 }
Ejemplo n.º 24
0
 function getFolder()
 {
     $folder = array();
     $folder_ids = array();
     #hash to detect cycle-lock
     $cur_task = $this;
     while ($cur_task && intval($cur_task->parent_task)) {
         if (isset($folder_ids[$cur_task->parent_task])) {
             trigger_error('Cycle lock for task ' . $cur_task->parent_task . '! Possibly invalid database structure', E_USER_WARNING);
             break;
         } else {
             if ($cur_task = Task::getVisibleById(intval($cur_task->parent_task))) {
                 $folder_ids[$cur_task->id] = true;
                 $folder[] = $cur_task;
             }
         }
     }
     return array_reverse($folder);
 }
Ejemplo n.º 25
0
 function render_tr(&$obj, $style = '')
 {
     if (!isset($obj) || !$obj instanceof Task) {
         return;
     }
     $value = "";
     if ($obj->for_milestone) {
         if ($milestone = Task::getVisibleById($obj->for_milestone)) {
             $value = $milestone->getLink();
         }
     }
     print "<td>{$value}</td>";
 }
Ejemplo n.º 26
0
/**
* move comments to folder...
*/
function commentsMoveToFolder()
{
    global $PH;
    $comment_ids = getPassedIds('comment', 'comments_*');
    if (!$comment_ids) {
        $PH->abortWarning(__("Select some comments to move"));
        return;
    }
    /**
     * if folder was given, directly move tasks...
     */
    $target_id = -1;
    # target is unknown
    $folder_ids = getPassedIds('folder', 'folders_*');
    if (count($folder_ids) == 1) {
        if ($folder_task = Task::getVisibleById($folder_ids[0])) {
            $target_id = $folder_task->id;
        }
    } else {
        if (get('from_selection')) {
            $target_id = 0;
            # to ungrout to root?
        }
    }
    if ($target_id != -1) {
        if ($target_id != 0) {
            if (!($target_task = Task::getEditableById($target_id))) {
                $PH->abortWarning(__("insufficient rights"));
            }
        }
        $count = 0;
        foreach ($comment_ids as $id) {
            if ($comment = Comment::getEditableById($id)) {
                $comment->task = $target_id;
                /**
                 * @@@ do we have to reset ->comment as well?
                 *
                 * this splits discussions into separate comments...
                 */
                $comment->comment = 0;
                $comment->update();
            } else {
                new FeedbackWarning(sprintf(__("Can not edit comment %s"), asHtml($comment->name)));
            }
        }
        ### return to from-page? ###
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    /**
     * build page folder list to select target...
     */
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    ### get project ####
    if (!($comment = Comment::getVisibleById($comment_ids[0]))) {
        $PH->abortWarning("could not get comment", ERROR_BUG);
    }
    if (!($project = Project::getVisibleById($comment->project))) {
        $PH->abortWarning("task without project?", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'company_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit tasks");
    $page->title = $project->name;
    $page->title_minor = __("Select one folder to move comments into");
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'commentsMoveToFolder'));
    echo new PageHeader();
    echo new PageContentOpen();
    echo __("... or select nothing to move to project root");
    ### write selected comments as hidden fields ###
    foreach ($comment_ids as $id) {
        if ($comment = Comment::getEditableById($id)) {
            echo "<input type=hidden name='comments_{$id}_chk' value='1'>";
        }
    }
    $list = new ListBlock_tasks();
    $list->reduced_header = true;
    $list->query_options['show_folders'] = true;
    $list->query_options['folders_only'] = true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    unset($list->columns['project']);
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    $list->no_items_html = __("No folders in this project...");
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project);
    echo "<input type=hidden name='from_selection' value='1'>";
    # keep flag to ungroup comments
    echo "<input type=hidden name='project' value='{$project->id}'>";
    $button_name = __("Move items");
    echo "<input class=button2 type=submit value='{$button_name}'>";
    $PH->go_submit = 'commentsMoveToFolder';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Ejemplo n.º 27
0
/**
* Initialize a page for displaying effort related content
*
* - inits: 
*   - breadcrumps
*   - options
*   - current section
*   - navigation
*   - pageType (including task folders)
*   - pageTitle (as Task title)
*/
function initPageForEffort($page, $effort, $project = NULL)
{
    global $PH;
    $crumbs = array();
    if (!$project) {
        $project = Project::getVisibleById($effort->project);
    }
    $task = Task::getVisibleById($effort->task);
    $page->cur_crumb = 'projViewEfforts';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->cur_tab = 'projects';
    if ($effort->name) {
        $page->title = $effort->name;
    } else {
        $page->title = __('Effort');
    }
    $page->title_minor_html = $PH->getLink('effortView', sprintf('#%d', $effort->id), array('effort' => $effort->id));
    global $g_status_names;
    $type = "";
    if ($task) {
        if ($folder = $task->getFolderLinks()) {
            $type = $folder . " &gt; ";
        }
        $type .= $task->getLink() . ' &gt; ';
    }
    $type .= __('Effort');
    $page->type = $type;
}
Ejemplo n.º 28
0
 /**
  * tries to build a valid a href-link to an item.
  *
  * - uses $this->name
  * - sets -this-html
  * - does all the neccessary security checks, styles and conversions
  */
 static function renderLinkFromItemId($target_id, $name = "")
 {
     global $PH;
     $target_id = intval($target_id);
     $html = "";
     if (!($item = DbProjectItem::getVisibleById($target_id))) {
         $html = '<em>' . sprintf(__("Unkwown item %s"), $target_id) . '</em>';
     } else {
         switch ($item->type) {
             case ITEM_TASK:
                 if ($task = Task::getVisibleById($item->id)) {
                     $style_isdone = $task->status >= STATUS_COMPLETED ? 'isDone' : '';
                     if ($name) {
                         $html = $PH->getLink('taskView', $name, array('tsk' => $task->id), $style_isdone, true);
                     } else {
                         $html = $task->getLink(false);
                     }
                 }
                 break;
             case ITEM_FILE:
                 require_once confGet('DIR_STREBER') . "db/class_file.inc.php";
                 if ($file = File::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('fileDownloadAsImage', $name, array('file' => $file->id), NULL, true);
                     } else {
                         $html = $PH->getLink('fileDownloadAsImage', $file->name, array('file' => $file->id));
                     }
                 }
                 break;
             case ITEM_COMMENT:
                 require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
                 if ($comment = Comment::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('commentView', $name, array('comment' => $comment->id), NULL, true);
                     } else {
                         $html = $PH->getLink('commentView', $comment->name, array('comment' => $comment->id));
                     }
                 }
                 break;
             case ITEM_PERSON:
                 if ($person = Person::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('personView', $name, array('person' => $person->id), NULL, true);
                     } else {
                         $html = $PH->getLink('personView', $person->name, array('person' => $person->id));
                     }
                 }
                 break;
             case ITEM_PROJECT:
                 if ($project = Project::getVisibleById($item->id)) {
                     if ($name == "") {
                         $name = asHtml($project->name);
                     }
                     $html = $PH->getLink('projView', $name, array('prj' => $project->id), NULL, true);
                 }
                 break;
             default:
                 $html = '<em>' . sprintf(__('Cannot link to item #%s of type %s'), intval($target_id), $item->type) . '</em>';
                 break;
         }
     }
     return $html;
 }
Ejemplo n.º 29
0
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     $str_url = "";
     $str_name = "";
     $str_addon = "";
     switch ($obj->type) {
         case ITEM_PROJECT:
             if ($project = Project::getVisibleById($obj->id)) {
                 $str_name = asHtml($project->name);
                 $str_url = $PH->getUrl('projView', array('prj' => $project->id));
             }
             break;
         case ITEM_TASK:
             if ($task = Task::getVisibleById($obj->id)) {
                 $str_name = asHtml($task->name);
                 $str_url = $PH->getUrl('taskView', array('tsk' => $task->id));
                 if ($project = Project::GetVisibleById($task->project)) {
                     $str_addon = "(" . $project->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_COMMENT:
             if ($comment = Comment::getVisibleById($obj->id)) {
                 if ($comment->name == '') {
                     $str_name = "-";
                 } else {
                     $str_name = asHtml($comment->name);
                 }
                 $str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
                 $str_addon .= "(";
                 if ($task = Task::getVisibleById($comment->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= $project->getLink(false) . " > ";
                     }
                     $str_addon .= $task->getLink(false);
                     if ($comment->comment) {
                         if ($comm = Comment::getVisibleById($comment->comment)) {
                             $str_addon .= " > " . $comm->name;
                         }
                     }
                 }
                 $str_addon .= ")";
             }
             break;
         case ITEM_COMPANY:
             if ($c = Company::getVisibleById($obj->id)) {
                 $str_name = asHtml($c->name);
                 $str_url = $PH->getUrl('companyView', array('company' => $c->id));
             }
             break;
         case ITEM_PERSON:
             if ($person = Person::getVisibleById($obj->id)) {
                 $str_name = asHtml($person->name);
                 $str_url = $PH->getUrl('personView', array('person' => $person->id));
             }
             break;
         case ITEM_PROJECTPERSON:
             if ($pp = ProjectPerson::getVisibleById($obj->id)) {
                 if (!($person = new Person($pp->person))) {
                     $PH->abortWarning("ProjectPerson has invalid person-pointer!", ERROR_BUG);
                 }
                 $str_name = asHtml($person->name);
                 $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 if ($project = Project::getVisibleById($pp->project)) {
                     $str_addon = "(" . $project->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_EMPLOYMENT:
             if ($emp = Employment::getById($obj->id)) {
                 if ($person = Person::getVisibleById($emp->person)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 if ($company = Company::getVisibleById($emp->company)) {
                     $str_addon = "(" . $company->getLink(false) . ")";
                 }
             }
             break;
         case ITEM_EFFORT:
             if ($e = Effort::getVisibleById($obj->id)) {
                 $str_name = asHtml($e->name);
                 $str_url = $PH->getUrl('effortEdit', array('effort' => $e->id));
                 if ($task = Task::getVisibleById($e->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= "(" . $project->getLink(false);
                         $str_addon .= " > " . $task->getLink(false) . ")";
                     }
                 }
             }
             break;
         case ITEM_FILE:
             if ($f = File::getVisibleById($obj->id)) {
                 $str_name = asHtml($f->org_filename);
                 $str_url = $PH->getUrl('fileView', array('file' => $f->id));
                 $str_addon .= "(";
                 if ($p = Project::getVisibleById($f->project)) {
                     $str_addon .= $p->getLink(false);
                 }
                 if ($t = Task::getVisibleById($f->parent_item)) {
                     $str_addon .= " > " . $t->getLink(false);
                 }
                 $str_addon .= ")";
             }
             break;
         case ITEM_ISSUE:
             if ($i = Issue::getVisibleById($obj->id)) {
                 if ($t = Task::getVisibleById($i->task)) {
                     $str_name = asHtml($t->name);
                     $str_url = $PH->getUrl('taskView', array('tsk' => $t->id));
                     if ($p = Project::getVisibleById($t->project)) {
                         $str_addon .= "(" . $p->getLink(false) . ")";
                     }
                 }
             }
             break;
         case ITEM_TASKPERSON:
             if ($tp = TaskPerson::getVisibleById($obj->id)) {
                 if ($person = Person::getVisibleById($tp->person)) {
                     $str_name = asHtml($person->name);
                     $str_url = $PH->getUrl('personView', array('person' => $person->id));
                 }
                 if ($task = Task::getVisibleById($tp->task)) {
                     if ($project = Project::getVisibleById($task->project)) {
                         $str_addon .= "(" . $project->getLink(false);
                         $str_addon .= " > " . $task->getLink(false) . ")";
                     }
                 }
             }
             break;
         default:
             break;
     }
     print "<td><a href='{$str_url}'>{$str_name}</a><span class='sub who'> {$str_addon}</span></td>";
 }