예제 #1
0
 /**
  * 根据GEOHASH编码得到附近的人
  * @param  string  $geohashCode 
  * @return  array  $arr
  */
 public function getNearPerson($geohashCode)
 {
     $neighbors = $this->geohash->neighbors($geohashCode);
     array_push($neighbors, $geohashCode);
     $criteria = new CDbCriteria();
     $criteria->addInCondition('geohash', array_values($neighbors));
     $states = UserState::model()->findAll($criteria);
     $arr = array();
     foreach ($states as $key => $value) {
         $arr[$key] = $value->userId;
     }
     return $arr;
 }
예제 #2
0
 /**
  *
  * @param
  * @param
  * @return
  */
 public function stateChange($userId, array $data)
 {
     $username = User::model()->findByPk($userId)->username;
     $avatar0 = User::model()->findByPk($userId)->avatar0;
     $model = UserState::model()->findByPk($userId);
     if (array_key_exists('userId', $data)) {
         unset($data['userId']);
     }
     $model->attributes = $data;
     if (!empty($model->attributes)) {
         $model->save();
         $data = $model->attributes;
         $data['username'] = $username;
         $data['avatar0'] = $avatar0;
         foreach ($data as $key => $value) {
             Yii::app()->user->setState($key, $value);
         }
         return true;
     }
 }
예제 #3
0
 private function upload($model, $attribute = 'file')
 {
     $file = array();
     $attach = CUploadedFile::getInstance($model, $attribute);
     if ($attach) {
         if ('jpg' == $attach->extensionName || 'png' == $attach->extensionName || 'gif' == $attach->extensionName) {
             $model->type = '1';
         }
         if ($attach->extensionName == 'amr' || $attach->extensionName == 'caf') {
             $model->type = '2';
         }
         $preRand = $model->receiver . time() . '.';
         $imageName = $preRand . $attach->extensionName;
         $file['origin'] = $imageName;
         $attach->saveAs($this->savePath . $imageName);
         if ($attach->extensionName != 'amr' && $attach->extensionName != 'caf') {
             $thumb = Yii::app()->thumb;
             $thumb->image = $this->savePath . $imageName;
             $size = getimagesize($thumb->image);
             $width = $size[0];
             $height = $size[1];
             $thumb->width = $width / 2;
             $thumb->height = $height / 2;
             $thumb->mode = 4;
             $thumb->directory = $this->savePath;
             $thumb->defaultName = '_' . $preRand;
             $thumb->createThumb();
             $thumb->save();
             if (UserState::model()->findByPk($model->receiver)->type == 0) {
                 $file['thumb'] = $thumb->defaultName . $attach->extensionName;
             }
         }
         return $file;
     } else {
         return '';
     }
 }