From d04080c7be7c8a06bd81a9747943600812339f40 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 17 Jan 2013 15:05:46 -0500 Subject: Follow-on to 94b26e506c339f50b8d094057bffc1877a79afa9 - make the new legal_file functions more robust when passed an unknown extension. Fixes Item_Model_Test. --- modules/gallery/tests/Item_Model_Test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 8ae8a5dd..a3929e62 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -356,7 +356,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { public function movie_files_must_have_an_extension_test() { try { - $movie = test::random_photo_unsaved(); + $movie = test::random_movie_unsaved(); $movie->type = "movie"; $movie->mime_type = "video/x-flv"; $movie->name = "no_extension"; -- cgit v1.2.3 From 61724f78da98d192cc86db6b3a12cdac506a916e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 17 Jan 2013 15:22:50 -0500 Subject: Update golden files. --- modules/gallery/tests/controller_auth_data.txt | 1 + modules/gallery/tests/xss_data.txt | 90 ++++++++++++++------------ 2 files changed, 48 insertions(+), 43 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index e35708c0..a7bc28dd 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -35,6 +35,7 @@ modules/server_add/controllers/admin_server_add.php autocomplete modules/server_add/controllers/server_add.php children DIRTY_CSRF modules/tag/controllers/admin_tags.php index DIRTY_CSRF modules/tag/controllers/tag.php __call DIRTY_CSRF|DIRTY_AUTH +modules/tag/controllers/tag_name.php __call DIRTY_AUTH modules/tag/controllers/tags.php autocomplete DIRTY_CSRF|DIRTY_AUTH modules/user/controllers/admin_users.php index DIRTY_CSRF modules/user/controllers/password.php reset DIRTY_AUTH diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index 2bfacb47..7d77645d 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -46,7 +46,6 @@ modules/exif/views/exif_dialog.html.php 21 DIRTY $detai modules/g2_import/views/admin_g2_import.html.php 7 DIRTY_JS url::site("__ARGS__") modules/g2_import/views/admin_g2_import.html.php 52 DIRTY $form modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY_ATTR text::alternate("g-odd","g-even") -modules/gallery/views/admin_advanced_settings.html.php 22 DIRTY $var->module_name modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity) modules/gallery/views/admin_block_log_entries.html.php 8 DIRTY_JS user_profile::url($entry->user->id) modules/gallery/views/admin_block_log_entries.html.php 10 DIRTY gallery::date_time($entry->timestamp) @@ -223,10 +222,13 @@ modules/gallery/views/menu_dialog.html.php 5 DIRTY_JS $menu- modules/gallery/views/menu_link.html.php 3 DIRTY $menu->css_id?"id='{$menu->css_id}'":"" modules/gallery/views/menu_link.html.php 4 DIRTY_ATTR $menu->css_class modules/gallery/views/menu_link.html.php 5 DIRTY_JS $menu->url -modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($item->file_url(true),"",$attrs) -modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $attrs["id"] -modules/gallery/views/movieplayer.html.php 7 DIRTY_JS url::abs_file("lib/flowplayer.swf") -modules/gallery/views/movieplayer.html.php 17 DIRTY_JS url::abs_file("lib/flowplayer.pseudostreaming.swf") +modules/gallery/views/movieplayer.html.php 2 DIRTY html::anchor($url,"",$attrs) +modules/gallery/views/movieplayer.html.php 4 DIRTY_JS $attrs["id"] +modules/gallery/views/movieplayer.html.php 5 DIRTY_JS $max_size +modules/gallery/views/movieplayer.html.php 23 DIRTY_JS url::abs_file("lib/flowplayer.swf") +modules/gallery/views/movieplayer.html.php 30 DIRTY_JS url::abs_file("lib/flowplayer.pseudostreaming-byterange.swf") +modules/gallery/views/movieplayer.html.php 48 DIRTY_JS $width +modules/gallery/views/movieplayer.html.php 48 DIRTY_JS $height modules/gallery/views/permissions_browse.html.php 3 DIRTY_JS url::site("permissions/form/__ITEM__") modules/gallery/views/permissions_browse.html.php 16 DIRTY_JS url::site("permissions/change/__CMD__/__GROUP__/__PERM__/__ITEM__?csrf=$csrf") modules/gallery/views/permissions_browse.html.php 43 DIRTY_ATTR $parent->id @@ -338,11 +340,13 @@ modules/rss/views/feed.mrss.php 67 DIRTY_ATTR $ite modules/rss/views/feed.mrss.php 68 DIRTY_ATTR $item->height modules/rss/views/feed.mrss.php 69 DIRTY_ATTR $item->width modules/rss/views/rss_block.html.php 6 DIRTY_JS rss::url($url) -modules/search/views/search.html.php 27 DIRTY_ATTR $item_class -modules/search/views/search.html.php 28 DIRTY_JS $item->url() -modules/search/views/search.html.php 29 DIRTY $item->thumb_img(array("class"=>"g-thumbnail")) -modules/search/views/search.html.php 31 DIRTY_ATTR $item_class -modules/search/views/search.html.php 41 DIRTY $theme->paginator() +modules/search/views/search.html.php 39 DIRTY_ATTR $item_class +modules/search/views/search.html.php 40 DIRTY_JS $item->url() +modules/search/views/search.html.php 41 DIRTY $item->thumb_img(array("class"=>"g-thumbnail")) +modules/search/views/search.html.php 43 DIRTY_ATTR $item_class +modules/search/views/search.html.php 53 DIRTY $theme->paginator() +modules/search/views/search_link.html.php 14 DIRTY_ATTR $item->id +modules/search/views/search_link.html.php 16 DIRTY_ATTR $item->parent_id modules/server_add/views/admin_server_add.html.php 8 DIRTY_JS url::site("__ARGS__") modules/server_add/views/admin_server_add.html.php 19 DIRTY $form modules/server_add/views/admin_server_add.html.php 30 DIRTY_ATTR $id @@ -378,22 +382,22 @@ modules/user/views/admin_users_group.html.php 24 DIRTY_JS $group modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url -themes/admin_wind/views/admin.html.php 5 DIRTY $theme->html_attributes() -themes/admin_wind/views/admin.html.php 35 DIRTY $theme->admin_head() -themes/admin_wind/views/admin.html.php 47 DIRTY_JS $theme->url() -themes/admin_wind/views/admin.html.php 52 DIRTY $theme->get_combined("css") -themes/admin_wind/views/admin.html.php 55 DIRTY $theme->get_combined("script") -themes/admin_wind/views/admin.html.php 59 DIRTY $theme->admin_page_top() -themes/admin_wind/views/admin.html.php 67 DIRTY $theme->admin_header_top() -themes/admin_wind/views/admin.html.php 68 DIRTY_JS item::root()->url() -themes/admin_wind/views/admin.html.php 71 DIRTY $theme->user_menu() -themes/admin_wind/views/admin.html.php 74 DIRTY $theme->admin_menu() -themes/admin_wind/views/admin.html.php 77 DIRTY $theme->admin_header_bottom() -themes/admin_wind/views/admin.html.php 84 DIRTY $content -themes/admin_wind/views/admin.html.php 90 DIRTY $sidebar -themes/admin_wind/views/admin.html.php 95 DIRTY $theme->admin_footer() -themes/admin_wind/views/admin.html.php 98 DIRTY $theme->admin_credits() -themes/admin_wind/views/admin.html.php 103 DIRTY $theme->admin_page_bottom() +themes/admin_wind/views/admin.html.php 4 DIRTY $theme->html_attributes() +themes/admin_wind/views/admin.html.php 34 DIRTY $theme->admin_head() +themes/admin_wind/views/admin.html.php 46 DIRTY_JS $theme->url() +themes/admin_wind/views/admin.html.php 51 DIRTY $theme->get_combined("css") +themes/admin_wind/views/admin.html.php 54 DIRTY $theme->get_combined("script") +themes/admin_wind/views/admin.html.php 58 DIRTY $theme->admin_page_top() +themes/admin_wind/views/admin.html.php 66 DIRTY $theme->admin_header_top() +themes/admin_wind/views/admin.html.php 67 DIRTY_JS item::root()->url() +themes/admin_wind/views/admin.html.php 70 DIRTY $theme->user_menu() +themes/admin_wind/views/admin.html.php 73 DIRTY $theme->admin_menu() +themes/admin_wind/views/admin.html.php 76 DIRTY $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php 83 DIRTY $content +themes/admin_wind/views/admin.html.php 89 DIRTY $sidebar +themes/admin_wind/views/admin.html.php 94 DIRTY $theme->admin_footer() +themes/admin_wind/views/admin.html.php 97 DIRTY $theme->admin_credits() +themes/admin_wind/views/admin.html.php 102 DIRTY $theme->admin_page_bottom() themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor themes/admin_wind/views/block.html.php 5 DIRTY $id themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id @@ -423,23 +427,23 @@ themes/wind/views/dynamic.html.php 17 DIRTY_ATTR $chi themes/wind/views/dynamic.html.php 29 DIRTY $theme->paginator() themes/wind/views/movie.html.php 5 DIRTY $theme->paginator() themes/wind/views/movie.html.php 9 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}")) -themes/wind/views/page.html.php 5 DIRTY $theme->html_attributes() -themes/wind/views/page.html.php 11 DIRTY $page_title -themes/wind/views/page.html.php 33 DIRTY $new_width -themes/wind/views/page.html.php 34 DIRTY $new_height -themes/wind/views/page.html.php 35 DIRTY $thumb_proportion -themes/wind/views/page.html.php 75 DIRTY_JS $theme->url() -themes/wind/views/page.html.php 80 DIRTY $theme->get_combined("css") -themes/wind/views/page.html.php 83 DIRTY $theme->get_combined("script") -themes/wind/views/page.html.php 93 DIRTY $header_text -themes/wind/views/page.html.php 95 DIRTY_JS item::root()->url() -themes/wind/views/page.html.php 99 DIRTY $theme->user_menu() -themes/wind/views/page.html.php 114 DIRTY_ATTR $breadcrumb->last?"g-active":"" -themes/wind/views/page.html.php 115 DIRTY_ATTR $breadcrumb->first?"g-first":"" -themes/wind/views/page.html.php 116 DIRTY_JS $breadcrumb->url -themes/wind/views/page.html.php 129 DIRTY $content -themes/wind/views/page.html.php 135 DIRTY newView("sidebar.html") -themes/wind/views/page.html.php 142 DIRTY $footer_text +themes/wind/views/page.html.php 4 DIRTY $theme->html_attributes() +themes/wind/views/page.html.php 10 DIRTY $page_title +themes/wind/views/page.html.php 32 DIRTY $new_width +themes/wind/views/page.html.php 33 DIRTY $new_height +themes/wind/views/page.html.php 34 DIRTY $thumb_proportion +themes/wind/views/page.html.php 74 DIRTY_JS $theme->url() +themes/wind/views/page.html.php 79 DIRTY $theme->get_combined("css") +themes/wind/views/page.html.php 82 DIRTY $theme->get_combined("script") +themes/wind/views/page.html.php 92 DIRTY $header_text +themes/wind/views/page.html.php 94 DIRTY_JS item::root()->url() +themes/wind/views/page.html.php 98 DIRTY $theme->user_menu() +themes/wind/views/page.html.php 113 DIRTY_ATTR $breadcrumb->last?"g-active":"" +themes/wind/views/page.html.php 114 DIRTY_ATTR $breadcrumb->first?"g-first":"" +themes/wind/views/page.html.php 115 DIRTY_JS $breadcrumb->url +themes/wind/views/page.html.php 128 DIRTY $content +themes/wind/views/page.html.php 134 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 141 DIRTY $footer_text themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url -- cgit v1.2.3 From 3a9009492e6d05fe657e3aacf34cf40ca3495db5 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Fri, 18 Jan 2013 20:06:05 +0100 Subject: #1943 - Make legal_file::change_extension more robust. Previously would fail with dots in the directory but no extension. Added unit tests to verify the new change works. --- modules/gallery/helpers/legal_file.php | 9 +++------ modules/gallery/tests/Legal_File_Helper_Test.php | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index e6f4cb54..e24aca36 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -137,15 +137,12 @@ class legal_file_Core { } /** - * Convert the extension of a filename. If the original filename has no + * Change the extension of a filename. If the original filename has no * extension, add the new one to the end. */ static function change_extension($filename, $new_ext) { - if (strpos($filename, ".") === false) { - return "{$filename}.{$new_ext}"; - } else { - return preg_replace("/\.[^\.]*?$/", ".{$new_ext}", $filename); - } + $filename_no_ext = preg_replace("/\.[^\.\/]*?$/", "", $filename); + return "{$filename_no_ext}.{$new_ext}"; } /** diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php index d80bcafe..d2813633 100644 --- a/modules/gallery/tests/Legal_File_Helper_Test.php +++ b/modules/gallery/tests/Legal_File_Helper_Test.php @@ -36,6 +36,24 @@ class Legal_File_Helper_Test extends Gallery_Unit_Test_Case { legal_file::change_extension("/website/foo.com/VID_20120513_105421.mp4", "jpg")); } + public function change_extension_path_containing_dots_and_no_extension_test() { + $this->assert_equal( + "/website/foo.com/VID_20120513_105421.jpg", + legal_file::change_extension("/website/foo.com/VID_20120513_105421", "jpg")); + } + + public function change_extension_path_containing_dots_and_dot_extension_test() { + $this->assert_equal( + "/website/foo.com/VID_20120513_105421.jpg", + legal_file::change_extension("/website/foo.com/VID_20120513_105421.", "jpg")); + } + + public function change_extension_path_containing_dots_and_non_standard_chars_test() { + $this->assert_equal( + "/j'écris@un#nom/bizarre(mais quand.même/ça_passe.jpg", + legal_file::change_extension("/j'écris@un#nom/bizarre(mais quand.même/ça_passe.\$ÇÀ@€#_", "jpg")); + } + public function smash_extensions_test() { $this->assert_equal("foo_bar.jpg", legal_file::smash_extensions("foo.bar.jpg")); $this->assert_equal("foo_bar_baz.jpg", legal_file::smash_extensions("foo.bar.baz.jpg")); -- cgit v1.2.3 From e2a2a5ce812c249b46d56ed2f738162e3f4cd09b Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 19 Jan 2013 00:52:13 +0100 Subject: #1944 - Fix possible warnings in legal_file::get_photo_types_by_extension and legal_file::get_movie_types_by_extension. Added unit tests for these two functions, too. --- modules/gallery/helpers/legal_file.php | 6 ++-- modules/gallery/tests/Legal_File_Helper_Test.php | 37 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php index e24aca36..70c07065 100644 --- a/modules/gallery/helpers/legal_file.php +++ b/modules/gallery/helpers/legal_file.php @@ -25,13 +25,14 @@ class legal_file_Core { * * @param string $extension (opt.) - return MIME of extension; if not given, return complete array */ - static function get_photo_types_by_extension($extension=NULL) { + static function get_photo_types_by_extension($extension=null) { $types_by_extension_wrapper = new stdClass(); $types_by_extension_wrapper->types_by_extension = array( "jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png"); module::event("photo_types_by_extension", $types_by_extension_wrapper); if ($extension) { // return matching MIME type + $extension = strtolower($extension); if (isset($types_by_extension_wrapper->types_by_extension[$extension])) { return $types_by_extension_wrapper->types_by_extension[$extension]; } else { @@ -50,13 +51,14 @@ class legal_file_Core { * * @param string $extension (opt.) - return MIME of extension; if not given, return complete array */ - static function get_movie_types_by_extension($extension=NULL) { + static function get_movie_types_by_extension($extension=null) { $types_by_extension_wrapper = new stdClass(); $types_by_extension_wrapper->types_by_extension = array( "flv" => "video/x-flv", "mp4" => "video/mp4", "m4v" => "video/x-m4v"); module::event("movie_types_by_extension", $types_by_extension_wrapper); if ($extension) { // return matching MIME type + $extension = strtolower($extension); if (isset($types_by_extension_wrapper->types_by_extension[$extension])) { return $types_by_extension_wrapper->types_by_extension[$extension]; } else { diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php index d2813633..66a5cc68 100644 --- a/modules/gallery/tests/Legal_File_Helper_Test.php +++ b/modules/gallery/tests/Legal_File_Helper_Test.php @@ -18,6 +18,43 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Legal_File_Helper_Test extends Gallery_Unit_Test_Case { + public function get_photo_types_by_extension_test() { + // Valid extensions return their corresponding mimes, invalid extensions return null + $tests = array("jpg" => "image/jpeg", + "JPG" => "image/jpeg", + "jpeg" => "image/jpeg", + "png" => "image/png", + "Png" => "image/png", + "gif" => "image/gif", + "tif" => null, + "mp4" => null, + "php" => null, + "php.jpg" => null); + foreach ($tests as $extension => $mime_type) { + $this->assert_equal($mime_type, legal_file::get_photo_types_by_extension($extension)); + } + // No extension returns full array + $this->assert_equal(4, count(legal_file::get_photo_types_by_extension())); + } + + public function get_movie_types_by_extension_test() { + // Valid extensions return their corresponding mimes, invalid extensions return null + $tests = array("flv" => "video/x-flv", + "FLV" => "video/x-flv", + "mp4" => "video/mp4", + "Mp4" => "video/mp4", + "m4v" => "video/x-m4v", + "avi" => null, + "jpg" => null, + "php" => null, + "php.flv" => null); + foreach ($tests as $extension => $mime_type) { + $this->assert_equal($mime_type, legal_file::get_movie_types_by_extension($extension)); + } + // No extension returns full array + $this->assert_equal(3, count(legal_file::get_movie_types_by_extension())); + } + public function change_extension_test() { $this->assert_equal("foo.jpg", legal_file::change_extension("foo.png", "jpg")); } -- cgit v1.2.3 From ea8219e1d462362985b526260cd71230a5db2afb Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sat, 19 Jan 2013 00:59:55 +0100 Subject: #1941, 1948 - Fix possible warnings in movie and graphics helpers, add functions to convert between seconds and hh:mm:ss.dd. Also add unit tests for new movie helper functions. --- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/movie.php | 35 ++++++++++++++++----- modules/gallery/tests/Movie_Helper_Test.php | 49 +++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 modules/gallery/tests/Movie_Helper_Test.php (limited to 'modules/gallery/tests') diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index e7c5da68..c840b920 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -157,7 +157,7 @@ class graphics_Core { if ($input_item->is_movie()) { // Convert the movie filename to a JPG first, delete anything that might already be there $output_file = legal_file::change_extension($output_file, "jpg"); - unlink($output_file); + @unlink($output_file); // Run movie_extract_frame events, which can either: // - generate an output file, bypassing the ffmpeg-based movie::extract_frame // - add to the options sent to movie::extract_frame (e.g. change frame extract time, diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 6d70ab2d..3524a8f9 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -66,7 +66,7 @@ class movie_Core { * @param string $output_file * @param array $movie_options (optional) */ - static function extract_frame($input_file, $output_file, $movie_options=NULL) { + static function extract_frame($input_file, $output_file, $movie_options=null) { $ffmpeg = movie::find_ffmpeg(); if (empty($ffmpeg)) { throw new Exception("@todo MISSING_FFMPEG"); @@ -74,17 +74,17 @@ class movie_Core { list($width, $height, $mime_type, $extension, $duration) = movie::get_file_metadata($input_file); - if (is_numeric($movie_options["start_time"])) { + if (isset($movie_options["start_time"]) && is_numeric($movie_options["start_time"])) { $start_time = max(0, $movie_options["start_time"]); // ensure it's non-negative } else { $start_time = module::get_var("gallery", "movie_extract_frame_time", 3); // use default } // extract frame at start_time, unless movie is too short $start_time_arg = ($duration >= $start_time + 0.1) ? - "-ss " . date("H:i:s", mktime(0,0,$start_time,0,0,0,0)) : ""; + "-ss " . movie::seconds_to_hhmmssdd($start_time) : ""; - $input_args = $movie_options["input_args"] ? $movie_options["input_args"] : ""; - $output_args = $movie_options["output_args"] ? $movie_options["output_args"] : ""; + $input_args = isset($movie_options["input_args"]) ? $movie_options["input_args"] : ""; + $output_args = isset($movie_options["output_args"]) ? $movie_options["output_args"] : ""; $cmd = escapeshellcmd($ffmpeg) . " $input_args -i " . escapeshellarg($input_file) . " -an $start_time_arg -an -r 1 -vframes 1" . @@ -149,8 +149,8 @@ class movie_Core { $mime_type = legal_file::get_movie_types_by_extension($extension); $mime_type = $mime_type ? $mime_type : "video/x-flv"; // No MIME found? Default to video/x-flv. - if (preg_match("/Duration: (\d+):(\d+):(\d+\.\d+)/", $result, $matches)) { - $duration = 3600 * $matches[1] + 60 * $matches[2] + $matches[3]; + if (preg_match("/Duration: (\d+:\d+:\d+\.\d+)/", $result, $matches)) { + $duration = movie::hhmmssdd_to_seconds($matches[1]); } else if (preg_match("/duration.*?:.*?(\d+)/", $result, $matches)) { $duration = $matches[1]; } else { @@ -160,4 +160,25 @@ class movie_Core { return array($width, $height, $mime_type, $extension, $duration); } + /** + * Return the time/duration formatted in hh:mm:ss.dd from a number of seconds. + * Useful for inputs to ffmpeg. + * + * Note that this is similar to date("H:i:s", mktime(0,0,$seconds,0,0,0,0)), but unlike this + * approach avoids potential issues with time zone and DST mismatch and/or using deprecated + * features (the last argument of mkdate above, which disables DST, is deprecated as of PHP 5.3). + */ + static function seconds_to_hhmmssdd($seconds) { + return sprintf("%02d:%02d:%05.2f", floor($seconds / 3600), floor(($seconds % 3600) / 60), + floor(100 * $seconds % 6000) / 100); + } + + /** + * Return the number of seconds from a time/duration formatted in hh:mm:ss.dd. + * Useful for outputs from ffmpeg. + */ + static function hhmmssdd_to_seconds($hhmmssdd) { + preg_match("/(\d+):(\d+):(\d+\.\d+)/", $hhmmssdd, $matches); + return 3600 * $matches[1] + 60 * $matches[2] + $matches[3]; + } } diff --git a/modules/gallery/tests/Movie_Helper_Test.php b/modules/gallery/tests/Movie_Helper_Test.php new file mode 100644 index 00000000..78ac21a1 --- /dev/null +++ b/modules/gallery/tests/Movie_Helper_Test.php @@ -0,0 +1,49 @@ + 0.5, + "00:00:06.00" => 6, + "00:00:59.99" => 59.999, + "00:01:00.00" => 60.001, + "00:07:00.00" => 7 * 60, + "00:45:19.00" => 45 * 60 + 19, + "03:45:19.00" => 3 * 3600 + 45 * 60 + 19, + "126:45:19.00" => 126 * 3600 + 45 * 60 + 19); + foreach ($times as $hhmmssdd => $seconds) { + $this->assert_equal($hhmmssdd, movie::seconds_to_hhmmssdd($seconds)); + } + } + + public function hhmmssdd_to_seconds_test() { + $times = array("0:00:00.01" => 0.01, + "00:00:00.50" => 0.5, + "00:00:06.00" => 6, + "00:00:59.99" => 59.99, + "00:01:00.00" => 60.00, + "00:07:00.00" => 7 * 60, + "00:45:19.00" => 45 * 60 + 19, + "03:45:19.00" => 3 * 3600 + 45 * 60 + 19, + "126:45:19.00" => 126 * 3600 + 45 * 60 + 19); + foreach ($times as $hhmmssdd => $seconds) { + $this->assert_equal($seconds, movie::hhmmssdd_to_seconds($hhmmssdd)); + } + } +} -- cgit v1.2.3 From 3a71813f35857faf1f8a6a68cc8dd3e8d6982a7e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jan 2013 00:24:08 -0500 Subject: Change the logic for finding controllers to use glob() but drop anything that we can find is git-ignore'd. --- modules/gallery/tests/Controller_Auth_Test.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/Controller_Auth_Test.php b/modules/gallery/tests/Controller_Auth_Test.php index 5131fae0..76027cf6 100644 --- a/modules/gallery/tests/Controller_Auth_Test.php +++ b/modules/gallery/tests/Controller_Auth_Test.php @@ -20,8 +20,9 @@ class Controller_Auth_Test extends Gallery_Unit_Test_Case { public function find_missing_auth_test() { $found = array(); - $controllers = explode("\n", `git ls-files '*/*/controllers/*.php'`); - $feeds = explode("\n", `git ls-files '*/*/helpers/*_rss.php'`); + $git_ignores = explode("\n", `git ls-files -o -i --exclude-standard`); + $controllers = array_diff(glob("*/*/controllers/*.php"), $git_ignores); + $feeds = array_diff(glob("*/*/helpers/*_rss.php"), $git_ignores); foreach (array_merge($controllers, $feeds) as $controller) { if (preg_match("{modules/(gallery_)?unit_test/}", $controller)) { continue; -- cgit v1.2.3 From a06abe32b0d12b83a5b1b1d5bd10b112a1e50465 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jan 2013 00:39:58 -0500 Subject: Simplify get_photo_types_by_extension_test and get_movie_types_by_extension_test. --- modules/gallery/tests/Legal_File_Helper_Test.php | 39 ++++++++---------------- 1 file changed, 12 insertions(+), 27 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/Legal_File_Helper_Test.php b/modules/gallery/tests/Legal_File_Helper_Test.php index 66a5cc68..041c5d1f 100644 --- a/modules/gallery/tests/Legal_File_Helper_Test.php +++ b/modules/gallery/tests/Legal_File_Helper_Test.php @@ -19,38 +19,23 @@ */ class Legal_File_Helper_Test extends Gallery_Unit_Test_Case { public function get_photo_types_by_extension_test() { - // Valid extensions return their corresponding mimes, invalid extensions return null - $tests = array("jpg" => "image/jpeg", - "JPG" => "image/jpeg", - "jpeg" => "image/jpeg", - "png" => "image/png", - "Png" => "image/png", - "gif" => "image/gif", - "tif" => null, - "mp4" => null, - "php" => null, - "php.jpg" => null); - foreach ($tests as $extension => $mime_type) { - $this->assert_equal($mime_type, legal_file::get_photo_types_by_extension($extension)); - } + $this->assert_equal("image/jpeg", legal_file::get_photo_types_by_extension("jpg")); // regular + $this->assert_equal("image/jpeg", legal_file::get_photo_types_by_extension("JPG")); // all caps + $this->assert_equal("image/png", legal_file::get_photo_types_by_extension("Png")); // some caps + $this->assert_equal(null, legal_file::get_photo_types_by_extension("php")); // invalid + $this->assert_equal(null, legal_file::get_photo_types_by_extension("php.jpg")); // invalid w/ . + // No extension returns full array $this->assert_equal(4, count(legal_file::get_photo_types_by_extension())); } public function get_movie_types_by_extension_test() { - // Valid extensions return their corresponding mimes, invalid extensions return null - $tests = array("flv" => "video/x-flv", - "FLV" => "video/x-flv", - "mp4" => "video/mp4", - "Mp4" => "video/mp4", - "m4v" => "video/x-m4v", - "avi" => null, - "jpg" => null, - "php" => null, - "php.flv" => null); - foreach ($tests as $extension => $mime_type) { - $this->assert_equal($mime_type, legal_file::get_movie_types_by_extension($extension)); - } + $this->assert_equal("video/x-flv", legal_file::get_movie_types_by_extension("flv")); // regular + $this->assert_equal("video/x-flv", legal_file::get_movie_types_by_extension("FLV")); // all caps + $this->assert_equal("video/mp4", legal_file::get_movie_types_by_extension("Mp4")); // some caps + $this->assert_equal(null, legal_file::get_movie_types_by_extension("php")); // invalid + $this->assert_equal(null, legal_file::get_movie_types_by_extension("php.flv")); // invalid w/ . + // No extension returns full array $this->assert_equal(3, count(legal_file::get_movie_types_by_extension())); } -- cgit v1.2.3 From 14b02a5b1215ced4e4ef1d536f0301c6bfb3a845 Mon Sep 17 00:00:00 2001 From: shadlaws Date: Sun, 20 Jan 2013 10:01:41 +0100 Subject: #1950 - Replace bogus file overwrites from item model unit test. - modified rename_photo_test, rename_album_test, move_album_test, move_photo_test - unit tests still test file system integrity and pass --- modules/gallery/tests/Item_Model_Test.php | 48 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index a3929e62..52c3d64d 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -69,9 +69,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $item = test::random_photo(); $original_name = $item->name; - file_put_contents($item->thumb_path(), "thumb"); - file_put_contents($item->resize_path(), "resize"); - file_put_contents($item->file_path(), "file"); + $thumb_file = file_get_contents($item->thumb_path()); + $resize_file = file_get_contents($item->resize_path()); + $fullsize_file = file_get_contents($item->file_path()); // Now rename it $item->name = ($new_name = test::random_name($item)); @@ -82,9 +82,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_equal($new_name, basename($item->file_path())); $this->assert_equal($new_name, basename($item->thumb_path())); $this->assert_equal($new_name, basename($item->resize_path())); - $this->assert_equal("thumb", file_get_contents($item->thumb_path())); - $this->assert_equal("resize", file_get_contents($item->resize_path())); - $this->assert_equal("file", file_get_contents($item->file_path())); + $this->assert_equal($thumb_file, file_get_contents($item->thumb_path())); + $this->assert_equal($resize_file, file_get_contents($item->resize_path())); + $this->assert_equal($fullsize_file, file_get_contents($item->file_path())); } public function rename_album_test() { @@ -92,9 +92,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $photo = test::random_photo($album); $album->reload(); - file_put_contents($photo->thumb_path(), "thumb"); - file_put_contents($photo->resize_path(), "resize"); - file_put_contents($photo->file_path(), "file"); + $thumb_file = file_get_contents($photo->thumb_path()); + $resize_file = file_get_contents($photo->resize_path()); + $fullsize_file = file_get_contents($photo->file_path()); $original_album_name = $album->name; $original_photo_name = $photo->name; @@ -119,9 +119,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_true(test::starts_with($photo->thumb_path(), dirname($album->thumb_path()))); $this->assert_true(test::starts_with($photo->resize_path(), dirname($album->resize_path()))); - $this->assert_equal("thumb", file_get_contents($photo->thumb_path())); - $this->assert_equal("resize", file_get_contents($photo->resize_path())); - $this->assert_equal("file", file_get_contents($photo->file_path())); + $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path())); + $this->assert_equal($resize_file, file_get_contents($photo->resize_path())); + $this->assert_equal($fullsize_file, file_get_contents($photo->file_path())); } public function item_rename_wont_accept_slash_test() { @@ -154,9 +154,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $album1 = test::random_album($album2); $photo = test::random_photo($album1); - file_put_contents($photo->thumb_path(), "thumb"); - file_put_contents($photo->resize_path(), "resize"); - file_put_contents($photo->file_path(), "file"); + $thumb_file = file_get_contents($photo->thumb_path()); + $resize_file = file_get_contents($photo->resize_path()); + $fullsize_file = file_get_contents($photo->file_path()); // Now move the album $album1->parent_id = item::root()->id; @@ -173,9 +173,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_true(test::starts_with($photo->thumb_path(), dirname($album1->thumb_path()))); $this->assert_true(test::starts_with($photo->resize_path(), dirname($album1->resize_path()))); - $this->assert_equal("thumb", file_get_contents($photo->thumb_path())); - $this->assert_equal("resize", file_get_contents($photo->resize_path())); - $this->assert_equal("file", file_get_contents($photo->file_path())); + $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path())); + $this->assert_equal($resize_file, file_get_contents($photo->resize_path())); + $this->assert_equal($fullsize_file, file_get_contents($photo->file_path())); } public function move_photo_test() { @@ -184,9 +184,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $album2 = test::random_album(); - file_put_contents($photo->thumb_path(), "thumb"); - file_put_contents($photo->resize_path(), "resize"); - file_put_contents($photo->file_path(), "file"); + $thumb_file = file_get_contents($photo->thumb_path()); + $resize_file = file_get_contents($photo->resize_path()); + $fullsize_file = file_get_contents($photo->file_path()); // Now move the photo $photo->parent_id = $album2->id; @@ -200,9 +200,9 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { $this->assert_true(test::starts_with($photo->thumb_path(), dirname($album2->thumb_path()))); $this->assert_true(test::starts_with($photo->resize_path(), dirname($album2->resize_path()))); - $this->assert_equal("thumb", file_get_contents($photo->thumb_path())); - $this->assert_equal("resize", file_get_contents($photo->resize_path())); - $this->assert_equal("file", file_get_contents($photo->file_path())); + $this->assert_equal($thumb_file, file_get_contents($photo->thumb_path())); + $this->assert_equal($resize_file, file_get_contents($photo->resize_path())); + $this->assert_equal($fullsize_file, file_get_contents($photo->file_path())); } public function move_album_with_conflicting_target_gets_uniqified_test() { -- cgit v1.2.3 From f1d2a8e871327d250574d2dd7cacbb21ea3ae995 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 20 Jan 2013 23:54:01 -0500 Subject: Add a long overdue test for File_Proxy_Controller that tests all the various edge case behaviors. It doesn't cover the various headers, but it does cover the permission based code paths. --- modules/gallery/controllers/file_proxy.php | 34 ++++-- .../gallery/tests/File_Proxy_Controller_Test.php | 130 +++++++++++++++++++++ 2 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 modules/gallery/tests/File_Proxy_Controller_Test.php (limited to 'modules/gallery/tests') diff --git a/modules/gallery/controllers/file_proxy.php b/modules/gallery/controllers/file_proxy.php index b2120455..df1f7908 100644 --- a/modules/gallery/controllers/file_proxy.php +++ b/modules/gallery/controllers/file_proxy.php @@ -49,7 +49,9 @@ class File_Proxy_Controller extends Controller { // Make sure that the request is for a file inside var $offset = strpos(rawurldecode($request_uri), $var_uri); if ($offset !== 0) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 1; + throw $e; } // file_uri: albums/foo/bar.jpg @@ -59,7 +61,9 @@ class File_Proxy_Controller extends Controller { // path: foo/bar.jpg list ($type, $path) = explode("/", $file_uri, 2); if ($type != "resizes" && $type != "albums" && $type != "thumbs") { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 2; + throw $e; } // If the last element is .album.jpg, pop that off since it's not a real item @@ -82,22 +86,30 @@ class File_Proxy_Controller extends Controller { } if (!$item->loaded()) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 3; + throw $e; } // Make sure we have access to the item if (!access::can("view", $item)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 4; + throw $e; } // Make sure we have view_full access to the original if ($type == "albums" && !access::can("view_full", $item)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 5; + throw $e; } // Don't try to load a directory if ($type == "albums" && $item->is_album()) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 6; + throw $e; } // Note: this code is roughly duplicated in data_rest, so if you modify this, please look to @@ -112,7 +124,9 @@ class File_Proxy_Controller extends Controller { } if (!file_exists($file)) { - throw new Kohana_404_Exception(); + $e = new Kohana_404_Exception(); + $e->test_fail_code = 7; + throw $e; } header("Content-Length: " . filesize($file)); @@ -146,6 +160,10 @@ class File_Proxy_Controller extends Controller { } } - readfile($file); + if (TEST_MODE) { + return $file; + } else { + readfile($file); + } } } diff --git a/modules/gallery/tests/File_Proxy_Controller_Test.php b/modules/gallery/tests/File_Proxy_Controller_Test.php new file mode 100644 index 00000000..dab2b8f3 --- /dev/null +++ b/modules/gallery/tests/File_Proxy_Controller_Test.php @@ -0,0 +1,130 @@ +_save = array($_SERVER); + } + + public function teardown() { + list($_SERVER) = $this->_save; + identity::set_active_user(identity::admin_user()); + } + + public function basic_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}"); + $controller = new File_Proxy_Controller(); + $this->assert_same($photo->file_path(), $controller->__call("", array())); + } + + public function query_params_are_ignored_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}?a=1&b=2"); + $controller = new File_Proxy_Controller(); + $this->assert_same($photo->file_path(), $controller->__call("", array())); + } + + public function file_must_be_in_var_test() { + $_SERVER["REQUEST_URI"] = url::file("index.php"); + $controller = new File_Proxy_Controller(); + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(1, $e->test_fail_code); + } + } + + public function file_must_be_in_albums_thumbs_or_resizes_test() { + $_SERVER["REQUEST_URI"] = url::file("var/test/var/uploads/.htaccess"); + $controller = new File_Proxy_Controller(); + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(2, $e->test_fail_code); + } + } + + public function movie_thumbnails_are_jpgs_test() { + $movie = test::random_movie(); + $name = legal_file::change_extension($movie->name, "jpg"); + $_SERVER["REQUEST_URI"] = url::file("var/thumbs/{$movie->name}"); + $controller = new File_Proxy_Controller(); + $this->assert_same($movie->thumb_path(), $controller->__call("", array())); + } + + public function invalid_item_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/x_{$photo->name}"); + $controller = new File_Proxy_Controller(); + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(3, $e->test_fail_code); + } + } + + public function need_view_full_permission_to_view_original_test() { + $album = test::random_album(); + $photo = test::random_photo($album); + $album = $album->reload(); // adding the photo changed the album in the db + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}/{$photo->name}"); + $controller = new File_Proxy_Controller(); + + access::deny(identity::everybody(), "view_full", $album); + identity::set_active_user(identity::guest()); + + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(5, $e->test_fail_code); + } + } + + public function cant_proxy_an_album_test() { + $album = test::random_album(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$album->name}"); + $controller = new File_Proxy_Controller(); + + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(6, $e->test_fail_code); + } + } + + public function missing_file_test() { + $photo = test::random_photo(); + $_SERVER["REQUEST_URI"] = url::file("var/albums/{$photo->name}"); + unlink($photo->file_path()); + $controller = new File_Proxy_Controller(); + + try { + $controller->__call("", array()); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + $this->assert_same(7, $e->test_fail_code); + } + } +} \ No newline at end of file -- cgit v1.2.3 From 8dc34dade882768feb8100d7041d94c7d446b818 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 21 Jan 2013 00:51:31 -0500 Subject: Add unit tests for data_rest. While I'm in there, get rid of the clause that returns nothing when the album has no album cover - we'll fail before that if the album's thumbnail is missing, and if it's not missing then we'll have something to serve even if it's out of date. --- modules/gallery/helpers/data_rest.php | 12 ++- modules/gallery/tests/Data_Rest_Helper_Test.php | 102 ++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 modules/gallery/tests/Data_Rest_Helper_Test.php (limited to 'modules/gallery/tests') diff --git a/modules/gallery/helpers/data_rest.php b/modules/gallery/helpers/data_rest.php index ef4f17e7..ad369037 100644 --- a/modules/gallery/helpers/data_rest.php +++ b/modules/gallery/helpers/data_rest.php @@ -51,12 +51,6 @@ class data_rest_Core { // We don't need to save the session for this request Session::instance()->abort_save(); - if ($item->is_album() && !$item->album_cover_item_id) { - // No thumbnail. Return nothing. - // @todo: what should we do here? - return; - } - // Dump out the image. If the item is a movie or album, then its thumbnail will be a JPG. if (($item->is_movie() || $item->is_album()) && $p->size == "thumb") { header("Content-Type: image/jpeg"); @@ -68,7 +62,11 @@ class data_rest_Core { if (isset($p->encoding) && $p->encoding == "base64") { print base64_encode(file_get_contents($file)); } else { - readfile($file); + if (TEST_MODE) { + return $file; + } else { + readfile($file); + } } // We must exit here to keep the regular REST framework reply code from adding more bytes on diff --git a/modules/gallery/tests/Data_Rest_Helper_Test.php b/modules/gallery/tests/Data_Rest_Helper_Test.php new file mode 100644 index 00000000..feec6d32 --- /dev/null +++ b/modules/gallery/tests/Data_Rest_Helper_Test.php @@ -0,0 +1,102 @@ +assert_equal($photo->id, $resolved->id); + } + + public function resolve_needs_permission_test() { + $album = test::random_album(); + $photo = test::random_photo($album); + $album->reload(); // new photo changed the album in the db + + access::deny(identity::everybody(), "view", $album); + identity::set_active_user(identity::guest()); + + try { + data_rest::resolve($photo->id); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + // pass + } + } + + public function basic_get_test() { + $photo = test::random_photo(); + + $request = new stdClass(); + $request->url = rest::url("data", $photo, "thumb"); + $request->params = new stdClass(); + + $request->params->size = "thumb"; + $this->assert_same($photo->thumb_path(), data_rest::get($request)); + + $request->params->size = "resize"; + $this->assert_same($photo->resize_path(), data_rest::get($request)); + + $request->params->size = "full"; + $this->assert_same($photo->file_path(), data_rest::get($request)); + } + + public function illegal_access_test() { + $album = test::random_album(); + $photo = test::random_photo($album); + $album->reload(); + + access::deny(identity::everybody(), "view", $album); + identity::set_active_user(identity::guest()); + + $request = new stdClass(); + $request->url = rest::url("data", $photo, "thumb"); + $request->params = new stdClass(); + $request->params->size = "thumb"; + + try { + data_rest::get($request); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + // pass + } + } + + public function missing_file_test() { + $photo = test::random_photo(); + + $request = new stdClass(); + $request->url = rest::url("data", $photo, "thumb"); + $request->params = new stdClass(); + $request->params->size = "thumb"; + + unlink($photo->thumb_path()); // oops! + + try { + data_rest::get($request); + $this->assert_true(false); + } catch (Kohana_404_Exception $e) { + // pass + } + } +} -- cgit v1.2.3 From d45a73777935c86fc5131955831833d7465b5e9d Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 21 Jan 2013 01:22:01 -0500 Subject: Update copyright to 2013. Fixes #1953. --- application/Bootstrap.php | 2 +- application/config/config.php | 2 +- index.php | 2 +- installer/cli.php | 2 +- installer/index.php | 2 +- installer/installer.php | 2 +- installer/web.php | 2 +- modules/akismet/controllers/admin_akismet.php | 2 +- modules/akismet/helpers/akismet.php | 2 +- modules/akismet/helpers/akismet_event.php | 2 +- modules/akismet/helpers/akismet_installer.php | 2 +- modules/akismet/tests/Akismet_Helper_Test.php | 2 +- modules/comment/controllers/admin_comments.php | 2 +- modules/comment/controllers/admin_manage_comments.php | 2 +- modules/comment/controllers/comments.php | 2 +- modules/comment/helpers/comment.php | 2 +- modules/comment/helpers/comment_block.php | 2 +- modules/comment/helpers/comment_event.php | 2 +- modules/comment/helpers/comment_installer.php | 2 +- modules/comment/helpers/comment_rest.php | 2 +- modules/comment/helpers/comment_rss.php | 2 +- modules/comment/helpers/comment_theme.php | 2 +- modules/comment/helpers/comments_rest.php | 2 +- modules/comment/helpers/item_comments_rest.php | 2 +- modules/comment/models/comment.php | 2 +- modules/comment/tests/Comment_Event_Test.php | 2 +- modules/comment/tests/Comment_Helper_Test.php | 2 +- modules/comment/tests/Comment_Model_Test.php | 2 +- modules/digibug/config/digibug.php | 2 +- modules/digibug/controllers/admin_digibug.php | 2 +- modules/digibug/controllers/digibug.php | 2 +- modules/digibug/helpers/digibug_event.php | 2 +- modules/digibug/helpers/digibug_installer.php | 2 +- modules/digibug/helpers/digibug_theme.php | 2 +- modules/digibug/models/digibug_proxy.php | 2 +- modules/digibug/tests/Digibug_Controller_Test.php | 2 +- modules/exif/controllers/exif.php | 2 +- modules/exif/helpers/exif.php | 2 +- modules/exif/helpers/exif_event.php | 2 +- modules/exif/helpers/exif_installer.php | 2 +- modules/exif/helpers/exif_task.php | 2 +- modules/exif/helpers/exif_theme.php | 2 +- modules/exif/models/exif_key.php | 2 +- modules/exif/models/exif_record.php | 2 +- modules/exif/tests/Exif_Test.php | 2 +- modules/g2_import/controllers/admin_g2_import.php | 2 +- modules/g2_import/controllers/g2.php | 2 +- modules/g2_import/helpers/g2_import.php | 2 +- modules/g2_import/helpers/g2_import_event.php | 2 +- modules/g2_import/helpers/g2_import_installer.php | 2 +- modules/g2_import/helpers/g2_import_task.php | 2 +- modules/g2_import/libraries/G2_Import_Exception.php | 2 +- modules/g2_import/models/g2_map.php | 2 +- modules/gallery/config/cache.php | 2 +- modules/gallery/config/cookie.php | 2 +- modules/gallery/config/database.php | 2 +- modules/gallery/config/locale.php | 2 +- modules/gallery/config/log_file.php | 2 +- modules/gallery/config/routes.php | 2 +- modules/gallery/config/session.php | 2 +- modules/gallery/config/upload.php | 2 +- modules/gallery/config/user_agents.php | 2 +- modules/gallery/controllers/admin.php | 2 +- modules/gallery/controllers/admin_advanced_settings.php | 2 +- modules/gallery/controllers/admin_dashboard.php | 2 +- modules/gallery/controllers/admin_graphics.php | 2 +- modules/gallery/controllers/admin_languages.php | 2 +- modules/gallery/controllers/admin_maintenance.php | 2 +- modules/gallery/controllers/admin_modules.php | 2 +- modules/gallery/controllers/admin_sidebar.php | 2 +- modules/gallery/controllers/admin_theme_options.php | 2 +- modules/gallery/controllers/admin_themes.php | 2 +- modules/gallery/controllers/admin_upgrade_checker.php | 2 +- modules/gallery/controllers/albums.php | 2 +- modules/gallery/controllers/combined.php | 2 +- modules/gallery/controllers/file_proxy.php | 2 +- modules/gallery/controllers/items.php | 2 +- modules/gallery/controllers/l10n_client.php | 2 +- modules/gallery/controllers/login.php | 2 +- modules/gallery/controllers/logout.php | 2 +- modules/gallery/controllers/movies.php | 2 +- modules/gallery/controllers/packager.php | 2 +- modules/gallery/controllers/permissions.php | 2 +- modules/gallery/controllers/photos.php | 2 +- modules/gallery/controllers/quick.php | 2 +- modules/gallery/controllers/reauthenticate.php | 2 +- modules/gallery/controllers/upgrader.php | 2 +- modules/gallery/controllers/uploader.php | 2 +- modules/gallery/controllers/user_profile.php | 2 +- modules/gallery/controllers/welcome_message.php | 2 +- modules/gallery/helpers/MY_html.php | 2 +- modules/gallery/helpers/MY_num.php | 2 +- modules/gallery/helpers/MY_remote.php | 2 +- modules/gallery/helpers/MY_url.php | 2 +- modules/gallery/helpers/MY_valid.php | 2 +- modules/gallery/helpers/access.php | 2 +- modules/gallery/helpers/ajax.php | 2 +- modules/gallery/helpers/album.php | 2 +- modules/gallery/helpers/auth.php | 2 +- modules/gallery/helpers/batch.php | 2 +- modules/gallery/helpers/block_manager.php | 2 +- modules/gallery/helpers/data_rest.php | 2 +- modules/gallery/helpers/dir.php | 2 +- modules/gallery/helpers/encoding.php | 2 +- modules/gallery/helpers/gallery.php | 2 +- modules/gallery/helpers/gallery_block.php | 2 +- modules/gallery/helpers/gallery_error.php | 2 +- modules/gallery/helpers/gallery_event.php | 2 +- modules/gallery/helpers/gallery_graphics.php | 2 +- modules/gallery/helpers/gallery_installer.php | 2 +- modules/gallery/helpers/gallery_rss.php | 2 +- modules/gallery/helpers/gallery_task.php | 2 +- modules/gallery/helpers/gallery_theme.php | 2 +- modules/gallery/helpers/graphics.php | 2 +- modules/gallery/helpers/identity.php | 2 +- modules/gallery/helpers/item.php | 2 +- modules/gallery/helpers/item_rest.php | 2 +- modules/gallery/helpers/items_rest.php | 2 +- modules/gallery/helpers/json.php | 2 +- modules/gallery/helpers/l10n_client.php | 2 +- modules/gallery/helpers/l10n_scanner.php | 2 +- modules/gallery/helpers/legal_file.php | 2 +- modules/gallery/helpers/locales.php | 2 +- modules/gallery/helpers/log.php | 2 +- modules/gallery/helpers/message.php | 2 +- modules/gallery/helpers/model_cache.php | 2 +- modules/gallery/helpers/module.php | 2 +- modules/gallery/helpers/movie.php | 2 +- modules/gallery/helpers/photo.php | 2 +- modules/gallery/helpers/random.php | 2 +- modules/gallery/helpers/site_status.php | 2 +- modules/gallery/helpers/system.php | 2 +- modules/gallery/helpers/task.php | 2 +- modules/gallery/helpers/theme.php | 2 +- modules/gallery/helpers/tree_rest.php | 2 +- modules/gallery/helpers/upgrade_checker.php | 2 +- modules/gallery/helpers/user_profile.php | 2 +- modules/gallery/helpers/xml.php | 2 +- modules/gallery/hooks/init_gallery.php | 2 +- modules/gallery/libraries/Admin_View.php | 2 +- modules/gallery/libraries/Block.php | 2 +- modules/gallery/libraries/Breadcrumb.php | 2 +- modules/gallery/libraries/Form_Script.php | 2 +- modules/gallery/libraries/Form_Uploadify.php | 2 +- modules/gallery/libraries/Form_Uploadify_buttons.php | 2 +- modules/gallery/libraries/Gallery_I18n.php | 2 +- modules/gallery/libraries/Gallery_View.php | 2 +- modules/gallery/libraries/IdentityProvider.php | 2 +- modules/gallery/libraries/InPlaceEdit.php | 2 +- modules/gallery/libraries/MY_Database.php | 2 +- modules/gallery/libraries/MY_Forge.php | 2 +- modules/gallery/libraries/MY_Input.php | 2 +- modules/gallery/libraries/MY_Kohana_Exception.php | 2 +- modules/gallery/libraries/MY_ORM.php | 2 +- modules/gallery/libraries/MY_View.php | 2 +- modules/gallery/libraries/Menu.php | 2 +- modules/gallery/libraries/ORM_MPTT.php | 2 +- modules/gallery/libraries/SafeString.php | 2 +- modules/gallery/libraries/Sendmail.php | 2 +- modules/gallery/libraries/Task_Definition.php | 2 +- modules/gallery/libraries/Theme_View.php | 2 +- modules/gallery/libraries/drivers/Cache/Database.php | 2 +- modules/gallery/libraries/drivers/IdentityProvider.php | 2 +- modules/gallery/models/access_cache.php | 2 +- modules/gallery/models/access_intent.php | 2 +- modules/gallery/models/cache.php | 2 +- modules/gallery/models/failed_auth.php | 2 +- modules/gallery/models/graphics_rule.php | 2 +- modules/gallery/models/incoming_translation.php | 2 +- modules/gallery/models/item.php | 2 +- modules/gallery/models/log.php | 2 +- modules/gallery/models/message.php | 2 +- modules/gallery/models/module.php | 2 +- modules/gallery/models/outgoing_translation.php | 2 +- modules/gallery/models/permission.php | 2 +- modules/gallery/models/task.php | 2 +- modules/gallery/models/theme.php | 2 +- modules/gallery/models/var.php | 2 +- modules/gallery/tests/Access_Helper_Test.php | 2 +- modules/gallery/tests/Albums_Controller_Test.php | 2 +- modules/gallery/tests/Breadcrumb_Test.php | 2 +- modules/gallery/tests/Cache_Test.php | 2 +- modules/gallery/tests/Controller_Auth_Test.php | 2 +- modules/gallery/tests/Data_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Database_Test.php | 2 +- modules/gallery/tests/Dir_Helper_Test.php | 2 +- modules/gallery/tests/DrawForm_Test.php | 2 +- modules/gallery/tests/File_Proxy_Controller_Test.php | 2 +- modules/gallery/tests/File_Structure_Test.php | 4 ++-- modules/gallery/tests/Gallery_Filters.php | 2 +- modules/gallery/tests/Gallery_I18n_Test.php | 2 +- modules/gallery/tests/Gallery_Installer_Test.php | 2 +- modules/gallery/tests/Html_Helper_Test.php | 2 +- modules/gallery/tests/Input_Library_Test.php | 2 +- modules/gallery/tests/Item_Helper_Test.php | 2 +- modules/gallery/tests/Item_Model_Test.php | 2 +- modules/gallery/tests/Item_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Items_Rest_Helper_Test.php | 2 +- modules/gallery/tests/Kohana_Exception_Test.php | 2 +- modules/gallery/tests/Legal_File_Helper_Test.php | 2 +- modules/gallery/tests/Locales_Helper_Test.php | 2 +- modules/gallery/tests/Menu_Test.php | 2 +- modules/gallery/tests/Movie_Helper_Test.php | 2 +- modules/gallery/tests/Num_Helper_Test.php | 2 +- modules/gallery/tests/ORM_MPTT_Test.php | 2 +- modules/gallery/tests/Photos_Controller_Test.php | 2 +- modules/gallery/tests/SafeString_Test.php | 2 +- modules/gallery/tests/Sendmail_Test.php | 2 +- modules/gallery/tests/System_Helper_Test.php | 2 +- modules/gallery/tests/Url_Security_Test.php | 2 +- modules/gallery/tests/Valid_Test.php | 2 +- modules/gallery/tests/Var_Test.php | 2 +- modules/gallery/tests/Xss_Security_Test.php | 2 +- modules/gallery_unit_test/controllers/gallery_unit_test.php | 2 +- modules/gallery_unit_test/helpers/MY_request.php | 2 +- modules/gallery_unit_test/helpers/test.php | 2 +- modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php | 2 +- modules/image_block/controllers/image_block.php | 2 +- modules/image_block/helpers/image_block_block.php | 2 +- modules/image_block/helpers/image_block_installer.php | 2 +- modules/info/helpers/info_block.php | 2 +- modules/info/helpers/info_installer.php | 2 +- modules/info/helpers/info_theme.php | 2 +- modules/kohana23_compat/config/pagination.php | 2 +- modules/kohana23_compat/libraries/MY_Database_Builder.php | 2 +- modules/kohana23_compat/libraries/Pagination.php | 2 +- modules/notification/controllers/notification.php | 2 +- modules/notification/helpers/notification.php | 2 +- modules/notification/helpers/notification_event.php | 2 +- modules/notification/helpers/notification_installer.php | 2 +- modules/notification/models/pending_notification.php | 2 +- modules/notification/models/subscription.php | 2 +- modules/organize/controllers/organize.php | 2 +- modules/organize/helpers/organize_event.php | 2 +- modules/organize/helpers/organize_installer.php | 2 +- modules/recaptcha/controllers/admin_recaptcha.php | 2 +- modules/recaptcha/helpers/recaptcha.php | 2 +- modules/recaptcha/helpers/recaptcha_event.php | 2 +- modules/recaptcha/helpers/recaptcha_installer.php | 2 +- modules/recaptcha/helpers/recaptcha_theme.php | 2 +- modules/recaptcha/libraries/Form_Recaptcha.php | 2 +- modules/rest/controllers/rest.php | 2 +- modules/rest/helpers/registry_rest.php | 2 +- modules/rest/helpers/rest.php | 2 +- modules/rest/helpers/rest_event.php | 2 +- modules/rest/helpers/rest_installer.php | 2 +- modules/rest/libraries/Rest_Exception.php | 2 +- modules/rest/models/user_access_key.php | 2 +- modules/rest/tests/Rest_Controller_Test.php | 2 +- modules/rss/controllers/rss.php | 2 +- modules/rss/helpers/rss.php | 2 +- modules/rss/helpers/rss_block.php | 2 +- modules/search/controllers/search.php | 2 +- modules/search/helpers/search.php | 2 +- modules/search/helpers/search_event.php | 2 +- modules/search/helpers/search_installer.php | 2 +- modules/search/helpers/search_task.php | 2 +- modules/search/helpers/search_theme.php | 2 +- modules/search/models/search_record.php | 2 +- modules/server_add/controllers/admin_server_add.php | 2 +- modules/server_add/controllers/server_add.php | 2 +- modules/server_add/helpers/server_add.php | 2 +- modules/server_add/helpers/server_add_event.php | 2 +- modules/server_add/helpers/server_add_installer.php | 2 +- modules/server_add/helpers/server_add_theme.php | 2 +- modules/server_add/models/server_add_entry.php | 2 +- modules/slideshow/helpers/slideshow_event.php | 2 +- modules/slideshow/helpers/slideshow_installer.php | 2 +- modules/slideshow/helpers/slideshow_theme.php | 2 +- modules/tag/controllers/admin_tags.php | 2 +- modules/tag/controllers/tag.php | 2 +- modules/tag/controllers/tag_name.php | 2 +- modules/tag/controllers/tags.php | 2 +- modules/tag/helpers/item_tags_rest.php | 2 +- modules/tag/helpers/tag.php | 2 +- modules/tag/helpers/tag_block.php | 2 +- modules/tag/helpers/tag_event.php | 2 +- modules/tag/helpers/tag_installer.php | 2 +- modules/tag/helpers/tag_item_rest.php | 2 +- modules/tag/helpers/tag_items_rest.php | 2 +- modules/tag/helpers/tag_rest.php | 2 +- modules/tag/helpers/tag_rss.php | 2 +- modules/tag/helpers/tag_task.php | 2 +- modules/tag/helpers/tag_theme.php | 2 +- modules/tag/helpers/tags_rest.php | 2 +- modules/tag/models/tag.php | 2 +- modules/tag/tests/Tag_Item_Rest_Helper_Test.php | 2 +- modules/tag/tests/Tag_Rest_Helper_Test.php | 2 +- modules/tag/tests/Tag_Test.php | 2 +- modules/tag/tests/Tags_Rest_Helper_Test.php | 2 +- modules/user/config/identity.php | 2 +- modules/user/controllers/admin_users.php | 2 +- modules/user/controllers/password.php | 2 +- modules/user/controllers/users.php | 2 +- modules/user/helpers/group.php | 2 +- modules/user/helpers/user.php | 2 +- modules/user/helpers/user_event.php | 2 +- modules/user/helpers/user_installer.php | 2 +- modules/user/helpers/user_theme.php | 2 +- modules/user/libraries/drivers/IdentityProvider/Gallery.php | 2 +- modules/user/models/group.php | 2 +- modules/user/models/user.php | 2 +- modules/user/tests/No_Direct_ORM_Access_Test.php | 2 +- modules/user/tests/User_Groups_Test.php | 2 +- modules/user/tests/User_Installer_Test.php | 2 +- modules/watermark/controllers/admin_watermarks.php | 2 +- modules/watermark/helpers/watermark.php | 2 +- modules/watermark/helpers/watermark_event.php | 2 +- modules/watermark/helpers/watermark_installer.php | 2 +- 309 files changed, 310 insertions(+), 310 deletions(-) (limited to 'modules/gallery/tests') diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 183705d9..93353b47 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -1,7 +1,7 @@ Date: Wed, 23 Jan 2013 18:24:31 -0500 Subject: Add a "can_add" permission bit similar to the "can_edit" bit to the RESTful array representation of Item_Model. Fixes #1903. --- modules/gallery/models/item.php | 12 ++++++++---- modules/gallery/tests/Item_Model_Test.php | 11 ++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 85aca2c1..bbfeee47 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -663,7 +663,7 @@ class Item_Model_Core extends ORM_MPTT { } /** - * Return a view for movies. By default this is a Flowplayer v3