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; $tpl->total_comments = $this->total_comments; $tpl->note = $note; return $tpl->execute(); }
// 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();
private function getFolder($folder_id) { global $sql; Kio::addTitle(t(ucfirst(u1))); Kio::addBreadcrumb(t(ucfirst(u1)), 'pm/' . u1); $note = new Notifier(); $this->subcodename = 'box'; $pager = new Pager('pm/' . u1, User::${'pm' . ucfirst(u1)}, Kio::getConfig('limit', 'pm')); $pager->sort(array(t('Subject') => 'subject', t('Message') => 'message', u1 == 'outbox' ? t('To') : t('From') => 'nickname', t('Sent') => 'sent'), 'sent', 'asc'); // Reset new messages counter if (User::$pmNew) { $sql->exec('UPDATE ' . DB_PREFIX . 'users SET pm_new = 0 WHERE id = ' . UID); } if (isset($_POST['action']) && !empty($_POST['messages'])) { $action_messages = implode(', ', array_map('intval', $_POST['messages'])); switch ($_POST['action']) { // Mark messages as read case 'read': $sql->exec(' UPDATE ' . DB_PREFIX . 'pm SET is_read = 1 WHERE id IN(' . $action_messages . ') AND folder = ' . $folder_id . ' AND owner_id = ' . UID); break; // Mark messages as unread // Mark messages as unread case 'unread': $sql->exec(' UPDATE ' . DB_PREFIX . 'pm SET is_read = 0 WHERE id IN(' . $action_messages . ') AND folder = ' . $folder_id . ' AND owner_id = ' . UID); break; // Delete messages // Delete messages case 'delete': $sql->exec(' DELETE FROM ' . DB_PREFIX . 'pm WHERE id IN(' . $action_messages . ') AND folder = ' . $folder_id . ' AND owner_id = ' . UID); } redirect(HREF . PATH); } $stmt = $sql->query(' SELECT pm.*, u.nickname, u.group_id FROM ' . DB_PREFIX . 'pm pm LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = pm.connector_id WHERE pm.owner_id = ' . UID . ' AND pm.folder = ' . $folder_id . ' ORDER BY ' . $pager->orderBy . ' LIMIT ' . $pager->limit . ' OFFSET ' . $pager->offset); if ($stmt->rowCount()) { $messages = array(); while ($row = $stmt->fetch()) { if ($row['connector_id']) { $row['nickname'] = User::format($row['connector_id'], $row['nickname'], $row['group_id']); } $messages[] = $row; } try { $tpl = new PHPTAL('modules/pm/pm.tpl.html'); $tpl->messages = $messages; $tpl->sort = $pager->sorters; $tpl->total = User::${'pm' . ucfirst(u1)}; $tpl->max = Kio::getConfig(u1 . '_max', 'pm'); $tpl->note = $note; $tpl->pager = $pager; $tpl->pagination = $pager->getLinks(); return $tpl->execute(); } catch (Exception $e) { return template_error($e); } } else { return $note->info(t('There is no messages in the box.')); } }