public function saveEmailListRoleList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['email_list_role_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(EmailListRolePeer::LIST_ID, $this->object->getPrimaryKey());
     EmailListRolePeer::doDelete($c, $con);
     $values = $this->getValue('email_list_role_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new EmailListRole();
             $obj->setListId($this->object->getPrimaryKey());
             $obj->setRoleId($value);
             $obj->save();
         }
     }
 }
示例#2
0
 public function executeAjaxSaveRoles(sfWebRequest $request)
 {
     $email_list = EmailListPeer::retrieveByPK($request->getParameter('email_list_id'));
     $this->forward404Unless($email_list);
     $roles = $request->getParameter('roles');
     $c = new Criteria();
     $c->add(EmailListRolePeer::LIST_ID, $email_list->getId());
     EmailListRolePeer::doDelete($c);
     foreach ($roles as $id) {
         $email_list_role = new EmailListRole();
         $email_list_role->setRoleId($id);
         $email_list_role->setListId($email_list->getId());
         $email_list_role->save();
     }
     $this->email_list = $email_list;
 }
示例#3
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     foreach (sfMixer::getCallables('BaseEmailListRole:delete:pre') as $callable) {
         $ret = call_user_func($callable, $this, $con);
         if ($ret) {
             return;
         }
     }
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(EmailListRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         EmailListRolePeer::doDelete($this, $con);
         $this->setDeleted(true);
         $con->commit();
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
     foreach (sfMixer::getCallables('BaseEmailListRole:delete:post') as $callable) {
         call_user_func($callable, $this, $con);
     }
 }