public function changeStatus() { $status = (int) $this->request->get('status'); $shipment = Shipment::getInstanceByID('Shipment', (int) $this->request->get('id'), true, array('Order' => 'CustomerOrder', 'ShippingAddress' => 'UserAddress')); $shipment->loadItems(); $zone = $shipment->getDeliveryZone(); $shipmentRates = $zone->getShippingRates($shipment); $shipment->setAvailableRates($shipmentRates); $history = new OrderHistory($shipment->order->get(), $this->user); $shipment->status->set($status); $shipment->save(); $history->saveLog(); $status = $shipment->status->get(); $enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES'); $m = array('EMAIL_STATUS_UPDATE_NEW' => Shipment::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => Shipment::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => Shipment::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => Shipment::STATUS_SHIPPED); $sendEmail = false; foreach ($m as $configKey => $constValue) { if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) { $sendEmail = true; } } if ($sendEmail || $this->config->get('EMAIL_STATUS_UPDATE')) { $user = $shipment->order->get()->user->get(); $user->load(); $email = new Email($this->application); $email->setUser($user); $email->setTemplate('order.status'); $email->set('order', $shipment->order->get()->toArray(array('payments' => true))); $email->set('shipments', array($shipment->toArray())); $email->send(); } return new JSONResponse(false, 'success'); }
private function sendMessage(NewsletterSentMessage $sent, LiveCart $application) { $config = $application->getConfig(); $email = new Email($application); $email->setTemplate('newsletter/template'); $email->set('subject', $this->subject->get()); $email->set('htmlMessage', $this->html->get()); $email->set('text', $this->text->get()); $email->set('email', $this->text->get()); $email->setFrom($config->get('NEWSLETTER_EMAIL') ? $config->get('NEWSLETTER_EMAIL') : $config->get('MAIN_EMAIL'), $config->get('STORE_NAME')); if ($user = $sent->user->get()) { $email->setTo($user->email->get(), $user->getName()); $email->set('email', $user->email->get()); } else { if ($subscriber = $sent->subscriber->get()) { $email->setTo($subscriber->email->get()); $email->set('email', $subscriber->email->get()); } } //$sent->time->set(new ARExpressionHandle('NOW()')); $sent->save(); if ($this->status->get() == self::STATUS_NOT_SENT) { $this->status->set(self::STATUS_PARTIALLY_SENT); $this->time->set(new ARExpressionHandle('NOW()')); $this->save(); } return $email->send(); }
public function add() { if ($this->buildOrderNoteValidator()->isValid()) { $order = CustomerOrder::getInstanceById($this->request->get('id'), CustomerOrder::LOAD_DATA); $note = OrderNote::getNewInstance($order, $this->user); $note->isAdmin->set(true); $note->text->set($this->request->get('comment')); $note->save(); if ($this->config->get('EMAIL_ORDERNOTE')) { $order->user->get()->load(); $email = new Email($this->application); $email->setUser($order->user->get()); $email->setTemplate('order.message'); $email->set('order', $order->toArray(array('payments' => true))); $email->set('message', $note->toArray()); $email->send(); } return new ActionRedirectResponse('backend.orderNote', 'view', array('id' => $note->getID())); } else { return new RawResponse('invalid'); } }
public function send() { if (!$this->buildValidator()->isValid()) { return new ActionRedirectResponse('contactForm', 'index'); } $email = new Email($this->application); $email->setTemplate('contactForm/contactForm'); $email->setFrom($this->request->get('email'), $this->request->get('name')); $email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME')); $email->set('message', $this->request->get('msg')); $email->send(); return new ActionRedirectResponse('contactForm', 'sent'); }
public static function queue_to_email($to_email, $to_name, $subject, $text, $html) { $email = new Email(); $email->set('user_id', $user->id); $email->set('subject', $subject); $email->set('text_body', $text); $email->set('html_body', $html); $email->set('to_email', $to_email); $email->set('to_name', $to_name); $email->set('queue_date', date("Y-m-d H:i:s")); $email->set('status', 'queued'); $email->save(); //send it right away. //$email->send(); }
public function subscribe() { $email = $this->request->get('email'); if (!$this->user->isAnonymous() || User::getInstanceByEmail($email)) { return new ActionRedirectResponse('newsletter', 'alreadySubscribed'); } $validator = $this->getSubscribeValidator(); if (!$validator->isValid()) { return new ActionRedirectResponse('index', 'index'); } $instance = NewsletterSubscriber::getInstanceByEmail($email); if (!$instance) { $instance = NewsletterSubscriber::getNewInstanceByEmail($email); } $instance->save(); $mail = new Email($this->application); $mail->setTo($email); $mail->setTemplate('newsletter/confirm'); $mail->set('subscriber', $instance->toArray()); $mail->set('email', $email); $mail->send(); return new ActionResponse('subscriber', $instance->toArray()); }
public static function queue_to_email($to_email, $to_name, $subject, $text, $html, $user_id = 0) { $email = new Email(); $email->set('user_id', $user_id); $email->set('subject', $subject); $email->set('text_body', $text); $email->set('html_body', $html); $email->set('to_email', $to_email); $email->set('to_name', $to_name); $email->set('queue_date', date("Y-m-d H:i:s")); $email->set('status', 'queued'); $email->save(); //send it right away, or queue it. if (!(defined("QUEUE_EMAIL") && QUEUE_EMAIL)) { $email->send(); } return $email; }
public function action_index() { $email = Security::xss_clean(Arr::get($this->post, 'email', '')); $user = ORM::factory('User')->where('email', '=', $email)->find(); if ($user->loaded() && $user->network_reg == 0 && empty($user->link_activate)) { $date = date("Y-m-d H:i:s"); $code = md5($date . $user->password); Email::connect(); Email::View('reminderapi'); Email::set(array('username' => $user->username, 'id' => $code, 'url' => URL::media($this->language . '/auth/recovery/', true))); Email::send($user->email, array('*****@*****.**', 'e-history.kz'), "E-history.kz, ссылка для смены пароля.", '', true); $save_code = ORM::factory('User', $user->id); $save_code->link_recovery = $code; $save_code->save(); $this->data = true; } else { $this->data['error'] = 'Email is not registered'; } $this->response->body(json_encode($this->data)); }
public function do_register() { $request = $this->application->getRequest(); $first_name = $request->get('firstName'); $last_name = $request->get('lastName'); $company = $request->get('companyName'); $email = $request->get('email'); $pass = $request->get('password'); if (!isset($first_name) || !isset($last_name) || !isset($email) || !isset($pass)) { throw new Exception("Please complete required field " . $last_name); } $user = User::getInstanceByEmail($email); if (isset($user)) { throw new Exception('User already exist'); } $user = User::getNewInstance($email, $pass); $user->firstName->set($first_name); $user->lastName->set($last_name); if (isset($company)) { $user->companyName->set($company); } $user->email->set($email); $user->isEnabled->set('1'); $user->save(); $code = rand(1, 10000000) . rand(1, 10000000); $user->setPreference('confirmation', $code); $user->save(); $_email = new Email($this->application); $_email->setUser($user); $_email->set('code', $code); $_email->setTemplate('user.confirm'); $_email->send(); $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>'); $response->addChild('state', '1'); return new SimpleXMLResponse($response); }
public function action_materials() { if (!Auth::instance()->logged_in()) { $this->redirect('/', 301); } $user_id = $this->user->id; $materials = ORM::factory('Material')->where('user_id', '=', $user_id); $paginate = Paginate::factory($materials)->paginate(NULL, NULL, 3)->render(); $materials = $materials->find_all(); $this->set('materials', $materials); $this->set('paginate', $paginate); $uploader = View::factory('storage/materials')->set('user_id', $user_id)->render(); $this->set('uploader', $uploader); if ($this->request->method() == Request::POST) { $journal = (int) Arr::get($_POST, 'material_type', 0); if ($journal !== 1) { $journal = 0; } try { $material = ORM::factory('Material'); $material->theme = substr(Arr::get($_POST, 'theme', ''), 0, 250); $material->message = substr(Arr::get($_POST, 'message', ''), 0, 500); $material->user_id = $user_id; $material->date = date('Y-m-d H:i:s'); $material->lang_notice = strtolower(Kohana_I18n::lang()); if ($journal) { $material->is_journal = 1; $material->is_moderator = 0; } $material->save(); $files = Arr::get($_POST, 'files', ''); if ($files) { foreach ($files as $key => $file) { if ($key > 7) { break; } if ($file) { $storage = ORM::factory('Storage', (int) $file); try { $upload = ORM::factory('Material_File'); $upload->user_id = $user_id; $upload->material_id = $material->id; $upload->date = date('Y-m-d H:i:s'); $upload->storage_id = (int) $file; $upload->filesize = filesize($storage->file_path); $upload->save(); } catch (ORM_Validation_Exception $e) { } } } } Message::success(i18n::get('The material sent to the moderator. Thank you!')); $user = ORM::factory('User', $user_id); $user_email = $user->email; Email::connect(); Email::View('review_now_' . i18N::lang()); Email::set(array('message' => I18n::get('Оставленный вами материал находится на рассмотрении редакционной коллегии портала'))); Email::send($user_email, array('*****@*****.**', 'e-history.kz'), I18n::get('Рассмотрение материала на портале "История Казахстана" e-history.kz'), '', true); if ($journal != 1) { $material_type = 'Интересные материалы'; $url = URL::media('/manage/materials', TRUE); } else { $material_type = 'Журнал e-history'; $url = URL::media('/manage/materials/ehistory', TRUE); } $user_profile = ORM::factory('User_Profile', $user_id); if ($user_profile->first_name != '') { $user_name = $user_profile->first_name . ' ' . $user_profile->last_name; } else { $user_name = $user->username; } $email = '*****@*****.**'; Email::connect(); Email::View('new_material'); Email::set(array('url' => $url, 'material_type' => $material_type, 'username' => $user_name)); Email::send($email, array('*****@*****.**', 'e-history.kz'), "Новый материал на e-history.kz", '', true); $this->redirect('profile/materials', 301); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $files = Arr::get($_POST, 'files', ''); $this->set('errors', $errors)->set('material', $_POST)->set('files', $files); } } $this->add_cumb('User profile', 'profile'); $this->add_cumb('Downloaded Content', '/'); }
/** * 测试邮件发送 * * @param * @return */ public function email_testingOp() { /** * 读取语言包 */ $lang = Language::getLangContent(); $email_type = trim($_POST['email_type']); $email_host = trim($_POST['email_host']); $email_port = trim($_POST['email_port']); $email_addr = trim($_POST['email_addr']); $email_id = trim($_POST['email_id']); $email_pass = trim($_POST['email_pass']); $email_test = trim($_POST['email_test']); $subject = $lang['test_email']; $site_url = SiteUrl; $site_title = $GLOBALS['setting_config']['site_name']; $message = '<p>' . $lang['this_is_to'] . "<a href='" . $site_url . "' target='_blank'>" . $site_title . '</a>' . $lang['test_email_send_ok'] . '</p>'; if ($email_type == '1') { require_once BasePath . DS . 'framework' . DS . 'libraries' . DS . 'email.php'; $obj_email = new Email(); $obj_email->set('email_server', $email_host); $obj_email->set('email_port', $email_port); $obj_email->set('email_user', $email_id); $obj_email->set('email_password', $email_pass); $obj_email->set('email_from', $email_addr); $obj_email->set('site_name', $site_title); $result = $obj_email->send($email_test, $subject, $message); } else { $result = @mail($email_test, $subject, $message); } if ($result === false) { $message = $lang['test_email_send_fail']; if (strtoupper(CHARSET) == 'GBK') { $message = Language::getUTF8($message); } showMessage($message, '', 'json'); } else { $message = $lang['test_email_send_ok']; if (strtoupper(CHARSET) == 'GBK') { $message = Language::getUTF8($message); } showMessage($message, '', 'json'); } }
public function sendContactForm() { $product = Product::getInstanceByID($this->request->get('id'), Product::LOAD_DATA); $redirect = new ActionRedirectResponse('product', 'index', array('id' => $product->getID())); $validator = $this->buildContactValidator(); if ($validator->isValid()) { $email = new Email($this->application); $email->setTemplate('contactForm/productInquiry'); $email->setFrom($this->request->get('email'), $this->request->get('name')); $email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME')); $email->set('message', $this->request->get('msg')); $email->set('product', $product->toArray()); $email->send(); $msg = $this->translate('_inquiry_form_sent'); if ($this->isAjax()) { $response = new JSONResponse(array('message' => $msg), 'success'); } else { $this->setMessage($msg); $response = $redirect; } return $response; } else { if ($this->isAjax()) { return new JSONResponse(array('errors' => $validator->getErrorList())); } else { return $redirect; } } }
/** * Sends all emails stored in email db, with a one second delay between each sending. * */ public function sendEmails() { $sql = "SELECT * FROM emails WHERE status <> 'sent'"; $q = $this->db->query($sql); $r = $q->result_array(); if (!$this->input->post('submit')) { $viewData['emails'] = $r; $this->load->view('control/send_emails', $viewData); return; } $this->load->model('email'); foreach ($r as $emailAssoc) { sleep(1); $email = new Email(); $email->fromAssoc($emailAssoc); $this->load->library('swiftwrap'); if ($result = $this->swiftwrap->email('*****@*****.**', '44naughty', $email->get('receiver'), $email->get('subject'), $email->get('message'))) { $email->set('status', Email::SENT); $viewData['messages'][] = "Successfully emailed " . $email->get('receiver') . ", with email: " . $email->get('subject'); } else { $email->set('error', $result); $email->set('status', Email::FAILED); } $email->update(); } }
/** * @return User */ private function createUser($password = '', $prefix = '') { $user = User::getNewInstance($this->request->get('email'), $this->request->get('password')); $user->firstName->set($this->request->get($prefix . 'firstName')); $user->lastName->set($this->request->get($prefix . 'lastName')); $user->companyName->set($this->request->get($prefix . 'companyName')); $user->email->set($this->request->get('email')); $user->isEnabled->set(!$this->config->get('REG_EMAIL_CONFIRM')); // custom fields $user->loadRequestData($this->request, array()); if ($password) { $this->session->set('password', $password); $user->setPassword($password); } $user->save(); if (!$this->config->get('REG_EMAIL_CONFIRM')) { SessionUser::setUser($user); $this->sendWelcomeEmail($user); } else { $code = rand(1, 10000000) . rand(1, 10000000); $user->setPreference('confirmation', $code); $user->save(); $email = new Email($this->application); $email->setUser($user); $email->set('code', $code); $email->setTemplate('user.confirm'); $email->send(); } return $user; }
public function action_new() { $id = (int) $this->request->param('id', 0); $debate = ORM::factory('Debate', $id); if ($debate->loaded() and !$debate->admin_create) { $this->redirect('manage/debate'); } $this->set('debate', $debate); if ($this->request->method() == Request::POST) { $author_email = strtolower(Arr::get($_POST, 'author_email', '')); $opponent_email = strtolower(Arr::get($_POST, 'opponent_email', '')); $author = ORM::factory('User')->where('email', '=', $author_email)->find(); $opponent = ORM::factory('User')->where('email', '=', $opponent_email)->find(); if ($opponent->loaded() && $author->loaded() && $author_email != $opponent_email) { if ($debate->loaded()) { $old_title = $debate->title; $old_description = $debate->description; $old_end_time = $debate->end_time; $old_author = $debate->author_id; $old_opponent = $debate->opponent_id; } else { $debate_create = true; } try { $debate->title = Arr::get($_POST, 'title', ''); $debate->description = Arr::get($_POST, 'description', ''); $debate->lifetime = (int) Arr::get($_POST, 'lifetime', ''); $debate->date = $debate->start_time = date('Y-m-d H:i:s'); $debate->end_time = date('Y-m-d H:i:s', strtotime("+" . $debate->lifetime . " hours", strtotime(date('Y-m-d H:i:s')))); $debate->author_id = $debate->replier_id = $author->id; $debate->author_email = $author_email; $debate->opponent_id = $opponent->id; $debate->opponent_email = $opponent_email; $debate->language = $this->language; $debate->is_public = 1; $debate->admin_create = 1; $debate->save(); if (isset($old_title) && $old_title != $debate->title) { $this->log($debate->id, 'title', $old_title, $debate->title); } if (isset($old_description) && $old_description != $debate->description) { $this->log($debate->id, 'description', $old_description, $debate->description); } if (isset($old_end_time) && $old_end_time != $debate->end_time) { $this->log($debate->id, 'time', $old_end_time, $debate->end_time); } if (isset($old_author) && $old_author != $debate->author_id) { $this->log($debate->id, 'member', $old_author, $debate->author_id); } if (isset($old_opponent) && $old_opponent != $debate->opponent_id) { $this->log($debate->id, 'member', $old_opponent, $debate->opponent_id); } if (isset($debate_create)) { $this->log($debate->id, 'create'); } Message::success(i18n::get('Дебаты сохранены')); $debate_link = Url::site("debate/view/" . $debate->id, true); $ending_tr = "Your opponent was given the right to begin debates"; Email::connect(); Email::View('new_debate'); Email::set(array('author' => $author->username, 'link' => 'e-history.kz', 'theme' => "<a href='" . $debate_link . "'>'" . $debate->title . "'</a>", 'ending' => true, 'ending_tr' => $ending_tr)); Email::send($debate->opponent_email, array('*****@*****.**', 'e-history.kz'), __("Участие в дебатах на тему :theme", array(':theme' => "'" . $debate->title . "'")), '', true); $ending_tr = "You are given the right to begin debates"; Email::connect(); Email::View('new_debate'); Email::set(array('author' => $opponent->username, 'link' => 'e-history.kz', 'theme' => "<a href='" . $debate_link . "'>'" . $debate->title . "'</a>", 'ending' => true, 'ending_tr' => $ending_tr)); Email::send($debate->author_email, array('*****@*****.**', 'e-history.kz'), __("Участие в дебатах на тему :theme", array(':theme' => "'" . $debate->title . "'")), '', true); $this->redirect('manage/debate'); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $this->set('debate', $_POST); $this->set('errors', $errors); } } else { if (!$author->loaded()) { $errors['author_email'] = true; } if (!$opponent->loaded()) { $errors['opponent_email'] = true; } if ($author_email == $opponent_email) { $errors['members'] = true; } $this->set('debate', $_POST); $this->set('errors', $errors); } } }
public function action_reject() { $id = $this->request->param('id'); $material = ORM::factory('Material', $id); if (!$material->loaded() or $material->status != 2 or $material->is_moderator == 0) { $this->redirect('manage/materials'); } $user_id = $material->user_id; $lang = $material->lang_notice; $user_email = ORM::factory('User', $user_id)->email; $this->set('material', $material); $token = Arr::get($_POST, 'token', false); $return = Arr::get($_POST, 'r', 'manage/materials'); $this->set('return', Url::site($return)); if ($this->request->method() == Request::POST && Security::token() === $token) { $message = Arr::get($_POST, 'message', ''); if ($message != '') { $material->status = 0; $material->mod_message = $message; $material->moderator_id = $this->user->id; $material->save(); $prelang = i18n::lang(); I18n::lang($lang); Email::connect(); Email::View('review_accept_' . $lang); Email::set(array('message' => I18n::get('Редакционной коллегией портала "История Казахстана" было отказано в публикации оставленного вами материала.'))); Email::send($user_email, array('*****@*****.**', 'e-history.kz'), I18n::get('Рассмотрение материала на портале "История Казахстана" e-history.kz'), '', true); I18n::lang($prelang); $this->redirect('manage/materials'); } else { $this->set('message', $message)->set('token', Security::token(true))->set('errors', true); } } else { $this->set('token', Security::token(true)); } }
public function action_register() { $post = $this->post; $username = Security::xss_clean(Arr::get($post, 'login', '')); $email = Security::xss_clean(Arr::get($post, 'email', '')); $password = Security::xss_clean(Arr::get($post, 'password', '')); $password_confirm = Security::xss_clean(Arr::get($post, 'password', '')); $social_token = Security::xss_clean(Arr::get($post, 'token', '')); if (!Auth::instance()->logged_in()) { if (!empty($post) || $social_token != '') { if ($social_token != '') { $s = file_get_contents('http://ulogin.ru/token.php?token=' . $social_token . '&host=' . $_SERVER['HTTP_HOST']); /* узнать как будет выглядеть массив от клиента с данными из соц сети */ $ulogin = json_decode($s, true); //var_dump($ulogin); //$ulogin = Security::xss_clean(Arr::get($post, 'ulogin', '')); $identity = $ulogin['network'] . '_' . $ulogin['uid']; $user = ORM::factory('user')->where('username', '=', $identity)->or_where('email', 'LIKE', '%' . Arr::get($ulogin, 'email', '1NrJH43ksWlrn'))->find(); if (!$user->loaded()) { $pass = strtotime(date("Y-m-d H:i:s")) . $social_token; $role = ORM::factory('Role', 1); $user = ORM::factory('User')->values(array('username' => $identity, 'password' => $pass, 'password_confirm' => $pass, 'email' => $ulogin['network'] . '_' . $ulogin['uid'] . '_' . Arr::get($ulogin, 'email', $identity . '@test.kz'), 'network_reg' => 1))->save(); $user->add('roles', $role); if ($ulogin['network'] != "yandex") { $photo = Storage::instance()->save_social_photo(Arr::get($ulogin, 'photo', ''), $user->pk()); } else { $photo = 0; } ORM::factory('User_Profile')->values(array('user_id' => $user->pk(), 'first_name' => Arr::get($ulogin, 'first_name', ''), 'last_name' => Arr::get($ulogin, 'last_name', ''), 'photo' => $photo, 'phone' => Arr::get($ulogin, 'phone', ''), 'email' => Arr::get($ulogin, 'email', ''), 'location_id' => 0))->save(); //Auth::instance()->force_login($identity); //успешная регистрация $this->data['socialReg'] = true; } else { $this->data['error'] = 'Social user is already registered'; //Auth::instance()->force_login($user->username); //Пользоатель уже существует } } else { $findusername = ORM::factory('User')->where('username', '=', $username)->find_all()->count(); if ($findusername == 0) { $findemail = ORM::factory('User')->where('email', '=', $email)->find_all()->count(); if ($findemail == 0) { $date = date("Y-m-d H:i:s"); $code = md5($date . $password); $user = ORM::factory('User')->values(array('username' => $username, 'email' => $email, 'password' => $password, 'password_confirm' => $password_confirm, 'network_reg' => 0, 'link_activate' => $code)); $user->save(); Email::connect(); Email::View('activate'); Email::set(array('username' => $username, 'id' => $code, 'url' => URL::site('/', true))); Email::send($email, array('*****@*****.**', 'e-history.kz'), "Подтверждение регистрации на сайте E-history.kz", '', true); $this->data[] = true; //Успешная простая регистрация } else { $this->data['error'] = 'Email is already registered'; //такой ящик уже есть } } else { $this->data['error'] = 'Login is already registered'; } //Message::success('На указанный email отправлено письмо со ссылкой на подтверждение регистрации.'); } } } $this->response->body(json_encode($this->data)); }
public function setEmailSettings($data) { Email::remove("email.transport"); if ($data['emailService'] == 'ses') { Email::set("email.transport.auth.accessKeyId", $data['emailAccessKeyId']); Email::set("email.transport.auth.secretAccessKey", $data['emailSecretAccessKey']); Email::set("email.transport.auth.rateLimit", $data['emailRateLimit']); Email::set("email.transport.auth.region", $data['emailRegion']); } elseif ($data['emailService'] == 'gmail') { Email::set("email.transport.auth.user", $data['emailUser']); Email::set("email.transport.auth.pass", $data['emailPass']); } elseif ($data['emailService'] == 'smtp') { Email::set("email.transport.auth.user", $data['emailUser']); Email::set("email.transport.auth.pass", $data['emailPass']); Email::set("email.transport.host", $data['emailHost']); Email::set("email.transport.port", $data['emailPort']); } if ($data['emailService'] != 'none') { Email::set("email.from", $data['emailSender']); } else { Email::set("email.from", null); } if ($data['emailService'] == 'smtp' || $data['emailService'] == 'none') { Email::set("email.transport.service", null); } else { Email::set("email.transport.service", $data['emailService']); } }
protected function finalizeOrder($options = array()) { if (!count($this->order->getShipments())) { throw new ApplicationException('No shipments in order'); } $user = $this->order->user->get(); $user->load(); $newOrder = $this->order->finalize($options); $orderArray = $this->order->toArray(array('payments' => true)); // send order confirmation email if ($this->config->get('EMAIL_NEW_ORDER')) { $email = new Email($this->application); $email->setUser($user); $email->setTemplate('order.new'); $email->set('order', $orderArray); $email->send(); } // notify store admin if ($this->config->get('NOTIFY_NEW_ORDER')) { $email = new Email($this->application); $email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME')); $email->setTemplate('notify.order'); $email->set('order', $orderArray); $email->set('user', $user->toArray()); $email->send(); } $this->session->set('completedOrderID', $this->order->getID()); if ($newOrder instanceof CustomerOrder) { SessionOrder::save($newOrder); } else { SessionOrder::destroy(); } return new ActionRedirectResponse('checkout', 'completed'); }
protected function finalizeOrder(CustomerOrder $customer_order, User $user) { $user->load(); /*if (!count($customer_order->getShipments())) { throw new Exception('No shipments in order'); }*/ $newOrder = $customer_order->finalize(); $orderArray = $customer_order->toArray(array('payments' => true)); // send order confirmation email if ($this->application->config->get('EMAIL_NEW_ORDER')) { $email = new Email($this->application); $email->setUser($user); $email->setTemplate('order.new'); $email->set('order', $orderArray); $email->send(); } // notify store admin if ($this->application->config->get('NOTIFY_NEW_ORDER')) { $email = new Email($this->application); $email->setTo($this->application->config->get('NOTIFICATION_EMAIL'), $this->application->config->get('STORE_NAME')); $email->setTemplate('notify.order'); $email->set('order', $orderArray); $email->set('user', $user->toArray()); $email->send(); } // if user hasn't wish list items order->finalize() will return null, saving null with SessionOrder causes fatal error! if ($newOrder instanceof CustomerOrder) { return true; } return false; }
protected function _execute(array $params) { $report_list = array(); $start = microtime(true); //получаем список юзеров имеющих подписки $user_list = ORM::factory('Subscription')->group_by('user_id')->find_all(); foreach ($user_list as $oneuser) { set_time_limit(30); $user_id = $oneuser->user_id; $lang = ORM::factory('Subscription_Setting')->where('user_id', '=', $user_id)->find()->lang; $lang_arr = array('ru', 'en', 'kz', 'RU', 'EN', 'KZ'); if (!in_array($lang, $lang_arr)) { $lang = 'ru'; } $period = ORM::factory('Subscription_Setting')->where('user_id', '=', $user_id)->find()->period; $user = ORM::factory('User', $user_id); $user_profile = ORM::factory('User_Profile', $user_id); $update_time = false; $period_arr = array('1', '2', '3'); if (!in_array($period, $period_arr)) { $update_time = true; } if ($period == '1') { $update_time = true; } if ($period == '2') { if (date('N') == 1) { $update_time = true; } } if ($period == '3') { if (date('j') == 1) { $update_time = true; } } //Как обращаться к пользователю if ($user_profile->first_name != '') { $user_name = $user_profile->first_name . ' ' . $user_profile->last_name; } else { $user_name = $user->username; } //На какое мыло слать $user_email = $user->email; //выставляем язык для рассылки I18n::lang($lang); //получаем список подписок текущего пользователя $sub_list = ORM::factory('Subscription')->where('user_id', '=', $user_id)->find_all(); $links = array(); //ищем самую старую дату из всех подписок $lastdate = '3000-01-01 00:00:00'; foreach ($sub_list as $sub) { if ($lastdate > $sub->date) { $lastdate = $sub->date; } } //если пришло время обновляться if ($update_time == true) { //перебираем список подписок текущего юзера foreach ($sub_list as $sub) { //Получаем запись из Pages, на которую подписан юзер $page = ORM::factory('Page', $sub->category_id); //Смотрим ключ записи, если ключ пустой то ищем имя ключа родителя $key = $page->key; if ($page->key == '' and $page->lvl == '3') { $page_lvl = ORM::factory('Page', $page->parent_id)->as_array(null, 'key'); $key = $page_lvl['key']; } //перебираем все варианты ключей //История казахстана и подразделы if ($key == 'history') { set_time_limit(30); if ($page->lvl == 2) { $allsubhistory = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $allsubhistory = ORM::factory('Page')->where('parent_id', 'in', $allsubhistory)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $allsubhistory)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($page->lvl == 3) { $allsubhistory = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $allsubhistory)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } //Первый президент и подразделы if ($key == 'president') { set_time_limit(30); if ($page->lvl == 3) { if ($page->key == '') { $find_child = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($find_child) > 0) { if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } else { if (count($inlog) > 0) { $find_child[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } } if ($page->lvl == 2) { $president = false; $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); foreach ($find_child_lvl3 as $child_lvl3) { if ($president == false) { if ($child_lvl3->key == '') { $find_child = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($find_child) > 0) { if (count($inlog) > 0) { if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $president = true; } } } else { if (count($inlog) > 0) { $find_child[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $find_child)) > 0) { $president = true; } } } } $e = explode('_', $page->key); if ($e[0] == 'books' and isset($e[2])) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); $cats[] = $e[2]; if (count($inlog) > 0) { if (count(Subtool::findinbooks($inlog, $cats)) > 0) { $president = true; } } } } } if ($president == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } //Экспертный взгляд и подразделы if ($key == 'expert' and $page->key == 'expert' and $page->lvl == 3) { set_time_limit(30); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Expert_Opinion'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'expert' and $page->key == '' and $page->lvl == 3) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'expert' and $page->lvl == 2) { set_time_limit(30); $expert = false; $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); foreach ($find_child_lvl3 as $child_lvl3) { if ($expert == false) { if ($child_lvl3->key == 'expert') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Expert_Opinion'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $expert = true; } } if ($child_lvl3->key == '') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $expert = true; } } } } } if ($expert == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Электронный архив и подразделы if ($key == 'archive' and $page->lvl == 3) { set_time_limit(30); $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); if (count($find_child_lvl3) > 0) { $archive_lvl3 = false; foreach ($find_child_lvl3 as $child_lvl3) { if ($archive_lvl3 == false) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $archive_lvl3 = true; } } } } if ($archive_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $sub->category_id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } if ($key == 'archive' and $page->lvl == 2) { $find_all_child = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); $archive_lvl3 = false; foreach ($find_all_child as $finded_child) { if ($archive_lvl3 == false) { set_time_limit(30); $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $finded_child->id)->find_all(); $archive_lvl3 = false; if (count($find_child_lvl3) > 0) { foreach ($find_child_lvl3 as $child_lvl3) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $archive_lvl3 = true; } } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsub[] = $finded_child->id; if (count(Subtool::findincontents($inlog, $allsub)) > 0) { $archive_lvl3 = true; } } } } } if ($archive_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Персоналии if ($key == 'biography' and $page->lvl == 3) { $all_biography_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); foreach ($all_biography_lvl4 as $biography_lvl4) { set_time_limit(30); $newbiography = false; $e = explode('_', $biography_lvl4->key); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Biography'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $biography = ORM::factory('Biography')->where('id', 'in', $inlog)->and_where('category_id', '=', $e[1])->find_all()->as_array(null, 'id'); if (count($biography) > 0) { $newbiography = true; } } } if ($newbiography == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'personal' and $page->lvl == 2) { $all_biography_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all()->as_array(null, 'id'); $all_biography_lvl4 = ORM::factory('Page')->where('parent_id', 'in', $all_biography_lvl3)->find_all(); $newbiography = false; foreach ($all_biography_lvl4 as $biography_lvl4) { set_time_limit(30); if ($newbiography == false) { $e = explode('_', $biography_lvl4->key); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Biography'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $biography = ORM::factory('Biography')->where('id', 'in', $inlog)->and_where('category_id', '=', $e[1])->find_all()->as_array(null, 'id'); if (count($biography) > 0) { $newbiography = true; } } } } if ($newbiography == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Книги любые $e = explode('_', $page->key); if ($e[0] == 'books' and isset($e[2])) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); $cats[] = $e[2]; if (count($inlog) > 0) { if (count(Subtool::findinbooks($inlog, $cats)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } // Историческое образование if ($key == 'education' and $page->lvl == 3) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all(); if (count($find_child_lvl3) > 0) { $education_lvl3 = false; foreach ($find_child_lvl3 as $child_lvl3) { if ($education_lvl3 == false) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $e = explode('_', $child_lvl3->key); $allsub[] = $e[1]; if (count(Subtool::findinbooks($inlog, $allsub)) > 0) { $education_lvl3 = true; } } } } if ($education_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'education' and $page->lvl == 2) { $find_child_lvl2 = ORM::factory('Page')->where('parent_id', '=', $sub->category_id)->find_all()->as_array(null, 'id'); $neweducation = false; foreach ($find_child_lvl2 as $child_lvl2) { set_time_limit(30); if ($neweducation == false) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $child_lvl2)->find_all(); if (count($find_child_lvl3) > 0) { foreach ($find_child_lvl3 as $child_lvl3) { $allsub = array(); $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $e = explode('_', $child_lvl3->key); $allsub[] = $e[1]; if (count(Subtool::findinbooks($inlog, $allsub)) > 0) { $neweducation = true; } } } } else { $booksfore = ORM::factory('Page', $child_lvl2); //опасный момент $e = explode('_', $booksfore->key); if ($e[0] == 'books' and isset($e[2])) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); $cats[] = $e[2]; if (count($inlog) > 0) { if (count(Subtool::findinbooks($inlog, $cats)) > 0) { $neweducation = true; } } } } } } if ($neweducation == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Организации образования и науки if ($key == 'institute' and $page->lvl == 3) { set_time_limit(30); $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); if (count($find_child_lvl4->as_array(null, 'id')) > 0) { foreach ($find_child_lvl4 as $child_lvl4) { $find_child_lvl5 = ORM::factory('Page')->where('parent_id', '=', $child_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl5) > 0) { $child_lvl5[] = $find_child_lvl5[0]; } } if (count($child_lvl5) > 0) { $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl5)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } else { $child_lvl4_ids = $find_child_lvl4->as_array(null, 'id'); $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl4_ids)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $page->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } if ($key == 'institute' and $page->lvl == 2) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newinstitute = false; foreach ($find_child_lvl3 as $child_lvl3) { set_time_limit(30); if ($newinstitute == false) { $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $child_lvl3->id)->find_all(); if (count($find_child_lvl4->as_array(null, 'id')) > 0) { foreach ($find_child_lvl4 as $child_lvl4) { set_time_limit(30); $find_child_lvl5 = ORM::factory('Page')->where('parent_id', '=', $child_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl5) > 0) { $child_lvl5[] = $find_child_lvl5[0]; } } if (count($child_lvl5) > 0) { $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl5)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $newinstitute = true; } } else { $child_lvl4_ids = $find_child_lvl4->as_array(null, 'id'); $find_organization = ORM::factory('Organization')->where('page_id', 'in', $child_lvl4_ids)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($find_organization) > 0) { $newinstitute = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $page->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $newinstitute = true; } } } } } if ($newinstitute == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'people' and $page->lvl == 3) { $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl4) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_child_lvl4; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $page->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } } if ($key == 'people' and $page->lvl == 2) { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newpeople = false; foreach ($find_child_lvl3 as $child_lvl3) { set_time_limit(30); if ($newpeople == false) { $find_child_lvl4 = ORM::factory('Page')->where('parent_id', '=', $child_lvl3->id)->find_all()->as_array(null, 'id'); if (count($find_child_lvl4) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_child_lvl4; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $newpeople = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $child_lvl3->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $newpeople = true; } } } } } if ($newpeople == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //публикации if ($key == 'publications' and $page->lvl == 2) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Publication'))->and_where('language', '=', $lang)->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($inlog) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //Электронный журнал "e-history.kz" if ($key == 'metodology' or $key == 'crossstudy' or $key == 'metodicheskie') { $find_childs_lvl4 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $finded_lvl3 = false; foreach ($find_childs_lvl4 as $childs_lvl4) { set_time_limit(30); if ($finded_lvl3 == false) { set_time_limit(30); $find_childs_lvl5 = ORM::factory('Page')->where('parent_id', '=', $childs_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_childs_lvl5) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_childs_lvl5; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $childs_lvl4->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; } } } } } if ($finded_lvl3 == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'journal_ehistory') { $find_childs_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newehistory = false; foreach ($find_childs_lvl3 as $childs_lvl3) { set_time_limit(30); if ($newehistory == false) { $find_childs_lvl4 = ORM::factory('Page')->where('parent_id', '=', $childs_lvl3->id)->find_all(); $finded_lvl3 = false; foreach ($find_childs_lvl4 as $childs_lvl4) { if ($finded_lvl3 == false) { set_time_limit(30); $find_childs_lvl5 = ORM::factory('Page')->where('parent_id', '=', $childs_lvl4->id)->find_all()->as_array(null, 'id'); if (count($find_childs_lvl5) > 0) { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs = $find_childs_lvl5; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; $newehistory = true; } } } else { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Pages_Content'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $allsubs[] = $childs_lvl4->id; if (count(Subtool::findincontents($inlog, $allsubs)) > 0) { $finded_lvl3 = true; $newehistory = true; } } } } } } } if ($newehistory == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } //блок интерактив if ($key == 'debate') { $debates = ORM::factory('Debate')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($debates) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'briefings') { $briefings = ORM::factory('Briefing')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($briefings) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'scorm') { $educations = ORM::factory('Education')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($educations) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'ent') { $ent = ORM::factory('Ent')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($ent) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'interactive') { $interactives = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newinteractive = false; foreach ($interactives as $child) { set_time_limit(30); if ($newinteractive == false) { $child_key = $child->key; if ($child_key == 'debate') { $debates = ORM::factory('Debate')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($debates) > 0) { $newinteractive = true; } } if ($child_key == 'briefings') { $briefings = ORM::factory('Briefing')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($briefings) > 0) { $newinteractive = true; } } if ($child_key == 'scorm') { $educations = ORM::factory('Education')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($educations) > 0) { $newinteractive = true; } } if ($child_key == 'ent') { $ent = ORM::factory('Ent')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($ent) > 0) { $newinteractive = true; } } } } if ($newinteractive == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'photosets') { $photosets = ORM::factory('Photoset')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($photosets) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'video') { $videos = ORM::factory('Video')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($videos) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'audio') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Audio'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $audios = ORM::factory('Audio')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($audios) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'infographs') { $infographs = ORM::factory('Infograph')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($infographs) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } if ($key == 'library') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $books = ORM::factory('Book')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($books) > 0) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } } if ($key == 'multimedia') { $find_child_lvl3 = ORM::factory('Page')->where('parent_id', '=', $page->id)->find_all(); $newmultimedia = false; foreach ($find_child_lvl3 as $child_lvl3) { set_time_limit(30); if ($newmultimedia == false) { $child_key = $child_lvl3->key; if ($child_key == 'photosets') { $photosets = ORM::factory('Photoset')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($photosets) > 0) { $newmultimedia = true; } } if ($child_key == 'video') { $videos = ORM::factory('Video')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($videos) > 0) { $newmultimedia = true; } } if ($child_key == 'audio') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Audio'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $audios = ORM::factory('Audio')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($audios) > 0) { $newmultimedia = true; } } } if ($child_key == 'infographs') { $infographs = ORM::factory('Infograph')->where('date', '>', $lastdate)->find_all()->as_array(null, 'id'); if (count($infographs) > 0) { $newmultimedia = true; } } if ($child_key == 'library') { $inlog = ORM::factory('Log')->where(DB::expr('lower(model)'), 'LIKE', strtolower('Model_Book'))->and_where('date', '>', $lastdate)->find_all()->as_array(null, 'content_id'); if (count($inlog) > 0) { $books = ORM::factory('Book')->where('id', 'in', $inlog)->find_all()->as_array(null, 'id'); if (count($books) > 0) { $newmultimedia = true; } } } } } if ($newmultimedia == true) { $links[] = array('link' => URL::media($lang . '/contents/list/' . $sub->category_id), 'title' => $page->name); } } $subupdate = ORM::factory('Subscription', $sub->id); $subupdate->date = date("Y-m-d H:i:s"); $subupdate->save(); } $time = microtime(true) - $start; if (count($links) != 0) { $report_list[] = array('time' => $time, 'user_id' => $user_id); Email::connect(); if ($lang == 'ru' or $lang == 'RU') { Email::View('distribution_ru'); } if ($lang == 'kz' or $lang == 'KZ') { Email::View('distribution_kz'); } if ($lang == 'en' or $lang == 'EN') { Email::View('distribution_en'); } Email::set(array('user' => $user_name, 'period1' => $lastdate, 'period2' => date("Y-m-d H:i:s"), 'unsublink' => Subtool::media('/' . $lang . '/profile/subscription'), 'links' => $links)); set_time_limit(60); Email::send($user_email, array('*****@*****.**', 'e-history.kz'), I18n::get('Обновления на портале Истории Казахстана e-history.kz'), '', true); } } } set_time_limit(60); if (count($report_list) != 0) { Email::connect(); Email::View('successsub'); Email::set(array('message' => 'Все рассылки успешно разослались', 'list' => $report_list)); Email::send('*****@*****.**', array('*****@*****.**', 'e-history.kz'), "Рассылки на истории", '', true); } else { Email::connect(); Email::View('default'); Email::set(array('message' => 'Сегодня никому ничего не отправлено')); Email::send('*****@*****.**', array('*****@*****.**', 'e-history.kz'), "Рассылки на истории", '', true); } }
public function action_agree() { $id = (int) $this->request->param('id', 0); if (!Auth::instance()->logged_in()) { Message::success(i18n::get('You can not participate in this debate')); $this->redirect('debate', 301); } $debate = ORM::factory('Debate', $id); $nowdate = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s', strtotime("+36 hours", strtotime($debate->date))); if ($debate->opponent_email == Auth::instance()->get_user()->email and $debate->is_closed == 0 and $debate->is_public == 0 or $date < $nowdate) { $date = date('Y-m-d H:i:s'); $debate->start_time = $date; $debate->end_time = date('Y-m-d H:i:s', strtotime("+" . $debate->lifetime . " hours", strtotime($date))); $debate->opponent_id = Auth::instance()->get_user()->id; $debate->is_public = 1; $debate->replier_id = $debate->author_id; $debate->save(); $user_id = Auth::instance()->get_user()->id; $user = ORM::factory('User', $debate->author_id); $email = $user->profile->email; $opponent = $user->username; $user = ORM::factory('User', $user_id); $author = $user->username; $debate_link = Url::site("debate/view/" . $debate->id, true); Message::success(i18n::get('You have agreed to participate in the debates. Notification to this effect was sent to your opponent')); Email::connect(); Email::View('debate_agree'); Email::set(array('opponent' => $opponent, 'author' => $author, 'link' => 'e-history.kz', 'theme' => "<a href='" . $debate_link . "'>'" . $debate->title . "'</a>")); Email::send($email, array('*****@*****.**', 'e-history.kz'), __("Ваш оппонент согласился участвовать в дебатах на портале :link", array(':link' => 'History.kz')), '', true); $this->redirect('debate/view/' . $id, 301); } else { if ($date < $nowdate) { Message::success(i18n::get('Expired 36 hours during which you could agree to take part in the debate')); } else { Message::success(i18n::get('You can not give consent to participate in this debate')); } $this->redirect('debate', 301); } }
public function action_show() { $id = (int) $this->request->param('id', 0); $page = (int) $this->request->param('page', 0); $theme = ORM::factory('Forum_Theme', $id); $section = ORM::factory('Forum', $theme->forum_id); if (!$theme->loaded()) { throw new HTTP_Exception_404(); } $notification = ORM::factory('Forum_Notification')->where('user_id', '=', $this->user)->and_where('theme_id', '=', $id)->find(); $messages = $theme->forum_message->where('first_message', '<>', 1)->and_where('companion_id', '=', 0)->order_by('date', 'asc'); $paginate = Paginate::factory($messages)->paginate(NULL, NULL, 4)->render(); $messages = $messages->find_all(); $this->add_cumb('Forum', 'forum'); $this->add_cumb($section->name, 'forum/list/' . $section->id); $this->add_cumb($theme->name, '/'); /* description */ $first_message = $theme->forum_message->where('first_message', '=', 1)->find(); $this->metadata->snippet($first_message->text); $this->set('theme', $theme)->set('page', $page)->set('messages', $messages)->set('notification', $notification->notification)->set('paginate', $paginate); if ($post = $this->request->post()) { if (!$this->user) { throw new HTTP_Exception_404(); } try { $email_notification = Security::xss_clean(Arr::get($post, 'notification', 0)); $message = ORM::factory('Forum_Message'); $message->text = Security::xss_clean(Arr::get($post, 'text', '')); $message->user_id = $this->user->pk(); $message->section_id = $theme->forum_id; $message->theme_id = $id; $message->companion_id = 0; $message->date = date('Y-m-d H:i:s'); $message->save(); if (!empty($email_notification)) { $notification = 1; } else { $notification = 0; } $notification_user = ORM::factory('Forum_Notification')->where('user_id', '=', $this->user->pk())->and_where('theme_id', '=', $id)->find(); if ($notification_user->loaded()) { $notification_user->notification = $notification; $notification_user->update(); } else { $notification_user->user_id = $this->user->pk(); $notification_user->theme_id = $id; $notification_user->notification = $notification; $notification_user->save(); } /* чтобы при добавлении нового сообщения нормально отработала пагинация */ $messages = $theme->forum_message->where('first_message', '<>', 1)->order_by('date', 'asc'); $paginate = Paginate::factory($messages)->paginate(NULL, NULL, 4); $last_page = $paginate->page_count(); $link = '/' . $this->language . '/forum/show/' . $id . '/page-' . $last_page; /* email уведомление подписанным на тему пользователям */ $users = ORM::factory('User')->join('forum_notifications', 'LEFT')->on('user.id', '=', 'forum_notifications.user_id')->where('forum_notifications.notification', '=', '1')->and_where('forum_notifications.theme_id', '=', $id)->and_where('forum_notifications.user_id', '<>', $this->user)->find_all(); if ($users->count() > 0) { Email::connect(); Email::View('forum_notification'); foreach ($users as $user) { Email::set(array('id' => $user->id, 'receivername' => $user->show_name(), 'sendername' => $this->user->show_name(), 'url' => $link)); Email::send($user->email, array('*****@*****.**', 'e-history.kz'), "Ответ в теме " . $theme->name, '', true); } } $this->redirect('forum/show/' . $id . '/page-' . $last_page, 301); } catch (ORM_Validation_Exception $e) { $errors = $e->errors($e->alias()); $this->set('errors', $errors); $this->set('message', $_POST); } } }
/** * 测试邮件发送 * * @param * @return */ public function email_testingOp() { /** * 读取语言包 */ $lang = Language::getLangContent(); $email_host = trim($_POST['email_host']); $email_port = trim($_POST['email_port']); $email_addr = trim($_POST['email_addr']); $email_id = trim($_POST['email_id']); $email_pass = trim($_POST['email_pass']); $email_test = trim($_POST['email_test']); $subject = $lang['test_email']; $site_url = SHOP_SITE_URL; $site_title = C('site_name'); $message = '<p>' . $lang['this_is_to'] . "<a href='" . $site_url . "' target='_blank'>" . $site_title . '</a>' . $lang['test_email_send_ok'] . '</p>'; // if ($email_type == '1'){ $obj_email = new Email(); $obj_email->set('email_server', $email_host); $obj_email->set('email_port', $email_port); $obj_email->set('email_user', $email_id); $obj_email->set('email_password', $email_pass); $obj_email->set('email_from', $email_addr); $obj_email->set('site_name', $site_title); $result = $obj_email->send($email_test, $subject, $message); // }else { // $result = @mail($email_test,$subject,$message); // } if ($result === false) { $message = $lang['test_email_send_fail']; if (strtoupper(CHARSET) == 'GBK') { $message = Language::getUTF8($message); } showMessage($message, '', 'json'); } else { $message = $lang['test_email_send_ok']; if (strtoupper(CHARSET) == 'GBK') { $message = Language::getUTF8($message); } showMessage($message, '', 'json'); } }
public function sendStatusNotifyEmail(CustomerOrder $order) { $status = $order->status->get(); $enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES'); $m = array('EMAIL_STATUS_UPDATE_NEW' => CustomerOrder::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => CustomerOrder::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => CustomerOrder::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => CustomerOrder::STATUS_SHIPPED); $sendEmail = false; foreach ($m as $configKey => $constValue) { if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) { $sendEmail = true; } } if ($this->config->get('EMAIL_STATUS_UPDATE') || $sendEmail) { $this->loadLanguageFile('Frontend'); $this->application->loadLanguageFiles(); $order->user->get()->load(); $email = new Email($this->application); $email->setUser($order->user->get()); $email->setTemplate('order.status'); $email->set('order', $order->toArray(array('payments' => true))); $email->set('shipments', $order->getShipments()->toArray()); $email->send(); } }
public function send() { if (!$this->buildValidator()->isValid()) { return new ActionRedirectResponse('EyeExam', 'index'); } $eyeExamScheduleID = $this->request->get('time'); // this field is used for passing ID $eyeExamSchedule = EyeExamSchedule::getInstanceByID('EyeExamSchedule', $eyeExamScheduleID, ActiveRecord::LOAD_DATA); $requestDate = $eyeExamSchedule->date->get(); $requestTime = $eyeExamSchedule->time->get(); $eyeExamRequest = EyeExamRequest::getNewInstance(); $eyeExamRequest->date->set(strtotime($requestDate)); // does it still needed in DB?? $eyeExamRequest->time->set($requestTime); // does it still needed in DB?? // custom fields $eyeExamRequest->getSpecification()->loadRequestData($this->request); $eyeExamRequest->save(); $eyeExamSchedule->setFieldValue('eyeExamRequestID', $eyeExamRequest); $eyeExamSchedule->save(); $email = new Email($this->application); $email->setTemplate('module/eye-exam/eyeExam/eyeExamRequestNotify'); $email->setTo($this->config->get('NOTIFICATION_EMAIL'), $this->config->get('STORE_NAME')); $email->set('date', $requestDate); $email->set('time', $requestTime); $email->set('doctorName', $eyeExamSchedule->doctorName->get()); $email->send(); $response = new ActionResponse(); $response->set('date', $requestDate); $response->set('time', $requestTime); $this->addBreadCrumb($this->translate('_title_lang'), $this->router->createUrl(array('controller' => 'EyeExam'))); $this->addBreadCrumb($this->translate('_form_sent'), ''); return $response; }
public function action_reminder() { $errors = NULL; if (!Auth::instance()->logged_in()) { if ($this->request->post()) { if (Captcha::valid($_POST['captcha'])) { $user = ORM::factory('User')->where('username', '=', Arr::get($_POST, 'username', ''))->find(); if ($user->loaded() && $user->network_reg == 0 && empty($user->link_activate)) { $date = date("Y-m-d H:i:s"); $code = md5($date . $user->password); Email::connect(); Email::View('reminder'); Email::set(array('username' => $user->username, 'id' => $code, 'url' => str_replace('/auth/reminder', '', URL::current(true)))); Email::send($user->email, array('*****@*****.**', 'e-history.kz'), "E-history.kz, ссылка для смены пароля.", '', true); $save_code = ORM::factory('User', $user->id); $save_code->link_recovery = $code; $save_code->save(); Message::success('Ссылка для восстановления пароля отправлена на указанный при регистрации адрес электронной почты.'); $this->redirect('/', 301); } else { $errors['login'] = I18n::get("Пользователь с таким логином не зарегистрирован."); } } else { $errors['captcha'] = I18n::get("Неправильно ввели код подтверждения."); } } } $this->set('errors', $errors); }