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(); }
/** * Toggle comment collapsing @ingroup pages */ function commentToggleViewCollapsed() { global $PH; ### get comment #### $id = getOnePassedId('comment', 'comments_*'); if (!($comment = Comment::getEditableById($id))) { $PH->abortWarning("undefined comment"); } if ($comment->view_collapsed) { $comment->view_collapsed = 0; } else { $comment->view_collapsed = 1; } $comment->update(); ### display taskView #### if (!$PH->showFromPage()) { $PH->show('home'); } }
/** * Filter own changes * */ function personToggleFilterOwnChanges() { global $PH; global $auth; ### get person #### $id = getOnePassedId('person', 'people_*'); if (!($p = Person::getEditableById($id))) { $PH->abortWarning("Invalid person-id!"); } $p->settings ^= USER_SETTING_FILTER_OWN_CHANGES; $p->update(array('settings'), false); if ($auth->cur_user && $p->id == $auth->cur_user->id) { $auth->cur_user->settings ^= USER_SETTING_FILTER_OWN_CHANGES; } ### display taskView #### if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $person->project)); } }
/** * Submit changes to notes on a person * * @ingroup pages */ function taskNoteOnPersonEditSubmit() { global $PH; global $auth; global $g_user_profile_names; ### cancel? ### if (get('form_do_cancel')) { if (!$PH->showFromPage()) { $PH->show('personView', array('person' => getOnePassedId('person_id'))); } exit; } ### temporary object or from database? ### $tsk_id = getOnePassedId('tsk', '', true, 'invalid id'); if ($tsk_id == 0) { $task = new Task(array('id' => 0)); } ## eventually needed later when note is a subcategory of task /*else { if(!$task= Task::getVisiblebyId($tsk_id)) { $PH->abortWarning(__("ERROR: could not get task"), ERROR_NOTE); return; } }*/ ## other parameter ## $person_id = getOnePassedId('person_id'); $prj_id = get('project'); $prj_new = get('new_project'); $prj_name = get('new_project_name'); $assignement1 = get('task_assignement1'); $assignement2 = get('task_assignement2'); $also_assignement = get('task_also_assign'); ### 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; } ## prio ## if ($prio = get('task_prio')) { $task->prio = $prio; } ## status ## if (!$task->id) { $task->status = STATUS_NEW; } # 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); } ### validate ### $is_ok = true; ## no project ## if ($prj_id <= 0) { if (!isset($prj_new) || !isset($prj_name)) { new FeedbackWarning(__("Note requires project")); ## and no assignement ## if (!isset($assignement1) && !isset($assignement2) && $also_assignement == -1) { new FeedbackWarning(__("Note requires assigned person(s)")); } $is_ok = false; } } ## if project but no assignement ## if (!isset($assignement1) && !isset($assignement2) && $also_assignement == -1) { $assignement1 = $auth->cur_user->id; } if (!$is_ok) { $PH->show('taskNoteOnPersonEdit', array('tsk' => $task->id, 'person' => $person_id), $task); exit; } ## new project if (isset($prj_new) && isset($prj_name)) { $pperson = Person::getById($person_id); if ($companies = $pperson->getCompanies()) { $company_id = $companies[0]->id; } else { $company_id = 0; } $new_project = new Project(array('name' => $prj_name, 'company' => $company_id, 'status' => STATUS_NEW, 'prio' => PRIO_NORMAL, 'pub_level' => PUB_LEVEL_OPEN)); $new_project->insert(); $prj_id = $new_project->id; ## get project ## if (!($project = Project::getById($prj_id))) { $PH->abortWarning(__("ERROR: could not get project"), ERROR_NOTE); } } else { ## get project ## if (!($project = Project::getById($prj_id))) { $PH->abortWarning(__("ERROR: could not get project"), ERROR_NOTE); } } ## set project of task ## if (!$task->id) { $task->project = $project->id; } ## assigne people to task## $new_task_assignments = array(); $count = 0; if (!$task->id) { if (isset($assignement1)) { $person = Person::getById($assignement1); $new_assignment1 = new TaskPerson(array('person' => $assignement1, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id)); $new_task_assignments[$count] = $new_assignment1; $count++; } if (isset($assignement2)) { $person = Person::getById($assignement2); $new_assignment2 = new TaskPerson(array('person' => $assignement2, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id)); $new_task_assignments[$count] = $new_assignment2; $count++; } if ($also_assignement != -1) { $person = Person::getById($also_assignement); $new_assignment_also = new TaskPerson(array('person' => $also_assignement, 'task' => $task->id, 'comment' => sprintf(__("formerly assigned to %s", "task-assigment comment"), $person->name), 'project' => $project->id)); $new_task_assignments[$count] = $new_assignment_also; $count++; } } ## eventually needed later when note is a subcategory of task /*else { # ToDo: check if people are assigned }*/ ## assigne person to project ## $team = array(); $new_project_assignments = array(); $count = 0; if (!$task->id) { $projperson = $project->getPeople(false); foreach ($projperson as $projp) { $team[$projp->id] = $projp->name; } if (isset($assignement1)) { if (!isset($team[$assignement1])) { $person = Person::getById($assignement1); $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1; $pp_new1 = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style)); $new_project_assignments[$count] = $pp_new1; $count++; } } if (isset($assignement2)) { if (!isset($team[$assignement2])) { $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1; $person = Person::getById($assignement2); $pp_new2 = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style)); $new_project_assignments[$count] = $pp_new2; $count++; } } if ($also_assignement != -1) { if (!isset($team[$also_assignement])) { $person = Person::getById($also_assignement); $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1; $pp_new_also = new ProjectPerson(array('person' => $person->id, 'project' => $project->id, 'name' => $g_user_profile_names[$person->profile], 'adjust_effort_style' => $effort_style)); $new_project_assignments[$count] = $pp_new_also; $count++; } } } ## eventually needed later when note is a subcategory of task /*else{ # ToDo: check if people are assigned }*/ ## Insert ## if ($task->id == 0) { $task->insert(); ### write task-assigments ### foreach ($new_task_assignments as $nta) { $nta->task = $task->id; $nta->insert(); } ### write project-assigments ### foreach ($new_project_assignments as $npa) { $npa->insert(); } new FeedbackMessage(sprintf(__("Created task %s with ID %s"), $task->getLink(false), $task->id)); } ## eventually needed later when note is a subcategory of task /* else{ } */ ### book effort ### $book_effort = get('book_effort'); if ($book_effort) { $as_duration = 0; if ($pperson = $project->getProjectPeople()) { foreach ($pperson as $pp) { if ($pp->project == $project->id && $pp->person == $auth->cur_user->id) { if ($pp->adjust_effort_style == 1) { $as_duration = 0; } else { $as_duration = 1; } } } } else { $as_duration = 0; } if (get('creation_time')) { $start_time = get('creation_time'); } else { $start_time = ''; } ### build new object ### $newEffort = new Effort(array('id' => 0, 'name' => '', 'project' => $project->id, 'task' => $task->id, 'person' => $auth->cur_user->id, 'as_duration' => $as_duration, 'time_start' => $start_time)); $PH->show('effortEdit', array('effort' => $newEffort->id), $newEffort); exit; } ### display personList #### if (!$PH->showFromPage()) { $PH->show('personList', array()); } }
/** * 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 ajaxUserTasks() { $q = asCleanString(getOnePassedId("q")); $prj = intval(getOnePassedId("prj")); if ($prj == 0) { $prj = NULL; } if ($q == "") { $q = NULL; } $tasks = Task::getAll(array('search' => $q, 'project' => $prj)); $result = array(); foreach ($tasks as $t) { $result[] = array('name' => $t->name, 'id' => $t->id); } echo json_encode($result); }
function ProjView() { global $PH; global $auth; require_once confGet('DIR_STREBER') . "render/render_wiki.inc.php"; ### get current project ### $id = getOnePassedId('prj', 'projects_*'); if ($project = Project::getEditableById($id)) { $editable = true; } else { if ($project = Project::getVisibleById($id)) { $editable = false; } else { $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 = __("Project overview"); 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 ### if ($project->isPersonVisibleTeamMember($auth->cur_user)) { if ($editable) { $page->add_function(new PageFunction(array('target' => 'projEdit', 'params' => array('prj' => $project->id), 'icon' => 'edit', 'tooltip' => __('Edit this project'), 'name' => __('Edit project')))); } /* $item = ItemPerson::getAll(array( 'person'=>$auth->cur_user->id, 'item'=>$project->id )); if((!$item) || ($item[0]->is_bookmark == 0)){ $page->add_function(new PageFunction(array( 'target' =>'itemsAsBookmark', 'params' =>array('proj'=>$project->id), 'tooltip' =>__('Mark this project as bookmark'), 'name' =>__('Bookmark'), ))); } else{ $page->add_function(new PageFunction(array( 'target' =>'itemsRemoveBookmark', 'params' =>array('proj'=>$project->id), 'tooltip' =>__('Remove this bookmark'), 'name' =>__('Remove Bookmark'), ))); } */ /* if($project->state == 1) { $page->add_function(new PageFunction(array( 'target'=>'projDelete', 'params'=>array('prj'=>$project->id), 'icon'=>'delete', 'tooltip'=>__('Delete this project'), 'name'=>__('Delete') ))); } */ #$page->add_function(new PageFunctionGroup(array( # 'name' => __('new') #))); /* $page->add_function(new PageFunction(array( 'target' =>'projAddPerson', 'params' =>array('prj'=>$project->id), 'icon' =>'add', 'tooltip' =>__('Add person as team-member to project'), 'name' =>__('Team member') ))); */ if ($project->settings & PROJECT_SETTING_ENABLE_TASKS) { $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('prj' => $project->id), 'icon' => 'new', 'tooltip' => __('Create task'), 'name' => __('New task')))); } if ($project->settings & PROJECT_SETTING_ENABLE_BUGS) { $page->add_function(new PageFunction(array('target' => 'taskNewBug', 'params' => array('prj' => $project->id, 'add_issue' => 1), 'icon' => 'new', 'tooltip' => __('Create task with issue-report'), 'name' => __('New bug')))); } $page->add_function(new PageFunction(array('target' => 'taskNewDocu', 'params' => array('prj' => $project->id), 'icon' => 'new', 'tooltip' => __('Create wiki documentation page or start discussion topic'), 'name' => __('New topic')))); if ($project->settings & PROJECT_SETTING_ENABLE_EFFORTS && $auth->cur_user->settings & USER_SETTING_ENABLE_EFFORTS) { $page->add_function(new PageFunction(array('target' => 'effortNew', 'params' => array('prj' => $project->id), 'icon' => 'loghours', 'tooltip' => __('Book effort for this project'), 'name' => __('Book effort')))); } } $url = $PH->getUrl("projViewAsRSS", array('prj' => $project->id)); $page->extra_header_html .= '<link rel="alternate" type="application/rss+xml" title="' . asHtml($project->name) . ' ' . __("News") . '"' . ' href="' . $url . '" />'; ### render title ### echo new PageHeader(); echo new PageContentOpen_Columns(); measure_stop('current milestone'); require_once confGet('DIR_STREBER') . 'blocks/current_milestone_block.inc.php'; $block = new CurrentMilestoneBlock($project); $block->render(); measure_stop('current milestone'); measure_start('team'); require_once confGet('DIR_STREBER') . 'lists/list_docustructure.inc.php'; if (Task::getDocuTasks($project->id, 0)) { $list = new Block_DocuNavigation(array('project_id' => $project->id)); $list->print_all(); } #--- list team ----------------------------------------------------------- /* { $list= new ListBlock_projectTeam(); $list->title= __('Team members'); $list->show_icons=true; $list->active_block_function = 'list'; $list->print_automatic($project); } measure_stop('team'); */ echo new PageContentNextCol(); echo "<div class=description>"; echo wikifieldAsHtml($project, 'description', array('empty_text' => "[quote]" . __("This project does not have any text yet.\nDoubleclick here to add some.") . "[/quote]")); echo "</div>"; #--- news ----------------------------------------------------------- if ($project->settings & PROJECT_SETTING_ENABLE_NEWS) { require_once confGet('DIR_STREBER') . './blocks/project_news_block.inc.php'; print new ProjectNewsBlock($project); } require_once confGet('DIR_STREBER') . './lists/list_recentchanges.inc.php'; printRecentChanges(array($project), false); /* measure_start('changes'); { require_once(confGet('DIR_STREBER') . './lists/list_changes.inc.php'); $list= new ListBlock_changes(); $list->query_options['date_min']= $auth->cur_user->last_logout; $list->query_options['not_modified_by']= $auth->cur_user->id; $list->query_options['project']= $project->id; //$list->print_automatic($project); $list->print_automatic(); } measure_stop('changes'); */ echo "<br><br>"; # @@@ hack for firefox overflow problems ### HACKING: 'add new task'-field ### $PH->go_submit = 'taskNew'; echo '<input type="hidden" name="prj" value="' . $project->id . '">'; #$rss_url = confGet('SELF_PROTOCOL').'://'.confGet('SELF_URL'); #$rss_url = str_replace("index.php", "rss/", $rss_url); #$prj_id = $this->page->options[0]->target_params['prj']; $url = $PH->getUrl('projViewAsRSS', array('prj' => $project->id)); echo "<a style='margin:0px; border-width:0px;' href='{$url}' target='_blank'>" . "<img style='margin:0px; border-width:0px;' src='" . getThemeFile("icons/rss_icon.gif") . "'>" . "</a>"; echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * downloads a file as image @ingroup pages * */ function fileDownloadAsImage() { ### get file #### $id = getOnePassedId('file', 'files_*'); if (!($file = File::getVisibleById($id))) { $PH->abortWarning(__("Select some file to display")); return; } if ($max_size = get('max_size')) { if ($max_size > 200) { $file->nowViewedByUser(); } $file->viewAsImage($max_size); } else { $file->view(); $file->nowViewedByUser(); } }
/** * submit changes to one bookmark @ingroup pages */ function itemBookmarkEditSubmit() { global $PH; global $auth; ### cancel ? ### if (get('form_do_cancel')) { if (!$PH->showFromPage()) { $PH->show('home', array()); } exit; } ### Validate form crc if (!validateFormCrc()) { $PH->abortWarning(__('Invalid checksum for hidden form elements')); } ### get bookmark #### $id = getOnePassedId('bookmark'); $bm_id = getOnePassedId('bookmark_id'); $is_already_bookmark = getOnePassedId('is_already_bookmark'); $count = 0; if ($bm_id != 0 && $is_already_bookmark) { if (!($bookmark = ItemPerson::getAll(array('item' => $id, 'person' => $auth->cur_user->id, 'is_bookmark' => 1)))) { $PH->abortWarning(__('Could not get bookmark')); return; } } elseif ($bm_id != 0 && !$is_already_bookmark) { if (!($bookmark = ItemPerson::getAll(array('item' => $id, 'person' => $auth->cur_user->id)))) { $PH->abortWarning(__('Could not get bookmark')); return; } } elseif ($bm_id == 0) { $date = getGMTString(); $bookmark = new ItemPerson(array('id' => 0, 'item' => $id, 'person' => $auth->cur_user->id, 'is_bookmark' => 1, 'created' => $date)); } if ($bm_id != 0) { $bookmark = $bookmark[0]; } # retrieve all possible values from post-data # NOTE: # - this could be an security-issue. # - TODO: as some kind of form-edit-behaviour to field-definition foreach ($bookmark->fields as $f) { $f->parseForm($bookmark); } $notify_on_change = get('notify_on_change'); if ($notify_on_change) { $bookmark->notify_on_change = 1; $bookmark->notify_date = getGMTString(); } else { $bookmark->notify_on_change = 0; } $notify_period = get('notify_period'); if (!is_null($notify_period)) { $bookmark->notify_if_unchanged = $notify_period; } if ($bm_id != 0 && $is_already_bookmark) { $bookmark->update(); } elseif ($bm_id != 0 && !$is_already_bookmark) { $bookmark->is_bookmark = 1; $bookmark->created = getGMTString(); $bookmark->update(); $count++; } elseif ($bm_id == 0) { $bookmark->insert(); $count++; } if ($count) { new FeedbackMessage(sprintf(__("Added %s bookmark(s)."), $count)); } ### display fromPage #### if (!$PH->showFromPage()) { $PH->show('home', array()); } }
/** * Show an RSS Feed of the latest changes on a project @ingroup pages */ function projViewAsRSS() { require_once confGet('DIR_STREBER') . "std/class_rss.inc.php"; global $PH; global $auth; $project_id = getOnePassedId('prj', 'projects_*'); # aborts on failure if (!($project = Project::getVisibleById($project_id))) { echo "Project is not readable. Anonymous user active?"; exit; } ### used cached? ### $filepath = "_rss/proj_{$project->id}.xml"; if (file_exists($filepath) || getGMTString(filemtime($filepath)) . "<" . $project->modified) { RSS::updateRSS($project); } readfile_chunked($filepath); exit; }
/** * Submit changes to an effort @ingroup pages */ function effortEditSubmit() { global $PH; global $auth; ### Validate form crc if (!validateFormCrc()) { $PH->abortWarning(__('Invalid checksum for hidden form elements')); } ### get effort #### $id = getOnePassedId('effort'); if ($id == 0) { $effort = new Effort(array('id' => 0)); } else { $effort = Effort::getEditableById($id); if (!$effort) { $PH->abortWarning(__("Could not get effort")); return; } $effort->validateEditRequestTime(); } ### cancel ### if (get('form_do_cancel')) { if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $effort->project)); } exit; } ### get project ### $effort->project = get('effort_project'); if (!($project = Project::getVisibleById($effort->project))) { $PH->abortWarning(__("Could not get project of effort")); } if (!$project->isPersonVisibleTeamMember($auth->cur_user)) { $PH->abortWarning("ERROR: Insufficient rights"); } ### get person ### if ($effort->person = get('effort_person')) { if (!($person = Person::getVisibleById($effort->person))) { $PH->abortWarning(__("Could not get person of effort")); } } # retrieve all possible values from post-data # NOTE: # - this could be an security-issue. # - TODO: as some kind of form-edit-behaviour to field-definition foreach ($effort->fields as $f) { $name = $f->name; $f->parseForm($effort); } ### times as duration ### if ($as_duration = get('effort_as_duration')) { $effort->as_duration = $as_duration; ### make sure day of time_end stays the same if date changes... ### if (($time_start = $effort->time_start) && ($time_end = $effort->time_end)) { $effort->time_end = gmdate("Y-m-d", strToClientTime($time_end)) . " " . gmdate("H:i:s", strToClientTime($time_end)); $effort->time_start = gmdate("Y-m-d", strToClientTime($time_end)) . " " . gmdate("00:00:00", strToClientTime($time_end)); } else { trigger_error("Getting time_start and time_end failed", E_USER_WARNING); } } ### pub level ### if ($pub_level = get('effort_pub_level')) { ### not a new effort ### if ($effort->id) { if ($pub_level > $effort->getValidUserSetPublicLevels()) { $PH->abortWarning('invalid data', ERROR_RIGHTS); } } #else { # #@@@ check for person create rights #} $effort->pub_level = $pub_level; } ## effort status ## if ($effort_status = get('effort_status')) { $effort->status = $effort_status; } if ($effort_billing = get('effort_billing')) { $effort->billing = intval($effort_billing); } if ($effort_productivity = get('effort_productivity')) { $effort->productivity = intval($effort_productivity); } ### link to task ### $task_id = get('effort_task'); if (!is_null($task_id)) { if ($task_id == 0) { $effort->task = 0; } else { if ($task = Task::getVisibleById($task_id)) { $effort->task = $task->id; } } } ### go back to from if validation fails ### $failure = false; if (!$effort->name) { $failure = true; new FeedbackWarning(__("Name required")); } if (strToGMTime($effort->time_end) - strToGMTime($effort->time_start) < 0) { $failure = true; new FeedbackWarning(__("Cannot start before end.")); } ### validation of the Datetime fields### if (!$as_duration) { if (strToGMTime($effort->time_start) == 0) { $failure = true; $name = $effort->fields['time_start']->name; $field_id = $effort->_type . '_' . $name; $value_time = get($field_id . '_time'); new FeedbackWarning(sprintf(__("<b>%s</b> is not a valid value for start time."), $value_time)); $effort->time_start = getGMTString(); } if (strToGMTime($effort->time_end) == 0) { $failure = true; $name = $effort->fields['time_end']->name; $field_id = $effort->_type . '_' . $name; $value_time = get($field_id . '_time'); new FeedbackWarning(sprintf(__("<b>%s</b> is not a valid value for end time."), $value_time)); $effort->time_end = getGMTString(); } } else { ##As duration if (strToGMTime($effort->time_end) == 0) { $failure = true; $name = $effort->fields['time_end']->name; $field_id = $effort->_type . '_' . $name; $value_time = get($field_id . '_time'); new FeedbackWarning(sprintf(__("<b>%s</b> is not a valid value for hours."), $value_time)); $effort->time_end = gmdate("Y-m-d", time()) . " 00:00:00"; } } if ($failure) { $PH->show('effortEdit', NULL, $effort); exit; } ### write to db ### if ($effort->id == 0) { $effort->insert(); } else { $effort->update(); } ### display taskView #### if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $effort->project)); } }
/** * Returns a list of folders for the given project. * This is used for picking the destination folder for moving tasks across * projects. */ function ajaxListProjectFolders() { global $PH; global $auth; require_once confGet('DIR_STREBER') . 'std/class_changeline.inc.php'; require_once confGet('DIR_STREBER') . 'lists/list_recentchanges.inc.php'; require_once confGet('DIR_STREBER') . 'render/render_block.inc.php'; require_once confGet('DIR_STREBER') . 'lists/list_taskfolders.inc.php'; require_once confGet('DIR_STREBER') . 'lists/list_comments.inc.php'; require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php'; header("Content-type: text/html; charset=utf-8"); ### get project #### $project_id = getOnePassedId('prj'); if (!($project = Project::getVisibleById($project_id))) { echo __("requested invalid project"); exit; //$PH->abortWarning("task without project?", ERROR_BUG); } $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'; 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='project' value='{$project->id}'>"; }
/** * Remove people from a company * * @ingroup pages */ function companyPeopleDelete() { global $PH; $id = getOnePassedId('company', 'companies_*'); $company = Company::getEditableById($id); if (!$company) { $PH->abortWarning("Could not get object..."); } $person_ids = getPassedIds('person', 'people*'); if (!$person_ids) { $PH->abortWarning(__("No people selected...")); } $employments = $company->getEmployments(); $counter = 0; $errors = 0; foreach ($person_ids as $pid) { if (!($person = Person::getEditableById($pid))) { $PH->abortWarning("Could not access person by id"); } $assigned_to = false; foreach ($employments as $e) { if ($e->person == $person->id) { $assigned_to = true; $e_id = $e->id; if ($assigned_to) { $e_remove = Employment::getEditableById($e_id); if (!$e_remove) { $PH->abortWarning("Could not access employment by id"); } else { if ($e_remove->delete()) { $counter++; } else { $errors++; } } } else { $PH->abortWarning("Contact person isn't related to this company"); } } } } if ($errors) { new FeedbackWarning(sprintf(__("Failed to remove %s contact person(s)"), $errors)); } else { new FeedbackMessage(sprintf(__("Removed %s contact person(s)"), $counter)); } if (!$PH->showFromPage()) { $PH->show('companyView', array('company' => $company->id)); } }
/** * Submit changes to a team member @ingroup pages */ function projectPersonEditSubmit() { global $PH; ### Validate form integrity ### if (!validateFormCrc()) { $PH->abortWarning(__('Invalid checksum for hidden form elements')); } ### get projectperson #### $id = getOnePassedId('projectperson', true, 'invalid id'); if ($id == 0) { $pp = new ProjectPerson(array('id' => 0)); } else { $pp = new ProjectPerson($id); if (!$pp) { $PH->abortWarning("Could not get project person"); return; } } ### cancel ### if (get('form_do_cancel')) { if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $pp->project)); } exit; } ### get project ### if (!($project = new Project($pp->project))) { $PH->abortWarning("ERROR: could not get project", ERROR_FATAL); } ### get person ### if (!($person = new Person($pp->person))) { $PH->abortWarning("ERROR: could not get project", ERROR_FATAL); } # retrieve all possible values from post-data # NOTE: # - this could be an security-issue. # - TODO: as some kind of form-edit-behaviour to field-definition foreach ($pp->fields as $f) { $name = $f->name; $f->parseForm($pp); } ### set rights role ### /** * if profile != 0, it will OVERWRITE (or reinit) user_rights * * therefore persEdit set profil to 0 if rights don't fit profile. It will * then be skipped here */ if ($profile = intval(get('person_profile'))) { global $g_user_profile_names; global $g_user_profiles; #if($profile_settings= $g_user_profiles[$g_user_profile_names[$profile]]) { if ($profile_settings = $g_user_profiles[$profile]) { $pp->level_view = $profile_settings['level_view']; $pp->level_edit = $profile_settings['level_edit']; $pp->level_create = $profile_settings['level_create']; $pp->level_delete = $profile_settings['level_delete']; $pp->level_reduce = $profile_settings['level_reduce']; $pp->role = $profile; new FeedbackMessage(sprintf(__('Changed role of <b>%s</b> to <b>%s</b>'), $person->name, $g_user_profile_names[$profile])); } else { trigger_error("undefined profile requested.", E_USER_WARNING); } } ### pub level ### if ($pub_level = get('projectperson_pub_level')) { if ($pp->id) { if ($pub_level > $pp->getValidUserSetPublicLevels()) { $PH->abortWarning('invalid data', ERROR_RIGHTS); } } #else { # #@@@ check for person create rights #} $pp->pub_level = $pub_level; } ### effort-style ### if ($effort_style = get('projectperson_effort_style')) { $pp->adjust_effort_style = $effort_style; } ### write to db ### if ($pp->id == 0) { $pp->insert(); } else { $pp->update(); } ### return to from-page ### if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $pp->project)); } }
/** * revert changes of a person * * Notes: * - This function is only available of people with RIGHT_PROJECT_EDIT. * - This will only effect changes to fields. * - Following changes will not be reverted: * - Creation of new items (Tasks, Topis, Efforts, Projects, etc.) * - Task-assignments * - Uploading of files * * person - id of person who did the changes * data - date to with revert changes * delete_history (Default off) - Reverting can't be undone! The person's modification are lost forever! * This can be useful on massive changes to avoid sending huge * notification mails. */ function personRevertChanges() { global $PH; global $auth; ### check rights ### if (!$auth->cur_user->user_rights & RIGHT_PROJECT_EDIT) { $PH->abortWarning("You require the right to edit projects."); } ### get person ### $person_id = getOnePassedId('person', 'people_*'); if (!($person = Person::getVisibleById($person_id))) { $PH->abortWarning(sprintf(__("invalid Person #%s"), $person_id)); return; } $page = new Page(); $page->tabs['admin'] = array('target' => "index.php?go=systemInfo", 'title' => __('Admin', 'top navigation tab'), 'bg' => "misc"); $page->cur_tab = 'admin'; $page->crumbs[] = new NaviCrumb(array('target_id' => 'systemInfo')); $page->title = __("Reverting user changes"); $page->type = __("Admin"); #$page->title_minor=get('go'); echo new PageHeader(); echo new PageContentOpen(); $block = new PageBlock(array('title' => __('Overview'), 'id' => 'overview')); $block->render_blockStart(); echo "<div class=text>"; echo "<ul>"; ### get changes of person ### $count_reverted_fields = 0; $changes = ItemChange::getItemChanges(array('person' => $person_id, 'order_by' => 'id DESC')); foreach ($changes as $c) { if (!($project_item = DbProjectItem::getObjectById($c->item))) { #print "unable to get item %s" % $c->item; } else { ### Only revert changes, if item has not be editted by other person if ($project_item->modified_by == $person_id) { $field_name = $c->field; echo "<li>" . "<strong>" . asHtml($project_item->name) . "." . asHtml($field_name) . "</strong>" . " '" . asHtml($project_item->{$field_name}) . "' = '" . asHtml($c->value_old) . "'" . "</li>"; $count_reverted_fields++; if ($field_name == 'state') { if ($project_item->state == -1 && $c->value_old == 1) { $project_item->deleted_by = "0"; $project_item->deleted = "0000-00-00 00-00-00"; } } $project_item->{$field_name} = $c->value_old; $project_item->update(array($field_name, 'deleted_by', 'deleted'), false, false); } else { echo "<li>" . sprintf(__("Skipped recently editted item #%s: <b>%s<b>"), $project_item->id, asHtml($project_item->name)) . "</li>"; } $c->deleteFull(); } } echo "</ul>"; echo "<p>" . sprintf(__("Reverted all changes (%s) of user %s"), $count_reverted_fields, asHtml($person->nickname)) . "</p>"; echo "<p>" . __("newly created items by this user remain unaffected.") . "</p>"; echo "</div>"; $block->render_blockEnd(); ### close page echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * Submitting changes to version @ingroup pages */ function versionEditSubmit() { global $PH; ### get version #### $id = getOnePassedId('version'); if ($id == 0) { $version = new Version(array('id' => 0)); } else { $version = Version::getEditableById($id); if (!$version) { $PH->abortWarning(__("Could not get version")); return; } } ### cancel ### if (get('form_do_cancel')) { if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $version->project)); } exit; } ### Validate integrety ### if (!validateFormCrc()) { $PH->abortWarning(__('Invalid checksum for hidden form elements')); } validateFormCaptcha(true); ### get project ### $version->project = get('version_project'); if (!($project = Project::getVisibleById($version->project))) { $PH->abortWarning(__("Could not get project of version")); } # retrieve all possible values from post-data # NOTE: # - this could be an security-issue. # - TODO: as some kind of form-edit-behaviour to field-definition foreach ($version->fields as $f) { $name = $f->name; $f->parseForm($version); } ### pub level ### if ($pub_level = get('version_pub_level')) { ### not a new version ### if ($version->id) { if ($pub_level > $version->getValidUserSetPublicLevels()) { $PH->abortWarning('invalid data', ERROR_RIGHTS); } } #else { # #@@@ check for person create rights #} $version->pub_level = $pub_level; } ### go back to from if validation fails ### $failure = false; if (!$version->name) { $failure = true; new FeedbackWarning(__("Name required")); } if ($failure) { $PH->show('versionEdit', NULL, $version); exit; } ### write to db ### if ($version->id == 0) { $version->insert(); } else { $version->update(); } if (!$PH->showFromPage()) { $PH->show('projView', array('prj' => $version->project)); } }
/** * Person View @ingroup pages */ function personView() { global $PH; global $auth; ### get current person ### $id = getOnePassedId('person', 'people_*'); if (!($person = Person::getVisibleById($id))) { $PH->abortWarning("invalid person-id"); return; } ### create from handle ### $PH->defineFromHandle(array('person' => $person->id)); ## is viewed by user ## $person->nowViewedByUser(); $page = new Page(); $page->cur_tab = 'people'; if ($person->can_login) { $page->title = $person->nickname; $page->title_minor = $person->name; } else { $page->title = $person->name; if ($person->category) { global $g_pcategory_names; if (isset($g_pcategory_names[$person->category])) { $page->title_minor = $g_pcategory_names[$person->category]; } } } $page->type = __("Person"); $page->crumbs = build_person_crumbs($person); $page->options = build_person_options($person); ### skip edit functions ### if ($edit = Person::getEditableById($person->id)) { ### page functions ### $page->add_function(new PageFunction(array('target' => 'taskNoteOnPersonNew', 'params' => array('person' => $person->id), 'tooltip' => __('Add task for this people (optionally creating project and effort on the fly)', 'Tooltip for page function'), 'name' => __('Add note', 'Page function person')))); #$page->add_function(new PageFunction(array( #'target' =>'personLinkCompanies', #'params' =>array('person'=>$person->id), #'tooltip' =>__('Add existing companies to this person'), #'name' =>__('Companies'), #))); $page->add_function(new PageFunction(array('target' => 'personEdit', 'params' => array('person' => $person->id), 'icon' => 'edit', 'tooltip' => __('Edit this person', 'Tooltip for page function'), 'name' => __('Edit', 'Page function edit person')))); $page->add_function(new PageFunction(array('target' => 'personEditRights', 'params' => array('person' => $person->id), 'icon' => 'edit', 'tooltip' => __('Edit user rights', 'Tooltip for page function'), 'name' => __('Edit rights', 'Page function for edit user rights')))); if ($person->id != $auth->cur_user->id) { $page->add_function(new PageFunction(array('target' => 'personDelete', 'params' => array('person' => $person->id), 'name' => __('Delete')))); } $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $person->id)); if (!$item || $item[0]->is_bookmark == 0) { #$page->add_function(new PageFunction(array( # 'target' =>'itemsAsBookmark', # 'params' =>array('person'=>$person->id), # 'tooltip' =>__('Mark this person as bookmark'), # 'name' =>__('Bookmark'), #))); } else { $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('person' => $person->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark')))); } if ($person->state == ITEM_STATE_OK && $person->can_login && ($person->personal_email || $person->office_email)) { $page->add_function(new PageFunction(array('target' => 'personSendActivation', 'params' => array('person' => $person->id)))); $page->add_function(new PageFunction(array('target' => 'peopleFlushNotifications', 'params' => array('person' => $person->id)))); } } ### render title ### echo new PageHeader(); echo new PageContentOpen_Columns(); ### write info block (but only for registed users) global $auth; if ($auth->cur_user->id != confGet('ANONYMOUS_USER')) { $block = new PageBlock(array('title' => __('Summary', 'Block title'), 'id' => 'summary')); $block->render_blockStart(); echo "<div class=text>"; if ($person->mobile_phone) { echo "<div class=labeled><label>" . __('Mobile', 'Label mobilephone of person') . '</label>' . asHtml($person->mobile_phone) . '</div>'; } if ($person->office_phone) { echo "<div class=labeled><label>" . __('Office', 'label for person') . '</label>' . asHtml($person->office_phone) . '</div>'; } if ($person->personal_phone) { echo "<div class=labeled><label>" . __('Private', 'label for person') . '</label>' . asHtml($person->personal_phone) . '</div>'; } if ($person->office_fax) { echo "<div class=labeled><label>" . __('Fax (office)', 'label for person') . '</label>' . asHtml($person->office_fax) . '</div>'; } if ($person->office_homepage) { echo "<div class=labeled><label>" . __('Website', 'label for person') . '</label>' . url2linkExtern($person->office_homepage) . '</div>'; } if ($person->personal_homepage) { echo "<div class=labeled><label>" . __('Personal', 'label for person') . '</label>' . url2linkExtern($person->personal_homepage) . '</div>'; } if ($person->office_email) { echo "<div class=labeled><label>" . __('E-Mail', 'label for person office email') . '</label>' . url2linkMail($person->office_email) . '</div>'; } if ($person->personal_email) { echo "<div class=labeled><label>" . __('E-Mail', 'label for person personal email') . '</label>' . url2linkMail($person->personal_email) . '</div>'; } if ($person->personal_street) { echo "<div class=labeled><label>" . __('Adress Personal', 'Label') . '</label>' . asHtml($person->personal_street) . '</div>'; } if ($person->personal_zipcode) { echo '<div class=labeled><label></label>' . asHtml($person->personal_zipcode) . '</div>'; } if ($person->office_street) { echo "<div class=labeled><label>" . __('Adress Office', 'Label') . '</label>' . asHtml($person->office_street) . '</div>'; } if ($person->office_zipcode) { echo "<div class=labeled><label></label>" . asHtml($person->office_zipcode) . '</div>'; } if ($person->birthdate && $person->birthdate != "0000-00-00") { echo "<div class=labeled><label>" . __('Birthdate', 'Label') . "</label>" . renderDateHtml($person->birthdate) . "</div>"; } if ($person->last_login) { echo "<div class=labeled><label>" . __('Last login', 'Label') . '</label>' . renderDateHtml($person->last_login) . '</div>'; } ### functions #### echo "</div>"; $block->render_blockEnd(); } require_once confGet('DIR_STREBER') . 'lists/list_companies.inc.php'; $companies = $person->getCompanies(); $list = new ListBlock_companies(); $list->title = __('works for', 'List title'); unset($list->columns['short']); unset($list->columns['homepage']); unset($list->columns['people']); unset($list->functions['companyDelete']); #unset($list->functions['companyNew']); /** * \todo We should provide a list-function to link more * people to this company. But therefore we would need to * pass the company's id, which is not possible right now... */ $list->add_function(new ListFunction(array('target' => $PH->getPage('personLinkCompanies')->id, 'name' => __('Link Companies'), 'id' => 'personLinkCompanies', 'icon' => 'add'))); $list->add_function(new ListFunction(array('target' => $PH->getPage('personCompaniesDelete')->id, 'name' => __('Remove companies from person'), 'id' => 'personCompaniesDelete', 'icon' => 'sub', 'context_menu' => 'submit'))); if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT) { $list->no_items_html = $PH->getLink('personLinkCompanies', __('link existing Company'), array('person' => $person->id)) . " " . __("or") . " " . $PH->getLink('companyNew', __('create new'), array('person' => $person->id)); } else { $list->no_items_html = __("no companies related"); } #$list->no_items_html=__("no company"); $list->render_list($companies); echo new PageContentNextCol(); #--- description ---------------------------------------------------------------- if ($person->description != "") { $block = new PageBlock(array('title' => __('Person details'), 'id' => 'persondetails')); $block->render_blockStart(); echo "<div class=text>"; echo wikifieldAsHtml($person, 'description'); echo "</div>"; $block->render_blockEnd(); } /** * \Note: passing colum to person->getProject is not simple... * the sql-querry currently just querry project-people, which do not contain anything usefull * Possible solutions: * - rewrite the querry-string * - rewrite all order-keys to something like company.name */ $order_by = get('sort_' . $PH->cur_page->id . "_projects"); require_once confGet('DIR_STREBER') . 'lists/list_projects.inc.php'; $projects = $person->getProjects($order_by); if ($projects || $person->can_login) { $list = new ListBlock_projects(); $list->title = __('works in Projects', 'list title for person projects'); $list->id = "works_in_projects"; unset($list->columns['date_closed']); unset($list->columns['date_start']); unset($list->columns['tasks']); unset($list->columns['efforts']); unset($list->functions['projDelete']); unset($list->functions['projNew']); if ($auth->cur_user->user_rights & RIGHT_PROJECT_CREATE) { $list->no_items_html = $PH->getLink('projNew', '', array()); } else { $list->no_items_html = __("no active projects"); } $list->render_list($projects); } require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php'; $list = new ListBlock_tasks(array('active_block_function' => 'list')); $list->query_options['assigned_to_person'] = $person->id; unset($list->columns['created_by']); unset($list->columns['planned_start']); unset($list->columns['assigned_to']); $list->title = __('Assigned tasks'); $list->no_items_html = __('No open tasks assigned'); if (isset($list->block_functions['tree'])) { unset($list->block_functions['tree']); $list->block_functions['grouped']->default = true; } $list->print_automatic(); ### add company-id ### # note: some pageFunctions like personNew can use this for automatical linking # echo "<input type='hidden' name='person' value='{$person->id}'>"; #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(); }
/** * 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(); }