public function view()
 {
     $crit = new B2DBCriteria();
     $crit->addWhere(TBGArticleViewsTable::ARTICLE_ID, $this->getID());
     $crit->addWhere(TBGArticleViewsTable::USER_ID, TBGContext::getUser()->getID());
     if (B2DB::getTable('TBGArticleViewsTable')->doCount($crit) == 0) {
         $crit = new B2DBCriteria();
         $crit->addInsert(TBGArticleViewsTable::ARTICLE_ID, $this->getID());
         $crit->addInsert(TBGArticleViewsTable::USER_ID, TBGContext::getUser()->getID());
         $crit->addInsert(TBGArticleViewsTable::SCOPE, TBGContext::getScope()->getID());
         B2DB::getTable('TBGArticleViewsTable')->doInsert($crit);
     }
 }
Exemplo n.º 2
0
 /**
  * Adds an issue to the list of issues "starred" by this user 
  *
  * @param integer $issue_id ID of issue to add
  * @return boolean
  */
 public function addStarredIssue($issue_id)
 {
     $this->_populateStarredIssues();
     TBGLogging::log("Starring issue with id {$issue_id} for user with id " . $this->getID());
     if ($this->isLoggedIn() == true && $this->isGuest() == false) {
         if (array_key_exists($issue_id, $this->_starredissues)) {
             TBGLogging::log('Already starred');
             return true;
         }
         TBGLogging::log('Logged in and unstarred, continuing');
         $crit = new B2DBCriteria();
         $crit->addInsert(TBGUserIssuesTable::ISSUE, $issue_id);
         $crit->addInsert(TBGUserIssuesTable::UID, $this->_id);
         $crit->addInsert(TBGUserIssuesTable::SCOPE, TBGContext::getScope()->getID());
         B2DB::getTable('TBGUserIssuesTable')->doInsert($crit);
         $issue = TBGContext::factory()->TBGIssue($issue_id);
         $this->_starredissues[$issue->getID()] = $issue;
         ksort($this->_starredissues);
         TBGLogging::log('Starred');
         return true;
     } else {
         TBGLogging::log('Not logged in');
         return false;
     }
 }
Exemplo n.º 3
0
 /**
  * Adds a user to the client
  *
  * @param TBGUser $user
  */
 public function addMember(TBGUser $user)
 {
     $crit = new B2DBCriteria();
     $crit->addInsert(TBGClientMembersTable::SCOPE, TBGContext::getScope()->getID());
     $crit->addInsert(TBGClientMembersTable::CID, $this->_id);
     $crit->addInsert(TBGClientMembersTable::UID, $user->getID());
     B2DB::getTable('TBGClientMembersTable')->doInsert($crit);
     if ($this->_members === null) {
         $this->_members = array();
     }
     $this->_members[] = $user->getID();
     array_unique($this->_members);
 }
 /**
  * Add a commit entry to the database
  *
  * @param $id Issue ID
  * @param $action A/D/U action applied to file
  * @param $commit_msg Log message
  * @param $file File changed
  * @param $new_rev New revision
  * @param $old_rev Old revision
  * @param $uid UID of changer
  * @param $date POSIX timestamp of change
  */
 public static function addEntry($id, $action, $commit_msg, $file, $new_rev, $old_rev, $uid, $date)
 {
     $crit = new B2DBCriteria();
     $crit->addInsert(TBGVCSIntegrationTable::ISSUE_NO, $id);
     $crit->addInsert(TBGVCSIntegrationTable::ACTION, $action);
     $crit->addInsert(TBGVCSIntegrationTable::LOG, $commit_msg);
     $crit->addInsert(TBGVCSIntegrationTable::FILE_NAME, $file);
     $crit->addInsert(TBGVCSIntegrationTable::NEW_REV, $new_rev);
     $crit->addInsert(TBGVCSIntegrationTable::OLD_REV, $old_rev);
     $crit->addInsert(TBGVCSIntegrationTable::AUTHOR, $uid);
     if ($date == null) {
         $crit->addInsert(TBGVCSIntegrationTable::DATE, time());
     } else {
         $crit->addInsert(TBGVCSIntegrationTable::DATE, $date);
     }
     $crit->addInsert(TBGVCSIntegrationTable::SCOPE, TBGContext::getScope()->getID());
     B2DB::getTable('TBGVCSIntegrationTable')->doInsert($crit);
 }