本文整理汇总了PHP中Comments::addComment方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::addComment方法的具体用法?PHP Comments::addComment怎么用?PHP Comments::addComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::addComment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: controller
public function controller($action)
{
switch ($action) {
case 'login':
$login = new LoginLogout();
$login->logIn();
break;
case 'do-login':
$login = new LoginLogout();
$login->doLogin();
break;
case 'logout':
$login = new LoginLogout();
$login->logOut();
break;
case 'list':
$records = new Records();
$records->getRecords();
break;
case 'view-record':
$records = new Records();
$records->getOneRecord(intval($_GET['id']));
break;
case 'add-record':
$records = new Records();
$records->addRecord();
break;
case 'delete-record':
$records = new Records();
$records->delRecord(intval($_GET['id']));
break;
case 'add-comment':
$comment = new Comments();
$comment->addComment();
break;
case 'delete-comment':
$comment = new Comments();
$comment->delComment(intval($_GET['id']));
break;
case 'about':
require ROOT . '/views/about.php';
break;
default:
die("No action");
}
}
示例2: _postCommentEntry
protected function _postCommentEntry($rawBody, $item)
{
// Get the Atom Adapter
$entry = AtomDocumentAdapterFactory::getInstance()->adapt($rawBody);
/* @var $entry AtomEntryAdapter */
// Check whether the entry is an atom entry or not
if ($entry->getDocumentType() == Atomns::ENTRY_ELEMENT) {
$atomProcessor = new AtomProcessor();
// Read the Entry
$data = $atomProcessor->readCommentEntry($entry);
if ($data['timestamp'] == '') {
$data['timestamp'] = time();
}
$data['source_id'] = $item->getSource();
$data['item_id'] = $item->getID();
// Add new comment
$comments = new Comments();
$comments->setUser($this->_application->user);
$data['id'] = $comments->addComment($data['source_id'], $data['item_id'], $data['comment'], $data['name'], $data['email'], $data['website'], $data['timestamp'], 0);
return new Comment($data);
} else {
$this->_buildResponse(Api_BaseController::HTTP_FAILED, 'Invalid Data!!! Atom Entry Document is required!!');
return false;
}
}
示例3: addAction
public function addAction()
{
if (!$this->getRequest()->isPost()) {
return $this->_helper->json->sendJson(true);
}
$form = $this->getForm();
if (!$form->isValid($_POST)) {
return $this->_helper->json->sendJson($form->getErrorArray());
}
// Get the values and proceed
$values = $form->getValues();
$source_id = $values['source'];
$item_id = $values['item'];
$name = $values['name'];
$email = $values['email'];
$website = $values['website'];
$comment = $values['comment'];
$options = $values['options'];
$timestamp = time();
$notify = @in_array('notify', $options) ? 1 : 0;
// Get the source and the user owning it
$data = new Data();
$sources = new Sources();
$users = new Users();
// Does the source exist ?
if (!($source = $sources->getSource($source_id))) {
return $this->_helper->json->sendJson(true);
}
// Does the item exists?
if (!($item = $data->getItem($source_id, $item_id))) {
return $this->_helper->json->sendJson(true);
}
// Does the user exist ?
if (!($user = $users->getUser($source['user_id']))) {
return $this->_helper->json->sendJson(true);
}
// Validate the website URL
$matches = array();
if (!preg_match_all("/^http/", $website, $matches)) {
$website = "http://{$website}";
}
// Add the comment to the database
$comments = new Comments();
$comments->addComment($source_id, $item_id, $comment, $name, $email, $website, $timestamp, $notify);
// Send an email alert to owner
$on_comment = $this->_properties->getProperty('on_comment');
$owner = $this->_application->user && $this->_application->user->email == $email ? true : false;
if ($on_comment && !$owner) {
$slug = $item->getSlug();
Stuffpress_Emails::sendCommentEmail($user->email, $user->username, $name, $email, $comment, $slug);
}
// Send email alerts to everyone else (skip owner and current submiter)
$subscribers = $comments->getSubscriptions($source_id, $item_id);
foreach ($subscribers as $subscriber) {
if ($subscriber['email'] == $user->email || $subscriber['email'] == $email) {
continue;
}
Stuffpress_Emails::sendCommentNotifyEmail($subscriber['email'], $subscriber['name'], $name, $comment, $source_id, $item_id);
}
// Ok send the result
return $this->_helper->json->sendJson(false);
}
示例4: postComments
/**
* Post a new comment.
*
* @global Smarty $smarty
* @param integer $kll_id
* @param string $author
* @param string $comment
* @param string $password
* @return xajaxResponse
*/
function postComments($kll_id, $author, $comment, $password = '')
{
if (config::get('comments')) {
$kll_id = intval($kll_id);
$comments = new Comments($kll_id);
global $smarty;
$config = new Config();
$page = new Page("Comments");
$comments = new Comments($kll_id);
$pw = false;
if (!config::get('comments_pw') || $page->isAdmin()) {
$pw = true;
}
if ($pw || crypt($password, config::get("comment_password")) == config::get("comment_password")) {
if ($comment == '') {
return getComments($kll_id, 'Error: The silent type, hey? Good for you, bad for a comment.');
} else {
if (!$author) {
$author = 'Anonymous';
}
$comments->addComment($author, $comment);
return getComments($kll_id);
}
} else {
// Password is wrong
return getComments($kll_id, 'Error: Wrong Password');
}
} else {
return false;
}
}
示例5: trimAll
<?php
require_once "../config/Autoload.php";
require_once "../libs/datafilter.php";
if (isset($_POST['text_c'])) {
$_POST = trimAll($_POST);
$_POST = htmlAll($_POST);
$comments = Comments::addComment($_POST['message_id'], $_POST['date_c'], $_POST['text_c'], $_POST['user_comment_id']);
if ($comments == true) {
echo 'Added successfully';
} else {
echo 'Please try again';
}
}
if (isset($_POST['text_edit_c'])) {
$_POST = trimAll($_POST);
$_POST = htmlAll($_POST);
$edit_comment = Comments::editComment($_POST['comment_edit_id'], $_POST['message_c_edit_id'], $_POST['text_edit_c']);
if ($edit_comment == true) {
echo 'Added successfully';
} else {
echo 'Please try again';
}
}
示例6: start
/**
* Start constructing the page.
*
* Prepare all the shared variables such as dates and check alliance ID.
*/
function start()
{
$this->kll_id = (int) edkURI::getArg('kll_id');
$this->kll_external_id = 0;
if (!$this->kll_id) {
$this->kll_external_id = (int) edkURI::getArg('kll_ext_id');
if (!$this->kll_external_id) {
// internal and external ids easily overlap so we can't guess which
$this->kll_id = (int) edkURI::getArg('id', 1);
}
}
$this->nolimit = edkURI::getArg('nolimit', 2);
$this->menuOptions = array();
$this->page = new Page('Kill details');
if (!$this->kll_id && !$this->kll_external_id) {
$html = "No kill id specified.";
$this->page->setContent($html);
$this->page->generate($html);
exit;
}
if ($this->kll_id) {
$this->kill = Cacheable::factory('Kill', $this->kll_id);
} else {
$this->kill = new Kill($this->kll_external_id, true);
$this->kll_id = $this->kill->getID();
}
if (!$this->kill->exists()) {
$html = "That kill doesn't exist.";
$this->page->setContent($html);
$this->page->generate($html);
exit;
}
if ($this->kll_external_id) {
$this->page->addHeader("<link rel='canonical' href='" . edkURI::build(array('kll_ext_id', $this->kll_external_id, true)) . "' />");
} else {
$this->page->addHeader("<link rel='canonical' href='" . edkURI::build(array('kll_id', $this->kll_id, true)) . "' />");
}
$this->finalblow = false;
$this->commenthtml = '';
// Check for posted comments.
// If a comment is being posted then we won't exit this block.
if (isset($_POST['comment']) && config::get('comments')) {
$comments = new Comments($this->kll_id);
$pw = false;
if (!config::get('comments_pw') || $this->page->isAdmin()) {
$pw = true;
}
if ($pw || crypt($_POST['password'], config::get("comment_password")) == config::get("comment_password")) {
if ($_POST['comment'] == '') {
$this->commenthtml = 'Error: The silent type, hey? Good for' . ' you, bad for a comment.';
} else {
$comment = $_POST['comment'];
$name = $_POST['name'];
if ($name == null) {
$name = 'Anonymous';
}
$comments->addComment($name, $comment);
//Redirect to avoid refresh reposting comments.
header('Location: ' . $_SERVER['REQUEST_URI'], TRUE, 303);
die;
}
} else {
// Password is wrong
$this->commenthtml = 'Error: Wrong Password';
}
}
global $smarty;
if (!file_exists('img/panel/' . config::get('fp_theme') . '.png')) {
config::set('fp_theme', 'tyrannis');
}
$smarty->assign('panel_colour', config::get('fp_theme'));
$smarty->assign('showiskd', config::get('kd_showiskd'));
$smarty->assign('formURL', edkURI::build(edkURI::parseURI()));
// Check admin update options.
if ($this->page->isAdmin()) {
$smarty->assign('admin', true);
$this->updatePrices();
}
$this->involvedSetup();
$this->fittingSetup();
}
示例7: showProduct
public function showProduct()
{
$msg = "";
if (filter_has_var(INPUT_GET, 'id')) {
$idprod = $_GET['id'];
}
$product = new Product();
$resultatProduct = $product->findProduct($idprod);
include_once "controllers/comments.php";
$comm = new Comments();
if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
$id_membre = $_SESSION['user']['id_membre'];
$id_salle = $resultatProduct['id_salle'];
$comm->addComment($id_membre, $id_salle);
}
$resultatRoom = $product->access_ModelRoom_FindOne($resultatProduct['id_salle']);
$resultatPromo = $product->access_ModelPromotion_FindOne($resultatProduct['id_promo']);
$dateArrivee = $product->changeDatetoFrenchFormat($resultatProduct['date_arrivee']);
$dateDepart = $product->changeDatetoFrenchFormat($resultatProduct['date_depart']);
$msg .= '<div class="row rowColor">';
$msg .= '<div class="col-sm-10 rowColor2">';
$msg .= '<div class="blocImage">';
$msg .= '<img class="img-responsive" src="' . $resultatRoom['photo'] . '" width= 600/>';
$msg .= '</div>';
$msg .= '<div class="infos ">';
$msg .= '<p class="detailTitre">' . $resultatRoom['titre'] . '</p>';
$msg .= '<p class="detailCat">Catégorie: ' . $resultatRoom['categorie'] . '</p>';
$msg .= '<p class="detailCat">Max: ' . $resultatRoom['capacite'] . ' personnes</p>';
$msg .= '<p class="detailAdresse">' . $resultatRoom['adresse'] . '</p>';
$msg .= '<p class="detailAdresse">' . $resultatRoom['cp'] . ' ' . $resultatRoom['ville'] . '</p>';
$msg .= '<p class="detailDate">Date d\'arrivée: ' . $dateArrivee . '</p>';
$msg .= '<p class="detailDate">Date de départ: ' . $dateDepart . '</p>';
$msg .= '<p class="detailPrix">' . $resultatProduct['prix'] . ' €</p>';
// SI LE CODE PROMO EXISTE
if (isset($resultatPromo['code_promo']) && $resultatPromo['code_promo'] != '') {
$msg .= '<p class="detailPromo">*Code promo: ' . $resultatPromo['code_promo'] . ' pour bénéficier d\'une réduction de ' . $resultatPromo['reduction'] . ' €</p>';
}
$msg .= '<div class="clearfix"></div>';
$msg .= '</div>';
$msg .= '</div>';
$msg .= '<div class="col-sm-2 optionsButton">';
if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
$msg .= '<a class="btn btn-success" href="index.php?controller=orders&action=addToCart&id=' . $resultatProduct['id_produit'] . '" title="Ajouter">Ajouter au panier</a>';
} else {
$msg .= '<a class="btn btn-success btnDetail" href="index.php?controller=members&action=connect" title="Se connecter">Se connecter</a>';
$msg .= "<br/>";
$msg .= '<a class="btn btn-success btnDetail" href="index.php?controller=members&action=add_member" title="Inscription">Inscription</a>';
}
$msg .= '</div>';
$msg .= '</div>';
// COMMENTAIRES
$msg .= '<div class="row row2">';
$msg .= '<div class="col-sm-4 detailAvis">';
// AFFICHAGE DES AVIS SUR LA SALLE
$comments = $product->access_ModelComment_roomComments($resultatProduct['id_salle']);
if (isset($comments) && !empty($comments)) {
$msg .= '<p class="avisTitre">Avis sur cette salle: </p>';
foreach ($comments as $comm) {
$member = $product->access_ModelMember_retrieveMember($comm['id_membre']);
$msg .= '<div class="commentaire">';
$msg .= '<p class="avisMembre">Par ' . $member['prenom'] . ' ' . $member['nom'] . ' le ' . $comm['date'] . '</p>';
$msg .= '<p class="avisTexte">' . $comm['commentaire'] . '</p>';
$msg .= '<p class="avisNote">Note: ' . $comm['note'] . '/10 </p>';
$msg .= '</div>';
}
} else {
$msg .= '<p>Cette salle n\'a aucun commentaires pour le moment.</p>';
}
$msg .= '</div>';
$msg .= '<div class="col-sm-8">';
$msg .= '<div class="row rowDesc">';
$msg .= '<p>' . $resultatRoom['description'] . '</p>';
$msg .= '</div>';
$msg .= '<div class="row rowMap">';
$msg .= '<input type="hidden" id="address" value="' . $resultatRoom['adresse'] . ' ' . $resultatRoom['cp'] . ' ' . $resultatRoom['ville'] . '"/>';
$msg .= '<div id="map-canvas" class="pull-right"></div>';
$msg .= '</div>';
$msg .= '</div>';
$msg .= '</div>';
$msg .= '<div class="row rowAvisForm">';
// Vérification si l'utilisateur connecté a déjà posté un avis sur cette salle
if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
$verif = $product->checkMemberComments($_SESSION['user']['id_membre'], $resultatProduct['id_salle']);
}
if (empty($verif) || $verif == NULL) {
//Affichage du formulaire pour entrer un commentaire
if ($product->access_ModelMember_userAdmin() || $product->access_ModelMember_sessionExists()) {
$msg .= '<form method="post" class="form-horizontal">';
$msg .= '<div class="form-group">';
$msg .= '<label class="label-control col-sm-4" for="comment">Ajouter un commentaire</label>';
$msg .= '<div class="col-sm-8">';
$msg .= '<textarea name="comment" id="comment">Votre commentaire...</textarea>';
$msg .= '</div>';
$msg .= '</div>';
$msg .= '<div class="form-group">';
$msg .= '<label class="label-control col-sm-4" for="note">Note/10</label>';
$msg .= '<div class="col-sm-8">';
$msg .= '<select class="form-control" name="note" id="note">';
$msg .= '<option value="0">0</option>';
$msg .= '<option value="1">1</option>';
//.........这里部分代码省略.........
示例8: file
// If sent Javascript will do anything...
echo "Error: Unauthorized.";
}
}
if (is_writable($jsonDatabaseFile) && is_readable($jsonDatabaseFile)) {
if (!($handle = fopen($jsonDatabaseFile, 'a+'))) {
echo "Cannot open file ({$jsonDatabaseFile})";
exit;
}
$comments = new Comments();
$comments->allComments($jsonDatabaseFile);
if ($_GET['action'] == "save" && $_POST['id'] == "E73BF175-F920-447D-993D-CE4169F17BCD") {
$postedComment = new Comment();
$postedComment->createComment($_POST['commentatorName'], $_POST['commentatorEmail'], $_POST['commentatorText'], $_POST['commentatorWebsite'], $_SERVER['REMOTE_ADDR']);
if (!is_null($postedComment)) {
$comments->addComment($postedComment);
echo json_encode($postedComment);
} else {
echo "Error: Comment could not be saved.";
}
} else {
if ($_GET['action'] == "save" && $_POST['id'] != "E73BF175-F920-447D-993D-CE4169F17BCD") {
echo "Error: Unauthorized.";
}
}
if ($_GET['action'] == "remove") {
if ($_POST['adminUsername'] == $encryptedUsername && $_POST['adminPassword'] == $encryptedPassword) {
$postid = $_GET['id'];
if ($postid == "") {
echo "Error: No ID sent or it is empty.";
} else {
示例9: upload_csv_file
//.........这里部分代码省略.........
echo $impRen->showMessage('error', "Check your CSV file and format.");
?>
</div>
<?php
}
}
$_REQUEST['action'] = 'dashboard';
echo $impRen->renderDashboard();
} else {
if (isset($_POST['post_csv']) && $_REQUEST['action'] == 'users') {
// Code for import users and their Datas.
echo $impRen->setDashboardAction();
require_once 'class.userroles.php';
$impCE1 = new SmackImpCE();
$userObj = new Users();
$data_rows = $impCE1->csv_file_data($impCE1->getUploadDirectory() . "/" . $_POST['filename'], $_POST['delim']);
$result = $userObj->addUsers($data_rows);
echo $impRen->renderMenu();
if ($userObj->insUserCount != 0) {
echo $impRen->showMessage('success', $userObj->insUserCount . " users has been imported");
}
if ($userObj->skipUserCount != 0) {
echo $impRen->showMessage('error', $userObj->skipUserCount . " users has been skipped");
}
$_SESSION['thirdformaction'] = 'dashboard';
echo $impRen->renderDashboard();
} else {
if (isset($_POST['post_csv']) && $_REQUEST['action'] == 'comments') {
echo $impRen->setDashboardAction();
require_once 'class.comments.php';
$impCE1 = new SmackImpCE();
$commentObj = new Comments();
$data_rows = $impCE1->csv_file_data($impCE1->getUploadDirectory() . "/" . $_POST['filename'], $_POST['delim']);
$result = $commentObj->addComment($data_rows);
echo $impRen->renderMenu();
if ($commentObj->insComments != 0) {
echo $impRen->showMessage('success', $commentObj->insComments . " comments has been imported");
}
if ($commentObj->skippedComments != 0) {
echo $impRen->showMessage('error', $commentObj->skippedComments . " comments has been skipped");
}
echo $impRen->renderDashboard();
} else {
?>
<!-- first form gets displayed from here -->
<?php
if (!$_REQUEST['action']) {
$_REQUEST['action'] = 'post';
} elseif ($_REQUEST['action'] == 'dashboard') {
echo $impRen->renderMenu();
echo $impRen->renderDashboard();
} elseif ($_REQUEST['action'] == 'settings') {
echo $impRen->renderMenu();
if ($pluginActive != null) {
echo $impRen->showMessage('error', $pluginActive);
}
echo $impRen->renderSettings();
} elseif ($_REQUEST['action'] == 'custompost') {
?>
<div class="wrap" id="smack-content">
<?php
echo $impRen->renderMenu();
$sett = new IMPSettings();
?>
<div class="smack-postform">
<?php
示例10: Comments
<?php
require_once "commentsClass.php";
echo "<html><body bgcolor=#D8D8D8>";
// Replace periods with underscores (SQL doesn't allow periods in table names)
$comments = new Comments(strtr($_GET['id'], ".", "_"));
echo "<h2>Discussion for PROJECT {$comments->projectID}</h2>";
/* Onclick event of 'Add Comment' button. Blocks empty comments and replaces
empty names with "Anonymous" */
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$comment = $_POST['comment'];
if ($name == "") {
$name = "Anonymous";
}
if ($comment != "") {
$comments->addComment($name, $comment);
}
}
/* Fetch comments from table and display them all */
$stmt = $comments->DB->prepare("SELECT * FROM {$comments->projectID}");
$stmt->execute();
$stmt->bind_result($name, $comment);
while ($stmt->fetch()) {
echo $name . " says: ";
echo $comment;
printf("<button onclick=prependName('%s');>Reply</button>", $name);
echo "<hr style='width:20%;' align='left'/>";
}
?>
<?php
示例11: ajax_comment_reply
function ajax_comment_reply()
{
$parent = isset($_POST['id']) ? absint($_POST['id']) : 0;
$content = isset($_POST['content']) ? $_POST['content'] : '';
if (!($comment = Comment::find($parent))) {
json_message('Parent comment not found.', false);
}
$page = $comment->page;
$page_url = $comment->page_url;
$page_title = $comment->page_title;
Comments::setMailer(app('mailer'))->setDispatcher(app('events'));
$comment = Comments::addComment(compact('content', 'parent', 'page', 'page_url', 'page_title'));
if (is_array($comment)) {
json_message(true);
} else {
json_message(is_object($comment) ? $comment->first() : trans('errors.dbsave'), false);
}
}