public function actionRemove($params) { $view = $this->ajaxView('comment'); $view->state = 'failed'; if ($params['id']) { $comment = new Model_Comment($this->getStorage(), $params['id']); $this->canPerform($view->comment->getArticle(), 'edit'); if ($view instanceof View_Html) { $view->redir('Admin_Article', 'edit', array('id' => $comment->article)); } if ($comment->isLoaded()) { $view->state = 'removed'; $view->id = $comment->getId(); try { //$comment->remove(); Model_Trashcan::put($comment); } catch (Exception $e) { $view->state = 'failed'; $view->error = $e->getMessage(); } } else { $view->error = 'Comment not found.'; } } else { $view->error = 'Comment ID is not set.'; } return $view; }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { if (self::$_loaded) { return ''; } self::$_loaded = true; if (defined('COMMENTS_DISABLED') && COMMENTS_DISABLED) { return ''; } $data = $data->fork(); $urlmeta = Model_UrlMeta::GetUrl(); if (!$urlmeta->exists()) { return ''; } $commeta = Model_Comment_Meta::Get($urlmeta['id']); if (!$commeta->exists()) { $commeta['urlmetaid'] = $urlmeta['id']; $commeta->save(); } else { if ($commeta['closed']) { $pm->setVariable('comments_closed', true); } } $data->set('meta', $commeta); $comments = new Model_Comment(); $comments->where('urlmetaid = ?', $urlmeta['id']); if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) { $comments->where('approved = 1'); } $comments->order('datecreated ASC'); $data->set('comments', $comments); $data->set('comments_require_captcha', COMMENTS_REQUIRE_CAPTCHA); parent::output($data, $stream); }
public function action_delete() { $comment = new Model_Comment($this->request->param('id')); if (!$comment->loaded()) { $this->redirect('admin/404/'); } $image_id = $comment->discussion->image->id; $comment->delete(); $this->redirect('admin/images/detail/' . $image_id . '#discussion'); }
public function save(Model_Comment $comment) { if ($comment->id) { $where[] = 'id = ' . $comment->id; $this->_db->update('comments', $comment->toArray(), $where); } else { $this->_db->insert('comments', $comment->toArray()); $comment->id = $this->_db->lastInsertId(); } return $comment; }
public function action_addcomment() { if ($this->request->post()) { $factory_comment = new Model_Comment(); $reply_comment_id = NULL; if (isset($_GET["replyfor"])) { $reply_comment_id = $_GET["replyfor"]; } $new_comment = $factory_comment->create_new($this->request->post(), $this->image->discussion_id, $reply_comment_id); $this->redirect('/share/' . $this->project->share_hash . '/images/detail/' . $this->image->id . '#comment' . $new_comment->id); } }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); $comments = new Model_Comment(); if (defined('COMMENTS_REQUIRE_APPROVAL') && 1 == COMMENTS_REQUIRE_APPROVAL) { $comments->select()->where('approved = 1'); } $comments->order('datecreated DESC'); $comments->limit(10); $data->set('comments', $comments); parent::output($data, $stream); }
public function createAction() { $request = $this->getRequest(); $ad_id = $this->_request->getParam('ad_id'); //first we check if user is logged, if not redir to login $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { //keep this url in zend session to redir after login $aNamespace = new Zend_Session_Namespace('Nolotiro'); $aNamespace->redir = $this->lang . '/ad/' . $ad_id; $this->_redirect($this->lang . '/auth/login'); } else { $form = $this->_getCommentForm(); // check to see if this action has been POST'ed to if ($this->getRequest()->isPost()) { if ($form->isValid($request->getPost())) { $formulario = $form->getValues(); //if comment its empty dont do nothing as redir to same ad if (empty($formulario['body'])) { $this->_helper->_flashMessenger->addMessage($this->view->translate('Write something!')); $this->_redirect('/' . $this->lang . '/ad/' . $ad_id); } //strip html tags to body $formulario['body'] = strip_tags($formulario['body']); //anti hoygan to body $split = explode(". ", $formulario['body']); foreach ($split as $sentence) { $sentencegood = ucfirst(mb_convert_case($sentence, MB_CASE_LOWER, "UTF-8")); $formulario['body'] = str_replace($sentence, $sentencegood, $formulario['body']); } //get the ip of the ad publisher if (getenv(HTTP_X_FORWARDED_FOR)) { $ip = getenv(HTTP_X_FORWARDED_FOR); } else { $ip = getenv(REMOTE_ADDR); } $formulario['ip'] = $ip; $formulario['ads_id'] = $ad_id; //get this ad user owner $formulario['user_owner'] = $auth->getIdentity()->id; //get date created //TODO to use the Zend Date object to apapt the time to the locale user zone $datenow = date("Y-m-d H:i:s", time()); $formulario['date_created'] = $datenow; $modelC = new Model_Comment(); $modelC->save($formulario); $this->_helper->_flashMessenger->addMessage($this->view->translate('Comment published succesfully!')); $this->_redirect('/' . $this->lang . '/ad/' . $ad_id); } } } }
public function add_child(Model_Comment $child) { $children = (array) $this->get('children'); $orphans = (array) $this->get('orphans'); if ($child->get('parent') != $this->get_id()) { $orphans[$child->get_id()] = $child; } else { $children[$child->get_id()] = $child; } $this->search_parents($children, $orphans); $this->set('children', $children); $this->set('orphans', $orphans); }
public function action_detail($id = 0) { $data["forum"] = Model_Forum::find($id); if ($data["forum"] == null) { Response::redirect("/teachers/forum/"); } if (Input::get("del_id", null) != null) { $del_comment = Model_Comment::find(Input::get("del_id", 0)); if ($del_comment->user_id == $this->user->id) { $del_comment->deleted_at = time(); $del_comment->save(); } } // add if (Input::post("body", "") != "" and Security::check_token()) { // save $comment = Model_Comment::forge(); $comment->body = Input::post("body", ""); $comment->forum_id = $id; $comment->user_id = $this->user->id; $comment->save(); } $data["user"] = $this->user; $view = View::forge("teachers/forum/detail", $data); $this->template->content = $view; }
public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
public function action_pinlun() { $articleid = $this->params['id']; $typeid = $this->params['typeid']; $action = $this->params['action']; $page = $this->params['page']; $table_arr = array('1' => 'line', '2' => 'hotel', '3' => 'car', '5' => 'spot', '8' => 'visa', '13' => 'tuan'); $module = $table_arr[$typeid]; $row = ORM::factory($module)->where("id={$articleid}")->find()->as_array(); $row['score'] = Model_Comment::getScore($articleid, $typeid); $row['commentnum'] = Model_Comment::getPinLunCount($articleid, $typeid); $page = $page ? $page : 1; $pagesize = 10; $offset = ($page - 1) * $pagesize; $sql = "select * from sline_comment where articleid='{$articleid}' and typeid='{$typeid}' limit {$offset},{$pagesize}"; $pl = DB::query(1, $sql)->execute()->as_array(); foreach ($pl as $key => $v) { $score = $pl[$key]['score1'] * 20; $memberinfo = Common::getMemberInfo($v['memberid']); $pl[$key]['memberico'] = $memberinfo['litpic'] ? $memberinfo['litpic'] : Common::getDefaultImage(); $pl[$key]['membername'] = $memberinfo['nickname']; $pl[$key]['membercore'] = $score . '%'; } if ($action == 'ajax') { echo json_encode($pl); exit; } $this->assign('pinlunlist', $pl); $this->assign('info', $row); $this->assign('typeid', $typeid); $this->display('public/pinlun'); }
public function action_profile($server_id) { $server = $this->getServer($server_id); $view = View::factory('server/index'); if (isset($this->user)) { // Handle adding a bot $bot_name = Arr::get($_POST, 'bot', false); if ($bot_name !== false) { $bot = ORM::factory('bot'); $bot->uid = $this->user; $bot->sid = $server; $bot->name = $bot_name; $bot->online = 0; if ($bot->check()) { $bot->save(); } else { $view->set('errors', $bot->validate()->errors('bot_errors')); } } // Handle Comments if (isset($_POST['s'])) { $posted = Model_Comment::post('server', $server, $this->user, $_POST['text']); $view->bind('posted', $posted); } } $comments = Model_Comment::fetch('server', $server, $this->request->param('page', 1)); $this->request->response = $view->bind('server', $server)->bind('comments', $comments); }
public function action_index() { $action = $this->params['action']; if (empty($action)) { $this->display('stourtravel/comment/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $keyword = Arr::get($_GET, 'keyword'); $order = 'order by a.addtime desc'; $sql = "select a.* from sline_comment as a {$order} limit {$start},{$limit}"; //echo $sql; $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_comment a ")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['productname'] = ORM::factory('question')->getProductName($v['articleid'], $v['typeid']); $v['nickname'] = Model_Comment::getMemberName($v['memberid']); $v['modulename'] = Model_Comment::getPinlunModule($v['typeid']); $new_list[] = $v; } $result['total'] = $totalcount_arr[0]['num']; $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('comment', $id); $model->delete(); } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); if (is_numeric($id)) { $model = ORM::factory('comment', $id); } if ($model->id) { $model->{$field} = $val; $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } }
public function action_delete($id, $message_id) { if ($comment = Model_Comment::find($id)) { $comment->delete(); Session::set_flash('success', 'Deleted comment #' . $id); } else { Session::set_flash('error', 'Could not delete comment #' . $id); } Response::redirect('messages/view/' . $message_id); }
public function action_delete() { if (!$this->user->id) { $this->redirect('/'); } $comment_id = $this->request->param('comment_id'); $comment = Model_Comment::get($comment_id); $article_id = $comment->delete_comment($this->user); $this->redirect('/article/' . $article_id); }
public function action_delete($id = null) { if ($comment = Model_Comment::find($id)) { $comment->delete(); Session::set_flash('success', 'Deleted comment #' . $id); } else { Session::set_flash('error', 'Could not delete comment #' . $id); } Response::redirect('admin/comments'); }
public function action_profile($user_id) { $profile = $this->getUser($user_id); $view = View::factory('user/index')->bind('profile', $profile); if (isset($this->user) && isset($_POST['s'])) { $posted = Model_Comment::post('user', $profile, $this->user, $_POST['text']); $view->bind('posted', $posted); } $comments = Model_Comment::fetch('user', $profile, $this->request->param('page', 1)); $this->request->response = $view->bind('comments', $comments); }
public function action_view($id = null) { is_null($id) and Response::redirect('blog'); if (!($blog = Model_Blog::find($id))) { Session::set_flash('error', 'Could not find blog #' . $id); Response::redirect('blog'); } $comments = Model_Comment::find('all', array('where' => array('blog_id' => $id))); $data = array('blog' => $blog, 'comments' => $comments); $this->template->title = "Blog"; $this->template->content = View::forge('blog/view', $data); }
public function action_view($id = null) { is_null($id) and Response::redirect('messages'); if (!($message = Model_Message::find($id))) { Session::set_flash('error', 'Could not find message #' . $id); Response::redirect('messages'); } $comments = Model_Comment::find('all', array('where' => array('message_id' => $id))); $data = array('message' => $message, 'comments' => $comments); $this->template->title = "Message"; $this->template->content = View::forge('messages/view', $data); }
private function saveComment(View_Html $view) { if (in_array("comments", $view->article->flags) && $_POST['comment'] === 'save' && !$_POST['comment_url']) { $comment = new Model_Comment($this->getStorage()); $comment->username = nl2br(htmlspecialchars(strip_tags($_POST['comment_username']))); $comment->email = $_POST['comment_email']; $comment->title = nl2br(htmlspecialchars(strip_tags($_POST['comment_title']))); $comment->content = nl2br(htmlspecialchars(strip_tags($_POST['comment_content']))); $comment->article = $view->article->getId(); //$comment->owner = $view->article->owner; //$comment->group = $view->article->group; if (empty($comment->title)) { $comment->title = "Без темы"; } if (!($errors = $comment->validate())) { $comment->save(); $view->redir("Default", "article", array('path' => $view->topic->getPath(), 'article' => $view->article->getId())); return true; } $view->errors = $errors; $view->newComment = $comment; } return false; }
public function action_showArticle() { $articleId = $this->request->param('article_id'); $this->view["id"] = $articleId; $article = Model_Article::get($articleId); if ($article->id == 0) { throw new HTTP_Exception_404(); } $this->stats->hit(Model_Stats::ARTICLE, $articleId); $this->view["article"] = $article; $this->title = $article->title; $comments = Model_Comment::getCommentsByArticle($articleId); $comments_table_rebuild = $this->methods->rebuildCommentsTree($comments); $this->view["comments"] = $comments_table_rebuild; $this->template->content = View::factory('templates/articles/article', $this->view); }
/** * Заполняет текущий объект строкой из базы данных. * * @param $article_row array строка из базы данных с создаваемой статьёй * @return Model_Article модель, заполненная полями из статьи, либо пустая модель, если была передана пустая строка. */ private function fillByRow($article_row) { if (!empty($article_row['id'])) { $this->id = $article_row['id']; $this->title = $article_row['title']; $this->text = $article_row['text']; $this->description = $article_row['description']; $this->cover = $article_row['cover']; $this->user_id = $article_row['user_id']; $this->dt_create = $article_row['dt_create']; $this->dt_update = $article_row['dt_update']; $this->is_removed = $article_row['is_removed']; $this->is_published = $article_row['is_published']; $this->author = Model_User::get($this->user_id); $this->commentsCount = Model_Comment::countCommentsByArticle($this->id); } return $this; }
public function action_profile($bot_id) { $bot = $this->getBot($bot_id); $view = View::factory('bot/index')->bind('bot', $bot); if ('cu_bullshit' == $bot->server->name) { $stats = ORM::factory('bullshit')->reset(false)->bot($bot_id); $game_count = $stats->count_all(); $stats = $stats->order_by('DatePlayed', 'DESC')->limit(10)->find_all(); $view->bind('stats', $stats); $view->bind('game_count', $game_count); } if (isset($this->user) && isset($_POST['s'])) { $posted = Model_Comment::post('bot', $bot, $this->user, $_POST['text']); $view->bind('posted', $posted); } $comments = Model_Comment::fetch('bot', $bot, $this->request->param('page', 1)); $this->request->response = $view->bind('comments', $comments); }
public function action_create($id = null) { if (Fuel\Core\Input::post()) { $comment = Model_Comment::forge(array('name' => Fuel\Core\Input::post('comment'), 'comment' => Fuel\Core\Input::post('comment'), 'message_id' => Fuel\Core\Input::post('message_id'))); if ($comment and $comment->save()) { Fuel\Core\Session::set_flash('success', 'Added comment #' . $comment->id . '.'); Fuel\Core\Response::redirect('messages/view/' . $comment->message_id); } else { Fuel\Core\Session::set_flash('error', 'Could not save comment'); } } else { $this->template->set_global('message', $id, false); } $data["subnav"] = array('create' => 'active'); $this->template->title = 'Comments » Create'; $data['form'] = View::forge('comments/_form'); $this->template->content = View::forge('comments/create', $data); }
<?php /* TODO: Add code here */ require 'config/globalconfig.php'; include_once 'class/model_comment.php'; include_once 'class/model_commentbad.php'; include_once 'class/model_articletype.php'; include_once 'class/model_article.php'; include_once 'class/model_user.php'; $objComment = new Model_Comment($objConnection); $objCommentBad = new Model_CommentBad($objConnection); $objUser = new Model_User($objConnection); $objArticle = new Model_Article($objConnection); $objArticleType = new Model_ArticleType($objConnection); if ($_pgR["act"] == model_Article::ACT_ADD || $_pgR["act"] == model_Article::ACT_UPDATE) { if (global_common::isCLogin()) { //get user info $c_userInfo = $_SESSION[global_common::SES_C_USERINFO]; $articleid = $_pgR[global_mapping::ArticleID]; $content = html_entity_decode($_pgR[global_mapping::Content], ENT_COMPAT, 'UTF-8'); $createdby = $c_userInfo[global_mapping::UserID]; $status = 1; if ($_pgR["act"] == Model_Comment::ACT_ADD) { $createdBy = $c_userInfo[global_mapping::UserID]; $resultID = $objComment->insert($articleid, $content, $createdby, $status); //echo global_common::convertToXML($arrHeader, array("rs","info"), array(0,$resultID), array(0,1)); //return; if ($resultID) { $commentHTML = $objComment->getCommentHTMLByArticle($articleid); $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode
* This file was automatically generated By Code Smith * Modifications will be overwritten when code smith is run * * PLEASE DO NOT MAKE MODIFICATIONS TO THIS FILE * Date Created 5/6/2012 * */ /// <summary> /// Implementations of slcomments represent a Comment /// /// </summary> chdir(".."); /* TODO: Add code here */ require 'config/globalconfig.php'; include_once 'class/model_comment.php'; $objComment = new Model_Comment($objConnection); if ($_pgR["act"] == Model_Comment::ACT_ADD || Model_Comment::ACT_USER_COMMENT) { if (global_common::isCLogin() || true) { //get user info //$c_userInfo = $_SESSION[consts::SES_C_USERINFO]; //if ($objMenu->getMenuByName($_pgR['name'])) { // echo global_common::convertToXML($arrHeader, array("rs",'info'), array(0,global_common::STRING_NAME_EXIST), array(0,1)); // return; //} $commentID = $_pgR['CommentID']; $commentID = global_editor::rteSafe(html_entity_decode($commentID, ENT_COMPAT, 'UTF-8')); $commentType = $_pgR['CommentType']; $commentType = global_editor::rteSafe(html_entity_decode($commentType, ENT_COMPAT, 'UTF-8')); $articleID = $_pgR['ArticleID']; $articleID = global_editor::rteSafe(html_entity_decode($articleID, ENT_COMPAT, 'UTF-8')); $content = $_pgR['Content'];
Comment admin listing controller 24 march 2011: cleaned up 25 march 2011: rewrote to use DAO 29 march 2011: now using getTotal */ // TODO: Consider making a separate admin page for comment sections (i.e., each URL that has a comment plugin) // TODO: Do it by adding filters at the top //$comments = Comment::DAOFactory(); $comments = new Model_Comment(); if (defined('COMMENTS_REQUIRE_APPROVAL')) { $pm->setVariable('comments_require_approval', COMMENTS_REQUIRE_APPROVAL); if (COMMENTS_REQUIRE_APPROVAL) { $comments->where('approved = 0'); $pm->setVariable('totalpending', $comments->getTotal()); //$comments->resetSelect(); $comments = new Model_Comment(); } } if (isset($_REQUEST['show']) && 'unapproved' == $_REQUEST['show']) { $comments->where('approved = 0'); } if (isset($_REQUEST['application'])) { $comments->select()->where('#__page.application = ?', $_REQUEST['application']); } $total = $comments->getTotal(); $comments->order('datecreated DESC'); $comments->setPagination(isset($_REQUEST['page']) ? $_REQUEST['page'] : 1); $pm->setVariable('comments', $comments); $page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1; Pagination::Calculate($total, 20, $page);
public function blogAction() { $ispost = $this->_getParam('idpost', false); $this->view->pageTitle = $this->view->tr(NULL, $this->view->lang, 'Наш Блог'); if ($ispost) { $this->view->token = new Zend_Service_ReCaptcha($this->config->capcha->pub, $this->config->capcha->priv); if ($this->_request->isPost()) { $filter = new Zend_Filter(); $filter = $filter->addFilter(new Zend_Filter_StripTags())->addFilter(new Zend_Filter_HtmlEntities()); $name = $filter->filter($this->_getParam('name', '')); $email = $filter->filter($this->_getParam('email', '')); $message = $filter->filter($this->_getParam('message', '')); $token = $this->_getParam('token', ''); $data = array('name' => $name, 'email' => $email, 'message' => $message, 'idpage' => $ispost); $recaptcha_challenge_field = $this->_getParam('recaptcha_challenge_field', 'default'); $recaptcha_response_field = $this->_getParam('recaptcha_response_field', 'default'); $result = $this->view->token->verify($recaptcha_challenge_field, $recaptcha_response_field); //var_dump($recaptcha_challenge_field, $recaptcha_response_field); if ($result->isValid()) { Model_Comment::updatepage($data); // send mail try { $mail = new Zend_Mail($charset = 'utf-8'); $mail->addTo($this->view->config->resources->mail->admin); $mail->setFrom($this->view->config->resources->mail->sender); $text = $this->view->config->resources->mail->template; $text = "Був доданий коментар до сторінки " . $this->view->config->baseurl . $this->getRequest()->getRequestUri() . "\n"; $text .= "Дата: " . $this->view->localDate(time(), $this->view->lang) . "\n"; $text .= "Имя: {$name} \n"; $text .= "Email: {$email} \n"; $text .= "Текст: {$message} \n"; $mail->setSubject('Коментар на сайті Party Zone'); $mail->setBodyText($text); $t = $mail->send(); } catch (Zend_Mail_Exception $e) { echo json_encode(array('status' => 'error', 'msg' => $e->getMessages())); // exit; } $this->_redirect($this->getRequest()->getRequestUri()); } } $this->view->comments = Model_Comment::getAll($ispost, 'asc'); $this->view->post = Model_Blogentry::getById($ispost, $this->view->lang); if (is_object($this->view->post)) { $this->view->pageTitle = $this->view->post->title; $this->view->headMeta()->appendName('keywords', $this->view->post->keyword); $this->view->headMeta()->appendName('description', $this->view->post->description); } return $this->renderScript('/index/blogentry.phtml'); } $this->view->blogs = $this->setPaginator(Model_Blogentry::getBlogs($this->view->lang)); $this->view->blogmenu = Model_Menu::getById(16, $this->view->lang); }
public static function save($data = array()) { $comment = Model_Comment::forge($data); return $comment and $comment->save(); }
/** * Get blog comments * * @param Model_User $viewer * @return Database_Result */ public function comments(Model_User $viewer = null) { $query = Model_Comment::query_viewer(DB::select_array(Model_Blog_Comment::factory()->fields()), $viewer); return $this->find_related('blog_comments', $query); }