Пример #1
0
/**
* Edit a person  @ingroup pages
*/
function personEdit($person = NULL)
{
    global $PH;
    global $auth;
    ### new object not in database ###
    if (!$person) {
        $id = getOnePassedId('person', 'people_*');
        # WARNS if multiple; ABORTS if no id found
        if (!($person = Person::getEditableById($id))) {
            $PH->abortWarning("ERROR: could not get Person");
            return;
        }
    }
    ### validate rights ###
    if ($auth->cur_user->id == $person->id && $auth->cur_user->user_rights & RIGHT_PERSON_EDIT_SELF || $auth->cur_user->user_rights & RIGHT_PERSON_EDIT || $auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $person->id == 0) {
        $pass = true;
    } else {
        $PH->abortWarning(__("not allowed to edit"), ERROR_RIGHTS);
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'person_name'));
    $page->cur_tab = 'people';
    $page->type = __('Edit Person', 'Page type');
    $page->title = $person->name;
    $page->title_minor = '';
    $page->crumbs = build_person_crumbs($person);
    $page->options = array(new NaviOption(array('target_id' => 'personEdit')));
    echo new PageHeader();
    echo new PageContentOpen();
    ### form background ###
    $block = new PageBlock(array('id' => 'person_edit'));
    $block->render_blockStart();
    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));
    ### profile and login ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT_RIGHTS || $auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $auth->cur_user->user_rights & RIGHT_PROJECT_ASSIGN && $person->id == 0) {
        /**
         * if checkbox not rendered, submit might reset $person->can_login.
         * ...be sure the user_rights match
         */
        $form->add(new Form_checkbox("person_can_login", __('Person with account (can login)', 'form label'), $person->can_login));
    }
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab("account", __("Account")));
    $fnick = $person->fields['nickname']->getFormElement($person);
    if ($person->can_login) {
        $fnick->required = true;
    }
    $tab->add($fnick);
    $tab->add($person->fields['office_email']->getFormElement($person));
    ### 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'), "__dont_change__", $person->fields['password']->tooltip);
    if ($person->can_login) {
        $fpw1->required = true;
    }
    $tab->add($fpw1);
    $fpw2 = new Form_password('person_password2', __('confirm Password', 'form label'), "__dont_change__", $person->fields['password']->tooltip);
    if ($person->can_login) {
        $fpw2->required = true;
    }
    $tab->add($fpw2);
    ### authentication ###
    if (confGet('LDAP')) {
        $authentication = array('streber' => 0, 'ldap' => 1);
        $tab->add(new Form_Dropdown('person_auth', __("Authentication with", "form label"), $authentication, $person->ldap));
    }
    ### profile and login ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_EDIT_RIGHTS) {
        global $g_user_profile_names;
        global $g_user_profiles;
        ### display "undefined" profile if rights changed ###
        # will be skipped when submitting
        $profile_num = $person->profile;
        $reset = "";
        if (!($default_rights = $g_user_profiles[$profile_num]['default_user_rights'])) {
            trigger_error("undefined/invalid profile requested ({$profile_num})", E_USER_ERROR);
        }
        $list = $g_user_profile_names;
        if ($default_rights != $person->user_rights) {
            $profile_num = '-1';
            $list['-1'] = __('-- reset to...--');
        }
        $tab->add(new Form_Dropdown('person_profile', __("Profile", "form label"), array_flip($list), $profile_num));
    }
    $a = array(sprintf(__('ASAP'), -1) => -1, 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;
    }
    $tab->add(new Form_Dropdown('person_notification_period', __("Send notifications", "form label"), $a, $p));
    #$tab->add(new Form_checkbox("person_html_mail",__('Send mail as html','form label'),$person->settings & USER_SETTING_HTML_MAIL));
    if ($person->id == 0) {
        $prj_num = '-1';
        $prj_names = array();
        $prj_names['-1'] = __('- no -');
        ## get all projects ##
        if ($projects = Project::getAll()) {
            foreach ($projects as $p) {
                $prj_names[$p->id] = $p->name;
            }
            ## assigne new person to ptoject ##
            $tab->add(new Form_Dropdown('assigned_prj', __('Assigne to project', 'form label'), array_flip($prj_names), $prj_num));
        }
    }
    $tab_group->add($tab = new Page_Tab("details", __("Details")));
    ### category ###
    if ($p = get('perscat')) {
        $perscat = $p;
    } else {
        $perscat = $person->category;
    }
    $tab->add(new Form_Dropdown('pcategory', __('Category', 'form label'), array_flip($g_pcategory_names), $perscat));
    $tab->add($person->fields['mobile_phone']->getFormElement($person));
    $tab->add($person->fields['office_phone']->getFormElement($person));
    $tab->add($person->fields['office_fax']->getFormElement($person));
    $tab->add($person->fields['office_street']->getFormElement($person));
    $tab->add($person->fields['office_zipcode']->getFormElement($person));
    $tab->add($person->fields['office_homepage']->getFormElement($person));
    $tab->add($person->fields['personal_email']->getFormElement($person));
    $tab->add($person->fields['personal_phone']->getFormElement($person));
    $tab->add($person->fields['personal_fax']->getFormElement($person));
    $tab->add($person->fields['personal_street']->getFormElement($person));
    $tab->add($person->fields['personal_zipcode']->getFormElement($person));
    $tab->add($person->fields['personal_homepage']->getFormElement($person));
    $tab->add($person->fields['birthdate']->getFormElement($person));
    $tab_group->add($tab = new Page_Tab("description", __("Description")));
    $e = $person->fields['description']->getFormElement($person);
    $e->rows = 20;
    $tab->add($e);
    $tab_group->add($tab = new Page_Tab("options", __("Options")));
    $tab->add(new Form_checkbox("person_enable_efforts", __('Enable efforts'), $person->settings & USER_SETTING_ENABLE_EFFORTS));
    $tab->add(new Form_checkbox("person_enable_bookmarks", __('Enable bookmarks'), $person->settings & USER_SETTING_ENABLE_BOOKMARKS));
    global $g_theme_names;
    if (count($g_theme_names) > 1) {
        $tab->add(new Form_Dropdown('person_theme', __("Theme", "form label"), array_flip($g_theme_names), $person->theme));
    }
    global $g_languages;
    $tab->add(new Form_Dropdown('person_language', __("Language", "form label"), array_flip($g_languages), $person->language));
    global $g_time_zones;
    $tab->add(new Form_Dropdown('person_time_zone', __("Time zone", "form label"), $g_time_zones, $person->time_zone));
    ### effort-style ###
    $effort_styles = array(__("start times and end times") => 1, __("duration") => 2);
    $effort_style = $person->settings & USER_SETTING_EFFORTS_AS_DURATION ? 2 : 1;
    $tab->add(new Form_Dropdown('person_effort_style', __("Log Efforts as"), $effort_styles, $effort_style));
    $tab->add(new Form_checkbox("person_filter_own_changes", __('Filter own changes from recent changes list'), $person->settings & USER_SETTING_FILTER_OWN_CHANGES));
    if (confGet('INTERNAL_COST_FEATURE') && $auth->cur_user->user_rights & RIGHT_VIEWALL && $auth->cur_user->user_rights & RIGHT_EDITALL) {
        $tab_group->add($tab = new Page_Tab("internal", __("Internal")));
        $tab->add($person->fields['salary_per_hour']->getFormElement($person));
    }
    ### temp uid for account activation ###
    if ($tuid = get('tuid')) {
        $form->add(new Form_Hiddenfield('tuid', '', $tuid));
    }
    ### create another person ###
    if ($auth->cur_user->user_rights & RIGHT_PERSON_CREATE && $person->id == 0) {
        #$form->add(new Form_checkbox("create_another","",));
        $checked = get('create_another') ? 'checked' : '';
        $form->form_options[] = "<span class=option><input id='create_another' name='create_another' class='checker' type=checkbox {$checked}><label for='create_another'>" . __("Create another person after submit") . "</label></span>";
    }
    #echo "<input type=hidden name='person' value='$person->id'>";
    $form->add(new Form_HiddenField('person', '', $person->id));
    echo $form;
    $PH->go_submit = 'personEditSubmit';
    ### pass company-id? ###
    if ($c = get('company')) {
        echo "<input type=hidden name='company' value='{$c}'>";
    }
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Пример #2
0
/**
* Edit a task
*
* @ingroup pages
*/
function taskEdit($task = NULL)
{
    global $PH;
    ### object or from database? ###
    if (!$task) {
        $ids = getPassedIds('tsk', 'tasks_*');
        if (!$ids) {
            $PH->abortWarning(__("Select some task(s) to edit"), ERROR_NOTE);
            return;
        } else {
            if (count($ids) > 1) {
                $PH->show('taskEditMultiple');
                exit;
            } else {
                if (!($task = Task::getEditableById($ids[0]))) {
                    $PH->abortWarning(__("You do not have enough rights to edit this task"), ERROR_RIGHTS);
                }
            }
        }
    }
    ### get parent project ####
    if (!($project = Project::getVisibleById($task->project))) {
        $PH->abortWarning("FATAL error! parent project not found");
    }
    ### abort, if not enough rights ###
    $project->validateEditItem($task);
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'task_name'));
    initPageForTask($page, $task, $project);
    if ($task->id) {
        $page->title = $task->name;
        $page->title_minor = $task->short;
    } else {
        if ($task->category == TCATEGORY_MILESTONE) {
            $page->title = __("New milestone");
        } else {
            if ($task->category == TCATEGORY_VERSION) {
                $page->title = __("New version");
            } else {
                if ($task->category == TCATEGORY_DOCU) {
                    $page->title = __("New topic");
                } else {
                    if ($task->category == TCATEGORY_FOLDER) {
                        $page->title = __("New folder");
                    } else {
                        $page->title = __("New task");
                        if ($task->parent_task && ($parent_task = Task::getVisibleById($task->parent_task))) {
                            $page->title_minor = sprintf(__('for %s', 'e.g. new task for something'), $parent_task->name);
                        } else {
                            $page->title_minor = sprintf(__('for %s', 'e.g. new task for something'), $project->name);
                        }
                    }
                }
            }
        }
    }
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    global $auth;
    global $REPRODUCIBILITY_VALUES;
    global $g_prio_names;
    global $g_status_names;
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($task->fields['name']->getFormElement($task));
    $list = array();
    if ($task->category == TCATEGORY_MILESTONE || $task->category == TCATEGORY_VERSION) {
        $list = array(TCATEGORY_MILESTONE, TCATEGORY_VERSION);
        ### make sure it's valid
        if ($task->category != TCATEGORY_MILESTONE || $task->category != TCATEGORY_VERSION) {
            if ($task->is_released > RELEASED_UPCOMMING) {
                $task->category = TCATEGORY_VERSION;
            } else {
                $task->category = TCATEGORY_MILESTONE;
            }
        }
    } else {
        $list = array();
        if ($project->settings & PROJECT_SETTING_ENABLE_TASKS) {
            $list[] = TCATEGORY_TASK;
        }
        if ($project->settings & PROJECT_SETTING_ENABLE_BUGS) {
            $list[] = TCATEGORY_BUG;
        }
        $list[] = TCATEGORY_DOCU;
        $list[] = TCATEGORY_FOLDER;
    }
    global $g_tcategory_names;
    $cats = array();
    foreach ($list as $c) {
        $cats[$c] = $g_tcategory_names[$c];
    }
    $form->add(new Form_Dropdown('task_category', __("Display as"), array_flip($cats), $task->category));
    ### warning if folder with subtasks ###
    if ($task->id && $task->category == TCATEGORY_FOLDER && ($num_subtasks = count($task->getSubtasks()))) {
        $form->add(new Form_CustomHtml('<p><label></label>' . sprintf(__("This folder has %s subtasks. Changing category will ungroup them."), $num_subtasks) . '</p>'));
    }
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab('task', __("Task")));
    ### normaltasks and folders ##
    if (!$task->isMilestoneOrVersion()) {
        if ($project->settings & PROJECT_SETTING_ENABLE_MILESTONES) {
            $tab->add(new Form_DropdownGrouped('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
        }
        ### prio ###
        if ($task->category != TCATEGORY_MILESTONE && $task->category != TCATEGORY_VERSION) {
            $tab->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio));
        }
    }
    ### for existing tasks, get already assigned
    if ($task->id) {
        $assigned_people = $task->getAssignedPeople();
        #$task_assignments = $task->getAssignments();
    } else {
        ### check new assigments ###
        $count = 0;
        while ($id_new = get('task_assign_to_' . $count)) {
            $count++;
            ### check if already assigned ###
            if ($p = Person::getVisibleById($id_new)) {
                $assigned_people[] = $p;
            }
        }
        if (!$count) {
            $parents = $task->getFolder();
            if ($parents) {
                $parents = array_reverse($parents);
                foreach ($parents as $p) {
                    if ($ap = $p->getAssignedPeople()) {
                        $assigned_people = $ap;
                        break;
                    }
                }
            }
        }
    }
    $team = array(__('- select person -') => 0);
    ### create team-list ###
    foreach ($project->getPeople() as $p) {
        $team[$p->name] = $p->id;
    }
    ### create drop-down-lists ###
    $count_new = 0;
    $count_all = 0;
    if (isset($assigned_people)) {
        foreach ($assigned_people as $ap) {
            if (!($p = Person::getVisibleById($ap->id))) {
                continue;
                # skip if invalid person
            }
            if ($task->id) {
                $tab->add(new Form_Dropdown('task_assigned_to_' . $ap->id, __("Assigned to"), $team, $ap->id));
            } else {
                $tab->add(new Form_Dropdown('task_assign_to_' . $count_new, __("Assign to"), $team, $ap->id));
                $count_new++;
            }
            $count_all++;
            unset($team[$ap->name]);
        }
    }
    ### add empty drop-downlist for new assignments ###
    $str_label = $count_all == 0 ? __("Assign to", "Form label") : __("Also assign to", "Form label");
    $tab->add(new Form_Dropdown("task_assign_to_{$count_new}", $str_label, $team, 0));
    ### completion ###
    if (!$task->is_released > RELEASED_UPCOMMING) {
        #$form->add($task->fields['estimated'    ]->getFormElement($task));
        $ar = array(__('undefined') => -1, '0%' => 0, '10%' => 10, '20%' => 20, '30%' => 30, '40%' => 40, '50%' => 50, '60%' => 60, '70%' => 70, '80%' => 80, '90%' => 90, '95%' => 95, '98%' => 98, '99%' => 99, '100%' => 100);
        $tab->add(new Form_Dropdown('task_completion', __("Completed"), $ar, $task->completion));
    }
    $st = array();
    foreach ($g_status_names as $s => $n) {
        if ($s >= STATUS_NEW) {
            $st[$s] = $n;
        }
    }
    if ($task->isMilestoneOrVersion()) {
        unset($st[STATUS_NEW]);
    }
    $field_status = new Form_Dropdown('task_status', "Status", array_flip($st), $task->status);
    if ($task->fields['status']->invalid) {
        $field_status->invalid = true;
    }
    $tab->add($field_status);
    if (!$task->isMilestoneOrVersion()) {
        if ($project->settings & PROJECT_SETTING_ENABLE_MILESTONES) {
            ### resolved version ###
            $tab->add(new Form_DropdownGrouped('task_resolved_version', __('Resolved in'), $project->buildResolvedInList(), $task->resolved_version));
        }
        ### resolved reason ###
        global $g_resolve_reason_names;
        $tab->add(new Form_Dropdown('task_resolve_reason', __('Resolve reason'), array_flip($g_resolve_reason_names), $task->resolve_reason));
    }
    $tab_group->add($tab = new Page_Tab("bug", __("Bug Report")));
    ### use issue-report ###
    global $g_severity_names;
    global $g_reproducibility_names;
    ### create new one ###
    if ($task->issue_report <= 0) {
        $issue = new Issue(array('id' => 0));
        ### get recent issue-reports ###
        if ($recent_ir = Issue::getCreatedRecently()) {
            $default_version = '';
            $default_plattform = '';
            $default_production_build = '';
            $default_os = '';
            foreach ($recent_ir as $ir) {
                if ($ir->project == $project->id) {
                    if (!$issue->version && $ir->version) {
                        $issue->version = $ir->version;
                    }
                    if (!$issue->plattform && $ir->plattform) {
                        $issue->plattform = $ir->plattform;
                    }
                    if (!$issue->os && $ir->os) {
                        $issue->os = $ir->os;
                    }
                    if (!$issue->production_build && $ir->production_build) {
                        $issue->production_build = $ir->production_build;
                    }
                }
            }
        }
    } else {
        /**
         * note: if task is visible ignore visibility of issue report
         */
        $issue = Issue::getById($task->issue_report);
    }
    if ($issue) {
        $tab->add(new Form_Dropdown('issue_severity', __("Severity", "Form label, attribute of issue-reports"), array_flip($g_severity_names), $issue->severity));
        $tab->add(new Form_Dropdown('issue_reproducibility', __("Reproducibility", "Form label, attribute of issue-reports"), array_flip($g_reproducibility_names), $issue->reproducibility));
        foreach ($issue->fields as $field) {
            $tab->add($field->getFormElement($issue));
        }
        $tab->add(new Form_HiddenField('task_issue_report', '', $task->issue_report));
    } else {
        trigger_error("could not get Issue with id ({$task->issue}-report)", E_USER_NOTICE);
    }
    $tab_group->add($tab = new Page_Tab("timing", __("Timing")));
    ### estimated ###
    if (!$task->isMilestoneOrVersion()) {
        #$tab->add($task->fields['estimated'    ]->getFormElement($task));
        $ar = array(__('undefined') => 0, __('30 min') => 30 * 60, __('1 h') => 60 * 60, __('2 h') => 2 * 60 * 60, __('4 h') => 4 * 60 * 60, __('1 Day') => 1 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Days') => 2 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Days') => 3 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('4 Days') => 4 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('1 Week') => 1 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Weeks') => 2 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Weeks') => 3 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60);
        $tab->add(new Form_Dropdown('task_estimated', __("Estimated time"), $ar, $task->estimated));
        $tab->add(new Form_Dropdown('task_estimated_max', __("Estimated worst case"), $ar, $task->estimated_max));
    }
    ### planned time ###
    if (!$task->isMilestoneOrVersion()) {
        $tab->add($task->fields['planned_start']->getFormElement($task));
    }
    $tab->add($task->fields['planned_end']->getFormElement($task));
    if ($task->isMilestoneOrVersion()) {
        global $g_released_names;
        $tab->add(new Form_Dropdown('task_is_released', __("Release as version", "Form label, attribute of issue-reports"), array_flip($g_released_names), $task->is_released));
        $tab->add($task->fields['time_released']->getFormElement($task));
    }
    $tab_group->add($tab = new Page_Tab('description', __("Description")));
    $e = $task->fields['description']->getFormElement($task);
    $e->rows = 20;
    $tab->add($e);
    $tab_group->add($tab = new Page_Tab('display', __("Display")));
    ### short ###
    $tab->add($task->fields['short']->getFormElement($task));
    ### order id ###
    $tab->add($task->fields['order_id']->getFormElement($task));
    ### Shows as news ###
    $tab->add($task->fields['is_news']->getFormElement($task));
    ### Shows Folder as documentation ###
    $tab->add($task->fields['show_folder_as_documentation']->getFormElement($task));
    ### public-level ###
    if (($pub_levels = $task->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        $tab->add(new Form_Dropdown('task_pub_level', __("Publish to"), $pub_levels, $task->pub_level));
    }
    ### label ###
    if (!$task->isOfCategory(TCATEGORY_VERSION, TCATEGORY_MILESTONE, TCATEGORY_FOLDER)) {
        $labels = array(__('undefined') => 0);
        $counter = 1;
        foreach (explode(",", $project->labels) as $l) {
            $labels[$l] = $counter++;
        }
        $tab->add(new Form_Dropdown('task_label', __("Label"), $labels, $task->label));
    }
    if (confGet('INTERNAL_COST_FEATURE') && $auth->cur_user->user_rights & RIGHT_VIEWALL && $auth->cur_user->user_rights & RIGHT_EDITALL) {
        $tab_group->add($tab = new Page_Tab("internal", __("Internal")));
        $tab->add($task->fields['calculation']->getFormElement($task));
    }
    /**
     * to reduce spam, enforce captcha test for guests
     */
    global $auth;
    if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
        $form->addCaptcha();
    }
    $form->add($task->fields['parent_task']->getFormElement($task));
    #echo "<input type=hidden name='tsk' value='$task->id'>";
    $form->add(new Form_HiddenField('tsk', '', $task->id));
    #echo "<input type=hidden name='task_project' value='$project->id'>";
    $form->add(new Form_HiddenField('task_project', '', $project->id));
    ### create another task ###
    if ($task->id == 0) {
        $checked = get('create_another') ? 'checked' : '';
        $form->form_options[] = "<input id='create_another' name='create_another' type=checkbox {$checked}><label for='create_another'>" . __("Create another task after submit") . "</label>";
    }
    echo $form;
    $PH->go_submit = 'taskEditSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    $block->render_blockEnd();
    #@@@ passing project-id is an security-issue, because it might allow to add tasks to unverified projects.
    # Double-checking project-rights in taskEditSubmit() required
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Пример #3
0
 public function render_quickedit($task)
 {
     global $PH;
     $editable = false;
     ### make sure it's editable ###
     if (Task::getEditableById($task->id)) {
         $editable = true;
     } else {
         if (!Task::getVisibleById($task->id)) {
             return false;
         }
     }
     ### get parent project ####
     if (!($project = Project::getVisibleById($task->project))) {
         return;
     }
     $this->render_blockStart();
     require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
     global $REPRODUCIBILITY_VALUES;
     global $g_prio_names;
     global $g_status_names;
     $form = new PageForm();
     $form->button_cancel = false;
     $form->add($tab_group = new Page_TabGroup());
     $tab_group->add($tab = new Page_Tab("comment", __("Add comment")));
     ### Comment ###
     $comment_name = '';
     $comment = new Comment(array('id' => 0, 'name' => $comment_name));
     $tab->add($comment->fields['name']->getFormElement($comment, __('Comment')));
     $e = $comment->fields['description']->getFormElement($comment);
     $e->rows = 8;
     $tab->add($e);
     ### request feedback
     $tab->add(buildRequestFeedbackInput($project));
     ### update ###
     if ($editable && $task->isOfCategory(array(TCATEGORY_TASK, TCATEGORY_BUG))) {
         $tab_group->add($tab = new Page_Tab("update", __("Update")));
         #$tab->add(new Form_Dropdown('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
         $tab->add(new Form_DropdownGrouped('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
         $tab->add(new Form_DropdownGrouped('task_resolved_version', __('Resolved in'), $project->buildResolvedInList(), $task->resolved_version));
         global $g_resolve_reason_names;
         $tab->add(new Form_Dropdown('task_resolve_reason', __('Resolve reason'), array_flip($g_resolve_reason_names), $task->resolve_reason));
         ### for existing tasks, get already assigned
         if ($task->id) {
             $assigned_people = $task->getAssignedPeople();
         } else {
             trigger_error("view a task with zero id?");
         }
         $team = array(__('- select person -') => 0);
         ### create team-list ###
         foreach ($project->getPeople() as $p) {
             $team[$p->name] = $p->id;
         }
         ### create drop-down-lists ###
         $count_new = 0;
         $count_all = 0;
         if (isset($assigned_people)) {
             foreach ($assigned_people as $ap) {
                 if (!($p = Person::getVisibleById($ap->id))) {
                     continue;
                     # skip if invalid person
                 }
                 if ($task->id) {
                     $tab->add(new Form_Dropdown('task_assigned_to_' . $ap->id, __("Assigned to"), $team, $ap->id));
                 } else {
                     $tab->add(new Form_Dropdown('task_assign_to_' . $count_new, __("Assign to"), $team, $ap->id));
                     $count_new++;
                 }
                 $count_all++;
                 unset($team[$ap->name]);
             }
         }
         ### add empty drop-downlist for new assignments ###
         $str_label = $count_all == 0 ? __("Assign to", "Form label") : __("Also assign to", "Form label");
         $tab->add(new Form_Dropdown("task_assign_to_{$count_new}", $str_label, $team, 0));
         if (!$task->isMilestoneOrVersion()) {
             $tab->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio));
         }
         $ar = array(__('undefined') => 0, __('30 min') => 30 * 60, __('1 h') => 60 * 60, __('2 h') => 2 * 60 * 60, __('4 h') => 4 * 60 * 60, __('1 Day') => 1 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Days') => 2 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Days') => 3 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('4 Days') => 4 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('1 Week') => 1 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Weeks') => 2 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Weeks') => 3 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60);
         $tab->add(new Form_Dropdown('task_estimated', __("Estimated time"), $ar, $task->estimated));
         $tab->add(new Form_Dropdown('task_estimated_max', __("Estimated worst case"), $ar, $task->estimated_max));
         $ar = array(__('undefined') => -1, '0%' => 0, '10%' => 10, '20%' => 20, '30%' => 30, '40%' => 40, '50%' => 50, '60%' => 60, '70%' => 70, '80%' => 80, '90%' => 90, '95%' => 95, '98%' => 98, '99%' => 99, '100%' => 100);
         $tab->add(new Form_Dropdown('task_completion', __("Completed"), $ar, $task->completion));
         $tab->add($task->fields['parent_task']->getFormElement($task));
         $st = array();
         foreach ($g_status_names as $s => $n) {
             if ($s >= STATUS_NEW) {
                 $st[$s] = $n;
             }
         }
         if ($task->isMilestoneOrVersion()) {
             unset($st[STATUS_NEW]);
         }
         $tab->add(new Form_Dropdown('task_status', "Status", array_flip($st), $task->status));
     }
     /**
      * to reduce spam, enforce captcha test for guests
      */
     global $auth;
     if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
         $form->addCaptcha();
     }
     ### some required hidden fields for correct data passing ###
     $form->add(new Form_HiddenField('tsk', '', $task->id));
     $form->add(new Form_HiddenField('comment', '', $comment->id));
     if ($return = get('return')) {
         $form->add(new Form_HiddenField('return', '', asHtml($return)));
     }
     echo $form;
     $PH->go_submit = 'taskEditSubmit';
     $this->render_blockEnd();
 }
