当前位置: 首页>>代码示例>>PHP>>正文


PHP Email::View方法代码示例

本文整理汇总了PHP中Email::View方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::View方法的具体用法?PHP Email::View怎么用?PHP Email::View使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Email的用法示例。


在下文中一共展示了Email::View方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_index

 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('no-reply@e-history.kz', '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));
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:20,代码来源:Passwordrecovery.php

示例2: action_agree

 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('no-reply@e-history.kz', '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);
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:40,代码来源:Debate.php

示例3: action_materials

 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('no-reply@e-history.kz', '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 = 'kaz.ehistory@gmail.com';
             Email::connect();
             Email::View('new_material');
             Email::set(array('url' => $url, 'material_type' => $material_type, 'username' => $user_name));
             Email::send($email, array('no-reply@e-history.kz', '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', '/');
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:86,代码来源:Profile.php

示例4: _execute


//.........这里部分代码省略.........
                 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('no-reply@e-history.kz', '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('kolledgpgu@mail.ru', array('no-reply@e-history.kz', 'e-history.kz'), "Рассылки на истории", '', true);
     } else {
         Email::connect();
         Email::View('default');
         Email::set(array('message' => 'Сегодня никому ничего не отправлено'));
         Email::send('kolledgpgu@mail.ru', array('no-reply@e-history.kz', 'e-history.kz'), "Рассылки на истории", '', true);
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:101,代码来源:Sendsub.php

示例5: action_new

 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('no-reply@e-history.kz', '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('no-reply@e-history.kz', '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);
         }
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:88,代码来源:Debate.php

示例6: action_reject

 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('no-reply@e-history.kz', '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));
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:36,代码来源:Materials.php

示例7: action_reminder

 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('no-reply@e-history.kz', '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);
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:29,代码来源:Auth.php

示例8: action_register

 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('no-reply@e-history.kz', '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));
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:65,代码来源:Auth.php

示例9: action_show

 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('no-reply@e-history.kz', '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);
         }
     }
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:72,代码来源:Forum.php


注:本文中的Email::View方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。