Esempio n. 1
0
/**
* 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();
}
Esempio n. 2
0
/**
* 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();
}
Esempio n. 3
0
/**
* Link companies to person @ingroup pages
*/
function personLinkCompanies()
{
    global $PH;
    $id = getOnePassedId('person', 'people_*');
    # WARNS if multiple; ABORTS if no id found
    $person = Person::getEditableById($id);
    if (!$person) {
        $PH->abortWarning("ERROR: could not get Person");
        return;
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'company_name'));
    $page->cur_tab = 'people';
    $page->type = __("Edit Person");
    $page->title = sprintf(__("Edit %s"), $person->name);
    $page->title_minor = __("Add related companies");
    $page->crumbs = build_person_crumbs($person);
    $page->options[] = new NaviOption(array('target_id' => 'personLinkCompanies'));
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'pages/company.inc.php';
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $companies = Company::getAll();
    $list = new ListBlock_companies();
    $list->show_functions = false;
    $list->show_icons = false;
    $list->render_list($companies);
    $PH->go_submit = 'personLinkCompaniesSubmit';
    echo "<input type=hidden name='person' value='{$person->id}'>";
    echo "<input class=button2 type=submit>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Esempio n. 4
0
/**
* Register a new Person @ingroup pages
*
*/
function personRegister($person = NULL)
{
    global $PH;
    global $auth;
    if (!confGet('REGISTER_NEW_USERS')) {
        $PH->abortWarning(__("Registering is not enabled"));
    }
    $person = new Person(array('id' => 0, 'description' => __('Because we are afraid of spam bots, please provide some information about you and why you want to register.') . __('The staff will then review your request and approve your account as soon as possible.')));
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'person_name'));
    $page->cur_tab = 'people';
    $page->type = __('Edit Person', 'Page type');
    $page->title = __("Register as a new user");
    $page->title_minor = '';
    $page->crumbs = build_person_crumbs($person);
    $page->options = array(new NaviOption(array('target_id' => 'personEdit')));
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    global $g_pcategory_names;
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($person->fields['name']->getFormElement($person));
    $f = $person->fields['office_email']->getFormElement($person);
    $f->required = true;
    $form->add($f);
    $fnick = $person->fields['nickname']->getFormElement($person);
    $fnick->required = true;
    $form->add($fnick);
    ### show password-fields if can_login ###
    /**
     * since the password as stored as md5-hash, we can initiate current password,
     * but have have to make sure the it is not changed on submit
     */
    $fpw1 = new Form_password('person_password1', __('Password', 'form label'), "", $person->fields['password']->tooltip);
    $fpw1->required = true;
    $form->add($fpw1);
    $fpw2 = new Form_password('person_password2', __('confirm Password', 'form label'), "", $person->fields['password']->tooltip);
    $fpw2->required = true;
    $form->add($fpw2);
    ### dropdown menu for person category ###
    if ($p = get('perscat')) {
        $perscat = $p;
    } else {
        $perscat = $person->category;
    }
    $form->add(new Form_Dropdown('pcategory', __('Category', 'form label'), array_flip($g_pcategory_names), $perscat));
    $a = array(sprintf(__('daily'), 1) => 1, sprintf(__('each 3 days'), 3) => 3, sprintf(__('each 7 days'), 7) => 7, sprintf(__('each 14 days'), 14) => 14, sprintf(__('each 30 days'), 30) => 30, __('Never') => 0);
    $p = $person->notification_period;
    if (!$person->settings & USER_SETTING_NOTIFICATIONS) {
        $p = 0;
    }
    $form->add(new Form_Dropdown('person_notification_period', __("Send notifications", "form label"), $a, $p));
    #$form->add(new Form_checkbox("person_html_mail",__('Send mail as html','form label'),$person->settings & USER_SETTING_HTML_MAIL));
    global $g_theme_names;
    if (count($g_theme_names) > 1) {
        $form->add(new Form_Dropdown('person_theme', __("Theme", "form label"), array_flip($g_theme_names), $person->theme));
    }
    global $g_languages;
    $form->add(new Form_Dropdown('person_language', __("Language", "form label"), array_flip($g_languages), $person->language));
    global $g_time_zones;
    $form->add(new Form_Dropdown('person_time_zone', __("Time zone", "form label"), $g_time_zones, $person->time_zone));
    $form->add($person->fields['description']->getFormElement($person));
    $form->addCaptcha();
    echo $form;
    $PH->go_submit = 'personRegisterSubmit';
    ### pass company-id? ###
    if ($c = get('company')) {
        echo "<input type=hidden name='company' value='{$c}'>";
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}