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


PHP Message::set方法代码示例

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


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

示例1: action_delete

 public function action_delete($id)
 {
     $post = Jelly::select('forum_post')->where('id', '=', $id)->load();
     if ($post->loaded()) {
         $this->title = 'Forum - Post - Delete';
     } else {
         Message::set(Message::ERROR, 'Post does not exist');
         $this->request->redirect('forum');
     }
     if ($this->user->id != $post->user->id) {
         Message::set(Message::ERROR, 'You are not the author of this post.');
         $this->request->redirect('forum');
     } else {
         $topic = Jelly::select('forum_topic')->where('id', '=', $post->topic->id)->load();
         if ($topic->posts > 1) {
             $topic->posts = $topic->posts - 1;
             $topic->save();
             $post->delete();
             Message::set(Message::SUCCESS, 'Post has been deleted.');
             $this->request->redirect('forum');
         }
         if ($topic->posts == 1) {
             $topic->delete();
             $post->delete();
             Message::set(Message::SUCCESS, 'Post has been deleted.');
             $this->request->redirect('forum');
         }
     }
     $this->template->content = View::factory('forum/post/delete')->set('post', $post);
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:30,代码来源:post.php

示例2: action_reply

 /**
  * Create a new post.
  */
 public function action_reply($id)
 {
     $topic = Jelly::select('forum_topic')->where('id', '=', $id)->load();
     // Make sure the topic exists
     if (!$topic->loaded()) {
         Message::set(Message::ERROR, 'Topic does not exist');
         $this->request->redirect('forum');
     }
     $this->title = 'Forum - Reply to ' . $topic->title;
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->filter(TRUE, 'htmlspecialchars', array(ENT_QUOTES))->rule('title', 'not_empty')->rule('title', 'min_length', array(3))->rule('title', 'max_length', array(20))->rule('content', 'not_empty')->rule('content', 'min_length', array(5))->rule('content', 'max_length', array(1000));
     if ($post->check()) {
         $values = array('title' => $post['title'], 'content' => $post['content'], 'user' => $this->user->id, 'topic' => $id);
         $message = Jelly::factory('forum_post');
         // Assign the validated data to the Jelly object
         $message->set($values);
         $message->save();
         $topic_id = $id;
         $topic = Jelly::select('forum_topic')->where('id', '=', $topic_id)->load();
         $topic->posts = $topic->posts + 1;
         $topic->save();
         Message::set(Message::SUCCESS, 'You posted a new reply.');
         $this->request->redirect('forum/topic/' . $id);
     } else {
         $this->errors = $post->errors('forum');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('forum/post/create')->set('post', $post->as_array());
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:34,代码来源:topic.php

示例3: action_new_topic

 /**
  * Create a new topic.
  */
 public function action_new_topic($id)
 {
     $this->title = 'Forum - New Topic';
     $category = Jelly::select('forum_category')->where('id', '=', $id)->load();
     if (!$category->loaded()) {
         Message::set(Message::ERROR, 'Category does not exist');
         $this->request->redirect('forum');
     }
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->filter(TRUE, 'htmlspecialchars', array(ENT_QUOTES))->rule('title', 'not_empty')->rule('title', 'min_length', array(3))->rule('title', 'max_length', array(20))->rule('content', 'not_empty')->rule('content', 'min_length', array(5))->rule('content', 'max_length', array(1000));
     if ($post->check()) {
         $topic_values = array('title' => $post['title'], 'user' => $this->user->id, 'category' => $id, 'status' => 'open', 'posts' => '1');
         $topic = Jelly::factory('forum_topic');
         // Assign the validated data to the sprig object
         $topic->set($topic_values);
         $topic->save();
         $topic_id = $topic->id;
         $post_values = array('title' => $post['title'], 'content' => $post['content'], 'user' => $this->user->id, 'topic' => $topic_id);
         $message = Jelly::factory('forum_post');
         // Assign the validated data to the sprig object
         $message->set($post_values);
         $message->save();
         Message::set(Message::SUCCESS, 'You created a topic.');
         $this->request->redirect('forum/category/' . $id);
     } else {
         $this->errors = $post->errors('forum');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('forum/topic/create')->set('post', $post->as_array());
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:35,代码来源:category.php

示例4: action_heal

 public function action_heal()
 {
     // Check if the user has a character already.
     if (!$this->character->loaded()) {
         $this->request->redirect('character/create');
     }
     $character = $this->character;
     // Initialize the character class, and set the players character as the default.
     $char = new Character($character);
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('amount', 'not_empty')->rule('amount', 'digit')->callback('amount', array($this, 'can_heal'));
     if ($post->check()) {
         try {
             $character->hp = $character->hp + $post['amount'];
             $character->money = $character->money - $post['amount'] * $this->heal_cost;
             $character->save();
             $this->request->redirect('character');
         } catch (Validate_Exception $e) {
             // Get the errors using the Validate::errors() method
             $this->errors = $e->array->errors('register');
         }
     } else {
         $this->errors = $post->errors('character/create');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('character/heal')->set('character', $character)->set('char', $char)->set('post', $post);
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:28,代码来源:character.php

示例5: action_edit

 /**
  * Редактирование новости автосервиса
  * @return void
  */
 function action_edit()
 {
     $id = $this->request->param('id', null);
     if (!empty($id)) {
         $payment = ORM::factory('payment', $id);
         if (!$payment->loaded()) {
             Message::set(Message::ERROR, "Платежная система не найдена");
             $this->request->redirect('admin/payment');
         }
         $this->values = $payment->as_array();
     } else {
         Message::set(Message::ERROR, "Платежная система не найдена");
         $this->request->redirect('admin/payment');
     }
     if ($_POST) {
         try {
             $payment->values($_POST, array('payment_name', 'status', 'position', 'tips', 'description'));
             $payment->save();
             Message::set(Message::SUCCESS, 'Платежная система сохранена');
             $this->request->redirect('admin/payment');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('backend/payment/form')->set('errors', $this->errors)->set('values', $this->values)->set('url', 'admin/payment/main/edit/' . $id);
     $this->template->title = 'Редактирование "' . $payment->payment_name;
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:34,代码来源:main.php

示例6: action_view

 public function action_view($id2, $id)
 {
     if (!is_numeric($id)) {
         Message::set(Message::ERROR, 'Invalid ID');
         $this->request->redirect('zone');
     }
     $item = Model_Shop::get_one_item($this->shop->id, $id);
     $this->title = $item->name;
     $this->item = $item;
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('amount', 'digit')->callback('amount', array($this, 'shop_got_item'));
     if ($post->check()) {
         $item2 = Model_User::get_item($this->user->id, $id);
         // User got the item in his relation table.
         if ($item2) {
             DB::update('user_items')->set(array('amount' => new Database_Expression('amount + ' . $post['amount'])))->where('user_id', '=', $this->user->id)->and_where('item_id', '=', $id)->execute();
         } else {
             DB::insert('user_items', array('user_id', 'item_id', 'amount'))->values(array($this->user->id, $id, $post['amount']))->execute();
         }
         DB::update('shop_items')->set(array('amount' => new Database_Expression('amount - ' . $post['amount'])))->where('shop_id', '=', $this->shop_id)->and_where('item_id', '=', $id)->execute();
         $item->amount = $item->amount - $post['amount'];
         Message::set(Message::SUCCESS, 'You bought ' . $post['amount'] . ' ' . $item->name);
     } else {
         if ($post->errors()) {
             Message::set(Message::ERROR, $post->errors('shop'));
         }
     }
     $this->template->content = View::factory('shop/view')->set('shop', $this->shop)->set('item', $item);
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:28,代码来源:shop.php

示例7: action_add

 public function action_add()
 {
     $cities = ORM::factory('city')->get_cities();
     $services = ORM::factory('service')->get_services_as_array();
     if ($_POST) {
         if (isset($_POST['city_id']) and $_POST['city_id'] != 0) {
             $services = ORM::factory('service')->get_services_as_array(array('city_id' => $_POST['city_id']));
         }
         $review = ORM::factory('review');
         try {
             $review->values($_POST, array('name', 'email', 'text', 'service_id'));
             if ($this->user) {
                 $review->user_id = $this->user->id;
             }
             $review->active = 0;
             $review->date = Date::formatted_time();
             $review->save();
             Message::set(Message::SUCCESS, __('review_adding_complete'));
             $this->request->redirect('reviews');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/review/add')->set('values', $this->values)->set('errors', $this->errors)->set('cities', $cities)->set('services', $services);
     $this->template->title = 'Написать отзыв';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:29,代码来源:reviews.php

示例8: action_register

 public function action_register()
 {
     if ($this->user) {
         Request::instance()->redirect('');
     }
     // Experimental facebook connection
     $this->facebook = new Fb();
     // User accessed from facebook!
     if ($this->facebook->validate_fb_params()) {
         $this->facebook->require_frame();
         $_SESSION['fb_uid'] = $this->facebook->require_login();
     } elseif (!isset($_SESSION['fb_uid'])) {
         Request::instance()->redirect('');
     }
     // Check if the user got an account.
     $user_facebook = Jelly::select('user_facebook')->where('facebook_id', '=', $_SESSION['fb_uid'])->load();
     // If we found it, log him in.
     if ($user_facebook->loaded()) {
         $this->a1->force_login($user_facebook->user->username);
         $_SESSION['facebook'] = 'TRUE';
         // Used for verifying if logged in using facebook.
         Request::instance()->redirect('');
     }
     $user = Jelly::factory('user');
     // Validate the form input
     $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('username', 'not_empty')->rule('username', 'min_length', array(3))->rule('username', 'max_length', array(20))->rule('username', 'alpha_numeric')->rule('email', 'email')->rule('tos', 'not_empty');
     if ($post->check()) {
         $values = array('username' => $post['username'], 'email' => $post['email']);
         // Assign the validated data to the sprig object
         $user->set($values);
         // Hash the password
         $user->password = '';
         // Set the default role for registered user.
         $user->role = 'facebook';
         try {
             // Create the new user
             $testy = $user->save();
             //print_r($testy);
             $user_id = mysql_insert_id();
             $ufb = Jelly::factory('user_facebook');
             $ufb->facebook_id = $_SESSION['fb_uid'];
             $ufb->user = $user_id;
             $ufb->save();
             $this->a1->force_login($values['username']);
             $_SESSION['facebook'] = 'TRUE';
             // Used for verifying if logged in using facebook.
             // Redirect the user to the login page
             $this->request->redirect('');
         } catch (Validate_Exception $e) {
             // Get the errors using the Validate::errors() method
             $this->errors = $e->array->errors('register');
         }
     } else {
         $this->errors = $post->errors('account/register');
     }
     if (!empty($this->errors)) {
         Message::set(Message::ERROR, $this->errors);
     }
     $this->template->content = View::factory('facebook/register')->set('post', $post->as_array());
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:60,代码来源:facebook.php

示例9: action_view

 /**
  * Просмотр запроса
  * @return void
  */
 public function action_view()
 {
     $feedback = ORM::factory('feedback', $this->request->param('id', NULL));
     if (!$feedback->loaded()) {
         Message::set(Message::ERROR, Kohana::message('admin', 'feedback_not_found'));
         $this->request->redirect('admin/feedback');
     }
     /*
     switch ($feedback->type)
     {
         case 1:
             $this->view = View::factory('backend/feedback/view_feedback');
             break;
         case 2:
             $this->view = View::factory('backend/feedback/view_adv');
             break;
     }
     $this->view->set('feedback', $feedback);
     
     $this->template->title = $title_pie.' от пользователя '.$feedback->user->username;
     */
     $this->view = View::factory('backend/feedback/view')->set('feedback', $feedback);
     $title_pie = $feedback->type == 1 ? 'Запрос' : 'Заявка на рекламу';
     $this->template->title = $title_pie . ' от пользователя ' . $feedback->user->username;
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:31,代码来源:feedback.php

示例10: action_index

 function action_index()
 {
     $services[0] = 'Выбрать компанию';
     foreach ($this->user->services->find_all() as $service) {
         $services[$service->id] = $service->name;
     }
     if ($_POST) {
         $feedback = ORM::factory('feedback');
         try {
             $feedback->values($_POST, array('title', 'text'));
             $feedback->type = 2;
             $feedback->user_id = $this->user->id;
             $feedback->service_id = Arr::get($_POST, 'service_id', 0);
             $feedback->date = Date::formatted_time();
             $feedback->save();
             $email_view = View::factory('email/adv')->set('username', $this->user->username)->set('title', $feedback->title)->set('text', $feedback->text);
             if ($feedback->service_id != 0) {
                 $email_view->set('service', $this->user->services->where('id', '=', $feedback->service_id)->find());
             }
             $email_view->render();
             Email::send('sekretar@as-avtoservice.ru', array('no-reply@as-avtoservice.ru', 'Ассоциация автосервисов'), $feedback->title, $email_view, TRUE);
             Message::set(Message::SUCCESS, 'Спасибо! Ваше заявка принята на рассмотрение администрацией сайта');
             $this->request->redirect('cabinet');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('frontend/cabinet/adv/create_blank')->set('services', $services)->set('errors', $this->errors)->set('values', $this->values);
     $this->template->title = 'Реклама на сайте';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:33,代码来源:adv.php

示例11: action_delete

 /**
  * Удаление новости автосервиса
  * @return void
  */
 function action_delete()
 {
     $settings = ORM::factory('payment_settings', $this->request->param('id', null));
     if (!$settings->loaded()) {
         Message::set(Message::ERROR, Kohana::message('admin', 'payment.settings_not_found'));
         $this->request->redirect('admin/payment/settings');
     }
     if ($settings->system == 'Y') {
         Message::set(Message::NOTICE, 'Нельзя удалять системные настройки');
         $this->request->redirect('admin/payment/settings');
     }
     if ($_POST) {
         $action = Arr::extract($_POST, array('submit', 'cancel'));
         if ($action['cancel']) {
             $this->request->redirect('admin/payment/settings');
         }
         if ($action['submit']) {
             $name = $settings->name;
             $settings->delete();
             Message::set(Message::SUCCESS, 'Платежная настройка <strong>' . $name . '</strong> удалена');
             $this->request->redirect('admin/payment/settings');
         }
     }
     $this->view = View::factory('backend/delete')->set('url', 'admin/payment/settings/delete/' . $settings->id)->set('from_url', 'admin/payment/settings')->set('title', 'Удаление платежной настройки: ' . $settings->name)->set('text', 'Вы действительно хотите удалить "' . $settings->name . '?');
     $this->template->title = 'Удаление новости "' . $settings->name . '"';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:32,代码来源:settings.php

示例12: action_send

 /**
  * Отправка сообщения на Email
  * @return void
  */
 public function action_send()
 {
     $user = ORM::factory('user', $this->request->param('id', NULL));
     if (!$user->loaded()) {
         $this->request->redirect('admin');
     }
     $feedback_id = Arr::get($_GET, 'feedback', 0);
     $email_from = array('no-reply' => 'no-reply@as-avtoservice.ru', 'sekretar' => 'sekretar@as-avtoservice.ru');
     if ($_POST) {
         $message = ORM::factory('message');
         $message->values($_POST, array('title', 'text', 'from'));
         $message->user_id = $user->id;
         $message->feedback_id = $feedback_id;
         $message->date = Date::formatted_time();
         try {
             $message->save();
             $this->add_to_email_queue($user->id, $message->id, $message->from);
             Message::set(Message::SUCCESS, 'Сообщения пользователю "' . $user->username . '" отправлено в очередь на отправку');
             $this->request->redirect('admin/message');
         } catch (ORM_Validation_Exception $e) {
             $this->errors = $e->errors('models');
             $this->values = $_POST;
         }
     }
     $this->view = View::factory('backend/message/send')->set('values', $this->values)->set('errors', $this->errors)->set('email_from', $email_from)->set('user', $user);
     $this->template->title = 'Отправка сообщения';
     $this->template->bc['#'] = $this->template->title;
     $this->template->content = $this->view;
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:33,代码来源:message.php

示例13: action_save

 public function action_save()
 {
     if ($_POST && $_FILES) {
         $imageChanged = false;
         $data = (object) $this->sanitize($_POST);
         $update = false;
         if ($data->id == "") {
             $editorial = ORM::factory("editorial");
         } else {
             $editorial = ORM::factory("editorial", $data->id);
         }
         if (in_array($_FILES['image']['type'], $this->allowed)) {
             Upload::$default_directory = Kohana::config('myshot.basePath');
             if ($stage_path = Upload::save($_FILES['image'])) {
                 $imageChanged = true;
                 Library_Akamai::factory()->addToDir($stage_path, 'editorials');
             }
         }
         $editorial->title = $data->title;
         $editorial->image = $imageChanged ? Kohana::config('myshot.cdn') . 'editorials/' . basename($stage_path) : $editorial->image;
         $editorial->image_alt = $data->image_alt;
         $editorial->link = $data->link;
         $editorial->link_text = $data->link_text;
         $editorial->text = $data->text;
         $editorial->save();
         Message::set(Message::SUCCESS, $update ? "You have sucessfully updated the editorial." : "You have sucessfully added the editorial.");
     }
     Request::instance()->redirect('admin/editorials');
 }
开发者ID:natgeo,项目名称:kids-myshot,代码行数:29,代码来源:editorials.php

示例14: action_travel

 /**
  * Moves the character to a new zone
  * 
  * @param  integer  $id
  */
 public function action_travel($id)
 {
     // Make sure id is an integer.
     if (!is_numeric($id)) {
         Message::set(Message::ERROR, 'Invalid ID');
         $this->request->redirect('travel');
     }
     if ($id == $this->character->zone->id) {
         Message::set(Message::ERROR, 'You cannot move to where you already are.');
         $this->request->redirect('travel');
     }
     // Load the zone
     $zone = Jelly::select('zone')->where('id', '=', $id)->load();
     $character = $this->character;
     // Make sure the character got enough of engery
     if ($character->energy < $zone->energy) {
         Message::set(Message::ERROR, 'Not enough energy.');
         $this->request->redirect('travel');
     }
     // Set the new zone, and energy
     $character->zone = $zone->id;
     $character->energy = $character->energy - $zone->energy;
     $character->save();
     $this->request->redirect('character');
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:30,代码来源:travel.php

示例15: action_login

 /**
  * Log in
  */
 public function action_login()
 {
     $this->title = __('user.authorization');
     if ($this->request->is_post()) {
         // If not logged
         if (!$this->auth->login($this->request->post('email'), $this->request->post('password'), (bool) $this->request->post('remember'))) {
             Message::error(__('user.error_authorization'));
             HTTP::redirect(Route::url('b_auth', ['action' => 'login']));
         }
     }
     $this->user = $this->auth->get_user();
     if ($this->user and !$this->user->confirmed) {
         Message::warning(__('user.email_сheck_and_confirm', [':email' => $this->user->email]));
         $this->auth->logout();
         HTTP::redirect(Route::url('b_auth', ['action' => 'login']));
     }
     // If user is admin
     if ($this->auth->logged_in('admin')) {
         Message::success(__('user.hello_username', [':username' => $this->user->username]));
         HTTP::redirect(Route::url('b_dashboard'));
     }
     // If user is user
     if ($this->auth->logged_in()) {
         Message::set('success', __('user.hello_username', [':username' => $this->user->username]));
         HTTP::redirect(Route::url('f_user_profile'));
     }
     $this->content = View::factory('auth/backend/v_login');
 }
开发者ID:eok8177,项目名称:shopCMS,代码行数:31,代码来源:Auth.php


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