Exemple #1
0
/**
* move comments to folder...
*/
function commentsMoveToFolder()
{
    global $PH;
    $comment_ids = getPassedIds('comment', 'comments_*');
    if (!$comment_ids) {
        $PH->abortWarning(__("Select some comments to move"));
        return;
    }
    /**
     * if folder was given, directly move tasks...
     */
    $target_id = -1;
    # target is unknown
    $folder_ids = getPassedIds('folder', 'folders_*');
    if (count($folder_ids) == 1) {
        if ($folder_task = Task::getVisibleById($folder_ids[0])) {
            $target_id = $folder_task->id;
        }
    } else {
        if (get('from_selection')) {
            $target_id = 0;
            # to ungrout to root?
        }
    }
    if ($target_id != -1) {
        if ($target_id != 0) {
            if (!($target_task = Task::getEditableById($target_id))) {
                $PH->abortWarning(__("insufficient rights"));
            }
        }
        $count = 0;
        foreach ($comment_ids as $id) {
            if ($comment = Comment::getEditableById($id)) {
                $comment->task = $target_id;
                /**
                 * @@@ do we have to reset ->comment as well?
                 *
                 * this splits discussions into separate comments...
                 */
                $comment->comment = 0;
                $comment->update();
            } else {
                new FeedbackWarning(sprintf(__("Can not edit comment %s"), asHtml($comment->name)));
            }
        }
        ### return to from-page? ###
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    /**
     * build page folder list to select target...
     */
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    ### get project ####
    if (!($comment = Comment::getVisibleById($comment_ids[0]))) {
        $PH->abortWarning("could not get comment", ERROR_BUG);
    }
    if (!($project = Project::getVisibleById($comment->project))) {
        $PH->abortWarning("task without project?", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'company_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit tasks");
    $page->title = $project->name;
    $page->title_minor = __("Select one folder to move comments into");
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'commentsMoveToFolder'));
    echo new PageHeader();
    echo new PageContentOpen();
    echo __("... or select nothing to move to project root");
    ### write selected comments as hidden fields ###
    foreach ($comment_ids as $id) {
        if ($comment = Comment::getEditableById($id)) {
            echo "<input type=hidden name='comments_{$id}_chk' value='1'>";
        }
    }
    $list = new ListBlock_tasks();
    $list->reduced_header = true;
    $list->query_options['show_folders'] = true;
    $list->query_options['folders_only'] = true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    unset($list->columns['project']);
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    $list->no_items_html = __("No folders in this project...");
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project);
    echo "<input type=hidden name='from_selection' value='1'>";
    # keep flag to ungroup comments
    echo "<input type=hidden name='project' value='{$project->id}'>";
    $button_name = __("Move items");
    echo "<input class=button2 type=submit value='{$button_name}'>";
    $PH->go_submit = 'commentsMoveToFolder';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
/**
* 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();
}
/**
* list documentation of a project @ingroup pages
*/
function ProjViewDocu()
{
    global $PH;
    global $auth;
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    if (!($project = Project::getVisibleById($id))) {
        $PH->abortWarning("invalid project-id");
        return;
    }
    ### create from handle ###
    $PH->defineFromHandle(array('prj' => $project->id));
    $page = new Page();
    $page->cur_tab = 'projects';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->title = $project->name;
    $page->title_minor = __("Topics");
    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");
        }
    }
    ### page functions ###
    if ($project->isPersonVisibleTeamMember($auth->cur_user)) {
        $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('prj' => $project->id, 'task_category' => TCATEGORY_DOCU, 'task_show_folder_as_documentation' => 1), 'icon' => 'new', 'tooltip' => __('Create a new page'), 'name' => __('New topic'))));
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    ### init known filters for preset ###
    $list = new ListBlock_tasks(array('active_block_function' => 'tree'));
    $list->title = __('Topics');
    $list->query_options['category'] = TCATEGORY_DOCU;
    $list->query_options['status_min'] = 0;
    $list->query_options['status_max'] = 10;
    $list->query_options['order_by'] = 'order_id';
    ### redefine columns ###
    $c_new = array();
    foreach ($list->columns as $cname => $c) {
        if ($cname == '_select_col_') {
            $c_new[$cname] = $c;
        }
    }
    $list->columns = $c_new;
    $list->add_col(new ListBlockCol_TaskAsDocu());
    ### redefine list functions ###
    unset($list->functions['taskNew']);
    unset($list->functions['taskNewBug']);
    unset($list->functions['tasksCompleted']);
    unset($list->functions['tasksApproved']);
    unset($list->functions['tasksClosed']);
    if (!($project->settings & PROJECT_SETTING_ENABLE_EFFORTS)) {
        unset($list->functions['effortNew']);
    }
    #unset($list->functions['commentNew']);
    $list->no_items_html = __('No topics yet');
    $list->print_automatic($project, NULL, false);
    $PH->go_submit = 'taskNew';
    echo '<input type="hidden" name="prj" value="' . $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();
}
Exemple #4
0
function personViewTasks()
{
    global $PH;
    global $auth;
    ### get current project ###
    $id = getOnePassedId('person', 'people_*');
    if (!($person = Person::getVisibleById($id))) {
        $PH->abortWarning("invalid person-id");
        return;
    }
    $presets = array('all_tasks' => array('name' => __('all'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_NEW, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'new_tasks' => array('name' => __('new'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_NEW, 'max' => STATUS_NEW)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'open_tasks' => array('name' => __('open'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_OPEN, 'max' => STATUS_OPEN)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'blocked_tasks' => array('name' => __('blocked'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_BLOCKED, 'max' => STATUS_BLOCKED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'approve_tasks' => array('name' => __('needs approval'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_COMPLETED, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'closed_tasks' => array('name' => __('closed'), 'filter_empty_folders' => false, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_APPROVED, STATUS_CLOSED), 'min' => STATUS_APPROVED, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))));
    ## set preset location ##
    $preset_location = 'personViewTasks';
    $preset_id = 'all_tasks';
    # default value
    if ($tmp_preset_id = get('preset')) {
        if (isset($presets[$tmp_preset_id])) {
            $preset_id = $tmp_preset_id;
        }
        ### set cookie
        setcookie('STREBER_personViewTasks_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0);
    } else {
        if ($tmp_preset_id = get('STREBER_personViewTasks_preset')) {
            if (isset($presets[$tmp_preset_id])) {
                $preset_id = $tmp_preset_id;
            }
        }
    }
    ### create from handle ###
    $PH->defineFromHandle(array('person' => $person->id, 'preset_id' => $preset_id));
    $page = new Page();
    $page->cur_tab = 'people';
    $page->title = $person->name;
    $page->title_minor = __('Tasks', 'Page title add on');
    $page->type = __("Person");
    $page->crumbs = build_person_crumbs($person);
    $page->options = build_person_options($person);
    echo new PageHeader();
    echo new PageContentOpen();
    $order_by = get('sort_' . $PH->cur_page->id . "_tasks");
    require_once confGet('DIR_STREBER') . 'db/class_project.inc.php';
    $list = new ListBlock_tasks(array('active_block_function' => 'list'));
    unset($list->columns['created_by']);
    unset($list->columns['planned_start']);
    unset($list->columns['assigned_to']);
    //unset($list->columns['efforts_estimated']);
    $list->no_items_html = __('no tasks yet');
    $list->filters[] = new ListFilter_tasks();
    $preset = $presets[$preset_id];
    foreach ($preset['filters'] as $f_name => $f_settings) {
        switch ($f_name) {
            case 'task_status':
                $list->filters[] = new ListFilter_status_min(array('value' => $f_settings['min']));
                $list->filters[] = new ListFilter_status_max(array('value' => $f_settings['max']));
                break;
            default:
                trigger_error("Unknown filter setting {$f_name}", E_USER_WARNING);
                break;
        }
    }
    $filter_empty_folders = isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'] ? true : NULL;
    $page->print_presets(array('target' => $preset_location, 'project_id' => '', 'preset_id' => $preset_id, 'presets' => $presets, 'person_id' => $person->id));
    $list->query_options['assigned_to_person'] = $person->id;
    $list->query_options['person'] = $person->id;
    $list->print_automatic(NULL, NULL, true);
    echo '<input type="hidden" name="person" value="' . $person->id . '">';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemple #5
0
/**
* list all tasks assigned to person @ingroup pages
*/
function homeTasks()
{
    global $PH;
    global $auth;
    ### set up page ####
    $presets = array('all_tasks' => array('name' => __('all'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_NEW, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'tree'))), 'open_tasks' => array('name' => __('open'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED, STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'my_open_tasks' => array('name' => __('my open'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED), 'min' => STATUS_NEW, 'max' => STATUS_BLOCKED), 'assigned_to' => array('id' => 'assigned_to', 'visible' => true, 'active' => true, 'value' => $auth->cur_user->id)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('task_assign_to_0' => $auth->cur_user->id)), 'my_blocked_tasks' => array('name' => __('my blocked'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_BLOCKED), 'min' => STATUS_BLOCKED, 'max' => STATUS_BLOCKED), 'assigned_to' => array('id' => 'assigned_to', 'visible' => true, 'active' => true, 'value' => $auth->cur_user->id)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('task_assign_to_0' => $auth->cur_user->id)), 'blocked_tasks' => array('name' => __('blocked'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_BLOCKED), 'min' => STATUS_BLOCKED, 'max' => STATUS_BLOCKED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'needs_feedback' => array('name' => __('needs feedback'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'not_modified_by' => $auth->cur_user->id), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'approve_tasks' => array('name' => __('needs approval'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_COMPLETED, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'without_milestone' => array('name' => __('without milestone'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'for_milestone' => array('id' => 'for_milestone', 'visible' => true, 'active' => true, 'value' => 0)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'closed_tasks' => array('name' => __('closed'), 'filter_empty_folders' => false, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_APPROVED, STATUS_CLOSED), 'min' => STATUS_APPROVED, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))));
    ## set preset location ##
    $preset_location = 'homeTasks';
    $preset_id = 'open_tasks';
    # default value
    if ($tmp_preset_id = get('preset')) {
        if (isset($presets[$tmp_preset_id])) {
            $preset_id = $tmp_preset_id;
        }
        ### set cookie
        setcookie('STREBER_homeTasks_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0);
    } else {
        if ($tmp_preset_id = get('STREBER_homeTasks_preset')) {
            if (isset($presets[$tmp_preset_id])) {
                $preset_id = $tmp_preset_id;
            }
        }
    }
    $page = new Page();
    ### init known filters for preset ###
    $list = new ListBlock_tasks(array('active_block_function' => 'list'));
    $list->filters[] = new ListFilter_for_milestone();
    $list->filters[] = new ListFilter_category_in(array('value' => array(TCATEGORY_TASK, TCATEGORY_BUG)));
    $preset = $presets[$preset_id];
    foreach ($preset['filters'] as $f_name => $f_settings) {
        switch ($f_name) {
            case 'task_status':
                $list->filters[] = new ListFilter_status_min(array('value' => $f_settings['min']));
                $list->filters[] = new ListFilter_status_max(array('value' => $f_settings['max']));
                break;
            case 'assigned_to':
                $list->filters[] = new ListFilter_assigned_to(array('value' => $f_settings['value']));
                break;
            case 'for_milestone':
                $list->filters[] = new ListFilter_for_milestone(array('value' => $f_settings['value']));
                break;
            case 'not_modified_by':
                $list->filters[] = new ListFilter_not_modified_by(array('value' => $f_settings['value']));
                break;
            default:
                trigger_error("Unknown filter setting {$f_name}", E_USER_WARNING);
                break;
        }
    }
    $filter_empty_folders = isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'] ? true : NULL;
    ### create from handle ###
    $PH->defineFromHandle(array('preset_id' => $preset_id));
    ### setup page details ###
    $page->cur_tab = 'home';
    $page->options = build_home_options();
    $page->title = __("Your Tasks");
    $page->type = __('List', 'page type');
    $page->title_minor = renderTitleDate(time());
    echo new PageHeader();
    echo new PageContentOpen();
    $page->print_presets(array('target' => $preset_location, 'project_id' => '', 'preset_id' => $preset_id, 'presets' => $presets, 'person_id' => ''));
    ### remove assigned column (we know, who they are assigned to) ###
    unset($list->columns['assigned_to']);
    unset($list->columns['efforts']);
    unset($list->columns['project']);
    unset($list->columns['pub_level']);
    #    unset($list->columns['planned_end']);
    unset($list->block_functions['tree']);
    $list->query_options['assigned_to_person'] = $auth->cur_user->id;
    $list->print_automatic();
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
Exemple #6
0
/**
* Returns a list of folders for the given project.
* This is used for picking the destination folder for moving tasks across
* projects.
*/
function ajaxListProjectFolders()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'std/class_changeline.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_recentchanges.inc.php';
    require_once confGet('DIR_STREBER') . 'render/render_block.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_taskfolders.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_comments.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    header("Content-type: text/html; charset=utf-8");
    ### get project ####
    $project_id = getOnePassedId('prj');
    if (!($project = Project::getVisibleById($project_id))) {
        echo __("requested invalid project");
        exit;
        //$PH->abortWarning("task without project?", ERROR_BUG);
    }
    $list = new ListBlock_tasks();
    $list->query_options['show_folders'] = true;
    $list->query_options['folders_only'] = true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    unset($list->columns['project']);
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project, NULL);
    echo __("(or select nothing to move to project root)") . "<br> ";
    echo "<input type=hidden name='project' value='{$project->id}'>";
}
Exemple #7
0
/**
* view a task @ingroup pages
*/
function TaskView()
{
    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 ($task->category == TCATEGORY_DOCU || $task->category == TCATEGORY_FOLDER && $task->show_folder_as_documentation) {
        TaskViewAsDocu($task, $editable);
        exit;
    }
    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;
    $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)) {
        if ($editable) {
            $page->add_function(new PageFunction(array('target' => 'taskEdit', 'params' => array('tsk' => $task->id), 'icon' => 'edit', 'tooltip' => sprintf(__('Edit this %s'), $task->getLabel()), '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 ($editable) {
            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'))));
            }
            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'))));
            }
        }
        ### folder ###
        if ($task->category == TCATEGORY_FOLDER) {
            $page->add_function(new PageFunctionGroup(array('name' => __('new'))));
            $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('parent_task' => $task->id), 'icon' => 'new', 'tooltip' => __('new subtask for this folder'), 'name' => __('Task'))));
            $page->add_function(new PageFunction(array('target' => 'taskNewBug', 'params' => array('parent_task' => $task->id), 'icon' => 'new', 'tooltip' => __('new bug for this folder'), 'name' => __('Bug'))));
        } else {
            if ($task->isMilestoneOrVersion()) {
                $page->add_function(new PageFunctionGroup(array('name' => __('new'))));
                $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('parent_task' => $task->id, 'for_milestone' => $task->id), 'icon' => 'new', 'tooltip' => __('new task for this milestone'), 'name' => __('Task'))));
                $page->add_function(new PageFunction(array('target' => 'taskNewBug', 'params' => array('parent_task' => $task->id), 'icon' => 'new', 'tooltip' => __('new bug for this folder'), 'name' => __('Bug'))));
            }
        }
        ### normal task ###
        #else {
        #    if($editable) {
        #        $page->add_function(new PageFunction(array(
        #            'target'=>'tasksMoveToFolder',
        ##            'params'=>array('tsk'=>$task->id),
        #            'icon'=>'edit',
        #            'name'=>__('Move', 'page function to move current task'),
        #        )));
        #    }
        #
        #}
        if ($auth->cur_user->settings & USER_SETTING_ENABLE_BOOKMARKS) {
            $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'))));
            }
        }
        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'))));
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen_Columns();
    #--- write info-block ------------
    if ($task->isMilestoneOrVersion()) {
        measure_stop('current milestone');
        require_once confGet('DIR_STREBER') . 'blocks/current_milestone_block.inc.php';
        $block = new CurrentMilestoneBlock($project);
        $block->current_milestone = $task;
        $block->title = __("Open milestone");
        $block->render();
        measure_stop('current milestone');
    }
    $block = new PageBlock(array('title' => __("Summary", "Block title"), 'id' => 'summary'));
    $block->render_blockStart();
    echo "<div class=text>";
    ### milestones and versions ###
    if ($task->isMilestoneOrVersion()) {
        global $g_released_names;
        if ($task->is_released && isset($g_released_names[$task->is_released])) {
            echo "<div class=labeled><label>" . __("Released as", "Label in Task summary") . "</label>" . $g_released_names[$task->is_released] . " / " . renderDateHtml($task->time_released) . "</div>";
        }
    } else {
        if ($task->for_milestone) {
            if ($milestone = Task::getVisibleById($task->for_milestone)) {
                echo "<div class=labeled><label>" . __("For Milestone", "Label in Task summary") . "</label>" . $milestone->getLink(false) . "</div>";
            }
        }
        global $g_status_names;
        if ($status = $g_status_names[$task->status]) {
            echo "<div class=labeled><label>" . __("Status", "Label in Task summary") . "</label>{$status}</div>";
        }
        echo "<div class=labeled><label>" . __("Opened", "Label in Task summary") . "</label>" . renderDateHtml($task->date_start) . "</div>";
        if ($task->estimated) {
            echo "<div class=labeled><label>" . __("Estimated", "Label in Task summary") . "</label>" . renderDuration($task->estimated) . ' ';
            if ($task->estimated_max) {
                echo " ... " . renderDuration($task->estimated_max);
            }
            echo "</div>";
        }
        if ($task->completion) {
            echo "<div class=labeled><label>" . __("Completed", "Label in Task summary") . "</label>" . $task->completion . "%</div>";
        }
        if ($task->planned_start && $task->planned_start != "0000-00-00 00:00:00") {
            echo "<div class=labeled><label>" . __("Planned start", "Label in Task summary") . "</label>" . renderTimestamp($task->planned_start) . "</div>";
        }
        if ($task->planned_end && $task->planned_end != "0000-00-00 00:00:00") {
            echo "<div class=labeled><label>" . __("Planned end", "Label in Task summary") . "</label>" . renderTimestamp($task->planned_end) . "</div>";
        }
        if ($task->date_closed != "0000-00-00") {
            echo "<div class=labeled><label>" . __("Closed", "Label in Task summary") . "</label>" . renderDateHtml($task->date_closed) . "</div>";
        }
    }
    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>";
    }
    #}
    $sum_efforts = $task->getSumEfforts();
    if ($sum_efforts) {
        echo "<div class=labeled><label>" . __("Logged effort", "Label in task-summary") . "</label>" . $PH->getLink('taskViewEfforts', round($sum_efforts / 60 / 60, 1), array('task' => $task->id)) . "</div>";
    }
    if ($tps = $task->getAssignedPeople()) {
        $value = "";
        $sep = "";
        foreach ($tps as $tp) {
            $value .= $sep . $tp->getLink();
            $sep = ", ";
        }
        $label = __("Assigned to");
        echo "<div class=labeled><label>{$label}</label>{$value}</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();
    #--- navigation structure for documentation --------------------------------------------
    if ($task->category == TCATEGORY_FOLDER) {
        require_once confGet('DIR_STREBER') . 'lists/list_docustructure.inc.php';
        $list = new Block_DocuNavigation(array('current_task' => $task, 'root' => $task));
        $list->title = __("Further Documentation");
        $list->print_all();
    }
    require_once confGet('DIR_STREBER') . 'lists/list_files.inc.php';
    $list = new ListBlock_files();
    #$list->query_options['visible_only']= false;
    $list->query_options['parent_item'] = $task->id;
    $list->show_functions = false;
    unset($list->columns['status']);
    unset($list->columns['mimetype']);
    unset($list->columns['filesize']);
    unset($list->columns['created_by']);
    #unset($list->columns['download']);
    unset($list->columns['version']);
    unset($list->columns['_select_col_']);
    unset($list->columns['modified']);
    unset($list->columns['name']);
    unset($list->columns['thumbnail']);
    unset($list->block_functions['list']);
    unset($list->block_functions['grouped']);
    unset($list->functions['fileEdit']);
    unset($list->functions['filesDelete']);
    $list->title = __('Attached files');
    if ($editable) {
        $list->summary = buildFileUploadForm($task);
    }
    $list->print_automatic($project);
    $PH->go_submit = $PH->getValidPage('filesUpload')->id;
    echo new PageContentNextCol();
    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 task 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);
    }
    #--- issue report -------------------------------------------------------------
    if ($task->category == TCATEGORY_BUG && $task->issue_report) {
        require_once confGet('DIR_STREBER') . 'db/class_issue.inc.php';
        $issue = new Issue($task->issue_report);
        $buffer = "";
        if ($issue->severity) {
            global $g_severity_names;
            if (isset($g_severity_names[$issue->severity])) {
                $buffer .= '<div class=labeled><label>' . __("Severity", "label in issue-reports") . '</label>' . $g_severity_names[$issue->severity] . '</div>';
            }
        }
        if ($issue->severity) {
            global $g_reproducibility_names;
            if (isset($g_reproducibility_names[$issue->reproducibility])) {
                $buffer .= '<div class=labeled><label>' . __("Reproducibility", "label in issue-reports") . '</label>' . $g_reproducibility_names[$issue->reproducibility] . '</div>';
            }
        }
        if ($issue->plattform) {
            $buffer .= '<div class="labeled"><label>' . __('Platform') . '</label>' . asHtml($issue->plattform) . '</div>';
        }
        if ($issue->os) {
            $buffer .= '<div class=labeled><label>' . __('OS') . '</label>' . asHtml($issue->os) . '</div>';
        }
        if ($issue->version) {
            $buffer .= '<div class=labeled><label>' . __('Version') . '</label>' . asHtml($issue->version) . '</div>';
        }
        if ($issue->production_build) {
            $buffer .= '<div class=labeled><label>' . __('Build') . '</label>' . asHtml($issue->production_build) . '</div>';
        }
        if ($issue->steps_to_reproduce) {
            $text = wikifieldAsHtml($issue, 'steps_to_reproduce');
            $buffer .= '<div class="labeled separated"><label>' . __("Steps to reproduce", "label in issue-reports") . "</label>{$text}</div>";
        }
        if ($issue->expected_result) {
            $text = wikifieldAsHtml($issue, 'expected_result');
            $buffer .= '<div class="labeled separated"><label>' . __("Expected result", "label in issue-reports") . "</label>{$text}</div>";
        }
        if ($issue->suggested_solution) {
            $text = wikifieldAsHtml($issue, 'suggested_solution');
            $buffer .= '<div class="labeled separated"><label>' . __("Suggested Solution", "label in issue-reports") . "</label>{$text}</div>";
        }
        if ($buffer) {
            $block = new PageBlock(array('title' => __('Issue report'), 'id' => 'issue_report'));
            $block->render_blockStart();
            echo "<div class=text>";
            echo $buffer;
            echo "<b class=doclear></b>";
            echo "</div>";
            $block->render_blockEnd();
        }
    }
    #--- list tasks -------------------------------------------------------------
    if ($task->category == TCATEGORY_FOLDER || $task->getNumSubtasks() > 0) {
        $list = new ListBlock_tasks(array('active_block_function' => 'tree', 'title' => __('Sub tasks')));
        unset($list->columns['project']);
        unset($list->columns['created_by']);
        unset($list->columns['planned_start']);
        unset($list->columns['modified']);
        unset($list->columns['estimate_complete']);
        unset($list->columns['pub_level']);
        $list->filters[] = new ListFilter_status_max(array('value' => STATUS_COMPLETED));
        $list->filters[] = new ListFilter_category_in(array('value' => array(TCATEGORY_FOLDER, TCATEGORY_TASK, TCATEGORY_BUG)));
        $list->print_automatic($project, $task);
    }
    #--- list milestone-tasks ---------------------------------------------------
    if ($task->isOfCategory(array(TCATEGORY_MILESTONE, TCATEGORY_VERSION))) {
        $list = new ListBlock_tasks(array('active_block_function' => 'tree', 'title' => __('Open tasks for milestone')));
        $list->no_items_html = __('No open tasks for this milestone');
        unset($list->columns['project']);
        unset($list->columns['created_by']);
        unset($list->columns['planned_start']);
        unset($list->columns['modified']);
        unset($list->columns['for_milestone']);
        unset($list->columns['pub_level']);
        $list->query_options['status_max'] = STATUS_COMPLETED;
        $list->query_options['for_milestone'] = $task->id;
        $list->print_automatic($project, NULL, true);
    }
    #--- list change log ---------------
    if ($task->category == TCATEGORY_VERSION) {
        ### get resolved tasks ###
        if ($resolved = Task::getAll(array('project' => $task->project, 'resolved_version' => $task->id, 'status_min' => 0, 'status_max' => 200, 'order_by' => 'resolve_reason'))) {
            $block = new PageBlock(array('title' => __("Resolved tasks", "Block title"), 'id' => 'resolved_tasks'));
            $block->render_blockStart();
            echo "<div class=text>";
            $buffer = "<ul>";
            foreach ($resolved as $r) {
                if ($r->resolve_reason && isset($g_resolve_reason_names[$r->resolve_reason])) {
                    $reason = $g_resolve_reason_names[$r->resolve_reason] . ": ";
                } else {
                    $reason = "";
                }
                $buffer .= '<li>' . $reason . $r->getLink(false) . '</li>';
            }
            $buffer .= "</ul>";
            echo $buffer;
            echo "</div>";
            $block->render_blockEnd();
        }
    }
    require_once confGet('DIR_STREBER') . 'blocks/comments_on_item_block.inc.php';
    print new CommentsOnItemBlock($task);
    #--- task quickedit form -------------------------------------------------------------
    echo new PageContentClose();
    echo new PageHtmlEnd();
    ## is viewed by user ##
    $task->nowViewedByUser();
}
Exemple #8
0
/**
* move files to folder...
*
* NOTE: this works either...
* - directly by passing a target folder in 'folder' or 'folders_*'
* - in two steps, whereas
*   - the passed task-ids are keept as hidden fields,
*   - a list with folders is been rendered
*   - a flag 'from_selection' is set
*   - after submit, the kept tasks are moved to 'folders_*'
*
*/
function FilesMoveToFolder()
{
    global $PH;
    $file_ids = getPassedIds('file', 'files_*');
    if (!$file_ids) {
        $PH->abortWarning(__("Select some files to move"));
        exit;
    }
    /**
     * by default render list of folders...
     */
    $target_id = -1;
    /**
     * ...but, if folder was given, directly move files...
     */
    $folder_ids = getPassedIds('folder', 'folders_*');
    if (count($folder_ids) == 1) {
        if ($folder_task = Task::getVisibleById($folder_ids[0])) {
            $target_id = $folder_task->id;
        }
    } else {
        if (get('from_selection')) {
            $target_id = 0;
        }
    }
    if ($target_id != -1) {
        if ($target_id != 0) {
            if (!($target_task = Task::getEditableById($target_id))) {
                $PH->abortWarning(__("insufficient rights"));
            }
            ### get path of target to check for cycles ###
            $parent_tasks = $target_task->getFolder();
            $parent_tasks[] = $target_task;
        } else {
            $parent_tasks = array();
        }
        $count = 0;
        foreach ($file_ids as $id) {
            if ($file = File::getEditableById($id)) {
                $file->parent_item = $target_id;
                $file->update();
            } else {
                $PH->messages[] = sprintf(__("Can not edit file %s"), $file->name);
            }
        }
        ### return to from-page? ###
        if (!$PH->showFromPage()) {
            $PH->show('home');
        }
        exit;
    }
    #else if($target_id != -1) {
    #    $PH->abortWarning(__("insufficient rights to edit any of the selected items"));
    #}
    /**
     * build page folder lists...
     */
    ### get project ####
    if (!($file = File::getVisibleById($file_ids[0]))) {
        $PH->abortWarning("could not get file", ERROR_BUG);
    }
    if (!($project = Project::getVisibleById($file->project))) {
        $PH->abortWarning("file without project?", ERROR_BUG);
    }
    $page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'company_name'));
    $page->cur_tab = 'projects';
    $page->type = __("Edit files");
    $page->title = "{$project->name}";
    $page->title_minor = __("Select folder to move files into");
    $page->crumbs = build_project_crumbs($project);
    $page->options[] = new NaviOption(array('target_id' => 'filesMoveToFolder'));
    echo new PageHeader();
    echo new PageContentOpen();
    ### write files as hidden entry ###
    foreach ($file_ids as $id) {
        if ($file = File::getEditableById($id)) {
            echo "<input type=hidden name='files_{$id}_chk' value='1'>";
        }
    }
    require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
    $list = new ListBlock_tasks();
    $list->query_options['show_folders'] = true;
    #$list->query_options['folders_only']= true;
    $list->query_options['project'] = $project->id;
    $list->groupings = NULL;
    $list->block_functions = NULL;
    $list->id = 'folders';
    $list->no_items_html = __('No folders available');
    unset($list->columns['status']);
    unset($list->columns['date_start']);
    unset($list->columns['days_left']);
    unset($list->columns['created_by']);
    unset($list->columns['label']);
    unset($list->columns['project']);
    $list->functions = array();
    $list->active_block_function = 'tree';
    $list->print_automatic($project, NULL);
    echo __("(or select nothing to move to project root)") . "<br> ";
    echo "<input type=hidden name='from_selection' value='1'>";
    # keep flag to ungroup files
    echo "<input type=hidden name='project' value='{$project->id}'>";
    $button_name = __("Move items");
    echo "<input class=button2 type=submit value='{$button_name}'>";
    $PH->go_submit = 'filesMoveToFolder';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
