本文整理汇总了PHP中Notifier::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifier::error方法的具体用法?PHP Notifier::error怎么用?PHP Notifier::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifier
的用法示例。
在下文中一共展示了Notifier::error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getForm
public static function getForm($errors = array())
{
global $cfg;
if (LOGGED) {
redirect(REFERER);
}
$note = new Notifier();
$err = new Error();
if ($errors) {
$note->error($errors);
}
if ($_POST['login'] && $_POST['module']) {
$form = array('logname' => $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '', 'password' => $_POST['password-session'] ? filter($_POST['password-session'], 100) : '');
$err->setError('empty_logname', t('Logname field is required.'))->condition(!$form['logname']);
$err->setError('logname_not_exists', t('The logname you used isn't registered.'))->condition($form['logname'] && !User::loginNameRegistered($form['logname']));
$err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
$err->setError('password_invalid', t('Password is invalid.'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
$err->noErrors() ? redirect(REFERER) : $note->restore()->error($err->toArray());
}
$tpl = new PHPTAL('modules/login/form.html');
$tpl->form = $form;
$tpl->err = $err->toArray();
$tpl->note = $note;
echo $tpl->execute();
}
示例2: getContent
public function getContent()
{
// User is logged in
if (LOGGED) {
$this->subcodename = 'logged';
$tpl = new PHPTAL('blocks/user_panel/logged.html');
$tpl->user = User::format(User::$id, User::$nickname, User::$groupId);
$pm_item = User::$pmNew ? array(t('Messages <strong>(New: %new)</strong>', array('%new' => $user->pm_new)), 'pm/inbox') : array(t('Messages'), 'pm');
$tpl->items = items(array($pm_item[0] => HREF . $pm_item[1], t('Administration') => HREF . 'admin', t('Edit profile') => HREF . 'edit_profile', t('Log out') => HREF . 'logout'));
return $tpl->execute();
} else {
$err = new Error();
$note = new Notifier('note-user_panel');
$this->subcodename = 'not_logged';
$form = array('logname' => null, 'password' => null);
if ($_POST['login'] && $_POST['user_panel']) {
$form['logname'] = $_POST['logname-session'] ? filter($_POST['logname-session'], 100) : '';
$form['password'] = $_POST['password-session'] ? $_POST['password-session'] : '';
$err->setError('logname_empty', t('Logname field is required.'))->condition(!$form['logname']);
$err->setError('logname_not_exists', t('Entered logname is not registered.'))->condition(!User::loginNameRegistered($form['logname']));
$err->setError('password_empty', t('Password field is required.'))->condition(!$form['password']);
$err->setError('password_incorrect', t('ERROR_PASS_INCORRECT'))->condition($form['password'] && !User::loginPasswordCorrect($form['password']));
if ($err->noErrors()) {
redirect('./');
} else {
$note->error($err->toArray());
}
}
$tpl = new PHPTAL('blocks/user_panel/not_logged.html');
$tpl->note = $note;
$tpl->form = $form;
$tpl->err = $err->toArray();
return $tpl->execute();
}
}
示例3: getContent
public function getContent()
{
global $sql;
//Lang::load('blocks/shoutbox/lang.*.php');
$err = new Error();
$note = new Notifier('note-shoutbox');
$form['author'] = LOGGED ? User::$nickname : '';
$form['message'] = '';
if (isset($_POST['reply-shoutbox'])) {
$form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
$form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
$err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
$err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
$err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
// No errors
if ($err->noErrors()) {
$sql->exec('
INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
VALUES (
' . TIMESTAMP . ',
"' . $form['author'] . '",
"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
' . UID . ',
"' . IP . '")');
$sql->clearCache('shoutbox');
$note->success(t('Entry was added successfully.'));
redirect(HREF . PATH . '#shoutbox');
} else {
$note->error($err->toArray());
}
}
// If cache for shoutbox doesn't exists
if (!($entries = $sql->getCache('shoutbox'))) {
$query = $sql->query('
SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
FROM ' . DB_PREFIX . 'shoutbox s
LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
ORDER BY s.id DESC
LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
while ($row = $query->fetch()) {
if ($row['author_id']) {
$row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
$row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
}
$entries[] = $row;
}
$sql->putCacheContent('shoutbox', $entries);
}
try {
$tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
$tpl->entries = $entries;
$tpl->err = $err->toArray();
$tpl->form = $form;
$tpl->note = $note;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e->getMessage());
//echo Note::error($e->getMessage());
}
}
示例4: not_found
/**
*
* @global object $kio
* @global object $module
* @param string $message
* @param array $causes [optional]
* @param bool $notify [optional]
*/
function not_found($message, $causes = array(), $notify = true)
{
global $kio, $module;
if (!$causes) {
$causes = array(t('Content was moved or deleted.'), t('Entered URL is invalid.'));
}
Kio::addTitle(t('Page not found'));
$module->codename = 'error';
$module->subcodename = 'not_found';
$note = new Notifier();
$note->error(t($message));
try {
$tpl = new PHPTAL('system/not_found.html');
$tpl->causes = $causes;
$tpl->note = $note;
echo $tpl->execute();
} catch (Exception $e) {
template_error();
}
}
示例5: getContent
public function getContent()
{
global $sql;
if (!LOGGED) {
return no_access('By mieć dostęp do edycji profilu musisz się zalogować.');
}
$note = new Notifier();
$err = new Error();
$edit = isset($_POST['edit']) ? true : false;
$countries = (include 'lang/countries.php');
asort($countries);
//Edit user by ID
if (ctype_digit(u1)) {
$profile = $sql->query('
SELECT u.*
FROM ' . DB_PREFIX . 'users u
WHERE u.id = ' . u1)->fetch(PDO::FETCH_ASSOC);
if ($profile) {
Kio::addTitle(t('Users'));
Kio::addBreadcrumb(t('Users'), 'users');
Kio::addTitle($profile['nickname'] . ' - ' . t('Edit profile'));
Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1);
Kio::addBreadcrumb(t('Edit profile'), 'edit_profile/' . u1);
$form = $profile;
} else {
return not_found(t('Selected user doesn't exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
}
} else {
$profile = User::toArray();
Kio::addTitle(t('Edit profile'));
Kio::addBreadcrumb(t('Edit profile'), 'edit_profile');
}
$form = $profile;
$form['password'] = '';
$form['password2'] = '';
$form['birthdate'] = explode('-', $profile['birthdate']);
$form['newsletter'] = $profile['newsletter'] ? 1 : 0;
$form['pm_notify'] = $profile['pm_notify'] ? 1 : 0;
$form['hide_email'] = $profile['hide_email'] ? 1 : 0;
if (!u1 || $profile) {
// Edit profile
if (!empty($edit)) {
$form = array('nickname' => Kio::getConfig('allow_change_nick', 'edit_profile') ? filter($_POST['nickname'], 100) : User::$nickname, 'password' => filter($_POST['password'], 100), 'password2' => filter($_POST['password2'], 100), 'email' => strtolower(filter($_POST['email'], 100)), 'forename' => $_POST['forename'], 'surname' => $_POST['surname'], 'gender' => $_POST['gender'], 'locality' => $_POST['locality'], 'country' => !empty($countries[$_POST['country']]) ? $_POST['country'] : '', 'communicator' => $_POST['communicator'], 'website' => $_POST['website'], 'birthdate' => array_map('intval', (array) $_POST['birthdate']), 'newsletter' => isset($_POST['newsletter']) ? 1 : 0, 'pm_notify' => isset($_POST['pm_notify']) ? 1 : 0, 'hide_email' => isset($_POST['hide_email']) ? 1 : 0, 'avatar' => $_FILES['avatar']['error'] == 0 && !$_POST['delete_avatar'] ? $_FILES['avatar'] : array(), 'delete_avatar' => isset($_POST['delete_avatar']) ? 1 : 0, 'photo' => isset($_FILES['photo']) ? $_FILES['photo'] : null, 'delete_photo' => isset($_POST['delete_photo']) ? 1 : 0, 'title' => $_POST['title'], 'interests' => $_POST['interests'], 'signature' => $_POST['signature']);
$allowed_types = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif');
// Nickname
$err->setError('nickname_empty', t('ERROR_NICKNAME_EMPTY'))->condition(!$form['nickname']);
$err->setError('nickname_exists', t('ERROR_NICKNAME_EXISTS'))->condition(Kio::getConfig('allow_change_nick', 'edit_profile') && $form['nickname'] && strtolower($form['nickname']) != strtolower($profile['nickname']) && is_registered($form['nickname']));
// Password
$err->setError('password_differ', t('ERROR_PASSWORD_DIFFER'))->condition($form['password'] != $form['password2']);
// E-mail
$err->setError('email_empty', t('ERROR_EMAIL_EMPTY'))->condition(!$form['email']);
if ($form['email']) {
$err->setError('email_invalid', t('ERROR_EMAIL_INVALID'))->condition($form['email'] && !is_email($form['email']));
$err->setError('email_exists', t('ERROR_EMAIL_EXISTS'))->condition($form['email'] != $profile['email'] && is_email($form['email']) && is_registered($form['email'], 'email'));
}
// Birthdate
$err->setError('birthdate_invalid', t('ERROR_BIRTHDATE'))->condition(array_sum($form['birthdate']) > 0 && !is_date('Y-n-j', $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2]));
// Avatar
if ($form['avatar']) {
$err->avatar_invalid_type(t('ERROR_ava'))->condition(!in_array($form['avatar']['type'], array_keys($allowed_types)));
$err->avatar_exceeded_max_size(t('ERROR_ava'))->condition(Kio::getConfig('avatar_size_max', 'edit_profile') && !$err->isError('avatar_invalid_type') && $form['avatar']['size'] > Kio::getConfig('avatar_size_max', 'edit_profile'));
}
// No errors
if ($err->noErrors()) {
if ($form['delete_avatar']) {
unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar);
}
if ($form['avatar']) {
move_uploaded_file($_FILES['avatar']['tmp_name'], ROOT . 'images/avatars/' . $profile['id'] . '.' . $allowed_types[$form['avatar']['type']]);
if ($allowed_types[$form['avatar']['type']] != User::$avatar) {
unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar);
}
}
$form['birthdate'] = array_sum($form['birthdate']) > 0 ? $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2] : '';
$sql->exec('
UPDATE ' . DB_PREFIX . 'users
SET nickname = "' . (Kio::getConfig('allow_change_nick', 'edit_profile') ? $form['nickname'] : User::$nickname) . '",
' . ($form['password'] ? 'pass = "' . md5($form['password']) . '",' : '') . '
email = "' . $form['email'] . '",
forename = "' . $form['forename'] . '",
surname = "' . $form['surname'] . '",
gender = ' . ($form['gender'] == 1 || $form['gender'] == 2 ? (int) $form['gender'] : 0) . ',
locality = "' . $form['locality'] . '",
country = "' . $form['country'] . '",
communicator = "' . $form['communicator'] . '",
website = "' . $form['website'] . '",
birthdate = "' . $form['birthdate'] . '",
newsletter = ' . $form['newsletter'] . ',
pm_notify = ' . $form['pm_notify'] . ',
hide_email = ' . $form['hide_email'] . ',
' . ($form['avatar'] ? 'avatar = "' . $allowed_types[$form['avatar']['type']] . '",' : ($form['delete_avatar'] ? 'avatar = "",' : '')) . '
title = "' . $form['title'] . '",
interests = "' . $form['interests'] . '",
signature = "' . $form['signature'] . '"
WHERE id = ' . $profile['id']);
$note->success(t('Your profile was modified successfully.'));
redirect(HREF . 'edit_profile');
} else {
$note->error($err->toArray());
}
//.........这里部分代码省略.........
示例6: Notifier
<?php
// KioCMS - Kiofol Content Managment System
// modules/guestbook/admin/settings.php
$note = new Notifier();
$err = new Errors();
$save = $_POST['save'] ? true : false;
$form = $save ? $_POST['form'] : $guestbook;
$form['bbcode'] = $save ? $_POST['bbcode'] : $guestbook['bbcode'] ? 1 : 0;
$form['allow_signatures'] = $save ? $_POST['allow_signatures'] : $guestbook['allow_signatures'] ? 1 : 0;
$form['blocks'] = $save ? array_diff($blocks, $_POST['blocks']) : ($guestbook['blocks'] ? explode(',', trim($guestbook['blocks'])) : '');
if ($save) {
// Errors
$err->message_max_empty(t('ERROR_MESSAGE_MAX_EMPTY'), !$form['message_max'])->limit_empty(t('ERROR_ERROR_LIMIT_EMPTY'), !$form['limit'])->order_by_empty(t('ERROR_ORDER_BY_EMPTY'), $form['order_by']);
if (!$err->count()) {
Settings::update('guestbook');
Cache::clear('contact.txt');
$note->success(t('SAVED_SUCCESSFUL'));
redirect(HREF . 'admin/modules/guestbook/settings');
} else {
$note->error($err);
}
} else {
$note->error(array(t('MODULE_SETTINGS'), t('REQUIRED_FIELDS')));
}
$tpl = new PHPTAL('modules/guestbook/admin/settings.html');
$tpl->form = $form;
$tpl->note = $note;
$tpl->columns = Settings::formColumns();
$tpl->blocks = Settings::formBlocks();
echo $tpl->execute();
示例7: t
// modules/contact/admin/index.php
$kio->path['admin/modules/contact'] = t('Contact');
$note = new Notifier();
$err = new Error();
$save = $_POST['save'] ? true : false;
$blocks = Settings::getBlocks();
if ($save) {
$form = $_POST['form'];
$form['blocks'] = array_diff(array_keys($blocks), (array) $_POST['blocks']);
$err->receivers_empty($lang2['ERROR_RECEIVERS_EMPTY'], !$form['receivers']);
$err->receivers_invalid($lang2['ERROR_RECEIVERS_INVALID'], $form['receivers'] && !preg_match('#^\\d+(, *\\d)*$#', $form['receivers']));
if (!$err->count()) {
Settings::update('contact');
Cache::clear('contact.txt');
$info->positive(t('SAVED_SUCCESSFUL'));
redirect(HREF . 'admin/modules/contact');
} else {
$note->error($err);
}
} else {
$form = $cfg->contact;
$form['blocks'] = explode(', ', $cfg->contact['blocks']);
$note->info(array($lang_admin['MODULE_SETTINGS'], $lang_system['REQUIRED']));
}
$tpl = new PHPTAL('modules/contact/admin/settings.html');
$tpl->note = $note;
$tpl->form = $form;
$tpl->err = $err;
$tpl->columns = Settings::formColumns();
$tpl->blocks = Settings::formBlocks();
echo $tpl->execute();
示例8: getContent
function getContent()
{
global $cfg, $user, $sql, $plug;
$note = new Notifier();
$tpl = new PHPTAL('plugins/comments/comments.tpl.html');
$err = new Error();
$tpl->entries = '';
if ($this->total_comments != -1 && !Kio::getConfig('view_only_logged', 'comments')) {
if ($this->total_comments > 0) {
$tpl->backlink = $this->backlink;
$tpl->cfg = $cfg;
$tpl->user = $user;
$tpl->entries = $this->getEntries();
} else {
$note->info('There is no comments.');
}
if (!Kio::getConfig('add_only_logged', 'comments') || LOGGED) {
if ($this->edited) {
$form = array('id' => $this->edited['comment_id'], 'author' => $this->edited['comment_author'], 'author_id' => $this->edited['comment_author_id'], 'message' => $this->edited['comment_message']);
if (!$form['author']) {
$form['author'] = User::getNickname(BY_ID, $this->edited['comment_author_id']);
}
$this->edit_mode = true;
} else {
$form['author'] = User::$nickname;
}
$add = isset($_POST['add']) ? true : false;
$edit = isset($_POST['edit']) ? true : false;
// Add or delete
if (isset($_POST['add']) || $edit) {
$form['author'] = isset($_POST['add']) && LOGGED ? User::$nickname : filter($_POST['author'], 100);
$form['message'] = filter($_POST['message'], Kio::getConfig('message_max', 'comments'));
$err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
$err->setError('author_exists', t('Entered nickname is registered.'))->condition($add && !LOGGED && is_registered($form['author'], 'nickname'));
$err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
// No errors
if ($err->noErrors()) {
// Add
if (isset($_POST['add'])) {
$sql->exec('
INSERT INTO ' . DB_PREFIX . 'comments (
comment_owner, comment_owner_child_id, comment_author,
comment_author_id, comment_author_ip, comment_added,
comment_message, comment_backlink)
VALUES(
"' . u0 . '",
' . $this->connector_id . ',
"' . (!LOGGED || isset($_POST['edit']) ? $form['author'] : '') . '",
' . UID . ',
"' . IP . '",
' . TIMESTAMP . ',
"' . $form['message'] . '",
"' . $this->backlink . '")');
$last = $sql->lastInsertId();
$sql->exec('
UPDATE ' . DB_PREFIX . $this->owner . '
SET comments = (comments + 1)
WHERE id = ' . $this->connector_id);
setcookie(COOKIE . '-comments', 'true', TIMESTAMP + Kio::getConfig('flood_interval', 'comments') + 1, '/');
redirect(HREF . PATH . '#comment-' . $last);
} else {
if (isset($_POST['edit'])) {
if ($form['author_id'] = User::getId(BY_NICKNAME, $form['author'])) {
$form['author'] = '';
} else {
$form['author_id'] = 0;
}
$sql->exec('
UPDATE ' . DB_PREFIX . 'comments
SET
comment_author = "' . $form['author'] . '",
comment_author_id = ' . $form['author_id'] . ',
comment_message = "' . $form['message'] . '"
WHERE comment_id = ' . $this->edited['comment_id']);
redirect(HREF . $this->edited['comment_backlink'] . '#comment-' . $this->edited['comment_id']);
}
}
} else {
$note->error($err->toArray());
}
} else {
if (isset($_POST['delete_id']) && ctype_digit($_POST['delete_id'])) {
$sql->exec('
DELETE FROM ' . DB_PREFIX . 'comments WHERE comment_id = ' . $_POST['delete_id'] . ';
UPDATE ' . DB_PREFIX . $this->owner . ' SET comments = (comments - 1) WHERE id = ' . $this->connector_id);
redirect(strpos(REFERER, 'admin') ? REFERER : '#comments');
}
}
//$tpl->comments = $comments;
$tpl->form = $form;
$tpl->err = $err->toArray();
} else {
$note->error(sprintf('Dodawanie komentarzy jest możliwe tylko dla <a href="%1$slogin">zalogowanych</a> osób, <a href="%1$sregistration">zarejestruj się</a> jeśli nie masz jeszcze konta.', HREF));
}
} else {
if ($this->total_comments != -1) {
$note->error(array('Komentarze są widoczne tylko dla zalogowanych osób.', '<a href="' . HREF . 'registration">Zarejestruj się</a> jeśli nie masz jeszcze konta.'));
}
}
$tpl->edit_mode = $this->edit_mode;
//.........这里部分代码省略.........
示例9: getContent
public function getContent()
{
global $sql, $user, $cfg;
//Lang::load('blocks/shoutbox/lang.*.php');
$err = new Error();
$note = new Notifier('note-shoutbox');
$form = array();
$form['author'] = $user->nickname;
if ($_POST['reply-shoutbox']) {
$form['author'] = LOGGED ? $user->nickname : filter($_POST['author-shoutbox'], 100);
$form['message'] = filter($_POST['message-shoutbox'], $cfg->shoutbox['message_max']);
$err->author_empty(t('Field <strong>author</strong> can not be empty.'), !$form['author']);
$err->author_exists(t('Entered <strong>nickname</strong> is registered.'), !LOGGED && is_registered($form['author']));
$err->message_empty(t('Field <strong>message</strong> can not be empty.'), !$form['message']);
// No errors
if (!$err->count()) {
$sql->exec('
INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
VALUES (
' . TIMESTAMP . ',
"' . $form['author'] . '",
"' . cut($form['message'], $cfg->shoutbox['message_max']) . '",
' . $user->id . ',
"' . IP . '")', 'shoutbox.txt');
$note->success(t('Entry was added successfully.'));
redirect(HREF . PATH . '#shoutbox');
} else {
$note->error($err);
}
}
// If cache for shoutbox doesn't exists
if (!($entries = $sql->getCache('shoutbox'))) {
$query = $sql->query('
SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
FROM ' . DB_PREFIX . 'shoutbox s, ' . DB_PREFIX . 'users u
WHERE u.id = s.author_id
ORDER BY s.id DESC
LIMIT ' . $cfg->shoutbox['limit']);
while ($row = $query->fetch()) {
if ($row['author_id']) {
$row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
$row['message'] = parse($row['message'], $cfg->shoutbox['parser']);
}
$entries[] = $row;
}
$sql->putCacheContent('shoutbox', $entries);
}
try {
$tpl = new PHPTAL('blocks/shoutbox/sbox_overall.html');
$tpl->cfg = $cfg;
$tpl->entries = $entries;
$tpl->err = $err->toArray();
$tpl->form = $form;
$tpl->note = $note;
$tpl->user = $user;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e->getMessage());
//echo Note::error($e->getMessage());
}
}
示例10: getComposeForm
private function getComposeForm()
{
global $sql;
Kio::addTitle(t('Compose message'));
Kio::addBreadcrumb(t('Compose message'), 'pm/write');
$err = new Error();
$note = new Notifier();
if ((u2 == 'resend' || u2 == 'reply') && ctype_digit(u3)) {
if (u2 == 'reply') {
$message = $sql->query('
SELECT connector_id, subject
FROM ' . DB_PREFIX . 'pm
WHERE id = ' . u3 . ' AND folder != 1')->fetch(PDO::FETCH_ASSOC);
$form['subject'] = 'Re: ' . $message['subject'];
} else {
$message = $sql->query('
SELECT connector_id, subject, message
FROM ' . DB_PREFIX . 'pm
WHERE id = ' . (int) u3 . ' AND folder = 1')->fetch(PDO::FETCH_ASSOC);
$form['subject'] = $message['subject'];
$form['message'] = $message['message'];
}
$form['receiver'] = User::getNickname(BY_ID, $message['connector_id']);
} else {
if (ctype_digit(u2)) {
$form['receiver'] = User::getNickname(BY_ID, u2);
}
}
if (isset($_POST['send'])) {
// Form values
$form = array('receiver' => filter($_POST['receiver'], 100), 'subject' => filter($_POST['subject'], 100), 'save' => $_POST['save'], 'bbcode' => $_POST['bbcode'] ? BBCODE : 0, 'emoticons' => $_POST['emoticons'] ? EMOTICONS : 0, 'autolinks' => $_POST['autolinks'] ? AUTOLINKS : 0, 'message' => filter($_POST['message'], 250));
$err->setError('receiver_empty', t('ERROR_RECEIVER_EMPTY'))->condition(!$form['receiver']);
$err->setError('receiver_not_exists', t('ERROR_RECEIVER_NOT_EXISTS'))->condition($form['receiver'] && !User::getId(BY_NICKNAME, $form['receiver']));
$err->setError('subject_empty', t('ERROR_SUBJECT_EMPTY'))->condition(!$form['subject']);
$err->setError('message_empty', t('ERROR_MESSAGE_EMPTY'))->condition(!$form['message']);
// No errors
if ($err->noErrors()) {
$form['receiver'] = User::getId(BY_NICKNAME, $form['receiver']);
$form['message'] = cut($form['message'], Kio::getConfig('message_max', 'pm'));
$form['parsers'] = $form['bbcode'] . $form['autolinks'] . $form['emoticons'] . CENSURE . PRE;
$stmt = $sql->prepare('
INSERT INTO ' . DB_PREFIX . 'pm
(sent, owner_id, connector_id, subject, message, folder, is_read, parsers)
VALUES
(:sent, :owner_id, :connector_id, :subject, :message, :folder, :is_read, :parsers)' . ($form['save'] ? ', (:sent, :owner_id, :connector_id, :subject, :message, :folder, :is_read, :parsers)' : ''));
$stmt->execute(array('sent' => TIMESTAMP, 'owner_id' => $form['receiver'], 'connector_id' => UID, 'subject' => $form['subject'], 'message' => $form['message'], 'folder' => 0, 'is_read' => 0, 'parsers' => $form['parsers']));
setcookie(COOKIE . '-pm', 'true', TIMESTAMP + Kio::getConfig('flood_interval', 'pm') + 1, '/');
$note->success('Wiadomość została wysłana.');
redirect(HREF . 'pm/inbox');
} else {
$note->error($err->toArray());
}
} else {
$note->info(array(t('WELCOME_MESSAGE'), t('REQUIRED')));
}
try {
$tpl = new PHPTAL('modules/pm/write.tpl.html');
$tpl->err = $err->toArray();
$tpl->form = $form;
$tpl->note = $note;
return $tpl->execute();
} catch (Exception $e) {
return template_error($e);
}
}