本文整理汇总了PHP中Flash::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Flash::set方法的具体用法?PHP Flash::set怎么用?PHP Flash::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Flash
的用法示例。
在下文中一共展示了Flash::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSend
public function actionSend($name = null)
{
if (defined('DISABLE_MESSAGING') && DISABLE_MESSAGING) {
throw new Lvc_Exception('Messaging disabled', 404);
}
$active_user = User::require_active_user();
$this->setLayoutVar('active_user', $active_user);
if (is_null($name)) {
throw new Lvc_Exception('Null username on send action');
}
if ($user = User::find(array('name' => $name))) {
if (!empty($this->post['submit'])) {
$subject = $this->post['subject'];
$body = $this->post['body'];
$result = Message::send($user, $subject, $body, $active_user);
if ($result['status']) {
Flash::set('success', $result['message']);
$this->redirect('/message/inbox');
die;
} else {
Flash::set('failure', $result['message']);
}
$this->setVar('subject', $subject);
$this->setVar('body', $body);
}
$this->setVar('to_user', $user);
} else {
throw new Lvc_Exception('User Not Found: ' . $name);
}
}
示例2: _add
private function _add($template)
{
$data = $this->request->post();
$this->auto_render = FALSE;
if (empty($data['status'])) {
$data['status'] = Model_Email_Template::INACTIVE;
}
Flash::set('post_data', $data);
$template->values($data);
try {
if ($template->create()) {
Kohana::$log->add(Log::INFO, 'Template :template has been added by :user', array(':template' => HTML::anchor(Route::get('email_controllers')->uri(array('controller' => 'templates', 'action' => 'edit', 'id' => $template->id)), $template->subject)))->write();
Messages::success(__('Email template has been saved!'));
Observer::notify('email_templates_add', $template);
}
} catch (ORM_Validation_Exception $e) {
Messages::errors($e->errors('validation'));
$this->go_back();
}
// save and quit or save and continue editing?
if ($this->request->post('commit') !== NULL) {
$this->go(Route::get('email_controllers')->uri(array('controller' => 'templates')));
} else {
$this->go(Route::get('email_controllers')->uri(array('controller' => 'templates', 'action' => 'edit', 'id' => $template->id)));
}
}
示例3: _add
private function _add(ORM $page)
{
$page_data = $this->request->post('page');
// Сохраняем полученые данные в сесиию
Flash::set('page::add::data', $page_data);
// Создаем новую страницу
try {
$page = $page->values($page_data)->create();
// Если есть права на управление ролями
if (ACL::check('page.permissions')) {
$page->save_permissions($this->request->post('page_permissions'));
}
Messages::success(__('Page has been saved!'));
Flash::clear('page::add::data');
} catch (ORM_Validation_Exception $e) {
Messages::errors($e->errors('validation'));
$this->go_back();
} catch (Kohana_Exception $e) {
Messages::errors(__('Something went wrong!'));
$this->go_back();
}
// save and quit or save and continue editing ?
if ($this->request->post('commit') !== NULL) {
$this->go();
} else {
$this->go(array('action' => 'edit', 'id' => $page->id));
}
}
示例4: update_event
public function update_event()
{
if (!isset($_POST['save'])) {
Flash::set('error', __('Could not update this event!'));
} else {
use_helper('Kses');
/* Prepare the data */
$data = $_POST['event'];
if (isset($data['id'])) {
$data['id'] = kses(trim($data['id']), array());
}
$event = new CalendarEvent();
if (isset($data['id'])) {
$event->id = $data['id'];
$event->created_by_id = $data['created_by_id'];
}
$event->title = $data['title'];
$event->date_from = $data['date_from'];
$event->date_to = $data['date_to'];
$event->description = $data['description'];
/* Check data and, if correct, save to DB */
if ($event->checkData() && $event->save()) {
if (isset($data['id'])) {
Flash::set('success', __('The event has been updated.'));
} else {
Flash::set('success', __('A new event has been created.'));
}
redirect(get_url('plugin/calendar/events'));
} else {
Flash::setNow('error', __('There are errors in the form.'));
$this->display(CALENDAR_VIEWS . '/update', array('event' => $event));
}
}
}
示例5: _save
/**
* Saves the settings.
*/
private final function _save()
{
$data = $_POST['setting'];
// CSRF checks
if (isset($_POST['csrf_token'])) {
$csrf_token = $_POST['csrf_token'];
if (!SecureToken::validateToken($csrf_token, BASE_URL . 'setting')) {
Flash::set('error', __('Invalid CSRF token found!'));
Observer::notify('csrf_token_invalid', AuthUser::getUserName());
redirect(get_url('setting'));
}
} else {
Flash::set('error', __('No CSRF token found!'));
Observer::notify('csrf_token_not_found', AuthUser::getUserName());
redirect(get_url('setting'));
}
if (!isset($data['allow_html_title'])) {
$data['allow_html_title'] = 'off';
}
use_helper('Kses');
$allowed = array('img' => array('src' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'b' => array(), 'blockquote' => array('cite' => array()), 'br' => array(), 'code' => array(), 'em' => array(), 'i' => array(), 'p' => array(), 'strike' => array(), 'strong' => array());
$data['admin_title'] = kses(trim($data['admin_title']), $allowed);
Setting::saveFromData($data);
Flash::set('success', __('Settings have been saved!'));
redirect(get_url('setting'));
}
示例6: _add
private function _add(ORM $user)
{
$data = $this->request->post('user');
$profile = $this->request->post('profile');
$user_roles = $this->request->post('user_roles');
$this->auto_render = FALSE;
if (empty($data['notice'])) {
$data['notice'] = 0;
}
Flash::set('users::add::data', $data);
try {
$user = $user->create_user($data, array('password', 'username', 'email'));
if (!empty($user_roles)) {
$user->update_related_ids('roles', explode(',', $user_roles));
}
$profile['user_id'] = $user->id;
$user->profile->values($profile)->create();
Messages::success(__('User has been added!'));
} catch (ORM_Validation_Exception $e) {
Messages::errors($e->errors('validation'));
$this->go_back();
}
if ($this->request->post('commit') !== NULL) {
$this->go();
} else {
$this->go(array('action' => 'edit', 'id' => $user->id));
}
}
示例7: create_user
public function create_user()
{
// If there are no users then let's create one.
$db = Database::get_instance();
$db->query('SELECT * FROM `users` LIMIT 1');
if ($db->has_rows() && !Auth::get_instance()->logged_in()) {
Flash::set('<p class="flash validation">Sorry but to create new users, you must be logged in.</p>');
Core_Helpers::redirect(WEB_ROOT . 'login/');
}
$validator = Error::instance();
if (isset($_POST['email'])) {
$validator->email($_POST['email'], 'email');
$validator->blank($_POST['username'], 'username');
$validator->blank($_POST['password'], 'password');
$validator->passwords($_POST['password'], $_POST['confirm_password'], 'confirm_password');
$user = new Users();
if ($user->select(array('username' => $_POST['username']))) {
$validator->add('username', 'The username <strong>' . htmlspecialchars($_POST['username']) . '</strong> is already taken.');
}
if ($validator->ok()) {
$user = new Users();
$user->load($_POST);
$user->level = 'admin';
$user->insert();
Flash::set('<p class="flash success">User created successfully.</p>');
Core_Helpers::redirect(WEB_ROOT . 'login/');
}
}
$this->data['error'] = $validator;
$this->load_template('create_user');
}
示例8: submit
public function submit()
{
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// TODO validate data
if ($_POST['password'] !== $_POST['passwordrepeat']) {
Flash::set('error_message', 'Your passwords did not match!');
} elseif (!preg_match("#[0-9]+#", $_POST['password'])) {
// should contain at least 1 number
Flash::set('error_message', 'Your password should contain at least 1 number');
} elseif (!preg_match("#[A-Z]+#", $_POST['password'])) {
// should contain at least 1 capital letter
Flash::set('error_message', 'Your password should contain at least an uppercase letter');
} elseif (!preg_match("#[a-z]+#", $_POST['password'])) {
// should contain at least 1 lowercase letter
Flash::set('error_message', 'Your password should contain at least a lowercase letter');
} else {
// TODO submit data
Real_Estate::create(['name' => $_POST['name'], 'password' => create_hash($_POST['password']), 'address' => $_POST['address'], 'email' => $_POST['email'], 'phone' => $_POST['phone'], 'photo' => null]);
Flash::set('success_message', 'Your company account has been created!');
$this->redirect('/');
return;
}
$this->redirect('/realest/signup');
} else {
$this->send404();
}
}
示例9: require_active_user
public static function require_active_user()
{
if ($user = self::get_active_user()) {
if (defined('ADMIN_ONLY') && ADMIN_ONLY) {
if ($user->admin) {
return $user;
} else {
buffer_end_clean();
Flash::set('failure', SITE_NAME . ' is currently locked, you must be an admin to login.');
//throw new Lvc_Exception('Non admin ('.$user->name.') tried to login during lock.');
//$_SESSION['flash']['referrer'] = $_SERVER['REQUEST_URI'];
header('Location: /locked');
die;
}
} else {
return $user;
}
} else {
buffer_end_clean();
Flash::set('failure', 'You must first login.');
$_SESSION['flash']['referrer'] = $_SERVER['REQUEST_URI'];
header('Location: /user/login');
die;
}
}
示例10: deactivate_plugin
function deactivate_plugin($plugin)
{
if (!AuthUser::hasPermission('administrator')) {
Flash::set('error', __('You do not have permission to access the requested page!'));
redirect(get_url());
}
Plugin::deactivate($plugin);
}
示例11: get_response
/**
* Generate a Response for the 401 Exception.
*
* The user should be redirect to a login page.
*
* @return Response
*/
public function get_response()
{
Flash::set('protected_page', Context::instance()->get_page());
if (($page = Model_Page_Front::findByField('behavior_id', 'protected_page')) !== FALSE) {
return Request::factory($page->url)->execute();
}
throw new HTTP_Exception_401($this->message);
}
示例12: _checkVersion
function _checkVersion()
{
if (CHECK_UPDATES) {
$v = file_get_contents('http://www.madebyfrog.com/version/');
if ($v > FROG_VERSION) {
Flash::set('error', __('<b>Information!</b> New Frog version available (v. <b>:version</b>)! Visit <a href="http://www.madebyfrog.com/">http://www.madebyfrog.com/</a> to upgrade your version!', array(':version' => $v)));
}
}
}
示例13: dashboard_events_widget_uninstall
function dashboard_events_widget_uninstall()
{
$conn = Record::getConnection();
if ($conn->exec("DROP TABLE IF EXISTS " . TABLE_PREFIX . "dashboard_log") === false) {
Flash::set("error", __("Unable to drop table dashboard_log"));
redirect(get_url("setting"));
die;
}
}
示例14: save
/**
* Save the settings
*
* @todo Add a sanity check for input.
*/
function save()
{
$settings = $_POST['settings'];
$ret = Plugin::setAllSettings($settings, 'multi_lang');
if ($ret) {
Flash::set('success', __('The settings have been updated.'));
} else {
Flash::set('error', 'An error has occurred while trying to save the settings.');
}
redirect(get_url('plugin/multi_lang/settings'));
}
示例15: save
function save()
{
$options = $_POST['options'];
$ret = Plugin::setAllSettings($options, 'easysnippet');
if ($ret) {
Flash::set('success', __('The settings have been updated.'));
} else {
Flash::set('error', 'An error has occurred while trying to save the settings.');
}
redirect(get_url('plugin/easysnippet/settings'));
}