/**
  * Return all commits associated to a given project
  *
  * @param $id ID number of project
  * @param $limit Maximum age of commits to show, use strtotime format (default is 2 weeks ago)
  *
  * @return false if no commits, otherwise array
  */
 public function getCommitsByProject($id, $limit = '-2 weeks')
 {
     $crit = new B2DBCriteria();
     $issues = TBGIssuesTable::getTable()->getIssuesByProjectId($id);
     $crit->addWhere(self::ISSUE_NO, $issues[0]->getID());
     for ($i = 1; $i != count($issues); $i++) {
         $crit->addOr(self::ISSUE_NO, $issues[$i]->getID());
     }
     $crit->addWhere(self::DATE, strtotime($limit), $crit::DB_GREATER_THAN_EQUAL);
     $crit->addOrderBy(self::DATE, B2DBCriteria::SORT_DESC);
     $results = $this->doSelect($crit);
     if (!is_object($results) || $results->getNumberOfRows() == 0) {
         return false;
     }
     $data = array();
     /* Build revision details */
     while ($results->next()) {
         $file = array($results->get(TBGVCSIntegrationTable::FILE_NAME), $results->get(TBGVCSIntegrationTable::ACTION), $results->get(TBGVCSIntegrationTable::NEW_REV), $results->get(TBGVCSIntegrationTable::OLD_REV));
         if (array_key_exists($results->get(TBGVCSIntegrationTable::NEW_REV), $data)) {
             $data[$results->get(TBGVCSIntegrationTable::NEW_REV)][1][] = $file;
         } else {
             // one array for revision details, other for files
             $data[$results->get(TBGVCSIntegrationTable::NEW_REV)] = array(array(), array());
             $data[$results->get(TBGVCSIntegrationTable::NEW_REV)][0] = array($results->get(TBGVCSIntegrationTable::ID), $results->get(TBGVCSIntegrationTable::AUTHOR), $results->get(TBGVCSIntegrationTable::DATE), $results->get(TBGVCSIntegrationTable::LOG), $results->get(TBGVCSIntegrationTable::ISSUE_NO));
             $data[$results->get(TBGVCSIntegrationTable::NEW_REV)][1][] = $file;
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 public function getArticles($num_articles = 5, $news = false, $published = true)
 {
     $crit = new B2DBCriteria();
     $crit->addWhere(TBGArticlesTable::SCOPE, TBGContext::getScope()->getID());
     $crit->addWhere(TBGArticlesTable::NAME, 'Category:%', B2DBCriteria::DB_NOT_LIKE);
     $crit->addOrderBy(TBGArticlesTable::DATE, 'desc');
     if ($published) {
         $crit->addWhere(TBGArticlesTable::IS_PUBLISHED, 1);
     }
     $articles = array();
     if ($res = TBGArticlesTable::getTable()->doSelect($crit)) {
         while (($row = $res->getNextRow()) && count($articles) < $num_articles) {
             try {
                 $article = PublishFactory::article($row->get(TBGArticlesTable::ID), $row);
             } catch (Exception $e) {
                 continue;
             }
             if ($article->hasAccess()) {
                 $articles[] = $article;
             }
         }
     }
     return $articles;
 }
Ejemplo n.º 3
0
 /**
  * Return the time when the issue was reopened
  * 
  * @return false if closed, otherwise a timestamp
  */
 public function whenReopened()
 {
     if ($this->isClosed()) {
         return false;
     }
     $crit = new B2DBCriteria();
     $crit->addSelectionColumn(TBGLogTable::TIME);
     $crit->addWhere(TBGLogTable::TARGET, $this->_id);
     $crit->addWhere(TBGLogTable::TARGET_TYPE, 1);
     $crit->addWhere(TBGLogTable::CHANGE_TYPE, 22);
     $crit->addOrderBy(TBGLogTable::TIME, 'desc');
     $res = TBGLogTable::getTable()->doSelect($crit);
     $ret_arr = array();
     if ($res->getNumberOfRows() == 0) {
         return false;
     }
     $row = $res->getNextRow();
     return $row->get(TBGLogTable::TIME);
 }