public function executeAjaxSubscribe(sfWebRequest $request) { $id = $request->getParameter('id'); $list_id = $request->getParameter('list_id'); $email_list_person = new EmailListPerson(); $email_list_person->setPersonId($id); $email_list_person->setListId($list_id); if (EmailListPersonPeer::doCount($email_list_person->buildCriteria())) { // what is this going to do? } else { $email_list_person->save(); } return $this->renderText($id); }
public function executeToggle(sfWebRequest $request) { $person = PersonPeer::retrieveByPK($this->getUser()->getId()); $html = ''; switch ($request->getParameter('name')) { case 'email_blocked': $person->setEmailBlocked($person->getEmailBlocked() == 1 ? 0 : 1); if ($person->getEmailBlocked() == 1) { $html = 'Yesun-block email'; } else { $html = 'No block email'; } break; case 'email_text_only': $person->setEmailTextOnly($person->getEmailTextOnly() == 1 ? 0 : 1); if ($person->getEmailTextOnly() == 1) { $html = 'Yesset to any'; } else { $html = 'No set to text only'; } break; case 'email': $validator = new sfValidatorEmail(array('required' => true), array('invalid' => 'Email address is invalid: %value%', 'required' => 'Email address is required')); try { $email = $validator->clean($request->getParameter('email')); $person->setEmail($email); $html = $email; } catch (sfValidatorError $e) { $html = '#' . $e->__toString(); } break; case 'email_list': $email_list_person = new EmailListPerson(); $email_list_person->setPersonId($person->getId()); $email_list_person->setListId($request->getParameter('id')); $result = EmailListPersonPeer::doSelectOne($email_list_person->buildCriteria()); if ($result instanceof EmailListPerson) { $result->delete(); } else { $email_list_person->save(); } if ($email_list_person->isNew()) { $html = 'subscribe'; } else { $html = 'un-subscribe'; } break; } $person->save(); return $this->renderText($html); }