コード例 #1
0
 /**
  * @param dmWebRequest $request 
  * 
  */
 public function executeImport(dmWebRequest $request)
 {
     $form = new ContactImportForm();
     if ($request->hasParameter($form->getName())) {
         $data = $request->getParameter($form->getName());
         $form->bind($data, $request->getFiles($form->getName()));
         if ($form->isValid()) {
             //$form->save();
             $this->getUser()->setFlash('contact_form_valid', true);
             $this->getService('dispatcher')->notify(new sfEvent($this, 'contact_import.saved', array('contact' => $form->getObject())));
             $this->redirectBack();
         }
     }
     $this->form = $this->forms['ContactImport'];
 }
コード例 #2
0
 /**
  * Handle dmUser/form form validation and creates the user account, then authenticates the user
  */
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new DmUserForm();
     if ($request->isMethod('post') && $request->hasParameter($form->getName())) {
         $data = $request->getParameter($form->getName());
         if ($form->isCaptchaEnabled()) {
             $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'))));
         }
         $form->bind($data, $request->getFiles($form->getName()));
         if ($form->isValid()) {
             $user = $form->save();
             $this->getUser()->signin($user);
             $this->redirectRegisteredUser($request);
         }
     }
     $this->forms['DmUser'] = $form;
 }
コード例 #3
0
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new DmContactForm();
     if ($request->hasParameter($form->getName())) {
         $data = $request->getParameter($form->getName());
         if ($form->isCaptchaEnabled()) {
             $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'))));
         }
         $form->bind($data, $request->getFiles($form->getName()));
         if ($form->isValid()) {
             $form->save();
             $this->getUser()->setFlash('contact_form_valid', true);
             $this->getService('dispatcher')->notify(new sfEvent($this, 'dm_contact.saved', array('contact' => $form->getObject())));
             $this->redirectBack();
         }
     }
     $this->forms['DmContact'] = $form;
 }
コード例 #4
0
 /**
  * executes the Guestbook form
  *
  * @param dmWebRequest $request
  * 
  */
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = $this->forms['AlGuestbook'];
     if ($request->hasParameter($form->getName())) {
         $data = $request->getParameter($form->getName());
         /* recaptcha field */
         if ($form->isCaptchaEnabled()) {
             $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'tecaptcha_response_field' => $request->getParameter('recaptcha_response_field'))));
         }
         $form->bind($data, $request->getFiles($form->getName()));
         /* if the form is Valid -> save */
         if ($form->isValid()) {
             $form->save();
             /* confirmations message */
             $this->getUser()->setFlash('guestbook_form_valid', true);
             /* set new al_guestbook.saved Event */
             $this->getService('dispatcher')->notify(new sfEvent($this, 'al_guestbook.saved', array('guestbook' => $form->getObject())));
             $this->redirectBack();
         }
     }
 }
コード例 #5
0
ファイル: actions.class.php プロジェクト: rafix/bibliocnic
 /**  
  * Handle dmUser/form form validation and creates the user account, then authenticates the user  
  */
 public function executeFormWidget(dmWebRequest $request)
 {
     $form = new DmUserForm();
     if ($request->isMethod('post') && $request->hasParameter($form->getName())) {
         $data = $request->getParameter($form->getName());
         // if the form uses captcha, include the additional data
         if ($form->isCaptchaEnabled()) {
             $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'))));
         }
         $form->bind($data, $request->getFiles($form->getName()));
         if ($request->isMethod('post') && $form->bindAndValid($request)) {
             $form->save();
             $this->getUser()->setFlash('busqueda_form_valid', true);
             $this->redirectBack();
         }
         if ($form->isValid()) {
             $user = $form->save();
             $this->getUser()->signin($user);
             $this->redirectRegisteredUser($request);
         }
     }
     // pass the form to the component
     $this->forms['DmUser'] = $form;
 }
コード例 #6
0
 /**
  * Handle dmUser/forgotPassword form validation and sends an email with a new password
  */
 public function executeForgotPasswordWidget(dmWebRequest $request)
 {
     // step 1
     if (!($forgotPasswordCode = $request->getParameter('_code'))) {
         $form = new DmForgotPasswordStep1Form();
         if ($request->isMethod('post') && $request->hasParameter($form->getName())) {
             $data = $request->getParameter($form->getName());
             if ($form->isCaptchaEnabled()) {
                 $data = array_merge($data, array('captcha' => array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'))));
             }
             $form->bind($data, $request->getFiles($form->getName()));
             if ($form->isValid()) {
                 $user = $form->getUserByEmail($form->getValue('email'));
                 $user->forgot_password_code = dmString::random(12);
                 $user->save();
                 $this->getService('mail')->setTemplate('dm_user_forgot_password')->addValues(array('username' => $user->username, 'email' => $user->email, 'step2_url' => $this->getHelper()->link($this->getPage())->param('_code', $user->forgot_password_code)->getAbsoluteHref()))->send();
                 $this->getUser()->setFlash('dm_forgot_password_email_sent', $user->email);
                 $this->redirectBack();
             }
         }
         $this->forms['DmForgotPasswordStep1'] = $form;
     } else {
         $this->forward404Unless($user = dmDb::table('DmUser')->retrieveByForgotPasswordCode($forgotPasswordCode));
         $form = new DmForgotPasswordStep2Form($user);
         if ($request->isMethod('post') && $request->hasParameter($form->getName())) {
             if ($form->bindAndValid($request)) {
                 $user->password = $form->getValue('password');
                 $user->forgot_password_code = null;
                 $user->save();
                 $this->getUser()->setFlash('dm_forgot_password_changed', true);
                 $this->redirectBack();
             }
         }
         $this->forms['DmForgotPasswordStep2'] = $form;
     }
 }