public function articleAction() { if ($this->_getParam('id', false)) { $news = new News(); $this->view->news = $news->getStory($this->_getParam('id')); $comments = new Comments(); $this->view->comments = $comments->getCommentsNews($this->_getParam('id')); $form = new CommentFindForm(); $form->submit->setLabel('Add a new comment'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $data = array(); $data['comment_findID'] = $this->_getParam('id'); $data['user_ip'] = $form->getValue('comment_author_IP'); $data['user_agent'] = $form->getValue('comment_agent'); $data['comment_type'] = 'newscomment'; $data['comment_author'] = $form->getValue('comment_author'); $data['comment_author_email'] = $form->getValue('comment_author_email'); $data['comment_content'] = $form->getValue('comment_content'); $data['comment_date'] = $this->getTimeForForms(); $data['user_id'] = $this->getIdentityForForms(); $config = Zend_Registry::get('config'); $akismetkey = $config->webservice->akismetkey; $akismet = new Zend_Service_Akismet($akismetkey, 'http://www.finds.org.uk'); if ($akismet->isSpam($data)) { $data['comment_approved'] = 'spam'; } else { $data['comment_approved'] = 'moderation'; } $comments = new Comments(); $insert = $comments->insert($data); $this->_flashMessenger->addMessage('Your comment has been entered and will appear shortly!'); $this->_redirect('/news/stories/article/id/' . $this->_getParam('id')); $this->_request->setMethod('GET'); } else { $this->_flashMessenger->addMessage('There are problems with your comment submission'); $form->populate($formData); } } } else { throw new Exception('No parameter on the url string'); } }
public function sendformAction() { $toy_id = trim($this->_getParam('toy_id')); $comm_name = trim($this->_getParam('comm_name')); $comm_text = trim($this->_getParam('comm_text')); if ($comm_name != '' && $comm_text != '') { $Comments = new Comments(); $comm_id = $Comments->insert(array('toy_id' => $toy_id, 'comm_name' => iconv('utf-8', 'cp1251', $comm_name), 'comm_text' => iconv('utf-8', 'cp1251', $comm_text), 'comm_time' => time() + 9 * 60 * 60)); if ($comm_id) { setcookie('comm_name', $comm_name, time() + 365 * 24 * 60 * 60, '/'); $this->_forward('onecomment', null, null, array('comm_id' => $comm_id)); } } else { echo 0; } $this->_helper->viewRenderer->setNoRender(); $this->_helper->layout->disableLayout(); }
function sendComment($postid) { $alert = ''; if (Request::has('btnComment')) { $valid = Validator::make(array('comment.content' => 'min:10|slashes', 'comment.fullname' => 'min:3|slashes', 'comment.email' => 'min:10|email|slashes')); if ($valid) { $send = Request::get('comment'); $send['postid'] = $postid; if (!($id = Comments::insert($send))) { throw new Exception("Error. Check comment info again!"); } else { throw new Exception("Success. We will review your comment"); } } else { throw new Exception("Error Processing Request"); } return $alert; } }
/** * Save a user's comment to the database. * * @param object $user User whose comment is being saved. * * @return bool True for success, false for failure. * @access public */ public static function saveComment($user) { // What record are we operating on? if (!isset($_GET['id'])) { return false; } if ($_REQUEST['commentId'] == 0) { $searchObject = SearchObjectFactory::initSearchObject(); $query = 'local_ids_str_mv:"' . addcslashes($_GET['id'], '"') . '"'; $searchObject->disableLogging(); $searchObject->setQueryString($query); $result = $searchObject->processSearch(); $searchObject->close(); if (PEAR::isError($result)) { PEAR::raiseError($result->getMessage()); } if ($result['response']['numFound'] == 0) { $idArray = array($_GET['id']); } else { $idArray = $result['response']['docs'][0]["local_ids_str_mv"]; } if ($_REQUEST['type'] == 1) { $commentsByUser = new Comments(); $commentList = $commentsByUser->getComments($_REQUEST['recordId']); foreach ($commentList as $comment) { if ($comment->user_id == $user->id) { return false; } } } $comments = new Comments(); $comments->user_id = $user->id; $rating = isset($_REQUEST['rating']) ? (double) $_REQUEST['rating'] : 0; $comments->rating = $rating > 0 && $rating <= 5 ? $rating : null; $comments->comment = $_REQUEST['comment']; $comments->type = $_REQUEST['type']; $comments->created = date('Y-m-d H:i:s'); $comments->insert(); $comments->addLinks($idArray); return true; } else { $comments = new Comments(); $comments->get($_REQUEST['commentId']); if ($comments->user_id == $user->id) { $comments->comment = $_REQUEST['comment']; $comments->rating = $_REQUEST['rating']; $comments->updated = date('Y-m-d H:i:s'); $comments->update(); return true; } return false; } }
function addComment($body, $user, $source = 'VuFind') { require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php'; $comment = new Comments(); $comment->user_id = $user->id; $comment->resource_id = $this->id; $comment->comment = $body; $comment->created = date('Y-m-d h:i:s'); $comment->insert(); return true; }
} // get posts for user $postObj->addSelection("{$gq} gid=1"); $res = $postObj->getPostFeed($r['id']); $rarr['posts'] = array(); while ($row = $res->fetch_assoc()) { $rarr['posts'][] = $row; } die(json_encode($rarr)); } } else { if ($r['action'] == 'comment') { // make a comment on a post // content, postid $comObj = new Comments($r); $comObj->checkTokenValid(); $comObj->checkInputHas(['content', 'postid']); $comObj->addInsertsFromArray($r, ['id', 'content', 'postid']); $comObj->addInsert('username', getUsername($r['id'])); $comObj->addInsert('doc', date('Y-m-d H:i:s')); $result = $comObj->insert(); if ($result) { execQuery("update posts set commentcount=commentcount+1 where postid={$r['postid']}"); die(json_encode($rarr)); } } else { makeError(ERR_NOACTION); } } } }
<?php if (isset($_POST['task']) && $_POST['task'] == 'comment_insert') { $userId = $_POST['userId']; $comment = str_replace("\n", "<br>", $_POST['comment']); $std = new stdClass(); $std->user = null; $std->comment = null; $std->error = false; require_once '../sql/models/comments.php'; if (class_exists('Comments') && class_exists('Subscribers')) { $userInfo = Subscribers::getSubscriber($userId); if ($userInfo == null) { //Cause some problems $std->error = true; } $commentInfo = Comments::insert($comment, $userId); if ($commentInfo == null) { //Cause some problems $std->error = true; } $std->user = $userInfo; $std->comment = $commentInfo; } echo json_encode($std); } else { }
public function addHistory($parent_name, $parent_id, $comment) { $data = array(); $data['parent_name'] = $parent_name; $data['parent_id'] = $parent_id; $data['comment'] = substr($comment, 2); $Comments = new Comments(); $Comments->insert($data); }
$app->render('post.html', array('post' => $post, 'error' => $error, 'comments' => $comments, 'redirect' => $redirect)); } else { $app->render('404_post.html'); } })->conditions(array('page' => '\\d+')); $app->post('/post/comment/new', function () use($app, $settings) { $username = $app->request->post('username'); $url = filter_var($app->request->post('url'), FILTER_SANITIZE_URL); $email = $app->request->post('email'); $text = filter_var($app->request->post('text'), FILTER_SANITIZE_STRING); $post_id = $app->request->post('post_id'); $redirect = $app->request->post('redirect'); if ($username == "") { $app->flash('error', 1); $app->redirect($settings->base_url . '/post/' . $post_id); } if ($url == "") { $app->flash('error', 2); $app->redirect($settings->base_url . '/post/' . $post_id); } if ($email == "" or !filter_var($email, FILTER_VALIDATE_EMAIL)) { $app->flash('error', 3); $app->redirect($settings->base_url . '/post/' . $post_id); } if ($text == "") { $app->flash('error', 4); $app->redirect($settings->base_url . '/post/' . $post_id); } Comments::insert(array('username' => $username, 'url' => $url, 'email' => $email, 'text' => $text, 'posts_id' => $post_id)); $app->render('success.html', array('redirect' => $redirect)); });
/** Display individual record * @todo move comment functionality to a model */ public function recordAction() { if ($this->_getParam('id', false)) { $this->view->recordID = $this->_getParam('id'); $id = $this->_getParam('id'); $findsdata = $this->_finds->getIndividualFind($id, $this->getRole()); if ($findsdata) { $this->view->finds = $findsdata; } else { throw new Pas_Exception_NotAuthorised('You are not authorised to view this record'); } $contexts = array('xml', 'rss', 'json', 'atom', 'kml', 'georss', 'ics', 'rdf', 'xcs', 'vcf', 'csv', 'pdf'); if (!in_array($this->_cs->getCurrentContext(), $contexts)) { $this->view->findsdata = $this->_finds->getFindData($id); $this->view->findsmaterial = $this->_finds->getFindMaterials($id); $this->view->temporals = $this->_finds->getFindTemporalData($id); $this->view->nexts = $this->_finds->getNextObject($id); $this->view->recordsprior = $this->_finds->getPreviousObject($id); $this->view->peoples = $this->_finds->getPersonalData($id); $this->view->findotherrefs = $this->_finds->getFindOtherRefs($id); $findspotsdata = new Findspots(); $this->view->findspots = $findspotsdata->getFindSpotData($id); $rallyfind = new Rallies(); $this->view->rallyfind = $rallyfind->getFindToRallyNames($id); $coins = new Coins(); $this->view->coins = $coins->getCoinData($id); $coinrefs = new Coinclassifications(); $this->view->coinrefs = $coinrefs->getAllClasses($id); $thumbs = new Slides(); $this->view->thumbs = $thumbs->getThumbnails($id); $refs = new Publications(); $this->view->refs = $refs->getReferences($id); $comments = new Comments(); $this->view->comments = $comments->getFindComments($id); $response = $this->getResponse(); if (in_array($this->getRole(), $this->_higherLevel) && !in_array($this->_cs->getCurrentContext(), array('xml', 'json', 'qrcode'))) { $wform = new WorkflowStageForm(); $wform->id->setValue($id); $wform->submit->setLabel('Change workflow'); $this->view->wform = $wform; $response->insert('workflow', $this->view->render('structure/workflow.phtml')); } else { $findspotsdata = new Findspots(); $this->view->findspots = $findspotsdata->getFindSpotData($id); } $form = new CommentFindForm(); $form->submit->setLabel('Add a new comment'); $this->view->form = $form; if ($this->getRequest()->isPost() && $form->isValid($this->_request->getPost())) { if ($form->isValid($form->getValues())) { $data = $form->getValues(); if ($this->getHelper->getAkismet()->isSpam($data)) { $data['comment_approved'] = 'spam'; } else { $data['comment_approved'] = 'moderation'; } $comments = new Comments(); $insert = $comments->insert($data); $this->_flashMessenger->addMessage('Your comment has been entered and will appear shortly!'); $this->_redirect(self::REDIRECT . 'record/id/' . $this->_getParam('id')); $this->_request->setMethod('GET'); } else { $this->_flashMessenger->addMessage('There are problems with your comment submission'); $form->populate($formData); } } } else { $this->_helper->layout->disableLayout(); //disable layout $record = $this->_finds->getAllData($id); if ($this->_auth->hasIdentity()) { $user = $this->_auth->getIdentity(); if (in_array($user->role, $this->_restricted)) { $record['0']['gridref'] = NULL; $record['0']['easting'] = NULL; $record['0']['northing'] = NULL; $record['0']['lat'] = NULL; $record['0']['lon'] = NULL; $record['0']['finder'] = NULL; $record['0']['address'] = NULL; $record['0']['postcode'] = NULL; $record['0']['findspotdescription'] = NULL; } } else { $record['0']['gridref'] = NULL; $record['0']['easting'] = NULL; $record['0']['northing'] = NULL; $record['0']['lat'] = NULL; $record['0']['lon'] = NULL; $record['0']['finder'] = NULL; $record['0']['address'] = NULL; $record['0']['postcode'] = NULL; $record['0']['findspotdescription'] = NULL; if (!is_null($record['0']['knownas'])) { $record['0']['parish'] = NULL; $record['0']['fourFigure'] = NULL; } } $this->view->record = $record; } } else { throw new Pas_Exception_Param($this->_missingParameter); } }