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
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      EmailListRole $value A EmailListRole object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(EmailListRole $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = serialize(array((string) $obj->getListId(), (string) $obj->getRoleId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }