/** * View a comment * * @ingroup pages */ function commentView() { global $PH; global $auth; require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; ### get task #### if (!($comment = Comment::getVisibleById(get('comment')))) { $PH->abortWarning("invalid comment-id", ERROR_FATAL); } if (!($project = Project::getVisibleById($comment->project))) { $PH->abortWarning("invalid project-id", ERROR_FATAL); } $task = $comment->task ? Task::getVisibleById($comment->task) : NULL; ### create from handle ### $from_handle = $PH->defineFromHandle(array('comment' => $comment->id)); ## is viewed by user ## $comment->nowViewedByUser(); $page = new Page(); initPageForComment($page, $comment, $project); if ($comment->state == -1) { $page->title_minor = sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($comment->deleted)); } ### page functions ### $page->add_function(new PageFunction(array('target' => 'commentEdit', 'params' => array('comment' => $comment->id), 'icon' => 'edit', 'tooltip' => __('Edit this comment'), 'name' => __('Edit')))); $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $comment->id)); if (!$item || $item[0]->is_bookmark == 0) { $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('comment' => $comment->id), 'tooltip' => __('Mark this comment as bookmark'), 'name' => __('Bookmark')))); } else { $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('comment' => $comment->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark')))); } if ($comment->state == ITEMSTATE_DELETED) { $page->add_function(new PageFunction(array('target' => 'commentsUndelete', 'params' => array('comment' => $comment->id), 'icon' => 'delete', 'tooltip' => __('Delete this comment'), 'name' => __('Restore')))); } else { $page->add_function(new PageFunction(array('target' => 'commentsDelete', 'params' => array('comment' => $comment->id), 'icon' => 'delete', 'tooltip' => __('Delete this comment'), 'name' => __('Delete')))); } ### render title ### echo new PageHeader(); echo new PageContentOpen(); $block = new PageBlock(array('title' => __('Description'), 'id' => 'description', 'noshade' => true)); $block->render_blockStart(); $str = wikifieldAsHtml($comment, 'description'); echo "<div class=text>"; echo "{$str}"; echo "</div>"; $block->render_blockEnd(); echo '<input type="hidden" name="prj" value="' . $comment->project . '">'; echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * 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(); }
/** * internal function to add update markers to wiki texts * these markers will later be replaced by render_wiki (see render_wiki.inc.php FormatBlockChangemarks) */ public function getTextfieldWithUpdateNotes($fieldname) { require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php"; require_once confGet('DIR_STREBER') . 'db/db_itemperson.inc.php'; global $auth; ### has user last edited this item? ### if ($this->modified_by == $auth->cur_user->id) { return $this->{$fieldname}; } else { if ($item_people = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $this->id))) { $ip = $item_people[0]; if ($ip->viewed_last > $this->modified) { return $this->{$fieldname}; } } else { return $this->{$fieldname}; } } $new_version = $this->{$fieldname}; $changes = ItemChange::getItemChanges(array('item' => $this->id, 'field' => $fieldname, 'order_by' => 'modified', 'date_min' => $ip->viewed_last)); if (!$changes) { return $this->{$fieldname}; } $old_version = $changes[0]->value_old; require_once confGet('DIR_STREBER') . "std/difference_engine.inc.php"; $ota = explode("\n", str_replace("\r\n", "\n", $old_version)); $nta = explode("\n", str_replace("\r\n", "\n", $new_version)); $diffs = new Diff($ota, $nta); $new_lines = array(); foreach ($diffs as $d) { foreach ($d as $do) { if ($do->type == 'copy') { $new_lines[] .= join("\n", $do->orig); } else { if ($do->type == 'add') { $new_lines[] = "[added word]" . join("\n", $do->closing) . "[/added word]"; } else { if ($do->type == 'delete') { $new_lines[] = '[deleted word]' . join("\n", $do->orig) . '[/deleted word]'; } else { if ($do->type == 'change') { ### render word level differences $wld = new WordLevelDiff($do->orig, $do->closing); $change_ratio = DbProjectItem::getEditRatioOfWordLevelDiff($wld); if ($change_ratio > 0.1) { $new_lines[] = "[deleted word]" . join("\n", $do->orig) . "[/deleted word]"; $new_lines[] = "[added word]" . join("\n", $do->closing) . "[/added word]"; } else { $new_lines[] = formatWordLevelDiff($wld); } } } } } } } $buffer = join($new_lines, "\n"); #debugMessage($old_version); #debugMessage( htmlspecialchars($buffer)); return $buffer; }
function render_tr(&$item, $style = "") { if ($ip = ItemPerson::getAll(array('item' => $item->id, 'notify_if_unchanged_min' => NOTIFY_1DAY))) { $period = ''; switch ($ip[0]->notify_if_unchanged) { case NOTIFY_1DAY: $period = 24 * 60 * 60; break; case NOTIFY_2DAYS: $period = 2 * 24 * 60 * 60; break; case NOTIFY_3DAYS: $period = 3 * 24 * 60 * 60; break; case NOTIFY_4DAYS: $period = 4 * 24 * 60 * 60; break; case NOTIFY_5DAYS: $period = 5 * 24 * 60 * 60; break; case NOTIFY_1WEEK: $period = 7 * 24 * 60 * 60; break; case NOTIFY_2WEEKS: $period = 2 * 7 * 24 * 60 * 60; break; case NOTIFY_3WEEKS: $period = 3 * 7 * 24 * 60 * 60; break; case NOTIFY_1MONTH: $period = 4 * 7 * 24 * 60 * 60; break; case NOTIFY_2MONTH: $period = 2 * 4 * 7 * 24 * 60 * 60; break; } $notify_date = $ip[0]->notify_date; if ($notify_date != '0000-00-00 00:00:00') { $send_date = strToGMTime($notify_date) + $period; $current_date = time(); if ($send_date > $current_date) { $days = round(($send_date - $current_date) / 60 / 60 / 24); print "<td>" . sprintf(__('in %s day(s)'), $days) . "</td>"; } else { $days = round(($current_date - $send_date) / 60 / 60 / 24); print "<td>" . sprintf(__('since %s day(s)'), $days) . "</td>"; } } else { print "<td> </td>"; } } else { print "<td> </td>"; } }
private function addUntouchedMonitoredItems() { $unchanged_headline_html = ''; $unchanged_headline_txt = ''; $unchanged_body_html = ''; $unchanged_body_plaintext = ''; $monitored_items_unchanged = ItemPerson::getAll(array('is_bookmark' => 1, 'notify_if_unchanged_min' => NOTIFY_1DAY, 'person' => $this->recipient->id)); if (!$monitored_items_unchanged) { return; } foreach ($monitored_items_unchanged as $miu) { ## reminder period ## $period = ''; switch ($miu->notify_if_unchanged) { case NOTIFY_1DAY: $period = 24 * 60 * 60; break; case NOTIFY_2DAYS: $period = 2 * 24 * 60 * 60; break; case NOTIFY_3DAYS: $period = 3 * 24 * 60 * 60; break; case NOTIFY_4DAYS: $period = 4 * 24 * 60 * 60; break; case NOTIFY_5DAYS: $period = 5 * 24 * 60 * 60; break; case NOTIFY_1WEEK: $period = 7 * 24 * 60 * 60; break; case NOTIFY_2WEEKS: $period = 2 * 7 * 24 * 60 * 60; break; case NOTIFY_3WEEKS: $period = 3 * 7 * 24 * 60 * 60; break; case NOTIFY_1MONTH: $period = 4 * 7 * 24 * 60 * 60; break; case NOTIFY_2MONTH: $period = 2 * 4 * 7 * 24 * 60 * 60; break; } $date = $miu->notify_date; if ($pi = DbProjectItem::getVisibleById($miu->item)) { $mod_date = $pi->modified; if ($date != '0000-00-00 00:00:00') { $date = strToGMTime($date) + $period; $date = date('Y-m-d H:i:s', $date); if ($date >= $mod_date && strToGMTime($date) <= time()) { $diff = strToGMTime($date) - strToGMTime($mod_date); if ($diff >= $period) { ### diff in days ### $information_count++; $days = round((time() - strToGMTime($miu->notify_date)) / 60 / 60 / 24); $object = DbProjectItem::getObjectById($pi->id); $unchanged_body_html .= '<li>' . sprintf(__("%s (not touched since %s day(s))"), asHtml($object->name), $days) . '</li>'; $unchanged_body_plaintext .= '- ' . sprintf(__("%s (not touched since %s day(s))"), $object->name, $days) . '\\n\\r'; } } } } } if ($unchanged_body_html) { $this->information_count++; $this->body_html .= "<h3>" . __('Unchanged monitored items:', 'notification') . "</h3>" . "<ul>" . $unchanged_body_html . "</ul>"; $this->body_plaintext .= "\n\r" . __('Unchanged monitored items:', 'notification') . "\n\r" . $unchanged_body_plaintext; } }
/** * 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()); } } } }
/** * submit changes to several bookmarks @ingroup pages */ function itemBookmarkEditMultipleSubmit() { global $PH; global $auth; ### cancel ? ### if (get('form_do_cancel')) { if (!$PH->showFromPage()) { $PH->show('home', array()); } exit; } $count = 0; $error = 0; $edit = 0; $bookmark_array = array(); $is_bookmark = array(); $number = get('number'); for ($i = 0; $i < $number; $i++) { $bm_id = intval(get('bookmark_id_' . $i)); $bm_item = intval(get('bookmark_item_' . $i)); $is_already_bookmark = intval(get('is_already_bookmark_' . $i)); $is_bookmark[$bm_id] = $is_already_bookmark; if ($bm_id != 0 && $is_already_bookmark) { if (!($bookmark = ItemPerson::getAll(array('id' => $bm_id, 'person' => $auth->cur_user->id, 'is_bookmark' => 1)))) { $error++; } else { $bookmark_array[] = $bookmark[0]; } } elseif ($bm_id != 0 && !$is_already_bookmark) { if (!($bookmark = ItemPerson::getAll(array('id' => $bm_id, 'person' => $auth->cur_user->id, 'is_bookmark' => 0)))) { $error++; } else { $bookmark_array[] = $bookmark[0]; } } elseif ($bm_id == 0) { $date = getGMTString(); $bookmark = new ItemPerson(array('id' => 0, 'item' => $bm_item, 'person' => $auth->cur_user->id, 'is_bookmark' => 1, 'created' => $date)); $bookmark_array[] = $bookmark; } } foreach ($bookmark_array as $bma) { #$change = false; ### notify on change ### $noc = intval(get('notify_on_change')); if (!is_null($noc) && $noc != -1 && $noc != $bma->notify_on_change) { $bma->notify_on_change = $noc; #$change= true; } ### notify if unchanged ### $niu = intval(get('notify_if_unchanged')); if (!is_null($niu) && $niu != -1 && $niu != $bma->notify_if_unchanged) { $bma->notify_if_unchanged = $niu; #$change= true; } #if($change){ if ($bma->id != 0 && $is_bookmark[$bma->id]) { $bma->update(); $edit++; } elseif ($bma->id != 0 && !$is_bookmark[$bma->id]) { $bma->is_bookmark = 1; $bma->created = getGMTString(); $bma->update(); $count++; } elseif ($bma->id == 0) { $bma->insert(); $count++; } #} } if ($count) { new FeedbackMessage(sprintf(__("Added %s bookmark(s)."), $count)); } if ($edit) { new FeedbackMessage(sprintf(__("Edited %s bookmark(s)."), $edit)); } if ($error) { new FeedbackWarning(sprintf(__('%s bookmark(s) could not be added.'), $error)); } ### display fromPage #### if (!$PH->showFromPage()) { $PH->show('home', array()); } }
/** * view details of a version @ingroup pages */ function versionView() { global $PH; global $auth; require_once "render/render_wiki.inc.php"; ### get task #### if (!($version = Version::getVisibleById(get('version')))) { $PH->abortWarning("invalid version-id", ERROR_FATAL); } if (!($project = Project::getVisibleById($version->project))) { $PH->abortWarning("invalid project-id", ERROR_FATAL); } ### create from handle ### $from_handle = $PH->defineFromHandle(array('version' => $version->id)); ## is viewed by user ## $version->isViewedByUser($auth->cur_user); $page = new Page(); $page->cur_tab = 'projects'; $page->cur_crumb = 'projViewTasks'; $page->crumbs = build_project_crumbs($project); $page->options = build_projView_options($project); $type = __('Version', 'page type'); if ($task) { $folder = $task->getFolderLinks() . "<em>></em>" . $task->getLink(); $page->type = $folder . " > " . $type; } else { $page->type = $type; } $page->title = $version->name; $page->title_minor = ""; if ($version->state == -1) { $page->title_minor = sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($version->deleted)); } ### page functions ### $page->add_function(new PageFunction(array('target' => 'versionEdit', 'params' => array('version' => $version->id), 'icon' => 'edit', 'tooltip' => __('Edit this version'), 'name' => __('Edit')))); $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $version->id)); if (!$item || $item[0]->is_bookmark == 0) { $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Mark this version as bookmark'), 'name' => __('Bookmark')))); } else { $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark')))); } ### render title ### echo new PageHeader(); echo new PageContentOpen(); $block = new PageBlock(array('title' => __('Description'), 'id' => 'description', 'noshade' => true)); $block->render_blockStart(); $str = wikifieldAsHtml($version, 'description'); echo "<div class=text>"; echo "{$str}"; echo "</div>"; $block->render_blockEnd(); echo '<input type="hidden" name="prj" value="' . $version->project . '">'; /** * give parameter for create of new items (subtasks, efforts, etc) */ #echo '<input type="hidden" name="parent_task" value="'.$task->id.'">'; echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * remove items from user's notification list @ingroup pages */ function itemsRemoveNotification() { global $PH; global $auth; $valid = false; if ($ids = getPassedIds('task', 'tasks_*')) { $valid = true; } elseif ($ids = getPassedIds('person', 'people_*')) { $valid = true; } elseif ($ids = getPassedIds('company', 'companies_*')) { $valid = true; } elseif ($ids = getPassedIds('proj', 'projects_*')) { $valid = true; } elseif ($ids = getPassedIds('effort', 'efforts_*')) { $valid = true; } elseif ($ids = getPassedIds('comment', 'comments_*')) { $valid = true; } elseif ($ids = getPassedIds('file', 'files_*')) { $valid = true; } elseif ($ids = getPassedIds('version', 'versions_*')) { $valid = true; } else { $PH->abortWarning(__("No item(s) selected."), ERROR_NOTE); } if ($valid) { foreach ($ids as $id) { if ($item = ItemPerson::getAll(array('item' => $id, 'notify_on_change' => true))) { $item[0]->notify_on_change = false; $item[0]->update(); } } } if (!$PH->showFromPage()) { $PH->show('home'); } }
/** * show details of an Effort @ingroup pages */ function effortView() { global $PH; global $auth; global $g_effort_billing_names; require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; ### get effort #### $ids = getPassedIds('effort', 'efforts_*'); if (!$ids) { $PH->abortWarning(__("Select one or more efforts")); return; } else { if (count($ids) > 1) { $PH->show('effortViewMultiple'); exit; } else { if (!($effort = Effort::getEditableById($ids[0]))) { $PH->abortWarning(__("You do not have enough rights"), ERROR_RIGHTS); } } } ## get project ## if (!($project = Project::getVisibleById($effort->project))) { $PH->abortWarning("invalid project-id", ERROR_FATAL); } ## get task # $task = $effort->task ? Task::getVisibleById($effort->task) : NULL; ### create from handle ### $from_handle = $PH->defineFromHandle(array('effort' => $effort->id)); ## is viewed by user ## $effort->nowViewedByUser(); $page = new Page(); initPageForEffort($page, $effort, $project); ### page functions ### $page->add_function(new PageFunction(array('target' => 'effortEdit', 'params' => array('effort' => $effort->id), 'icon' => 'edit', 'tooltip' => __('Edit this effort'), 'name' => __('Edit')))); $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $effort->id)); if (!$item || $item[0]->is_bookmark == 0) { $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('effort' => $effort->id), 'tooltip' => __('Mark this effort as bookmark'), 'name' => __('Bookmark')))); } else { $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('effort' => $effort->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark')))); } ### render title ### echo new PageHeader(); echo new PageContentOpen(); $block = new PageBlock(array('title' => __('Description'))); $block->render_blockStart(); echo '<div class="text">'; if ($project) { echo "<div class=labeled><label>" . __('Project', 'label') . "</label>" . $project->getLink(false) . "</div>"; } if ($task) { if ($task->parent_task != 0) { $folder = $task->getFolderLinks(false) . "<em> > </em>" . $task->getLink(false); echo "<div class=labeled><label>" . __('Task', 'label') . "</label>" . $folder . "</div>"; } else { echo "<div class=labeled><label>" . __('Task', 'label') . "</label>" . $task->getLink(false) . "</div>"; } } else { echo "<div class=labeled><label>" . __('Task', 'label') . "</label>" . __('No task related') . "</div>"; } if (!($person = Person::getById($effort->person))) { echo "<div class=labeled><label>" . __('Created by', 'label') . "</label>" . __('not available') . "</div>"; } else { echo "<div class=labeled><label>" . __('Created by', 'label') . "</label>" . $person->getLink() . "</div>"; } if ($effort) { $duration = round((strToGMTime($effort->time_end) - strToGMTime($effort->time_start)) / 60 / 60, 1) . " h"; if ($effort->as_duration) { echo "<div class=labeled><label>" . __('Created at', 'label') . "</label>" . renderDateHtml($effort->time_start) . "</div>"; echo "<div class=labeled><label>" . __('Duration', 'label') . "</label>" . asHtml($duration) . "</div>"; } else { echo "<div class=labeled><label>" . __('Time start', 'label') . "</label>" . renderTimestampHtml($effort->time_start) . "</div>"; echo "<div class=labeled><label>" . __('Time end', 'label') . "</label>" . renderTimestampHtml($effort->time_end) . "</div>"; echo "<div class=labeled><label>" . __('Duration', 'label') . "</label>" . asHtml($duration) . "</div>"; } echo "<div class=labeled><label>" . __('Productivity', 'label') . "</label>" . asHtml($effort->productivity) . "</div>"; echo "<div class=labeled><label>" . __('Billing', 'label') . "</label>" . $g_effort_billing_names[intval($effort->billing)] . "</div>"; } echo "</div>"; $block->render_blockEnd(); $block = new PageBlock(array('title' => __('Description'), 'id' => 'description')); $block->render_blockStart(); if ($effort->description != "") { echo '<div class="text">'; echo wikifieldAsHtml($effort, 'description'); ### update task if relative links have been converted to ids ### if (checkAutoWikiAdjustments()) { $effort->description = applyAutoWikiAdjustments($effort->description); $effort->update(array('description'), false); } echo "</div>"; } else { if ($auth->cur_user->user_rights & RIGHT_PROJECT_ASSIGN) { echo '<div class="empty">' . $PH->getLink('effortEdit', '', array('effort' => $effort->id)) . "</div>"; } else { echo '<div class="text">' . __('No description available') . "</div>"; } } $block->render_blockEnd(); echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * View a company * * @ingroup pages */ function companyView() { global $PH; global $auth; require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; ### get current company ### $id = getOnePassedId('company', 'companies_*'); $company = Company::getVisibleById($id); if (!$company) { $PH->abortWarning("invalid company-id"); return; } ## is viewed by user ## $company->nowViewedByUser(); $company->validateView(); ### create from handle ### $PH->defineFromHandle(array('company' => $company->id)); $page = new Page(); $page->cur_tab = 'companies'; $page->title = $company->name; $page->title_minor = __("Overview"); $page->type = __("Company"); ### breadcrumbs ### $page->crumbs = build_company_crumbs($company); ### page functions ### $page->add_function(new PageFunctionGroup(array('name' => __('edit')))); $page->add_function(new PageFunction(array('target' => 'companyEdit', 'params' => array('company' => $company->id), 'icon' => 'edit', 'tooltip' => __('Edit this company'), 'name' => __('Company')))); $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $company->id)); if (!$item || $item[0]->is_bookmark == 0) { $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('company' => $company->id), 'tooltip' => __('Mark this company as bookmark'), 'name' => __('Bookmark')))); } else { $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('company' => $company->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark')))); } if ($company->state == 1) { $page->add_function(new PageFunction(array('target' => 'companyDelete', 'params' => array('company' => $company->id), 'icon' => 'delete', 'tooltip' => __('Delete this company'), 'name' => __('Delete')))); } $page->add_function(new PageFunctionGroup(array('name' => __('new')))); $page->add_function(new PageFunction(array('target' => 'personNew', 'params' => array('company' => $company->id), 'icon' => 'new', 'tooltip' => __('Create new person for this company'), 'name' => __('Person')))); $page->add_function(new PageFunction(array('target' => 'projNew', 'params' => array('company' => $company->id), 'icon' => 'new', 'tooltip' => __('Create new project for this company'), 'name' => __('Project')))); $page->add_function(new PageFunction(array('target' => 'companyLinkPeople', 'params' => array('company' => $company->id), 'icon' => 'add', 'tooltip' => __('Add existing people to this company'), 'name' => __('People')))); ### render title ### echo new PageHeader(); echo new PageContentOpen_Columns(); $block = new PageBlock(array('title' => __('Summary'), 'id' => 'summary')); $block->render_blockStart(); echo "<div class=text>"; if ($company->comments) { echo wikifieldAsHtml($company, 'comments'); } if ($company->street) { echo '<div class=labeled><label>' . __('Adress') . ':</label>' . asHtml($company->street) . '</div>'; } if ($company->zipcode) { echo '<div class=labeled><label></label>' . asHtml($company->zipcode) . '</div>'; } if ($company->phone) { echo '<div class=labeled><label>' . __('Phone') . ':</label>' . asHtml($company->phone) . '</div>'; } if ($company->fax) { echo '<div class=labeled><label>' . __('Fax') . ':</label>' . asHtml($company->fax) . '</div>'; } if ($company->homepage) { echo '<div class=labeled><label>' . __('Web') . ':</label>' . url2linkExtern($company->homepage) . '</div>'; } if ($company->intranet) { echo '<div class=labeled><label>' . __('Intra') . ':</label>' . url2linkExtern($company->intranet) . '</div>'; } if ($company->email) { echo '<div class=labeled><label>' . __('Mail') . ':</label>' . url2linkMail($company->email) . '</div>'; } $sum = 0; foreach ($company->getProjects() as $p) { $sum += $p->getOpenEffortsSum(); } if ($sum > 0) { echo "<div class=text>"; echo '<div class=labeled><label>' . __('Open efforts') . ':</label>' . round($sum / 60 / 60, 1) . 'h</div>'; echo "</div>"; } echo "</div>"; $block->render_blockEnd(); require_once confGet('DIR_STREBER') . 'pages/person.inc.php'; $list = new ListBlock_people(); $people = $company->getPeople(); $list->title = __('related People'); $list->id = "related_people"; unset($list->columns['tagline']); unset($list->columns['nickname']); unset($list->columns['profile']); unset($list->columns['projects']); unset($list->columns['personal_phone']); unset($list->columns['office_phone']); unset($list->columns['companies']); unset($list->columns['changes']); unset($list->columns['last_login']); unset($list->functions['personDelete']); unset($list->functions['personEditRights']); /** * \NOTE 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('companyLinkPeople')->id, 'name' => __('Link People'), 'id' => 'companyLinkPeople', 'icon' => 'add'))); $list->add_function(new ListFunction(array('target' => $PH->getPage('companyPeopleDelete')->id, 'name' => __('Remove person from company'), 'id' => 'companyPeopleDelete', 'icon' => 'sub', 'context_menu' => 'submit'))); if ($auth->cur_user->user_rights & RIGHT_COMPANY_EDIT) { $list->no_items_html = $PH->getLink('companyLinkPeople', __('link existing Person'), array('company' => $company->id)) . " " . __("or") . " " . $PH->getLink('personNew', __('create new'), array('company' => $company->id)); } else { $list->no_items_html = __("no people related"); } $list->render_list($people); //$list->print_automatic($people); echo new PageContentNextCol(); require_once confGet('DIR_STREBER') . 'lists/list_projects.inc.php'; $order_by = get('sort_' . $PH->cur_page->id . "_projects"); $list = new ListBlock_projects(); $list->title = __("Active projects"); $list->id = "active_projects"; $list->groupings = NULL; $list->block_functions = NULL; unset($list->columns['company']); unset($list->functions['projNew']); unset($list->functions['projDelete']); $list->query_options['status_min'] = STATUS_UPCOMING; $list->query_options['status_max'] = STATUS_OPEN; $list->query_options['company'] = $company->id; if ($auth->cur_user->user_rights & RIGHT_PROJECT_CREATE) { $list->no_items_html = $PH->getLink('projNew', __('Create new project'), array('company' => $company->id)) . " " . __(" Hint: for already existing projects please edit those and adjust company-setting."); } else { $list->no_items_html = __("no projects yet"); } $list->print_automatic(); $list = new ListBlock_projects(); $list->groupings = NULL; $list->block_functions = NULL; $list->title = __("Closed projects"); $list->id = "closed_projects"; unset($list->columns['company']); unset($list->functions['projNew']); unset($list->functions['projDelete']); $list->query_options['status_min'] = STATUS_BLOCKED; $list->query_options['status_max'] = STATUS_CLOSED; $list->query_options['company'] = $company->id; $list->print_automatic(); ### add company-id ### # note: some pageFunctions like personNew can use this for automatical linking echo "<input type=hidden name=company value='{$company->id}'>"; echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * view task a documentation page @ingroup pages */ function taskViewAsDocu() { global $PH; global $auth; require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; require_once confGet('DIR_STREBER') . 'db/db_itemperson.inc.php'; ### get task #### $tsk = get('tsk'); $editable = false; # flag, if this task can be edited if ($task = Task::getEditableById($tsk)) { $editable = true; } else { if (!($task = Task::getVisibleById($tsk))) { $PH->abortWarning("invalid task-id", ERROR_FATAL); } } if (!($project = Project::getVisibleById($task->project))) { $PH->abortWarning("this task has an invalid project id", ERROR_DATASTRUCTURE); } ### create from handle ### $from_handle = $PH->defineFromHandle(array('tsk' => $task->id)); global $g_wiki_task; $g_wiki_task = $task; ### set up page and write header #### measure_start("page_render"); $page = new Page(); $page->use_autocomplete = true; initPageForTask($page, $task, $project); $page->title_minor_html = $PH->getLink('taskView', sprintf('#%d', $task->id), array('tsk' => $task->id)); if ($task->state == -1) { $page->title_minor_html .= ' ' . sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($task->deleted)); } ### page functions ### if ($project->isPersonVisibleTeamMember($auth->cur_user)) { ### edit ### if ($editable) { $page->add_function(new PageFunction(array('target' => 'taskEdit', 'params' => array('tsk' => $task->id), 'icon' => 'edit', 'tooltip' => __('Edit this task'), 'name' => __('Edit')))); $page->add_function(new PageFunction(array('target' => 'tasksMoveToFolder', 'params' => array('tsk' => $task->id), 'icon' => 'edit', 'name' => __('Move', 'page function to move current task')))); if ($task->state == 1) { $page->add_function(new PageFunction(array('target' => 'tasksDelete', 'params' => array('tsk' => $task->id), 'icon' => 'delete', 'tooltip' => __('Delete this task'), 'name' => __('Delete')))); } else { if ($task->state == -1) { $page->add_function(new PageFunction(array('target' => 'tasksUndelete', 'params' => array('tsk' => $task->id), 'icon' => 'undelete', 'tooltip' => __('Restore this task'), 'name' => __('Undelete')))); } } } if ($auth->cur_user->settings & USER_SETTING_ENABLE_EFFORTS && $project->settings & PROJECT_SETTING_ENABLE_EFFORTS) { $page->add_function(new PageFunction(array('target' => 'effortNew', 'params' => array('parent_task' => $task->id), 'icon' => 'effort', 'name' => __('Book Effort')))); } ### new ### if ($task->category == TCATEGORY_FOLDER) { $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('parent_task' => $task->id, 'task_category' => TCATEGORY_DOCU, 'task_show_folder_as_documentation' => 1), 'icon' => 'edit', 'name' => __('New topic')))); } else { if ($task->parent_task) { $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('parent_task' => $task->parent_task, 'task_category' => TCATEGORY_DOCU, 'task_show_folder_as_documentation' => 1), 'icon' => 'edit', 'name' => __('New topic')))); } else { $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('prj' => $task->project, 'task_category' => TCATEGORY_DOCU), 'icon' => 'edit', 'name' => __('New topic')))); } } if ($auth->cur_user->settings & USER_SETTING_ENABLE_BOOKMARKS) { require_once confGet('DIR_STREBER') . 'db/db_itemperson.inc.php'; $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $task->id)); if (!$item || $item[0]->is_bookmark == 0) { $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('task' => $task->id), 'tooltip' => __('Mark this task as bookmark'), 'name' => __('Bookmark')))); } else { $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('task' => $task->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark')))); } } } ### render title ### echo new PageHeader(); echo new PageContentOpen_Columns(); require_once confGet('DIR_STREBER') . 'lists/list_docustructure.inc.php'; $list = new Block_DocuNavigation(array('current_task' => $task)); $list->print_all(); $block = new PageBlock(array('id' => 'summary', 'reduced_header' => true)); $block->render_blockStart(); echo "<div class=text>"; if ($person_creator = Person::getVisibleById($task->created_by)) { echo "<div class=labeled><label>" . __("Created", "Label in Task summary") . "</label>" . renderDateHtml($task->created) . ' / ' . $person_creator->getLink() . '</div>'; } if ($person_modify = Person::getVisibleById($task->modified_by)) { echo "<div class=labeled><label>" . __("Modified", "Label in Task summary") . "</label>" . renderDateHtml($task->modified) . ' / ' . $person_modify->getLink() . '</div>'; } require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php"; $versions = ItemVersion::getFromItem($task); if (count($versions) > 1) { $str_version = $PH->getLink('itemViewDiff', sprintf(__("View previous %s versions"), count($versions)), array('item' => $task->id)); echo "<div class=labeled><label></label>{$str_version}</div>"; } ### publish to ### global $g_pub_level_names; if ($task->pub_level != PUB_LEVEL_OPEN && isset($g_pub_level_names[$task->pub_level])) { echo "<div class=labeled><label>" . __("Publish to", "Label in Task summary") . "</label>" . $g_pub_level_names[$task->pub_level]; if ($editable) { echo '<br>(' . $PH->getLink('itemsSetPubLevel', __('Set to Open'), array('item' => $task->id, 'item_pub_level' => PUB_LEVEL_OPEN)) . ')'; } echo "</div>"; } echo "</div>"; $block->render_blockEnd(); require_once confGet('DIR_STREBER') . 'blocks/files_attached_to_item.inc.php'; print new FilesAttachedToItemBlock($task); echo new PageContentNextCol(); require_once confGet('DIR_STREBER') . 'db/db_itemperson.inc.php'; if ($view = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $task->id, 'feedback_requested_by' => true))) { if ($requested_by = Person::getPeople(array('id' => $view[0]->feedback_requested_by))) { echo "<div class=item_notice>"; echo "<h3>" . sprintf(__("Your feedback is requested by %s."), asHtml($requested_by[0]->nickname)) . "</h3>"; echo __("Please edit or comment this item."); echo "</div>"; } } #$descriptionWithUpdates= $task->getTextfieldWithUpdateNotes('description'); echo "<div class=description>"; echo wikifieldAsHtml($task, 'description', array('empty_text' => "[quote]" . __("This topic does not have any text yet.\nDoubleclick here to add some.") . "[/quote]")); echo "</div>"; ### Apply automatic link conversions if (checkAutoWikiAdjustments()) { $task->description = applyAutoWikiAdjustments($task->description); $task->update(array('description'), false); } require_once confGet('DIR_STREBER') . 'blocks/comments_on_item_block.inc.php'; print new CommentsOnItemBlock($task); echo new PageContentClose(); echo new PageHtmlEnd(); measure_stop("page_render"); $task->nowViewedByUser(); }
/** * View details of a file (versions, etc) @ingroup pages */ function fileView() { global $PH; global $auth; require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; ### get object #### $file_id = getOnePassedId('file'); if (!($file = File::getVisibleById($file_id))) { $PH->abortWarning("invalid file-id", ERROR_FATAL); } $file_org = $file->getOriginal(); if ($file->is_latest) { $file_latest = $file; } else { $file_latest = $file->getLatest(); } if (!($project = Project::getVisibleById($file->project))) { $PH->abortWarning("invalid project-id", ERROR_FATAL); } /** * parent item (not implemented yet) */ $parent_task = NULL; if ($file->parent_item) { #trigger_error('@@@not implemented yet', E_USER_ERROR); if (!($parent_task = Task::getVisibleById(intval($file->parent_item)))) { $PH->messages[] = sprintf(__("Could not access parent task Id:%s"), $file->parent_item); } } ### create from handle ### $from_handle = $PH->defineFromHandle(array('file' => $file->id)); ## is viewed by user ## $file->nowViewedByUser(); $page = new Page(); initPageForFile($page, $file, $project); #$page->title_minor=sprintf('#%d', $file_org->id);; if ($file->state == -1) { $page->title_minor = sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($file->deleted)); } ### page functions ### $page->add_function(new PageFunction(array('target' => 'fileEdit', 'params' => array('file' => $file->id), 'icon' => 'edit', 'tooltip' => __('Edit this file'), 'name' => __('Edit')))); $page->add_function(new PageFunction(array('target' => 'filesMoveToFolder', 'params' => array("file" => $file->id), 'tooltip' => __('Move this file to another task'), 'name' => __('Move')))); if ($auth->cur_user->settings & USER_SETTING_ENABLE_BOOKMARKS) { $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $file->id)); if (!$item || $item[0]->is_bookmark == 0) { $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('file' => $file->id), 'tooltip' => __('Mark this file as bookmark'), 'name' => __('Bookmark')))); } else { $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('file' => $file->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark')))); } } ### render title ### echo new PageHeader(); echo new PageContentOpen(); $block = new PageBlock(array('title' => __('Upload new version', 'block title'), 'id' => 'summary')); $block->render_blockStart(); echo "<div class=text>"; echo '<input type="hidden" name="MAX_FILE_SIZE" value="' . confGet('FILE_UPLOAD_SIZE_MAX') . '" />'; echo '<input id="userfile" name="userfile" type="file" size="40" accept="*" />'; echo '<input type="submit" value="' . __('Upload') . '" />'; echo '</div>'; $block->render_blockEnd(); $block = new PageBlock(array('title' => sprintf(__('Version #%s (current): %s'), $file_latest->version, $file_latest->name), 'id' => 'description')); $block->render_blockStart(); echo "<div class=text>"; ### show thumbnail if ($file_latest->mimetype == "image/png" || $file_latest->mimetype == "image/x-png" || $file_latest->mimetype == "image/jpeg" || $file_latest->mimetype == "image/gif") { echo "<div class=image style='float:right;'><a href='index.php?go=fileDownloadAsImage&file={$file_latest->id}'>"; echo "<img src='index.php?go=fileDownloadAsImage&file={$file_latest->id}&max_size=128'>"; echo "</a></div>"; } if ($parent_task) { echo "<div class=labeled><label>" . __('For task') . "</label><span>" . $parent_task->getLink(false) . "</span></div>"; } echo "<div class=labeled><label>" . __('Filesize') . "</label><span>{$file_latest->filesize} bytes</span></div>"; echo "<div class=labeled><label>" . __('Type') . "</label><span>{$file_latest->mimetype}</span></div>"; echo "<div class=labeled><label>" . __('Uploaded') . "</label><span>" . renderDateHtml($file_latest->created) . "</span></div>"; if ($uploader = Person::getVisibleById($file->created_by)) { echo "<div class=labeled><label>" . __('Uploaded by') . "</label><span>" . $uploader->getLink() . "</span></div>"; } if ($file_latest->created != $file_latest->modified) { echo "<div class=labeled><label>" . __('Modified') . "</label><span>" . renderDateHtml($file_latest->created) . "</span></div>"; } echo "<div class=labeled><label>" . __('Download') . "</label><span>" . $PH->getLink('fileDownload', $file_latest->org_filename, array('file' => $file_latest->id)) . "</span></div>"; $str = wikifieldAsHtml($file_latest, 'description'); echo "<br>"; echo "{$str}"; echo "</div>"; $block->render_blockEnd(); /** * build list of old versions, * because org_file is zero for the original file, with have to append it */ $old_files = File::getAll(array('latest_only' => false, 'org_file' => $file_org->id, 'order_by' => 'version DESC', 'project' => $project->id)); if ($file_latest->id != $file_org->id) { $old_files[] = $file_org; } foreach ($old_files as $of) { if ($of->id != $file_latest->id) { $block = new PageBlock(array('title' => sprintf(__('Version #%s : %s'), $of->version, $of->name), 'id' => 'version_' . $of->id)); $block->render_blockStart(); echo "<div class=text>"; ### show thumbnail if ($of->mimetype == "image/png" || $of->mimetype == "image/x-png" || $of->mimetype == "image/jpeg" || $of->mimetype == "image/gif") { echo "<div class=image style='float:right;'><a href='index.php?go=fileDownloadAsImage&file={$of->id}'>"; echo "<img src='index.php?go=fileDownloadAsImage&file={$of->id}&max_size=128'>"; echo "</a></div>"; } $str = wikifieldAsHtml($of, 'description'); echo "{$str}"; echo "<div class=labeled><label>" . __('Filesize') . "</label><span>{$of->filesize} bytes</span></div>"; echo "<div class=labeled><label>" . __('Type') . "</label><span>{$of->mimetype}</span></div>"; echo "<div class=labeled><label>" . __('Uploaded') . "</label><span>" . renderDateHtml($of->created) . "</span></div>"; #echo "<div class=labeled><label>" . __('Version') . "</label><span>". intval($of->version) ."</span></div>"; echo "<div class=labeled>" . $PH->getLink('fileDownload', '', array('file' => $of->id)) . "</div>"; echo "</div>"; $block->render_blockEnd(); } } $PH->go_submit = 'fileUpdate'; /** * list comments * NOTE: can files have comments? */ /* { $comments= $file->getComments(); $list=new ListBlock_comments(); $list->no_items_html=$PH->getLink('commentNew','',array('parent_task'=>$task->id)); $list->render_list($comments); } */ echo '<input type="hidden" name="prj" value="' . $file->project . '">'; echo '<input type="hidden" name="org_file" value="' . $file->id . '">'; /** * give parameter for create of new items (subtasks, efforts, etc) */ #echo '<input type="hidden" name="parent_task" value="'.$task->id.'">'; echo new PageContentClose(); echo new PageHtmlEnd(); }