/**
  * Run method with main page logic
  * 
  * Populate template and display form for creating a new album entry. For POST request,
  * validate form data and save information to database. Available to admins only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $albumDAO = AlbumDAO::getInstance();
     $album = null;
     $form_errors = array();
     $form_values = array("title" => "");
     if (!empty($_POST)) {
         $form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
         if (empty($form_values["title"])) {
             $form_errors["title"] = "No title specified";
         }
         if (empty($form_errors)) {
             $album = new Album();
             $album->setTitle($form_values["title"]);
             if ($albumDAO->insert($album)) {
                 $session->setMessage("Album saved");
                 header("Location: edit_album.php?id={$album->id}");
                 return;
             } else {
                 $session->setMessage("Album not saved");
             }
         }
     }
     $this->template->render(array("title" => "Create Album", "session" => $session, "main_page" => "create_album_tpl.php", "album" => $album, "form_values" => $form_values, "form_errors" => $form_errors));
 }
Example #2
0
 function form_finish()
 {
     if ($_POST['albumselect'] == '' && empty($_POST['folder'])) {
         return $this->form_publish('Please enter the name of the new album');
     }
     if ($_POST['albumselect'] == '' && $_POST['folder'] != '') {
         $folder = strip($_POST['folder']);
         $uploaddir = SERVERPATH . '/albums/' . $folder;
         if (!is_dir($uploaddir)) {
             mkdir($uploaddir, 0777);
         }
         @chmod($uploaddir, 0777);
         $gallery = new Gallery();
         $album = new Album($gallery, $folder);
         $title = strip($_POST['albumtitle']);
         if (!empty($title)) {
             $album->setTitle($title);
         }
     } else {
         $folder = strip($_POST['albumselect']);
     }
     $this->header();
     echo '<h2>Just a moment...</h2>';
     $this->buttonsEnableBack = true;
     $this->buttonsEnableNext = true;
     $this->buttonsLastServerSidePage = true;
     $this->footer('startUpload("' . utf8::encode_javascript($folder) . '"); ');
 }
Example #3
0
 private function setAlbumTitle()
 {
     Module::dependencies(isset($_POST['albumIDs'], $_POST['title']));
     $album = new Album($this->database, $this->plugins, $this->settings, $_POST['albumIDs']);
     echo $album->setTitle($_POST['title']);
 }
Example #4
0
 if ($new) {
     $rightsalbum = new Album($gallery, dirname($folder));
 } else {
     $rightsalbum = new Album($gallery, $folder);
 }
 if (!$rightsalbum->isMyItem(UPLOAD_RIGHTS)) {
     if (!zp_apply_filter('admin_managed_albums_access', false, $return)) {
         header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php');
         exit;
     }
 }
 if ($new) {
     mkdir_recursive($targetPath, CHMOD_VALUE);
     $album = new Album($gallery, $folder);
     $album->setShow($_POST['http_publishalbum']);
     $album->setTitle(sanitize($_POST['http_albumtitle']));
     $album->setOwner($_zp_current_admin_obj->getUser());
     $album->save();
 }
 @chmod($targetPath, CHMOD_VALUE);
 $error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tempFile);
 if (!$error) {
     if (is_valid_image($name) || is_valid_other_type($name)) {
         $seoname = seoFriendly($name);
         if (strrpos($seoname, '.') === 0) {
             $seoname = sha1($name) . $seoname;
         }
         // soe stripped out all the name.
         $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
         if (file_exists($targetFile)) {
             $append = '_' . time();
 // Make sure the folder exists. If not, create it.
 if (isset($_POST['processed']) && !empty($_POST['folder']) && ($newAlbum || !$files_empty)) {
     $folder = sanitize_path($_POST['folder']);
     $uploaddir = $gallery->albumdir . UTF8ToFilesystem($folder);
     if (!is_dir($uploaddir)) {
         mkdir($uploaddir, CHMOD_VALUE);
     }
     @chmod($uploaddir, CHMOD_VALUE);
     $album = new Album($gallery, $folder);
     if ($album->exists) {
         if (!isset($_POST['publishalbum'])) {
             $album->setShow(false);
         }
         $title = sanitize($_POST['albumtitle'], 2);
         if (!empty($title) && $newAlbum) {
             $album->setTitle($title);
         }
         $album->save();
     } else {
         $AlbumDirName = str_replace(SERVERPATH, '', $gallery->albumdir);
         zp_error(gettext("The album couldn't be created in the 'albums' folder. This is usually a permissions problem. Try setting the permissions on the albums and cache folders to be world-writable using a shell:") . " <code>chmod 777 " . $AlbumDirName . CACHEFOLDER . "</code>, " . gettext("or use your FTP program to give everyone write permissions to those folders."));
     }
     $error = false;
     foreach ($_FILES['files']['error'] as $key => $error) {
         if ($_FILES['files']['name'][$key] == "") {
             continue;
         }
         if ($error == UPLOAD_ERR_OK) {
             $tmp_name = $_FILES['files']['tmp_name'][$key];
             $name = $_FILES['files']['name'][$key];
             $soename = UTF8toFilesystem(seoFriendlyURL($name));
Example #6
0
 public function run()
 {
     // first of all - try to guess if this dir should be
     // treated as an album or as a bunch of loose tracks
     // further this method is adding score to several attributes which will be migrated to production db-table
     $this->setHandleAsAlbum();
     #print_r($this->r);
     cliLog("handleAsAlbumScore " . $this->handleAsAlbumScore, 3, 'purple');
     #die();
     #if($this->tracks[0]['relativePath'] == 'newroot/crse002cd--Calibre-Musique_Concrete-2CD-CRSE002CD-2001-sour/101-calibre-deep_everytime.mp3') {
     #print_r($this->r); die();
     #}
     // extract some attributes from tracks
     // those will be used for album stuff
     $mergedFromTracks = array('artist' => array(), 'genre' => array(), 'label' => array(), 'catalogNr' => array());
     foreach (array_keys($mergedFromTracks) as $what) {
         foreach ($this->tracks as $idx => $rawTagData) {
             $mergedFromTracks[$what][] = $this->getMostScored($idx, $what);
         }
         $mergedFromTracks[$what][] = $this->getMostScored('album', $what);
         $mergedFromTracks[$what] = join(',', array_unique($mergedFromTracks[$what]));
     }
     $albumArtists = count(trimExplode(",", $mergedFromTracks['artist'])) > 3 ? 'Various Artists' : $mergedFromTracks['artist'];
     $a = new Album();
     $a->setArtistId(join(",", Artist::getIdsByString($albumArtists)));
     $a->setGenreId(join(",", Genre::getIdsByString($mergedFromTracks['genre'])));
     #$a->setLabelId(join(",", Label::getIdsByString($mergedFromTracks['label'])));
     $a->setCatalogNr($this->mostScored['album']['catalogNr']);
     $a->setRelativePath($this->getRelativeDirectoryPath());
     $a->setRelativePathHash($this->getRelativeDirectoryPathHash());
     $a->setAdded($this->getDirectoryMtime());
     $a->setFilemtime($this->getDirectoryMtime());
     $a->setTitle($this->mostScored['album']['title']);
     $a->setYear($this->mostScored['album']['year']);
     $a->setIsJumble($this->handleAsAlbum === TRUE ? 0 : 1);
     $a->setTrackCount(count($this->tracks));
     #print_r($a); die();
     $a->update();
     $albumId = $a->getId();
     // add the whole bunch of valid and indvalid attributes to albumindex table
     $this->updateAlbumIndex($albumId);
     foreach ($this->tracks as $idx => $rawTagData) {
         $t = $this->migrateNonGuessableData($rawTagData);
         $t->setArtistId($this->mostScored[$idx]['artist']);
         // currently the string insted of an artistId
         $t->setTitle($this->mostScored[$idx]['title']);
         $t->setFeaturedArtistsAndRemixers();
         # setFeaturedArtistsAndRemixers() is processing:
         # $t->setArtistId();
         # $t->setFeaturingId();
         # $t->setRemixerId();
         $t->setGenreId(join(",", Genre::getIdsByString($this->getMostScored($idx, 'genre'))));
         $t->setLabelId(join(",", Label::getIdsByString($this->getMostScored($idx, 'label'))));
         $t->setCatalogNr($this->mostScored[$idx]['catalogNr']);
         $t->setDisc($this->mostScored[$idx]['disc']);
         $t->setNumber($this->mostScored[$idx]['number']);
         $t->setComment($this->mostScored[$idx]['comment']);
         $t->setYear($this->mostScored[$idx]['year']);
         $t->setAlbumId($albumId);
         // make sure to use identical ids in table:rawtagdata and table:track
         \Slimpd\Track::ensureRecordIdExists($t->getId());
         $t->update();
         // make sure extracted images will be referenced to an album
         \Slimpd\Bitmap::addAlbumIdToTrackId($t->getId(), $albumId);
         #
         // add the whole bunch of valid and indvalid attributes to trackindex table
         $this->updateTrackIndex($t->getId(), $idx);
     }
     unset($this->r['album']);
     if ($this->handleAsAlbum === TRUE) {
         // try to guess if all tracks of this album has obviously invalid fixable attributes
     }
     return;
     print_r($this->r);
     #die();
 }
Example #7
0
 if ($new) {
     $rightsalbum = new Album($gallery, dirname($folder));
 } else {
     $rightsalbum = new Album($gallery, $folder);
 }
 if (!$rightsalbum->isMyItem(UPLOAD_RIGHTS)) {
     if (!zp_apply_filter('admin_managed_albums_access', false, $return)) {
         header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php');
         exit;
     }
 }
 if ($new) {
     mkdir_recursive($targetPath, CHMOD_VALUE);
     $album = new Album($gallery, $folder);
     $album->setShow($albumparmas[0] != 'false');
     $album->setTitle($albumparmas[2]);
     $album->setOwner($_zp_current_admin_obj->getUser());
     $album->save();
 }
 @chmod($targetPath, CHMOD_VALUE);
 $error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tempFile);
 if (!$error) {
     if (is_valid_image($name) || is_valid_other_type($name)) {
         $seoname = seoFriendly($name);
         if (strrpos($seoname, '.') === 0) {
             $seoname = sha1($name) . $seoname;
         }
         // soe stripped out all the name.
         $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
         if (file_exists($targetFile)) {
             $append = '_' . time();
Example #8
0
 public function updateAction()
 {
     $id = $this->params("id");
     $album = new Album();
     $album->setArtist("La vela puerca");
     $album->setTitle("El viejo");
     $album->setId($id);
     $albumDao = new AlbumDao($this->_serviceLocator);
     $res = $albumDao->save($album);
     var_dump($res);
     exit;
 }
 public function addAlbum($request, $title, $number = null, $mini = null)
 {
     $daoAlbum = $this->dao->getDAO("Album");
     $albumTitle = $title == null ? 'Album glowny' : $title;
     if ($number == 0) {
         $number = $daoAlbum->countByUserId($_SESSION['oUser']->getId());
         ++$number;
     }
     if ($mini != null) {
         $icon = $mini;
     }
     $album = new Album();
     $album->setAccess(NewPhotoEnum::ALBUM_PUBLIC);
     $album->setAdded($album->getAdded());
     $album->setDescription($request->getDescription());
     $album->setNumber($number);
     $album->setTitle($albumTitle);
     $album->setIcon($icon);
     $album->setUserId($_SESSION['oUser']->getId());
     $albumAdded = $daoAlbum->save($album);
     return $albumAdded;
 }
Example #10
0
                        $tab = '';
                    } else {
                        $tab = '&tab=subalbuminfo';
                    }
                } else {
                    $tab = '&tab=albuminfo';
                }
                header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin-edit.php?page=edit{$albumdir}&exists=" . urlencode($name) . $tab);
                exit;
            } else {
                mkdir_recursive($uploaddir, CHMOD_VALUE);
            }
            @chmod($uploaddir, CHMOD_VALUE);
            $album = new Album($gallery, $folder);
            if ($album->exists) {
                $album->setTitle($name);
                $album->save();
                header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/admin-edit.php?page=edit" . "&album=" . pathurlencode($folder));
                exit;
            } else {
                $AlbumDirName = str_replace(SERVERPATH, '', $gallery->albumdir);
                zp_error(gettext("The album couldn't be created in the 'albums' folder. This is usually a permissions problem. Try setting the permissions on the albums and cache folders to be world-writable using a shell:") . " <code>chmod 777 " . $AlbumDirName . '/' . CACHEFOLDER . '/' . "</code>, " . gettext("or use your FTP program to give everyone write permissions to those folders."));
            }
            break;
    }
    // end of switch
} else {
    if (time() > getOption('last_garbage_collect') + 864000) {
        $gallery->garbageCollect();
    }
    if (isset($_GET['albumimagesort'])) {
Example #11
0
 /**
  * Finds an album by title. Optionally creates a new album if none exists
  * by that title.
  *
  * @bug Only allows one album by title globally, this should be (at least)
  * on a per-user basis.
  *
  * @param string $title title of the album
  * @param boolean $create (optional) create a new album if none found,
  * defaults to false
  *
  * @return Album loaded instance when found/created, otherwise a bare
  * instance
  */
 public static function findByTitle($title, $create = false)
 {
     $db = Core::getDb();
     // Find
     $qTitle = $db->escape($title);
     $q = "select id from albums where title='{$qTitle}'";
     $id = $db->getSingleValue($q);
     // Create if it doesn't exist
     if (!$id && $create) {
         $album = new Album();
         $album->setTitle($title);
         $album->save();
         return $album;
     }
     return new Album($id);
 }
