예제 #1
0
 public static function retrieveByUser($user_id, $max = 5)
 {
     $userGroups = HistoryGroupUserPeer::retrieveByUserId($user_id);
     $groups = array();
     foreach ($userGroups as $result) {
         $groups[] = $result->getHistoryGroup();
     }
     $c = new Criteria();
     $crit0 = $c->getNewCriterion(self::HISTORY_GROUP_ID, '');
     $crit_groups = array();
     foreach ($groups as $group) {
         $group = HistoryGroupPeer::retrieveByName($group->getName());
         $crit_groups[] = $c->getNewCriterion(self::HISTORY_GROUP_ID, $group->getId());
     }
     sfContext::getInstance()->getLogger()->info('Groups: [' . count($crit_groups) . ']');
     foreach ($crit_groups as $crit_group) {
         $crit0->addOr($crit_group);
     }
     $c->add($crit0);
     $c->addDescendingOrderByColumn(self::CREATED_AT);
     $c->setLimit($max);
     sfContext::getInstance()->getLogger()->info('Grabbing history now');
     return self::doSelect($c);
 }
예제 #2
0
 public function getHistoryGroup()
 {
     $group = HistoryGroupPeer::retrieveByName($this->getUuid() . '-project-history');
     if ($group == null) {
         $group = $this->createHistoryGroup();
     }
     return $group;
 }
예제 #3
0
 public function executeUnsubscribeToFeed()
 {
     $group = HistoryGroupPeer::retrieveByUuid($this->getRequestParameter('feed'));
     if ($group != null) {
         $this->getUser()->getProfile()->unsubscribeToHistory($group->getName());
     }
     $this->redirect($this->getRequest()->getReferer());
 }
예제 #4
0
 public function getHistoryGroup()
 {
     $group = HistoryGroupPeer::retrieveByName('feature-history-' . $this->getUuid());
     if ($group == null) {
         $group = $this->createHistoryGroup();
     }
     return $group;
 }
예제 #5
0
 public function getHistoryGroup($con = null)
 {
     if ($this->aHistoryGroup === null && $this->history_group_id !== null) {
         include_once 'lib/model/om/BaseHistoryGroupPeer.php';
         $this->aHistoryGroup = HistoryGroupPeer::retrieveByPK($this->history_group_id, $con);
     }
     return $this->aHistoryGroup;
 }
예제 #6
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = HistoryGroupPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUuid($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setPublicTitle($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setVersion($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setDeletedAt($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setCreatedAt($arr[$keys[6]]);
     }
 }
예제 #7
0
 public static function doSelectJoinAllExceptsfGuardUser(Criteria $c, $con = null)
 {
     foreach (sfMixer::getCallables('BaseHistoryGroupUserPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) {
         call_user_func($callable, 'BaseHistoryGroupUserPeer', $c, $con);
     }
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     HistoryGroupUserPeer::addSelectColumns($c);
     $startcol2 = HistoryGroupUserPeer::NUM_COLUMNS - HistoryGroupUserPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     HistoryGroupPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + HistoryGroupPeer::NUM_COLUMNS;
     $c->addJoin(HistoryGroupUserPeer::HISTORY_GROUP_ID, HistoryGroupPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = HistoryGroupUserPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = HistoryGroupPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getHistoryGroup();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addHistoryGroupUser($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initHistoryGroupUsers();
             $obj2->addHistoryGroupUser($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
예제 #8
0
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(HistoryGroupPeer::ID, $pks, Criteria::IN);
         $objs = HistoryGroupPeer::doSelect($criteria, $con);
     }
     return $objs;
 }