当前位置: 首页>>代码示例>>PHP>>正文


PHP Comments::save方法代码示例

本文整理汇总了PHP中Comments::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::save方法的具体用法?PHP Comments::save怎么用?PHP Comments::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Comments的用法示例。


在下文中一共展示了Comments::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addComment

 public function addComment($data)
 {
     /** @var myModel $this */
     $comment = new Comments();
     $comment->content = $data['content'];
     $comment->commentable_id = $this->id;
     $comment->commentable_type = get_class($this);
     //        $comment->user_id = $this->getDI()->getShared('session')->get('auth')['id'];//获得当前登录对象的id
     $user = \Phalcon\Di::getDefault()->get('auth');
     $comment->user_id = $user->id;
     //获得当前登录对象的id
     //        dd($comment);
     $comment->save();
     /** @var myModel $this */
     if (method_exists($this, 'increaseCount')) {
         $this->increaseCount('commentCount');
     } else {
         $this->save();
         //更新时间
     }
     if (is_a($this, 'Tags')) {
         $meta = $this->getTagmetaOrNew();
         $meta->save();
     }
     return $this;
 }
开发者ID:huoybb,项目名称:standard,代码行数:26,代码来源:commentableTrait.php

示例2: 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'));
     }
 }
开发者ID:lanzelotik,项目名称:celestic-community,代码行数:52,代码来源:CasesController.php

示例3: addComment

 public function addComment($user_id, $post_id, $content)
 {
     $model = new Comments();
     $model->post_id = $post_id;
     $model->created_by = $user_id;
     $model->updated_at = time();
     $model->comment_content = $content;
     $model->status = 1;
     $model->created_at = time();
     $model->updated_at = time();
     $model->save(FALSE);
     $post = Posts::model()->findByPk($post_id);
     $post->post_comment_count++;
     $user = User::model()->findByPk($model->created_by);
     $user_commented = User::model()->findByPk($post->user_id);
     if ($user_commented) {
         if ($user->id != $post->user_id) {
             $users_have_commented = $this->getListUserCommentedOnPost($post_id);
             if ($users_have_commented) {
                 foreach ($users_have_commented as $item) {
                     if ($user_id != $item->created_by && $post->user_id != $item->created_by) {
                         $arr_noti_others = array('user_id' => $user->id, 'content' => "{$user->username} cũng đã bình luận bài viết của {$user_commented->username}", 'type' => 'comment_also', 'recipient_id' => $item->created_by, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
                         Notifications::model()->add($arr_noti_others);
                     }
                 }
             }
             $arr_noti = array('user_id' => $user->id, 'content' => "{$user->username} vừa bình luận bài viết của bạn", 'type' => 'comment', 'recipient_id' => $user_commented->id, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
             Notifications::model()->add($arr_noti);
         } else {
             $users_have_commented = $this->getListUserCommentedOnPost($post_id);
             if ($users_have_commented) {
                 foreach ($users_have_commented as $item) {
                     if ($user_id != $item->created_by) {
                         $arr_noti_others = array('user_id' => $user->id, 'content' => "{$user->username} cũng đã bình luận bài viết của họ", 'type' => 'comment_also', 'recipient_id' => $item->created_by, 'url' => Yii::app()->createAbsoluteUrl('post/viewPost', array('post_id' => $post_id, array('ref' => 'noti'))));
                         Notifications::model()->add($arr_noti_others);
                     }
                 }
             }
         }
     }
     if ($model->save(FALSE) && $post->save(FALSE)) {
         $returnArr = array();
         $returnArr['created_by'] = $model->created_by;
         $returnArr['username'] = $user->username;
         $returnArr['photo'] = StringHelper::generateUrlImage($user->photo);
         $returnArr['created_at'] = Util::time_elapsed_string($model->created_at);
         $returnArr['comment_content'] = $model->comment_content;
         return $returnArr;
     }
     return FALSE;
 }
开发者ID:huynt57,项目名称:fashion,代码行数:51,代码来源:Comments.php

示例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;
             }
         }
     }
 }
开发者ID:vitalya-xxx,项目名称:vitacod.ru,代码行数:34,代码来源:CommentsController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  * @param itemid <=== What?
  * @param itemtype
  * @param userid
  * @param string key
  * @return Response
  */
 public function store()
 {
     $itemid = Input::get('itemid');
     $itemtype = Input::get('itemtype');
     $userid = Input::get('userid');
     $usercomment = Input::get('comment');
     $key = Input::get('key');
     $retVal = array('status' => 'ERR', 'msg' => 'Invalid Session');
     try {
         $user = \Member::where('session_key', '=', $key)->exists();
         if (!$user) {
             return Response::json($retVal);
         }
         $media = \Media::where('_id', '=', $itemid)->exists();
         //var_dump($media);
         if (!$media) {
             $retVal = array('status' => 'ERR', 'msg' => 'Invalid item.');
             return Response::json($retVal);
         }
         $comment = new \Comments();
         $comment->itemid = $itemid;
         $comment->itemtype = $itemtype;
         $comment->userid = $userid;
         $comment->comment = $usercomment;
         $comment->save();
         $retVal = array('status' => 'OK');
         return Response::json($retVal);
     } catch (ModelNotFoundException $e) {
     }
 }
