public function actionAddComt() { $comtback = new comtback(); if (isset($_POST['newsid']) & isset($_POST['comtuserid']) & isset($_POST['parentcomtid']) & isset($_POST['comtcontent'])) { //用户积分修改 $u = user_load($_POST['comtuserid']); $edit = array('field_jifen' => array('und' => array(0 => array('value' => $u->field_jifen['und'][0]['value'] + 2)))); user_save($u, $edit); //drupal新增评论 $comment = (object) array('nid' => $_POST['newsid'], 'cid' => 0, 'pid' => $_POST['parentcomtid'], 'uid' => $_POST['comtuserid'], 'mail' => '', 'is_anonymous' => 0, 'homepage' => '', 'status' => 0, 'subject' => $_POST['comtcontent'], 'language' => LANGUAGE_NONE); comment_submit($comment); comment_save($comment); $comtback->comtid = $comment->cid; $comtback->comtcontent = $comment->subject; $comtback->error_code = 0; if ($_POST['parentcomtid'] != 0) { //评论别人的评论 $cominfo = new Cominfo(); $cominfo->uid = $_POST['comtuserid']; $cominfo->nid = $_POST['newsid']; /* $user=user_load($_POST['comtuserid']); //评论人头像 if($user->picture->uri=="") $cominfo->upic=BigImg.'user/basic.png'; else $cominfo->upic=str_replace("public://",BigImg,$user->picture->uri); //评论人昵称 $cominfo->uname=$user->name; */ //评论内容 $cominfo->ucontent = $_POST['comtcontent']; //父评论 $pcomment = comment_load($_POST['parentcomtid']); //父评论内容 //$cominfo->tocontent=$pcomment->subject; //父评论的所有者id $cominfo->toid = $pcomment->uid; $cominfo->save(false); } } else { $comtback->error_code = 1; $comtback->error_msg = "no enough input parameters"; } $jsonObj = CJSON::encode($comtback); echo $jsonObj; }
public function actionHeart($uid) { $criteria = new CDbCriteria(); $criteria->condition = 'toid=:toid' . ' AND isnew=:isnew'; $criteria->params = array(':toid' => $uid, ':isnew' => 1); $Cominfos = Cominfo::model()->findAll($criteria); $sql = "SELECT * FROM pm_index WHERE is_new=1 and recipient=" . $uid; $result = yii::app()->drupaldb->createCommand($sql); $sqls = $result->queryAll(); if ($Cominfos) { if (count($Cominfos) > 0) { $return['comment'] = 1; } else { $return['comment'] = 0; } } else { $return['comment'] = 0; } if ($sqls) { if (count($sqls) > 0) { $return['sysmgs'] = 1; } else { $return['sysmgs'] = 0; } } else { $return['sysmgs'] = 0; } $jsonObj = CJSON::encode($return); echo $jsonObj; }