Example #12
0
                 continue;
             }
             $connection = $user->getConnection($id);
             if ($connection) {
                 $rs = $connection->postEvent($event);
                 if (isset($rs->id)) {
                     $errors[] = "<p>" . $connection->serviceName() . " status geupdate: <a target=\"_blank\" href=\"" . $rs->url . "\">" . $rs->url . "</a></p>\n";
                 } else {
                     $errors[] = "<p>\nEr is een fout opgetreden bij het updaten van je " . $connection->serviceName() . " status:</p>\n<pre>" . print_r($rs->error, true) . "</pre>\n";
                 }
             }
         }
         // Update title of corresponding album
         $album = new Album($event->albumId());
         $album->setSystem(true);
         $album->setTitle($event->title());
         $album->save();
     }
 }
 if (isset($_POST['json'])) {
     $response = array();
     $response['formId'] = $_POST['formId'];
     $response['eventId'] = $event->id();
     $response['event'] = Events::showSingle($db, $user, $event->id(), true);
     $response['errors'] = $errors;
     header('Content-type: application/json');
     echo json_encode($response);
     exit;
 }
 if (!count($errors)) {
     Router::redirect($_SERVER['HTTP_REFERER'], 303);
 /**
  * Converts the album fetched from the database to the Album object.
  */
 private function convertAlbum($row)
 {
     $album = new Album($row['id'], $row['owner_id']);
     $album->setTitle($row['title']);
     $album->setDescription($row['description']);
     $album->setMediaMimeType($row['media_mime_type']);
     $album->setThumbnailUrl($row['thumbnail_url']);
     $album->setMediaType($row['media_type']);
     $album->setMediaItemCount($row['media_item_count']);
     if (isset($row['address_id'])) {
         $album->setLocation($this->getAddress($row['address_id']));
     }
     $album->setMediaItemCount($this->getCount("select count(*) from media_items where album_id = " . $row['id']));
     return $album;
 }