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; }
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); }
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(); } }
/** * 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); }
/** * 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); } } }