Beispiel #1
0
 /**
  * Deletes the profile image or profile banner
  */
 public function actionDeleteProfileImage()
 {
     $this->forcePostRequest();
     $space = $this->getSpace();
     //$space->getProfileImage()->delete();
     $type = Yii::app()->request->getParam('type', 'profile');
     $json = array('type' => $type);
     $image = NULL;
     if ($type == 'profile') {
         $image = new ProfileImage($space->guid, 'default_space');
     } elseif ($type == 'banner') {
         $image = new ProfileBannerImage($space->guid);
     }
     if ($image) {
         $image->delete();
         $json['defaultUrl'] = $image->getUrl();
     }
     $this->renderJson($json);
 }
Beispiel #2
0
 /**
  * Handle the banner image upload
  */
 public function actionBannerImageUpload()
 {
     $model = new UploadProfileImageForm();
     $json = array();
     $files = CUploadedFile::getInstancesByName('bannerfiles');
     $file = $files[0];
     $model->image = $file;
     if ($model->validate()) {
         $json['error'] = false;
         $profileImage = new ProfileBannerImage(Yii::app()->user->guid);
         $profileImage->setNew($model->image);
         $json['name'] = "";
         $json['url'] = $profileImage->getUrl();
         $json['size'] = $model->image->getSize();
         $json['deleteUrl'] = "";
         $json['deleteType'] = "";
     } else {
         $json['error'] = true;
         $json['errors'] = $model->getErrors();
     }
     return $this->renderJson(array('files' => $json));
 }