Beispiel #1
0
 public function uploadAction()
 {
     if (!empty($_FILES)) {
         $file = (object) $_FILES['photo'];
         $id = (int) $_REQUEST['id'];
         if ($id !== 0) {
             $photo = RM_Photo::getById($id);
             if ($photo->getIdUser() === $this->_user->getId() || $this->_user->getRole()->isAdmin()) {
                 $photo->upload($file->tmp_name);
                 $photo->save();
             } else {
                 throw new Exception('NOT USER PHOTO ACCESS');
             }
         } else {
             $photo = RM_Photo::create($this->_user);
             $photo->upload($file->tmp_name);
             $photo->save();
         }
         $w = (int) $_REQUEST['w'];
         $h = (int) $_REQUEST['h'];
         $w = $w === 0 ? $photo->getWidth() : $w;
         $h = $h === 0 ? $photo->getHeight() : $h;
         echo json_encode(array('id' => $photo->getIdPhoto(), 'path' => $photo->getPath((int) $w, (int) $h), 'full_path' => $photo->getPath(), 'w' => $w, 'h' => $h));
     }
 }
 public function qqUploadAction()
 {
     $this->__disableView();
     $uploader = new RM_System_Uploader('qqfile', 1024 * 1024 * 8);
     $photo = RM_Photo::create($this->_user);
     $uploader->uploadPhoto($photo);
     $this->_saveGalleryPhoto($photo);
 }
Beispiel #3
0
 public function _createAvatar(RM_User_Profile $profile, $src)
 {
     $photo = RM_Photo::create($profile->getUser());
     $photo->upload($src);
     return $photo;
 }