Пример #4
0
/**
* Edit a project @ingroup pages
*/
function projEdit($project = NULL)
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
    if (!$project) {
        $prj = getOnePassedId('prj', 'projects_*');
        ### get project ####
        if (!($project = Project::getEditableById($prj))) {
            $PH->abortWarning("could not get Project");
            return;
        }
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'project_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit Project");
    $page->title = $project->name;
    $page->title_minor = $project->short;
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'projEdit'));
    echo new PageHeader();
    echo new PageContentOpen();
    global $g_status_names;
    global $g_prio_names;
    require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
    ### form background ###
    $block = new PageBlock(array('id' => 'project_edit'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($project->fields['name']->getFormElement($project));
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab("project", __("Project")));
    $tab->add(new Form_Dropdown('project_status', "Status", array_flip($g_status_names), $project->status));
    ### build company-list ###
    $companies = Company::getAll();
    $cl_options = array('undefined' => 0);
    foreach ($companies as $c) {
        $cl_options[$c->name] = $c->id;
    }
    $tab->add(new Form_Dropdown('project_company', __('Company', 'form label'), $cl_options, $project->company));
    $tab->add(new Form_Dropdown('project_prio', "Prio", array_flip($g_prio_names), $project->prio));
    $tab->add($project->fields['projectpage']->getFormElement($project));
    $tab->add($project->fields['date_start']->getFormElement($project));
    $tab->add($project->fields['date_closed']->getFormElement($project));
    $tab_group->add($tab = new Page_Tab("description", __("Description")));
    $e = $project->fields['description']->getFormElement($project);
    $e->rows = 20;
    $tab->add($e);
    global $g_project_setting_names;
    $tab_group->add($tab = new Page_Tab("tab3", __("Display")));
    $tab->add($project->fields['short']->getFormElement($project));
    $tab->add($project->fields['status_summary']->getFormElement($project));
    $tab->add($project->fields['color']->getFormElement($project));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_TASKS', $g_project_setting_names[PROJECT_SETTING_ENABLE_TASKS], $project->settings & PROJECT_SETTING_ENABLE_TASKS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_FILES', $g_project_setting_names[PROJECT_SETTING_ENABLE_FILES], $project->settings & PROJECT_SETTING_ENABLE_FILES));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_BUGS', $g_project_setting_names[PROJECT_SETTING_ENABLE_BUGS], $project->settings & PROJECT_SETTING_ENABLE_BUGS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_EFFORTS', $g_project_setting_names[PROJECT_SETTING_ENABLE_EFFORTS], $project->settings & PROJECT_SETTING_ENABLE_EFFORTS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_MILESTONES', $g_project_setting_names[PROJECT_SETTING_ENABLE_MILESTONES], $project->settings & PROJECT_SETTING_ENABLE_MILESTONES));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_VERSIONS', $g_project_setting_names[PROJECT_SETTING_ENABLE_VERSIONS], $project->settings & PROJECT_SETTING_ENABLE_VERSIONS));
    $tab->add(new Form_checkbox('PROJECT_SETTING_ENABLE_NEWS', $g_project_setting_names[PROJECT_SETTING_ENABLE_NEWS], $project->settings & PROJECT_SETTING_ENABLE_NEWS));
    ### create another one ###
    if ($auth->cur_user->user_rights & RIGHT_PROJECT_CREATE && $project->id == 0) {
        $checked = get('create_another') ? 'checked' : '';
        $form->form_options[] = "<span class=option><input name='create_another' class='checker' type=checkbox {$checked}>" . __("Create another project after submit") . "</span>";
    }
    #echo "<input type=hidden name='prj' value='$project->id'>";
    $form->add(new Form_Hiddenfield('prj', '', $project->id));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'projEditSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Пример #5
