本文整理汇总了PHP中Notification::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::set方法的具体用法?PHP Notification::set怎么用?PHP Notification::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
public function set($fields = array())
{
if (!$this->_db->insert('posts', $fields)) {
throw new Exception('There was a problem posting');
}
$notification = new Notification();
$timestamp = date('Y-m-d H:i:s');
$notification->set(array('uid' => $fields['uid'], 'fid' => $fields['fid'], 'type' => 'new_post', 'timestamp' => $timestamp));
$notification->set(array('uid' => $fields['fid'], 'fid' => $fields['uid'], 'type' => 'posted', 'timestamp' => $timestamp));
}
示例2: delete
/**
* Delete a sms client
*
* @access public
* @param int $id
* @return void
*/
public function delete($id)
{
$client = new Smsclient();
if ($client->delete($id)) {
Notification::set(Smsclients::SUCCESS, "Succesfully deleted the client");
} else {
Notification::set(Smsclients::DANGER, "Something went wrong");
}
redirect(base_url() . "smsclients/index");
}
示例3: update
public function update($id)
{
$region = (new Region())->findById($id);
if ($this->input->post('name')) {
$region->populate($this->input->post());
if ($region->save()) {
Notification::set(Regions::SUCCESS, "The region has been added");
redirect("/regions/");
}
}
$this->data["region"] = $region;
$this->load->view("regions/update.tpl", $this->data);
}
示例4: main
/**
* main toggle admin function
*/
public static function main()
{
// handle option form submit
if (Request::post('toggle_options')) {
if (Security::check(Request::post('csrf'))) {
Option::update('toggle_duration', (int) Request::post('toggle_duration'));
Option::update('toggle_easing', Request::post('toggle_easing'));
Notification::set('success', __('Configuration has been saved with success!', 'toggle'));
} else {
Notification::set('error', __('Request was denied. Invalid security token. Please refresh the page and try again.', 'toggle'));
die;
}
Request::redirect('index.php?id=toggle');
}
// Display view
View::factory('toggle/views/backend/index')->display();
}
示例5: main
/**
* Main Emails admin function
*/
public static function main()
{
// Init vars
$email_templates_path = STORAGE . DS . 'emails' . DS;
$email_templates_list = array();
// Check for get actions
// -------------------------------------
if (Request::get('action')) {
// Switch actions
// -------------------------------------
switch (Request::get('action')) {
// Plugin action
// -------------------------------------
case "edit_email_template":
if (Request::post('edit_email_template') || Request::post('edit_email_template_and_exit')) {
if (Security::check(Request::post('csrf'))) {
// Save Email Template
File::setContent(STORAGE . DS . 'emails' . DS . Request::post('email_template_name') . '.email.php', Request::post('content'));
Notification::set('success', __('Your changes to the email template <i>:name</i> have been saved.', 'emails', array(':name' => Request::post('email_template_name'))));
if (Request::post('edit_email_template_and_exit')) {
Request::redirect('index.php?id=emails');
} else {
Request::redirect('index.php?id=emails&action=edit_email_template&filename=' . Request::post('email_template_name'));
}
}
}
$content = File::getContent($email_templates_path . Request::get('filename') . '.email.php');
// Display view
View::factory('box/emails/views/backend/edit')->assign('content', $content)->display();
break;
}
} else {
// Get email templates
$email_templates_list = File::scan($email_templates_path, '.email.php');
// Display view
View::factory('box/emails/views/backend/index')->assign('email_templates_list', $email_templates_list)->display();
}
}
示例6: main
/**
* Themes plugin admin
*/
public static function main()
{
// Get current themes
$current_site_theme = Option::get('theme_site_name');
$current_admin_theme = Option::get('theme_admin_name');
// Init vars
$themes_site = Themes::getSiteThemes();
$themes_admin = Themes::getAdminThemes();
$templates = Themes::getTemplates();
$chunks = Themes::getChunks();
$styles = Themes::getStyles();
$scripts = Themes::getScripts();
$errors = array();
$chunk_path = THEMES_SITE . DS . $current_site_theme . DS;
$template_path = THEMES_SITE . DS . $current_site_theme . DS;
$style_path = THEMES_SITE . DS . $current_site_theme . DS . 'css' . DS;
$script_path = THEMES_SITE . DS . $current_site_theme . DS . 'js' . DS;
// Save site theme
if (Request::post('save_site_theme')) {
if (Security::check(Request::post('csrf'))) {
Option::update('theme_site_name', Request::post('themes'));
// Clean Monstra TMP folder.
Monstra::cleanTmp();
// Increment Styles and Javascript version
Stylesheet::stylesVersionIncrement();
Javascript::javascriptVersionIncrement();
Request::redirect('index.php?id=themes');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Save site theme
if (Request::post('save_admin_theme')) {
if (Security::check(Request::post('csrf'))) {
Option::update('theme_admin_name', Request::post('themes'));
// Clean Monstra TMP folder.
Monstra::cleanTmp();
Request::redirect('index.php?id=themes');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Its mean that you can add your own actions for this plugin
Action::run('admin_themes_extra_actions');
// Check for get actions
// -------------------------------------
if (Request::get('action')) {
// Switch actions
// -------------------------------------
switch (Request::get('action')) {
// Add chunk
// -------------------------------------
case "add_chunk":
if (Request::post('add_file') || Request::post('add_file_and_exit')) {
if (Security::check(Request::post('csrf'))) {
if (trim(Request::post('name')) == '') {
$errors['file_empty_name'] = __('Required field', 'themes');
}
if (file_exists($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php')) {
$errors['file_exists'] = __('This chunk already exists', 'themes');
}
if (count($errors) == 0) {
// Save chunk
File::setContent($chunk_path . Security::safeName(Request::post('name'), null, false) . '.chunk.php', Request::post('content'));
Notification::set('success', __('Your changes to the chunk <i>:name</i> have been saved.', 'themes', array(':name' => Security::safeName(Request::post('name'), null, false))));
if (Request::post('add_file_and_exit')) {
Request::redirect('index.php?id=themes');
} else {
Request::redirect('index.php?id=themes&action=edit_chunk&filename=' . Security::safeName(Request::post('name'), null, false));
}
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Save fields
if (Request::post('name')) {
$name = Request::post('name');
} else {
$name = '';
}
if (Request::post('content')) {
$content = Request::post('content');
} else {
$content = '';
}
// Display view
View::factory('box/themes/views/backend/add')->assign('name', $name)->assign('content', $content)->assign('errors', $errors)->assign('action', 'chunk')->display();
break;
// Add template
// -------------------------------------
// Add template
// -------------------------------------
case "add_template":
if (Request::post('add_file') || Request::post('add_file_and_exit')) {
if (Security::check(Request::post('csrf'))) {
if (trim(Request::post('name')) == '') {
//.........这里部分代码省略.........
示例7: delete
/**
* @access public
* @param int $id
* @return void
*/
public function delete($id)
{
if (!is_numeric($id)) {
Notification::set(StationDetails::WARNING, "No access allowed");
redirect("/graph");
}
}
示例8: resendInvite
/**
* Resend invitation e-mail
*
* @access public
* @param int $id
* @return void
*/
public function resendInvite($id)
{
if ($this->_send_user_invitation($id)) {
Notification::set(User::SUCCESS, "The e-mail has been send");
}
redirect("/user");
}
示例9: main
/**
* Snippets admin function
*/
public static function main()
{
// Init vars
$snippets_path = STORAGE . DS . 'snippets' . DS;
$snippets_list = array();
$errors = array();
// Check for get actions
// -------------------------------------
if (Request::get('action')) {
// Switch actions
// -------------------------------------
switch (Request::get('action')) {
// Add snippet
// -------------------------------------
case "add_snippet":
if (Request::post('add_snippets') || Request::post('add_snippets_and_exit')) {
if (Security::check(Request::post('csrf'))) {
if (trim(Request::post('name')) == '') {
$errors['snippets_empty_name'] = __('Required field', 'snippets');
}
if (file_exists($snippets_path . Security::safeName(Request::post('name')) . '.snippet.php')) {
$errors['snippets_exists'] = __('This snippet already exists', 'snippets');
}
if (count($errors) == 0) {
// Save snippet
File::setContent($snippets_path . Security::safeName(Request::post('name')) . '.snippet.php', Request::post('content'));
Notification::set('success', __('Your changes to the snippet <i>:name</i> have been saved.', 'snippets', array(':name' => Security::safeName(Request::post('name')))));
if (Request::post('add_snippets_and_exit')) {
Request::redirect('index.php?id=snippets');
} else {
Request::redirect('index.php?id=snippets&action=edit_snippet&filename=' . Security::safeName(Request::post('name')));
}
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Save fields
if (Request::post('name')) {
$name = Request::post('name');
} else {
$name = '';
}
if (Request::post('content')) {
$content = Request::post('content');
} else {
$content = '';
}
// Display view
View::factory('box/snippets/views/backend/add')->assign('content', $content)->assign('name', $name)->assign('errors', $errors)->display();
break;
// Edit snippet
// -------------------------------------
// Edit snippet
// -------------------------------------
case "edit_snippet":
// Save current snippet action
if (Request::post('edit_snippets') || Request::post('edit_snippets_and_exit')) {
if (Security::check(Request::post('csrf'))) {
if (trim(Request::post('name')) == '') {
$errors['snippets_empty_name'] = __('Required field', 'snippets');
}
if (file_exists($snippets_path . Security::safeName(Request::post('name')) . '.snippet.php') and Security::safeName(Request::post('snippets_old_name')) !== Security::safeName(Request::post('name'))) {
$errors['snippets_exists'] = __('This snippet already exists', 'snippets');
}
// Save fields
if (Request::post('content')) {
$content = Request::post('content');
} else {
$content = '';
}
if (count($errors) == 0) {
$snippet_old_filename = $snippets_path . Request::post('snippets_old_name') . '.snippet.php';
$snippet_new_filename = $snippets_path . Security::safeName(Request::post('name')) . '.snippet.php';
if (!empty($snippet_old_filename)) {
if ($snippet_old_filename !== $snippet_new_filename) {
rename($snippet_old_filename, $snippet_new_filename);
$save_filename = $snippet_new_filename;
} else {
$save_filename = $snippet_new_filename;
}
} else {
$save_filename = $snippet_new_filename;
}
// Save snippet
File::setContent($save_filename, Request::post('content'));
Notification::set('success', __('Your changes to the snippet <i>:name</i> have been saved.', 'snippets', array(':name' => basename($save_filename, '.snippet.php'))));
if (Request::post('edit_snippets_and_exit')) {
Request::redirect('index.php?id=snippets');
} else {
Request::redirect('index.php?id=snippets&action=edit_snippet&filename=' . Security::safeName(Request::post('name')));
}
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
//.........这里部分代码省略.........
示例10: array
// Generate new hash
$new_hash = Text::random('alnum', 12);
// Update user hash
$users->updateWhere("[login='" . $user_login . "']", array('hash' => $new_hash));
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$mail->ContentType = 'text/html';
$mail->SetFrom(Option::get('system_email'));
$mail->AddReplyTo(Option::get('system_email'));
$mail->AddAddress($user['email'], $user['login']);
$mail->Subject = __('Your login details for :site_name', 'users', array(':site_name' => $site_name));
$mail->MsgHTML(View::factory('box/emails/views/emails/email_layout')->assign('site_url', $site_url)->assign('site_name', $site_name)->assign('user_id', $user['id'])->assign('user_login', $user['login'])->assign('new_hash', $new_hash)->assign('email_template', 'reset-password')->render());
$mail->Send();
// Set notification
Notification::set('success', __('Your login details for :site_name has been sent', 'users', array(':site_name' => $site_name)));
Notification::set('reset_password', 'reset_password');
// Redirect to password-reset page
Request::redirect(Site::url() . '/admin');
}
Notification::setNow('reset_password', 'reset_password');
}
// If admin user is login = true then set is_admin = true
if (Session::exists('admin') && Session::get('admin') == true) {
$is_admin = true;
} else {
$is_admin = false;
}
// Logout user from system
if (Request::get('logout') && Request::get('logout') == 'do') {
Session::destroy();
}
示例11: main
/**
* System plugin admin
*/
public static function main()
{
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
$filters = Filter::$filters;
$plugins = Plugin::$plugins;
$components = Plugin::$components;
$actions = Action::$actions;
// Get pages table
$pages = new Table('pages');
// Get system timezone
$system_timezone = Option::get('timezone');
// Get languages files
$language_files = File::scan(PLUGINS_BOX . DS . 'system' . DS . 'languages' . DS, '.lang.php');
foreach ($language_files as $language) {
$parts = explode('.', $language);
$languages_array[$parts[0]] = I18n::$locales[$parts[0]];
}
// Get all pages
$pages_array = array();
$pages_list = $pages->select('[slug!="error404" and parent="" and status="published"]');
foreach ($pages_list as $page) {
$pages_array[$page['slug']] = Html::toText($page['title']);
}
// Create Sitemap
// -------------------------------------
if (Request::get('sitemap') == 'create') {
if (Security::check(Request::get('token'))) {
Notification::set('success', __('Sitemap created', 'system'));
Sitemap::create();
Request::redirect('index.php?id=system');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Delete temporary files
// -------------------------------------
if (Request::get('temporary_files') == 'delete') {
if (Security::check(Request::get('token'))) {
Monstra::cleanTmp();
if (count(File::scan(MINIFY, array('css', 'js', 'php'))) == 0 && count(Dir::scan(CACHE)) == 0) {
Notification::set('success', __('Temporary files deleted', 'system'));
Request::redirect('index.php?id=system');
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Set maintenance state on or off
// -------------------------------------
if (Request::get('maintenance')) {
if (Security::check(Request::get('token'))) {
if ('on' == Request::get('maintenance')) {
Option::update('maintenance_status', 'on');
Request::redirect('index.php?id=system');
}
if ('off' == Request::get('maintenance')) {
Option::update('maintenance_status', 'off');
Request::redirect('index.php?id=system');
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Edit settings
// -------------------------------------
if (Request::post('edit_settings')) {
if (Security::check(Request::post('csrf'))) {
// Add trailing slashes
$_site_url = Request::post('system_url');
Option::update(array('sitename' => Request::post('site_name'), 'keywords' => Request::post('site_keywords'), 'description' => Request::post('site_description'), 'slogan' => Request::post('site_slogan'), 'defaultpage' => Request::post('site_default_page'), 'siteurl' => $_site_url, 'timezone' => Request::post('system_timezone'), 'system_email' => Request::post('system_email'), 'language' => Request::post('system_language'), 'maintenance_message' => Request::post('site_maintenance_message')));
Notification::set('success', __('Your changes have been saved.', 'system'));
Request::redirect('index.php?id=system');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Its mean that you can add your own actions for this plugin
Action::run('admin_system_extra_actions');
// Display view
View::factory('box/system/views/backend/index')->assign('pages_array', $pages_array)->assign('languages_array', $languages_array)->display();
} else {
Request::redirect('index.php?id=users&action=edit&user_id=' . Session::get('user_id'));
}
}
示例12: getPosts
/**
* Get posts
*
* <code>
* // Get all posts
* echo Blog::getPosts();
*
* // Get last 5 posts
* echo Blog::getPosts(5);
* </code>
*
* @param integer $num Number of posts to show
* @return string
*/
public static function getPosts($nums = 10)
{
// Get page param
$page = Request::get('page') ? (int) Request::get('page') : 1;
if (Request::get('tag')) {
$query = '[parent="' . Blog::$parent_page_name . '" and status="published" and contains(tags, "' . Request::get('tag') . '")]';
Notification::set('tag', Request::get('tag'));
} else {
$query = '[parent="' . Blog::$parent_page_name . '" and status="published"]';
Notification::clean();
}
// Get Elements Count
$elements = count(Pages::$pages->select($query, 'all'));
// Get Pages Count
$pages = ceil($elements / $nums);
if ($page < 1) {
$page = 1;
} elseif ($page > $pages) {
$page = $pages;
}
$start = ($page - 1) * $nums;
// If there is no posts
if ($start < 0) {
$start = 0;
}
// Get posts and sort by DESC
$posts = Pages::$pages->select($query, $nums, $start, array('slug', 'title', 'author', 'date'), 'date', 'DESC');
// Loop
foreach ($posts as $key => $post) {
$post_short = explode("{cut}", Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . $post['id'] . '.page.txt')));
$posts[$key]['content'] = Filter::apply('content', $post_short[0]);
}
// Display view
return View::factory('blog/views/frontend/index')->assign('posts', $posts)->render() . View::factory('blog/views/frontend/pager')->assign('pages', $pages)->assign('page', $page)->render();
}
示例13: delete
/**
* @access protected
* @return boolean
*/
public function delete($id)
{
$this->allow("admin");
$feedback = new UserFeedback();
$obj = $feedback->findById($id);
if ($obj) {
if ($feedback->delete($id)) {
redirect("/feedback");
}
}
Notification::set(Feedback::DANGER, "Something went wrong. Please try again.");
redirect("/feedback");
}
示例14: main
//.........这里部分代码省略.........
include PLUGINS . DS . basename(Text::lowercase(Request::get('install')), '.manifest.xml') . DS . 'install' . DS . $plugin_name . '.install.php';
}
Request::redirect('index.php?id=plugins');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Delete plugin from server
// -------------------------------------
if (Request::get('delete_plugin_from_server')) {
if (Security::check(Request::get('token'))) {
// Clean Monstra TMP folder.
Monstra::cleanTmp();
Stylesheet::stylesVersionIncrement();
Javascript::javascriptVersionIncrement();
Dir::delete(PLUGINS . DS . basename(Request::get('delete_plugin_from_server'), '.manifest.xml'));
Request::redirect('index.php?id=plugins');
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Upload & extract plugin archive
// -------------------------------------
if (Request::post('upload_file')) {
if (Security::check(Request::post('csrf'))) {
if ($_FILES['file']) {
if (in_array(File::ext($_FILES['file']['name']), array('zip'))) {
$tmp_dir = ROOT . DS . 'tmp' . DS . uniqid('plugin_');
$error = 'Plugin was not uploaded';
if (Dir::create($tmp_dir)) {
$file_locations = Zip::factory()->extract($_FILES['file']['tmp_name'], $tmp_dir);
if (!empty($file_locations)) {
$manifest = '';
foreach ($file_locations as $filepath) {
if (substr($filepath, -strlen('.manifest.xml')) === '.manifest.xml') {
$manifest = $filepath;
break;
}
}
if (!empty($manifest) && basename(dirname($manifest)) === 'install') {
$manifest_file = pathinfo($manifest, PATHINFO_BASENAME);
$plugin_name = str_replace('.manifest.xml', '', $manifest_file);
if (Dir::create(PLUGINS . DS . $plugin_name)) {
$tmp_plugin_dir = dirname(dirname($manifest));
Dir::copy($tmp_plugin_dir, PLUGINS . DS . $plugin_name);
Notification::set('success', __('Plugin was uploaded', 'plugins'));
$error = false;
}
}
}
} else {
$error = 'System error';
}
} else {
$error = 'Forbidden plugin file type';
}
} else {
$error = 'Plugin was not uploaded';
}
if ($error) {
Notification::set('error', __($error, 'plugins'));
}
if (Request::post('dragndrop')) {
Request::shutdown();
} else {
Request::redirect($site_url . '/admin/index.php?id=plugins#installnew');
}
} else {
die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
}
}
// Installed plugins
$plugins_installed = array();
// New plugins
$plugins_new = array();
// Plugins to install
$plugins_to_intall = array();
// Scan plugins directory for .manifest.xml
$plugins_new = File::scan(PLUGINS, '.manifest.xml');
// Get installed plugins from plugins table
$plugins_installed = $plugins->select(null, 'all', null, array('location', 'priority'), 'priority', 'ASC');
// Update $plugins_installed array. extract plugins names
foreach ($plugins_installed as $plg) {
$_plg[] = basename($plg['location'], 'plugin.php') . 'manifest.xml';
}
// Diff
$plugins_to_install = array_diff($plugins_new, $_plg);
// Create array of plugins to install
$count = 0;
foreach ($plugins_to_install as $plugin) {
$plg_path = PLUGINS . DS . Text::lowercase(basename($plugin, '.manifest.xml')) . DS . 'install' . DS . $plugin;
if (file_exists($plg_path)) {
$plugins_to_intall[$count]['path'] = $plg_path;
$plugins_to_intall[$count]['plugin'] = $plugin;
$count++;
}
}
// Draw template
View::factory('box/plugins/views/backend/index')->assign('installed_plugins', $installed_plugins)->assign('plugins_to_intall', $plugins_to_intall)->assign('_users_plugins', $_users_plugins)->assign('fileuploader', array('uploadUrl' => $site_url . '/admin/index.php?id=plugins', 'csrf' => Security::token(), 'errorMsg' => __('Upload server error', 'filesmanager')))->display();
}
示例15: enable
/**
* Enable a station
*
* @access public
* @param int $id (station id)
* @return void
*/
public function enable($id)
{
$station = (new Station())->findById($id);
if ($station->getId() !== null) {
$station->setActive(1);
if ($station->save() !== false) {
Notification::set(Stations::SUCCESS, "The station is activated");
} else {
Notification::set(Stations::WARNING, "Something went wrong. Please try agian");
}
}
redirect("/stations/");
}