/** * 好友添加 */ public function actionAdd() { $model = new Friend(); $uid = Yii::app()->user->id; $fuid = Yii::app()->request->getParam('id'); $msg = ''; //不允许加自己好友 if ($fuid == $uid) { $msg = '不允许自己加自己好友'; } $t = Yii::app()->request->getParam('t'); //加好友的权限设置 if ($t != "agree") { //$model->__checkeFriendPrivacy($fuid); } //检查好友状态 $is_add = $model->checkFriendStatus($uid, $fuid); if ("1" === $is_add) { $msg = '你们已经是好友了'; } elseif ("0" === $is_add) { $msg = '等待验证中'; } //对方已经发过请求了,直接就加为好友 if ("0" === $model->checkFriendStatus($fuid, $uid)) { //并且弹出好友分组页面 //$model->__straightAddFrends($fuid,intval($_GET['nid'])); } $model->fuid = $fuid; if (isset($_POST['Friend'])) { $model->attributes = $_POST['Friend']; if ($model->save()) { $this->redirect(array('list')); } } $data = array('model' => $model, 'msg' => $msg); if (Yii::app()->request->isAjaxRequest) { $this->renderPartial('create', $data); } else { $this->render('create', $data); } }