/** * 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'); } }
/** * 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(); }
public function __toString() { global $PH; global $auth; #--- news ----------------------------------------------------------- $comments = $this->item_with_comments->getComments(array('order_by' => 'created')); $block = new PageBlock(array('title' => sprintf(__("%s Comments"), count($comments) ? count($comments) : __("No", "As in... >No< Comments")), 'id' => 'news')); $block->render_blockStart(); $count = 0; foreach ($comments as $c) { ### own comment $is_comment_editable = $auth->cur_user->user_rights & RIGHT_EDITALL || $c->created_by == $auth->cur_user->id; if (!($creator = Person::getVisibleById($c->created_by))) { continue; } echo "<div class='post_list_entry'>"; echo "<h3>"; if ($c->created_by == $auth->cur_user->id) { echo $creator->nickname; } else { echo $creator->getLink(); } echo "<span class=separator>:</span>"; echo asHtml($c->name); if ($new = $c->isChangedForUser()) { if ($new == 1) { echo '<span class=new> (' . __('New') . ') </span>'; } else { echo '<span class=new> (' . __('Updated') . ') </span>'; } } echo "</h3>"; echo "<p class= details>"; echo renderTimeAgo($c->created); require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php"; $versions = ItemVersion::getFromItem($c); if (count($versions) > 1) { echo " (" . $PH->getLink('itemViewDiff', sprintf(__("%s. update", "like in... Nth update"), count($versions)), array('item' => $c->id)); echo " " . renderTimeAgo($c->modified); echo ") "; } if ($c->pub_level != PUB_LEVEL_OPEN) { echo ' - ' . sprintf(__("visible as %s"), renderPubLevelName($c->pub_level)); ### publish ### if (($parent_task = Task::getEditableById($c->task)) && $c->pub_level < PUB_LEVEL_OPEN) { echo " - " . $PH->getLink('itemsSetPubLevel', __('Publish'), array('item' => $c->id, 'item_pub_level' => PUB_LEVEL_OPEN)); } } ### delete if ($is_comment_editable) { echo " - " . $PH->getLink('commentsDelete', __('Delete'), array('comment' => $c->id)); } echo "</p>"; if ($is_comment_editable) { echo wikifieldAsHtml($c, 'description'); } else { echo wikifieldAsHtml($c, 'description', array('editable' => false)); } echo "</div>"; $c->nowViewedByUser(); } $this->render_blockEnd(); return ''; }
function render_tr(&$obj, $style = "") { global $PH; global $auth; global $COMMENTTYPE_NAMES; if (!isset($obj) || !$obj instanceof Comment) { trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING); return; } $style_cur_user = ''; if ($obj->created_by != 0 && ($person = Person::getById($obj->created_by))) { if ($obj->created_by == $auth->cur_user->id) { $style_cur_user = '******'; } } $column_poster = '<td class="details ' . $style_cur_user . '">'; if ($obj->created_by != 0 && ($person = Person::getById($obj->created_by))) { $column_poster .= '<p class="poster">' . $person->getLink() . '</p>'; } if (!$obj->view_collapsed) { ### time ### $p_time = renderDateHtml($obj->time); $column_poster .= "<span class=date>{$p_time}</span>"; ### pub level if not open ### if ($obj->pub_level != PUB_LEVEL_OPEN) { global $g_pub_level_names; $column_poster .= "<br>(" . $g_pub_level_names[$obj->pub_level] . ')<br>'; } require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php"; $versions = ItemVersion::getFromItem($obj); if (count($versions) > 1) { $column_poster .= "<br>" . $PH->getLink('itemViewDiff', sprintf(__("version %s"), count($versions)), array('item' => $obj->id)); } $column_poster .= "<div class=edit_functions>"; # if current user is the creator of the comment if ($obj->created_by == $auth->cur_user->id) { if ($obj->isEditable()) { $column_poster .= $PH->getLink('commentEdit', __('Edit'), array('comment' => $obj->id)); $column_poster .= $PH->getLink('commentsDelete', __('Delete'), array('comment' => $obj->id)); } } else { ### check sufficient rights ### if ($parent_task = Task::getEditableById($obj->task)) { # have to send the task-id otherwise the reply function doesn't work $column_poster .= $PH->getLink('commentNew', __('Reply'), array('comment' => $obj->id, 'parent_task' => $obj->task)); if ($obj->pub_level != PUB_LEVEL_OPEN) { $column_poster .= $PH->getLink('itemsSetPubLevel', __('Publish'), array('item' => $obj->id, 'item_pub_level' => PUB_LEVEL_OPEN)); } } } $column_poster .= "</div>"; } $column_poster .= "</td>"; print $column_poster; }
/** * Edit note on person * * @ingroup pages */ function taskNoteOnPersonEdit($task = NULL, $person = NULL) { global $PH; global $auth; global $g_pub_level_names; global $g_prio_names; if (!$task) { $id = getOnePassedId('tsk'); if (!($task = Task::getEditableById($id))) { $PH->abortWarning(__("Select a note to edit"), ERROR_NOTE); return; } } ## get person ## if (!$person) { $pid = getOnePassedId('person'); if (!($person = Person::getById($pid))) { $PH->abortWarning(__("ERROR: could not get Person"), ERROR_NOTE); return; } } $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'task_name')); $page->cur_tab = 'people'; if ($person->id) { $page->crumbs = build_person_crumbs($person); } $page->crumbs[] = new NaviCrumb(array('target_id' => 'taskNoteOnPersonEdit')); $page->type = __("Note"); if (!$task->id) { $page->title = __('Create new note'); $page->title_minor = __('Edit'); ## default title ## $date = gmdate("Y-m-d", time()); $time = getGMTString(); $dt = $date . " " . renderTime($time); $task->name = sprintf(__("New Note on %s, %s"), $person->name, $dt); } ## eventually needed later when note is a subcategory of task /*else { $page->title=$task->name; $page->title_minor=$task->short; }*/ echo new PageHeader(); echo new PageContentOpen(); require_once confGet('DIR_STREBER') . 'render/render_form.inc.php'; $form = new PageForm(); $form->button_cancel = true; ## name field ## $form->add($task->fields['name']->getFormElement($task)); ## description field ## $e = $task->fields['description']->getFormElement($task); $e->rows = 22; $form->add($e); ### public-level drop down menu ### $form->add(new Form_Dropdown('task_pub_level', __("Publish to", "Form label"), array_flip($g_pub_level_names), $task->pub_level)); ## priority drop down menu## $form->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio)); if ($task->id == 0) { $proj_select = 0; } $p_list = array(); $count = 1; $p_projects = $person->getProjects(); $num = count($p_projects); if ($num > 0) { $p_list[0] = __('Assigned Projects'); foreach ($p_projects as $pp) { $p_list[$pp->id] = "- " . $pp->name; $count++; } } $p_companies = $person->getCompanies(); $num = count($p_companies); if ($num > 0) { $p_list['-1'] = __('Company Projects'); foreach ($p_companies as $pcs) { $c_id = $pcs->id; $c_projects = Project::getAll(array('company' => $c_id)); $count2 = 0; foreach ($c_projects as $cp) { $p_list[$cp->id] = "- " . $cp->name; } } } if (!($projects = Project::getAll(array('order_by' => 'name ASC')))) { } else { $p_list['-2'] = __('All other Projects'); foreach ($projects as $pj) { $p_list[$pj->id] = "- " . $pj->name; } } $form->add(new Form_Dropdown('project', __('For Project', 'form label'), array_flip($p_list), $proj_select, "id='proj_list'")); ## new project ## if ($task->id == 0) { $form->add(new Form_checkbox('new_project', __('New project', 'form label'), false, "id='proj_new_checkbox'")); $form->add(new Form_Input('new_project_name', __('Project name', 'form label'), false, NULL, false, "id='proj_new_input'", "style='display:none'")); } $checked1 = ""; $checked2 = ""; if ($task->id == 0) { $checked1 = "checked"; $checked2 = "checked"; $person_select = -1; } ## eventually needed later when note is a subcategory of task /*else { if(!$pperson = $task->getAssignedPeople()){ $PH->abortWarning(__("ERROR: could not get assigned people"), ERROR_NOTE); } else{ foreach($pperson as $pp){ if($pp->id == $person->id){ $checked1= "checked"; } elseif($pp->id == $auth->cur_user->id){ $checked2= "checked"; } else{ $person_select = $pp->id; } } } }*/ $form->add(new Form_customHTML('<p><label>' . __('Assign to') . '</lable></p>', 'assigne_note')); if ($person->id != $auth->cur_user->id) { $form->add(new Form_customHTML('<span class="checker"><input value="' . $person->id . '" name="task_assignement1" type="checkbox" ' . $checked1 . '><label for="task_assignement1">' . $person->name . '</label></span>', 'assigned_person1')); $form->add(new Form_customHTML('<span class="checker"><input value="' . $auth->cur_user->id . '" name="task_assignement2" type="checkbox" ' . $checked2 . '><label for="task_assignement2">' . $auth->cur_user->name . '</label></span>', 'assigned_person2')); } else { $form->add(new Form_customHTML('<span class="checker"><input value="' . $auth->cur_user->id . '" name="task_assignement2" type="checkbox" ' . $checked2 . '><label for="task_assignement2">' . $auth->cur_user->name . '</label></span>', 'assigned_person')); } $pers_list = array(); $pers_list[-1] = __('undefined'); if ($people = Person::getPeople(array('can_login' => 1))) { foreach ($people as $pers) { if ($auth->cur_user->name != $pers->name) { $pers_list[$pers->id] = $pers->name; } } } $form->add(new Form_Dropdown('task_also_assign', __('Also assign to'), array_flip($pers_list), $person_select)); ## Book effort after submit ## $form->form_options[] = "<span class=option><input id='book_effort' name='book_effort' class='checker' type=checkbox>" . __("Book effort after submit") . "</span>"; $form->add(new Form_HiddenField('tsk', '', $task->id)); $form->add(new Form_HiddenField('person_id', '', $person->id)); $form->add(new Form_HiddenField('creation_time', '', $time)); echo $form; $PH->go_submit = 'taskNoteOnPersonEditSubmit'; echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * 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()); } } } }
function render_tr(&$task, $style = "") { global $PH; global $g_resolve_reason_names; if (!isset($task) || !is_object($task)) { trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING); return; } $buffer = ''; ### collapsed view ### $html_link = '<b>' . $task->getLink(false, false) . '</b>'; if ($task->view_collapsed) { $buffer .= $PH->getLink('taskToggleViewCollapsed', "<img src=\"" . getThemeFile("img/toggle_folder_closed.gif") . "\">", array('tsk' => $task->id), NULL, true) . $html_link; } else { $buffer .= $PH->getLink('taskToggleViewCollapsed', "<img src=\"" . getThemeFile("img/toggle_folder_open.gif") . "\">", array('tsk' => $task->id), NULL, true) . $html_link . '<br>'; $editable = false; if (Task::getEditableById($task->id)) { $editable = true; } $buffer .= "<div class=description>"; $buffer .= wikifieldAsHtml($task, 'description'); $buffer .= "</div>"; } echo '<td>' . $buffer . '</td>'; }
function _getParentOfTaskId($task_id) { global $PH; ### get path of target to check for cycles ### if ($task_id != 0) { if (!($task = Task::getEditableById($task_id))) { $PH->abortWarning(__("insufficient rights")); } $parents = $task->getFolder(); $parents[] = $task; } else { $parents = array(); } return $parents; }
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(); }
/** * 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(); }