public function contactFormAction() { //create the form $form = new Zend_Form(); //this page should post back to itself $form->setAction($_SERVER['REQUEST_URI']); $form->setMethod('post'); $name = $form->createElement('text', 'name'); $name->setLabel($this->view->getTranslation('Your Name') . ': '); $name->setRequired(TRUE); $name->addFilter('StripTags'); $name->addErrorMessage($this->view->getTranslation('Your name is required!')); $name->setAttrib('size', 30); $email = $form->createElement('text', 'email'); $email->setLabel($this->view->getTranslation('Your Email') . ': '); $email->setRequired(TRUE); $email->addValidator('EmailAddress'); $email->addErrorMessage($this->view->getTranslation('Invalid email address!')); $email->setAttrib('size', 30); $subject = $form->createElement('text', 'subject'); $subject->setLabel($this->view->getTranslation('Subject') . ': '); $subject->setRequired(TRUE); $subject->addFilter('StripTags'); $subject->addErrorMessage($this->view->getTranslation('The subject is required!')); $subject->setAttrib('size', 40); $message = $form->createElement('textarea', 'message'); $message->setLabel($this->view->getTranslation('Message') . ': '); $message->setRequired(TRUE); $message->addErrorMessage($this->view->getTranslation('The message is required!')); $message->setAttrib('cols', 35); $message->setAttrib('rows', 10); $captcha = new Zend_Form_Element_Captcha('captcha', array('label' => $this->view->getTranslation('Please verify you\'re a human'), 'captcha' => array('captcha' => 'Figlet', 'wordLen' => 6, 'timeout' => 300))); $form->addElement($name); $form->addElement($email); $form->addElement($subject); $form->addElement($message); $form->addElement($captcha); $form->addElement('submit', 'submitContactForm', array('label' => $this->view->getTranslation('Send Message'))); $this->view->form = $form; if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) { if ($form->isValid($_POST)) { //get form data $data = $form->getValues(); //get the module data $module = new Digitalus_Module(); $moduleData = $module->getData(); //render the message $this->view->data = $data; $htmlMessage = $this->view->render('public/message.phtml'); $mail = new Digitalus_Mail(); $this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage); } } }
public function contactFormAction() { //create the form $form = new Contact_Form(); // retrieve the id that is set in the <DigitalusControl>-tag $digControlId = $this->view->getFilter('DigitalusControl')->getId(); $this->view->form = $form; if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitContactForm')) { if ($form->isValid($_POST)) { //get form data $data = $form->getValues(); //get the module data $module = new Digitalus_Module($digControlId); $moduleData = $module->getData(); //render the message $this->view->data = $data; $htmlMessage = $this->view->render('public/message.phtml'); $mail = new Digitalus_Mail(); $this->view->isSent = $mail->send($moduleData->email, array($data['email'], $data['name']), $data['subject'], $htmlMessage); } } }
/** * Reset password action * * @return void */ public function resetPasswordAction() { if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $userName = Digitalus_Filter_Post::get('name'); $user = new Model_User(); $match = $user->getUserByUsername($userName); if ($match) { //create the password $password = Digitalus_Toolbox_String::random(10); //10 character random string //load the email data $data['username'] = $match->name; $data['first_name'] = $match->first_name; $data['last_name'] = $match->last_name; $data['email'] = $match->email; $data['password'] = $password; //get standard site settings $s = new Model_SiteSettings(); $settings = $s->toObject(); $emailFormat = "Hello %s (<em>%s %s</em>),<br /><br />Your password has been reset to:<br /><br /><strong>%s</strong><br /><br />You can login again with Your new Password.<br /><br />Best wishes,<br />%s"; $emailText = sprintf($emailFormat, $data['username'], $data['first_name'], $data['last_name'], $data['password'], $settings->default_email_sender); //attempt to send the email $mail = new Digitalus_Mail(); if ($mail->send($match->email, array($settings->default_email, $settings->default_email_sender), 'Password Reminder', $emailText)) { //update the user's password $match->password = md5($password); $match->save(); //save the new password $m = new Digitalus_View_Message(); $m->add($this->view->getTranslation('Your password has been reset for security and sent to your email address')); } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('Sorry, there was an error sending you your updated password. Please contact us for more help.')); } } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('Sorry, we could not locate your account. Please contact us to resolve this issue.')); } $url = 'admin/auth/login'; $this->_redirect($url); } }
/** * Mail test action * * @return void */ public function mailTestAction() { $settings = new Model_SiteSettings(); $message = new Digitalus_Mail(); $message->send($settings->get('default_email'), array($settings->get('default_email'), $settings->get('default_email_sender')), 'Digitalus CMS Test Message', 'test'); $this->_forward('index'); }