Ejemplo n.º 1
0
 function cmdNewAlbum($pParamHash)
 {
     global $gBitUser;
     $response = array();
     if (empty($pParamHash['newAlbumTitle'])) {
         $pParamHash['newAlbumTitle'] = $gBitUser->getTitle() . "'s Gallery";
     }
     $storeHash['title'] = !empty($pParamHash['newAlbumTitle']) ? $pParamHash['newAlbumTitle'] : '';
     $storeHash['edit'] = !empty($pParamHash['newAlbumDesc']) ? $pParamHash['newAlbumDesc'] : '';
     $gallery = new FisheyeGallery();
     $gallery->store($storeHash);
     if ($pParamHash['set_albumName']) {
         $parentGallery = new FisheyeGallery();
         if ($parentGallery = $parentGallery->lookup(array('content_id' => $pParamHash['set_albumName']))) {
             $parentGallery->load();
             $gallery->addToGalleries(array($parentGallery->mGalleryId));
         }
     }
     $response = $this->createResponse(FEG2REMOTE_SUCCESS, 'Gallery created', array('album_name' => $storeHash['title']));
     return $response;
 }
Ejemplo n.º 2
0
function fisheye_process_ftp_directory($pProcessDir)
{
    global $gBitSystem, $gBitUser;
    if (empty($_REQUEST['gallery_additions'])) {
        $_REQUEST['gallery_additions'] = array();
    }
    $errors = array();
    if ($archiveDir = opendir($pProcessDir)) {
        $order = 100;
        while ($fileName = readdir($archiveDir)) {
            $sortedNames[] = $fileName;
        }
        sort($sortedNames);
        $order = 100;
        foreach ($sortedNames as $fileName) {
            if (!preg_match('/^\\./', $fileName) && $fileName != 'Thumbs.db') {
                $scanFile = array('type' => $gBitSystem->lookupMimeType(substr($fileName, strrpos($fileName, '.') + 1)), 'name' => $fileName, 'size' => filesize("{$pProcessDir}/{$fileName}"), 'tmp_name' => "{$pProcessDir}/{$fileName}");
                if (is_dir($pProcessDir . '/' . $fileName)) {
                    // create a new gallery from directory
                    $dirGallery = new FisheyeGallery();
                    $galleryHash = array('title' => str_replace('_', ' ', $fileName));
                    if ($dirGallery->store($galleryHash)) {
                        $dirGallery->addToGalleries($_REQUEST['gallery_additions']);
                        $errors = array_merge($errors, fisheye_process_directory($pProcessDir . '/' . $fileName, $dirGallery));
                    } else {
                        $errors = array_merge($errors, array_values($dirGallery->mErrors));
                    }
                    unset($dirGallery);
                } else {
                    if (preg_match('/(^image|pdf)/i', $scanFile['type'])) {
                        // process image
                        $newImage = new FisheyeImage();
                        $imageHash = array('upload' => $scanFile);
                        if ($newImage->store($imageHash)) {
                            $newImage->addToGalleries($_REQUEST['gallery_additions']);
                            // if we have a gallery to add these images to, load one of them
                            if (!empty($_REQUEST['gallery_additions'][0]) && @(!is_object($imageGallery))) {
                                $imageGallery = new FisheyeGallery();
                                $imageGallery->mGalleryId = $_REQUEST['gallery_additions'][0];
                                $imageGallery->load();
                            }
                            if (@(!is_object($imageGallery))) {
                                global $gBitUser;
                                $galleryHash = array('title' => $gBitUser->getDisplayName() . "'s Gallery");
                                $imageGallery = new FisheyeGallery();
                                if ($imageGallery->store($galleryHash)) {
                                    $imageGallery->load();
                                } else {
                                    $errors = array_merge($errors, array_values($imageGallery->mErrors));
                                }
                            }
                            $imageGallery->addItem($newImage->mContentId);
                        } else {
                            $errors = array_merge($errors, array_values($newImage->mErrors));
                        }
                    } else {
                        // create a new gallery from archive
                        $archiveGallery = new FisheyeGallery();
                        $galleryHash = array('title' => substr($fileName, 0, str_replace('_', ' ', strrpos($fileName, '.'))));
                        if (!$archiveGallery->store($galleryHash)) {
                            $errors = array_merge($errors, array_values($archiveGallery->mErrors));
                        }
                        $errors = fisheye_process_archive($scanFile, $archiveGallery, TRUE);
                        unset($archiveGallery);
                    }
                }
                $order += 10;
            }
        }
    }
    return $errors;
}