Ejemplo n.º 1
0
 /**
  * displayEditProfilePictureFormSubmit 
  * 
  * @return void
  */
 function displayEditProfilePictureFormSubmit()
 {
     // Figure out where we are currently saving photos, and create new destination object
     $photoDestinationType = getDestinationType() . 'ProfileDestination';
     $photoDestination = new $photoDestinationType($this->fcmsError, $this->fcmsUser);
     $uploadPhoto = new UploadPhoto($this->fcmsError, $photoDestination);
     $profileUploader = new UploadProfile($this->fcmsError, $this->fcmsDatabase, $this->fcmsUser, $photoDestination, $uploadPhoto);
     $formData = $_POST;
     if (isset($_FILES['avatar'])) {
         $formData['avatar'] = $_FILES['avatar'];
     }
     if (!$profileUploader->upload($formData)) {
         $this->displayHeader();
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     $_SESSION['success'] = 1;
     header("Location: profile.php?view=picture");
 }
Ejemplo n.º 2
0
Archivo: index.php Proyecto: lmcro/fcms
 /**
  * displayFacebookUploadFormSubmit 
  * 
  * @return void
  */
 function displayFacebookUploadFormSubmit()
 {
     load('facebook');
     // Figure out where we are currently saving photos, and create new destination object
     $photoDestinationType = getDestinationType() . 'PhotoGalleryDestination';
     $photoDestination = new $photoDestinationType($this->fcmsError, $this->fcmsUser);
     $uploadPhoto = new UploadPhoto($this->fcmsError, $photoDestination);
     // Figure out what type of photo gallery uploader we are using, and create new object
     $photoGalleryType = getPhotoGallery();
     $photoGalleryUploader = new $photoGalleryType($this->fcmsError, $this->fcmsDatabase, $this->fcmsUser, $photoDestination, $uploadPhoto);
     $formData = array('photos' => $_POST['photos'], 'albums' => $_POST['albums'], 'newCategory' => $_POST['new-category']);
     $formData['category'] = isset($_POST['category']) ? $_POST['category'] : null;
     if (!$photoGalleryUploader->upload($formData)) {
         header('Location: index.php?action=upload&type=facebook');
         return;
     }
     $categoryId = $photoGalleryUploader->getLastCategoryId();
     header("Location: index.php?edit-category={$categoryId}&user=" . $this->fcmsUser->id);
 }
Ejemplo n.º 3
0
 /**
  * uploadAdvancedAvatar 
  * 
  * @return void
  */
 function uploadAdvancedAvatar()
 {
     // Figure out where we are currently saving photos, and create new destination object
     $photoDestinationType = getDestinationType() . 'ProfileDestination';
     $photoDestination = new $photoDestinationType($this->fcmsError, $this->fcmsUser);
     $uploadPhoto = new UploadPhoto($this->fcmsError, $photoDestination);
     $profileUploader = new UploadFamilyTree($this->fcmsError, $this->fcmsDatabase, $this->fcmsUser, $photoDestination, $uploadPhoto);
     $formData = $_POST;
     $formData['userid'] = (int) $_GET['advanced_avatar'];
     if (isset($_FILES['file'])) {
         $_FILES['file']['name'] = $_POST['name'];
         $formData['avatar'] = $_FILES['file'];
     } else {
         if (isset($_FILES['avatar'])) {
             $formData['avatar'] = $_FILES['avatar'];
         }
     }
     if (!$profileUploader->upload($formData)) {
         $this->displayHeader();
         $this->fcmsError->displayError();
         $this->displayFooter();
         return;
     }
     $_SESSION['success'] = 1;
 }
Ejemplo n.º 4
0
 /**
  * deletePhotos
  * 
  * Will delete an array of photos. Including removing the photo, and comments
  * from the db and also deleting the photo from the server.
  * 
  * @param array $ids
  * 
  * @return boolean
  */
 function deletePhotos(array $ids)
 {
     $in = implode(',', array_fill(0, count($ids), '?'));
     // Get photo info
     $sql = "SELECT `id`, `user`, `category`, `filename`, `external_id`\n                FROM `fcms_gallery_photos` \n                WHERE `id` IN ({$in})";
     $photos = $this->fcmsDatabase->getRows($sql, $ids);
     if ($photos === false) {
         return false;
     }
     $photoExternalIds = array();
     foreach ($photos as $photo) {
         $photoIds[] = $photo['id'];
         $photoFilenames[] = $photo['filename'];
         $photoUserIds[] = $photo['user'];
         $photoCategories[] = $photo['category'];
         if (!empty($photo['external_id'])) {
             $photoExternalIds[] = $photo['external_id'];
         }
     }
     $in = implode(',', array_fill(0, count($photoIds), '?'));
     // Remove the photos from the DB
     $sql = "DELETE FROM `fcms_gallery_photos` \n                WHERE `id` IN ({$in})";
     if (!$this->fcmsDatabase->delete($sql, $photoIds)) {
         return false;
     }
     // Remove any comments for these photos
     $sql = "DELETE FROM `fcms_gallery_photo_comment` \n                WHERE `photo` IN ({$in})";
     if (!$this->fcmsDatabase->delete($sql, $photoIds)) {
         return false;
     }
     // Remove external photos for these photos
     if (count($photoExternalIds) > 0) {
         $in = implode(',', array_fill(0, count($photoExternalIds), '?'));
         $sql = "DELETE FROM `fcms_gallery_external_photo`\n                    WHERE `id` IN ({$in})";
         if (!$this->fcmsDatabase->delete($sql, $photoExternalIds)) {
             return false;
         }
     }
     // Figure out where we are currently saving photos, and create new destination object
     $photoDestinationType = getDestinationType() . 'PhotoGalleryDestination';
     $photoDestination = new $photoDestinationType($this->fcmsError, $this->fcmsUser);
     // Remove these photos from the server
     foreach ($photoFilenames as $photoFilename) {
         $filePath = basename($photoFilename);
         $thumbPath = 'tb_' . basename($photoFilename);
         $fullPath = 'full_' . basename($photoFilename);
         $photoDestination->deleteFile($filePath);
         $photoDestination->deleteFile($thumbPath);
         $photoDestination->deleteFile($fullPath);
     }
     return true;
 }
Ejemplo n.º 5
0
Archivo: utils.php Proyecto: lmcro/fcms
/**
 * getAvatarPath 
 * 
 * @param string $avatar   no_avatar.jpg | gravatar | <filename>
 * @param string $gravatar email address for gravatar or ''
 * 
 * @return string
 */
function getAvatarPath($avatar, $gravatar)
{
    if ($avatar === 'gravatar') {
        return 'http://www.gravatar.com/avatar.php?gravatar_id=' . md5(strtolower($gravatar)) . '&amp;s=80';
    } else {
        if ($avatar === 'no_avatar.jpg') {
            return URL_PREFIX . 'uploads/avatar/no_avatar.jpg';
        }
    }
    $fcmsError = FCMS_Error::getInstance();
    $fcmsDatabase = Database::getInstance($fcmsError);
    $fcmsUser = new User($fcmsError, $fcmsDatabase);
    $destinationType = getDestinationType() . 'ProfileDestination';
    $destination = new $destinationType($fcmsError, $fcmsUser);
    return $destination->getPhotoSource($avatar);
}