/**
  * print a complete list as html
  * - use filters
  * - use check list style (tree, list, grouped)
  * - check customization-values
  * - check sorting
  * - get objects from database
  *
  */
 public function print_automatic()
 {
     require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
     global $PH;
     if (!($this->active_block_function = $this->getBlockStyleFromCookie())) {
         $this->active_block_function = 'list';
     }
     $this->initOrderQueryOption();
     ### grouped view ###
     if ($this->active_block_function == 'grouped') {
         $this->group_by = get("blockstyle_{$PH->cur_page->id}_{$this->id}_grouping");
         /**
          * @@@ later use only once...
          *
          *   $this->columns= filterOptions($this->columns,"CURPAGE.BLOCKS[{$this->id}].STYLE[{$this->active_block_function}].COLUMNS");
          */
         if (isset($this->columns[$this->group_by])) {
             unset($this->columns[$this->group_by]);
         }
         ### prepend key to sorting ###
         if (isset($this->query_options['order_by'])) {
             $this->query_options['order_by'] = $this->groupings->getActiveFromCookie() . "," . $this->query_options['order_by'];
         } else {
             $this->query_options['order_by'] = $this->groupings->getActiveFromCookie();
         }
     }
     $versions = Task::getAll($this->query_options);
     $this->render_list($versions);
 }
 public function __toString()
 {
     global $PH;
     global $auth;
     require_once confGet('DIR_STREBER') . 'lists/list_files.inc.php';
     $files = File::getall(array('parent_item' => $this->item_with_attachments->id));
     $list = new ListBlock_files();
     $list->reduced_header = true;
     $list->query_options['parent_item'] = $this->item_with_attachments->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['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 ($this->item_with_attachments->isEditable()) {
         $list->summary = buildFileUploadForm($this->item_with_attachments);
     }
     $list->print_automatic($project);
     $PH->go_submit = $PH->getValidPage('filesUpload')->id;
     return "";
 }
