/** * Remove items of certain type and autho * * This method can be used to remove spam comments or attachments * * 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 itemsRemoveMany() { global $PH; global $auth; $PH->go_submit = 'itemsRemoveManyPreview'; $page = new Page(); $page->cur_tab = 'home'; $page->title = __('Remove many items'); $page->title_minor = ''; echo new PageHeader(); echo new PageContentOpen(); require_once confGet('DIR_STREBER') . "render/render_form.inc.php"; $form = new PageForm(); $form->button_cancel = true; ### author $people = array(0 => 'anybody'); foreach (Person::getPeople() as $p) { $people[$p->id] = $p->nickname; } $form->add(new Form_Dropdown('person', __("Created by"), array_flip($people), 0)); $form->add(new Form_Checkbox('type_comment', __("Comments"), true)); $form->add(new Form_Checkbox('only_spam_comments', __("Only comments that look like spam"), true)); $form->add(new Form_Checkbox('type_task', __("Tasks"), false)); $form->add(new Form_Checkbox('type_topic', __("Topic"), false)); $form->add(new Form_DateTime('time_start', __('starting at', 'label for time filter'), getGMTString(time() - 7 * 24 * 60 * 60))); $form->add(new Form_DateTime('time_end', __('ending at', 'label for time filter'), getGMTString(time() + 60 * 60))); echo $form; echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * go through all accounts and collect information * * returns array of count of... [$num_notification_sent, $num_warnings] */ public static function sendNotifications() { global $PH; $people = Person::getPeople(array('visible_only' => false, 'can_login' => true)); $num_notifications_sent = 0; $num_warnings = 0; foreach ($people as $p) { if ($p->settings & USER_SETTING_NOTIFICATIONS) { if ($p->office_email || $p->personal_email) { $now = time(); $last = strToGMTime($p->notification_last); $period = $p->notification_period * 60 * 60 * 24; if (strToGMTime($p->notification_last) + $period < time() || $period == -1) { $email = new EmailNotification($p); if ($email->information_count) { $result = $email->send(); if ($result === true) { ### reset activation-flag ### $p->settings &= USER_SETTING_SEND_ACTIVATION ^ RIGHT_ALL; $p->notification_last = gmdate("Y-m-d H:i:s"); $p->update(); $num_notifications_sent++; } else { if ($result !== false) { $num_warnings++; new FeedbackWarning(sprintf(__('Failure sending mail: %s'), $result)); } } } } } } } return array($num_notifications_sent, $num_warnings); }
static function renderLinkFromTargetName($target, $name) { measure_start("BlockLink::renderLinkFromTargetName"); global $PH; global $g_replace_list; global $g_wiki_project; $html = ""; /** * start with looking for tasks... */ $decoded_name = strtr($target, array_flip(get_html_translation_table(HTML_SPECIALCHARS, ENT_QUOTES))); measure_start("BlockLink::renderLinkFromTargetName::getTasks"); if ($g_wiki_project) { $tasks = Task::getAll(array('name' => $decoded_name, 'project' => $g_wiki_project->id, 'status_max' => STATUS_CLOSED)); } else { $tasks = Task::getAll(array('name' => $decoded_name, 'status_max' => STATUS_CLOSED)); } measure_stop("BlockLink::renderLinkFromTargetName::getTasks"); if (count($tasks) == 1) { ### matches name ### if (!strcasecmp(asHtml($tasks[0]->name), $target)) { $style_isdone = $tasks[0]->status >= STATUS_COMPLETED ? 'isDone' : ''; if ($name) { $html = "<a class='item task {$style_isdone}' href='" . $PH->getUrl('taskView', array('tsk' => intval($tasks[0]->id))) . "'>" . asHtml($name) . "</a>"; global $g_replace_list; $g_replace_list[$target] = '#' . $tasks[0]->id . '|' . $name; } else { $html = "<a class='item task {$style_isdone}' href='" . $PH->getUrl('taskView', array('tsk' => intval($tasks[0]->id))) . "'>" . asHtml($tasks[0]->name) . "</a>"; global $g_replace_list; $g_replace_list[$target] = '#' . $tasks[0]->id . '|' . $tasks[0]->name; } } else { if (!strcasecmp($tasks[0]->short, $target)) { $style_isdone = $tasks[0]->status >= STATUS_COMPLETED ? 'isDone' : ''; if ($name) { $html = "<a class='item task {$style_isdone}' href='" . $PH->getUrl('taskView', array('tsk' => intval($tasks[0]->id))) . "'>" . asHtml($name) . "</a>"; global $g_replace_list; $g_replace_list[$target] = '#' . $tasks[0]->id . '|' . $name; } else { $html = "<a class='item task {$style_isdone}' href='" . $PH->getUrl('taskView', array('tsk' => intval($tasks[0]->id))) . "'>" . asHtml($tasks[0]->name) . "</a>"; global $g_replace_list; $g_replace_list[$target] = '#' . $tasks[0]->id . '|' . $tasks[0]->short; } } else { $title = __('No task matches this name exactly'); $title2 = __('This task seems to be related'); $html = "<span title='{$title}' class=not_found>{$name}</span>" . "<a href='" . $PH->getUrl('taskView', array('tsk' => intval($tasks[0]->id))) . "' title='{$title2}'>?</a>"; } } } else { if (count($tasks) > 1) { measure_start("BlockLink::renderLinkFromTargetName::iterateSeveralTasks"); $matches = array(); $best = -1; $best_rate = 0; foreach ($tasks as $t) { if (!strcasecmp($t->name, $target) && $g_wiki_project && $t->project == $g_wiki_project->id) { $matches[] = $t; } else { if (!strcasecmp($t->short, $target)) { $matches[] = $t; } } } if (count($matches) == 1) { $html = "<a href='" . $PH->getUrl('taskView', array('tsk' => intval($matches[0]->id))) . "'>" . $matches[0]->name . "</a>"; } else { if (count($matches) > 1) { $title = __('No item excactly matches this name.'); $title2 = sprintf(__('List %s related tasks'), count($tasks)); $html = "<a class=not_found title= '{$title2}' href='" . $PH->getUrl('search', array('search_query' => $target)) . "'> " . $target . " (" . count($matches) . ' ' . __('identical') . ")</a>"; } else { if ($g_wiki_project) { $title = __('No item matches this name. Create new task with this name?'); $url = $PH->getUrl('taskNew', asHtml($target), array('prj' => $g_wiki_project->id)); $html = "<a href='{$url}' title='{$title}' class=not_found>{$target}</a>"; } else { $title = __('No item matches this name...'); $html = "<span title='{$title}' class=not_found>{$target}</span>"; } } } measure_stop("BlockLink::renderLinkFromTargetName::iterateSeveralTasks"); } else { if (0 == count($tasks)) { measure_start("BlockLink::renderLinkFromTargetName::notATaskItem"); /** * now check for team-members... */ if ($g_wiki_project) { $people = Person::getPeople(array('project' => $g_wiki_project->id, 'search' => $target)); if (count($people) == 1) { return "<a class='item person' title= '" . asHtml($people[0]->name) . "' href='" . $PH->getUrl('personView', array('person' => $people[0]->id)) . "'>" . asHtml($target) . "</a>"; } measure_stop("BlockLink::renderLinkFromTargetName::getPeople"); } /** * Link to create new task or topic */ if ($g_wiki_project) { $title = __('No item matches this name. Create new task with this name?'); global $g_wiki_task; if (isset($g_wiki_task) && $g_wiki_task->type == ITEM_TASK) { if ($g_wiki_task->category == TCATEGORY_FOLDER) { $parent_task = $g_wiki_task->id; } else { $parent_task = $g_wiki_task->parent_task; } } else { $parent_task = 0; } $url = $PH->getUrl('taskNew', array('prj' => $g_wiki_project->id, 'new_name' => urlencode($target), 'parent_task' => $parent_task)); $html = "<a href='{$url}' title='{$title}' class=not_found>{$target}</a>"; } else { $title = __('No item matches this name'); $html = "<span title='{$title}' class=not_found>{$target}</span>"; trigger_error('g_wiki_project was not defined. Could not provide create-link.', E_USER_NOTICE); } measure_stop("BlockLink::renderLinkFromTargetName::notATaskItem"); } } } measure_stop("BlockLink::renderLinkFromTargetName"); return $html; }
/** * Edit note on person * * @ingroup pages */ function taskNoteOnPersonEdit($task = NULL, $person = NULL) { global $PH; global $auth; global $g_pub_level_names; global $g_prio_names; if (!$task) { $id = getOnePassedId('tsk'); if (!($task = Task::getEditableById($id))) { $PH->abortWarning(__("Select a note to edit"), ERROR_NOTE); return; } } ## get person ## if (!$person) { $pid = getOnePassedId('person'); if (!($person = Person::getById($pid))) { $PH->abortWarning(__("ERROR: could not get Person"), ERROR_NOTE); return; } } $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'task_name')); $page->cur_tab = 'people'; if ($person->id) { $page->crumbs = build_person_crumbs($person); } $page->crumbs[] = new NaviCrumb(array('target_id' => 'taskNoteOnPersonEdit')); $page->type = __("Note"); if (!$task->id) { $page->title = __('Create new note'); $page->title_minor = __('Edit'); ## default title ## $date = gmdate("Y-m-d", time()); $time = getGMTString(); $dt = $date . " " . renderTime($time); $task->name = sprintf(__("New Note on %s, %s"), $person->name, $dt); } ## eventually needed later when note is a subcategory of task /*else { $page->title=$task->name; $page->title_minor=$task->short; }*/ echo new PageHeader(); echo new PageContentOpen(); require_once confGet('DIR_STREBER') . 'render/render_form.inc.php'; $form = new PageForm(); $form->button_cancel = true; ## name field ## $form->add($task->fields['name']->getFormElement($task)); ## description field ## $e = $task->fields['description']->getFormElement($task); $e->rows = 22; $form->add($e); ### public-level drop down menu ### $form->add(new Form_Dropdown('task_pub_level', __("Publish to", "Form label"), array_flip($g_pub_level_names), $task->pub_level)); ## priority drop down menu## $form->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio)); if ($task->id == 0) { $proj_select = 0; } $p_list = array(); $count = 1; $p_projects = $person->getProjects(); $num = count($p_projects); if ($num > 0) { $p_list[0] = __('Assigned Projects'); foreach ($p_projects as $pp) { $p_list[$pp->id] = "- " . $pp->name; $count++; } } $p_companies = $person->getCompanies(); $num = count($p_companies); if ($num > 0) { $p_list['-1'] = __('Company Projects'); foreach ($p_companies as $pcs) { $c_id = $pcs->id; $c_projects = Project::getAll(array('company' => $c_id)); $count2 = 0; foreach ($c_projects as $cp) { $p_list[$cp->id] = "- " . $cp->name; } } } if (!($projects = Project::getAll(array('order_by' => 'name ASC')))) { } else { $p_list['-2'] = __('All other Projects'); foreach ($projects as $pj) { $p_list[$pj->id] = "- " . $pj->name; } } $form->add(new Form_Dropdown('project', __('For Project', 'form label'), array_flip($p_list), $proj_select, "id='proj_list'")); ## new project ## if ($task->id == 0) { $form->add(new Form_checkbox('new_project', __('New project', 'form label'), false, "id='proj_new_checkbox'")); $form->add(new Form_Input('new_project_name', __('Project name', 'form label'), false, NULL, false, "id='proj_new_input'", "style='display:none'")); } $checked1 = ""; $checked2 = ""; if ($task->id == 0) { $checked1 = "checked"; $checked2 = "checked"; $person_select = -1; } ## eventually needed later when note is a subcategory of task /*else { if(!$pperson = $task->getAssignedPeople()){ $PH->abortWarning(__("ERROR: could not get assigned people"), ERROR_NOTE); } else{ foreach($pperson as $pp){ if($pp->id == $person->id){ $checked1= "checked"; } elseif($pp->id == $auth->cur_user->id){ $checked2= "checked"; } else{ $person_select = $pp->id; } } } }*/ $form->add(new Form_customHTML('<p><label>' . __('Assign to') . '</lable></p>', 'assigne_note')); if ($person->id != $auth->cur_user->id) { $form->add(new Form_customHTML('<span class="checker"><input value="' . $person->id . '" name="task_assignement1" type="checkbox" ' . $checked1 . '><label for="task_assignement1">' . $person->name . '</label></span>', 'assigned_person1')); $form->add(new Form_customHTML('<span class="checker"><input value="' . $auth->cur_user->id . '" name="task_assignement2" type="checkbox" ' . $checked2 . '><label for="task_assignement2">' . $auth->cur_user->name . '</label></span>', 'assigned_person2')); } else { $form->add(new Form_customHTML('<span class="checker"><input value="' . $auth->cur_user->id . '" name="task_assignement2" type="checkbox" ' . $checked2 . '><label for="task_assignement2">' . $auth->cur_user->name . '</label></span>', 'assigned_person')); } $pers_list = array(); $pers_list[-1] = __('undefined'); if ($people = Person::getPeople(array('can_login' => 1))) { foreach ($people as $pers) { if ($auth->cur_user->name != $pers->name) { $pers_list[$pers->id] = $pers->name; } } } $form->add(new Form_Dropdown('task_also_assign', __('Also assign to'), array_flip($pers_list), $person_select)); ## Book effort after submit ## $form->form_options[] = "<span class=option><input id='book_effort' name='book_effort' class='checker' type=checkbox>" . __("Book effort after submit") . "</span>"; $form->add(new Form_HiddenField('tsk', '', $task->id)); $form->add(new Form_HiddenField('person_id', '', $person->id)); $form->add(new Form_HiddenField('creation_time', '', $time)); echo $form; $PH->go_submit = 'taskNoteOnPersonEditSubmit'; echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * TB 2006-07-03 tsk: 1220 * print a complete list as html * - use filters * - use check list style (tree, list, grouped) * - check customization-values * - check sorting * - get objects from database * */ public function print_automatic() { global $PH; #if(!$this->active_block_function=$this->getBlockStyleFromCookie()) { $this->active_block_function = 'list'; #} $this->group_by = get("blockstyle_{$PH->cur_page->id}_{$this->id}_grouping"); $s_cookie = "sort_{$PH->cur_page->id}_{$this->id}_{$this->active_block_function}"; if ($sort = get($s_cookie)) { $this->query_options['order_by'] = $sort; } ### grouped view ### if ($this->active_block_function == 'grouped') { /** * @@@ later use only once... * * $this->columns= filterOptions($this->columns,"CURPAGE.BLOCKS[{$this->id}].STYLE[{$this->active_block_function}].COLUMNS"); */ if (isset($this->columns[$this->group_by])) { unset($this->columns[$this->group_by]); } ### prepend key to sorting ### if (isset($this->query_options['order_by'])) { $this->query_options['order_by'] = $this->groupings->getActiveFromCookie() . "," . $this->query_options['order_by']; } else { $this->query_options['order_by'] = $this->groupings->getActiveFromCookie(); } } else { $pass = true; } ### add filter options ### foreach ($this->filters as $f) { foreach ($f->getQuerryAttributes() as $k => $v) { $this->query_options[$k] = $v; } } $people = Person::getPeople($this->query_options); $this->render_list($people); }
<?php require_once dirname(__FILE__) . '/Person1.php'; $ivan = new Person('Иван', 25); $maria = new Person('Мария', 33); $ivan->greet(); $maria->greet(); echo $ivan->getAge(); echo "<br>"; echo Person::getPeople();
/** * select new people from a list @ingroup pages * * userRights have been validated by pageHandler() * * \TODO add additional project-specific check here? */ function projAddPerson() { global $PH; $id = getOnePassedId('prj', ''); # WARNS if multiple; ABORTS if no id found if (!($project = Project::getEditableById($id))) { $PH->abortWarning("ERROR: could not get Project"); } $page = new Page(array('use_jscalendar' => false)); $page->cur_tab = 'projects'; $page->type = __("Edit Project"); $page->title = "{$project->name}"; $page->title_minor = __("Select new team members"); $page->crumbs = build_project_crumbs($project); $page->options[] = new NaviOption(array('target_id' => 'projAddPerson')); echo new PageHeader(); echo new PageContentOpen(); require_once confGet('DIR_STREBER') . "pages/person.inc.php"; require_once confGet('DIR_STREBER') . "render/render_form.inc.php"; ### build hash of already added person ### $pps = $project->getProjectPeople(array('alive_only' => true, 'visible_only' => false)); $pp_hash = array(); foreach ($pps as $pp) { $pp_hash[$pp->person] = true; } ### filter already added people ### $people = array(); if ($pers = Person::getPeople()) { foreach ($pers as $p) { if (!isset($pp_hash[$p->id])) { $people[] = $p; } } } $list = new ListBlock_people(); unset($list->columns['personal_phone']); unset($list->columns['office_phone']); unset($list->columns['mobile_phone']); unset($list->columns['companies']); unset($list->columns['changes']); unset($list->columns['last_login']); $list->functions = array(); $list->no_items_html = __("Found no people to add. Go to `People` to create some."); $list->render_list($people); #@@@ probably add dropdown-list with new project-role here $PH->go_submit = 'projAddPersonSubmit'; echo "<input type=hidden name='project' value='{$project->id}'>"; echo "<div class=formbuttons>"; $name = __('Add'); echo "<input class=button type=submit value='{$name}'>"; echo "</div>"; echo new PageContentClose(); echo new PageHtmlEnd(); }
static function getForQuery($search_query, $project = NULL) { $count_overall = 0; $results = array(); global $PH; require_once confGet('DIR_STREBER') . "db/class_company.inc.php"; $args = array('order_str' => NULL, 'has_id' => NULL, 'search' => $search_query); foreach ($companies = Company::getAll($args) as $company) { $rate = RATE_TYPE_COMPANY; $rate *= SearchResult::RateItem($company); $rate *= SearchResult::RateTitle($company, $search_query); $results[] = new SearchResult(array('name' => $company->name, 'rating' => $rate, 'type' => __('Company'), 'jump_id' => 'companyView', 'jump_params' => array('company' => $company->id, 'q' => $search_query), 'item' => $company)); } require_once confGet('DIR_STREBER') . "db/class_person.inc.php"; foreach ($people = Person::getPeople(array('search' => $search_query)) as $person) { $rate = RATE_TYPE_PERSON; $rate *= SearchResult::RateItem($person); $rate *= SearchResult::RateTitle($person, $search_query); $results[] = new SearchResult(array('name' => $person->name, 'rating' => $rate, 'type' => __('Person'), 'jump_id' => 'personView', 'jump_params' => array('person' => $person->id, 'q' => $search_query), 'item' => $person)); } require_once confGet('DIR_STREBER') . "db/class_project.inc.php"; $projects = Project::getAll(array('status_min' => 0, 'status_max' => 10, 'search' => $search_query)); if ($projects) { foreach ($projects as $project) { $rate = RATE_TYPE_PROJECT; if ($project->status == STATUS_TEMPLATE) { $rate *= RATE_PROJECT_IS_TEMPLATE; } else { if ($project->status < STATUS_COMPLETED) { $rate *= RATE_PROJECT_IS_OPEN; } else { $rate *= RATE_PROJECT_IS_CLOSED; } } if ($diz = SearchResult::getExtract($project, $search_query)) { $rate *= RATE_IN_DETAILS; } ### status ### global $g_status_names; $status = isset($g_status_names[$project->status]) ? $g_status_names[$project->status] : ''; if ($project->status > STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_CLOSED; } else { if ($project->status >= STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_COMPLETED; } } ### for company ### $html_location = ''; if ($company = Company::getVisibleById($project->company)) { $html_location = __('for') . ' ' . $company->getLink(); } $rate *= SearchResult::RateItem($project); $rate *= SearchResult::RateTitle($project, $search_query); $results[] = new SearchResult(array('name' => $project->name, 'rating' => $rate, 'item' => $project, 'type' => __('Project'), 'jump_id' => 'projView', 'jump_params' => array('prj' => $project->id, 'q' => $search_query), 'extract' => $diz, 'status' => $status, 'html_location' => $html_location)); } } require_once confGet('DIR_STREBER') . "db/class_task.inc.php"; $order_str = get('sort_' . $PH->cur_page->id . "_tasks"); $tasks = Task::getAll(array('order_by' => $order_str, 'search' => $search_query, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED)); if ($tasks) { foreach ($tasks as $task) { $rate = RATE_TYPE_TASK; $rate *= SearchResult::RateItem($task); $rate *= SearchResult::RateTitle($task, $search_query); if ($task->category == TCATEGORY_FOLDER) { $rate *= RATE_TASK_IS_FOLDER; } if ($diz = SearchResult::getExtract($task, $search_query)) { $rate *= RATE_IN_DETAILS; } global $g_status_names; $status = isset($g_status_names[$task->status]) ? $g_status_names[$task->status] : ''; if ($task->status > STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_CLOSED; } else { if ($task->status >= STATUS_COMPLETED) { $rate *= RATE_TASK_STATUS_COMPLETED; } } if ($project = Project::getVisibleById($task->project)) { $prj = $project->getLink(); } else { $prj = ''; } $html_location = __('in') . " <b>{$prj}</b> > " . $task->getFolderLinks(); $is_done = $task->status < STATUS_COMPLETED ? false : true; $results[] = new SearchResult(array('name' => $task->name, 'rating' => $rate, 'extract' => $diz, 'item' => $task, 'type' => $task->getLabel(), 'status' => $status, 'html_location' => $html_location, 'is_done' => $is_done, 'jump_id' => 'taskView', 'jump_params' => array('tsk' => $task->id, 'q' => $search_query))); } } require_once confGet('DIR_STREBER') . "db/class_comment.inc.php"; $comments = Comment::getAll(array('search' => $search_query)); if ($comments) { foreach ($comments as $comment) { $rate = RATE_TYPE_COMMENT; $rate *= SearchResult::RateItem($comment); $rate *= SearchResult::RateTitle($comment, $search_query); if ($diz = SearchResult::getExtract($comment, $search_query)) { $rate *= RATE_IN_DETAILS; } if ($project = Project::getVisibleById($comment->project)) { $prj = $project->getLink(); } else { $prj = ''; } $html_location = __('on') . " <b>{$prj}</b>"; $is_done = false; if ($task = Task::getVisibleById($comment->task)) { if ($folders = $task->getFolderLinks()) { $html_location .= ' > ' . $folders; } $html_location .= ' > ' . $task->getLink(false); if ($task->status >= STATUS_COMPLETED) { $is_done = true; } } else { $html_location = ''; } $results[] = new SearchResult(array('name' => $comment->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Comment'), 'html_location' => $html_location, 'jump_id' => 'commentView', 'jump_params' => array('comment' => $comment->id, 'q' => $search_query), 'item' => $comment, 'is_done' => $is_done)); } } $count_overall += count($comments); require_once confGet('DIR_STREBER') . "db/class_effort.inc.php"; $efforts = Effort::getAll(array('search' => $search_query)); if ($efforts) { foreach ($efforts as $effort) { $rate = RATE_TYPE_EFFORT; $rate *= SearchResult::RateItem($effort); $rate *= SearchResult::RateTitle($effort, $search_query); if ($diz = SearchResult::getExtract($effort, $search_query)) { $rate *= RATE_IN_DETAILS; } if ($project = Project::getVisibleById($effort->project)) { $prj = $project->getLink(); } else { $prj = ''; } $html_location = __('on') . " <b>{$prj}</b>"; $is_done = false; if ($task = Task::getVisibleById($effort->task)) { if ($folders = $task->getFolderLinks()) { $html_location .= ' > ' . $folders; } $html_location .= ' > ' . $task->getLink(false); if ($task->status >= STATUS_COMPLETED) { $is_done = true; } } else { $html_location = ''; } $results[] = new SearchResult(array('name' => $effort->name, 'rating' => $rate, 'extract' => $diz, 'type' => __('Effort'), 'html_location' => $html_location, 'jump_id' => 'effortView', 'jump_params' => array('effort' => $effort->id, 'q' => $search_query), 'item' => $effort, 'is_done' => $is_done)); } } $count_overall += count($efforts); return $results; }
/** * Link People to company * * @ingroup pages */ function companyLinkPeople() { global $PH; $id = getOnePassedId('company', 'companies_*'); # WARNS if multiple; ABORTS if no id found $company = Company::getEditableById($id); if (!$company) { $PH->abortWarning("ERROR: could not get Company"); return; } $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'company_name')); $page->cur_tab = 'companies'; $page->type = __("Edit Company"); $page->title = sprintf(__("Edit %s"), $company->name); $page->title_minor = __("Add people employed or related"); $page->crumbs = build_company_crumbs($company); $page->options[] = new NaviOption(array('target_id' => 'companyLinkPeople')); echo new PageHeader(); echo new PageContentOpen(); require_once confGet('DIR_STREBER') . 'pages/person.inc.php'; require_once confGet('DIR_STREBER') . 'render/render_form.inc.php'; $people = Person::getPeople(); $list = new ListBlock_people(); $list->show_functions = false; $list->show_icons = false; $list->render_list($people); $PH->go_submit = 'companyLinkPeopleSubmit'; echo "<input type=hidden name='company' value='{$company->id}'>"; echo "<input class=button2 type=submit>"; 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(); }
/** * query if editable for current user */ static function getEditableById($id, $use_cache = false) { if (!is_int($id) && !is_string($id)) { trigger_error('Person::getVisibleById() requires int-paramter', E_USER_WARNING); return NULL; } $id = intval($id); global $auth; if ($auth->cur_user->id == $id && $auth->cur_user->user_rights & RIGHT_PERSON_EDIT_SELF || $auth->cur_user->user_rights & RIGHT_PERSON_EDIT) { $people = Person::getPeople(array('id' => $id)); if (count($people) == 1) { if ($people[0]->id) { return $people[0]; } } } return NULL; }