/** * personList active @ingroup pages */ function personList() { global $PH; global $auth; if (!($auth->cur_user->user_rights & RIGHT_PERSON_EDIT) && confGet('ANONYMOUS_USER') != false) { ### set up page and write header #### $page = new Page(); $page->type = __("List"); $page->cur_tab = 'people'; $page->title = __('List of people'); echo new PageHeader(); echo new PageContentOpen(); echo "<div class=license>"; echo wiki2purehtml("\r\nYou have insufficent user rights to see complete list.\r\n"); echo "</div>"; echo new PageContentClose(); echo new PageHtmlEnd(); exit; } $presets = array('all_people' => array('name' => __('all'), 'filters' => array('person_category' => array('id' => 'person_category', 'visible' => true, 'active' => true, 'min' => PCATEGORY_UNDEFINED, 'max' => PCATEGORY_PARTNER)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'tree'))), 'people_without_account' => array('name' => __('without account'), 'filters' => array('can_login' => array('id' => 'can_login', 'value' => '0', 'visible' => true, 'active' => true)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'people_with_account' => array('name' => __('with account'), 'filters' => array('can_login' => array('id' => 'can_login', 'value' => '1', 'visible' => true, 'active' => true)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'person_employee' => array('name' => __('employees'), 'filters' => array('person_category' => array('id' => 'person_category', 'visible' => false, 'active' => true, 'min' => PCATEGORY_STAFF, 'max' => PCATEGORY_EXEMPLOYEE)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'person_contact' => array('name' => __('contact people'), 'filters' => array('person_category' => array('id' => 'person_category', 'visible' => true, 'active' => true, 'min' => PCATEGORY_CLIENT, 'max' => PCATEGORY_PARTNER)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'deleted_people' => array('name' => __('deleted'), 'filters' => array('person_is_alive' => array('id' => 'person_is_alive', 'value' => false, 'visible' => true, 'active' => true)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')))); ## set preset location ## $preset_location = 'personList'; $preset_id = 'people_with_account'; # default value if ($tmp_preset_id = get('preset')) { if (isset($presets[$tmp_preset_id])) { $preset_id = $tmp_preset_id; } ### set cookie setcookie('STREBER_personList_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0); } else { if ($tmp_preset_id = get('STREBER_personList_preset')) { if (isset($presets[$tmp_preset_id])) { $preset_id = $tmp_preset_id; } } } ### create from handle ### $PH->defineFromHandle(array('preset_id' => $preset_id)); $page = new Page(); $page->cur_tab = 'people'; $page->title = __('People', 'Pagetitle for person list'); if (!($auth->cur_user->user_rights & RIGHT_VIEWALL)) { $page->title_minor = sprintf(__("relating to %s", "Page title Person list title add on"), $auth->cur_user->name); } else { $page->title_minor = __("admin view", "Page title add on if admin"); } $page->type = __('List', 'page type'); $page->options = build_personList_options(); ### page functions ### $page->add_function(new PageFunction(array('target' => 'personNew', 'params' => array(), 'icon' => 'new', 'tooltip' => __('New person')))); ### render title ### echo new PageHeader(); echo new PageContentOpen(); if ($order_by = get('sort_' . $PH->cur_page->id . "_people_list")) { $order_by = str_replace(",", ", ", $order_by); } else { $order_by = 'name'; } $list = new ListBlock_people(); $list->title = $page->title; unset($list->columns['profile']); unset($list->columns['projects']); unset($list->columns['changes']); $list->filters[] = new ListFilter_people(); $preset = $presets[$preset_id]; foreach ($preset['filters'] as $f_name => $f_settings) { switch ($f_name) { case 'person_category': $list->filters[] = new ListFilter_person_category_min(array('value' => $f_settings['min'])); $list->filters[] = new ListFilter_person_category_max(array('value' => $f_settings['max'])); break; case 'can_login': $list->filters[] = new ListFilter_can_login(array('value' => $f_settings['value'])); break; case 'person_is_alive': $list->filters[] = new ListFilter_is_alive(array('value' => $f_settings['value'])); break; default: trigger_error("Unknown filter setting {$f_name}", E_USER_WARNING); break; } } $filter_empty_folders = isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'] ? true : NULL; if ($auth->cur_user->user_rights & RIGHT_PERSON_CREATE) { $list->no_items_html = $PH->getLink('personNew', ''); } else { $list->no_items_html = __("no related people"); } $page->print_presets(array('target' => $preset_location, 'project_id' => '', 'preset_id' => $preset_id, 'presets' => $presets, 'person_id' => '')); $list->query_options['order_by'] = $order_by; $list->print_automatic(); ## Link to start cvs export for priviledged users ## if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT || confGet('ANONYMOUS_USER') == false) { $format = get('format'); if ($format == FORMAT_HTML || $format == '') { echo $PH->getCSVLink(); } } echo new PageContentClose(); echo new PageHtmlEnd(); }
/** * save field value of an item which has been edited inplace * and return formatted html code. * * If only a chapter has been edited, number defined in "chapter" */ function itemSaveField() { header("Content-type: text/html; charset=utf-8"); ### disable page caching ### header("Expires: -1"); header("Cache-Control: post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); $value = get('value'); if (is_null($value)) { return; } if (!($item_id = get('item'))) { print "Failure"; return; } global $g_wiki_project; if (!($item = DbProjectItem::getEditableById($item_id))) { print "Failure"; return; } if (!($object = DbProjectItem::getObjectById($item_id))) { print "Failure"; return; } if ($item->type == ITEM_PROJECT) { if (!($project = Project::getVisibleById($item->id))) { print "Failure getting project"; return; } } else { if (!($project = Project::getVisibleById($item->project))) { print "Failure getting project"; return; } } $g_wiki_project = $project; $field_name = 'description'; if (get('field')) { $field_name = asCleanString(get('field')); } if (!isset($object->fields[$field_name])) { return NULL; } require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; $chapter = intVal(get('chapter')); ### replace complete field ### if (is_null($chapter)) { $object->{$field_name} = $value; } else { require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php'; /** * split originial wiki block into chapters * start with headline and belonging text */ $org = $object->{$field_name}; if ($object->type == ITEM_TASK) { global $g_wiki_task; $g_wiki_task = $object; } $parts = getWikiChapters($org); ### replace last line return (added by textarea) ### if (!preg_match("/\n\$/", $value)) { $value .= "\n"; } #$value= str_replace("\\'", "'", $value); #$value= str_replace('\\"', "\"", $value); $parts[$chapter] = $value; $new_wiki_text = implode('', $parts); $object->{$field_name} = $new_wiki_text; } ### update $object->update(array($field_name)); ### mark parent of comment as changes if ($item->type == ITEM_COMMENT) { if ($parent_task = Task::getById($object->task)) { print "calling now changed by user"; $parent_task->nowChangedByUser(); } } print wiki2purehtml($object->{$field_name}); $item->nowChangedByUser(); }