本文整理汇总了PHP中Notifications::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::set方法的具体用法?PHP Notifications::set怎么用?PHP Notifications::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifications
的用法示例。
在下文中一共展示了Notifications::set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public static function add($post_id)
{
$post = Input::post(array('name', 'email', 'text'));
$errors = array();
if (empty($post['name'])) {
$errors[] = 'Please enter ayour name';
}
if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) {
$errors[] = 'Please enter a valid email address';
}
if (empty($post['text'])) {
$errors[] = 'Please enter your comments';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
$post['date'] = time();
$post['status'] = 'pending';
$post['post'] = $post_id;
$keys = array();
$values = array();
$args = array();
foreach ($post as $key => $value) {
$keys[] = '`' . $key . '`';
$values[] = '?';
$args[] = $value;
}
$sql = "insert into comments (" . implode(', ', $keys) . ") values (" . implode(', ', $values) . ")";
Db::query($sql, $args);
Notifications::set('success', 'Your comment has been sent');
return true;
}
示例2: add
public static function add($post_id)
{
$post = Input::post(array('name', 'email', 'text'));
$errors = array();
if (empty($post['name'])) {
$errors[] = 'Please enter your name';
}
if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) {
$errors[] = 'Please enter a valid email address';
}
if (empty($post['text'])) {
$errors[] = 'Please enter your comments';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
$post['date'] = time();
$post['status'] = Config::get('metadata.auto_published_comments', 0) ? 'published' : 'pending';
$post['post'] = $post_id;
// encode any html
$post['text'] = Html::encode($post['text']);
Db::insert('comments', $post);
Notifications::set('success', 'Your comment has been sent');
return true;
}
示例3: update
public static function update()
{
$post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page'));
$errors = array();
if (empty($post['sitename'])) {
$errors[] = 'You need a site sitename';
}
if (empty($post['description'])) {
$errors[] = 'You need a site description';
}
if (empty($post['theme'])) {
$errors[] = 'You need a theme';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
$post['sitename'] = htmlentities($post['sitename']);
$post['description'] = htmlentities($post['description']);
foreach ($post as $key => $value) {
Db::update('meta', array('value' => $value), array('key' => $key));
}
Notifications::set('success', 'Your metadata has been updated');
return true;
}
示例4: update
public static function update()
{
$post = Input::post(array('sitename', 'description', 'theme', 'twitter', 'home_page', 'posts_page', 'auto_published_comments', 'posts_per_page'));
$errors = array();
if (empty($post['sitename'])) {
$errors[] = 'You need a site sitename';
}
if (empty($post['description'])) {
$errors[] = 'You need a site description';
}
if (empty($post['theme'])) {
$errors[] = 'You need a theme';
}
// auto publish comments
$post['auto_published_comments'] = $post['auto_published_comments'] ? 1 : 0;
// format posts per page, must be a whole number above 1 defaults to 10 if a invalid number is entered
$post['posts_per_page'] = ($posts_per_page = intval($post['posts_per_page'])) > 0 ? $posts_per_page : 10;
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
foreach ($post as $key => $value) {
Db::update('meta', array('value' => $value), array('key' => $key));
}
Notifications::set('success', 'Your metadata has been updated');
return true;
}
示例5: reset
public function reset($hash)
{
// find user
if (($user = Users::find(array('hash' => $hash))) === false) {
Notifications::set('error', 'User not found');
return Response::redirect($this->admin_url . '/users');
}
/*if(Input::method() == 'POST') {
if(Users::reset_password($user->id)) {
return Response::redirect($this->admin_url);
}
}*/
Template::render('users/reset', array('user' => $user));
}
示例6: add
public static function add()
{
$post = Input::post(array('username', 'password', 'email', 'real_name', 'bio', 'status', 'role'));
$errors = array();
if (empty($post['username'])) {
$errors[] = 'Please enter a username';
} else {
if (static::find(array('username' => $post['username']))) {
$errors[] = 'Username is already being used';
}
}
if (empty($post['password'])) {
$errors[] = 'Please enter a password';
}
if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) {
$errors[] = 'Please enter a valid email address';
}
if (empty($post['real_name'])) {
$errors[] = 'Please enter a display name';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
// encrypt password
$post['password'] = crypt($post['password']);
// format email
$post['email'] = strtolower(trim($post['email']));
// add record
Db::insert('users', $post);
Notifications::set('success', 'A new user has been added');
return true;
}
示例7: add
public static function add()
{
// verify Csrf token
if (Csrf::verify(Input::post('token')) === false) {
Notifications::set('error', 'Invalid token');
return false;
}
$post = Input::post(array('slug', 'name', 'title', 'content', 'redirect', 'status'));
$errors = array();
if (empty($post['name'])) {
$errors[] = Lang::line('pages.missing_name', 'Please enter a name');
}
if (empty($post['title'])) {
$errors[] = Lang::line('pages.missing_title', 'Please enter a title');
}
// check for duplicate slug
$sql = "select id from pages where slug = ?";
if (Db::row($sql, array($post['slug']))) {
$errors[] = Lang::line('pages.duplicate_slug', 'A pages with the same slug already exists, please change your page slug.');
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
if (empty($post['slug'])) {
$post['slug'] = $post['name'];
}
$post['slug'] = Str::slug($post['slug']);
Db::insert('pages', $post);
Notifications::set('success', Lang::line('pages.page_success_created', 'Your new page has been added'));
return true;
}
示例8: add
public static function add()
{
$post = Input::post(array('title', 'slug', 'description', 'html', 'css', 'js', 'status', 'field', 'comments'));
$errors = array();
if (empty($post['title'])) {
$errors[] = 'Please enter a title';
}
if (empty($post['description'])) {
$errors[] = 'Please enter a description';
}
if (empty($post['html'])) {
$errors[] = 'Please enter your html';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
if (empty($post['slug'])) {
$post['slug'] = preg_replace('/\\W+/', '-', trim(strtolower($post['title'])));
}
$custom = array();
if (is_array($post['field'])) {
foreach ($post['field'] as $keylabel => $value) {
list($key, $label) = explode(':', $keylabel);
$custom[$key] = array('label' => $label, 'value' => $value);
}
}
// remove from update
unset($post['field']);
$post['custom_fields'] = json_encode($custom);
// set creation date
$post['created'] = time();
// set author
$user = Users::authed();
$post['author'] = $user->id;
Db::insert('posts', $post);
Notifications::set('success', 'Your new post has been added');
return true;
}
示例9: add
public static function add()
{
$post = Input::post(array('slug', 'name', 'title', 'content', 'status'));
$errors = array();
if (empty($post['name'])) {
$errors[] = 'Please enter a name';
}
if (empty($post['title'])) {
$errors[] = 'Please enter a title';
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
if (empty($post['slug'])) {
$post['slug'] = preg_replace('/\\W+/', '-', trim(strtolower($post['name'])));
}
Db::insert('pages', $post);
Notifications::set('success', 'Your new page has been added');
return true;
}
示例10: add
public static function add()
{
// verify Csrf token
if (Csrf::verify(Input::post('token')) === false) {
Notifications::set('error', 'Invalid token');
return false;
}
$post = Input::post(array('title', 'slug', 'created', 'description', 'html', 'css', 'js', 'status', 'field', 'comments'));
$errors = array();
$post['created'] = strtotime($post['created']);
if ($post['created'] === false) {
$errors[] = Lang::line('posts.invalid_date', 'Please enter a valid date');
}
if (empty($post['title'])) {
$errors[] = Lang::line('posts.missing_title', 'Please enter a title');
}
if (empty($post['description'])) {
$errors[] = Lang::line('posts.missing_description', 'Please enter a description');
}
if (empty($post['html'])) {
$errors[] = Lang::line('posts.missing_html', 'Please enter your html');
}
// use title as fallback
if (empty($post['slug'])) {
$post['slug'] = $post['title'];
}
// format slug
$post['slug'] = Str::slug($post['slug']);
// check for duplicate slug
$sql = "select id from posts where slug = ?";
if (Db::row($sql, array($post['slug']))) {
$errors[] = Lang::line('posts.duplicate_slug', 'A post with the same slug already exists, please change your post slug.');
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
$custom = array();
if (is_array($post['field'])) {
foreach ($post['field'] as $keylabel => $value) {
list($key, $label) = explode(':', $keylabel);
$custom[$key] = array('label' => $label, 'value' => $value);
}
}
// remove from update
unset($post['field']);
$post['custom_fields'] = json_encode($custom);
// set author
$user = Users::authed();
$post['author'] = $user->id;
Db::insert('posts', $post);
Notifications::set('success', Lang::line('posts.post_success_created', 'Your new post has been added'));
return true;
}
示例11: add
public static function add()
{
// verify Csrf token
if (Csrf::verify(Input::post('token')) === false) {
Notifications::set('error', 'Invalid token');
return false;
}
$post = Input::post(array('username', 'password', 'email', 'real_name', 'bio', 'status', 'role'));
$errors = array();
if (empty($post['username'])) {
$errors[] = Lang::line('users.missing_username', 'Please enter a username');
} else {
if (static::find(array('username' => $post['username']))) {
$errors[] = Lang::line('users.username_exists', 'Username is already being used');
}
}
if (empty($post['password'])) {
$errors[] = Lang::line('users.missing_password', 'Please enter a password');
}
if (filter_var($post['email'], FILTER_VALIDATE_EMAIL) === false) {
$errors[] = Lang::line('users.invalid_email', 'Please enter a valid email address');
}
if (empty($post['real_name'])) {
$errors[] = Lang::line('users.missing_name', 'Please enter a display name');
}
if (count($errors)) {
Notifications::set('error', $errors);
return false;
}
// encrypt password
$post['password'] = Hash::make($post['password']);
// format email
$post['email'] = strtolower(trim($post['email']));
// strip tags on real_name (http://osvdb.org/show/osvdb/79659)
$post['real_name'] = strip_tags($post['real_name']);
// add record
Db::insert('users', $post);
Notifications::set('success', Lang::line('users.user_success_created', 'A new user has been added'));
return true;
}