public function run() { $contacts = null; if ($this->part == 'left') { $contacts = LuxContactInfo::model()->findByAttributes(array('label' => '[LEFT]')); } if ($this->part == 'right') { $contacts = LuxContactInfo::model()->findByAttributes(array('label' => '[RIGHT]')); } $this->render('contacts', array('contacts' => $contacts)); }
public function actionSend() { /* @var $contacts LuxContactInfo */ $name = Yii::app()->request->getParam('name', null); $email = Yii::app()->request->getParam('mail', null); $message = Yii::app()->request->getParam('message', null); $cap_id = Yii::app()->request->getParam('cap_id', null); $cap = Yii::app()->request->getParam('cap', null); $contacts = LuxContactInfo::model()->findAll(); if (count($contacts) > 0) { $contact = $contacts[0]; } else { $contact = new LuxContactInfo(); } $success = false; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $captcha = new DwCaptcha(); if (strlen($message) < 7 || !$captcha->CheckCaptcha($cap, $cap_id)) { $success = false; } if (strlen($message) > 7 && $captcha->CheckCaptcha($cap, $cap_id)) { $subject = $contact->getLngObject(Yii::app()->language)->feedback_subject; $to = $contact->administrator_email; //send email $headers = array(); $headers[] = "MIME-Version: 1.0"; $headers[] = "Content-type: text/plain; charset=iso-8859-1"; $headers[] = "From: " . $name . " <" . $email . ">"; $headers[] = "Subject: {$subject}"; $headers[] = "X-Mailer: PHP/" . phpversion(); $success = mail($to, $subject, $message, implode("\r\n", $headers)); } } if ($success) { $this->redirect(UrlHelper::GetActionUrl('pages', 'index') . '#contacts'); } else { $this->redirect(UrlHelper::GetActionUrl('pages', 'index', array('error' => 1)) . '#contacts'); } }
public function actionUpdateContacts() { /* @var $contacts LuxContactInfo */ /* @var $contactsLng LuxContactInfoLng */ $id = Yii::app()->request->getParam('id', null); $label = Yii::app()->request->getParam('label', null); $email_1 = Yii::app()->request->getParam('email_1', null); $phone_1 = Yii::app()->request->getParam('phone_1', null); $phone_2 = Yii::app()->request->getParam('phone_2', null); $email_admin = Yii::app()->request->getParam('email_admin', null); $map_link = Yii::app()->request->getParam('map_link', null); $small_text_lng = Yii::app()->request->getParam('info', array()); $subject_lng = Yii::app()->request->getParam('subject', array()); $title_lng = Yii::app()->request->getParam('title', array()); $contacts = LuxContactInfo::model()->findByPk($id); if ($contacts == null) { $contacts = new LuxContactInfo(); } $contacts->email_1 = $email_1; $contacts->phone_1 = $phone_1; $contacts->phone_2 = $phone_2; $contacts->administrator_email = $email_admin; $contacts->map_link = $map_link; $contacts->label = $label; $old_f_name = $contacts->map_image; $new_f_name = DwHelper::uploadPicAndGetPath($_FILES, 'map_img', $old_f_name); if ($new_f_name != "") { $contacts->map_image = $new_f_name; } if ($contacts->isNewRecord) { $contacts->save(); } else { $contacts->update(); } foreach (Constants::GetLngArray() as $lng) { $contactsLng = $contacts->getLngObject($lng); $contactsLng->small_text = $small_text_lng[$lng]; $contactsLng->feedback_subject = $subject_lng[$lng]; $contactsLng->text = $title_lng[$lng]; if ($contactsLng->isNewRecord) { $contactsLng->save(); } else { $contactsLng->update(); } } $this->redirect($this->createUrl('/admin/inlux/contacts')); }