/** * Checks if an image is a cover by its filename. * Used in /photoalbum/actions/refreshPhotoAlbum * * @param String $picture_file * @return Boolean */ public function isCover($picture_file, $user) { $name = Util::removeExtension($picture_file); $settings = Doctrine_Core::getTable('Settings')->findOneByUserId($user); if ($name == $settings['covers']) { return true; } else { return false; } }
public function executeRefreshMovieCollection(sfWebRequest $request) { ini_set('display_errors', false); $util = new Util(); $current_movies = array(); $settings = Doctrine_Core::getTable('Settings')->findOneByUserId($this->getUser()->getGuardUser()->getId()); //adding new movies $handle_movie = opendir($util->makePath(array($settings['movies_root']))); if ($handle_movie) { while (false != ($movie_file = readdir($handle_movie))) { //Only permitted video files if ($util->validVideoFile($movie_file)) { //getting only the name from movie file $movie_title = $util->formatName($util->removeExtension($movie_file)); //insert into current_albums array if not duplicated $current_movies[] = $movie_title; $util->createMovie($movie_title, $movie_file, $this->getUser()->getGuardUser()->getId()); } } //while - no more movie files closedir($handle_movie); } //deleting missing movies $movies = Doctrine::getTable('Movie')->createQuery('a')->orderBy('a.title ASC')->execute(); foreach ($movies as $movie) { if (!in_array($movie['title'], $current_movies)) { $util->deleteMovie($movie, $this->getUser()->getGuardUser()->getId()); } } //displaying movies in view $this->movies = Doctrine::getTable('Movie')->createQuery('a')->orderBy('a.title ASC')->execute(); $this->setTemplate('index'); }