/** * Logs out the current user and redirect to homepage. */ public function actionSendEmail() { if (SupportMailSetting::sendEmail('*****@*****.**', 'Putra Sudaryanto', 'testing', 'testing', 1)) { echo 'send'; } else { echo 'notsend'; } }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); if ($this->isNewRecord && $this->queue->member_id == 0) { $setting = OmmuSettings::model()->findByPk(1, array('select' => 'signup_checkemail')); if ($setting->signup_checkemail == 1) { SupportMailSetting::sendEmail($this->queue->email, $this->queue->email, 'User Invite', 'Silahkan bergabung dan masukkan code invite', 1); } else { SupportMailSetting::sendEmail($this->queue->email, $this->queue->email, 'User Invite', 'Silahkan bergabung', 1); } } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionSetting() { $model = SupportMailSetting::model()->findByPk(1); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['SupportMailSetting'])) { $model->attributes = $_POST['SupportMailSetting']; $jsonError = CActiveForm::validate($model); if (strlen($jsonError) > 2) { $errors = $model->getErrors(); $summary['msg'] = "<div class='errorSummary'><strong>" . Yii::t('phrase', 'Please fix the following input errors:') . "</strong>"; $summary['msg'] .= "<ul>"; foreach ($errors as $key => $value) { $summary['msg'] .= "<li>{$value[0]}</li>"; } $summary['msg'] .= "</ul></div>"; $message = json_decode($jsonError, true); $merge = array_merge_recursive($summary, $message); $encode = json_encode($merge); echo $encode; } else { if (isset($_GET['enablesave']) && $_GET['enablesave'] == 1) { if ($model->save()) { echo CJSON::encode(array('type' => 0, 'msg' => '<div class="errorSummary success"><strong>' . Yii::t('phrase', 'Mail Setting success updated.') . '</strong></div>')); } else { print_r($model->getErrors()); } } } Yii::app()->end(); } else { $this->pageTitle = Yii::t('phrase', 'Mail Settings'); $this->pageDescription = ''; $this->pageMeta = ''; $this->render('admin_setting', array('model' => $model)); } }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); if ($this->isNewRecord) { SupportMailSetting::sendEmail($this->email, $this->displayname, $this->subject, $this->message, 0); } else { SupportMailSetting::sendEmail($this->email, $this->displayname, 'RE: ' . $this->subject, $this->message_reply, 1); } }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); $controller = strtolower(Yii::app()->controller->id); $currentAction = strtolower(Yii::app()->controller->id . '/' . Yii::app()->controller->action->id); // Generate Verification Code if ($this->verified == 0) { $verify = new UserVerify(); $verify->user_id = $this->user_id; $verify->save(); } if ($this->isNewRecord) { $setting = OmmuSettings::model()->findByPk(1, array('select' => 'site_type, signup_welcome, signup_adminemail')); if ($setting->site_type == 1) { $invite = UserInviteQueue::model()->findByAttributes(array('email' => strtolower($this->email)), array('select' => 'queue_id, member_id, reference_id')); if ($invite != null && $invite->member_id == 0) { $invite->member_id = $this->user_id; if ($this->referenceId != '') { $invite->reference_id = $this->referenceId; } $invite->update(); } } // Send Welcome Email if ($setting->signup_welcome == 1) { $welcome_search = array('{$baseURL}', '{$index}', '{$displayname}'); $welcome_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/index'), $this->displayname); $welcome_template = 'user_welcome'; $welcome_title = 'Welcome to SSO-GTP by BPAD Yogyakarta'; $welcome_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $welcome_template . '.php'); $welcome_ireplace = str_ireplace($welcome_search, $welcome_replace, $welcome_message); SupportMailSetting::sendEmail($this->email, $this->displayname, $welcome_title, $welcome_ireplace, 1); } // Send Account Information $account_search = array('{$baseURL}', '{$login}', '{$displayname}', '{$email}', '{$password}'); $account_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/login'), $this->displayname, $this->email, $this->newPassword); $account_template = 'user_welcome_account'; $account_title = 'SSO-GTP Account (' . $this->displayname . ')'; $account_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $account_template . '.php'); $account_ireplace = str_ireplace($account_search, $account_replace, $account_message); SupportMailSetting::sendEmail($this->email, $this->displayname, $account_title, $account_ireplace, 1); // Send New Account to Email Administrator if ($setting->signup_adminemail == 1) { SupportMailSetting::sendEmail($this->email, $this->displayname, 'New Member', 'informasi member terbaru', 0); } } else { // Send Account Information //if($this->enabled == 1) {} if ($controller == 'password') { $account_search = array('{$baseURL}', '{$login}', '{$displayname}', '{$email}', '{$password}'); $account_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('site/login'), $this->displayname, $this->email, $this->newPassword); $account_template = 'user_forgot_new_password'; $account_title = 'Your password changed'; $account_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $account_template . '.php'); $account_ireplace = str_ireplace($account_search, $account_replace, $account_message); SupportMailSetting::sendEmail($this->email, $this->displayname, $account_title, $account_ireplace, 1); } if ($controller == 'verify') { SupportMailSetting::sendEmail($this->email, $this->displayname, 'Verify Email Success', 'Verify Email Success', 1); } } }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); if ($this->isNewRecord) { // Guest Subscribe if ($this->user_id == 0 && $this->subscribe == 1) { $message = OmmuTemplate::getMessage('user_subscribe_launching', array(CHtml::encode($this->email))); SupportMailSetting::sendEmail($this->email, $this->email, 'Subscribe Success', $message, 1); } } else { if ($this->subscribe == 0) { // Guest Unsubscribe if ($this->user_id == 0) { SupportMailSetting::sendEmail($this->email, $this->email, 'Unsubscribe Success', 'Unsubscribe Success', 1); // Member Unsubscribe } else { SupportMailSetting::sendEmail($this->user->email, $this->user->displayname, 'Unsubscribe Success', 'Unsubscribe Success', 1); } } } }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); if ($this->isNewRecord) { // Send Email to Member $verify_search = array('{$baseURL}', '{$verify}', '{$displayname}'); $verify_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('users/verify/code', array('key' => $this->code, 'secret' => $this->user->salt)), $this->user->displayname); $verify_template = 'user_verify_email'; $verify_title = 'Please verify your SSO-GTP account'; $verify_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $verify_template . '.php'); $verify_ireplace = str_ireplace($verify_search, $verify_replace, $verify_message); SupportMailSetting::sendEmail($this->user->email, $this->user->displayname, $verify_title, $verify_ireplace, 1); } }
/** * After save attributes */ protected function afterSave() { parent::afterSave(); if ($this->isNewRecord) { // Send Email to Member $forgot_search = array('{$baseURL}', '{$forgot}', '{$displayname}'); $forgot_replace = array(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->request->baseUrl, Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('users/password/verify', array('key' => $this->code, 'secret' => $this->user->salt)), $this->user->displayname); $forgot_template = 'user_forgot_password'; $forgot_title = 'SSO-GTP Password Assistance'; $forgot_message = file_get_contents(YiiBase::getPathOfAlias('webroot.externals.users.template') . '/' . $forgot_template . '.php'); $forgot_ireplace = str_ireplace($forgot_search, $forgot_replace, $forgot_message); SupportMailSetting::sendEmail($this->user->email, $this->user->displayname, $forgot_title, $forgot_ireplace, 1); } }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionUnsubscribe() { /** * example get link * http://localhost/_product/nirwasita_hijab/support/newsletter/unsubscribe/email/putra.sudaryanto@gmail.com/secret/uvijijxykmabhiijdehinofgtuuvbcGH * secret = salt[Users] * email = email[Users] */ $renderError = 0; if (isset($_GET['success']) || (isset($_GET['email']) || isset($_GET['secret']))) { if (isset($_GET['success'])) { if (isset($_GET['date'])) { $title = Phrase::trans(23116, 1); $desc = Phrase::trans(23118, 1, array($_GET['success'], Utility::dateFormat($_GET['date']))); } else { $title = Phrase::trans(23119, 1); $desc = Phrase::trans(23120, 1, array($_GET['success'])); } } else { if (isset($_GET['email']) || isset($_GET['secret'])) { $newsletter = UserNewsletter::model()->findByAttributes(array('email' => $_GET['email']), array('select' => 'id, user_id, email, subscribe, subscribe_date, unsubscribe_date')); if ($newsletter != null) { if ($newsletter->user_id != 0) { $secret = Users::model()->findByAttributes(array('salt' => $_GET['secret']), array('select' => 'email')); $guest = $secret != null && $secret->email == $newsletter->email ? 1 : 0; } else { $guest = md5($newsletter->email . $newsletter->subscribe_date) == $_GET['secret'] ? 1 : 0; } if ($guest == 1) { if ($newsletter->subscribe == 1) { $newsletter->subscribe = 0; if ($newsletter->update()) { $title = Phrase::trans(23116, 1); $desc = Phrase::trans(23117, 1, array($newsletter->email)); } } else { $title = Phrase::trans(23116, 1); $desc = Phrase::trans(23118, 1, array($newsletter->email, Utility::dateFormat($newsletter->unsubscribe_date))); } } else { $renderError = 1; $title = Phrase::trans(23113, 1); $desc = Phrase::trans(23115, 1, array($newsletter->email)); } } else { $renderError = 1; $title = Phrase::trans(23113, 1); $desc = Phrase::trans(23114, 1); } } } } else { $model = new UserNewsletter(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['UserNewsletter'])) { $model->attributes = $_POST['UserNewsletter']; $jsonError = CActiveForm::validate($model); if (strlen($jsonError) > 2) { echo $jsonError; } else { if (isset($_GET['enablesave']) && $_GET['enablesave'] == 1) { if ($model->validate()) { if ($model->subscribe == 1) { if ($model->user_id != 0) { $email = $model->user->email; $displayname = $model->user->displayname; $secret = $model->user->salt; } else { $email = $displayname = $model->email; $secret = md5($email . $model->subscribe_date); } // Send Email to Member $ticket = Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('support/newsletter/unsubscribe', array('email' => $email, 'secret' => $secret)); SupportMailSetting::sendEmail($email, $displayname, 'Unsubscribe Ticket', $ticket, 1); $url = Yii::app()->controller->createUrl('unsubscribe', array('success' => $email)); } else { $url = Yii::app()->controller->createUrl('unsubscribe', array('success' => $model->email, 'date' => $model->unsubscribe_date)); } echo CJSON::encode(array('type' => 5, 'get' => $url)); } else { print_r($model->getErrors()); } } } Yii::app()->end(); } $title = Phrase::trans(23111, 1); $desc = Phrase::trans(23112, 1); } $this->dialogDetail = true; $this->dialogGroundUrl = Yii::app()->createUrl('site/index'); $this->dialogFixed = true; $this->pageTitle = $title; $this->pageDescription = $desc; $this->pageMeta = ''; $this->render('front_unsubscribe', array('model' => $model, 'renderError' => $renderError, 'launch' => 2)); }