Inheritance: extends Basecomment
Example #1
0
 /**
  * Return a list of comments
  *
  * @param string $contextlevel ('system, course, user', etc..)
  * @param int $instanceid
  * @param string $component the name of the component
  * @param int $itemid the item id
  * @param string $area comment area
  * @param int $page page number
  * @return array of comments and warnings
  * @since Moodle 2.9
  */
 public static function get_comments($contextlevel, $instanceid, $component, $itemid, $area = '', $page = 0)
 {
     $warnings = array();
     $arrayparams = array('contextlevel' => $contextlevel, 'instanceid' => $instanceid, 'component' => $component, 'itemid' => $itemid, 'area' => $area, 'page' => $page);
     $params = self::validate_parameters(self::get_comments_parameters(), $arrayparams);
     $context = self::get_context_from_params($params);
     self::validate_context($context);
     require_capability('moodle/comment:view', $context);
     $args = new stdClass();
     $args->context = $context;
     $args->area = $params['area'];
     $args->itemid = $params['itemid'];
     $args->component = $params['component'];
     $commentobject = new comment($args);
     $comments = $commentobject->get_comments($params['page']);
     // False means no permissions to see comments.
     if ($comments === false) {
         throw new moodle_exception('nopermissions', 'error', '', 'view comments');
     }
     foreach ($comments as $key => $comment) {
         list($comments[$key]->content, $comments[$key]->format) = external_format_text($comment->content, $comment->format, $context->id, $params['component'], '', 0);
     }
     $results = array('comments' => $comments, 'warnings' => $warnings);
     return $results;
 }
Example #2
0
function module_comment_edit()
{
    global $global, $smarty;
    $obj = new comment();
    $obj->set_where('com_id = ' . $global['id']);
    $one = $obj->get_one();
    $one['channel'] = '';
    $one['title'] = '';
    $obj = new channel();
    $list = $obj->get_list();
    for ($i = 0; $i < count($list); $i++) {
        if ($list[$i]['cha_id'] == $one['com_channel_id']) {
            $one['channel'] = $list[$i]['cha_code'];
            $original = $list[$i]['cha_code'];
            if ($list[$i]['cha_original'] != 0) {
                for ($j = 0; $j < count($list); $j++) {
                    if ($list[$i]['cha_original'] == $list[$j]['cha_id']) {
                        $original = $list[$j]['cha_code'];
                    }
                }
            }
            if ($original == 'goods') {
                $table = 'goods';
            } else {
                $table = 'article';
            }
            $one['title'] = get_data($table, $one['com_page_id'], substr($table, 0, 3) . '_title');
        }
    }
    $smarty->assign('comment', $one);
}
Example #3
0
 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($this->instance)) {
         return null;
     }
     $this->content->footer = '';
     $this->content->text = '';
     if (isloggedin() && !isguestuser()) {
         // Show the block
         $cmt = new stdclass();
         $cmt->context = $this->instance->context;
         $cmt->area = 'block_comments';
         $cmt->itemid = $this->instance->id;
         $cmt->course = $this->page->course;
         // this is a hack to adjust commenting UI
         // in block_comments
         $cmt->env = 'block_comments';
         $cmt->linktext = get_string('showcomments');
         $comment = new comment($cmt);
         $this->content = new stdClass();
         $this->content->text = $comment->init(true);
         $this->content->footer = '';
     }
     return $this->content;
 }
