/**
  * setDefaults
  *
  * @param  SchemaHasUser $SchemaHasUser
  */
 public function setDefaults($SchemaHasUser)
 {
     if (!isset($this->schema)) {
         $this->schema = myActionTools::findCurrentSchema();
     }
     if ($this->schema) {
         $SchemaHasUser->setSchemaId($this->schema->getId());
     }
     $SchemaHasUser->setIsRegistrarFor(false);
     parent::setDefaults($SchemaHasUser);
 }
示例#2
0
 /**
  * @param null $con
  * @return int
  * @throws Exception
  * @throws PropelException
  */
 public function save($con = null)
 {
     $userId = sfContext::getInstance()->getUser()->getSubscriberId();
     if ($userId) {
         $this->setUpdatedUserId($userId);
         if ($this->isNew()) {
             $this->setCreatedUserId($userId);
         }
     }
     $con = Propel::getConnection();
     try {
         $con->begin();
         $ret = parent::save($con);
         // update schema_has_user table
         $schemaId = $this->getId();
         $mode = sfContext::getInstance()->getRequest()->getParameter('action');
         if ($userId && $schemaId) {
             //see if there's already an entry in the table and if not, add it
             $criteria = new Criteria();
             $criteria->add(SchemaHasUserPeer::USER_ID, $userId);
             $SchemaHasUsersColl = $this->getSchemaHasUsers($criteria, $con);
             if (!count($SchemaHasUsersColl)) {
                 $schemaUser = new SchemaHasUser();
                 $schemaUser->setSchemaId($schemaId);
                 $schemaUser->setUserId($userId);
                 $schemaUser->setIsRegistrarFor(true);
                 $schemaUser->setIsAdminFor(true);
                 $schemaUser->setIsMaintainerFor(true);
                 $schemaUser->save($con);
             }
         }
         $con->commit();
         return $ret;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
 /**
  * Method called to associate a SchemaHasUser object to this object
  * through the SchemaHasUser foreign key attribute
  *
  * @param      SchemaHasUser $l SchemaHasUser
  * @return     void
  * @throws     PropelException
  */
 public function addSchemaHasUser(SchemaHasUser $l)
 {
     $this->collSchemaHasUsers[] = $l;
     $l->setSchema($this);
 }