本文整理汇总了PHP中Attachments::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachments::model方法的具体用法?PHP Attachments::model怎么用?PHP Attachments::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attachments
的用法示例。
在下文中一共展示了Attachments::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Attachments the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Attachments::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: getOne
/**
* 根据图片ID返回图片信息
* @param type $id
* @return boolean
*/
public static function getOne($id)
{
if (!$id || !is_numeric($id)) {
return false;
}
//todo,图片分表,将图片表分为attachments0~9
return Attachments::model()->findByPk($id);
}
示例3: actionStat
public function actionStat()
{
$posts = Posts::model()->count();
$commentsNum = Comments::model()->count();
$attachsNum = Attachments::model()->count();
$feedbackNum = Feedback::model()->count();
$arr = array('posts' => $posts, 'commentsNum' => $commentsNum, 'attachsNum' => $attachsNum, 'feedbackNum' => $feedbackNum);
$this->render('stat', $arr);
}
示例4: actionIndex
public function actionIndex()
{
$criteria = new CDbCriteria();
$criteria->order = 'cTime DESC';
$count = Attachments::model()->count($criteria);
$pager = new CPagination($count);
$pager->pageSize = 30;
$pager->applyLimit($criteria);
$posts = Attachments::model()->findAll($criteria);
foreach ($posts as $k => $val) {
$_img = Attachments::getUrl($val, 240);
$posts[$k]['filePath'] = $_img;
}
$this->render('index', array('pages' => $pager, 'posts' => $posts));
}
示例5: actionCreate
public function actionCreate($id = '')
{
if (!$this->uid) {
$this->redirect(array('site/login'));
}
if ($id) {
$model = $this->loadModel($id);
} else {
$model = new SiteInfo();
}
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['SiteInfo'])) {
$filter = Posts::handleContent($_POST['SiteInfo']['content']);
$_POST['SiteInfo']['content'] = $filter['content'];
if (!empty($filter['attachids'])) {
$attkeys = array_filter(array_unique($filter['attachids']));
if (!empty($attkeys)) {
$_POST['SiteInfo']['faceimg'] = $attkeys[0];
//默认将文章中的第一张图作为封面图
}
}
$model->attributes = $_POST['SiteInfo'];
if ($model->save()) {
//将上传的图片置为通过
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'siteinfo'));
if (!empty($attkeys)) {
$attstr = join(',', $attkeys);
if ($attstr != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
}
}
$this->redirect(array('siteinfo/view', 'code' => $model->code));
}
}
$this->render('/site/createSiteInfo', array('model' => $model));
}
示例6: check
/**
* 验证用户具体发帖权限,并不影响其他权限
* @param type $uid 验证的用户
* @param type $type 验证的类型
* @param type $field 是否检查总数
* @return type
*/
public static function check($type, $field = false, $uid = '')
{
if (!$uid) {
$uid = Yii::app()->user->id;
}
if (!$uid) {
if (zmf::config('officalUid')) {
return array('status' => 1, 'msg' => '');
}
return array('status' => 0, 'msg' => '用户不存在');
}
$uinfo = Users::getUserInfo($uid);
if (!$uinfo) {
return array('status' => 0, 'msg' => '用户不存在');
}
if (!$uinfo['groupid']) {
return array('status' => 0, 'msg' => '无组织用户');
}
$groupInfo = UserPower::model()->find('groupid=:gid', array(':gid' => $uinfo['groupid']));
if (!$groupInfo) {
return array('status' => 0, 'msg' => '无组织用户');
}
$num = $groupInfo->getAttribute($type);
if ($num === null) {
return array('status' => 0, 'msg' => '无法完成验证的type:' . $type);
} elseif ($num === 0) {
return array('status' => 0, 'msg' => '不允许');
} elseif ($field) {
switch ($field) {
case 'addPost':
$totalNum = $groupInfo['postNum'];
$hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'addQuestion':
$totalNum = $groupInfo['questionNum'];
$hasNum = Question::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'addAnswer':
$totalNum = $groupInfo['answerNum'];
$hasNum = Answer::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'addPoiPost':
$totalNum = $groupInfo['poiPostNum'];
$hasNum = PoiPost::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'addPoiTips':
$totalNum = $groupInfo['poiTipsNum'];
$hasNum = PoiTips::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'addImage':
$totalNum = $groupInfo['imageNum'];
$hasNum = Attachments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'addComment':
$totalNum = $groupInfo['commentNum'];
$hasNum = Comments::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'addPlan':
$totalNum = $groupInfo['planNum'];
$hasNum = Plans::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
case 'yueban':
$totalNum = $groupInfo['yuebanNum'];
$hasNum = Posts::model()->count('uid=:uid AND cTime>=:cTime', array(':uid' => $uid, ':cTime' => $ctime));
break;
}
if (!$totalNum) {
return array('status' => 1, 'msg' => '无限制');
} else {
if ($hasNum >= $totalNum) {
return array('status' => 0, 'msg' => '已超出限制:' . $totalNum);
} else {
return array('status' => 1, 'msg' => '');
}
}
} else {
return array('status' => 1, 'msg' => '');
}
}
示例7: text
public static function text($params, $content, $lazyload = true, $size = 600)
{
if (is_array($params)) {
$width = $params['imgwidth'];
$action = $params['action'];
$encode = $params['encode'];
}
if (!$width) {
$width = $size;
}
if ($action != 'edit') {
$content = tools::addcontentlink($content);
} else {
$lazyload = false;
}
if (strpos($content, '[attach]') !== false) {
preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $content, $match);
if (!empty($match[1])) {
foreach ($match[1] as $key => $val) {
$thekey = $match[0][$key];
$src = Attachments::model()->findByPk($val);
if ($src) {
$_imgurl = self::uploadDirs($src['cTime'], 'site', $src['classify'], $size) . $src['filePath'];
$imgurl = self::uploadDirs($src['cTime'], 'app', $src['classify'], $size) . $src['filePath'];
if ($lazyload) {
$filesize = getimagesize($imgurl);
if (empty($filesize)) {
$content = str_ireplace("{$thekey}", '', $content);
continue;
}
$imgurl = "<img src='" . self::lazyImg() . "' width='" . $filesize[0] . "px' height='" . $filesize[1] . "' class='lazy img-responsive' data-original='{$_imgurl}' " . ($action == 'edit' ? 'data="' . $src['id'] . '"' : '') . "/>";
} else {
$imgurl = "<img src='{$_imgurl}' class='img-responsive' " . ($action == 'edit' ? 'data="' . $src['id'] . '"' : '') . "/>";
}
$content = str_ireplace("{$thekey}", $imgurl, $content);
} else {
$content = str_ireplace("{$thekey}", '', $content);
}
}
}
}
$content = self::handleContent($content);
return $content;
}
示例8: addAds
public static function addAds($uid)
{
if (!$uid) {
return false;
}
$model = new Ads();
$thekeyid = zmf::filterInput($_POST['Ads']['id']);
$attachid = zmf::filterInput($_POST['Ads']['attachid'], 't', 1);
$intoData = $_POST['Ads'];
$intoData['attachid'] = $attachid;
$intoData['status'] = 1;
$intoData['uid'] = $uid;
if (isset($intoData['start_time'])) {
$intoData['start_time'] = strtotime($intoData['start_time']);
}
if (isset($intoData['expired_time'])) {
$intoData['expired_time'] = strtotime($intoData['expired_time']);
}
$model->attributes = $intoData;
if ($model->validate()) {
if ($model->updateByPk($thekeyid, $intoData)) {
zmf::delFCache("notSaveAds{$uid}");
if ($attachid) {
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), "logid={$thekeyid} AND uid={$uid} AND classify='ads'");
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED), "id={$attachid}");
}
return true;
} else {
$info = $_POST['Ads'];
}
} else {
$info = $_POST['Ads'];
}
return $info;
}
示例9: delUserContent
/**
* 删除用户发布的内容
* @param type $uid
* @param type $type
* @return boolean
*/
public static function delUserContent($uid, $type)
{
if (!$uid || !$type) {
return false;
}
switch ($type) {
case 'posts':
Posts::model()->updateAll(array('status' => Posts::STATUS_DELED), 'uid=:uid', array(':uid' => $uid));
break;
case 'tips':
PoiPost::model()->updateAll(array('status' => Posts::STATUS_DELED), 'uid=:uid', array(':uid' => $uid));
PoiTips::model()->updateAll(array('status' => Posts::STATUS_DELED), 'uid=:uid', array(':uid' => $uid));
break;
case 'questions':
Question::model()->updateAll(array('status' => Posts::STATUS_DELED), 'uid=:uid', array(':uid' => $uid));
break;
case 'answers':
Answer::model()->updateAll(array('status' => Posts::STATUS_DELED), 'uid=:uid', array(':uid' => $uid));
break;
case 'comments':
Comments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'uid=:uid', array(':uid' => $uid));
break;
case 'attaches':
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'uid=:uid', array(':uid' => $uid));
break;
case 'records':
//UserAction::model()->updateAll(array('status'=>Posts::STATUS_DELED),'uid=:uid',array(':uid'=>$uid));
break;
}
return true;
}
示例10: actionDelUploadImg
public function actionDelUploadImg($_attachid = '')
{
if (!empty($_attachid)) {
$attachid = $_attachid;
} else {
$attachid = zmf::filterInput($_POST['attachid'], 't', 1);
}
//$attachid=tools::jieMi($attachid);
if (!Yii::app()->request->isAjaxRequest) {
$this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
}
if (Yii::app()->user->isGuest) {
$this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
}
$info = Attachments::getOne($attachid);
if (!$info) {
$this->jsonOutPut(0, Yii::t('default', 'pagenotexists'));
}
if ($info['uid'] != Yii::app()->user->id and !$admin) {
$this->jsonOutPut(0, Yii::t('default', 'forbiddenaction'));
}
if ($info['classify'] == 'coverimg') {
$model = new Posts();
} elseif ($info['classify'] == 'columns') {
$model = new Columns();
} elseif ($info['classify'] == 'ads') {
$model = new Ads();
}
$dirs = zmf::uploadDirs($info['logid'], 'app', $info['classify']);
if (empty($dirs)) {
$this->jsonOutPut(0, Yii::t('default', 'unkownerror'));
}
foreach ($dirs as $dir) {
$filePath = $dir . '/' . $info['filePath'];
//$this->delItem($attchid, $filePath);
@unlink($filePath);
}
if (Attachments::model()->deleteByPk($attachid)) {
zmf::delFCache("attach{$attachid}");
if (isset($model)) {
$model->updateAll(array('attachid' => 0), 'id=:id', array(':id' => $info['logid']));
}
if ($admin) {
$this->jsonOutPut(1, '操作成功!');
} else {
$this->jsonOutPut(1, '操作成功!');
}
} else {
$this->jsonOutPut(0, '操作失败');
}
}
示例11: actionCreate
public function actionCreate($id = '')
{
$this->layout = 'common';
$id = zmf::myint($id);
if (!$this->uid) {
$this->redirect(array('site/login'));
}
if ($id) {
$model = $this->loadModel($id);
$isNew = false;
} else {
$model = new Posts();
$isNew = true;
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['Posts'])) {
//处理文本
$filter = Posts::handleContent($_POST['Posts']['content']);
$_POST['Posts']['content'] = $filter['content'];
if (!empty($filter['attachids'])) {
$attkeys = array_filter(array_unique($filter['attachids']));
if (!empty($attkeys)) {
$_POST['Posts']['faceimg'] = $attkeys[0];
//默认将文章中的第一张图作为封面图
}
} else {
$_POST['Posts']['faceimg'] = '';
//否则将封面图置为空(有可能编辑后没有图片了)
}
if (!$_POST['Posts']['mapZoom']) {
//没有缩放级别则认为用户只是点开看了一下
$_POST['Posts']['lat'] = $_POST['Posts']['long'] = '';
}
$tagids = array_unique(array_filter($_POST['tags']));
$model->attributes = $_POST['Posts'];
if ($model->save()) {
//将上传的图片置为通过
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
if (!empty($attkeys)) {
$attstr = join(',', $attkeys);
if ($attstr != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
}
}
//处理标签
$intoTags = array();
if (!empty($tagids)) {
foreach ($tagids as $tagid) {
$_info = Tags::addRelation($tagid, $model->id, 'posts');
if ($_info) {
$intoTags[] = $tagid;
}
}
}
if (!$isNew || !empty($intoTags)) {
Posts::model()->updateByPk($model->id, array('tagids' => join(',', $intoTags)));
}
if ($model->status == Posts::STATUS_NOTPASSED) {
$this->redirect(array('posts/index'));
} else {
$this->redirect(array('/posts/view', 'id' => $model->id));
}
}
}
$tags = Tags::getClassifyTags('posts');
$postTags = array();
if (!$isNew) {
$postTags = Tags::getByIds($model->tagids);
}
$this->pageTitle = '与世界分享你的旅行见闻 - ' . zmf::config('sitename');
$this->render('create', array('model' => $model, 'tags' => $tags, 'postTags' => $postTags));
}
示例12: actionCreate
/**
* 已取消其他文章类型,默认为游记
* @param type $classify,分类
*/
public function actionCreate($id = '')
{
$id = zmf::filterInput($id);
if (!zmf::uid()) {
$this->redirect(array('site/login'));
}
if ($id) {
$model = $this->loadModel($id);
if ($model->uid != zmf::uid()) {
if (!Users::checkPower('editpost', false, true)) {
throw new CHttpException(403, '不被允许的操作.');
}
}
} else {
$model = new Posts();
$model->classify = Posts::CLASSIFY_WEDDING;
//文章分类
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'posts-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['Posts'])) {
//判断是否应被禁止
//todo,应排除编辑
// $forbidInfo = Posts::isForbidden($_POST['Posts']['content'], 'post');
// if ($forbidInfo['status'] != Posts::STATUS_PASSED) {
// //todo,增加用户非法操作次数
// $_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
// }
//处理文本
$filter = Posts::handleContent($_POST['Posts']['content']);
$_POST['Posts']['content'] = $filter['content'];
foreach ($_POST['Posts'] as $k => $val) {
$_POST['Posts'][$k] = zmf::filterInput($val, 't');
}
if (Yii::app()->session['checkHasBadword'] == 'yes') {
$_POST['Posts']['status'] = Posts::STATUS_STAYCHECK;
}
if (!$model->isNewRecord) {
$_POST['Posts']['updateTime'] = zmf::now();
$isNew = false;
} else {
$isNew = true;
}
unset(Yii::app()->session['checkHasBadword']);
if (!empty($filter['attachids'])) {
$attkeys = array_filter(array_unique($filter['attachids']));
if (!empty($attkeys)) {
$_POST['Posts']['faceimg'] = $attkeys[0];
//默认将文章中的第一张图作为封面图
}
} else {
$_POST['Posts']['faceimg'] = '';
//否则将封面图置为空(有可能编辑后没有图片了)
}
//相关标签
$tags = $_POST['tagnames'];
$tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
$model->attributes = $_POST['Posts'];
if ($model->save()) {
//将上传的图片置为通过
Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'posts'));
if (!empty($attkeys)) {
$attstr = join(',', $attkeys);
if ($attstr != '') {
Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
}
}
//相关标签
$tagids = array();
if (!empty($tags)) {
foreach ($tags as $str) {
$_tmp = explode('-', $str);
if ($_tmp[1] > 0) {
//添加对应关系
if (Tags::addRelation($_tmp[1], $model->id, 'posts')) {
$tagids[] = $_tmp[1];
}
} else {
//查找是否有对应话题
$_tagid = Tags::findAndAdd($_tmp[0], 'posts', $model->id);
if ($_tagid) {
$tagids[] = $_tagid;
}
}
}
$tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
$tagStr = join(',', $tagids);
if ($tagStr != '') {
Posts::model()->updateByPk($model->id, array('tagids' => $tagStr));
}
}
$this->redirect(array('view', 'id' => $model->id));
}
}
//.........这里部分代码省略.........
示例13: foreachNaodong
private function foreachNaodong($posts)
{
if (!empty($posts)) {
$uids = array_keys(CHtml::listData($posts, 'uid', ''));
$usersInfo = array();
if (!empty($uids)) {
$uidstr = join(',', $uids);
$items = Users::model()->findAll(array('condition' => "id IN({$uidstr}) AND status=" . Posts::STATUS_PASSED, 'select' => "id,truename"));
$usersInfo = CHtml::listData($items, 'id', 'truename');
}
$imgsize = 600;
if ($this->isMobile == 'yes') {
$imgsize = 170;
}
foreach ($posts as $k => $v) {
if ($v['attachid'] > 0) {
$_attach = Attachments::model()->findByPk($v['attachid']);
$_url = Attachments::getUrl($_attach, $imgsize);
$posts[$k]['attachid'] = $_url;
} else {
$posts[$k]['attachid'] = '';
}
$posts[$k]['truename'] = $usersInfo[$v['uid']];
}
}
return $posts;
}
示例14: actionView
public function actionView($id)
{
$id = zmf::filterInput($id);
$info = $this->loadModel($id);
if ($info['redirect'] > 0) {
$this->redirect(array('position/view', 'id' => $info['redirect']));
}
$_title = '';
if ($info['title_cn'] != '') {
$_title = $info['title_cn'];
}
if ($info['title_en'] != '' && $_title != '') {
$_title .= '(' . $info['title_en'] . ')';
} elseif ($info['title_local'] && $_title != '') {
$_title .= '(' . $info['title_local'] . ')';
} elseif ($info['title_en'] != '') {
$_title .= $info['title_en'];
} else {
$_title .= $info['title_local'];
}
$_address = '';
if ($info['address_cn'] != '') {
$_address = $info['address_cn'];
} elseif ($info['address_en'] != '') {
$_address = $info['address_en'];
} else {
$_address = $info['address_local'];
}
if (!Yii::app()->user->isGuest) {
if (Favorites::checkFavored($id, 'poi')) {
$this->favorited = true;
}
$tipinfo = PoiPost::model()->findByAttributes(array('logid' => $id, 'uid' => Yii::app()->user->id), 'status=' . Posts::STATUS_PASSED);
if ($tipinfo) {
$this->tiped = $tipinfo;
}
}
$info->faceimg = Attachments::faceImg($info, 600);
//获取图片
$images = Attachments::model()->findAll(array('condition' => "logid=:id AND " . ($info['faceimg'] > 0 ? "id!=" . $info['faceimg'] . ' AND ' : '') . " classify='poi' AND status=" . Posts::STATUS_PASSED, 'select' => 'id,filePath,classify,cTime', 'limit' => 6, 'order' => 'favor DESC', 'params' => array(':id' => $id)));
$breads = array();
$breads[] = CHtml::link('目的地', array('position/index'));
if ($info['areaid']) {
$areaInfo = Area::model()->findByPk($info['areaid']);
if ($areaInfo) {
$breads[] = CHtml::link($areaInfo['title'], array('position/index', 'areaid' => $areaInfo['id']));
}
}
//获取购买地址
$buylinks = array();
if ($info['classify'] == Position::HOTEL) {
$buylinks = Buylink::getAll('poi', $info->id);
}
//更新访问统计
Posts::updateCount($id, 'Position');
$breads[] = $_title;
$this->pageTitle = $_title . ' - ' . zmf::config('sitename');
$this->pageDescription = '【' . $_title . '】位于' . $_address . ',' . zmf::subStr($info['content'], 200);
$this->render('view', array('info' => $info, 'type' => $type, 'breads' => $breads, 'buylinks' => $buylinks, 'images' => $images));
}
示例15: 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');
//.........这里部分代码省略.........