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


PHP Comments::validate方法代码示例

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


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

示例1: processRequest

 public function processRequest($model)
 {
     $comment = new Comments();
     $request = Yii::app()->request;
     $pkAttr = $model->getObjectPkAttribute();
     if ($request->isPostRequest && $request->isAjaxRequest) {
         $comment->attributes = $request->getPost('Comments');
         $comment->model = $model->getModelName();
         $comment->owner_title = $model->getOwnerTitle();
         $comment->object_id = $model->{$pkAttr};
         if ($comment->validate()) {
             $comment->saveNode();
             echo CJSON::encode(array('success' => 'OK'));
             Yii::app()->end();
             Yii::app()->session['caf'] = time();
         }
     }
     return $comment;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:19,代码来源:CommentsModule.php

示例2: actionAddcomment

 public function actionAddcomment()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(2, Yii::t('default', 'loginfirst'));
     } else {
         $uid = zmf::uid();
     }
     //        $checkInfo = UserPower::check('addComment', true);
     //        if (!$checkInfo['status']) {
     //            $this->jsonOutPut(0, $checkInfo['msg']);
     //        }
     $keyid = zmf::filterInput($_POST['k']);
     $to = zmf::filterInput($_POST['to']);
     $type = zmf::filterInput($_POST['t'], 't', 1);
     $content = zmf::filterInput($_POST['c'], 't', 1);
     if (!isset($type) or !in_array($type, array('naodong'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (!isset($keyid) or !is_numeric($keyid)) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists') . '--1');
     }
     if (!$content) {
         $this->jsonOutPut(0, '评论不能为空哦~');
     }
     $status = Posts::STATUS_PASSED;
     //判断是否应被禁止
     //        $forbidInfo = Posts::isForbidden($content, 'comment');
     //        if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
     //            //todo,增加用户非法操作次数
     //            $status = Posts::STATUS_STAYCHECK;
     //        }
     //处理文本
     $filter = Posts::handleContent($content);
     $content = $filter['content'];
     if (Yii::app()->session['checkHasBadword'] == 'yes') {
         $status = Posts::STATUS_STAYCHECK;
     }
     $model = new Comments();
     $ainfo = Posts::getSimpleInfo(array('keyid' => $keyid, 'origin' => strtolower($type)));
     if (!$ainfo) {
         $this->jsonOutPut(0, Yii::t('default', 'contentnotexists') . '--' . $type);
     }
     $toNotice = true;
     if ($ainfo['uid'] == $uid) {
         $toNotice = false;
     }
     $touid = $ainfo['uid'];
     if ($to) {
         $comInfo = Posts::getSimpleInfo(array('keyid' => $to, 'origin' => 'comments'));
         if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
             $to = '';
         } elseif ($comInfo['uid'] == $uid) {
             $toNotice = false;
         } else {
             $touid = $comInfo['uid'];
             $toNotice = true;
         }
     }
     $intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => $this->platform, 'tocommentid' => $to, 'status' => $status);
     unset(Yii::app()->session['checkHasBadword']);
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->save()) {
             if ($type == 'naodong') {
                 Posts::updateCount($keyid, 'Naodong', 1, 'comments');
                 $_url = CHtml::link('查看详情', array('index/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 $_content = '您的作品有了新的评论,' . $_url;
             }
             if ($to && $_url) {
                 $_content = '您的评论有了新的回复,' . $_url;
             }
             if ($toNotice) {
                 $_noticedata = array('uid' => $touid, 'authorid' => $uid, 'content' => $_content, 'new' => 1, 'type' => 'comment', 'cTime' => zmf::now(), 'from_id' => $keyid, 'from_num' => 1);
                 Notification::add($_noticedata);
             }
             $html = $this->renderPartial('//comments/_comment', array('data' => $model), true);
             $this->jsonOutPut(1, $html);
         } else {
             $this->jsonOutPut(0, '新增评论失败');
         }
     } else {
         $this->jsonOutPut(0, '新增评论失败');
     }
 }
开发者ID:ph7pal,项目名称:naodong,代码行数:87,代码来源:AjaxController.php

