本文整理汇总了PHP中Comments类的典型用法代码示例。如果您正苦于以下问题:PHP Comments类的具体用法?PHP Comments怎么用?PHP Comments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Comments类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionChangeStatus
/**
* Change Case status using select-box
*/
public function actionChangeStatus()
{
// check if user has permissions to changeStatusCases
if (Yii::app()->user->checkAccess('changeStatusCases')) {
// verify is request was made via post ajax
if (Yii::app()->request->isAjaxRequest && isset($_POST)) {
// get Cases object model
$model = $this->loadModel($_REQUEST['id']);
// set new status
$model->status_id = $_POST['changeto'];
// validate and save
if ($model->save()) {
// save log
$attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CaseStatusChanged', 'log_resourceid' => $model->case_id, 'log_type' => Logs::LOG_UPDATED, 'user_id' => Yii::app()->user->id, 'module_id' => Yii::app()->controller->id, 'project_id' => $model->project_id);
Logs::model()->saveLog($attributes);
// create comment to let then know that some user change the case status
$modelComment = new Comments();
$modelComment->comment_date = date("Y-m-d G:i:s");
$modelComment->comment_text = Status::STATUS_COMMENT . ": " . $model->Status->status_id;
$modelComment->user_id = Yii::app()->user->id;
$modelComment->module_id = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $this->getId())))->module_id;
$modelComment->comment_resourceid = $model->case_id;
$modelComment->save(false);
// prepare email template for each project manager
Yii::import('application.extensions.phpMailer.yiiPhpMailer');
$mailer = new yiiPhpMailer();
$subject = Yii::t('email', 'CaseStatusChange') . " - " . $model->case_name;
//$Users = Users::model()->with('Clients')->findManagersByProject($model->project_id);
$Users = Projects::model()->findAllUsersByProject($model->project_id);
$recipientsList = array();
foreach ($Users as $client) {
$recipientsList[] = array('name' => $client->CompleteName, 'email' => $client->user_email);
}
// load template
$str = $this->renderPartial('//templates/cases/StatusChanged', array('case' => $model, 'user' => Users::model()->findByPk(Yii::app()->user->id), 'urlToCase' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->createUrl('cases/view', array('id' => $model->case_id)), 'typeNews' => $model->status_id == Status::STATUS_ACCEPTED || $model->status_id == Status::STATUS_TOREVIEW ? 'buenas' : 'malas', 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://" . $_SERVER['SERVER_NAME'] . Yii::app()->request->baseUrl), true);
$mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
$output = Yii::t('cases', 'StatusChanged');
} else {
$output = Yii::t('cases', 'StatusError');
}
echo $output;
Yii::app()->end();
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
} else {
throw new CHttpException(403, Yii::t('site', '403_Error'));
}
}
示例2: submitComment
public function submitComment()
{
$model = new Comments();
$model->submitComment();
// Now we redirect to the book, so it shows the new comment
header('Location: index.php?action=showbook&id=' . $_SESSION['bookid']);
}
示例3: newComment
public function newComment()
{
// POST İLE GÖNDERİLEN DEĞERLERİ ALALIM.
$postData = Input::all();
// FORM KONTROLLERİNİ BELİRLEYELİM
$rules = array('question_id' => 'required|integer', 'comment' => 'required');
// HATA MESAJLARINI OLUŞTURALIM
$messages = array('question_id.required' => 'İşleminiz yapılırken teknik bir sorun oluştu', 'question_id.integer' => 'İşleminiz yapılırken teknik bir sorun oluştu', 'comment.required' => 'Lütfen yanıtınızı yazın');
// KONTROL (VALIDATION) İŞLEMİNİ GERÇEKLEŞTİRELİM
$validator = Validator::make($postData, $rules, $messages);
// EĞER VALİDASYON BAŞARISIZ OLURSA HATALARI GÖSTERELİM
if ($validator->fails()) {
// KULLANICIYI SORU SAYFASINA GERİ GÖNDERELİM
return Redirect::to(URL::previous())->withErrors($validator->messages());
} else {
// SORUYU VERİTABANINA EKLEYELİM
$comment = new Comments();
$comment->user_id = Auth::user()->id;
$comment->question_id = $postData['question_id'];
$comment->comment = e(trim($postData['comment']));
$comment->created_at = date('Y-m-d H:i:s');
$comment->created_ip = Request::getClientIp();
$comment->save();
// KULLANICIYI YENİDEN SORUYA YÖNLENDİRELİM
return Redirect::to(URL::previous());
}
}
示例4: actionSave_comment
/**
* Добавление / редактирование комментариев
*/
public function actionSave_comment()
{
if (Yii::app()->user->isGuest) {
$this->redirect($this->createAbsoluteUrl('base'));
}
// Редактирование или добавление новой
if (isset($_GET['idComment'])) {
$model = Comments::model()->findByPk($_GET['idComment']);
} else {
$model = new Comments();
}
if (isset($_POST['idArticle']) && isset($_POST['text']) && isset($_POST['idAuthor'])) {
$model->idArticle = $_POST['idArticle'];
$model->text = $_POST['text'];
$model->idUser = empty($this->_user) ? Users::getIdUserForAdmin() : $this->_user['idUser'];
$model->typeUser = $model->idUser == $_POST['idAuthor'] ? 'author' : (empty($this->_user) ? 'admin' : 'user');
if ($model->save()) {
if (Yii::app()->request->isAjaxRequest) {
$criteria = new CDbCriteria();
$criteria->with = array('idUser0');
$criteria->condition = 'idArticle = :idArticle AND deleted = 0 AND public = 1';
$criteria->params = array(':idArticle' => $_POST['idArticle']);
$comments = Comments::model()->findAll($criteria);
$commentsDataProvider = new CArrayDataProvider($comments, array('keyField' => 'idComment', 'pagination' => array('pageSize' => 50)));
$listComments = $this->renderPartial('_list_comments', array('dataProvider' => $commentsDataProvider), true);
echo CJSON::encode(array('listComments' => $listComments));
exit;
}
}
}
}
示例5: module_most_commented
function module_most_commented($mod_reference, $module_params)
{
global $smarty;
global $commentslib;
if (!isset($commentslib)) {
include_once ('lib/comments/commentslib.php');
$commentslib = new Comments();
}
$type = 'wiki';
if (isset($module_params['objectType'])) {
$type = $module_params['objectType'];
if ($type != 'article' && $type != 'blog' && $type != 'wiki') {
//If parameter is not properly set then default to wiki
$type = 'wiki';
}
}
$result = $commentslib->order_comments_by_count($type, isset($module_params['objectLanguageFilter']) ? $module_params['objectLanguageFilter'] : '', $mod_reference['rows']);
if ($result === false) {
$smarty->assign('module_error', tra('Feature disabled'));
return;
}
$smarty->assign('modMostCommented', $result['data']);
$smarty->assign('modContentType', $type);
}
示例6: smarty_function_poll
function smarty_function_poll($params, &$smarty)
{
global $polllib;
global $dbTiki;
global $commentslib;
global $feature_poll_comments;
extract($params);
// Param = zone
if (!is_object($polllib)) {
include_once 'lib/polls/polllib_shared.php';
}
include_once 'lib/commentslib.php';
if (isset($rate)) {
if (!$tikilib->page_exists($rate)) {
return false;
}
}
if (empty($id)) {
$id = $polllib->get_random_active_poll();
}
if ($id) {
$menu_info = $polllib->get_poll($id);
$channels = $polllib->list_poll_options($id);
if ($feature_poll_comments == 'y') {
$commentslib = new Comments($dbTiki);
$comments_count = $commentslib->count_comments("poll:" . $menu_info["pollId"]);
}
$smarty->assign('comments', $comments_count);
$smarty->assign('ownurl', 'tiki-poll_results.php?pollId=' . $id);
$smarty->assign('menu_info', $menu_info);
$smarty->assign('channels', $channels);
$smarty->display('tiki-poll.tpl');
}
}
示例7: onmineAction
/** Comments on your records
*/
public function onmineAction()
{
$params = $this->_getAllParams();
$this->view->params = $params;
$comments = new Comments();
$this->view->comments = $comments->getCommentsOnMyRecords($this->getIdentityForForms(), $this->_getParam('page'), $this->_getParam('approval'));
}
示例8: actionSendMail
public function actionSendMail()
{
if (!empty($_POST)) {
Yii::import('ext.yii-mail.YiiMailMessage');
$message = new YiiMailMessage();
$message->setBody($_POST['content']);
$message->subject = $_POST['subject'];
$message->from = $_POST['email'];
$message->to = Yii::app()->params['adminEmail'];
if (Yii::app()->mail->send($message)) {
$model = new Comments();
$model->title = $_POST['subject'];
$model->content = $_POST['content'];
$model->email = $_POST['email'];
$model->name = $_POST['fullName'];
$model->phone = $_POST['phone'];
$model->created = time();
if ($model->save()) {
return jsonOut(array('error' => false, 'message' => 'Cảm ơn bạn đã gửi thông tin, chúng tôi sẽ phản hồi cho bạn trong thời gian sớm nhất!'));
} else {
return json_encode(array('error' => true, 'message' => 'Lỗi hệ thống, gửi thông tin không thành công.'));
}
} else {
return json_encode(array('error' => true, 'message' => 'Gửi thông tin không thành công'));
}
}
}
示例9: indexAction
public function indexAction()
{
// Get, check and setup the parameters
if (!($widget_id = $this->getRequest()->getParam("id"))) {
throw new Stuffpress_Exception("No widget id provided to the widget controller");
}
// Verify if the requested widget exist and get its data
$widgets = new Widgets();
if (!($widget = $widgets->getWidget($widget_id))) {
throw new Stuffpress_Exception("Invalid widget id");
}
// Get the last comments
$comments = new Comments(array(Stuffpress_Db_Table::USER => $widget['user_id']));
$mycomments = $comments->getLastComments();
$data = new Data();
// Prepare the comments for output
foreach ($mycomments as &$comment) {
$time = strtotime($comment['timestamp']);
$item = $data->getItem($comment['source_id'], $comment['item_id']);
$comment['item'] = $item;
$comment['when'] = Stuffpress_Date::ago($time, "j M y");
$comment['comment'] = str_replace("\n", " ", $comment['comment']);
if (strlen($comment['comment']) > 50) {
$comment['comment'] = mb_substr($comment['comment'], 0, 47) . "...";
}
}
// Get the widget properties
$properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
$title = $properties->getProperty('title');
$this->view->title = $title ? $title : "Latest comments";
// Prepare the view for rendering
$this->view->comments = $mycomments;
}
示例10: deleteComment
public function deleteComment(Comments $comment)
{
/** @var myModel $this */
if (method_exists($this, 'decreaseCount')) {
$this->decreaseCount('commentCount');
}
return $comment->delete();
}
示例11: actionView
/**
* Вывод инфы о бане
* @param integer $id ID бана
*/
public function actionView($id)
{
// Подгружаем комментарии и файлы
$files = new Files();
//$this->performAjaxValidation($files);
$files->unsetAttributes();
$comments = new Comments();
$comments->unsetAttributes();
// Подгружаем баны
$model = Bans::model()->with('admin')->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$geo = false;
// Проверка прав на просмотр IP
$ipaccess = Webadmins::checkAccess('ip_view');
if ($ipaccess) {
$geo = array('city' => 'Н/А', 'region' => 'Не определен', 'country' => 'Не определен', 'lat' => 0, 'lng' => 0);
$get = @file_get_contents('http://ipgeobase.ru:7020/geo?ip=' . $model->player_ip);
if ($get) {
$xml = @simplexml_load_string($get);
if (!empty($xml->ip)) {
$geo['city'] = $xml->ip->city;
$geo['region'] = $xml->ip->region;
$geo['country'] = $xml->ip->country;
$geo['lat'] = $xml->ip->lat;
$geo['lng'] = $xml->ip->lng;
}
}
}
// Добавление файла
if (isset($_POST['Files'])) {
// Задаем аттрибуты
$files->attributes = $_POST['Files'];
$files->bid = intval($id);
if ($files->save()) {
$this->refresh();
}
}
// Добавление комментария
if (isset($_POST['Comments'])) {
//exit(print_r($_POST['Comments']));
$comments->attributes = $_POST['Comments'];
$comments->bid = $id;
if ($comments->save()) {
$this->refresh();
}
}
// Выборка комментариев
$c = new CActiveDataProvider($comments, array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
// Выборка файлов
$f = new CActiveDataProvider(Files::model(), array('criteria' => array('condition' => 'bid = :bid', 'params' => array(':bid' => $id))));
// История банов
$history = new CActiveDataProvider('Bans', array('criteria' => array('condition' => '`bid` <> :hbid AND (`player_ip` = :hip OR `player_id` = :hid)', 'params' => array(':hbid' => $id, ':hip' => $model->player_ip, ':hid' => $model->player_id)), 'pagination' => array('pageSize' => 5)));
// Вывод всего на вьюху
$this->render('view', array('geo' => $geo, 'ipaccess' => $ipaccess, 'model' => $model, 'files' => $files, 'comments' => $comments, 'f' => $f, 'c' => $c, 'history' => $history));
}
示例12: saveCommentTo
/**
* 这里可以作为一个通用的保存评论的方法来使用
* @param myModel $model
* @param $data
*/
protected function saveCommentTo(myModel $model, $data)
{
$comment = new Comments();
$comment->content = $data['content'];
$comment->commentable_id = $model->id;
$comment->commentable_type = get_class($model);
$comment->user_id = $this->auth->id;
$comment->save();
}
示例13: editCommentAction
public function editCommentAction(Sites $site, Comments $comment)
{
if ($this->request->isPost()) {
$comment->update($this->request->getPost());
$this->redirectByRoute(['for' => 'sites.show', 'site' => $site->id]);
}
$this->view->comment = $comment;
$this->view->form = myForm::buildCommentForm($site, $comment);
}
示例14: editCommentAction
public function editCommentAction(Episodes $episode, Comments $comment)
{
if ($this->request->isPost()) {
$comment->update($this->request->getPost());
return $this->redirectByRoute(['for' => 'movies.showEpisode', 'movie' => $episode->getMovie()->id, 'episode' => $episode->id]);
}
$this->view->comment = $comment;
$this->view->form = myForm::buildCommentForm($episode, $comment);
}
示例15: feature_home_pages
/**
* Computes the alternate homes for each feature
* (used in admin general template)
*
* @access public
* @return array of url's and labels of the alternate homepages
*/
function feature_home_pages($partial = false)
{
global $prefs, $tikilib, $commentslib;
$tikiIndex = array();
//wiki
$tikiIndex['tiki-index.php'] = tra('Wiki');
// Articles
if (!$partial && $prefs['feature_articles'] == 'y') {
$tikiIndex['tiki-view_articles.php'] = tra('Articles');
}
// Blog
if (!$partial && $prefs['feature_blogs'] == 'y') {
if ($prefs['home_blog'] != '0') {
global $bloglib;
require_once 'lib/blogs/bloglib.php';
$hbloginfo = $bloglib->get_blog($prefs['home_blog']);
$home_blog_name = substr($hbloginfo['title'], 0, 20);
} else {
$home_blog_name = tra('Set blogs homepage first');
}
$tikiIndex['tiki-view_blog.php?blogId=' . $prefs['home_blog']] = tra('Blog:') . $home_blog_name;
}
// Image gallery
if (!$partial && $prefs['feature_galleries'] == 'y') {
if ($prefs['home_gallery'] != '0') {
$hgalinfo = $tikilib->get_gallery($prefs['home_gallery']);
$home_gal_name = substr($hgalinfo["name"], 0, 20);
} else {
$home_gal_name = tra('Set Image gal homepage first');
}
$tikiIndex['tiki-browse_gallery.php?galleryId=' . $prefs['home_gallery']] = tra('Image Gallery:') . $home_gal_name;
}
// File gallery
if (!$partial && $prefs['feature_file_galleries'] == 'y') {
$filegallib = TikiLib::lib('filegal');
$hgalinfo = $filegallib->get_file_gallery($prefs['home_file_gallery']);
$home_gal_name = substr($hgalinfo["name"], 0, 20);
$tikiIndex['tiki-list_file_gallery.php?galleryId=' . $prefs['home_file_gallery']] = tra('File Gallery:') . $home_gal_name;
}
// Forum
if (!$partial && $prefs['feature_forums'] == 'y') {
require_once 'lib/comments/commentslib.php';
if (!isset($commentslib)) {
$commentslib = new Comments();
}
if ($prefs['home_forum'] != '0') {
$hforuminfo = $commentslib->get_forum($prefs['home_forum']);
$home_forum_name = substr($hforuminfo['name'], 0, 20);
} else {
$home_forum_name = tra('Set Forum homepage first');
}
$tikiIndex['tiki-view_forum.php?forumId=' . $prefs['home_forum']] = tra('Forum:') . $home_forum_name;
}
// Custom home
$tikiIndex['tiki-custom_home.php'] = tra('Custom home');
return $tikiIndex;
}