Beispiel #1
0
 public function home($request, $match)
 {
     $prj = $request->project;
     $team = $prj->getMembershipData();
     $title = (string) $prj;
     $downloads = array();
     if ($request->rights['hasDownloadsAccess']) {
         $tags = IDF_Views_Download::getDownloadTags($prj);
         // the first tag is the featured, the last is the deprecated.
         $downloads = $tags[0]->get_idf_upload_list();
     }
     $pages = array();
     if ($request->rights['hasWikiAccess']) {
         $tags = IDF_Views_Wiki::getWikiTags($prj);
         $pages = $tags[0]->get_idf_wikipage_list();
     }
     return Pluf_Shortcuts_RenderToResponse('idf/project/home.html', array('page_title' => $title, 'team' => $team, 'downloads' => $downloads, 'pages' => $pages), $request);
 }
Beispiel #2
0
 public function timeline($request, $match)
 {
     $prj = $request->project;
     $title = sprintf(__('%s Updates'), (string) $prj);
     $team = $prj->getMembershipData();
     $pag = new IDF_Timeline_Paginator(new IDF_Timeline());
     $pag->class = 'recent-issues';
     $pag->item_extra_props = array('request' => $request);
     $pag->summary = __('This table shows the project updates.');
     // 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\'';
     }
     $sql = sprintf('model_class IN (%s)', implode(', ', $rights));
     $pag->forced_where = new Pluf_SQL('project=%s AND ' . $sql, array($prj->id));
     $pag->sort_order = array('creation_dtime', 'ASC');
     $pag->sort_reverse_order = array('creation_dtime');
     $pag->action = array('IDF_Views_Project::timeline', array($prj->shortname));
     $list_display = array('creation_dtime' => __('Age'), 'id' => __('Change'));
     $pag->configure($list_display, array(), array('creation_dtime'));
     $pag->items_per_page = 20;
     $pag->no_results_text = __('No changes were found.');
     $pag->setFromRequest($request);
     $downloads = array();
     if ($request->rights['hasDownloadsAccess']) {
         $tags = IDF_Views_Download::getDownloadTags($prj);
         // the first tag is the featured, the last is the deprecated.
         $downloads = $tags[0]->get_idf_upload_list();
     }
     $pages = array();
     if ($request->rights['hasWikiAccess']) {
         $tags = IDF_Views_Wiki::getWikiTags($prj);
         $pages = $tags[0]->get_idf_wikipage_list();
     }
     if (!$request->user->isAnonymous() and $prj->isRestricted()) {
         $feedurl = Pluf_HTTP_URL_urlForView('idf_project_timeline_feed_auth', array($prj->shortname, IDF_Precondition::genFeedToken($prj, $request->user)));
     } else {
         $feedurl = Pluf_HTTP_URL_urlForView('idf_project_timeline_feed', array($prj->shortname));
     }
     return Pluf_Shortcuts_RenderToResponse('idf/project/timeline.html', array('page_title' => $title, 'feedurl' => $feedurl, 'timeline' => $pag, 'team' => $team, 'downloads' => $downloads), $request);
 }
Beispiel #3
0
 /**
  * Generate the tag clouds.
  *
  * Return an array of tags sorted by class, then name. Each tag
  * get the extra property 'nb_use' for the number of use in the
  * project.
  *
  * @param string ('issues') 'closed_issues', 'wiki' or 'downloads'
  * @return ArrayObject of IDF_Tag
  */
 public function getTagCloud($what = 'issues')
 {
     $tag_t = Pluf::factory('IDF_Tag')->getSqlTable();
     if ($what == 'issues' or $what == 'closed_issues') {
         $what_t = Pluf::factory('IDF_Issue')->getSqlTable();
         $asso_t = $this->_con->pfx . 'idf_issue_idf_tag_assoc';
         if ($what == 'issues') {
             $ostatus = $this->getTagIdsByStatus('open');
         } else {
             $ostatus = $this->getTagIdsByStatus('closed');
         }
         if (count($ostatus) == 0) {
             $ostatus[] = 0;
         }
         $sql = sprintf('SELECT ' . $tag_t . '.id AS id, COUNT(*) AS nb_use FROM ' . $tag_t . ' ' . "\n" . 'LEFT JOIN ' . $asso_t . ' ON idf_tag_id=' . $tag_t . '.id ' . "\n" . 'LEFT JOIN ' . $what_t . ' ON idf_issue_id=' . $what_t . '.id ' . "\n" . 'WHERE idf_tag_id IS NOT NULL AND ' . $what_t . '.status IN (%s) AND ' . $what_t . '.project=' . $this->id . ' GROUP BY ' . $tag_t . '.id, ' . $tag_t . '.class, ' . $tag_t . '.name ORDER BY ' . $tag_t . '.class ASC, ' . $tag_t . '.name ASC', implode(', ', $ostatus));
     } elseif ($what == 'wiki') {
         $dep_ids = IDF_Views_Wiki::getDeprecatedPagesIds($this);
         $extra = '';
         if (count($dep_ids)) {
             $extra = ' AND idf_wikipage_id NOT IN (' . implode(', ', $dep_ids) . ') ';
         }
         $what_t = Pluf::factory('IDF_WikiPage')->getSqlTable();
         $asso_t = $this->_con->pfx . 'idf_tag_idf_wikipage_assoc';
         $sql = 'SELECT ' . $tag_t . '.id AS id, COUNT(*) AS nb_use FROM ' . $tag_t . ' ' . "\n" . 'LEFT JOIN ' . $asso_t . ' ON idf_tag_id=' . $tag_t . '.id ' . "\n" . 'LEFT JOIN ' . $what_t . ' ON idf_wikipage_id=' . $what_t . '.id ' . "\n" . 'WHERE idf_tag_id IS NOT NULL ' . $extra . ' AND ' . $what_t . '.project=' . $this->id . ' GROUP BY ' . $tag_t . '.id, ' . $tag_t . '.class, ' . $tag_t . '.name ORDER BY ' . $tag_t . '.class ASC, ' . $tag_t . '.name ASC';
     } elseif ($what == 'downloads') {
         $dep_ids = IDF_Views_Download::getDeprecatedFilesIds($this);
         $extra = '';
         if (count($dep_ids)) {
             $extra = ' AND idf_upload_id NOT IN (' . implode(', ', $dep_ids) . ') ';
         }
         $what_t = Pluf::factory('IDF_Upload')->getSqlTable();
         $asso_t = $this->_con->pfx . 'idf_tag_idf_upload_assoc';
         $sql = 'SELECT ' . $tag_t . '.id AS id, COUNT(*) AS nb_use FROM ' . $tag_t . ' ' . "\n" . 'LEFT JOIN ' . $asso_t . ' ON idf_tag_id=' . $tag_t . '.id ' . "\n" . 'LEFT JOIN ' . $what_t . ' ON idf_upload_id=' . $what_t . '.id ' . "\n" . 'WHERE idf_tag_id IS NOT NULL ' . $extra . ' AND ' . $what_t . '.project=' . $this->id . ' GROUP BY ' . $tag_t . '.id, ' . $tag_t . '.class, ' . $tag_t . '.name ORDER BY ' . $tag_t . '.class ASC, ' . $tag_t . '.name ASC';
     }
     $tags = array();
     foreach ($this->_con->select($sql) as $idc) {
         $tag = new IDF_Tag($idc['id']);
         $tag->nb_use = $idc['nb_use'];
         $tags[] = $tag;
     }
     return new Pluf_Template_ContextVars($tags);
 }