Example #4
0
function module_comment_sheet()
{
    global $global, $smarty;
    $obj = new comment();
    $obj->set_page_size(10);
    $obj->set_page_num($global['page']);
    $sheet = $obj->get_sheet();
    set_link($obj->get_page_sum());
    for ($i = 0; $i < count($sheet); $i++) {
        $sheet[$i]['channel'] = '';
        $sheet[$i]['title'] = '';
        $obj = new channel();
        $list = $obj->get_list();
        for ($j = 0; $j < count($list); $j++) {
            if ($list[$j]['cha_id'] == $sheet[$i]['com_channel_id']) {
                $sheet[$i]['channel'] = $list[$j]['cha_code'];
                $original = $list[$j]['cha_code'];
                if ($list[$j]['cha_original'] != 0) {
                    for ($k = 0; $k < count($list); $k++) {
                        if ($list[$j]['cha_original'] == $list[$k]['cha_id']) {
                            $original = $list[$k]['cha_code'];
                        }
                    }
                }
                if ($original == 'goods') {
                    $table = 'goods';
                } else {
                    $table = 'article';
                }
                $sheet[$i]['title'] = get_data($table, $sheet[$i]['com_page_id'], substr($table, 0, 3) . '_title');
            }
        }
    }
    $smarty->assign('comment', $sheet);
}
Example #5
0
 function get_content()
 {
     global $CFG, $PAGE;
     if (!$CFG->usecomments) {
         $this->content->text = '';
         if ($this->page->user_is_editing()) {
             $this->content->text = get_string('disabledcomments');
         }
         return $this->content;
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($this->instance)) {
         return null;
     }
     $this->content->footer = '';
     $this->content->text = '';
     list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
     $args = new stdClass();
     $args->context = $PAGE->context;
     $args->course = $course;
     $args->area = 'page_comments';
     $args->itemid = 0;
     // set 'env' to tell moodle tweak ui for this block
     $args->env = 'block_comments';
     $args->component = 'block_comments';
     $args->linktext = get_string('showcomments');
     $comment = new comment($args);
     $comment->set_view_permission(true);
     $this->content = new stdClass();
     $this->content->text = $comment->output(true);
     $this->content->footer = '';
     return $this->content;
 }
 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']);
 }
Example #7
0
 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;
 }
Example #8
0
 public function addAction()
 {
     if (user::isGuest() && reg::getKey('/comments/only_reg')) {
         system::stop();
     }
     if (user::isGuest() && !system::validCapcha('random_image')) {
         system::json(array('error' => 1, 'data' => lang::get('FEEDBACK_ERROR1')));
     }
     // Добавляем новый комментарий
     $comment = new comment();
     $comment->setParentId(system::POST('parent_id'));
     $comment->setObjId(system::POST('obj_id'));
     $comment->setUserName(system::POST('username'));
     $comment->setEmail(system::POST('email'));
     $comment->setText(system::POST('text'));
     $comment->setSendEmail(system::POST('send_email'));
     $obj_id = $comment->save();
     if ($obj_id) {
         page::assign('current_url', system::POST('back_url'));
         $html = page::macros('comments')->view($comment->id());
         system::json(array('error' => 0, 'data' => $html));
     } else {
         system::json(array('error' => 2, 'data' => $comment->getErrorListText(' ')));
     }
     if (!empty($_POST['back_url']) && !system::isAjax()) {
         system::redirect($_POST['back_url'] . '#comment' . $obj_id, true);
     } else {
         system::stop();
     }
 }
 function comment_js_action() {
     front::check_type(front::get('aid'));
     $comment=new comment();
     $this->view->comments=$comment->getrows('state=1 and aid='.front::get('aid'),20,'1');
     $this->view->aid=front::get('aid');
     echo  tool::text_javascript($this->fetch());
     exit;
 }