/**
* list tasks of a project @ingroup pages
*/
function projViewTasks()
{
    global $PH;
    global $auth;
    ### get current project ###
    $id = getOnePassedId('prj', 'projects_*');
    if (!($project = Project::getVisibleById($id))) {
        $PH->abortWarning("invalid project-id");
        return;
    }
    ### get upcoming or selected milestone ###
    /*
    pixtur: 2008-09-60
    WARNING: Selecting a milestone directly to limit the viewed tasks
    does not work because editing a task with a milestone will compromize
    the following task list. I have no idea, why this code is in here,
    or weather it is required at all.
    */
    $for_milestone = intval(get("for_milestone"));
    $milestone = NULL;
    if ($for_milestone) {
        $milestone = Task::getVisibleById($for_milestone);
    }
    #if($milestone= $project->getNextMilestone()) {
    #    $for_milestone= $milestone->id;
    #}
    $presets = array('all_tasks' => array('name' => __('all'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_NEW, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'tree'))), 'open_tasks' => array('name' => __('open'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED, STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'my_open_tasks' => array('name' => __('my open'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED), 'min' => STATUS_NEW, 'max' => STATUS_BLOCKED), 'assigned_to' => array('id' => 'assigned_to', 'visible' => true, 'active' => true, 'value' => $auth->cur_user->id)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('task_assign_to_0' => $auth->cur_user->id)), 'next_milestone' => array('name' => __('for milestone'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => false, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED, STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'for_milestone' => array('id' => 'for_milestone', 'visible' => true, 'active' => true, 'value' => $for_milestone)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('for_milestone' => $for_milestone)), 'needs_feedback' => array('name' => __('modified'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'not_modified_by' => $auth->cur_user->id), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'approve_tasks' => array('name' => __('needs approval'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_COMPLETED, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'without_milestone' => array('name' => __('without milestone'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'for_milestone' => array('id' => 'for_milestone', 'visible' => true, 'active' => true, 'value' => 0)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'closed_tasks' => array('name' => __('closed'), 'filter_empty_folders' => false, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_APPROVED, STATUS_CLOSED), 'min' => STATUS_APPROVED, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))));
    ## set preset location ##
    $preset_location = 'projViewTasks';
    $preset_id = 'open_tasks';
    # default value
    if ($tmp_preset_id = get('preset')) {
        if (isset($presets[$tmp_preset_id])) {
            $preset_id = $tmp_preset_id;
        }
        ### set cookie
        setcookie('STREBER_projViewTasks_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0);
    } else {
        if ($tmp_preset_id = get('STREBER_projViewTasks_preset')) {
            if (isset($presets[$tmp_preset_id])) {
                $preset_id = $tmp_preset_id;
            }
        }
    }
    if ($milestone) {
        ### create from handle ###
        $PH->defineFromHandle(array('prj' => $project->id, 'preset_id' => $preset_id, 'for_milestone' => $milestone->id));
    } else {
        ### create from handle ###
        $PH->defineFromHandle(array('prj' => $project->id, 'preset_id' => $preset_id));
    }
    $page = new Page();
    ### init known filters for preset ###
    $list = new ListBlock_tasks(array('active_block_function' => 'tree'));
    $list->filters[] = new ListFilter_category_in(array('value' => array(TCATEGORY_TASK, TCATEGORY_BUG)));
    $preset = $presets[$preset_id];
    foreach ($preset['filters'] as $f_name => $f_settings) {
        switch ($f_name) {
            case 'task_status':
                $list->filters[] = new ListFilter_status_min(array('value' => $f_settings['min']));
                $list->filters[] = new ListFilter_status_max(array('value' => $f_settings['max']));
                break;
            case 'assigned_to':
                $list->filters[] = new ListFilter_assigned_to(array('value' => $f_settings['value']));
                break;
            case 'for_milestone':
                $list->filters[] = new ListFilter_for_milestone(array('value' => $f_settings['value']));
                break;
            case 'not_modified_by':
                $list->filters[] = new ListFilter_not_modified_by(array('value' => $f_settings['value']));
                break;
            default:
                trigger_error("Unknown filter setting {$f_name}", E_USER_WARNING);
                break;
        }
    }
    $filter_empty_folders = isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'] ? true : NULL;
    $page->cur_tab = 'projects';
    $page->crumbs = build_project_crumbs($project);
    $page->options = build_projView_options($project);
    $page->title = $project->name;
    if (isset($preset['name'])) {
        $page->title_minor = $preset['name'];
        if ($preset_id == 'next_milestone' && isset($milestone) && isset($milestone->name)) {
            $page->title_minor = __('Milestone') . ' ' . $milestone->name;
        }
    } else {
        $page->title_minor = __("Tasks");
    }
    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");
        }
    }
    ### page functions ###
    $new_task_options = isset($preset['new_task_options']) ? $preset['new_task_options'] : array();
    if ($project->isPersonVisibleTeamMember($auth->cur_user)) {
        #$page->add_function(new PageFunctionGroup(array(
        #    'name'=>__('new'),
        #)));
        if ($preset_id != 'next_milestone') {
            $page->add_function(new PageFunction(array('target' => 'taskNewFolder', 'params' => array('prj' => $project->id) + $new_task_options, 'icon' => 'new', 'tooltip' => __('Create a new folder for tasks and files'))));
        }
        $page->add_function(new PageFunction(array('target' => 'taskNew', 'params' => array('prj' => $project->id) + $new_task_options, 'icon' => 'new', 'tooltip' => __('new subtask for this folder'))));
        if ($project->settings & PROJECT_SETTING_ENABLE_BUGS) {
            $page->add_function(new PageFunction(array('target' => 'taskNewBug', 'params' => array('prj' => $project->id, 'add_issue' => 1) + $new_task_options, 'icon' => 'new', 'tooltip' => __('Create task with issue-report'))));
        }
    }
    ### render title ###
    echo new PageHeader();
    echo new PageContentOpen();
    ### list available presets ###
    if ($page->format != FORMAT_CSV) {
        $page->print_presets(array('target' => $preset_location, 'project_id' => $project->id, 'preset_id' => $preset_id, 'presets' => $presets, 'person_id' => ''));
    }
    if ($page->format == FORMAT_HTML) {
        $PH->go_submit = 'taskNew';
        echo '<input type="hidden" name="prj" value="' . $id . '">';
        /**
         * add preset specific options (like milestone,etc) as hidden fields
         * e.i. if we list tasks for a milestone, new tasks require to belong to this
         * milestone, otherwise they are not visible after creation
         */
        foreach ($new_task_options as $name => $value) {
            echo "<input type=hidden name='{$name}' value='{$value}'>";
        }
        ### Link to start cvs export ###
        $format = get('format');
        if ($format == FORMAT_HTML || $format == '') {
            $list->footer_links[] = $PH->getCSVLink();
        }
    }
    if ($for_milestone) {
        $list->filters[] = new ListFilter_for_milestone(array('value' => $for_milestone));
    }
    $list->show_project_folder = false;
    unset($list->columns['project']);
    unset($list->columns['planned_start']);
    /**
     * NOTE: pixtur 2006-10-13
     * for a clean version of this list with a AJAX-driven side board
     * following columns should be hidden:
     */
    if (confGet('TASKDETAILS_IN_SIDEBOARD')) {
        unset($list->columns['assigned_to']);
        #unset($list->columns['for_milestone']);
        unset($list->columns['estimate_complete']);
        unset($list->columns['pub_level']);
        #unset($list->columns['_select_col_']);
        unset($list->columns['label']);
    }
    if (!confGet('TASK_LIST_EFFORT_COLUMN')) {
        unset($list->columns['efforts']);
    }
    $list->no_items_html = __('No tasks');
    $list->print_automatic($project, NULL, $filter_empty_folders);
    #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();
}