Beispiel #3
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();
}
/**
* Remove items of certain type and autho
*
*/
function itemsRemoveManyPreview()
{
    global $PH;
    global $auth;
    ### cancel ? ###
    if (get('form_do_cancel')) {
        if (!$PH->showFromPage()) {
            $PH->show('home', array());
        }
        exit;
    }
    $PH->go_submit = 'itemsRemoveManySubmit';
    $page = new Page();
    $page->cur_tab = 'home';
    $page->title = __('Following items will be removed');
    $page->title_minor = '';
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
    $form = new PageForm();
    $form->button_cancel = true;
    renderPreviewList();
    echo $form;
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
/**
* Remove items of certain type and autho
*
* This method can be used to remove spam comments or attachments
* 
* 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 itemsRemoveMany()
{
    global $PH;
    global $auth;
    $PH->go_submit = 'itemsRemoveManyPreview';
    $page = new Page();
    $page->cur_tab = 'home';
    $page->title = __('Remove many items');
    $page->title_minor = '';
    echo new PageHeader();
    echo new PageContentOpen();
    require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
    $form = new PageForm();
    $form->button_cancel = true;
    ### author
    $people = array(0 => 'anybody');
    foreach (Person::getPeople() as $p) {
        $people[$p->id] = $p->nickname;
    }
    $form->add(new Form_Dropdown('person', __("Created by"), array_flip($people), 0));
    $form->add(new Form_Checkbox('type_comment', __("Comments"), true));
    $form->add(new Form_Checkbox('only_spam_comments', __("Only comments that look like spam"), true));
    $form->add(new Form_Checkbox('type_task', __("Tasks"), false));
    $form->add(new Form_Checkbox('type_topic', __("Topic"), false));
    $form->add(new Form_DateTime('time_start', __('starting at', 'label for time filter'), getGMTString(time() - 7 * 24 * 60 * 60)));
    $form->add(new Form_DateTime('time_end', __('ending at', 'label for time filter'), getGMTString(time() + 60 * 60)));
    echo $form;
    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();
}
/**
* do some checks before doing anything serious
*
* This file is assumed to be php4 valid.
* - will exit script on errors!
*/
function validateEnvironment()
{
    # NOTE: it's weird that we have to use strings for referring to functions...
    foreach (array('testPhpVersion', 'testDb', 'testInstallDirectoryExists') as $test_function) {
        $result = $test_function();
        if ($result !== true) {
            ### Set uft8
            header("Content-type: text/html; charset=utf-8");
            ### Disable page caching ###
            header("Expires: -1");
            header("Cache-Control: post-check=0, pre-check=0");
            header("Pragma: no-cache");
            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
            echo sprintf(confGet('MESSAGE_OFFLINE'), confGet('EMAIL_ADMINISTRATOR'), confGet('EMAIL_ADMINISTRATOR'));
            echo $result;
            exit;
        }
    }
    return true;
}
Beispiel #8
0
 function render_blockFooter()
 {
     global $PH;
     global $g_valid_login_params;
     $form = new PageForm();
     $form->add(new Form_Input('login_name', __('Nickname', 'label in login form'), ''));
     $form->add(new Form_Password('login_password', __('Password', 'label in login form'), ''));
     #$form->form_options[]="<span class=option><input name='login_forgot_password' class='checker' type=checkbox>".__("I forgot my password")."</span>";
     $form->form_options[] = $PH->getLink('loginForgotPassword');
     if (confGet('ANONYMOUS_USER')) {
         $form->form_options[] = $PH->getLink('home', __("Continue anonymously"));
     }
     ### add probably go-values as hidden fields ###
     $go_after = NULL;
     if (confGet('USE_MOD_REWRITE') && get('go') == 'globalView') {
         $go_after = get('id');
         if ($go_after == 'login') {
             $go_after = '';
         }
     } else {
         $go_after = get('go');
     }
     if ($go_after != "" && $go_after != 'logout' && $go_after != 'loginForm' && $go_after != 'loginFormSubmit') {
         $form->add(new Form_Hiddenfield('go_after', '', $go_after));
         foreach ($g_valid_login_params as $var) {
             if ($value = get($var)) {
                 $form->add(new Form_Hiddenfield($var, '', $value));
             }
         }
     }
     ### guess user's local time with javascript ###
     echo "<input type=hidden id=user_timeoffset name=user_timeoffset>";
     echo '<script type="text/javascript">
     var now = new Date();document.getElementById("user_timeoffset").value= (now.getHours() + ":" + now.getMinutes() +":"+ now.getSeconds());
     </script>';
     echo $form;
     #$this->render_blockEnd();
     $PH->go_submit = 'loginFormSubmit';
 }
Beispiel #9
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();
}
/**
* display efforts for current user  @ingroup pages
*
* @NOTE 
* - actually this is an excact copy for personViewEfforts
* - this is of course not a good solution, but otherwise the breadcrumbs would change
*
*/
function homeListEfforts()
{
    global $PH;
    global $auth;
    require_once confGet('DIR_STREBER') . 'db/class_effort.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_efforts.inc.php';
    ### get current project ###
    $person = $auth->cur_user;
    $presets = array('all_efforts' => array('name' => __('all'), 'filters' => array('effort_status' => array('id' => 'effort_status', 'visible' => true, 'active' => true, 'min' => EFFORT_STATUS_NEW, 'max' => EFFORT_STATUS_BALANCED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'new_efforts' => array('name' => __('new'), 'filters' => array('effort_status' => array('id' => 'effort_status', 'visible' => true, 'active' => true, 'min' => EFFORT_STATUS_NEW, 'max' => EFFORT_STATUS_NEW)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'open_efforts' => array('name' => __('open'), 'filters' => array('effort_status' => array('id' => 'effort_status', 'visible' => true, 'active' => true, 'min' => EFFORT_STATUS_OPEN, 'max' => EFFORT_STATUS_OPEN)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'discounted_efforts' => array('name' => __('discounted'), 'filters' => array('effort_status' => array('id' => 'effort_status', 'visible' => true, 'active' => true, 'min' => EFFORT_STATUS_DISCOUNTED, 'max' => EFFORT_STATUS_DISCOUNTED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'notchargeable_efforts' => array('name' => __('not chargeable'), 'filters' => array('effort_status' => array('id' => 'effort_status', 'visible' => true, 'active' => true, 'min' => EFFORT_STATUS_NOTCHARGEABLE, 'max' => EFFORT_STATUS_NOTCHARGEABLE)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'balanced_efforts' => array('name' => __('balanced'), 'filters' => array('effort_status' => array('id' => 'effort_status', 'visible' => true, 'active' => true, 'min' => EFFORT_STATUS_BALANCED, 'max' => EFFORT_STATUS_BALANCED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_logout' => array('name' => __('last logout'), 'filters' => array('last_logout' => array('id' => 'last_logout', 'visible' => true, 'active' => true, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_week' => array('name' => __('1 week'), 'filters' => array('last_weeks' => array('id' => 'last_weeks', 'visible' => true, 'active' => true, 'factor' => 7, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_two_weeks' => array('name' => __('2 weeks'), 'filters' => array('last_weeks' => array('id' => 'last_weeks', 'visible' => true, 'active' => true, 'factor' => 14, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_three_weeks' => array('name' => __('3 weeks'), 'filters' => array('last_weeks' => array('id' => 'last_weeks', 'visible' => true, 'active' => true, 'factor' => 21, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'last_month' => array('name' => __('1 month'), 'filters' => array('last_weeks' => array('id' => 'last_weeks', 'visible' => true, 'active' => true, 'factor' => 28, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))), 'prior' => array('name' => __('prior'), 'filters' => array('prior' => array('id' => 'prior', 'visible' => true, 'active' => true, 'factor' => 29, 'value' => $auth->cur_user->id)), 'list_settings' => array('changes' => array('hide_columns' => array(''), 'style' => 'list'))));
    ## set preset location ##
    $preset_location = 'homeListEfforts';
    $preset_id = 'all_efforts';
    # default value
    if ($tmp_preset_id = get('preset')) {
        if (isset($presets[$tmp_preset_id])) {
            $preset_id = $tmp_preset_id;
        }
        ### set cookie
        setcookie('STREBER_homeListEfforts_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0);
    } else {
        if ($tmp_preset_id = get('STREBER_homeListEfforts_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 = 'home';
    $page->title = __("Your efforts");
    $page->title_minor = __('Efforts', 'Page title add on');
    $page->type = __("Person");
    #$page->crumbs = build_person_crumbs($person);
    $page->options = build_home_options($person);
    echo new PageHeader();
    echo new PageContentOpen();
    $order_by = get('sort_' . $PH->cur_page->id . "_efforts");
    require_once confGet('DIR_STREBER') . 'db/class_effort.inc.php';
    /*$efforts= Effort::getAll(array(
          'person'    => $person->id,
          'order_by'  => $order_by,
      ));*/
    $list = new ListBlock_efforts();
    unset($list->functions['effortNew']);
    unset($list->functions['effortNew']);
    $list->no_items_html = __('no efforts yet');
    $list->filters[] = new ListFilter_efforts();
    $preset = $presets[$preset_id];
    foreach ($preset['filters'] as $f_name => $f_settings) {
        switch ($f_name) {
            case 'effort_status':
                $list->filters[] = new ListFilter_effort_status_min(array('value' => $f_settings['min']));
                $list->filters[] = new ListFilter_effort_status_max(array('value' => $f_settings['max']));
                break;
            case 'last_logout':
                $list->filters[] = new ListFilter_last_logout(array('value' => $f_settings['value']));
                break;
            case 'last_weeks':
                $list->filters[] = new ListFilter_min_week(array('value' => $f_settings['value'], 'factor' => $f_settings['factor']));
                break;
            case 'prior':
                $list->filters[] = new ListFilter_max_week(array('value' => $f_settings['value'], 'factor' => $f_settings['factor']));
                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['order_by'] = $order_by;
    $list->query_options['person'] = $person->id;
    $list->print_automatic();
    //$list->render_list($efforts);
    echo '<input type="hidden" name="person" value="' . $person->id . '">';
    echo new PageContentClose();
    echo new PageHtmlEnd();
}
 protected function _render_commentField()
 {
     global $PH;
     echo "<div class=footer_form>";
     require_once confGet('DIR_STREBER') . "render/render_form.inc.php";
     $project = new Project($this->item_with_comments->project);
     $form = new PageForm();
     $form->button_cancel = false;
     $form->add(new Form_CustomHTML('<h3>' . __("Add Comment") . "</h3>"));
     ### Comment ###
     $comment_name = '';
     $comment = new Comment(array('id' => 0, 'name' => $comment_name));
     $e = $comment->fields['description']->getFormElement($comment, __('Comment'));
     $e->rows = 8;
     $form->add($e);
     $form->add($comment->fields['name']->getFormElement($comment, __('Summary')));
     ### request feedback
     $form->add(buildRequestFeedbackInput($project));
     /**
      * to reduce spam, enforce captcha test for guests
      */
     global $auth;
     if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
         $form->addCaptcha();
     }
     ### some required hidden fields for correct data passing ###
     $form->add(new Form_HiddenField('comment_task', '', $this->item_with_comments->id));
     $form->add(new Form_HiddenField('comment', '', 0));
     if ($return = get('return')) {
         $form->add(new Form_HiddenField('return', '', asHtml($return)));
     }
     $PH->go_submit = 'commentEditSubmit';
     echo $form;
     echo "</div>";
 }
Beispiel #12
0
 function render_tr(&$obj, $style = "")
 {
     if (!isset($obj) || !$obj instanceof Effort) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     if ($obj->as_duration) {
         echo "<td>-</td>";
     } else {
         $tmp = mysqlDatetime2utc($obj->time_start);
         $day_time_start = confGet('DAYGRAPH_START_HOUR') * 60 * 60;
         $day_time_end = confGet('DAYGRAPH_END_HOUR') * 60 * 60;
         $stretch = confGet('DAYGRAPH_WIDTH') / ($day_time_end - $day_time_start);
         $time_start = round(($tmp['hour'] * 60 * 60 + $tmp['min'] * 60 + $tmp['sec'] - $day_time_start) * $stretch, 0);
         if ($time_start < 0) {
             $time_start = 0;
         }
         $tmp = mysqlDatetime2utc($obj->time_end);
         $time_end = round(($tmp['hour'] * 60 * 60 + $tmp['min'] * 60 + $tmp['sec'] - $day_time_start) * $stretch, 0);
         if ($time_end < $time_start) {
             $time_end = 0;
         }
         $time_len = $time_end - $time_start;
         echo "<td>";
         echo "<nobr>";
         echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$time_start}px;height:3px;'>";
         echo "<img src='" . getThemeFile("img/pixel.gif") . "' style='width:{$time_len}px;height:12px;background-color:#f00;'>";
         echo "</nobr>";
         echo "</td>";
     }
 }
Beispiel #13
0
 /**
  * Depending on the MOD_REWRITE-setting, urls inside the Email have to look differently
  */
 protected function getUrlToItem($id)
 {
     $url = confGet('SELF_PROTOCOL') . '://' . confGet('SELF_URL');
     # returns something like http://localhost/streber/index.php
     if (confGet('USE_MOD_REWRITE')) {
         $url = str_replace('index.php', '', $url);
         return $url . "/" . intval($id);
     } else {
         return $url . "?go=itemView&id=" . intval($id);
     }
 }
    exit;
}
# streber - a php based project management system
# Copyright (c) 2005 Thomas Mann - thomas@pixtur.de
# Distributed under the terms and conditions of the GPL as stated in docs/license.txt
/**\file
 * pages relating to people
 *
 * @author Thomas Mann
 *
 */
require_once confGet('DIR_STREBER') . 'db/class_task.inc.php';
require_once confGet('DIR_STREBER') . 'db/class_project.inc.php';
require_once confGet('DIR_STREBER') . 'db/class_person.inc.php';
require_once confGet('DIR_STREBER') . 'db/db_itemchange.inc.php';
require_once confGet('DIR_STREBER') . 'render/render_list.inc.php';
/**
* 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
Beispiel #15
0
 /**
  * tries to build a valid a href-link to an item.
  *
  * - uses $this->name
  * - sets -this-html
  * - does all the neccessary security checks, styles and conversions
  */
 static function renderLinkFromItemId($target_id, $name = "")
 {
     global $PH;
     $target_id = intval($target_id);
     $html = "";
     if (!($item = DbProjectItem::getVisibleById($target_id))) {
         $html = '<em>' . sprintf(__("Unkwown item %s"), $target_id) . '</em>';
     } else {
         switch ($item->type) {
             case ITEM_TASK:
                 if ($task = Task::getVisibleById($item->id)) {
                     $style_isdone = $task->status >= STATUS_COMPLETED ? 'isDone' : '';
                     if ($name) {
                         $html = $PH->getLink('taskView', $name, array('tsk' => $task->id), $style_isdone, true);
                     } else {
                         $html = $task->getLink(false);
                     }
                 }
                 break;
             case ITEM_FILE:
                 require_once confGet('DIR_STREBER') . "db/class_file.inc.php";
                 if ($file = File::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('fileDownloadAsImage', $name, array('file' => $file->id), NULL, true);
                     } else {
                         $html = $PH->getLink('fileDownloadAsImage', $file->name, array('file' => $file->id));
                     }
                 }
                 break;
             case ITEM_COMMENT:
                 require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
                 if ($comment = Comment::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('commentView', $name, array('comment' => $comment->id), NULL, true);
                     } else {
                         $html = $PH->getLink('commentView', $comment->name, array('comment' => $comment->id));
                     }
                 }
                 break;
             case ITEM_PERSON:
                 if ($person = Person::getVisibleById($item->id)) {
                     if ($name) {
                         $html = $PH->getLink('personView', $name, array('person' => $person->id), NULL, true);
                     } else {
                         $html = $PH->getLink('personView', $person->name, array('person' => $person->id));
                     }
                 }
                 break;
             case ITEM_PROJECT:
                 if ($project = Project::getVisibleById($item->id)) {
                     if ($name == "") {
                         $name = asHtml($project->name);
                     }
                     $html = $PH->getLink('projView', $name, array('prj' => $project->id), NULL, true);
                 }
                 break;
             default:
                 $html = '<em>' . sprintf(__('Cannot link to item #%s of type %s'), intval($target_id), $item->type) . '</em>';
                 break;
         }
     }
     return $html;
 }
Beispiel #16
0
 /**
  * getAssignedPeople
  */
 function getAssignedPeople($visible_only = true)
 {
     global $auth;
     $prefix = confGet('DB_TABLE_PREFIX');
     $dbh = new DB_Mysql();
     $order_by = "pers.name";
     $query_str = "SELECT i.*, pers.* from {$prefix}item i, {$prefix}person pers, {$prefix}taskperson tp, {$prefix}item itp\r\n            WHERE\r\n                pers.state = 1\r\n\r\n            AND pers.id = i.id\r\n            AND pers.id = tp.person\r\n                      AND tp.task= {$this->id}\r\n                      AND tp.id = itp.id\r\n                              AND itp.state = 1\r\n\r\n            ORDER BY {$order_by}";
     $sth = $dbh->prepare($query_str);
     $sth->execute("", 1);
     $tmp = $sth->fetchall_assoc();
     $people = array();
     #--- return all ---
     if (!$visible_only || $auth->cur_user->user_rights & RIGHT_PROJECT_ASSIGN) {
         foreach ($tmp as $t) {
             $people[] = new Person($t);
         }
         return $people;
     } else {
         $project = Project::getById($this->project);
         foreach ($tmp as $t) {
             $p = new Person($t);
             if ($project->isPersonVisibleTeamMember($p)) {
                 $people[] = $p;
             }
         }
         return $people;
     }
 }
 static function getItemChanges($args = NULL)
 {
     global $auth;
     $prefix = confGet('DB_TABLE_PREFIX');
     ### default params ###
     $item = NULL;
     $date_min = NULL;
     $date_max = NULL;
     $person = NULL;
     $field = NULL;
     $project = NULL;
     $order_by = 'modified';
     ### filter params ###
     if ($args) {
         foreach ($args as $key => $value) {
             if (!isset(${$key}) && !is_null(${$key}) && !${$key} === "") {
                 trigger_error("unknown parameter", E_USER_NOTICE);
             } else {
                 ${$key} = $value;
             }
         }
     }
     $str_project = $project ? "AND c.project= " . intval($project) : '';
     $str_item = $item ? "AND c.item=" . intval($item) : '';
     $str_date_min = $date_min ? "AND c.modified >= '" . asCleanString($date_min) . "'" : '';
     $str_date_max = $date_max ? "AND c.modified <= '" . asCleanString($date_max) . "'" : '';
     $str_field = $field ? "AND c.field ='" . asCleanString($field) . "'" : '';
     $str_person = $person ? "AND c.modified_by = " . intval($person) : '';
     ### show all ###
     $str_query = "SELECT c.*  from {$prefix}itemchange c\r\n            WHERE 1\r\n            {$str_project}\r\n            {$str_item}\r\n            {$str_person}\r\n            {$str_field}\r\n            {$str_date_max}\r\n            {$str_date_min}\r\n            " . getOrderByString($order_by);
     $dbh = new DB_Mysql();
     $sth = $dbh->prepare($str_query);
     $sth->execute("", 1);
     $tmp = $sth->fetchall_assoc();
     $item_changes = array();
     foreach ($tmp as $t) {
         $c = new ItemChange($t);
         $item_changes[] = $c;
     }
     return $item_changes;
 }
Beispiel #18
0
 /**
  * records history events in rss/rss_$project->id.xml
  *
  * must be called from a project-related page!
  *
  *
  * @param project - current project object used in: proj.inc.php <- function call
  */
 static function updateRSS($project)
 {
     global $PH;
     global $auth;
     if (!$project) {
         return NULL;
     }
     /**
      * only show changes by others
      */
     if (Auth::isAnonymousUser()) {
         $not_modified_by = NULL;
     } else {
         $not_modified_by = $auth->cur_user->id;
     }
     ### get all the changes (array of history items) ##
     $changes = ChangeLine::getChangeLines(array('project' => $project->id, 'unviewed_only' => false, 'limit_rowcount' => 20, 'type' => array(ITEM_TASK, ITEM_FILE), 'limit_offset' => 0));
     /*
     $changes= DbProjectItem::getAll(array(
         'project'           => $project->id,        # query only this project history
         'alive_only'        => false,               # get deleted entries
         'visible_only'      => false,               # ignore user viewing rights
         'limit_rowcount'    => 20,                  # show only last 20 entries in rss feed
         #'show_assignments'  => false,              # ignore simple assignment events
     ));
     */
     $url = confGet('SELF_PROTOCOL') . '://' . confGet('SELF_URL');
     # url part of the link to the task
     $from_domain = confGet('SELF_DOMAIN');
     # domain url
     if (confGet('USE_MOD_REWRITE')) {
         $url = str_replace('index.php', '', $url);
     }
     ### define general rss file settings ###
     $rss = new UniversalFeedCreator();
     $rss->title = "StreberPM: " . $project->name;
     $rss->description = "Latest Project News";
     $rss->link = "{$url}?go=projView&prj={$project->id}";
     $rss->syndicationURL = $url;
     # go through all retrieved changes and create rss feed
     foreach ($changes as $ch) {
         $item = $ch->item;
         $name_author = __('???');
         if ($person = Person::getVisibleById($item->modified_by)) {
             $name_author = $person->name;
         }
         $str_updated = '';
         if ($new = $ch->item->isChangedForUser()) {
             if ($new == 1) {
                 $str_updated = __('New');
             } else {
                 $str_updated = __('Updated');
             }
         }
         $feeditem = new FeedItem();
         $feeditem->title = $item->name . " (" . $ch->txt_what . ' ' . __("by") . ' ' . $name_author . ")";
         $feeditem->link = $url . "?go=itemView&item={$item->id}";
         $feeditem->date = gmdate("r", strToGMTime($item->modified));
         $feeditem->source = $url;
         $feeditem->author = $name_author;
         switch ($ch->type) {
             case ChangeLine::COMMENTED:
                 $feeditem->description = $ch->html_details;
                 break;
             case ChangeLine::NEW_TASK:
                 $feeditem->description = str_replace("\n", "<br>", $item->description);
                 break;
             default:
                 $feeditem->description = $ch->type . " " . str_replace("\n", "<br>", $item->description);
                 break;
         }
         $rss->addItem($feeditem);
     }
     /**
      * all history items processed ...
      * save the rss 2.0 feed to rss/rss_$project->id.xml ...
      * false stands for not showing the resulting feed file -> create in background
      */
     $rss->saveFeed("RSS2.0", "_rss/proj_{$project->id}.xml", false);
 }
 public static function initStreberUrl()
 {
     global $g_streber_url;
     $directory = explode("/tests/", $_SERVER['SCRIPT_NAME']);
     $g_streber_url = confGet('SELF_PROTOCOL') . "://" . asCleanString($_SERVER['HTTP_HOST']) . $directory[0];
 }
Beispiel #20
0
/**
* companyLinkPeopleSubmit @ingroup pages
*/
function personLinkCompaniesSubmit()
{
    global $PH;
    require_once confGet('DIR_STREBER') . 'db/class_company.inc.php';
    $id = getOnePassedId('person', 'people_*');
    $person = Person::getEditableById($id);
    if (!$person) {
        $PH->abortWarning("Could not get object...");
    }
    $company_ids = getPassedIds('company', 'companies_*');
    if (!$company_ids) {
        $PH->abortWarning(__("No companies selected..."));
    }
    $employments = $person->getEmployments();
    foreach ($company_ids as $cid) {
        if (!($company = Company::getEditableById($cid))) {
            $PH->abortWarning("Could not access company by id");
        }
        #### company already related to person? ###
        $already_in = false;
        foreach ($employments as $e) {
            if ($e->company == $company->id) {
                $already_in = true;
                break;
            }
        }
        if (!$already_in) {
            $e_new = new Employment(array('id' => 0, 'person' => $person->id, 'company' => $company->id));
            $e_new->insert();
        } else {
            new FeedbackMessage(__("Company already related to person"));
        }
    }
    ### display personView ####
    if (!$PH->showFromPage()) {
        $PH->show('personView', array('person' => $person->id));
    }
}
Beispiel #21
0
 /**
  * internal function to add update markers to wiki texts
  * these markers will later be replaced by render_wiki (see render_wiki.inc.php FormatBlockChangemarks)
  */
 public function getTextfieldWithUpdateNotes($fieldname)
 {
     require_once confGet('DIR_STREBER') . "db/db_itemchange.inc.php";
     require_once confGet('DIR_STREBER') . 'db/db_itemperson.inc.php';
     global $auth;
     ### has user last edited this item? ###
     if ($this->modified_by == $auth->cur_user->id) {
         return $this->{$fieldname};
     } else {
         if ($item_people = ItemPerson::getAll(array('person' => $auth->cur_user->id, 'item' => $this->id))) {
             $ip = $item_people[0];
             if ($ip->viewed_last > $this->modified) {
                 return $this->{$fieldname};
             }
         } else {
             return $this->{$fieldname};
         }
     }
     $new_version = $this->{$fieldname};
     $changes = ItemChange::getItemChanges(array('item' => $this->id, 'field' => $fieldname, 'order_by' => 'modified', 'date_min' => $ip->viewed_last));
     if (!$changes) {
         return $this->{$fieldname};
     }
     $old_version = $changes[0]->value_old;
     require_once confGet('DIR_STREBER') . "std/difference_engine.inc.php";
     $ota = explode("\n", str_replace("\r\n", "\n", $old_version));
     $nta = explode("\n", str_replace("\r\n", "\n", $new_version));
     $diffs = new Diff($ota, $nta);
     $new_lines = array();
     foreach ($diffs as $d) {
         foreach ($d as $do) {
             if ($do->type == 'copy') {
                 $new_lines[] .= join("\n", $do->orig);
             } else {
                 if ($do->type == 'add') {
                     $new_lines[] = "[added word]" . join("\n", $do->closing) . "[/added word]";
                 } else {
                     if ($do->type == 'delete') {
                         $new_lines[] = '[deleted word]' . join("\n", $do->orig) . '[/deleted word]';
                     } else {
                         if ($do->type == 'change') {
                             ### render word level differences
                             $wld = new WordLevelDiff($do->orig, $do->closing);
                             $change_ratio = DbProjectItem::getEditRatioOfWordLevelDiff($wld);
                             if ($change_ratio > 0.1) {
                                 $new_lines[] = "[deleted word]" . join("\n", $do->orig) . "[/deleted word]";
                                 $new_lines[] = "[added word]" . join("\n", $do->closing) . "[/added word]";
                             } else {
                                 $new_lines[] = formatWordLevelDiff($wld);
                             }
                         }
                     }
                 }
             }
         }
     }
     $buffer = join($new_lines, "\n");
     #debugMessage($old_version);
     #debugMessage( htmlspecialchars($buffer));
     return $buffer;
 }
Beispiel #22
0
 public function viewAsImage($max_size = 0)
 {
     $max_size = intval($max_size);
     if (!($dimensions = $this->getImageDimensions($max_size))) {
         log_message("file::viewAsImage({$this->id}) can not find file1 '{$filepath}'", LOG_MESSAGE_MISSING_FILES);
         return;
     }
     $filepath = $dimensions['filepath'];
     $new_width = $dimensions['new_width'];
     $new_height = $dimensions['new_height'];
     $width = $dimensions['width'];
     $height = $dimensions['height'];
     $filesize = filesize($filepath);
     /**
      * just provide the original file
      */
     if (!$dimensions['downscale']) {
         header('Content-Length: ' . $filesize);
         header('Content-Type: ' . $this->mimetype);
         header("Content-Disposition: inline; filename={$this->org_filename}");
         header("Cache-Control: public");
         header('Last-Modified: ' . gmdate("D, j M Y G:i:s T", strToClientTime($this->modified)));
         if ($filesize > 1000000) {
             readfile_chunked($filepath);
         } else {
             readfile($filepath);
         }
         return;
     }
     /**
      * rescale with gd
      */
     if (!function_exists('imagecreatetruecolor')) {
         log_message("file::viewAsImage({$this->id}) gd not installed", LOG_MESSAGE_MISSING_FILES);
         return;
     }
     ### check if cached file exists
     $md5 = md5(http_build_query(array('filepath' => $filepath, 'new_width' => $new_width, 'new_height' => $new_height)));
     $cached_filepath = confGet('DIR_IMAGE_CACHE') . "/" . $md5 . ".jpg";
     if (file_exists($cached_filepath)) {
         header('Content-Length: ' . filesize($cached_filepath));
         header('Content-Type: ' . $this->mimetype);
         header("Content-Disposition: inline; filename= {$this->org_filename}");
         header("Cache-Control: public");
         header('Last-Modified: ' . gmdate("D, j M Y G:i:s T", strToClientTime($this->modified)));
         header("Expires: " . gmdate("D, d M Y H:i:s", time() + 60 * 60 * 24 * 365) . " GMT");
         readfile($cached_filepath);
         return;
     }
     $image_new = NULL;
     ### downscale
     if ($this->mimetype == 'image/jpeg' || $this->mimetype == 'image/jpg' || $this->mimetype == 'image/pjpeg') {
         $image = imagecreatefromjpeg($filepath);
     } else {
         if ($this->mimetype == 'image/png' || $this->mimetype == 'image/x-png') {
             $image = imagecreatefrompng($filepath);
         } else {
             if ($this->mimetype == 'image/gif') {
                 $image = imagecreatefromgif($filepath);
             } else {
                 return NULL;
             }
         }
     }
     ### Downscale image and stream content
     header('Content-Type: ' . 'image/jpeg');
     header("Cache-Control: public");
     ### Tell browser to cache forever, because the file will never change
     header("Last-Modified: " . gmdate('r', strToClientTime($this->modified)));
     header("Expires: " . gmdate("D, d M Y H:i:s", time() + 60 * 60 * 24 * 365) . " GMT");
     $image_new = imagecreatetruecolor($new_width, $new_height) or die("Cannot Initialize new GD image stream");
     if (imagecopyresampled($image_new, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height)) {
         imagejpeg($image_new);
     } else {
         imagejpeg($image);
     }
     ### write cached file
     if ($image_new) {
         imagejpeg($image_new, $cached_filepath);
         imagedestroy($image_new);
     }
 }
Beispiel #23
0
 static function getCreatedRecently($person_id = NULL)
 {
     if (!$person_id) {
         global $auth;
         $person_id = $auth->cur_user->id;
     } else {
         $person_id = intval($person_id);
     }
     $prefix = confGet('DB_TABLE_PREFIX');
     require_once confGet('DIR_STREBER') . 'db/class_issue.inc.php';
     $dbh = new DB_Mysql();
     $sth = $dbh->prepare("SELECT i.*, iss.*\r\n                 from {$prefix}item i,  {$prefix}issue iss\r\n                WHERE   i.created_by={$person_id}\r\n                    AND i.type = '" . ITEM_ISSUE . "'\r\n                    AND iss.id = i.id\r\n                    AND i.state = 1\r\n                    ORDER BY i.created DESC\r\n                ")->execute();
     $tmp = $sth->fetchall_assoc();
     $issues = array();
     foreach ($tmp as $n) {
         $issue = new Issue($n);
         $issues[] = $issue;
     }
     return $issues;
 }
 function render_tr(&$obj, $style = "")
 {
     global $PH;
     if (!isset($obj) || !$obj instanceof Comment) {
         trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
         return;
     }
     global $auth;
     if ($obj->created_by == $auth->cur_user->id) {
         $column_text = '<td class="comment_text by_cur_user">';
     } else {
         $column_text = "<td class=comment_text>";
     }
     $column_text .= "<div class=comment_block style='padding-left:" . $obj->level * 2.0 . "em'>";
     if ($obj->view_collapsed) {
         $column_text .= $PH->getLink('commentToggleViewCollapsed', "<img src=\"" . getThemeFile("img/toggle_folder_closed.gif") . "\">", array('comment' => $obj->id), NULL, true);
         $column_text .= "<span class=title>" . $PH->getLink('commentView', $obj->name, array('comment' => $obj->id)) . "</span>";
         if ($obj->num_children) {
             $column_text .= "<span class=children> (";
             if ($obj->num_children == 1) {
                 $column_text .= __("1 sub comment");
             } else {
                 $column_text .= printf(__("%s sub comments"), $obj->num_children);
             }
             $column_text .= ")</span>";
         }
     } else {
         $column_text .= $PH->getLink('commentToggleViewCollapsed', "<img src=\"" . getThemeFile("img/toggle_folder_open.gif") . "\">", array('comment' => $obj->id), NULL, true);
         $column_text .= "<span class=title>" . $PH->getLink('commentView', $obj->name, array('comment' => $obj->id)) . "</span>";
         require_once confGet('DIR_STREBER') . 'render/render_wiki.inc.php';
         $project = Project::getVisibleById($obj->project);
         $obj->nowViewedByUser();
         ### editable? ###
         $editable = false;
         if ($obj->created_by == $auth->cur_user->id) {
             #if($pp= $obj->getProjectPerson()) {
             #    if($pp->level_edit < $obj->pub_level) {
             $editable = true;
             #   }
             #}
         }
         $diz = wikifieldAsHtml($obj, 'description');
         if ($diz) {
             $column_text .= "<div class=comment_text>{$diz}</div>";
         }
     }
     $column_text .= "</div>";
     $column_text .= "</td>";
     print $column_text;
 }
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 #26
0
/**
* return a valid link to streber's wiki documentation...
*
* @@@put this function somewhere else
*/
function getStreberWikiLink($pagename = NULL, $displayname = NULL)
{
    if (!$pagename) {
        trigger_error("getStreberWikiLink() requires pagename", E_USER_NOTICE);
    }
    if (!$displayname) {
        $displayname = $pagename;
    }
    return "<a href=\"" . confGet('STREBER_WIKI_URL') . "{$pagename}\">{$displayname}</a>";
}
Beispiel #27
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();
}
 protected function getPlaintextBody()
 {
     return sprintf(__('Hello %s,', 'notification'), $this->recipient->name) . "\n\n" . sprintf(__('Your account at %s is still active.', 'notification'), "<a href='" . $this->url . "'>" . confGet('SELF_DOMAIN') . "</a>") . "\n" . __('Your login name is', 'notification') . " '" . asHtml($this->recipient->nickname) . "'.\n" . "\n" . __('Please use the following link to update your account settings:') . "\n" . $this->url . "?go=activateAccount&tuid=" . $this->recipient->identifier . "\n" . "\n" . "\n" . "   " . __('Thanks for your time', 'notification') . "\n" . "   " . __('the management', 'notification') . "\n";
 }
 function validateView()
 {
     global $auth;
     global $PH;
     $prefix = confGet('DB_TABLE_PREFIX');
     ### all ###
     if ($auth->cur_user->user_rights & RIGHT_VIEWALL) {
         return true;
     }
     ### all companies ###
     if ($auth->cur_user->user_rights & RIGHT_COMPANY_VIEWALL) {
         return true;
     }
     $str = "SELECT COUNT(*) from {$prefix}company c, {$prefix}project p, {$prefix}projectperson upp\r\n             WHERE\r\n                    upp.person = {$auth->cur_user->id}\r\n                AND upp.state = 1         /* upp all user projectpeople */\r\n\r\n                AND  p.id = upp.project   /* all user projects */\r\n                AND  c.id = p.company     /* all companies */\r\n                AND  c.id = {$this->id}\r\n                AND  c.state = 1\r\n            ";
     $dbh = new DB_Mysql();
     $sth = $dbh->prepare($str);
     $sth->execute("", 1);
     $tmp = $sth->fetchall_assoc();
     $count = $tmp[0]['COUNT(*)'];
     if ($count == 1) {
         return true;
     } else {
         if ($count > 1) {
             $PH->abortWarning(__("not available"), ERROR_RIGHTS);
         } else {
             $PH->abortWarning(__("not available"), ERROR_RIGHTS);
         }
     }
 }
if (!function_exists('startedIndexPhp')) {
    header("location:../index.php");
    exit;
}
# streber - a php5 based project management system  (c) 2005-2007  / www.streber-pm.org
# Distributed under the terms and conditions of the GPL as stated in lang/license.html
/**\file
 * classes related to rendering project news
 *
 * included by: @render_page
 * @author     Thomas Mann
 */
require_once confGet('DIR_STREBER') . "render/render_page.inc.php";
require_once confGet('DIR_STREBER') . "render/render_list_column.inc.php";
require_once confGet('DIR_STREBER') . "render/render_list_column_special.inc.php";
class ProjectNewsBlock extends PageBlock
{
    public $project;
    public $max_news = 3;
    function __construct($project)
    {
        parent::__construct(NULL);
        $this->project = $project;
        $this->title = __('Project News');
        $this->id = 'project_news';
    }
    public function __toString()
    {
        global $PH;
        $news = $this->project->getTasks(array('is_news' => 1, 'order_by' => 'created DESC'));