开发者ID:awidarto,项目名称:bilnatracker,代码行数:38,代码来源:CommentController.php

示例6: 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'));
         }
     }
 }
开发者ID:phiphi1992,项目名称:fpthue,代码行数:27,代码来源:ContactController.php

示例7: setAction

 public function setAction()
 {
     $post = ['name' => false, 'email' => false, 'comment' => true];
     if ($this->_status['response']['status'] && !$this->_getPost($post)) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 201;
         $this->_status['response']['detail'] = $post['empty'];
     }
     $urlId = $this->dispatcher->getParam('id');
     if (!$this->_status['response']['status'] && empty($urlId)) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 203;
     }
     $posts = Posts::findFirst($urlId);
     if ($this->_status['response']['status'] && !$posts) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 404;
     }
     if (!$this->_status['response']['status']) {
         return $this->response->setJsonContent($this->_status);
     }
     $comments = new Comments();
     $comments->assign(['posts_id' => $posts->id, 'name' => $this->_post['name'], 'email' => $this->_post['email'], 'comment' => $this->_post['comment']]);
     if (!$comments->save()) {
         $this->_status['response']['status'] = false;
         $this->_status['response']['code'] = 102;
     }
     return $this->response->setJsonContent($this->_status);
 }
开发者ID:gomasiyo,项目名称:cms,代码行数:29,代码来源:CommentController.php

示例8: indexAction

 public function indexAction()
 {
     if ($this->request->isPost()) {
         $comment = new Comments();
         $comment->setName($this->request->getPost('name'));
         $comment->setEmail($this->request->getPost('email'));
         $comment->setContent($this->request->getPost('comment'));
         //store comment on the comments table
         if ($comment->save() == false) {
             echo "These errors occurred: ";
             foreach ($comment->getMessages() as $msg) {
                 echo $msg;
             }
         } else {
             //store on the post_comments table
             $post_id = $this->request->getPost('id');
             $post_comment = new PostComments();
             $post_comment->setCommentId($comment->id());
             $post_comment->setPostId($post_id);
             if ($post_comment->save() == false) {
                 echo "These errors occurred: ";
                 foreach ($post_comment->getMessages() as $msg) {
                     echo $msg;
                 }
             } else {
                 return (new \Phalcon\Http\Response())->redirect('posts/post/' . $post_id);
             }
         }
     }
 }
开发者ID:poorman,项目名称:MyCMS,代码行数:30,代码来源:CommentController.php

示例9: 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());
     }
 }
开发者ID:burak-tekin,项目名称:laravel-ornek-uygulama,代码行数:27,代码来源:CommentsController.php

示例10: 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();
 }
开发者ID:huoybb,项目名称:movie,代码行数:14,代码来源:myController.php

示例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']) && !empty($_POST['Files']['name'])) {
         // Задаем аттрибуты
         $files->attributes = $_POST['Files'];
         $files->bid = intval($id);
         $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));
 }
开发者ID:BroneKot,项目名称:CS-Bans,代码行数:60,代码来源:BansController.php

示例12: addCommentBy

 public function addCommentBy(Users $user, $data)
 {
     $comment = new Comments();
     $comment->content = $data['content'];
     $comment->commentable_id = $this->id;
     $comment->commentable_type = get_class($this);
     $comment->user_id = $user->id;
     $comment->save();
     return $this;
 }
开发者ID:huoybb,项目名称:movie,代码行数:10,代码来源:commentableTrait.php

示例13: createComment

 /**
  * Creates a new comment
  * TODO: Figure out how to fix the email issues
  * @param  int  $id   The Comment id
  * @return array
  */
 private function createComment()
 {
     $model = new Comments();
     $model->attributes = $_POST;
     $model->approved = Cii::getConfig('autoApproveComments', 0);
     if ($model->save()) {
         return $model->getApiAttributes();
     }
     return $this->returnError(400, NULL, $model->getErrors());
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:16,代码来源:CommentController.php

示例14: actionAdd

 public function actionAdd()
 {
     $model = new Comments();
     if (isset($_POST['comments'])) {
         $model->attributes = $_POST['comments'];
         if ($model->save()) {
             $this->redirect($this->createUrl('comments/index'));
         }
     }
     $this->render('add', array('model' => $model));
 }
开发者ID:bashik,项目名称:empty,代码行数:11,代码来源:CommentsController.php

示例15: addLog

 static function addLog($input)
 {
     $comments = new Comments();
     $comments->customer_id = $input['customerId'];
     $comments->franchisee_id = Session::get('franchiseId');
     $comments->log_text = $input['logText'];
     $comments->created_by = "0";
     $comments->created_at = date("Y-m-d H:i:s");
     $comments->save();
     return $comments;
 }
开发者ID:Headrun-php,项目名称:TLG,代码行数:11,代码来源:Logs.php


注:本文中的Comments::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。