/** * แสดงผล */ public function render($login) { // send email form $form = Html::create('form', array('id' => 'write_frm', 'class' => 'setup_frm', 'action' => 'index.php/index/model/sendmail/save', 'onsubmit' => 'doFormSubmit', 'token' => true, 'ajax' => true)); $fieldset = $form->add('fieldset', array('title' => '{LNG_Details of} {LNG_Email}')); // reciever $reciever = self::$request->get('to')->topic(); $fieldset->add('text', array('id' => 'reciever', 'itemClass' => 'item', 'labelClass' => 'g-input icon-email-sent', 'label' => '{LNG_Reciever}', 'comment' => '{LNG_Recipient's Email Address Many can be found Each separated by, (comma).}', 'autofocus', 'value' => $reciever)); // email_from $datas = array($login['email'] => $login['email']); if (Login::isAdmin() && empty($login['fb'])) { $datas[self::$cfg->noreply_email] = self::$cfg->noreply_email; foreach (\Index\Sendmail\Model::findAdmin(self::$request) as $item) { $datas[$item] = $item; } } $fieldset->add('select', array('id' => 'from', 'itemClass' => 'item', 'labelClass' => 'g-input icon-email', 'label' => '{LNG_Sender}', 'options' => $datas)); // subject $fieldset->add('text', array('id' => 'subject', 'itemClass' => 'item', 'labelClass' => 'g-input icon-edit', 'label' => '{LNG_Subject}', 'comment' => '' . '{LNG_Please fill in} {LNG_Subject}')); // detail $fieldset->add('ckeditor', array('id' => 'detail', 'itemClass' => 'item', 'height' => 300, 'language' => Language::name(), 'toolbar' => 'Email', 'label' => '{LNG_Detail}', 'value' => Template::load('', '', 'mailtemplate'))); $fieldset = $form->add('fieldset', array('class' => 'submit')); // submit $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Send message}')); return $form->render(); }
/** * หน้าส่งอีเมล์ * สมาชิกส่งจดหมายถึงสมาชิก และ แอดมิน * * @param Request $request * @return object */ public function render(Request $request) { // สมาชิก if ($login = Login::isMember()) { // ค่าที่ส่งมา $to = strtolower($request->get('to')->filter('0-9a-zA-Z')); if (preg_match('/^[0-9]+$/', $to)) { $reciever = \Index\Sendmail\Model::getUser($to); $to = ''; foreach ($reciever as $id => $item) { $to_msg = empty($item['name']) ? $item['email'] : $item['name']; $to = $id; } } elseif ($to == 'admin') { $to_msg = self::$cfg->member_status[1]; } else { $to = ''; } if ($to != '') { // antispam $antispam = new Antispam(); // ข้อมูลส่งกลับ $index = (object) array('topic' => Language::replace('Send a message to the :name', array(':name' => $to_msg)), 'keywords' => self::$cfg->web_title, 'description' => self::$cfg->web_description, 'module' => 'sendmail'); $template = Template::create('member', 'member', 'sendmail'); $template->add(array('/{TOPIC}/' => $index->topic, '/{ANTISPAM}/' => $antispam->getId(), '/{ANTISPAMVAL}/' => Login::isAdmin() ? $antispam->getValue() : '', '/{RECIEVER}/' => $to_msg, '/{SENDER}/' => $login['email'], '/{RECIEVERID}/' => $to)); $index->detail = $template->render(); // breadcrumbs $index->canonical = WEB_URL . 'index.php?module=sendmail&to=' . $to; Gcms::$view->addBreadcrumb($index->canonical, $index->topic); return $index; } } // ไม่สามารถส่งอีเมล์ได้ $message = Language::get('Unable to send e-mail, Because you can not send e-mail to yourself or can not find the email address of the recipient.'); return createClass('Index\\PageNotFound\\Controller')->init($request, 'member', $message); }