summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2010-06-10 08:16:07 -0700
committerTim Almdal <tnalmdal@shaw.ca>2010-06-10 08:16:07 -0700
commit6119ddc735ccfa6816b78bb7028c56dabf322019 (patch)
treeb9cccdf2fb28e67b5cf37b26d0e0635a8cf7ad2a /modules
parentd5b80f29444e03aadc1130ab1624a09c0689fb93 (diff)
parent26d0af45eabe962c5366cb1e95de7e252b831796 (diff)
Merge branch 'master' into talmdal_dev
Diffstat (limited to 'modules')
-rw-r--r--modules/exif/tests/Exif_Test.php4
-rw-r--r--modules/gallery/models/item.php21
-rw-r--r--modules/gallery/tests/Gallery_Filters.php4
-rw-r--r--modules/gallery/tests/Item_Model_Test.php25
-rw-r--r--modules/gallery/tests/Items_Rest_Helper_Test.php4
-rw-r--r--modules/gallery/tests/xss_data.txt5
-rw-r--r--modules/gallery_unit_test/controllers/gallery_unit_test.php4
7 files changed, 51 insertions, 16 deletions
diff --git a/modules/exif/tests/Exif_Test.php b/modules/exif/tests/Exif_Test.php
index cf5af851..404b6cde 100644
--- a/modules/exif/tests/Exif_Test.php
+++ b/modules/exif/tests/Exif_Test.php
@@ -33,8 +33,8 @@ class Exif_Test extends Gallery_Unit_Test_Case {
array("caption" => "Exposure Time", "value" => "1/60 sec"),
array("caption" => "Flash", "value" => "No Flash"),
array("caption" => "Focal Length", "value" => "50 mm"),
- array("caption" => "ISO", "value" => "6553700"),
- array("caption" => "Metering Mode", "value" => "Multi-Segment"),
+ array("caption" => "ISO", "value" => "100"),
+ array("caption" => "Metering Mode", "value" => "Pattern"),
array("caption" => "Date/Time", "value" => "2008:03:17 17:41:25"),
array("caption" => "Copyright", "value" => "(C) 2008 - T. Almdal"),
array("caption" => "Orientation", "value" => "1: Normal (0 deg)"),
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 409ed3cc..009457c1 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -924,17 +924,21 @@ class Item_Model extends ORM_MPTT {
/**
* Same as ORM::as_array() but convert id fields into their RESTful form.
*/
- public function as_restful_array() {
+ public function as_restful_array($convert_ids=true) {
// Convert item ids to rest URLs for consistency
$data = $this->as_array();
- if ($tmp = $this->parent()) {
- $data["parent"] = rest::url("item", $tmp);
- }
- unset($data["parent_id"]);
- if ($tmp = $this->album_cover()) {
- $data["album_cover"] = rest::url("item", $tmp);
+
+ if ($convert_ids) {
+ if ($tmp = $this->parent()) {
+ $data["parent"] = rest::url("item", $tmp);
+ }
+ unset($data["parent_id"]);
+
+ if ($tmp = $this->album_cover()) {
+ $data["album_cover"] = rest::url("item", $tmp);
+ }
+ unset($data["album_cover_item_id"]);
}
- unset($data["album_cover_item_id"]);
if (access::can("view_full", $this) && $this->is_photo()) {
$data["file_url"] = $this->file_url(true);
@@ -944,6 +948,7 @@ class Item_Model extends ORM_MPTT {
$data["resize_url"] = $tmp;
}
$data["thumb_url"] = $this->thumb_url(true);
+ $data["can_edit"] = access::can("edit", $this);
// Elide some internal-only data that is going to cause confusion in the client.
foreach (array("relative_path_cache", "relative_url_cache", "left_ptr", "right_ptr",
diff --git a/modules/gallery/tests/Gallery_Filters.php b/modules/gallery/tests/Gallery_Filters.php
index 4e32553b..debbe846 100644
--- a/modules/gallery/tests/Gallery_Filters.php
+++ b/modules/gallery/tests/Gallery_Filters.php
@@ -28,8 +28,10 @@ class GalleryCodeFilterIterator extends FilterIterator {
public function accept() {
// Skip anything that we didn"t write
$path_name = $this->getInnerIterator()->getPathName();
+ $file_name = $this->getInnerIterator()->getFileName();
return !(
- strpos($path_name, ".svn") ||
+ $file_name == "." ||
+ $file_name == ".." ||
strpos($path_name, DOCROOT . "test") !== false ||
strpos($path_name, DOCROOT . "var") !== false ||
strpos($path_name, MODPATH . "forge") !== false ||
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 15aa2d8c..f9e6a4e3 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -18,6 +18,10 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Item_Model_Test extends Gallery_Unit_Test_Case {
+ public function teardown() {
+ identity::set_active_user(identity::admin_user());
+ }
+
public function saving_sets_created_and_updated_dates_test() {
$item = test::random_photo();
$this->assert_true(!empty($item->created));
@@ -364,6 +368,27 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(!array_key_exists("album_cover_item_id", $result));
}
+ public function as_restful_array_with_ids_test() {
+ $album = test::random_album();
+ $photo = test::random_photo($album);
+ $album->reload();
+
+ $result = $album->as_restful_array(false);
+ $this->assert_same(item::root()->id, $result["parent_id"]);
+ $this->assert_same($photo->id, $result["album_cover_item_id"]);
+ $this->assert_true(!array_key_exists("parent", $result));
+ $this->assert_true(!array_key_exists("album_cover_item", $result));
+ }
+
+ public function as_restful_array_with_edit_bit_test() {
+ $response = item::root()->as_restful_array(true);
+ $this->assert_true($response["can_edit"]);
+
+ identity::set_active_user(identity::guest());
+ $response = item::root()->as_restful_array(true);
+ $this->assert_false($response["can_edit"]);
+ }
+
public function first_photo_becomes_album_cover() {
$album = test::random_album();
$photo = test::random_photo($album);
diff --git a/modules/gallery/tests/Items_Rest_Helper_Test.php b/modules/gallery/tests/Items_Rest_Helper_Test.php
index 94bf912a..17e979a5 100644
--- a/modules/gallery/tests/Items_Rest_Helper_Test.php
+++ b/modules/gallery/tests/Items_Rest_Helper_Test.php
@@ -135,7 +135,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case {
items_rest::get($request));
}
- public function get_ancestor_test() {
+ public function get_ancestors_test() {
$album1 = test::random_album();
$photo1 = test::random_photo($album1);
$album2 = test::random_album($album1);
@@ -155,7 +155,7 @@ class Items_Rest_Helper_Test extends Gallery_Unit_Test_Case {
$request = new stdClass();
$request->params = new stdClass();
- $request->params->ancestor_for = rest::url("item", $photo2);
+ $request->params->ancestors_for = rest::url("item", $photo2);
$this->assert_equal_array(
array(
$restful_root,
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 0a75d6f7..68dca9cb 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -4,6 +4,7 @@ modules/akismet/views/admin_akismet_stats.html.php 9 DIRTY_ATTR urle
modules/comment/views/admin_block_recent_comments.html.php 4 DIRTY_ATTR text::alternate("g-even","g-odd")
modules/comment/views/admin_block_recent_comments.html.php 5 DIRTY_ATTR $comment->author()->avatar_url(32,$theme->url(,true))
modules/comment/views/admin_block_recent_comments.html.php 10 DIRTY gallery::date_time($comment->created)
+modules/comment/views/admin_comments.html.php 5 DIRTY $form
modules/comment/views/admin_manage_comments.html.php 43 DIRTY $menu->render()
modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR $comment->id
modules/comment/views/admin_manage_comments.html.php 107 DIRTY_ATTR text::alternate("g-odd","g-even")
@@ -32,8 +33,8 @@ modules/comment/views/comment.mrss.php 29 DIRTY $child
modules/comment/views/comment.mrss.php 34 DIRTY_ATTR $child->thumb_url
modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_height
modules/comment/views/comment.mrss.php 35 DIRTY_ATTR $child->thumb_width
-modules/comment/views/comments.html.php 18 DIRTY_ATTR $comment->id
-modules/comment/views/comments.html.php 21 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true))
+modules/comment/views/comments.html.php 21 DIRTY_ATTR $comment->id
+modules/comment/views/comments.html.php 24 DIRTY_ATTR $comment->author()->avatar_url(40,$theme->url(,true))
modules/comment/views/user_profile_comments.html.php 5 DIRTY_ATTR $comment->id
modules/comment/views/user_profile_comments.html.php 10 DIRTY_JS $comment->item()->url()
modules/comment/views/user_profile_comments.html.php 11 DIRTY $comment->item()->thumb_img(array(),50)
diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php
index 80ee16d9..e241e1dd 100644
--- a/modules/gallery_unit_test/controllers/gallery_unit_test.php
+++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php
@@ -89,7 +89,9 @@ class Gallery_Unit_Test_Controller extends Controller {
}
}
- // Clean out the filesystem
+ // Clean out the filesystem. Note that this cleans out test/var/database.php, but that's ok
+ // because we technically don't need it anymore. If this is confusing, we could always
+ // arrange to preserve that one file.
@system("rm -rf test/var");
@mkdir('test/var/logs', 0777, true);