Example #10
0
 public function index($id = NULL, $page = 1)
 {
     if (is_null($id) or is_numeric($id)) {
         $this->redirect($this->conf['blog_siteurl']);
     }
     $tag = $id;
     $post = new post();
     $link = new link();
     $comment = new comment();
     $this->html->useTheme($this->conf['blog_current_theme']);
     $info = array();
     $info["isAdmin"] = false;
     if ($this->cookie->check("logged") and $this->cookie->id_user == 1) {
         $info["isAdmin"] = true;
     }
     $this->themes->info = $info;
     $includes['charset'] = $this->html->charsetTag("UTF-8");
     $includes['rssFeed'] = $this->html->includeRSS();
     if ($page > 1) {
         $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />";
     } else {
         $includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />";
     }
     $this->registry->includes = $includes;
     $this->plugin->call('index_includes');
     $includes = null;
     foreach ($this->registry->includes as $include) {
         $includes .= $include;
     }
     $this->themes->includes = $includes;
     $this->themes->links = $link->findAll();
     $this->themes->single = false;
     $total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag));
     $page = (int) is_null($page) ? 1 : $page;
     $limit = $this->conf['blog_posts_per_page'];
     $offset = ($page - 1) * $limit;
     $limitQuery = $offset . "," . $limit;
     $targetpage = $this->path . "tag/{$tag}/";
     $this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
     $posts = $post->getPostsByTag($tag, $limitQuery);
     foreach ($posts as $k => $p) {
         $posts[$k]['title'] = htmlspecialchars($p['title']);
         $posts[$k]['tags'] = $post->getTags($p['ID']);
         $posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']);
         $user = new user();
         if ($posts[$k]['id_user'] < 2) {
             $posts[$k]['autor'] = $user->find(1);
         } else {
             $posts[$k]['autor'] = $user->find($posts[$k]['id_user']);
         }
     }
     $this->registry->posts = $posts;
     $this->plugin->call("index_post_content");
     $this->themes->posts = $this->registry->posts;
     $this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}";
     $this->render();
 }
 public function show($id)
 {
     $articles = new Article();
     $comment = new comment();
     $article = $articles->where('article_id=' . $id)->find();
     $comments = $comment->where('article_id=' . $id)->order('created_at')->select();
     //$comments = $articles->relation(true)->find($id);
     $this->assign('article', $article);
     $this->assign('comments', $comments);
     $this->display('showArticle');
 }
Example #12
0
function reply_comment()
{
    global $smarty, $lang;
    $com_id = post('com_id');
    $com_reply = post('com_reply');
    $obj = new comment();
    $obj->set_value('com_reply', $com_reply);
    $obj->set_where("com_id = {$com_id}");
    $obj->edit();
    $smarty->assign('info_text', '回复评论成功');
    $smarty->assign('link_text', $lang['return_list']);
    $smarty->assign('link_href', url(array('channel' => 'service', 'mod' => 'comment_sheet')));
}
 /**
  * Add a new comment to the collection.
  * @see REST_Controller::_create($resource)
  */
 public function _create($comment)
 {
     $item = ORM::factory("item", $this->input->post("item_id"));
     access::required("view", $item);
     $form = comment_3nids::get_add_form($item);
     $valid = $form->validate();
     if ($valid) {
         if (user::active()->guest && !$form->add_comment->inputs["name"]->value) {
             $form->add_comment->inputs["name"]->add_error("missing", 1);
             $valid = false;
         }
         if (!$form->add_comment->text->value) {
             $form->add_comment->text->add_error("missing", 1);
             $valid = false;
         }
     }
     if ($valid) {
         $comment = comment::create($item, user::active(), $form->add_comment->text->value, $form->add_comment->inputs["name"]->value, $form->add_comment->email->value, $form->add_comment->url->value);
         $active = user::active();
         if ($active->guest) {
             $form->add_comment->inputs["name"]->value("");
             $form->add_comment->email->value("");
             $form->add_comment->url->value("");
         } else {
             $form->add_comment->inputs["name"]->value($active->full_name);
             $form->add_comment->email->value($active->email);
             $form->add_comment->url->value($active->url);
         }
     }
     url::redirect(url::site("comments_3nids?item_id=" . $item->id));
 }
Example #14
0
 public function displayComments($resource_id, $instance)
 {
     //instance ce u stvari biti ovo gde dodamo (add_instance), na stranici kursa
     //Mozda prvo da se izlistaju svi resursi pa da se omoguce komentari
     comment::init();
     $options = new stdClass();
     $options->area = 'resource_comments';
     $options->course = $course;
     $options->context = $context;
     $options->itemid = $itemid;
     $options->component = 'component_1';
     $options->showcount = true;
     $options->displaycancel = true;
     $comment = new comment($options);
     $comment->set_view_permission(true);
 }
