Ejemplo n.º 1
0
 public function actionGetFriendType()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "uid=:uid OR uid = 0";
     $criteria->params = array(':uid' => Yii::app()->user->id);
     $models = FriendGroup::model()->findAll($criteria);
     echo '(' . CJSON::encode($models) . ')';
 }
Ejemplo n.º 2
0
 /**
  * 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 the primary key value. Defaults to null, meaning using the 'id' GET variable
  */
 public function loadFriendGroup($id = null)
 {
     if ($this->_model === null) {
         if ($id !== null || isset($_GET['id'])) {
             $this->_model = FriendGroup::model()->findbyPk($id !== null ? $id : $_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Ejemplo n.º 3
0
 /**
 * 获得用户的所有好友分组列表
 * @param unknown_type $uid
 * @return Ambigous <mixed, multitype:, NULL, unknown>
         //TODO cache
 */
 public function getFriendGroups($uid)
 {
     $key = "getFriendGroups_{$uid}";
     //Yii::app()->cache->delete($key);
     $resource = Yii::app()->cache->get($key);
     if ($resource !== false) {
         return $resource;
     }
     if (empty($uid)) {
         $uid = Yii::app()->user->id;
     }
     //初始化
     $criteria = new CDbCriteria();
     $criteria->order = 'id';
     $criteria->condition = "(uid=0 OR uid=:uid) AND id != 1";
     $criteria->params = array(':uid' => $uid);
     $model = new FriendGroup();
     $groups = $model->findAll($criteria);
     $resource = Yii::app()->cache->set($key, $groups);
     return $groups;
 }
Ejemplo n.º 4
0
 public function getUserFriendGroups()
 {
     //初始化
     $criteria = new CDbCriteria();
     $criteria->order = 'id';
     $criteria->condition = "uid=0 OR uid=:uid";
     $criteria->params = array(':uid' => Yii::app()->user->id);
     $model = new FriendGroup();
     $groups = $model->findAll($criteria);
     return $groups;
 }
Ejemplo n.º 5
0
 public function actionAddGroup()
 {
     $model = new FriendGroup();
     $model->scenario = 'add';
     if (isset($_POST['FriendGroup'])) {
         $model->attributes = $_POST['FriendGroup'];
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     }
     $data = array('model' => $model);
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('friendGroup', $data, '', TRUE, TRUE);
     } else {
         $this->render('friendGroup', $data);
     }
 }