public function getAlbums()
 {
     $albums = PhotoAlbum::get()->sort('Created DESC');
     if ($albums->Exists()) {
         return $albums->map("ID", "Name", "Please Select");
     } else {
         return array("No albums found");
     }
 }
Пример #2
0
 // child = album id
 $session->requireLoggedIn();
 function handleUpload($p)
 {
     $session = SessionHandler::getInstance();
     //XXX SECURITY: verify that destination album is owned by current user
     $fileId = File::importImage(USER, $p['img'], $p['album']);
     if ($fileId) {
         js_redirect('u/album/show/' . $session->id . '/' . $p['album']);
     }
     return false;
 }
 if (!$this->child) {
     die('nonoAAA');
 }
 $album = PhotoAlbum::get($this->child);
 if ($album->owner != 0 && $album->owner != $session->id) {
     throw new \Exception('epic HACK attempt');
 }
 echo '<h1>Upload photo to album ' . $album->name . '</h1>';
 $form = new XhtmlForm();
 $form->addHidden('album', $this->child);
 $form->addFile('img', 'Select file');
 $form->addSubmit('Save');
 $form->setHandler('handleUpload');
 echo $form->render();
 // only enable Html5Uploader for supported browsers
 $b = HttpUserAgent::getBrowser();
 if ($b->name == 'Firefox' || $b->name == 'Chrome') {
     echo '<h1>' . ahref('u/album/uploadmulti/' . $this->child, $b->name . ' detected, try the new drag & drop multi image uploader') . '</h1>';
 }
 public function OtherAlbums()
 {
     $OtherAlbums = PhotoAlbum::get()->exclude("ID", $this->getAlbum()->ID)->filter("PhotoGalleryID", $this->ID)->limit("10");
     $OtherAlbumSet = new ArrayList();
     if ($OtherAlbums->exists()) {
         foreach ($OtherAlbums as $OtherAlbum) {
             if ($OtherAlbum->getComponents("PhotoItems")->exists() and $OtherAlbum->getComponent("PhotoGallery")->exists() and $OtherAlbum->getComponent("AlbumCover")->exists()) {
                 $OtherAlbumSet->push($OtherAlbum);
             }
         }
     }
     return $OtherAlbumSet;
 }