コード例 #1
0
 static function getChangeLinesForPerson(&$person, $project = NULL, $date_compare = NULL)
 {
     global $PH;
     $query_options = array();
     if (!$date_compare) {
         $date_compare = $person->last_logout;
     }
     if ($project) {
         $query_options['project'] = $project->id;
     }
     fillMissingValues($query_options, array('alive_only' => false, 'date_min' => $date_compare, 'not_modified_by' => $person->id));
     $change_lines = ChangeLine::getChangeLines($query_options);
     return $change_lines;
 }
コード例 #2
0
 public function print_automatic()
 {
     global $PH;
     global $auth;
     ### add filter options ###
     foreach ($this->filters as $f) {
         foreach ($f->getQuerryAttributes() as $k => $v) {
             $this->query_options[$k] = $v;
         }
     }
     if ($auth->cur_user->user_rights & RIGHT_VIEWALL) {
         $this->query_options['visible_only'] = false;
     } else {
         $this->query_options['visible_only'] = true;
     }
     $changes = ChangeLine::getChangeLines($this->query_options);
     $this->render_list($changes);
 }
コード例 #3
0
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();
    }
}
コード例 #4
0
ファイル: class_rss.inc.php プロジェクト: Bremaweb/streber-1
 /**
  * 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);
 }
コード例 #5
0
 private function addRecentChanges()
 {
     ### list project changes ###
     require_once confGet('DIR_STREBER') . './lists/list_changes.inc.php';
     $updates_html = '';
     $updates_txt = '';
     foreach ($this->projects as $p) {
         if ($changes = ChangeLine::getChangeLinesForPerson($this->recipient, $p, $this->recipient->notification_last)) {
             $this->information_count++;
             $updates_html .= "<h4>";
             $updates_html .= $this->getItemLink($p->id, $p->name);
             $updates_html .= "</h4><ul>";
             $updates_txt .= "\n\r" . $p->name . "\n\r";
             foreach ($changes as $c) {
                 $updates_html .= "<li>";
                 $updates_txt .= "\n\r- ";
                 ### task
                 if ($c->item && $c->item->type == ITEM_TASK) {
                     $task = $c->item;
                     $updates_html .= $this->getItemLink($task->id, $task->name);
                     $updates_txt .= $task->name;
                 } else {
                     if ($c->item && $c->item->type == ITEM_FILE) {
                         $file = $c->item;
                         $updates_html .= $this->getItemLink($file->id, $file->name);
                         $updates_txt .= $file->name;
                     }
                 }
                 $updates_html .= '<br><span class="details">';
                 # invisible user
                 $updates_txt .= "\n\r";
                 # invisible user
                 ### what...
                 if ($c->html_what) {
                     $updates_html .= $c->html_what . ' ';
                     if ($c->txt_what) {
                         $updates_txt .= '  ' . $c->txt_what;
                     } else {
                         $updates_txt .= '  ' . strip_tags($c->html_what);
                     }
                 }
                 $updates_html .= ' ' . __("by") . ' ';
                 # invisible user
                 $updates_txt .= ' ' . __("by") . ' ';
                 # invisible user
                 ### who...
                 if ($c->person_by) {
                     if ($p_who = Person::getVisibleById($c->person_by)) {
                         $updates_html .= "<b>" . asHtml($p_who->nickname) . "</b>" . " ";
                         $updates_txt .= $p_who->nickname;
                     } else {
                         $updates_html .= '??? ';
                         # invisible user
                         $updates_txt .= '???: ';
                         # invisible user
                     }
                 }
                 ### when...
                 if ($c->timestamp) {
                     $updates_html .= ' - ' . renderTimestamp($c->timestamp);
                     $updates_txt .= ' - ' . renderTimestamp($c->timestamp);
                 }
                 ### to...
                 /**
                  * @@@ bug: this contains internal links that can be viewed from mail
                  **/
                 if ($c->html_assignment) {
                     $updates_html .= ' (' . $c->html_assignment . ') ';
                 }
                 $updates_html .= "</span>";
                 $updates_html .= "<div class='details'>" . $c->html_details . "</div>";
                 $updates_html .= "</li>";
                 $updates_txt .= "\n\r";
             }
             $updates_html .= "</ul>";
             $updates_txt .= "\n\r";
         }
     }
     if ($updates_html) {
         $this->body_html .= "<h3>" . __('Project Updates') . "</h3>" . $updates_html;
         $this->body_plaintext .= "\n\r" . __('Project Updates') . "\n\r" . str_repeat("=", strlen(__('Project Updates'))) . "\n\r" . $updates_txt;
     }
 }
コード例 #6
0
ファイル: item_ajax.inc.php プロジェクト: Bremaweb/streber-1
/**
* get recent changes for ajax request from home @ingroup pages
*
* @Params
* - prj
* - start
* - count
*
* @NOTE
* This page function was formerly a part of home.inc.php but since it will
* be used in other places as well, item_ajax might be a better place for it.
*/
function AjaxMoreChanges()
{
    require_once confGet('DIR_STREBER') . 'std/class_changeline.inc.php';
    require_once confGet('DIR_STREBER') . 'lists/list_recentchanges.inc.php';
    global $auth;
    header("Content-type: text/html; charset=utf-8");
    if (!($project = Project::getVisibleById(get('prj')))) {
        return;
    }
    $start = is_null(get('start')) ? 0 : intval(get('start'));
    $count = is_null(get('count')) ? 20 : intval(get('count'));
    $options = array('project' => $project->id, 'unviewed_only' => false, 'limit_rowcount' => $count, 'limit_offset' => $start, 'type' => array(ITEM_TASK, ITEM_FILE));
    if ($auth->cur_user->settings & USER_SETTING_FILTER_OWN_CHANGES) {
        $options['not_modified_by'] = $auth->cur_user->id;
    }
    /**
     * first query all unviewed changes
     */
    if ($changes = ChangeLine::getChangeLines($options)) {
        $lines = 0;
        foreach ($changes as $c) {
            printChangeLine($c);
        }
    }
}