Example #1
0
/**
* 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();
}
Example #2
0
/**
* 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();
}
Example #3
0
/**
* 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();
}