示例3: actionAddComment

 public function actionAddComment()
 {
     $keyid = zmf::val('k', 2);
     $to = zmf::val('to', 2);
     $type = zmf::val('t', 1);
     $content = zmf::val('c', 1);
     $email = zmf::val('email', 1);
     $username = zmf::val('username', 1);
     if (!isset($type) or !in_array($type, array('posts'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (!isset($keyid) or !is_numeric($keyid)) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!$content) {
         $this->jsonOutPut(0, '评论不能为空哦~');
     }
     if ($this->uid) {
         $status = Posts::STATUS_PASSED;
         $uid = $this->uid;
     } else {
         if (!$username) {
             $this->jsonOutPut(0, '请填写称呼');
         }
         zmf::setCookie('noLoginUsername', $username, 2592000);
         if ($email != '') {
             $validator = new CEmailValidator();
             if (!$validator->validateValue($email)) {
                 $this->jsonOutPut(0, '请填写正确的邮箱地址');
             }
             zmf::setCookie('noLoginEmail', $email, 2592000);
         }
         $status = Posts::STATUS_STAYCHECK;
         $uid = 0;
         if (zmf::actionLimit($type, $keyid, 5, 86400, true)) {
             $this->jsonOutPut(0, '操作太频繁,请稍后再试');
         }
     }
     $postInfo = Posts::model()->findByPk($keyid);
     if (!$postInfo || $postInfo['status'] != Posts::STATUS_PASSED) {
         $this->jsonOutPut(0, '您所评论的内容不存在');
     }
     //处理文本
     $filter = Posts::handleContent($content);
     $content = $filter['content'];
     $model = new Comments();
     $toNotice = true;
     $touid = $postInfo['uid'];
     if ($to) {
         $comInfo = Comments::model()->findByPk($to);
         if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
             $to = '';
         } elseif ($comInfo['uid'] == $uid) {
             $toNotice = false;
         } else {
             $touid = $comInfo['uid'] > 0 ? $comInfo['uid'] : '';
             $toNotice = true;
         }
     }
     $intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => '', 'tocommentid' => $to, 'status' => $status, 'username' => $username, 'email' => $email);
     unset(Yii::app()->session['checkHasBadword']);
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->save()) {
             if ($type == 'posts') {
                 $_url = CHtml::link('查看详情', array('posts/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 if ($status == Posts::STATUS_PASSED) {
                     Posts::updateCommentsNum($keyid);
                 }
                 $_content = '您的文章有了新的评论,' . $_url;
             }
             if ($to && $_url) {
                 $_content = '您的评论有了新的回复,' . $_url;
             }
             if ($toNotice) {
                 $_noticedata = array('uid' => $touid, 'authorid' => $uid, 'content' => $_content, 'new' => 1, 'type' => 'comment', 'cTime' => zmf::now(), 'from_id' => $model->id, 'from_num' => 1);
                 Notification::add($_noticedata);
             }
             if ($uid) {
                 $intoData['loginUsername'] = $this->userInfo['truename'];
             }
             $html = $this->renderPartial('/posts/_comment', array('data' => $intoData, 'postInfo' => $postInfo), true);
             $this->jsonOutPut(1, $html);
         } else {
             $this->jsonOutPut(0, '新增评论失败');
         }
     } else {
         $this->jsonOutPut(0, '新增评论失败');
     }
 }
开发者ID:ph7pal,项目名称:momo,代码行数:90,代码来源:AjaxController.php

