Esempio n. 1
0
 /**
  * Standard email form for all webinstances
  * @since 23 aug 2013
  */
 public function emailAction()
 {
     $r = $this->getRequest();
     $form = new PubcontactFormOp(null, $r->getParams());
     $form->setMethod('post');
     $purl = $this->_buildUrlFromParams($r->getParams());
     if ($purl === '') {
         $purl = '/publicms/forms/email/';
     }
     $currentLangCode = $this->getCurrentLangCode();
     $purl .= !empty($currentLangCode) ? '?slang=' . $currentLangCode : '';
     $purl .= '#pubcontact';
     $form->setAction($purl);
     if ($r->isPost()) {
         $p = $this->_flattenForemailForm($r->getParams());
         $form->populate($p);
         if ($form->isValid($p)) {
             $db = new Pubcontact();
             $dbRow = $db->createRow();
             // $dbRow->id = '';
             $dbRow->safinstances_id = Sydney_Tools_Sydneyglobals::getSafinstancesId();
             $dbRow->datetime = date('Y-m-d H:i:s');
             // $dbRow->timestamp = '';
             if (isset($p['fname'])) {
                 $dbRow->fname = $p['fname'];
             }
             if (isset($p['lname'])) {
                 $dbRow->lname = $p['lname'];
             }
             if (isset($p['fullname'])) {
                 $dbRow->fullname = $p['fullname'];
             }
             if (isset($p['email'])) {
                 $dbRow->email = $p['email'];
             }
             if (isset($p['phonenr'])) {
                 $dbRow->phonenr = $p['phonenr'];
             }
             if (isset($p['subject'])) {
                 $dbRow->subject = $p['subject'];
             }
             if (isset($p['message'])) {
                 $dbRow->message = $p['message'];
             }
             if (isset($p['subsnewsletter'])) {
                 $dbRow->subsnewsletter = $p['subsnewsletter'];
             }
             // upload the file if any
             $dbRow->filfiles_id = 0;
             if (isset($p['MAX_FILE_SIZE'])) {
                 if ($form->uploadfile->receive()) {
                     $filefilesDb = new FilfilesOp();
                     $fileData = $filefilesDb->fileToFileManager($form->uploadfile->getFileName(), date('d/m/Y H:i:s') . ' file uploaded from FORMMAIL - Author : ' . $dbRow->fname . ' ' . $dbRow->lname . ' ' . $dbRow->fullname, 'Formmail');
                     $dbRow->filfiles_id = $fileData;
                 } else {
                     Zend_Debug::dump('ERROR: The file could not be uploaded...');
                 }
             }
             $entId = $dbRow->save();
             if ($entId !== false) {
                 $this->view->confirmSent = true;
                 $this->view->form = Sydney_Tools_Localization::_('Thanks, your message has been sent.');
                 // send the mail
                 if ($this->_sendEmailForms($p['emails'], $dbRow)) {
                     Sydney_Db_Trace::add('trace.event.emailsent_emailform' . ' [' . $dbRow->email . ']', 'publicms', 'pubcontact', 'email', $entId);
                 } else {
                     Sydney_Db_Trace::add('trace.event.emailerror_emailform' . ' [' . $dbRow->email . ']', 'publicms', 'pubcontact', 'email', $entId);
                 }
             } else {
                 $this->view->form = $form;
             }
         } else {
             $this->view->form = $form;
         }
     } else {
         $this->view->form = $form;
     }
 }
Esempio n. 2
0
 public function __construct($id = 0)
 {
     $this->_schema = Sydney_Tools_Sydneyglobals::getConf()->db->params->dbname;
     parent::__construct($id);
 }