function add() { $response = new Response(); try { $workOrderId = $this->input->post("workOrderId"); $commentText = $this->input->post("comment"); $workOrder = $this->findById("Workorder", $workOrderId); $loggedInUser = $this->getLoggedInUser(); $comment = new Comment(); $comment->setCreated(new DateTime()); $comment->setCommentedBy($loggedInUser); $comment->setComment($commentText); $workOrder->getComments()->add($comment); $this->save($workOrder); $cmt = new Commentdto(); $cmt->setId($comment->getId()); $cmt->setComment($comment->getComment()); $cmt->setCommentedBy($comment->getCommentedBy()->getFirstName() . " " . $comment->getCommentedBy()->getLastName()); $cmt->setCreated(date_format($comment->getCreated(), "d-M-Y")); $response->setData($cmt); } catch (Exception $e) { $response->setStatus(false); $response->setErrorMessage($e->getMessage()); } $this->output->set_content_type('application/json')->set_output(json_encode($response)); }
public function testAddComment() { $comment = new Comment(); $comment->id_user = $this->user->id; $errors = $comment->validateController(); $this->assertEquals(3, sizeof($errors)); // username, repository, comment required $nbComments = sizeof($comments = $this->user->comments()); $this->assertEquals(0, $nbComments); $comment->setUsername("jessylenne"); $comment->setRepository("jessylenne"); $this->setExpectedExceptionRegExp('Exception', '/Veuillez fournir un commentaire valide/'); $comment->setComment('<script type="text/javascript">console.log("Yeah Fail!")</script>'); $this->assertFalse($comment->save()); $comment->setComment("comment"); $this->assertTrue($comment->save()); $this->assertEquals($nbComments + 1, sizeof($this->user->comments())); $comment->delete(); }
function saveComment($comment) { $dpComment = new Comment(); $dpComment->setDp($comment['dp']); $dpComment->setComment($comment['comment']); $dpComment->setAutor($comment['autor']); $dpComment->setDate(time()); $commentId = $dpComment->saveDpComment(); return $commentId; }
public static function map(Comment $comment, array $properties) { if (array_key_exists('comment_id', $properties)) { $comment->setComment_id((int) $properties['comment_id']); } if (array_key_exists('comment', $properties)) { $comment->setComment($properties['comment']); } if (array_key_exists('user_id', $properties)) { $comment->setUser_id((int) $properties['user_id']); } if (array_key_exists('item_id', $properties)) { $comment->setItem_id((int) $properties['item_id']); } }
public static function update($values, $user) { $comment = new Comment(); $comment->setComment(substr($values['comment'], 0, 5000)); if ($values['application_id']) { $comment->setApplicationId($values['application_id']); } if ($values['module_id']) { $comment->setMaduleId($values['module_id']); } if ($values['theme_id']) { $comment->setThemeId($values['theme_id']); } $comment->setUserId($user->getId()); $comment->save(); return $comment; }
public function handleRequest($command, $comment) { switch ($command) { case 'set': $response = Comment::setComment($comment); break; case 'delete': $response = Comment::deleteComment($comment); break; default: throw new Exception("Unsupported property!"); break; } if (empty($response)) { $response = false; } $formattedResponse = Comment::formatResponse($response); render('comment', array('comments' => $formattedResponse)); }
public function addComment($id_membre, $id_salle) { $msg = ""; if ($_POST) { $comment = htmlentities($_POST['comment'], ENT_QUOTES, "utf-8"); $note = htmlentities($_POST['note'], ENT_QUOTES, "utf-8"); $dateNow = new DateTime("now"); $date = $dateNow->format('Y-m-d H:i:s'); $commentaire = new Comment(); $commentaire->setIdMembre($id_membre); $commentaire->setIdSalle($id_salle); $commentaire->setComment($comment); $commentaire->setNote($note); $commentaire->setDate($date); //Vérifications si besoin avant entrée en base $msgError = ""; //Entrée en base if ($msgError == "") { $commentaire->addComment(); } else { $msg .= $msgError; } } }
<?php namespace sql_nd_3\DDD; require_once "Comment.php"; require_once "CommentRepository.php"; require_once "TopicRepository.php"; $commentRepository = new CommentRepository(); $topicRepository = new TopicRepository(); $bla = "blablablabla"; $comment = new Comment(); $comment->setAuthor('Author' . rand(0, 1000)); $comment->setTopicID($topicRepository->getRandomId()); $comment->setComment(substr($bla, 0, rand(12, strlen($bla)))); $commentRepository->saveComment($comment); echo "<div>" . $comment->getTopicID() . "</div>"; echo "<div>" . $comment->getAuthor() . "</div>"; echo "<div>" . $comment->getComment() . "</div>";
<?php $model = $_REQUEST['model']; $action = $_REQUEST['action']; include_once MODELS_ADMIN . "/" . $model . "_model.php"; switch (strtoupper($action)) { case 'VIEW': $objComment = new Comment(); $datum = $objComment->getComment($_REQUEST['id']); break; case 'UPDATE': if (isset($_REQUEST['btn_submit']) && $_REQUEST['btn_submit'] == 'Update') { $objComment = new Comment(); $objComment->setComment($_REQUEST); $objComm->redirect('index.php?model=' . $model); } break; default: $objComment = new Comment(); $data = $objComment->getAllComment(); break; }
<?php require_once '../entity/CommentRep.php'; require_once '../entity/ThemeRep.php'; if (isset($_GET['theme_id']) && is_numeric($_GET['theme_id'])) { $comment = new Comment(); $comment->setDate((new DateTime('now'))->format('Y-m-d H:i:s')); $comment->setAuthor(isset($_GET['author']) ? $_GET['author'] : 'bet koks autorius'); $comment->setComment(isset($_GET['comment']) ? $_GET['comment'] : 'bet koks komentaras'); $comment->setThemeId($_GET['theme_id']); $themeRep = new ThemeRep(); $theme = $themeRep->findById($_GET['theme_id']); if (empty($theme)) { echo 'Tema su id ' . $_GET['theme_id'] . ' neegzistuoja'; return; } $themeRep->increaseCommentCount($theme); $commentRep = new CommentRep(); $commentRep->save($comment); echo 'Komentaras pridetas.'; } else { echo 'Reikalingas temos id.'; }
//Look for and detect IPv4/IPv6 addresses in comment text, and warn the commenter. if ((preg_match('/\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/', $_POST['comment']) || preg_match('/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/', $_POST['comment'])) && $_POST['privpol-check-override'] != "override") { BootstrapSkin::displayAlertBox("IP address detected in comment text. Warning acknowledgement checkbox must be checked.", "alert-error", "Error", true, false); $smarty->assign("request", $request); $smarty->assign("comment", $_POST['comment']); $smarty->assign("actionLocation", "comment-quick"); $smarty->display("privpol-warning.tpl"); BootstrapSkin::displayInternalFooter(); die; } $comment = new Comment(); $comment->setDatabase(gGetDb()); $comment->setRequest($request->getId()); $comment->setVisibility($visibility); $comment->setUser(User::getCurrent()->getId()); $comment->setComment($_POST['comment']); $comment->save(); Notification::commentCreated($comment); header("Location: acc.php?action=zoom&id=" . $request->getId()); } elseif ($action == "changepassword") { if (!isset($_POST['oldpassword']) || $_POST['oldpassword'] == "") { //Throw an error if old password is not specified. BootstrapSkin::displayAlertBox("You did not enter your old password.", "alert-error", "Error", true, false); BootstrapSkin::displayInternalFooter(); die; } if (!isset($_POST['newpassword']) || $_POST['newpassword'] == "") { //Throw an error if new password is not specified. BootstrapSkin::displayAlertBox("You did not enter your new password.", "alert-error", "Error", true, false); BootstrapSkin::displayInternalFooter(); die;
protected function addComment($worklist_id, $user_id, $comment_text, $parent_comment_id) { // in case the comment is a reply to another comment, // we'll fetch the original comment's email <mikewasmike> $comment = new Comment(); $comment->setWorklist_id((int) $worklist_id); $comment->setUser_id((int) $user_id); $correspondent = null; if (isset($parent_comment_id)) { $comment->setComment_id((int) $parent_comment_id); $originalComment = new Comment(); $originalComment->findCommentById((int) $parent_comment_id); $cuser = new User(); $cuser->findUserById($originalComment->getUser_id()); // add the author of the parent comment, as long as it's not the // same as the logged in user, in order to prevent email notification // to the author of the new comment if ($cuser->isActive() && $cuser->getId() != Session::uid()) { $correspondent = array($cuser->getUsername()); } else { $correspondent = array(); } } $comment->setComment($comment_text); try { $id = $comment->save(); } catch (Exception $e) { error_log("Failure saving comment:\n" . $e); } $redirectToDefaultView = true; $result = array('correspondent' => $correspondent, 'id' => $id); return $result; }
<?php require_once '../model/Comment.php'; require_once '../model/Theme.php'; if (isset($_GET['theme_id']) && is_numeric($_GET['theme_id'])) { $comment = new Comment(); $comment->setDate((new DateTime('now'))->format('Y-m-d H:i:s')); $comment->setAuthor(isset($_GET['author']) ? $_GET['author'] : 'nežinomas autorius'); $comment->setComment(isset($_GET['comment']) ? $_GET['comment'] : 'nežinomas komentaras'); $comment->setThemeId($_GET['theme_id']); $theme = Theme::findById($_GET['theme_id']); if (empty($theme)) { echo 'Tema ' . $_GET['theme_id'] . ' neegzistuoja'; return; } $theme->increaseCommentsCount(); $comment->save(); echo 'Komentaras pridetas.'; } else { echo 'Reikalingas temos id.'; }
<?php /** * Created by PhpStorm. * User: Florent * Date: 18/02/2015 * Time: 15:11 */ require_once '../class/Comment.php'; require_once '../manager/CommentManager.php'; require_once '../bdd/pdo.php'; session_start(); /** Vérification */ if (isset($_POST['produit']) && isset($_POST['note']) && isset($_POST['comment']) && $_POST['produit'] != "" && $_POST['note'] != "" && $_POST['comment'] != "") { /** Premiere partie formulaire $monnouveaucomment */ $monnouveaucomment = new Comment(); $monnouveaucomment->setArticleid($_POST['produit']); $monnouveaucomment->setNote($_POST['note']); $monnouveaucomment->setComment($_POST['comment']); /** Insertion en base $monManagerUtilisateur */ $monManagerComment = new CommentManager($bdd); $monManagerComment->insertion($monnouveaucomment); /** Redirection */ header('Location:../main/comment.php'); } else { echo "Un des champs est incorrect"; header('Location:../main/comment.php'); }
public function search($marecherche) { $requete = $this->_db->prepare('select c.comment_id , u.name , u.first_name , c.comment , a.nom , c.note from commentaire c inner join utilisateur u on u.id=c.profile_id inner join article a on a.id=c.article_id where a.nom like "%":search"%"'); $requete->execute(array(':search' => $marecherche)); $results = $requete->fetchAll(); $tabobject = array(); if (empty($results)) { /** Si pas de resultat alors faux */ return false; } else { /** Sinon parcours et stocke dans un tableau les commentaires */ foreach ($results as $result) { $monretourcomment = new Comment(); $monretourcomment->setId($result['comment_id']); $monretourcomment->setPid($result['name'] . " " . $result['first_name']); $monretourcomment->setComment($result['comment']); $monretourcomment->setArticleid($result['nom']); $monretourcomment->setNote($result['note']); array_push($tabobject, $monretourcomment); // Push l'objet $article dans le tableau $tabobject } } return $tabobject; }
exitZP(); } XSRFdefender('savecomment'); $id = sanitize_numeric($_POST['id']); $comment = new Comment($id); if (isset($_POST['name'])) { $comment->setName(sanitize($_POST['name'], 3)); } if (isset($_POST['email'])) { $comment->setEmail(sanitize($_POST['email'], 3)); } if (isset($_POST['website'])) { $comment->setWebsite(sanitize($_POST['website'], 3)); } $comment->setDateTime(sanitize($_POST['date'], 3)); $comment->setComment(sanitize($_POST['comment'], 1)); $comment->setCustomData($_comment_form_save_post = serialize(getCommentAddress(0))); $comment->save(); header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/comment_form/admin-comments.php?saved&page=editcomment&id=' . $comment->getID()); exitZP(); } } printAdminHeader('comments'); zp_apply_filter('texteditor_config', 'admin_comments'); ?> <script type="text/javascript"> //<!-- <![CDATA[ function confirmAction() { if ($('#checkallaction').val() == 'deleteall') { return confirm('<?php echo js_encode(gettext("Are you sure you want to delete the checked items?"));
<?php require_once 'connexion.class.php'; require_once 'comment.class.php'; $comment = new Comment(); $comment->setComment($_POST['gallery'], $_POST['pics'], $_POST['author'], $_POST['comment']);
<?php namespace Akademija\ActiveRecord; include_once 'Theme.php'; include_once 'Comment.php'; include_once 'dbConnection.php'; if (isset($_POST["themeId"])) { $db = new dbConnection('localhost', 'root', '', 'akademija-nd'); $db = $db->connect(); $themeId = (int) $_POST["themeId"]; $theme = new Theme($db); $theme = $theme->load($themeId); $comment = new Comment($db); $comment->setThemeId($themeId); $comment->setDate(date("Y-m-d H:i:s")); $comment->setAuthor($_POST["author"]); $comment->setComment($_POST["comment"]); $theme->addComments($comment); echo "<h2>Komentaras pridetas!</h2>"; } else { echo "<h2>Klaida!</h2>"; } //header( "Refresh:15; url=List.php", true, 303); echo '<a href="List.php"><- Atgal</a>';
/** * Generic comment adding routine. Called by album objects or image objects * to add comments. * * Returns a comment object * * @param string $name Comment author name * @param string $email Comment author email * @param string $website Comment author website * @param string $comment body of the comment * @param string $code CAPTCHA code entered * @param string $code_ok CAPTCHA hash expected * @param string $type 'albums' if it is an album or 'images' if it is an image comment * @param object $receiver the object (image or album) to which to post the comment * @param string $ip the IP address of the comment poster * @param bool $private set to true if the comment is for the admin only * @param bool $anon set to true if the poster wishes to remain anonymous * @param string $customdata * @param bit $check bitmask of which fields must be checked. If set overrides the options * @return object */ function comment_form_addComment($name, $email, $website, $comment, $code, $code_ok, $receiver, $ip, $private, $anon, $customdata, $check = false) { global $_zp_captcha, $_zp_gallery, $_zp_authority, $_zp_comment_on_hold, $_zp_spamFilter; if ($check === false) { $whattocheck = 0; if (getOption('comment_email_required') == 'required') { $whattocheck = $whattocheck | COMMENT_EMAIL_REQUIRED; } if (getOption('comment_name_required')) { $whattocheck = $whattocheck | COMMENT_NAME_REQUIRED; } if (getOption('comment_web_required') == 'required') { $whattocheck = $whattocheck | COMMENT_WEB_REQUIRED; } switch (getOption('Use_Captcha')) { case 0: break; case 2: if (zp_loggedin(POST_COMMENT_RIGHTS)) { break; } default: $whattocheck = $whattocheck | USE_CAPTCHA; break; } if (getOption('comment_body_requiired')) { $whattocheck = $whattocheck | COMMENT_BODY_REQUIRED; } if (getOption('email_new_comments')) { $whattocheck = $whattocheck | COMMENT_SEND_EMAIL; } } else { $whattocheck = $check; } $type = $receiver->table; $receiver->getComments(); $name = trim($name); $email = trim($email); $website = trim($website); // Let the comment have trailing line breaks and space? Nah... // Also (in)validate HTML here, and in $name. $comment = trim($comment); $receiverid = $receiver->getID(); $goodMessage = 2; if ($private) { $private = 1; } else { $private = 0; } if ($anon) { $anon = 1; } else { $anon = 0; } $commentobj = new Comment(); $commentobj->transient = false; // otherwise we won't be able to save it.... $commentobj->setOwnerID($receiverid); $commentobj->setName($name); $commentobj->setEmail($email); $commentobj->setWebsite($website); $commentobj->setComment($comment); $commentobj->setType($type); $commentobj->setIP($ip); $commentobj->setPrivate($private); $commentobj->setAnon($anon); $commentobj->setInModeration(0); $commentobj->setCustomData($customdata); if ($whattocheck & COMMENT_EMAIL_REQUIRED && (empty($email) || !is_valid_email_zp($email))) { $commentobj->setInModeration(-2); $commentobj->comment_error_text .= ' ' . gettext("You must supply an e-mail address."); $goodMessage = false; } if ($whattocheck & COMMENT_NAME_REQUIRED && empty($name)) { $commentobj->setInModeration(-3); $commentobj->comment_error_text .= ' ' . gettext("You must enter your name."); $goodMessage = false; } if ($whattocheck & COMMENT_WEB_REQUIRED && (empty($website) || !isValidURL($website))) { $commentobj->setInModeration(-4); $commentobj->comment_error_text .= ' ' . gettext("You must supply a WEB page URL."); $goodMessage = false; } if ($whattocheck & USE_CAPTCHA) { if (!$_zp_captcha->checkCaptcha($code, $code_ok)) { $commentobj->setInModeration(-5); $commentobj->comment_error_text .= ' ' . gettext("CAPTCHA verification failed."); $goodMessage = false; } } if ($whattocheck & COMMENT_BODY_REQUIRED && empty($comment)) { $commentobj->setInModeration(-6); $commentobj->comment_error_text .= ' ' . gettext("You must enter something in the comment text."); $goodMessage = false; } $moderate = 0; if ($goodMessage && isset($_zp_spamFilter)) { $goodMessage = $_zp_spamFilter->filterMessage($name, $email, $website, $comment, $receiver, $ip); switch ($goodMessage) { case 0: $commentobj->setInModeration(2); $commentobj->comment_error_text .= sprintf(gettext('Your comment was rejected by the <em>%s</em> SPAM filter.'), $_zp_spamFilter->name); $goodMessage = false; break; case 1: $_zp_comment_on_hold = sprintf(gettext('Your comment has been marked for moderation by the <em>%s</em> SPAM filter.'), $_zp_spamFilter->name); $commentobj->comment_error_text .= $_zp_comment_on_hold; $commentobj->setInModeration(1); $moderate = 1; break; case 2: $commentobj->setInModeration(0); break; } } $localerrors = $commentobj->getInModeration(); zp_apply_filter('comment_post', $commentobj, $receiver); if ($check === false) { // ignore filter provided errors if caller is supplying the fields to check $localerrors = $commentobj->getInModeration(); } if ($goodMessage && $localerrors >= 0) { // Update the database entry with the new comment $commentobj->save(); // add to comments array and notify the admin user if (!$moderate) { $receiver->comments[] = array('name' => $commentobj->getname(), 'email' => $commentobj->getEmail(), 'website' => $commentobj->getWebsite(), 'comment' => $commentobj->getComment(), 'date' => $commentobj->getDateTime(), 'custom_data' => $commentobj->getCustomData()); } switch ($type) { case "albums": $url = "album=" . pathurlencode($receiver->name); $ur_album = getUrAlbum($receiver); if ($moderate) { $action = sprintf(gettext('A comment has been placed in moderation on your album “%1$s”.'), $receiver->name); } else { $action = sprintf(gettext('A comment has been posted on your album “%1$s”.'), $receiver->name); } break; case "news": $url = "p=news&title=" . urlencode($receiver->getTitlelink()); if ($moderate) { $action = sprintf(gettext('A comment has been placed in moderation on your article “%1$s”.'), $receiver->getTitlelink()); } else { $action = sprintf(gettext('A comment has been posted on your article “%1$s”.'), $receiver->getTitlelink()); } break; case "pages": $url = "p=pages&title=" . urlencode($receiver->getTitlelink()); if ($moderate) { $action = sprintf(gettext('A comment has been placed in moderation on your page “%1$s”.'), $receiver->getTitlelink()); } else { $action = sprintf(gettext('A comment has been posted on your page “%1$s”.'), $receiver->getTitlelink()); } break; default: // all image types $album = $receiver->getAlbum(); $url = "album=" . pathurlencode($album->name) . "&image=" . urlencode($receiver->filename); $ur_album = getUrAlbum($album); if ($moderate) { $action = sprintf(gettext('A comment has been placed in moderation on your image “%1$s” in the album “%2$s”.'), $receiver->getTitle(), $album->name); } else { $action = sprintf(gettext('A comment has been posted on your image “%1$s” in the album “%2$s”.'), $receiver->getTitle(), $album->name); } break; } if ($whattocheck & COMMENT_SEND_EMAIL) { $message = $action . "\n\n" . sprintf(gettext('Author: %1$s' . "\n" . 'Email: %2$s' . "\n" . 'Website: %3$s' . "\n" . 'Comment:' . "\n\n" . '%4$s'), $commentobj->getname(), $commentobj->getEmail(), $commentobj->getWebsite(), $commentobj->getComment()) . "\n\n" . sprintf(gettext('You can view all comments about this item here:' . "\n" . '%1$s'), 'http://' . $_SERVER['SERVER_NAME'] . WEBPATH . '/index.php?' . $url) . "\n\n" . sprintf(gettext('You can edit the comment here:' . "\n" . '%1$s'), 'http://' . $_SERVER['SERVER_NAME'] . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/comment_form/admin-comments.php?page=editcomment&id=' . $commentobj->getID()); $emails = array(); $admin_users = $_zp_authority->getAdministrators(); foreach ($admin_users as $admin) { // mail anyone with full rights if (!empty($admin['email']) && ($admin['rights'] & ADMIN_RIGHTS || ($admin['rights'] & (MANAGE_ALL_ALBUM_RIGHTS | COMMENT_RIGHTS)) == (MANAGE_ALL_ALBUM_RIGHTS | COMMENT_RIGHTS))) { $emails[] = $admin['email']; unset($admin_users[$admin['id']]); } } if ($type === "images" or $type === "albums") { // mail to album admins $id = $ur_album->getID(); $sql = 'SELECT `adminid` FROM ' . prefix('admin_to_object') . ' WHERE `objectid`=' . $id . ' AND `type` LIKE "album%"'; $result = query($sql); if ($result) { while ($anadmin = db_fetch_assoc($result)) { $id = $anadmin['adminid']; if (array_key_exists($id, $admin_users)) { $admin = $admin_users[$id]; if ($admin['rights'] & COMMENT_RIGHTS && !empty($admin['email'])) { $emails[] = $admin['email']; } } } db_free_result($result); } } $on = gettext('Comment posted'); $result = zp_mail("[" . $_zp_gallery->getTitle() . "] {$on}", $message, $emails); if ($result) { $commentobj->setInModeration(-12); $commentobj->comment_error_text = $result; } } } return $commentobj; }