public function addHistoryGroupUser(HistoryGroupUser $l) { $this->collHistoryGroupUsers[] = $l; $l->setsfGuardUser($this); }
public function subscribeToHistory($historyGroup) { $group = HistoryGroupPeer::retrieveByName($historyGroup); $c = new Criteria(); $c->add(HistoryGroupUserPeer::HISTORY_GROUP_ID, $group->getId()); $c->add(HistoryGroupUserPeer::USER_ID, $this->getSfGuardUser()->getId()); $subscription = HistoryGroupUserPeer::doSelectOne($c); if ($subscription == null) { sfContext::getInstance()->getLogger()->info('User not subscribing, subscribing now'); $subscription = new HistoryGroupUser(); $subscription->setHistoryGroupId($group->getId()); $subscription->setUserId($this->getSfGuardUser()->getId()); $subscription->save(); $this->addHistoryEvent('You have subscribe to a feed', 'You will now be alerted for whenever the feed ' . $historyGroup . ' is updated. The updates will also be available on your external RSS feed.', 'feeds'); return true; } sfContext::getInstance()->getLogger()->info('User already subscribing'); return true; }