Example #15
0
 public function create_comment_for_user_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $admin = user::lookup(2);
     $comment = comment::create($root, $admin, "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $this->assert_equal($admin->full_name, $comment->author_name());
     $this->assert_equal($admin->email, $comment->author_email());
     $this->assert_equal($admin->url, $comment->author_url());
     $this->assert_equal("text_{$rand}", $comment->text);
     $this->assert_equal(1, $comment->item_id);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("HTTP_ACCEPT", $comment->server_http_accept);
     $this->assert_equal("HTTP_ACCEPT_CHARSET", $comment->server_http_accept_charset);
     $this->assert_equal("HTTP_ACCEPT_ENCODING", $comment->server_http_accept_encoding);
     $this->assert_equal("HTTP_ACCEPT_LANGUAGE", $comment->server_http_accept_language);
     $this->assert_equal("HTTP_CONNECTION", $comment->server_http_connection);
     $this->assert_equal("HTTP_HOST", $comment->server_http_host);
     $this->assert_equal("HTTP_REFERER", $comment->server_http_referer);
     $this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
     $this->assert_equal("QUERY_STRING", $comment->server_query_string);
     $this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
     $this->assert_equal("REMOTE_HOST", $comment->server_remote_host);
     $this->assert_equal("REMOTE_PORT", $comment->server_remote_port);
     $this->assert_true(!empty($comment->created));
 }
Example #16
0
 /**
  * Delete a field completely
  */
 public function delete()
 {
     // Delete the comments.
     $params = array('contextid' => $this->df->context->id, 'commentarea' => $this->name);
     comment::delete_comments($params);
     return parent::delete();
 }
Example #17
0
 public function commentAction()
 {
     if ($_POST) {
         $content = $_POST['content'];
         $uid = $_POST['UID'];
         $aid = $_POST['AID'];
         $rid = $_POST['RID'];
         $abstract = substr($content, 0, 100);
         $time = date('Y-m-d H:i:s');
         $comment = new comment();
         $comment_arr = array('UID' => $uid, 'RID' => $rid, 'AID' => $aid, 'Time' => $time, 'Ccontent' => $content, 'Cabstract' => $abstract);
         $cid = $comment->insertComment($comment_arr);
         //$this->view->cid = $cid;
         echo $cid;
         //$this->render('commented');
     }
 }
Example #18
0
 /**
  * Present a form for adding a new comment to this item or editing an existing comment.
  */
 public function form_add($item_id)
 {
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     if (!comment::can_comment()) {
         access::forbidden();
     }
     print comment::prefill_add_form(comment::get_add_form($item));
 }
