/**
  * setDefaults
  *
  * @param  VocabularyHasUser $VocabularyHasUser
  */
 public function setDefaults($VocabularyHasUser)
 {
     if (!isset($this->vocabulary)) {
         $this->vocabulary = myActionTools::findCurrentVocabulary();
     }
     if ($this->vocabulary) {
         $VocabularyHasUser->setVocabularyId($this->vocabulary->getId());
     }
     $VocabularyHasUser->setIsRegistrarFor(false);
     parent::setDefaults($VocabularyHasUser);
 }
 public function save($con = null)
 {
     $con = Propel::getConnection();
     try {
         $con->begin();
         $ret = parent::save($con);
         // update vocabulary_has_user table
         $userId = sfContext::getInstance()->getUser()->getSubscriberId();
         $vocabularyId = $this->getId();
         $mode = sfContext::getInstance()->getRequest()->getParameter('action');
         if ($userId && $vocabularyId) {
             //see if there's already an entry in the table and if not, add it
             $criteria = new Criteria();
             $criteria->add(VocabularyHasUserPeer::USER_ID, $userId);
             $VocabularyHasUsersColl = $this->getVocabularyHasUsers($criteria, $con);
             if (!count($VocabularyHasUsersColl)) {
                 $vocabularyUser = new VocabularyHasUser();
                 $vocabularyUser->setVocabularyId($vocabularyId);
                 $vocabularyUser->setUserId($userId);
                 $vocabularyUser->setIsRegistrarFor(true);
                 $vocabularyUser->setIsAdminFor(true);
                 $vocabularyUser->setIsMaintainerFor(true);
                 $vocabularyUser->save($con);
             }
         }
         $con->commit();
         return $ret;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Example #3
0
 /**
  * Method called to associate a VocabularyHasUser object to this object
  * through the VocabularyHasUser foreign key attribute
  *
  * @param      VocabularyHasUser $l VocabularyHasUser
  * @return     void
  * @throws     PropelException
  */
 public function addVocabularyHasUser(VocabularyHasUser $l)
 {
     $this->collVocabularyHasUsers[] = $l;
     $l->setUser($this);
 }