0
/**
* Edit a team member @ingroup pages
*/
function projectPersonEdit($pp = NULL)
{
    global $PH;
    global $auth;
    if (!$pp) {
        $id = getOnePassedId('projectperson', 'projectpeople_*', true, 'No team member selected?');
        # WARNS if multiple; ABORTS if no id found
        if (!($pp = ProjectPerson::getEditableById($id))) {
            $PH->abortWarning("ERROR: could not get Project Person");
            return;
        }
    }
    ### get project ###
    if (!($project = Project::getVisibleById($pp->project))) {
        $PH->abortWarning("ERROR: could not get project");
    }
    ### get person ###
    if (!($person = Person::getVisibleById($pp->person))) {
        $PH->abortWarning("ERROR: could not get person");
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'projectperson_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit Team Member");
    $page->title = sprintf(__("role of %s in %s", "edit team-member title"), $person->name, $project->name);
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'projectPersonEdit'));
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($tab_group = new Page_TabGroup());
    $tab_group->add($tab = new Page_Tab("details", __("Details")));
    global $g_theme_names;
    global $g_user_profile_names;
    global $g_user_profiles;
    ### display "undefined" profile if rights changed ###
    $profile_num = 0;
    # will be skipped when submitting
    $reset = "";
    $check = array_keys($g_user_profile_names);
    $number = count($g_user_profile_names);
    $count = 0;
    for ($i = 0; $i < $number; $i++) {
        if ($pp->role == $check[intval($i)]) {
            $profile_num = $count;
            break;
        }
        $count++;
    }
    /*$profile_settings= $g_user_profiles[intval($profile_num)];
    
                $count=0;
    			echo "LevelV: " . $pp->level_view . "<br>";
    			echo "SetV: " . $profile_settings['level_view'] . "<br>";
    			echo "LevelC: " . $pp->level_create . "<br>";
    			echo "SetC: " . $profile_settings['level_create'] . "<br>";
    			echo "LevelE: " . $pp->level_edit . "<br>";
    			echo "SetE: " . $profile_settings['level_edit'] . "<br>";
    			echo "LevelD: " . $pp->level_delete . "<br>";
    			echo "SetV: " . $profile_settings['level_delete'] . "<br>";
                foreach($g_user_profiles as $profile_id => $profile_settings) {
                    if($pp->level_view          == $profile_settings['level_view']
                        && $pp->level_create    == $profile_settings['level_create']
                        && $pp->level_edit      == $profile_settings['level_edit']
                        && $pp->level_delete    == $profile_settings['level_delete']
                    ){
                        $profile_num=$count;
                        break;
                    }
                    $count++;
                }*/
    /*$form->add(new Form_Dropdown('person_profile',
                                  __("Role in this project"),
                                  array_flip($g_user_profile_names),
                                  $profile_num
      ));*/
    $tab->add(new Form_Dropdown('person_profile', __("Role in this project"), array_flip($g_user_profile_names), $profile_num));
    //$form->add($pp->fields['name']->getFormElement($pp));
    $tab->add($pp->fields['name']->getFormElement($pp));
    ### public-level ###
    if (($pub_levels = $pp->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        //$form->add(new Form_Dropdown('projectperson_pub_level',  __("Publish to"),$pub_levels,$pp->pub_level));
        $tab->add(new Form_Dropdown('projectperson_pub_level', __("Publish to"), $pub_levels, $pp->pub_level));
    }
    ### effort-style ###
    $effort_styles = array(__("start times and end times") => 1, __("duration") => 2);
    //$form->add(new Form_Dropdown('projectperson_effort_style',  __("Log Efforts as"), $effort_styles, $pp->adjust_effort_style));
    $tab->add(new Form_Dropdown('projectperson_effort_style', __("Log Efforts as"), $effort_styles, $pp->adjust_effort_style));
    if (confGet('INTERNAL_COST_FEATURE') && $auth->cur_user->user_rights & RIGHT_VIEWALL && $auth->cur_user->user_rights & RIGHT_EDITALL) {
        $tab_group->add($tab = new Page_Tab("internal", __("Internal")));
        $tab->add($pp->fields['salary_per_hour']->getFormElement($pp));
    }
    echo $form;
    $PH->go_submit = 'projectPersonEditSubmit';
    echo "<input type=hidden name='projectperson' value='{$pp->id}'>";
    echo "<input type=hidden name='projectperson_project' value='{$pp->project}'>";
    echo new PageContentClose();
}