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 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 usersNotify() { $postID = $this->registry->postID; $lastCommentID = $this->registry->lastCommentID; $Comment = new comment(); $comment = $Comment->find($lastCommentID); $Post = new post(); $post = $Post->find($postID); if ($comment['status'] != 'publish') { return; } $Comment = new comment(); $usersToNotify = $Comment->findAll("email,author,created,ID,content", "ID DESC", null, "WHERE suscribe = 1 AND NOT user_id = 1 AND status = 'publish' AND id_post = {$postID} GROUP BY email"); if (!$usersToNotify) { return; } $mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\tHay un nuevo comentario en la entrada \"<a href=\"{$this->registry->path}{$post['urlfriendly']}#comments\">{$post['title']}</a>\".<br />\n\t\t\t\t\t<small><a href=\"{$this->registry->path}{$post['urlfriendly']}#comments\">{$this->registry->path}{$post['urlfriendly']}</a></small><br /><br />\n\t\t\t\t\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t\t<strong>Comentario</strong>: <br />\n\t\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tLee aquí todos los comentarios de esta entrada:<br />\n\t\t\t\t\t\t<a href=\"{$this->registry->path}{$post['urlfriendly']}#comments\">{$this->registry->path}{$post['urlfriendly']}</a><br />\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t"; $conf = $this->registry->conf; $subject = "[{$conf['blog_name']}] haz recibido respueta a tu comentario en: {$post['title']}"; $suscribers = array(); foreach ($usersToNotify as $mail) { $this->enviaMail($mail['email'], $subject, $mailStr, null); } }