Example #19
0
 public function deleting_an_item_deletes_its_comments_too_test()
 {
     $rand = rand();
     $album = album::create(ORM::factory("item", 1), "test_{$rand}", "test_{$rand}");
     $comment = comment::create($album, identity::guest(), "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $album->delete();
     $deleted_comment = ORM::factory("comment", $comment->id);
     $this->assert_false($deleted_comment->loaded);
 }
Example #20
0
 static function photo_bottom($theme)
 {
     $block = new Block();
     $block->css_id = "gComments";
     $block->title = t("Comments");
     $view = new View("comments.html");
     $view->comments = ORM::factory("comment")->where("item_id", $theme->item()->id)->where("state", "published")->orderby("created", "ASC")->find_all();
     $block->content = $view;
     $block->content .= comment::get_add_form($theme->item())->render("form.html");
     return $block;
 }
Example #21
0
 function delete()
 {
     // delete all contacts and comments linked with this client as well
     $db = new db_alloc();
     $query = prepare("SELECT * FROM clientContact WHERE clientID=%d", $this->get_id());
     $db->query($query);
     while ($db->next_record()) {
         $clientContact = new clientContact();
         $clientContact->read_db_record($db);
         $clientContact->delete();
     }
     $query = prepare("SELECT * FROM comment WHERE commentType = 'client' and commentLinkID=%d", $this->get_id());
     $db->query($query);
     while ($db->next_record()) {
         $comment = new comment();
         $comment->read_db_record($db);
         $comment->delete();
     }
     return parent::delete();
 }
Example #22
0
 /**
  * @Route("/account")
  * @Route("/account/{action}/{id}")
  */
 public function accountAction(Request $request, $action = 'get_app', $id = '1')
 {
     if (!$this->session->get('username')) {
         return $this->redirectToRoute('app_dashboard_dashboard');
     }
     $repository = $this->getDoctrine()->getRepository('AppBundle:Comment');
     $query = $repository->createQueryBuilder('t')->orderBy('t.id', 'DESC')->setMaxResults(5)->getQuery();
     $result = $query->getResult();
     $comment_data = $result;
     if ($this->session->get("fb_login") == true) {
         $fb_bool = true;
     } else {
         $fb_bool = "";
     }
     if ($this->session->get("fb_realm_name")) {
         $fb_name = $this->session->get("fb_realm_name");
     } else {
         $fb_name = $this->session->get("email");
     }
     if ($request->getMethod() == 'POST' && $request->get('comment_submit')) {
         $comment = new comment();
         $comment->setTitle($request->request->get('title_comment'));
         $comment->setBody($request->request->get('comment'));
         $comment->setCreated(time());
         $comment->setDisplay(1);
         $comment->setLastEdited(1);
         $comment->setOwner(1);
         $em = $this->getDoctrine()->getManager();
         $em->persist($comment);
         $em->flush();
         return $this->redirectToRoute('app_dashboard_account');
     }
     $no_comments = $this->CheckCommentsExist();
     if (strpos($this->session->get("avatar_src"), 'data:image/') !== false) {
         $avatar_data_img = $this->session->get("avatar_src");
     } else {
         $avatar_data_img = "";
     }
     if (isset($action) && isset($id)) {
         //action=get_app&id=' . $id
         $app_info = file_get_contents('http://localhost/hello/itsme.php');
         $app_info = json_decode($app_info, true);
         $html = $this->container->get('templating')->render('dashboard/account.html.twig', array('username' => $this->session->get("username"), 'user_id' => $this->session->get("user_id"), 'avatar_src' => $this->session->get("avatar_src"), 'avatar_data_img' => $avatar_data_img, 'email' => $this->session->get("email"), 'created' => $this->session->get("created"), 'fb_bool' => $fb_bool, 'fb_real_name' => $fb_name, 'comment_data' => $comment_data, 'comment_exist' => $no_comments, 'tag_title' => $app_info['title'], 'tag_body' => $app_info['body'], 'tag_created_by' => $app_info['created_by']));
         return new Response($html);
     } else {
         $html = $this->container->get('templating')->render('dashboard/account.html.twig', array('username' => $this->session->get("username"), 'user_id' => $this->session->get("user_id"), 'avatar_src' => $this->session->get("avatar_src"), 'email' => $this->session->get("email"), 'created' => $this->session->get("created"), 'fb_bool' => $fb_bool, 'fb_real_name' => $fb_name, 'avatar_data_img' => $avatar_data_img, 'comment_data' => $comment_data, 'comment_exist' => $no_comments));
         return new Response($html);
     }
 }
Example #23
0
 /**
  * Render comment list.
  *
  * @return  string
  */
 public function comments()
 {
     $html = '';
     $comments = comment::findByPage($this->page)->page(1, 10);
     if ($comments->count() > 0) {
         $html .= '<div class="items comments">';
         foreach ($comments as $comment) {
             $html .= tpl::load(__DIR__ . DS . 'template.php', array('field' => $this, 'comment' => $comment));
         }
         $html .= '</div>';
     }
     return $html;
 }
Example #24
0
 function get_content()
 {
     global $CFG, $PAGE;
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (!$CFG->usecomments) {
         $this->content = new stdClass();
         $this->content->text = '';
         if ($this->page->user_is_editing()) {
             $this->content->text = get_string('disabledcomments');
         }
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (empty($this->instance)) {
         return $this->content;
     }
     list($context, $course, $cm) = get_context_info_array($PAGE->context->id);
     $args = new stdClass();
     $args->context = $PAGE->context;
     $args->course = $course;
     $args->area = 'page_comments';
     $args->itemid = 0;
     $args->component = 'block_comments';
     $args->linktext = get_string('showcomments');
     $args->notoggle = true;
     $args->autostart = true;
     $args->displaycancel = false;
     $comment = new comment($args);
     $comment->set_view_permission(true);
     $comment->set_fullwidth();
     $this->content = new stdClass();
     $this->content->text = $comment->output(true);
     $this->content->footer = '';
     return $this->content;
 }
Example #25
0
 public function getPost($urlfriendly, $status = null)
 {
     $urlfriendy = rawurlencode($this->sql_escape($urlfriendly));
     $post = array();
     if (is_null($status) === true) {
         $post = $this->findBy('urlfriendly', $urlfriendly);
     } else {
         $post = $this->findBy(array('urlfriendly', 'status'), array($urlfriendly, $status));
     }
     if ($this->isNew() === false) {
         if ($post['title']) {
             $post['title'] = htmlspecialchars($post['title']);
         } else {
             $post['title'] = "Untitled";
         }
         $post['tags'] = $this->getTags($post['ID']);
         $C = new comment();
         $post["comments_count"] = $C->countCommentsByPost($post['ID'], "publish");
         $post["comments"] = $C->getAll($post['ID'], "publish");
     }
     return $post;
 }
Example #26
0
 public function cant_view_comments_for_unviewable_items_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $comment = comment::create($album, user::guest(), "text", "name", "email", "url");
     user::set_active(user::guest());
     // We can see the comment when permissions are granted on the album
     access::allow(group::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
     // We can't see the comment when permissions are denied on the album
     access::deny(group::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
 }
Example #27
0
 public function setup()
 {
     Input::instance()->ip_address = "1.1.1.1";
     Kohana::$user_agent = "Akismet_Helper_Test";
     $root = ORM::factory("item", 1);
     $this->_comment = comment::create($root, user::guest(), "This is a comment", "John Doe", "*****@*****.**", "http://gallery2.org");
     foreach ($this->_comment->list_fields("comments") as $name => $field) {
         if (strpos($name, "server_") === 0) {
             $this->_comment->{$name} = substr($name, strlen("server_"));
         }
     }
     $this->_comment->save();
     module::set_var("akismet", "api_key", "TEST_KEY");
 }
Example #28
0
 public static function checkOldComments($postId)
 {
     $commentNum = comment::commentNum($postId);
     if ($commentNum > 10) {
         if ($commentNum - 10 == 1) {
             $prefix = '';
         } else {
             $prefix = 's';
         }
         return '<li class="comment"><a href="javascript:void(0)" id="seeOlder" data-postId="' . $postId . '" data-lastComment="' . ($commentNum - 10) . '">See ' . ($commentNum - 10) . ' More Comment' . $prefix . '</a> <span class="loading"><span></span></span> <span class="numComment">Total ' . $commentNum . ' comments</span><div class="cleaner"></div></li>';
     } else {
         return '';
     }
 }
Example #29
0
function admin_purge_related($table, $id)
{
    $ns = e107::getRender();
    $tp = e107::getParser();
    $msg = "";
    $tp->parseTemplate("");
    // Delete any related comments
    require_once e_HANDLER . "comment_class.php";
    $_com = new comment();
    $num = $_com->delete_comments($table, $id);
    if ($num) {
        $msg .= $num . " " . LAN_COMMENTS . " " . LAN_DELETED . "<br />";
    }
    // Delete any related ratings
    require_once e_HANDLER . "rate_class.php";
    $_rate = new rater();
    $num = $_rate->delete_ratings($table, $id);
    if ($num) {
        $msg .= LAN_RATING . " " . LAN_DELETED . "<br />";
    }
    if ($msg) {
        $ns->tablerender(LAN_DELETE, $msg);
    }
}
Example #30
0
function module_comment()
{
    global $global, $smarty;
    if ($global['id']) {
        $obj = new comment();
        $obj->set_where('com_channel_id = ' . get_id('channel', 'cha_code', $global['channel']));
        $obj->set_where('com_page_id = ' . $global['id']);
        $obj->set_page_size(5);
        $obj->set_page_num($global['page']);
        $sheet = $obj->get_sheet();
        set_link($obj->get_page_sum());
        $smarty->assign('comment', $sheet);
    }
}