示例4: actionCreate

 public function actionCreate()
 {
     $owner_title = $_POST['owner_title'];
     $modelName = $_POST['model'];
     $objID = $_POST['object_id'];
     $comment = new Comments();
     $request = Yii::app()->request;
     if ($request->isPostRequest && $request->isAjaxRequest) {
         $comment->attributes = $request->getPost('Comments');
         $comment->model = $modelName;
         $comment->owner_title = $owner_title;
         $comment->object_id = $objID;
         if ($comment->validate()) {
             $comment->saveNode();
             echo CJSON::encode(array('success' => true, 'message' => 'Комментарий будет опубликован после проверки'));
             Yii::app()->end();
             Yii::app()->session['caf'] = CMS::time();
         }
     }
     return $comment;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:21,代码来源:DefaultController.php

示例5: addComment

 public function addComment($params = array())
 {
     extract($params);
     if (isset($dynamic_id) && isset($user_id) && $user_id && $dynamic_id) {
         $comment = array('dynamic_id' => $dynamic_id, 'user_id' => $user_id);
         if (isset($content) && $content) {
             $comment['content'] = $content;
         }
         if (isset($image) && $image) {
             if (!is_null(json_decode($image))) {
                 $images = json_decode($image);
                 $comment['images'] = implode(',', $images);
             } else {
                 $comment['images'] = $image;
             }
         }
         if (isset($content) && $content || isset($image) && $image) {
             $model = new Comments();
             $model->attributes = $comment;
             if ($model->validate() && $model->save()) {
                 $ret = $this->notice('OK', 0, '成功', []);
             } else {
                 $ret = $this->notice('ERR', 307, '操作数据错误', $model->getErrors());
             }
         } else {
             $ret = $this->notice('ERR', 303, '没有评论内容', []);
         }
     } else {
         $ret = $this->notice('ERR', 301, '缺少关键参数', []);
     }
     return $ret;
 }
开发者ID:kl0428,项目名称:urtime,代码行数:32,代码来源:AllianceService.php

示例6: actionAfterPost

 public function actionAfterPost($st_id, $c_id, $j_id, $pr_id)
 {
     $model = new Comments();
     // uncomment the following code to enable ajax-based validation
     /*
     if(isset($_POST['ajax']) && $_POST['ajax']==='job-profile-_form-form')
     {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     */
     if (isset($_POST['Comments'])) {
         $model->txt = $_POST['Comments']['txt'];
         $model->st_id = $st_id;
         $model->c_id = $c_id;
         $model->j_id = $j_id;
         $model->pr_id = Yii::App()->user->id;
         if ($model->validate()) {
             // form inputs are valid, do something here
             $model->save();
             Yii::app()->user->setFlash('success', 'Comment Posted Successfully ');
             $this->redirect(array('index'));
             return;
         } else {
             var_dump($model->getErrors());
             echo 'validation problem';
         }
     }
 }
开发者ID:shobhit6993,项目名称:Placement-Portal,代码行数:29,代码来源:PlacementRepController.php

示例7: actionComment

 /**
  * 写评论
  */
 public function actionComment()
 {
     if (!Yii::app()->request->isAjaxRequest) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (Yii::app()->user->isGuest) {
         $this->jsonOutPut(2, Yii::t('default', 'loginfirst'));
     } else {
         $uid = zmf::uid();
     }
     $checkInfo = UserPower::check('addComment', true);
     if (!$checkInfo['status']) {
         $this->jsonOutPut(0, $checkInfo['msg']);
     }
     $keyid = zmf::filterInput($_POST['k']);
     $to = zmf::filterInput($_POST['to']);
     $type = zmf::filterInput($_POST['t'], 't', 1);
     $content = zmf::filterInput($_POST['c'], 't', 1);
     if (!isset($type) or !in_array($type, array('attachments', 'posts', 'poipost', 'poitips', 'question', 'answer', 'yueban', 'goods'))) {
         $this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
     }
     if (!isset($keyid) or !is_numeric($keyid)) {
         $this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
     }
     if (!$content) {
         $this->jsonOutPut(0, '评论不能为空哦~');
     }
     $status = Posts::STATUS_PASSED;
     //判断是否应被禁止
     //        $forbidInfo = Posts::isForbidden($content, 'comment');
     //        if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
     //            //todo,增加用户非法操作次数
     //            $status = Posts::STATUS_STAYCHECK;
     //        }
     //处理文本
     $filter = Posts::handleContent($content);
     $content = $filter['content'];
     if (Yii::app()->session['checkHasBadword'] == 'yes') {
         $status = Posts::STATUS_STAYCHECK;
     }
     $model = new Comments();
     $ainfo = Posts::getSimpleInfo(array('keyid' => $keyid, 'origin' => strtolower($type)));
     if (!$ainfo) {
         $this->jsonOutPut(0, Yii::t('default', 'contentnotexists'));
     }
     $toNotice = true;
     if ($ainfo['uid'] == $uid) {
         $toNotice = false;
     }
     //当为商品评论且不是回复某人时,不提醒发布商品的人
     if ($type == 'goods' && !$to) {
         $toNotice = false;
     }
     $touid = $ainfo['uid'];
     if ($to) {
         $comInfo = Posts::getSimpleInfo(array('keyid' => $to, 'origin' => 'comments'));
         if (!$comInfo || $comInfo['status'] != Posts::STATUS_PASSED) {
             $to = '';
         } elseif ($comInfo['uid'] == $uid) {
             $toNotice = false;
         } else {
             $touid = $comInfo['uid'];
             $toNotice = true;
         }
     }
     $intoData = array('logid' => $keyid, 'uid' => $uid, 'content' => $content, 'cTime' => zmf::now(), 'classify' => $type, 'platform' => $this->platform, 'tocommentid' => $to, 'status' => $status);
     unset(Yii::app()->session['checkHasBadword']);
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->save()) {
             if ($type == 'answer') {
                 Answer::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 $_content = '您的回答有了新的评论,' . $_url;
             } elseif ($type == 'poitips') {
                 PoiTips::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_url = CHtml::link('查看详情', array('question/answer', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 $_content = '您的短评有了新的评论,' . $_url;
             } elseif ($type == 'poipost') {
                 $_url = CHtml::link('查看详情', array('poipost/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 PoiPost::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的点评有了新的评论,' . $_url;
             } elseif ($type == 'question') {
                 $_url = CHtml::link('查看详情', array('question/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Question::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的提问有了新的评论,' . $_url;
             } elseif ($type == 'posts') {
                 $_url = CHtml::link('查看详情', array('posts/index', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Posts::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的文章有了新的评论,' . $_url;
             } elseif ($type == 'attachments') {
                 $_url = CHtml::link('查看详情', array('attachments/view', 'id' => $keyid, '#' => 'pid-' . $model->id));
                 Attachments::model()->updateCounters(array('comments' => 1), 'id=:id', array(':id' => $keyid));
                 $_content = '您的图片有了新的评论,' . $_url;
             } elseif ($type == 'yueban') {
                 $_url = CHtml::link('查看详情', array('yueban/index', 'areaid' => $ainfo['toAreaid'], 'year' => zmf::time($ainfo['startTime'], 'Y'), 'month' => zmf::time($ainfo['startTime'], 'm'), 'day' => zmf::time($ainfo['startTime'], 'd')));
                 Posts::updateCount($keyid, 'UserYueban', 1, 'comments');
//.........这里部分代码省略.........
开发者ID:ph7pal,项目名称:wedding,代码行数:101,代码来源:AjaxController.php


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