Beispiel #1
0
/**
* Shown, if unknown page-id requested
*
* @ingroup pages
*
* \TODO this should only trigger an error and relay to home
* \TODO removing this function would make renderBacktrace() obsolete, too
*/
function error()
{
    global $PH;
    require_once confGet('DIR_STREBER') . 'render/render_list.inc.php';
    $page = new Page();
    $page->tabs['error'] = array('target' => "index.php?go=error", 'title' => __('Error', 'top navigation tab'), 'bg' => "error");
    $page->cur_tab = 'error';
    $page->title = __("Unknown Page");
    $page->type = __("Error");
    $page->title_minor = get('go');
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Error'), 'id' => 'error'));
    $block->render_blockStart();
    echo "<div class=text>";
    echo "<p>Sorry but you found a function that has not yet been implemented.<br>";
    echo "If you feel this a bug, or a very important function is missing, please help us to fix this,\r\n    Please hit the back-button of your browser and use the 'Wiki + Help' option to follow to the online\r\n    documentation. Then edit 'issue' or 'request-part'.</p>";
    echo "</div>";
    ### Show traceback only for admins
    if ($auth->cur_user->user_rights & RIGHT_VIEWALL) {
        $block->render_blockEnd();
        $block = new PageBlock(array('title' => 'Details', 'id' => 'details'));
        $block->render_blockStart();
        echo "<div class=text>";
        echo "<pre>";
        echo renderBacktrace(debug_backtrace());
        echo "</pre>";
        echo "</div>";
        $block->render_blockEnd();
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Beispiel #2
0
/**
* render home view @ingroup pages
*/
function home()
{
    global $PH;
    global $auth;
    ### create from handle ###
    $PH->defineFromHandle(array());
    $page = new Page();
    $page->cur_tab = 'home';
    $page->options = build_home_options();
    $page->title = __("Today");
    # $auth->cur_user->name;
    $page->type = __("At Home");
    $page->title_minor = renderTitleDate(time());
    ### page functions ###
    $page->add_function(new PageFunction(array('target' => 'personEdit', 'params' => array('person' => $auth->cur_user->id), 'icon' => 'edit', 'name' => __('Edit your Profile'))));
    $page->add_function(new PageFunction(array('target' => 'personAllItemsViewed', 'params' => array('person' => $auth->cur_user->id), 'icon' => 'edit', 'name' => __('Mark all items as viewed'))));
    echo new PageHeader();
    echo new PageContentOpen_Columns();
    measure_stop('init2');
    require_once confGet('DIR_STREBER') . 'db/class_company.inc.php';
    $block = new PageBlock(array('title' => __('Active projects'), 'id' => 'projects'));
    $block->render_blockStart();
    echo "<div class=linklist>";
    /**
     * get companies
     */
    foreach (Company::getAll() as $c) {
        /**
         * get project for company
         *
         * @NOTE single sql requests are not the fastes solution here...
         */
        if ($projects = Project::getAll(array('order_by' => 'c.name', 'company' => $c->id))) {
            echo "<span class=sub>" . __("for", "short for client") . '</span> <b>' . $c->getLink() . "</b>:";
            echo '<ul>';
            foreach ($projects as $project) {
                echo '<li>' . $PH->getLink('projView', $project->name, array('prj' => $project->id)) . '</li>';
            }
            echo '</ul>';
        }
    }
    if ($projects = Project::getAll(array('order_by' => 'c.name', 'company' => 0))) {
        echo __("without client");
        echo '<ul>';
        foreach ($projects as $project) {
            echo '<li>' . $PH->getLink('projView', $project->name, array('prj' => $project->id)) . '</li>';
        }
        echo '</ul>';
    }
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentNextCol();
    if ($projects = Project::getAll(array('order_by' => 'modified DESC'))) {
        require_once confGet('DIR_STREBER') . 'lists/list_recentchanges.inc.php';
        printRecentChanges($projects);
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
function projViewFiles()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . "render/render_wiki.inc.php";
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    $project = Project::getVisibleById($id);
    if (!$project || !$project->id) {
        $PH->abortWarning(__("invalid project-id"));
        return;
    }
    ### define from-handle ###
    $PH->defineFromHandle(array('prj' => $project->id));
    ## is viewed by user ##
    $project->nowViewedByUser();
    ## next milestone ##
    $next = $project->getNextMilestone();
    $page = new Page();
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->cur_tab = 'projects';
    $page->title = $project->name;
    $page->title_minor = __("Downloads");
    if ($project->status == STATUS_TEMPLATE) {
        $page->type = __("Project Template");
    } else {
        if ($project->status >= STATUS_COMPLETED) {
            $page->type = __("Inactive Project");
        } else {
            $page->type = __("Project", "Page Type");
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    measure_stop('init2');
    measure_start('info');
    $block = new PageBlock(array('id' => 'support'));
    $block->render_blockStart();
    echo "<div class=text>";
    if ($task = Task::getVisibleById(3645)) {
        echo wikifieldAsHtml($task, 'description');
    }
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Beispiel #4
0
/**
* show system information @ingroup pages
*/
function systemInfo()
{
    global $PH;
    require_once confGet('DIR_STREBER') . 'render/render_list.inc.php';
    $system_info = getSysInfo();
    $page = new Page();
    $page->tabs['admin'] = array('target' => "index.php?go=systemInfo", 'title' => __('Admin', 'top navigation tab'), 'bg' => "misc");
    $page->cur_tab = 'admin';
    $page->crumbs[] = new NaviCrumb(array('target_id' => 'systemInfo'));
    $page->title = __("System information");
    $page->type = __("Admin");
    #$page->title_minor=get('go');
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Overview'), 'id' => 'overview'));
    $block->render_blockStart();
    echo "<div class=text>";
    foreach ($system_info as $label => $value) {
        echo "<div class=labeled><label>{$label}:</label> <span>{$value}</span></div>";
    }
    echo "</div>";
    global $auth;
    echo "<br>";
    echo "<h2>Timezone detection</h2>";
    echo "<div class=text>";
    echo "<ul>";
    echo "<li> time-offset for user: "******"sec";
    echo "<li> renderDateHtml(): " . renderDateHtml($auth->cur_user->last_login) . "";
    echo "<li> original db-string (should be GMT): " . $auth->cur_user->last_login;
    echo "<li> strToClienttime(): " . strToClientTime($auth->cur_user->last_login);
    echo "<li> gmdate:(strToClientTime) " . gmdate("H:i:s", strToClientTime($auth->cur_user->last_login));
    echo "<li> strToTime(): " . strToTime($auth->cur_user->last_login);
    echo "<li> date(strToTime): " . date("H:i:s", strToTime($auth->cur_user->last_login));
    echo "</ul>";
    echo "</div>";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Beispiel #5
0
/**
* Edit description of a task
*
* @ingroup pages
*/
function taskEditDescription($task = NULL)
{
    global $PH;
    ### object or from database? ###
    if (!$task) {
        $id = getOnePassedId('tsk', 'tasks_*');
        if (!($task = Task::getEditableById($id))) {
            $PH->abortWarning(__("Select a task to edit description"), ERROR_NOTE);
            return;
        }
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'task_name'));
    initPageForTask($page, $task);
    $page->title_minor = __("Edit description");
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $block = new PageBlock(array('id' => 'edit'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add(new Form_HiddenField('task_id', '', $task->id));
    $form->add($task->fields['name']->getFormElement($task));
    $e = $task->fields['description']->getFormElement($task);
    $e->rows = 22;
    $form->add($e);
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'taskEditDescriptionSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Beispiel #6
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();
}
Beispiel #7
0
/**
* view details of a version @ingroup pages
*/
function versionView()
{
    global $PH;
    global $auth;
    require_once "render/render_wiki.inc.php";
    ### get task ####
    if (!($version = Version::getVisibleById(get('version')))) {
        $PH->abortWarning("invalid version-id", ERROR_FATAL);
    }
    if (!($project = Project::getVisibleById($version->project))) {
        $PH->abortWarning("invalid project-id", ERROR_FATAL);
    }
    ### create from handle ###
    $from_handle = $PH->defineFromHandle(array('version' => $version->id));
    ## is viewed by user ##
    $version->isViewedByUser($auth->cur_user);
    $page = new Page();
    $page->cur_tab = 'projects';
    $page->cur_crumb = 'projViewTasks';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $type = __('Version', 'page type');
    if ($task) {
        $folder = $task->getFolderLinks() . "<em>&gt;</em>" . $task->getLink();
        $page->type = $folder . " > " . $type;
    } else {
        $page->type = $type;
    }
    $page->title = $version->name;
    $page->title_minor = "";
    if ($version->state == -1) {
        $page->title_minor = sprintf(__('(deleted %s)', 'page title add on with date of deletion'), renderTimestamp($version->deleted));
    }
    ### page functions ###
    $page->add_function(new PageFunction(array('target' => 'versionEdit', 'params' => array('version' => $version->id), 'icon' => 'edit', 'tooltip' => __('Edit this version'), 'name' => __('Edit'))));
    $item = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $version->id));
    if (!$item || $item[0]->is_bookmark == 0) {
        $page->add_function(new PageFunction(array('target' => 'itemsAsBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Mark this version as bookmark'), 'name' => __('Bookmark'))));
    } else {
        $page->add_function(new PageFunction(array('target' => 'itemsRemoveBookmark', 'params' => array('version' => $version->id), 'tooltip' => __('Remove this bookmark'), 'name' => __('Remove Bookmark'))));
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Description'), 'id' => 'description', 'noshade' => true));
    $block->render_blockStart();
    $str = wikifieldAsHtml($version, 'description');
    echo "<div class=text>";
    echo "{$str}";
    echo "</div>";
    $block->render_blockEnd();
    echo '<input type="hidden" name="prj" value="' . $version->project . '">';
    /**
     * give parameter for create of new items (subtasks, efforts, etc)
     */
    #echo '<input type="hidden" name="parent_task" value="'.$task->id.'">';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
/**
* revert changes of a person
*
* Notes:
* - This function is only available of people with RIGHT_PROJECT_EDIT.
* - This will only effect changes to fields.
* - Following changes will not be reverted:
*   - Creation of new items (Tasks, Topis, Efforts, Projects, etc.)
*   - Task-assignments
*   - Uploading of files
* 
* 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 personRevertChanges()
{
    global $PH;
    global $auth;
    ### check rights ###
    if (!$auth->cur_user->user_rights & RIGHT_PROJECT_EDIT) {
        $PH->abortWarning("You require the right to edit projects.");
    }
    ### get person ###
    $person_id = getOnePassedId('person', 'people_*');
    if (!($person = Person::getVisibleById($person_id))) {
        $PH->abortWarning(sprintf(__("invalid Person #%s"), $person_id));
        return;
    }
    $page = new Page();
    $page->tabs['admin'] = array('target' => "index.php?go=systemInfo", 'title' => __('Admin', 'top navigation tab'), 'bg' => "misc");
    $page->cur_tab = 'admin';
    $page->crumbs[] = new NaviCrumb(array('target_id' => 'systemInfo'));
    $page->title = __("Reverting user changes");
    $page->type = __("Admin");
    #$page->title_minor=get('go');
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('title' => __('Overview'), 'id' => 'overview'));
    $block->render_blockStart();
    echo "<div class=text>";
    echo "<ul>";
    ### get changes of person ###
    $count_reverted_fields = 0;
    $changes = ItemChange::getItemChanges(array('person' => $person_id, 'order_by' => 'id DESC'));
    foreach ($changes as $c) {
        if (!($project_item = DbProjectItem::getObjectById($c->item))) {
            #print "unable to get item %s" % $c->item;
        } else {
            ### Only revert changes, if item has not be editted by other person
            if ($project_item->modified_by == $person_id) {
                $field_name = $c->field;
                echo "<li>" . "<strong>" . asHtml($project_item->name) . "." . asHtml($field_name) . "</strong>" . " '" . asHtml($project_item->{$field_name}) . "' = '" . asHtml($c->value_old) . "'" . "</li>";
                $count_reverted_fields++;
                if ($field_name == 'state') {
                    if ($project_item->state == -1 && $c->value_old == 1) {
                        $project_item->deleted_by = "0";
                        $project_item->deleted = "0000-00-00 00-00-00";
                    }
                }
                $project_item->{$field_name} = $c->value_old;
                $project_item->update(array($field_name, 'deleted_by', 'deleted'), false, false);
            } else {
                echo "<li>" . sprintf(__("Skipped recently editted item #%s: <b>%s<b>"), $project_item->id, asHtml($project_item->name)) . "</li>";
            }
            $c->deleteFull();
        }
    }
    echo "</ul>";
    echo "<p>" . sprintf(__("Reverted all changes (%s) of user %s"), $count_reverted_fields, asHtml($person->nickname)) . "</p>";
    echo "<p>" . __("newly created items by this user remain unaffected.") . "</p>";
    echo "</div>";
    $block->render_blockEnd();
    ### close page
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
/**
* export selected efforts as a CSV ready for copy and paste into a spread-sheet  @ingroup pages
**
*/
function effortShowAsCSV()
{
    global $PH;
    global $g_effort_status_names;
    $effort_ids = getPassedIds('effort', 'efforts_*');
    if (!$effort_ids) {
        $PH->abortWarning(__("Select some efforts(s) to show"));
        exit;
    }
    $efforts = array();
    $different_fields = array();
    $edit_fields = array('status', 'pub_level', 'task');
    foreach ($effort_ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $efforts[] = $effort;
            ### check project for first task
            if (count($efforts) == 1) {
                ### make sure all are of same project ###
                if (!($project = Project::getVisibleById($effort->project))) {
                    $PH->abortWarning('could not get project');
                }
            } else {
                if ($effort->project != $efforts[0]->project) {
                    $PH->abortWarning(__("For editing all efforts must be of same project."));
                }
                foreach ($edit_fields as $field_name) {
                    if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
                        $different_fields[$field_name] = true;
                    }
                }
            }
        }
    }
    $page = new Page(array('use_jscalendar' => true));
    $page->cur_tab = 'projects';
    $page->options[] = new naviOption(array('target_id' => 'effortEdit'));
    $page->type = __("Edit multiple efforts", "Page title");
    $page->title = sprintf(__("%s efforts for copy and pasting into a spread-sheet", "Page title"), count($efforts));
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
    $block->render_blockStart();
    $format = "[Date][Weekday][Task][Comment][Duration]";
    preg_match_all("/\\[(.*?)\\]/", $format, $matches);
    $overallDuration = 0;
    echo "<textarea style='width:96%; height:300px;'>";
    echo join("\t", $matches[1]) . "\n";
    foreach ($efforts as $e) {
        preg_match_all("/\\[(.*?)\\]/", $format, $matches);
        $separator = "";
        foreach ($matches[1] as $matchedFormat) {
            echo $separator;
            switch ($matchedFormat) {
                case "Date":
                    echo gmstrftime("%Y-%m-%d", strToGMTime($e->time_start));
                    break;
                case "Weekday":
                    echo gmstrftime("%a", strToGMTime($e->time_start));
                    break;
                case "Task":
                    if ($t = Task::getVisibleById($e->task)) {
                        echo $t->name;
                    }
                    break;
                case "Comment":
                    echo $e->name;
                    break;
                case "Duration":
                    $durationInMinutes = round((strToGMTime($e->time_end) - strToGMTime($e->time_start)) / 60, 0);
                    $roundUpTo15 = ceil($durationInMinutes / 15) * 15 / 60;
                    $overallDuration += $roundUpTo15;
                    echo number_format($roundUpTo15, 2, $dec_point = ',', '');
                    break;
            }
            $separator = "\t";
        }
        echo "\n";
    }
    echo "</textarea>";
    echo "<br>";
    echo __("Overall Duration:") . $overallDuration . "h";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
    exit;
}
Beispiel #10
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();
}
Beispiel #11
0
/**
* Edit several efforts @ingroup pages
*/
function effortEditMultiple()
{
    global $PH;
    global $g_effort_status_names;
    $effort_ids = getPassedIds('effort', 'efforts_*');
    if (!$effort_ids) {
        $PH->abortWarning(__("Select some efforts(s) to edit"));
        exit;
    }
    $efforts = array();
    $different_fields = array();
    $edit_fields = array('status', 'pub_level', 'task');
    foreach ($effort_ids as $id) {
        if ($effort = Effort::getEditableById($id)) {
            $efforts[] = $effort;
            ### check project for first task
            if (count($efforts) == 1) {
                ### make sure all are of same project ###
                if (!($project = Project::getVisibleById($effort->project))) {
                    $PH->abortWarning('could not get project');
                }
            } else {
                if ($effort->project != $efforts[0]->project) {
                    $PH->abortWarning(__("For editing all efforts must be of same project."));
                }
                foreach ($edit_fields as $field_name) {
                    if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
                        $different_fields[$field_name] = true;
                    }
                }
            }
        }
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'effort_name'));
    $page->cur_tab = 'projects';
    $page->options[] = new naviOption(array('target_id' => 'effortEdit'));
    $page->type = __("Edit multiple efforts", "Page title");
    $page->title = sprintf(__("Edit %s efforts", "Page title"), count($efforts));
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($efforts as $e) {
        echo "<li>" . $e->getLink(false) . "</li>";
    }
    echo "</ol>";
    $block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $st = array();
    foreach ($g_effort_status_names as $key => $value) {
        $st[$key] = $value;
    }
    if (isset($different_fields['status'])) {
        $st[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('effort_status', __("Status"), array_flip($st), -1));
    } else {
        $form->add(new Form_Dropdown('effort_status', __("Status"), array_flip($st), $efforts[0]->status));
    }
    ### get meta-tasks / folders ###
    $folders = Task::getAll(array('sort_hierarchical' => true, 'parent_task' => 0, 'show_folders' => true, 'folders_only' => false, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED, 'project' => $project->id));
    if ($folders) {
        $folder_list = array("undefined" => "0");
        if ($effort->task) {
            if ($task = Task::getVisibleById($effort->task)) {
                ### add, if normal task (folders will added below) ###
                if (!$task->category == TCATEGORY_FOLDER) {
                    $folder_list[$task->name] = $task->id;
                }
            }
        }
        foreach ($folders as $f) {
            $str = '';
            foreach ($f->getFolder() as $pf) {
                $str .= $pf->getShort() . " > ";
            }
            $str .= $f->name;
            $folder_list[$str] = $f->id;
        }
        if (isset($different_fields['task'])) {
            $folder_list['-- ' . __('keep different') . ' --'] = -1;
            $form->add(new Form_Dropdown('effort_task', __("For task"), $folder_list, -1));
        } else {
            $form->add(new Form_Dropdown('effort_task', __("For task"), $folder_list, $efforts[0]->task));
        }
    }
    if (($pub_levels = $effort->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        if (isset($different_fields['pub_level'])) {
            $pub_levels['-- ' . __('keep different') . ' --'] = -1;
            $form->add(new Form_Dropdown('effort_pub_level', __("Publish to"), $pub_levels, -1));
        } else {
            $form->add(new Form_Dropdown('effort_pub_level', __("Publish to"), $pub_levels, $efforts[0]->pub_level));
        }
    }
    $number = 0;
    foreach ($efforts as $e) {
        $form->add(new Form_HiddenField("effort_id_{$number}", '', $e->id));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'effortEditMultipleSubmit';
    if ($return = get('return')) {
        echo "<input type=hidden name='return' value='{$return}'>";
    }
    echo new PageContentClose();
    echo new PageHtmlEnd();
    exit;
}
Beispiel #12
0
 function renderListHtml(&$list = NULL)
 {
     if ($list || !$this->no_items_html) {
         $this->render_header();
         if (!$this->reduced_header) {
             $this->render_thead();
         }
         if ($list) {
             ### grouping ###
             if ($this->groupings && $this->active_block_function == 'grouped' && $this->groupings->active_grouping_obj) {
                 $last_group = NULL;
                 $gr = $this->groupings->active_grouping_key;
                 foreach ($list as $e) {
                     if ($last_group != $e->{$gr}) {
                         echo '<tr class=group><td colspan=' . count($this->columns) . '>' . $this->groupings->active_grouping_obj->render($e) . '</td></tr>';
                         $last_group = $e->{$gr};
                     }
                     $this->render_trow($e);
                 }
             } else {
                 foreach ($list as $e) {
                     $this->render_trow($e);
                 }
             }
         }
         $this->render_tfoot();
         parent::render_blockEnd();
     } else {
         parent::render_blockStart();
         echo '<div class="no_content">';
         echo $this->no_items_html;
         echo '</div>';
         parent::render_blockEnd();
         #$this->render_tfoot_empty();
     }
 }
Beispiel #13
0
/**
* Edit a company
* @ingroup pages
*/
function companyEdit($company = NULL)
{
    global $PH;
    global $auth;
    ### use object or get from database ###
    if (!$company) {
        $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 = $company->name;
    $page->crumbs = build_company_crumbs($company);
    $page->options[] = new NaviOption(array('target_id' => 'companyEdit'));
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('id' => 'edit'));
    $block->render_blockStart();
    global $g_ccategory_names;
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $form = new PageForm();
    $form->button_cancel = true;
    foreach ($company->fields as $field) {
        $form->add($field->getFormElement($company));
    }
    ### dropdown menu for company category ###
    if (get('comcat')) {
        $comcat = get('comcat');
    } else {
        if ($company->id) {
            $comcat = $company->category;
        } else {
            $comcat = CCATEGORY_CLIENT;
        }
    }
    $form->add(new Form_Dropdown('ccategory', __('Category', 'form label'), array_flip($g_ccategory_names), $comcat));
    ### create another  ###
    if ($auth->cur_user->user_rights & RIGHT_COMPANY_CREATE && $company->id == 0) {
        $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 company after submit") . "</label></span>";
    }
    echo $form;
    $PH->go_submit = 'companyEditSubmit';
    ### pass person-id? ###
    if ($p = get('person')) {
        echo "<input type='hidden' name='person' value='{$p}'>";
    }
    echo "<input type=hidden name='company' value='{$company->id}'>";
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Beispiel #14
0
/**
* 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();
}
Beispiel #15
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();
}
Beispiel #16
0
/**
* Edit a comment 
*
* @ingroup pages
*/
function commentEdit($comment = NULL)
{
    global $PH;
    global $auth;
    ### edit existing object or get from database ? ###
    if (!$comment) {
        $id = getOnePassedId('comment', 'comments*');
        # WARNS if multiple; ABORTS if no id found
        $comment = Comment::getVisibleById($id);
        if (!$comment) {
            $PH->abortWarning("could not get Comment", ERROR_FATAL);
            return;
        }
    }
    ### check user-rights ###
    if (!($project = Project::getVisibleById($comment->project))) {
        $PH->abortWarning("comment without project?", ERROR_BUG);
    }
    $project->validateEditItem($comment);
    # aborts if not enough rights to edit
    $task = Task::getVisibleById($comment->task);
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'comment_name'));
    initPageForComment($page, $comment, $project);
    if ($comment->id) {
        $page->title = __("Edit Comment", "Page title");
    } else {
        $page->title = __("New Comment", "Page title");
    }
    echo new PageHeader();
    echo new PageContentOpen();
    global $COMMENTTYPE_VALUES;
    global $PUB_LEVEL_VALUES;
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $block = new PageBlock(array('id' => 'edit'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($comment->fields['name']->getFormElement($comment));
    $e = $comment->fields['description']->getFormElement($comment);
    $e->rows = 22;
    $form->add($e);
    $form->add(new Form_HiddenField('comment_project', '', $comment->project));
    $form->add(new Form_HiddenField('comment_task', '', $comment->task));
    $form->add(new Form_HiddenField('comment_comment', '', $comment->comment));
    ### public-level ###
    if (($pub_levels = $comment->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        $form->add(new Form_Dropdown('comment_pub_level', __('Publish to', 'form label'), $pub_levels, $comment->pub_level));
    }
    if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
        $form->addCaptcha();
    }
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'commentEditSubmit';
    echo "<input type=hidden name='comment' value='{$comment->id}'>";
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Beispiel #17
0
/**
* edit several bookmarks @ingroup pages
*/
function itemBookmarkEditMultiple($thebookmarks = NULL)
{
    global $PH;
    global $auth;
    global $g_notitychange_period;
    $is_already_bookmark = array();
    $bookmarks = array();
    $items = array();
    $edit_fields = array('notify_if_unchanged', 'notify_on_change');
    $different_fields = array();
    # hash containing fieldnames which are different in bookmarks
    if (!$thebookmarks) {
        $item_ids = getPassedIds('bookmark', 'bookmarks_*');
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            }
        }
    } else {
        $item_ids = $thebookmarks;
        foreach ($item_ids as $is) {
            if ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 0))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = false;
                }
            } elseif ($bookmark = ItemPerson::getAll(array('item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1))) {
                if ($item = DbProjectItem::getById($bookmark[0]->item)) {
                    $bookmarks[] = $bookmark[0];
                    $items[] = $item;
                    $is_already_bookmark[$bookmark[0]->id] = true;
                }
            } else {
                $date = getGMTString();
                $bookmark = new ItemPerson(array('id' => 0, 'item' => $is, 'person' => $auth->cur_user->id, 'is_bookmark' => 1, 'notify_if_unchanged' => 0, 'notify_on_change' => 0, 'created' => $date));
                if ($item = DbProjectItem::getById($is)) {
                    $bookmarks[] = $bookmark;
                    $items[] = $item;
                    $is_already_bookmark[$bookmark->id] = false;
                }
            }
        }
    }
    if (!$items) {
        $PH->abortWarning(__("Please select some items"));
    }
    $page = new Page();
    $page->cur_tab = 'home';
    $page->options = array(new NaviOption(array('target_id' => 'itemBookmarkEdit', 'name' => __('Edit bookmarks'))));
    $page->type = __('Edit multiple bookmarks', 'page title');
    $page->title = sprintf(__('Edit %s bookmark(s)'), count($items));
    $page->title_minor = __('Edit');
    echo new PageHeader();
    echo new PageContentOpen();
    echo "<ol>";
    foreach ($items as $item) {
        ## get item name ##
        $str_link = '';
        if ($type = $item->type) {
            switch ($type) {
                case ITEM_TASK:
                    require_once "db/class_task.inc.php";
                    if ($task = Task::getVisibleById($item->id)) {
                        $str_link = $task->getLink(false);
                    }
                    break;
                case ITEM_COMMENT:
                    require_once "db/class_comment.inc.php";
                    if ($comment = Comment::getVisibleById($item->id)) {
                        $str_link = $comment->getLink(false);
                    }
                    break;
                case ITEM_PERSON:
                    require_once "db/class_person.inc.php";
                    if ($person = Person::getVisibleById($item->id)) {
                        $str_link = $person->getLink(false);
                    }
                    break;
                case ITEM_EFFORT:
                    require_once "db/class_effort.inc.php";
                    if ($e = Effort::getVisibleById($item->id)) {
                        $str_link = $e->getLink(false);
                    }
                    break;
                case ITEM_FILE:
                    require_once "db/class_file.inc.php";
                    if ($f = File::getVisibleById($item->id)) {
                        $str_link = $f->getLink(false);
                    }
                    break;
                case ITEM_PROJECT:
                    require_once "db/class_project.inc.php";
                    if ($prj = Project::getVisibleById($item->id)) {
                        $str_link = $prj->getLink(false);
                    }
                    break;
                case ITEM_COMPANY:
                    require_once "db/class_company.inc.php";
                    if ($c = Company::getVisibleById($item->id)) {
                        $str_link = $c->getLink(false);
                    }
                    break;
                case ITEM_VERSION:
                    require_once "db/class_task.inc.php";
                    if ($tsk = Task::getVisibleById($item->id)) {
                        $str_link = $tsk->getLink(false);
                    }
                    break;
                default:
                    break;
            }
        }
        echo "<li>" . $str_link . "</li>";
    }
    echo "</ol>";
    foreach ($bookmarks as $bookmark) {
        foreach ($edit_fields as $field_name) {
            if ($bookmark->{$field_name} != $bookmarks[0]->{$field_name}) {
                $different_fields[$field_name] = true;
            }
        }
    }
    $block = new PageBlock(array('id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $b = array();
    $b[0] = __('no');
    $b[1] = __('yes');
    if (isset($different_fields['notify_on_change'])) {
        $b[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), -1));
    } else {
        $form->add(new Form_Dropdown('notify_on_change', __("Notify on change"), array_flip($b), $bookmarks[0]->notify_on_change));
    }
    $a = array();
    foreach ($g_notitychange_period as $key => $value) {
        $a[$key] = $value;
    }
    if (isset($different_fields['notify_if_unchanged'])) {
        $a[-1] = '-- ' . __('keep different') . ' --';
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), -1));
    } else {
        $form->add(new Form_Dropdown('notify_if_unchanged', __("Notify if unchanged in"), array_flip($a), $bookmarks[0]->notify_if_unchanged));
    }
    $number = 0;
    foreach ($bookmarks as $bm) {
        $form->add(new Form_HiddenField("bookmark_id_{$number}", '', $bm->id));
        $form->add(new Form_HiddenField("bookmark_item_{$number}", '', $bm->item));
        $form->add(new Form_HiddenField("is_already_bookmark_{$number}", '', $is_already_bookmark[$bm->id]));
        $number++;
    }
    $form->add(new Form_HiddenField("number", '', $number));
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'itemBookmarkEditMultipleSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
function printRecentChanges($projects, $print_project_headlines = true)
{
    global $PH;
    global $auth;
    /**
     * first get all changelines for projects to filter out projects without changes
     */
    $projects_with_changes = array();
    # array with projects
    $project_changes = array();
    # hash with project id and changelist
    foreach ($projects as $project) {
        /**
         * first query all unviewed changes
         */
        $options = array('project' => $project->id, 'unviewed_only' => false, 'limit_rowcount' => confGet('MAX_CHANGELINES') + 1, 'limit_offset' => 0, 'type' => array(ITEM_TASK, ITEM_FILE));
        if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
            $options['not_modified_by'] = $auth->cur_user->id;
        }
        if ($changes = ChangeLine::getChangeLines($options)) {
            $projects_with_changes[] = $project;
            $project_changes[$project->id] = $changes;
        }
    }
    if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
        $link_name = __("Also show yours", "E.i. also show your changes");
    } else {
        $link_name = __("Hide yours", "E.i. Filter out your changes");
    }
    $block = new PageBlock(array('title' => __('Recent changes'), 'id' => 'recentchanges', 'headline_links' => array($PH->getLink('personToggleFilterOwnChanges', $link_name, array('person' => $auth->cur_user->id)))));
    $block->render_blockStart();
    ### no changes
    if (0 == count($projects_with_changes)) {
        echo "<div class=text>" . __("No changes yet") . "</div>";
        ### more options ###
        echo "<p class=more>";
        echo $PH->getLink('personToggleFilterOwnChanges', $link_name, array('person' => $auth->cur_user->id));
        echo "</p>";
        $block->render_blockEnd();
    } else {
        $changelines_per_project = confGet('MAX_CHANGELINES_PER_PROJECT');
        if (count($projects_with_changes) < confGet('MAX_CHANGELINES') / confGet('MAX_CHANGELINES_PER_PROJECT')) {
            $changelines_per_project = confGet('MAX_CHANGELINES') / count($projects_with_changes) - 1;
        }
        /**
         * count printed changelines to keep size of list
         */
        $printed_changelines = 0;
        foreach ($projects_with_changes as $project) {
            echo "<div class=post_list_entry>";
            $changes = $project_changes[$project->id];
            if ($print_project_headlines) {
                echo '<h3>' . sprintf(__("%s project", "links to project in recent changes list"), $PH->getLink('projView', $project->name, array('prj' => $project->id))) . "</h3>";
            }
            echo "<ul id='changesOnProject_{$project->id}'>";
            $lines = 0;
            foreach ($changes as $c) {
                $lines++;
                printChangeLine($c);
                $printed_changelines++;
                if ($lines >= $changelines_per_project) {
                    break;
                }
            }
            echo "</ul>";
            ### more options ###
            echo "<p class=more>";
            if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
                $link_name = __("Also show your changes");
            } else {
                $link_name = __("Hide your changes");
            }
            if ($lines < count($changes)) {
                echo " | ";
                echo "<a href='javascript:getMoreChanges({$project->id}, " . ($lines - 1) . ", " . confGet('MORE_CHANGELINES') . ");' " . '>' . __('Show more') . '</a>';
            }
            echo "</p>";
            /**
             * limit number of projects
             */
            if ($printed_changelines >= confGet('MAX_CHANGELINES')) {
                break;
            }
            echo "</div>";
        }
        $block->render_blockEnd();
    }
}
Beispiel #19
0
/**
* Display forgot password page @ingroup pages
*/
function loginForgotPassword()
{
    global $PH;
    global $auth;
    global $g_valid_login_params;
    if (isset($auth->cur_user)) {
        $auth->cur_user = NULL;
    }
    $page = new Page(array('autofocus_field' => 'login_name'));
    global $g_tabs_login;
    $page->tabs = $g_tabs_login;
    $page->cur_tab = 'login';
    $page->type = "";
    $page->title = __('Password reminder', 'Page title');
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $block = new PageBlock(array('title' => __('Please enter your nickname'), 'id' => 'functions'));
    $block->render_blockStart();
    $form = new PageForm();
    $form->button_cancel = true;
    $msg = __("We will then sent you an E-mail with a link to adjust your password.") . " ";
    if ($mail = confGet('EMAIL_ADMINISTRATOR')) {
        $msg .= sprintf(__("If you do not know your nickname, please contact your administrator: %s."), "<a href='mailto:{$mail}'>{$mail}</a>");
    }
    $form->add(new Form_Text($msg));
    $form->add(new Form_Input('login_name', __('Nickname', 'label in login form'), ''));
    #$form->form_options[]="<span class=option><input name='login_forgot_password' class='checker' type=checkbox>".__("I forgot my password")."</span>";
    echo $form;
    $block->render_blockEnd();
    $PH->go_submit = 'loginForgotPasswordSubmit';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Beispiel #20
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();
}
Beispiel #21
0
/**
* Edit meta information of a file
*
* read more at http://www.streber-pm.org/3658
*/
function fileEdit($file = NULL)
{
    global $PH;
    if (!$file) {
        $id = getOnePassedId('file', 'files_*');
        # WARNS if multiple; ABORTS if no id found
        if (!($file = File::getEditableById($id))) {
            $PH->abortWarning("ERROR: could not get File");
            return;
        }
    }
    if (!($project = Project::getVisibleById($file->project))) {
        $PH->abortWarning("ERROR: could not get Project", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => true, 'autofocus_field' => 'file_name'));
    initPageForFile($page, $file, $project);
    if ($file->id) {
        $page->title = __('Edit File', 'page title');
    } else {
        $page->title = __('New file', 'page title');
    }
    #$page->title_minor= sprintf(__('On project %s','page title add on'),$project->name);
    echo new PageHeader();
    echo new PageContentOpen();
    $block = new PageBlock(array('id' => 'edit'));
    $block->render_blockStart();
    require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
    $form = new PageForm();
    $form->button_cancel = true;
    $form->add($file->fields['name']->getFormElement($file));
    $form->add($file->fields['description']->getFormElement($file));
    /**
     * until new file is added to database keep details in hiddenfields
     */
    if ($file->id == 0) {
        $form->add(new Form_HiddenField('file_mimetype', '', urlencode($file->mimetype)));
        $form->add(new Form_HiddenField('file_filesize', '', intval($file->filesize)));
        $form->add(new Form_HiddenField('file_org_filename', '', urlencode($file->org_filename)));
        $form->add(new Form_HiddenField('file_tmp_filename', '', urlencode($file->tmp_filename)));
        $form->add(new Form_HiddenField('file_tmp_dir', '', $file->tmp_dir));
        $form->add(new Form_HiddenField('file_is_image', '', $file->is_image));
        $form->add(new Form_HiddenField('file_version', '', $file->version));
        $form->add(new Form_HiddenField('file_parent_item', '', $file->parent_item));
        $form->add(new Form_HiddenField('file_org_file', '', $file->org_file));
    }
    $form->add(new Form_HiddenField('file', '', $file->id));
    $form->add(new Form_HiddenField('file_project', '', $file->project));
    $st = array();
    global $g_status_names;
    foreach ($g_status_names as $s => $n) {
        if ($s >= STATUS_NEW) {
            $st[$s] = $n;
        }
    }
    $form->add(new Form_Dropdown('file_status', "Status", array_flip($st), $file->status));
    ### public-level ###
    if (($pub_levels = $file->getValidUserSetPublicLevels()) && count($pub_levels) > 1) {
        $form->add(new Form_Dropdown('file_pub_level', __("Publish to"), $pub_levels, $file->pub_level));
    }
    echo $form;
    $PH->go_submit = 'fileEditSubmit';
    $block->render_blockEnd();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}