/** * Returns an array of model classes for which the current user * has rights and which should be used according to his filter * * @param object $request * @param string $model_filter * @return array */ private static function determineModelClasses($request, $model_filter = 'all') { $classes = array(); if (true === IDF_Precondition::accessSource($request) && ($model_filter == 'all' || $model_filter == 'commits')) { $classes[] = '\'IDF_Commit\''; // FIXME: this looks like a hack... IDF_Scm::syncTimeline($request->project); } if (true === IDF_Precondition::accessIssues($request) && ($model_filter == 'all' || $model_filter == 'issues')) { $classes[] = '\'IDF_Issue\''; $classes[] = '\'IDF_IssueComment\''; } if (true === IDF_Precondition::accessDownloads($request) && ($model_filter == 'all' || $model_filter == 'downloads')) { $classes[] = '\'IDF_Upload\''; } if (true === IDF_Precondition::accessWiki($request) && ($model_filter == 'all' || $model_filter == 'documents')) { $classes[] = '\'IDF_WikiPage\''; $classes[] = '\'IDF_WikiRevision\''; } if (true === IDF_Precondition::accessReview($request) && ($model_filter == 'all' || $model_filter == 'reviews')) { $classes[] = '\'IDF_Review_Comment\''; $classes[] = '\'IDF_Review_Patch\''; } if (count($classes) == 0) { $classes[] = '\'IDF_Dummy\''; } return $classes; }
/** * Entry point for the post-update signal. * * It tries to find the name of the project, when found it runs an * update of the timeline. */ public static function postUpdate($signal, &$params) { // Chop the ".git" and get what is left $pname = basename($params['git_dir'], '.git'); try { $project = IDF_Project::getOr404($pname); } catch (Pluf_HTTP_Error404 $e) { Pluf_Log::event(array('IDF_Plugin_SyncGit::postUpdate', 'Project not found.', array($pname, $params))); return false; // Project not found } // Now we have the project and can update the timeline Pluf_Log::debug(array('IDF_Plugin_SyncGit::postUpdate', 'Project found', $pname, $project->id)); IDF_Scm::syncTimeline($project, true); Pluf_Log::event(array('IDF_Plugin_SyncGit::postUpdate', 'sync', array($pname, $project->id))); }
public function timelineFeed($request, $match) { $prj = $request->project; // Need to check the rights $rights = array(); if (true === IDF_Precondition::accessSource($request)) { $rights[] = '\'IDF_Commit\''; IDF_Scm::syncTimeline($request->project); } if (true === IDF_Precondition::accessIssues($request)) { $rights[] = '\'IDF_Issue\''; $rights[] = '\'IDF_IssueComment\''; } if (true === IDF_Precondition::accessDownloads($request)) { $rights[] = '\'IDF_Upload\''; } if (true === IDF_Precondition::accessWiki($request)) { $rights[] = '\'IDF_WikiPage\''; $rights[] = '\'IDF_WikiRevision\''; } if (true === IDF_Precondition::accessReview($request)) { $rights[] = '\'IDF_Review_Comment\''; $rights[] = '\'IDF_Review_Patch\''; } if (count($rights) == 0) { $rights[] = '\'IDF_Dummy\''; } $sqls = sprintf('model_class IN (%s)', implode(', ', $rights)); $sql = new Pluf_SQL('project=%s AND ' . $sqls, array($prj->id)); $params = array('filter' => $sql->gen(), 'order' => 'creation_dtime DESC', 'nb' => 20); $items = Pluf::factory('IDF_Timeline')->getList($params); $set = new Pluf_Model_Set($items, array('public_dtime' => 'public_dtime')); $out = array(); foreach ($set as $item) { if ($item->id) { $out[] = $item->feedFragment($request); } } if ($items->count() > 0) { $date = Pluf_Date::gmDateToGmString($items[0]->creation_dtime); } else { $date = gmdate('c'); } $out = Pluf_Template::markSafe(implode("\n", $out)); $tmpl = new Pluf_Template('idf/index.atom'); $title = __('Updates'); $feedurl = Pluf::f('url_base') . Pluf::f('idf_base') . $request->query; $viewurl = Pluf_HTTP_URL_urlForView('IDF_Views_Project::timeline', array($prj->shortname)); $context = new Pluf_Template_Context_Request($request, array('body' => $out, 'date' => $date, 'title' => $title, 'feedurl' => $feedurl, 'viewurl' => $viewurl)); return new Pluf_HTTP_Response('<?xml version="1.0" encoding="utf-8"?>' . "\n" . $tmpl->render($context), 'application/atom+xml; charset=utf-8'); }
/** * Update the timeline in post commit. * */ public function processSyncTimeline($params) { $pname = basename($params['rel_dir']); try { $project = IDF_Project::getOr404($pname); } catch (Pluf_HTTP_Error404 $e) { Pluf_Log::event(array('IDF_Plugin_SyncMercurial::processSyncTimeline', 'Project not found.', array($pname, $params))); return false; // Project not found } // Now we have the project and can update the timeline Pluf_Log::debug(array('IDF_Plugin_SyncMercurial::processSyncTimeline', 'Project found', $pname, $project->id)); IDF_Scm::syncTimeline($project, true); Pluf_Log::event(array('IDF_Plugin_SyncMercurial::processSyncTimeline', 'sync', array($pname, $project->id))); }
/** * Update the timeline after a push * */ public function processSyncTimeline($project_name) { try { $project = IDF_Project::getOr404($project_name); } catch (Pluf_HTTP_Error404 $e) { Pluf_Log::event(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'Project not found.', array($project_name, $params))); return false; // Project not found } Pluf_Log::debug(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'Project found', $project_name, $project->id)); IDF_Scm::syncTimeline($project, true); Pluf_Log::event(array('IDF_Plugin_SyncMonotone::processSyncTimeline', 'sync', array($project_name, $project->id))); }