本文整理汇总了PHP中Messages::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Messages::error方法的具体用法?PHP Messages::error怎么用?PHP Messages::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Messages
的用法示例。
在下文中一共展示了Messages::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Function for easy update a ORM object
*
* @param ORM $object ORM object to update
* @param array $messages Array of custom messages
*/
public function update(ORM $object, array $messages = array())
{
// Check if is a valid object
if (!$object->loaded()) {
Messages::warning(isset($messages['warning']) ? $messages['warning'] : 'El elemento que intentas modificar no existe o fue eliminado.');
$this->go();
}
// Only if Request is POST
if ($this->request->method() == Request::POST) {
// Catch ORM_Validation
try {
// Set object values and update
$object->values($this->request->post())->update();
// If object is saved....
if ($object->saved()) {
// Success message & redirect
Messages::success(isset($messages['success']) ? $messages['success'] : 'El elemento fue modificado correctamente.');
$this->go();
}
} catch (ORM_Validation_Exception $e) {
// Error message
if (isset($messages['error'])) {
Messages::error($messages['error']);
}
// Validation messages
Messages::validation($e);
}
}
}
示例2: on_page_load
public function on_page_load()
{
$email_ctx_id = $this->get('email_id_ctx', 'email');
$email = $this->_ctx->get($email_ctx_id);
$referrer_page = Request::current()->referrer();
$next_page = $this->get('next_url', Request::current()->referrer());
if (!Valid::email($email)) {
Messages::errors(__('Use a valid e-mail address.'));
HTTP::redirect($referrer_page);
}
$user = ORM::factory('user', array('email' => $email));
if (!$user->loaded()) {
Messages::errors(__('No user found!'));
HTTP::redirect($referrer_page);
}
$reflink = ORM::factory('user_reflink')->generate($user, 'forgot', array('next_url' => URL::site($this->next_url, TRUE)));
if (!$reflink) {
Messages::errors(__('Reflink generate error'));
HTTP::redirect($referrer_page);
}
Observer::notify('admin_login_forgot_before', $user);
try {
Email_Type::get('user_request_password')->send(array('username' => $user->username, 'email' => $user->email, 'reflink' => Route::url('reflink', array('code' => $reflink)), 'code' => $reflink));
Messages::success(__('Email with reflink send to address set in your profile'));
} catch (Exception $e) {
Messages::error(__('Something went wrong'));
}
HTTP::redirect($next_page);
}
示例3: 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);
}
示例4: store
function store()
{
$rules = array('icao' => 'alpha|required', 'name' => 'required', 'radio' => '', 'website' => 'url');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
Messages::error($validator->messages()->all());
return Redirect::back()->withInput();
}
if (is_null($airline = Airline::whereIcao(Input::get('icao'))->whereNew(true)->first())) {
$airline = new Airline();
$airline->icao = Input::get('icao');
$airline->name = Input::get('name');
$airline->new = true;
$airline->save();
}
Diff::compare($airline, Input::all(), function ($key, $value, $model) {
$change = new AirlineChange();
$change->airline_id = $model->id;
$change->user_id = Auth::id();
$change->key = $key;
$change->value = $value;
$change->save();
}, ['name', 'radio', 'website']);
Messages::success('Thank you for your submission. We will check whether all information is correct and soon this airline might be available.');
return Redirect::back();
}
示例5: action_create
/**
* Добавление нового пользователя
*/
public function action_create()
{
if (\Input::method() == 'POST') {
$val = \Model_User::validate('create');
if ($val->run()) {
try {
$created = \Auth::create_user(\Input::post('username'), \Input::post('password'), \Input::post('email'), \Config::get('application.user.default_group', 100));
if ($created) {
\Session::set_flash('success', e('Добавлен новый пользователь'));
\Response::redirect_back('admin/users');
} else {
// oops, creating a new user failed?
\Session::set_flash('error', e('Не удалось создать пользователя'));
}
} catch (\SimpleUserUpdateException $e) {
// Повтор е-мэил
if ($e->getCode() == 2) {
\Session::set_flash('error', e('E-Mail существует'));
} elseif ($e->getCode() == 3) {
\Session::set_flash('error', e('Логин существует'));
} else {
\Messages::error($e->getMessage());
}
}
} else {
\Session::set_flash('error', $val->error());
}
}
$this->template->title = 'Пользователи';
$this->template->content = \View::forge('users/create');
}
示例6: store
function store()
{
$rules = array('icao' => 'alpha_num|required', 'iata' => 'alpha_num', 'name' => 'required', 'city' => 'required', 'lat' => 'required|numeric', 'lon' => 'required|numeric', 'elevation' => 'required|numeric', 'country_id' => 'required|exists:countries,id', 'website' => 'url');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
Messages::error($validator->messages()->all());
return Redirect::back()->withInput();
}
if (is_null($airport = Airport::whereIcao(Input::get('icao'))->whereNew(true)->first())) {
$airport = new Airport();
$airport->icao = Input::get('icao');
$airport->name = Input::get('name');
$airport->new = true;
$airport->save();
}
Diff::compare($airport, Input::all(), function ($key, $value, $model) {
$change = new AirportChange();
$change->airport_id = $model->id;
$change->user_id = Auth::id();
$change->key = $key;
$change->value = $value;
$change->save();
}, ['name', 'iata', 'city', 'country_id', 'lat', 'lon', 'elevation', 'website']);
Messages::success('Thank you for your submission. We will check whether all information is correct and soon this airport might be available.');
return Redirect::back();
}
示例7: action_index
/**
* The index action
*
* @access public
* @return void
*/
public function action_index()
{
$settings = \Config::load('autoresponder.db');
// $autoResponder = Model_Setting::find(array('where' => array(array('meta_key', '=', 'auto-responders'))));
if (\Input::post()) {
$input = \Input::post();
if (!\Input::is_ajax()) {
$val = Model_Setting::validate('create');
if (!$val->run()) {
if ($val->error() != array()) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings</strong>');
foreach ($val->error() as $e) {
\Messages::error($e->get_message());
}
}
} else {
try {
\Config::save('autoresponder.db', array('logo_url' => $input['logo_url'], 'company_name' => $input['company_name'], 'address' => $input['address'], 'website' => $input['website'], 'phone' => $input['phone'], 'email_address' => $input['email_address'], 'sender_email_address' => $input['sender_email_address'], 'contact_us_email_address' => $input['contact_us_email_address'], 'instagram_account_name' => $input['instagram_account_name'], 'facebook_account_name' => $input['facebook_account_name']));
// $setting->save();
\Messages::success('Settings successfully created.');
\Response::redirect('admin/settings');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings.</strong>');
// Uncomment lines below to show database errors
$errors = $e->getMessage();
\Messages::error($errors);
}
}
}
}
\View::set_global('title', 'Settings');
\Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
}
示例8: before
/**
* @param none
* @throws none
* @returns void
*/
public function before()
{
$result = array();
// users need to be logged in to access this controller
if (!\Sentry::check()) {
$result = array('message' => 'You need to be logged in to access that page.', 'url' => '/admin/login');
// Don't show this message if url is just 'admin'
if (\Uri::string() == 'admin/admin/index') {
unset($result['message']);
}
\Session::set('redirect_to', \Uri::admin('current'));
} else {
if (!\Sentry::user()->is_admin()) {
$result = array('message' => 'Access denied. You need to be a member of staff to access that page.', 'url' => '/admin/login');
\Session::set('redirect_to', \Uri::admin('current'));
}
}
if (!empty($result)) {
if (\Input::is_ajax()) {
\Messages::error('You need to be logged in to complete this action.');
echo \Messages::display('left', false);
exit;
} else {
if (isset($result['message'])) {
\Messages::warning($result['message']);
}
\Response::redirect($result['url']);
}
}
parent::before();
}
示例9: action_callback
public function action_callback()
{
// Opauth can throw all kinds of nasty bits, so be prepared
try {
// get the Opauth object
$opauth = \Auth_Opauth::forge(false);
// and process the callback
$status = $opauth->login_or_register();
// fetch the provider name from the opauth response so we can display a message
$provider = $opauth->get('auth.provider', '?');
// deal with the result of the callback process
switch ($status) {
// a local user was logged-in, the provider has been linked to this user
case 'linked':
// inform the user the link was succesfully made
\Messages::success(sprintf(__('login.provider-linked'), ucfirst($provider)));
// and set the redirect url for this status
$url = 'dashboard';
break;
// the provider was known and linked, the linked account as logged-in
// the provider was known and linked, the linked account as logged-in
case 'logged_in':
// inform the user the login using the provider was succesful
\Messages::success(sprintf(__('login.logged_in_using_provider'), ucfirst($provider)));
// and set the redirect url for this status
$url = 'dashboard';
break;
// we don't know this provider login, ask the user to create a local account first
// we don't know this provider login, ask the user to create a local account first
case 'register':
// inform the user the login using the provider was succesful, but we need a local account to continue
\Messages::info(sprintf(__('login.register-first'), ucfirst($provider)));
// and set the redirect url for this status
$url = 'user/register';
break;
// we didn't know this provider login, but enough info was returned to auto-register the user
// we didn't know this provider login, but enough info was returned to auto-register the user
case 'registered':
// inform the user the login using the provider was succesful, and we created a local account
\Messages::success(__('login.auto-registered'));
// and set the redirect url for this status
$url = 'dashboard';
break;
default:
throw new \FuelException('Auth_Opauth::login_or_register() has come up with a result that we dont know how to handle.');
}
$url = str_replace('#_=_', '', $url);
// redirect to the url set
\Response::redirect($url);
} catch (\OpauthException $e) {
\Messages::error($e->getMessage());
\Response::redirect_back();
} catch (\OpauthCancelException $e) {
// you should probably do something a bit more clean here...
exit('It looks like you canceled your authorisation.' . \Html::anchor('users/oath/' . $provider, 'Click here') . ' to try again.');
}
}
示例10: before
/**
* @param none
* @throws none
* @returns void
*/
public function before()
{
// users need to be logged in to access this controller
//if ( ! \Sentry::check())
if ($this->check_logged_type() != 'user') {
\Messages::error('Access denied. Please login first');
\Response::redirect('/user/login');
}
parent::before();
}
示例11: action_delete
public function action_delete($id = null)
{
$post = \Model_Post::find($id);
if ($post->delete()) {
// Delete cache
\Cache::delete('sidebar');
\Messages::success(__('backend.post.deleted'));
} else {
\Messages::error(__('error'));
}
\Response::redirect_back(\Router::get('admin_post'));
}
示例12: action_delete
public function action_delete($id = null)
{
$category = Model_Category::find($id);
if ($category->delete()) {
// Delete cache
\Cache::delete('sidebar');
\Messages::success(__('backend.category.deleted'));
} else {
\Messages::error(__('error'));
}
\Response::redirect_back(\Router::get('admin_category'));
}
示例13: processing
function processing()
{
$user = Auth::user();
if ($user->processing == 2) {
$user->processing = 0;
$user->save();
Messages::success('The processing has been reset. Visit your pilot or controller profile to start processing again');
return Redirect::route('user.edit');
} else {
Messages::error('You are not allowed to perform this action.');
return Redirect::route('user.edit');
}
}
示例14: action_index
/**
* The index action
*
* @access public
* @return void
*/
public function action_index()
{
$settings = \Config::load('backup.db');
if (\Input::post()) {
$input = \Input::post();
if (!\Input::is_ajax()) {
$val = Model_Backup::validate('create');
if (!$val->run()) {
if ($val->error() != array()) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings</strong>');
foreach ($val->error() as $e) {
\Messages::error($e->get_message());
}
}
} else {
try {
\Config::save('backup.db', array('enable' => $input['enable'], 'email' => $input['email'], 'period' => $input['period']));
//save cronjob
$output = shell_exec('crontab -l');
$db_backup_cron_file = "/tmp/db_backup_cron.txt";
if ($input['enable']) {
if ($input['period'] == 'daily') {
$daily_backup_command = '0 0 * * * wget ' . \Uri::create('backup/execute');
file_put_contents($db_backup_cron_file, $daily_backup_command . PHP_EOL);
} else {
if ($input['period'] == 'weekly') {
$weekly_backup_command = '0 0 * * 0 wget ' . \Uri::create('backup/execute');
file_put_contents($db_backup_cron_file, $weekly_backup_command . PHP_EOL);
}
}
} else {
file_put_contents($db_backup_cron_file, "" . PHP_EOL);
}
exec("crontab {$db_backup_cron_file}");
\Messages::success('Settings successfully created.');
\Response::redirect('admin/backup');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create settings.</strong>');
// Uncomment lines below to show database errors
$errors = $e->getMessage();
\Messages::error($errors);
}
}
}
}
\View::set_global('title', 'Backup');
\Theme::instance()->set_partial('content', $this->view_dir . 'index')->set('settings', $settings, false);
}
示例15: action_login
/**
* Login user
*/
public function action_login()
{
if ($this->request->method() == Request::POST) {
$login = $this->request->post();
if (Auth::instance()->login($login['email'], $login['password'], isset($login['remember']))) {
if ($next_url = Flash::get('redirect')) {
$this->go($next_url);
}
$this->go_backend();
}
Messages::error('Por favor, comprueba tus datos de acceso e inténtalo de nuevo.');
}
Document::title('Ingresar');
}