public function indexAction() { $this->view->headScript()->appendFile('//www.google.com/recaptcha/api.js'); $this->view->addHelperPath(APPLICATION_PATH . '/../vendor/wendrowycz/zf1-recaptcha-2/src/Wendrowycz/View/Helper', 'Wendrowycz\\View\\Helper\\'); $request = $this->getRequest(); $form = new Application_Form_Contact(); if ($request->isPost() && $form->isValid($_POST)) { $values = $form->getValues(); unset($values['g-recaptcha-response']); $this->view->values = $values; } $this->view->form = $form; }
public function indexAction() { $form = new Application_Form_Contact(); $request = $this->getRequest(); $post = $request->getPost(); if ($request->isPost()) { if ($form->isValid($post)) { $message = 'From: ' . mysql_real_escape_string($post['name']) . chr(10) . 'Email: ' . mysql_real_escape_string($post['email']) . chr(10); $message .= 'Message: ' . mysql_real_escape_string($post['message']); $headers = 'From: contact@dictro.com' . "\r\n" . 'Reply-To: webmaster@dictro.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail('*****@*****.**', 'contact: ' . mysql_real_escape_string($post['subject']), $message, $headers); } } $this->view->form = $form; }
public function contactAction() { $contacts = new Application_Model_Contacts(); $request = $this->getRequest(); $contactForm = new Application_Form_Contact(); if ($request->isPost() && $contactForm->isValid($request->getPost())) { $contacts = new Application_Model_Contacts(); $data = $request->getPost(); if ($contacts->insert($data['name'], $data['email'], $data['website'], $data['body'])) { $this->view->success = " Your Message has been sent successfully."; } else { $this->view->error = " Internal Error "; } } $this->view->form = $contactForm; }
public function addAction() { $form = new Application_Form_Contact(); if ($this->_request->isPost()) { $data = $this->_request->getPost(); if ($form->isValid($data)) { $dataFiltrees = $form->getValues(); $contact = new Application_Model_Contact(); $contact->setPrenom($dataFiltrees['prenom'])->setNom($dataFiltrees['nom'])->setEmail($dataFiltrees['email'])->setTelephone($dataFiltrees['telephone']); $this->mapper->insert($contact); $this->_flashMessenger->addMessage('Le contact ' . $contact->getPrenom() . ' a bien été créé'); $this->_redirector->gotoRouteAndExit(['controller' => 'contact'], null, true); } } $this->view->contactForm = $form; }
/** * Send form action handler */ public function sendAction() { $res = new stdClass(); $form = new Application_Form_Contact(); if ($form->isValid($_POST)) { $res->success = true; $lang = Zend_Registry::get('Zend_Translate'); $subject = $lang->translate($form->type->getValue()); $message = $form->message->getValue(); $fromName = $form->name->getValue(); $fromEmail = $form->email->getValue(); $this->sendMail($subject, $message, $fromName, $fromEmail); // Send email } else { $res->errors = array_keys($form->getMessages()); } $this->_helper->json->sendJson($res); }
public function updateAction() { if (!$this->_hasParam('id')) { return $this->_redirect('/contact/index/page/1'); } $form = new Application_Form_Contact(); $persons = new Application_Model_Contacts(); if ($this->getRequest()->isPost()) { if ($form->isValid($this->_getAllParams())) { $model = new Application_Model_Contacts(); $model->save($form->getValues(), $this->_getParam('id')); return $this->_redirect('/contact/index/page/1'); } } else { $row = $persons->getRow($this->_getParam('id')); if ($row) { $form->populate($row->toArray()); } } $this->view->form = $form; }
/** * @Created By : Mahipal Singh Adhikari * @Created On : 8-Dec-2010 * @Description: Used to display contact us page and send mails to Site Administrator */ public function contactAction() { $identifire = $this->view->actionName; $page = new Application_Model_Page(); $preview = false; $preview = $this->_getParam("preview"); $page = $page->getStaticContent($identifire); $this->view->preview = $preview; $this->view->status = $page->getStatus(); $this->view->title = $page->getTitle(); $this->view->content = $page->getContent(); $this->view->headTitle()->setSeparator(' - '); if ($page->getMetaTitle() == "") { $this->view->headTitle()->set($page->getTitle()); } else { $this->view->headTitle()->set($page->getMetaTitle()); } //append meta title and keywords $this->view->headMeta()->appendName('keywords', $page->getMetaKeyword()); $this->view->headMeta()->appendName('description', $page->getMetaDescription()); $this->view->headMeta()->appendName('title', $page->getMetaTitle()); //submit information $form = new Application_Form_Contact(); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); $element->removeDecorator('dd'); } $this->view->form = $form; if ($this->getRequest()->isPost()) { $params = $this->getRequest()->getPost(); if ($form->isValid($params)) { //set user id if logged in else set 0 as default $user_id = 0; $userNs = new Zend_Session_Namespace('members'); $user_id = $userNs->userId; //create contact model object $contactM = new Application_Model_Contact(); //set values $contactM->setContactName($this->_getParam('contact_name')); $contactM->setContactEmail($this->_getParam('contact_email')); $contactM->setContactReason(nl2br($this->_getParam('contact_reason'))); $contactM->setUserId($user_id); $contactM->setStatus(1); //save data $contact_id = $contactM->save(); $message = ""; if ($contact_id > 0) { //send email to admin $settings = new Admin_Model_GlobalSettings(); $admin_email = $settings->settingValue('admin_email'); //$admin_email = "*****@*****.**"; //set sender information $mailOptions['sender_name'] = ucwords($this->_getParam('contact_name')); $mailOptions['sender_email'] = $this->_getParam('contact_email'); $mailOptions['sender_comments'] = $this->_getParam('contact_reason'); //set receiver information $mailOptions['receiver_email'] = $admin_email; //$mailOptions['receiver_name'] = "Administrator"; //create mail class object and send the email $Mail = new Base_Mail(); $Mail->sendContactusEmail($mailOptions); $message = "Thanks! We have your feedback and will try and get in touch with you as soon as possible."; } else { $message = "Error occured while sending email."; } //set falsh message and redirect user $_SESSION["flash_msg"] = $message; $this->_redirect($this->view->seoUrl('/index/contact/')); } //end of if } //end if }
/** * Class constructor */ public final function __construct() { global $Campsite, $controller; if (!is_null($this->m_properties)) { return; } $this->login_action = (object) array('is_error' => false, 'error_message' => ''); self::$m_nullMetaArticle = new MetaArticle(); self::$m_nullMetaSection = new MetaSection(); // register plugin objects and listobjects foreach (CampPlugin::GetPluginsInfo(true) as $info) { if (is_array($info['template_engine']['objecttypes'])) { foreach ($info['template_engine']['objecttypes'] as $objecttype) { $this->registerObjectType($objecttype); } } if (is_array($info['template_engine']['listobjects'])) { foreach ($info['template_engine']['listobjects'] as $listobject) { $this->registerListObject($listobject); } } } $this->m_properties['htmlencoding'] = false; $this->m_properties['subs_by_type'] = null; $this->m_readonlyProperties['version'] = $Campsite['VERSION']; $this->m_readonlyProperties['current_list'] = null; $this->m_readonlyProperties['lists'] = array(); $this->m_readonlyProperties['prev_list_empty'] = null; $this->m_readonlyProperties['default_url'] = new MetaURL(); $this->m_readonlyProperties['url'] = new MetaURL(); if (!$this->m_readonlyProperties['default_url']->is_valid) { header('HTTP/1.0 404 Not Found'); if (!$this->m_readonlyProperties['url']->language->defined) { $this->m_readonlyProperties['url']->language = $this->m_readonlyProperties['url']->publication->default_language; $this->m_readonlyProperties['default_url'] = $this->m_readonlyProperties['url']; } } $this->m_objects['user'] = $this->m_readonlyProperties['url']->user; $this->m_readonlyProperties['preview'] = $this->m_readonlyProperties['url']->preview; if (!$this->m_readonlyProperties['preview']) { if (!$this->m_readonlyProperties['url']->article->is_published) { $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle; $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle; } if (!$this->m_readonlyProperties['url']->issue->is_published) { $this->m_readonlyProperties['default_url']->article = self::$m_nullMetaArticle; $this->m_readonlyProperties['url']->article = self::$m_nullMetaArticle; $this->m_readonlyProperties['default_url']->section = self::$m_nullMetaSection; $this->m_readonlyProperties['url']->section = self::$m_nullMetaSection; $this->m_readonlyProperties['default_url']->issue = new MetaIssue(); $this->m_readonlyProperties['url']->issue = new MetaIssue(); } } $this->m_objects['publication'] = $this->m_readonlyProperties['url']->publication; $this->m_objects['language'] = $this->m_readonlyProperties['url']->language; $this->m_objects['issue'] = $this->m_readonlyProperties['url']->issue; $this->m_objects['section'] = $this->m_readonlyProperties['url']->section; $this->m_objects['article'] = $this->m_readonlyProperties['url']->article; $this->m_objects['template'] = $this->m_readonlyProperties['url']->template; if (is_numeric($this->m_readonlyProperties['url']->get_parameter('tpid'))) { $this->m_objects['topic'] = new MetaTopic($this->m_readonlyProperties['url']->get_parameter('tpid')); } $this->m_readonlyProperties['default_template'] = $this->m_objects['template']; $this->m_readonlyProperties['default_language'] = $this->m_objects['language']; $this->m_readonlyProperties['default_publication'] = $this->m_objects['publication']; $this->m_readonlyProperties['default_issue'] = $this->m_objects['issue']; $this->m_readonlyProperties['default_section'] = $this->m_objects['section']; $this->m_readonlyProperties['default_article'] = $this->m_objects['article']; $this->m_readonlyProperties['default_topic'] = $this->topic; if (!is_null($commentId = CampRequest::GetVar('acid'))) { $this->m_objects['comment'] = new MetaComment($commentId); } $this->m_readonlyProperties['request_action'] = MetaAction::CreateAction(CampRequest::GetInput(CampRequest::GetMethod())); $requestActionName = $this->m_readonlyProperties['request_action']->name; if ($requestActionName != 'default') { $this->m_readonlyProperties['request_action']->takeAction($this); } foreach (MetaAction::ReadAvailableActions() as $actionName => $actionAttributes) { $propertyName = $actionName . '_action'; if ($requestActionName == $actionName) { $this->m_readonlyProperties[$propertyName] =& $this->m_readonlyProperties['request_action']; } else { $this->m_readonlyProperties[$propertyName] = MetaAction::DefaultAction(); } } // Initialize the default comment attribute at the end, after the // submit comment action had run. $this->m_readonlyProperties['default_comment'] = $this->comment; // add browser info $this->m_readonlyProperties['browser'] = new Browser(); // initialize plugins foreach (CampPlugin::GetPluginsInfo(true) as $info) { if (function_exists($info['template_engine']['init'])) { $plugin_init = $info['template_engine']['init']; $plugin_init($this); } } // initialize geo-map holders $this->m_properties['map_dynamic_constraints'] = null; $this->m_properties['map_dynamic_areas'] = null; $this->m_properties['map_dynamic_max_points'] = 0; $this->m_properties['map_dynamic_tot_points'] = 0; $this->m_properties['map_dynamic_points_raw'] = null; $this->m_properties['map_dynamic_points_objects'] = null; $this->m_properties['map_dynamic_meta_article_objects'] = null; $this->m_properties['map_dynamic_map_label'] = ""; $this->m_properties['map_dynamic_id_counter'] = 0; $this->m_properties['map_common_header_set'] = false; if (defined('APPLICATION_PATH')) { $options = $controller->getInvokeArg('bootstrap')->getOptions(); $form = new \Application_Form_Contact(); $form->setMethod('POST'); $request = \Zend_Controller_Front::getInstance()->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $email = new \Zend_Mail('utf-8'); $email->setFrom($form->email->getValue(), $form->first_name->getValue() . ' ' . $form->last_name->getValue())->setSubject($form->subject->getValue())->setBodyText($form->message->getValue())->addTo($options['email']['contact'])->send(); $controller->getHelper('flashMessenger')->addMessage("form_contact_done"); $controller->getHelper('redirector')->gotoUrl($request->getPathInfo()); exit; } $this->form_contact = $form; $this->flash_messages = $controller->getHelper('flashMessenger')->getMessages(); } }