public function index($id = NULL) { $this->view->setLayout("admin"); $this->view->conf = $this->conf; $this->title_for_layout($this->l10n->__("Comentarios - Codice CMS")); $comment = new comment(); $total_rows = $comment->countCommentsByPost(); $page = $id; $page = is_null($page) ? 1 : $page; $limit = $this->userConf['posts_per_page']; $offset = ($page - 1) * $limit; $limitQuery = $offset . "," . $limit; $targetpage = $this->path . 'comments/'; $pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage); $this->view->pagination = $pagination; $comments = $comment->findAll(NULL, "ID DESC", $limitQuery, NULL); foreach ($comments as $key => $value) { $Post = new post(); $post = $Post->findBy('ID', $value['ID_post']); $value['post'] = array('urlfriendly' => $post['urlfriendly'], 'title' => $post['title']); $value["content"] = utils::htmlentities($value["content"]); $value["content"] = utils::nl2br($value["content"]); $comments[$key] = $value; } $this->registry->comments = $comments; $this->plugin->call("comments_comment_content"); $this->view->comments = $this->registry->comments; $this->render(); }
public function getAll($ID_post, $status = null) { $C = new comment(); $rows = array(); if (is_null($status) === true) { $rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post}"); } else { if (is_array($status)) { $status_sql = ""; foreach ($status as $st) { $status_sql .= "status = '{$st}' OR "; } $status_sql = substr($status_sql, 0, -4); $rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post} AND ({$status_sql})"); } else { $rows = $C->findAll('comments.*, md5(comments.email) as md5_email', 'created ASC', null, "WHERE ID_post={$ID_post} AND status='{$status}'"); } } foreach ($rows as $key => $comment) { $comment['content'] = utils::htmlentities($comment['content']); $comment['content'] = utils::nl2br($comment['content']); $rows[$key] = $comment; } return $rows; }
public function adminNotify() { if ($this->cookie->check("id_user") and $this->cookie->id_user == 1) { //no notificamos a administrador de su propio comentario. return; } $id = $this->registry->lastCommentID; $Comment = new comment(); $comment = $Comment->find($id); $comment['content'] = utils::nl2br($comment['content']); if (!defined('GESHI_VERSION')) { $comment['content'] = $this->comment_source_code_beautifier($comment['content'], 'addTagPRE'); } else { $comment['content'] = $this->comment_source_code_beautifier($comment['content']); } $User = new user(); $user = $User->find(1); $Post = new post(); $post = $Post->find($comment['ID_post']); $commentsWaiting = $Comment->countCommentsByPost(null, 'waiting'); $mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<small>\n\t\t\t\t\t\t<strong>From IP</strong>: {$comment['IP']}<br />\n\t\t\t\t\t\t<strong>URL</strong>: <a href=\"{$comment['url']}\">{$comment['url']}</a><br />\n\t\t\t\t\t\t<strong>Email</strong>: <a href=\"mailto:{$comment['email']}\">{$comment['email']}</a><br />\n\t\t\t\t\t\t<strong>DateTime</strong>: {$comment['created']}<br />\n\t\t\t\t\t</small>\n\t\t\t\t\t<hr>\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr><td><strong>Content</strong></td></tr>\n\t\t\t<tr><td bgcolor=\"#f7f7f7\">\n\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tModerate comment: <a href=\"{$this->registry->path}comments/edit/{$comment['ID']}\">{$this->registry->path}comments/edit/{$comment['ID']}</a><br />\n\t\t\t\t\t\tView entry: <a href=\"{$this->registry->path}{$post['urlfriendly']}\">{$this->registry->path}{$post['urlfriendly']}</a>\n\t\t\t\t\t</p>\n\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThere are {$commentsWaiting} comments waiting for approbal. <br />\n\t\t\t\t\t\tPlease moderate comments: <a href=\"{$this->registry->path}comments/waiting\">{$this->registry->path}comments</a>\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t</table>\n\t\t"; $conf = $this->registry->conf; $subject = "[{$conf['blog_name']}] Nuevo Comentario en: {$post['title']}"; $this->enviaMail($user['email'], $subject, $mailStr, $user['email']); }