本文整理汇总了PHP中Session::set_flash方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::set_flash方法的具体用法?PHP Session::set_flash怎么用?PHP Session::set_flash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::set_flash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_to
public function action_to($id = null)
{
// redirect if no id
if ($id == null) {
Response::redirect('message');
}
// redirect if no right access
if (!Sentry::user()->has_access('message_send')) {
Session::set_flash('error', "You are not allowed to send message");
Response::redirect('');
}
$data['user'] = Sentry::user(intval($id));
$data['messages'] = Model_Message::messageWith($data['user'], $this->current_user);
if (Input::method() == 'POST') {
$message = Model_Message::forge(array('subject' => Input::post('subject'), 'content' => Input::post('content'), 'to' => $data['user']->id, 'from' => $this->current_user->id, 'parent_id' => '', 'read' => 0, 'from_delete' => 0, 'to_delete' => 0));
if ($message and $message->save()) {
Session::set_flash('success', 'Message successfuly sent to ' . $data['user']->username);
Response::redirect('message');
} else {
Session::set_flash('error', 'Could not send the message.');
}
}
$this->template->h2 = 'Send Message to ' . $data['user']->username;
$this->template->title = 'Message » to';
$this->template->content = View::forge('message/to', $data);
}
示例2: action_register
public function action_register()
{
if (\Auth::check()) {
\Session::set_flash('error', 'FLASH: Can\'t register while logged in, log out first.');
\Output::redirect('myauth');
}
// The same fields as the example above
$val = \Validation::factory('myauth2');
$val->add_field('username', 'Your username', 'required|min_length[3]|max_length[20]');
// $val->add_field('username', 'Your username', 'required|min_length[3]|max_length[20]|unique[simpleauth.username]');
$val->add_field('password', 'Your password', 'required|min_length[3]|max_length[20]');
$val->add_field('email', 'Email', 'required|valid_email');
// run validation on just post
if ($val->run()) {
if (\Auth::instance()->create_user($val->validated('username'), $val->validated('password'), $val->validated('email'), '100')) {
\Session::set_flash('notice', 'FLASH: User created.');
\Output::redirect('myauth');
} else {
throw new Exception('Smth went wrong while registering');
}
} else {
// validation failed
if ($_POST) {
$data['username'] = $val->validated('username');
$data['login_error'] = 'All fields are required.';
} else {
$data['login_error'] = false;
}
}
$this->template->title = 'Myauth » Register';
$this->template->login_error = @$data['login_error'];
$this->template->content = \View::factory('register');
}
示例3: action_save
/**
* 编辑保存被投票项目
* @param int $id
* @throws \Exception
* @throws \FuelException
*/
public function action_save($id = 0)
{
if (\Input::method() == 'POST') {
$msg = ['status' => 'err', 'msg' => '', 'errcode' => 10];
$data = \Input::post();
$data['start_at'] = $data['start_at'] ? strtotime($data['start_at']) : 0;
$data['end_at'] = $data['end_at'] ? strtotime($data['end_at']) : 0;
$data['account_id'] = \Session::get('WXAccount')->id;
$data['seller_id'] = \Session::get('WXAccount')->seller_id;
$data['type'] = 'VOTE';
$market = \Model_Marketing::find($id);
if (!$market) {
$market = \Model_Marketing::forge();
}
$market->set($data);
if ($market->save()) {
$limit = \Model_MarketingLimit::forge(['involved_total_num' => 1, 'marketing_id' => $market->id]);
$limit->save();
$msg = ['status' => 'succ', 'msg' => '', 'errcode' => 0, 'data' => $market->to_array()];
}
if (\Input::is_ajax()) {
die(json_encode($msg));
}
\Session::set_flash('msg', $msg);
}
}
示例4: before
public function before()
{
parent::before();
// if user not connected and not on the login, 404 or session_up pages then redirect to login page
if (Request::active()->action != 'login' && !Sentry::check() && Request::active()->action != '404' && Request::active()->action != 'session_up') {
Session::set(array('redirect' => Request::active()->route->translation));
Response::redirect('login');
}
$this->current_user = self::current_user();
View::set_global('current_user', self::current_user());
if (Sentry::check()) {
// logout if banned
if (Sentry::attempts($this->current_user->username)->get() == Sentry::attempts()->get_limit()) {
Session::set_flash('Your account has been blocked');
Sentry::logout();
Response::redirect('login');
}
}
View::set_global('site_title', 'IKON Backend');
View::set_global('separator', '/');
foreach (Model_Forms::find('all') as $k => $form) {
$this->tables[$k]['cleanName'] = $form->cleanName;
$this->tables[$k]['url'] = $form->url;
$this->tables[$k]['table'] = $form->table;
}
View::set_global('tables', $this->tables);
}
示例5: action_edit
public function action_edit($id = null)
{
is_null($id) and Response::redirect('category');
if (!($category = Model_Category::find($id))) {
Session::set_flash('error', 'Could not find category #' . $id);
Response::redirect('category');
}
$val = Model_Category::validate('edit');
if ($val->run()) {
$category->name = Input::post('name');
$category->keywords = Input::post('keywords');
$category->meta = Input::post('meta');
if ($category->save()) {
Session::set_flash('success', 'Updated category #' . $id);
Response::redirect('admin/category');
} else {
Session::set_flash('error', 'Could not update category #' . $id);
}
} else {
if (Input::method() == 'POST') {
$category->name = $val->validated('name');
$category->keywords = $val->validated('keywords');
$category->meta = $val->validated('meta');
Session::set_flash('error', $val->error());
}
$this->template->set_global('category', $category, false);
}
$this->template->title = "Categories";
$this->template->content = View::forge('admin/category/create');
}
示例6: action_edit
public function action_edit($id = null, $one = null, $two = null)
{
$redirect = $two ? $one . '/' . $two : $one;
$auction = Model_Auction::find($id);
$val = Model_Auction::validate_edit();
if ($val->run()) {
$auction->item_count = Input::post('item_count');
$auction->price = Input::post('price');
$auction->memo = Input::post('memo');
if (\Security::check_token() && $auction->save()) {
Session::set_flash('success', e('Updated auction #' . $auction->auc_id));
Response::redirect('admin/' . $redirect);
} else {
Session::set_flash('error', e('Could not update auction #' . $auction->auc_id));
}
} else {
if (Input::method() == 'POST') {
$auction->item_count = $val->validated('item_count');
$auction->price = $val->validated('price');
$auction->memo = $val->validated('memo');
Session::set_flash('error', $val->error());
}
$this->template->set_global('auction', $auction, false);
}
$this->template->set_global('redirect', $redirect, false);
$this->template->title = $auction->title;
$this->template->content = View::forge('admin/auction/edit');
}
示例7: action_index
/**
* Mmeber setting viewtype
*
* @access public
* @return Response
*/
public function action_index()
{
$page_name = term('notice', 'site.setting');
$val = \Form_MemberConfig::get_validation($this->u->id, 'notice', 'Notice');
if (\Input::method() == 'POST') {
\Util_security::check_csrf();
try {
if (!$val->run()) {
throw new \FuelException($val->show_errors());
}
$post = $val->validated();
\DB::start_transaction();
\Form_MemberConfig::save($this->u->id, $val, $post);
\DB::commit_transaction();
\Session::set_flash('message', $page_name . 'を変更しました。');
\Response::redirect('member/setting');
} catch (\FuelException $e) {
if (\DB::in_transaction()) {
\DB::rollback_transaction();
}
\Session::set_flash('error', $e->getMessage());
}
}
$this->set_title_and_breadcrumbs($page_name, array('member/setting' => term('site.setting', 'form.update')), $this->u);
$this->template->content = \View::forge('member/setting/_parts/form', array('val' => $val, 'label_size' => 5, 'form_params' => array('common' => array('radio' => array('layout_type' => 'grid')))));
}
示例8: action_edit
/**
* Mmeber_profile edit
*
* @access public
* @return Response
*/
public function action_edit($type = null)
{
list($type, $is_regist) = self::validate_type($type, $this->u->id);
$form_member_profile = new Form_MemberProfile($type == 'regist' ? 'regist-config' : 'config', $this->u);
$form_member_profile->set_validation();
if (\Input::method() == 'POST') {
\Util_security::check_csrf();
try {
$form_member_profile->validate(true);
\DB::start_transaction();
$form_member_profile->seve();
if ($is_regist) {
Model_MemberConfig::delete_value($this->u->id, 'terms_un_agreement');
}
\DB::commit_transaction();
$message = $is_regist ? sprintf('%sが%sしました。', term('site.registration'), term('form.complete')) : term('profile') . 'を編集しました。';
$redirect_uri = $is_regist ? $this->after_auth_uri : 'member/profile';
\Session::set_flash('message', $message);
\Response::redirect($redirect_uri);
} catch (\FuelException $e) {
if (\DB::in_transaction()) {
\DB::rollback_transaction();
}
\Session::set_flash('error', $e->getMessage());
}
}
$this->set_title_and_breadcrumbs(term('profile') . term($is_regist ? 'site.registration' : 'form.edit'), $is_regist ? array() : array('member/profile' => term('common.my', 'profile')), $is_regist ? null : $this->u);
$this->template->content = View::forge('member/profile/edit', array('is_regist' => $is_regist, 'val' => $form_member_profile->get_validation(), 'member_public_flags' => $form_member_profile->get_member_public_flags(), 'profiles' => $form_member_profile->get_profiles(), 'member_profile_public_flags' => $form_member_profile->get_member_profile_public_flags()));
}
示例9: before
public function before()
{
parent::before();
$flag = $this->getNotOpenidAllowed();
if ($flag) {
return;
}
if (!\Session::get('wechat', false) && !\Input::get('openid', false)) {
//获取到openid之后跳转的参数列表
//$params = \handler\mp\UrlTool::createLinkstring(\Input::get());
//本站域名
$baseUrl = \Config::get('base_url');
$url = $baseUrl . \Input::server('REQUEST_URI');
$toUrl = urlencode($url);
$callback = "{$baseUrl}wxapi/oauth2_callback?to_url={$toUrl}";
$account = \Session::get('WXAccount', \Model_WXAccount::find(1));
$url = \handler\mp\Tool::createOauthUrlForCode($account->app_id, $callback);
\Response::redirect($url);
} else {
if (!\Session::get('wechat', false)) {
$wxopenid = \Model_WechatOpenid::query()->where(['openid' => \Input::get('openid')])->get_one();
if (!$wxopenid) {
\Session::set_flash('msg', ['status' => 'err', 'msg' => '未找到您的微信信息,无法确认您的身份! 系统无法为您提供服务!', 'title' => '拒绝服务']);
return $this->show_mesage();
}
\Session::set('wechat', $wxopenid->wechat);
\Session::set('OpenID', $wxopenid);
\Auth::force_login($wxopenid->wechat->user_id);
} else {
if (!\Auth::check() && \Session::get('wechat')->user_id) {
\Auth::force_login(\Session::get('wechat')->user_id);
}
}
}
}
示例10: action_edit
public function action_edit($id = null)
{
parent::has_access("create_employee");
is_null($id) and Response::redirect('employees/view' . $id);
if (!($bank = Model_Bank::find('first', array('where' => array('employee_id' => $id))))) {
Session::set_flash('error', 'Could not find user #' . $id);
Response::redirect('employees/view/' . $id);
}
if (Input::method() == 'POST') {
$bank->account_no = Input::post('account_no');
$bank->account_type = Input::post('account_type');
$bank->branch = Input::post('branch');
$bank->city = Input::post('city');
$bank->state = Input::post('state');
$bank->ifsc_code = Input::post('ifsc_code');
$bank->payment_type = Input::post('payment_type');
if ($bank->save()) {
Session::set_flash('success', 'Updated bank details #' . $id);
Response::redirect('employees/view/' . $id);
} else {
Session::set_flash('error', 'Could not update bank #' . $id);
}
}
$this->template->title = "Banks";
$this->template->content = View::forge('banks/edit');
}
示例11: action_login
public function action_login()
{
// Already logged in
Auth::check() and Response::redirect('admin');
$val = Validation::forge();
if (Input::method() == 'POST') {
$val->add('email', 'ユーザ名')->add_rule('required');
$val->add('password', 'パスワード')->add_rule('required');
if ($val->run()) {
$auth = Auth::instance();
// check the credentials. This assumes that you have the previous table created
if (Auth::check() or $auth->login(Input::post('email'), Input::post('password'))) {
// credentials ok, go right in
if (Config::get('auth.driver', 'Simpleauth') == 'Ormauth') {
$current_user = Model\Auth_User::find_by_username(Auth::get_screen_name());
} else {
$current_user = Model_User::find_by_username(Auth::get_screen_name());
}
Session::set_flash('success', e('ようこそ、' . $current_user->username . 'さん'));
Response::redirect('admin');
} else {
$this->template->set_global('login_error', '失敗しました');
}
}
}
$this->template->title = 'ログイン';
$this->template->content = View::forge('admin/login', array('val' => $val), false);
}
示例12: action_addtask
public function action_addtask($project_id)
{
if (!($project = Model_Project::find($project_id))) {
\Fuel\Core\Session::set_flash('error', "Cannot find the selected project # {$project_id}");
\Fuel\Core\Response::redirect_back('user/projects');
}
$val = Model_Projecttask::validate('create');
if (\Fuel\Core\Input::method() == 'POST') {
if ($val->run()) {
$projecttask = Model_Projecttask::forge(array('project_id' => Input::post('project_id'), 'user_id' => Input::post('user_id'), 'project_task_name_id' => Input::post('project_task_name_id'), 'hourly_rate' => Input::post('hourly_rate'), 'task_status' => 0, 'task_due' => Input::post('task_due'), 'project_task_description' => Input::post('project_task_description'), 'comment' => Input::post('comment'), 'priority' => Input::post('priority')));
if ($projecttask and $projecttask->save()) {
Session::set_flash('success', e('Added task #' . $projecttask->id . '.'));
Response::redirect('user/projects/view/' . $project_id);
} else {
Session::set_flash('error', e('Could not save task.'));
}
} else {
\Fuel\Core\Session::set_flash('error', $val->error());
}
}
$this->load_presenter($project, Model_Projecttask::forge(array('id' => 0, 'project_id' => $project->id, 'user_id' => $this->current_user->id, 'task_status' => 0, 'hourly_rate' => 456, 'task_due' => date('Y-m-d'))));
$this->template->set_global('project_task_names', Model_Projecttaskname::find('all', array('order_by' => array(array('name', 'asc')))));
$this->template->set_global('users', array(Model_User::find($this->current_user->id)));
$this->template->set_global('priorities', THelper::get_priorities());
$this->template->title = 'My Projects';
$this->template->content = Fuel\Core\View::forge('user/projects/addtask');
}
示例13: action_subscription
public function action_subscription($id = null)
{
is_null($id) and Response::redirect('');
if (!($user = Model_User::find($id))) {
Messages::error('Could not find user #' . $id);
Response::redirect('');
}
$val = \Model_User::validate_subscription('edit');
if ($val->run()) {
$user->delivery_address = Input::post('delivery_address');
$user->delivery_address_2 = Input::post('delivery_address_2');
$user->delivery_city = Input::post('delivery_city');
$user->delivery_state = Input::post('delivery_state');
$user->delivery_zip_code = Input::post('delivery_zip_code');
if ($user->save()) {
Messages::success('Updated user #' . $id);
} else {
Messages::error('Could not update user #' . $id);
}
\Response::redirect('backend/account/index/subscription');
} else {
if (Input::method() == 'POST') {
$user->delivery_address = $val->validated('delivery_address');
$user->delivery_address_2 = $val->validated('delivery_address_2');
$user->delivery_city = $val->validated('delivery_city');
$user->delivery_state = $val->validated('delivery_state');
Session::set_flash('error', $val->error());
}
$data['user'] = $this->_user;
$this->template->content = View::forge('account/subscription/edit', $data);
}
$this->template->title = "Delivery Settings";
$data['user'] = $this->_user;
$this->template->content = View::forge('account/subscription/edit', $data);
}
示例14: action_usercp
public function action_usercp()
{
if (!$this->current_user->logged_in()) {
Session::set_flash('error', 'You need to be logged in to access is page');
Session::set_flash('login_redirect', Uri::current());
Response::redirect('login');
}
$this->title('UserCP');
$this->view = $this->theme->view('users/usercp');
if (Input::param() != array()) {
// Set name and email
$this->current_user->name = Input::param('name');
$this->current_user->email = Input::param('email');
// Set new password
if (Input::param('new_password')) {
$this->current_user->password = Input::param('new_password');
}
// Check if the current password is valid...
$auth = Model_User::authenticate_login($this->current_user->username, Input::param('current_password'));
if ($this->current_user->is_valid() and $auth) {
$this->current_user->save();
Session::set_flash('success', 'Details saved');
Response::redirect('usercp');
} else {
$errors = $this->current_user->errors();
if (!$auth) {
$errors = array('Current password is invalid.') + $errors;
}
}
$this->view->set('errors', isset($errors) ? $errors : array());
}
}
示例15: create_group
/**
* @author Bui Dang <dangbcd6591@seta-asia.com.vn>
* action create and edit group
* @return array
*/
public function create_group($data = array())
{
if ($data['group_id'] and !\Model_Mgroups::find_by_pk($data['group_id'])) {
Session::set_flash('error', '取引先グループは存在しません');
return array('status' => \Constants::$_status_save['id_not_exist']);
}
if (isset($data['group_id'])) {
$group = Model_Mgroups::find_by_pk($data['group_id']);
$data['updated_at'] = date('Y-m-d H:i:s');
} else {
$group = new Model_Mgroups();
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = date('Y-m-d H:i:s');
}
$data['name'] = Utility::strip_tag_string($data['group_name']);
$group->set($data);
//Set data
$is_name = self::check_name($data['group_id'], $data['group_name']);
if ($is_name != 0) {
return array('status' => \Constants::$_status_save['value_exist']);
}
if ($group and $group->save() >= 0) {
Session::set_flash('success', '保存しました ');
return array('group_id' => $group->m_group_id, 'status' => \Constants::$_status_save['save_success']);
}
}