summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.build_number2
-rw-r--r--modules/gallery/controllers/admin_graphics.php2
-rw-r--r--modules/gallery/controllers/albums.php1
-rw-r--r--modules/gallery/controllers/movies.php1
-rw-r--r--modules/gallery/controllers/photos.php1
-rw-r--r--modules/gallery/controllers/uploader.php2
-rw-r--r--modules/gallery/helpers/graphics.php10
-rw-r--r--modules/gallery/helpers/legal_file.php83
-rw-r--r--modules/gallery/libraries/Breadcrumb.php70
-rw-r--r--modules/gallery/libraries/Form_Uploadify.php1
-rw-r--r--modules/gallery/libraries/IdentityProvider.php12
-rw-r--r--modules/gallery/models/item.php76
-rw-r--r--modules/gallery/tests/Breadcrumb_Test.php36
-rw-r--r--modules/gallery/tests/Item_Model_Test.php23
-rw-r--r--modules/gallery/tests/xss_data.txt1
-rw-r--r--modules/gallery/views/form_uploadify.html.php2
-rw-r--r--modules/search/controllers/search.php14
-rw-r--r--modules/search/helpers/search.php2
-rw-r--r--modules/tag/controllers/tag.php17
-rw-r--r--modules/user/libraries/drivers/IdentityProvider/Gallery.php2
-rw-r--r--modules/user/models/group.php6
-rw-r--r--modules/user/models/user.php6
-rw-r--r--modules/user/views/reset_password.html.php5
-rw-r--r--themes/wind/views/page.html.php27
24 files changed, 319 insertions, 83 deletions
diff --git a/.build_number b/.build_number
index a10819e7..a533fe1e 100644
--- a/.build_number
+++ b/.build_number
@@ -3,4 +3,4 @@
; process. You don't need to edit it. In fact..
;
; DO NOT EDIT THIS FILE BY HAND!
-build_number=163
+build_number=170
diff --git a/modules/gallery/controllers/admin_graphics.php b/modules/gallery/controllers/admin_graphics.php
index a2d19d4a..a8a7cdc0 100644
--- a/modules/gallery/controllers/admin_graphics.php
+++ b/modules/gallery/controllers/admin_graphics.php
@@ -40,6 +40,8 @@ class Admin_Graphics_Controller extends Admin_Controller {
$msg = t("Changed graphics toolkit to: %toolkit", array("toolkit" => $tk->$toolkit_id->name));
message::success($msg);
log::success("graphics", $msg);
+
+ module::event("graphics_toolkit_change", $toolkit_id);
}
url::redirect("admin/graphics");
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index ccf6c1cb..1c48c734 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -69,6 +69,7 @@ class Albums_Controller extends Items_Controller {
"item" => $album,
"children" => $album->viewable()->children($page_size, $offset),
"parents" => $album->parents()->as_array(), // view calls empty() on this
+ "breadcrumbs" => Breadcrumb::array_from_item_parents($album),
"children_count" => $children_count));
$template->content = new View("album.html");
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 8e81c594..0f12c3fb 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -43,6 +43,7 @@ class Movies_Controller extends Items_Controller {
"children" => array(),
"children_count" => 0,
"parents" => $movie->parents()->as_array(),
+ "breadcrumbs" => Breadcrumb::array_from_item_parents($movie),
"next_item" => $next_item,
"previous_item" => $previous_item,
"sibling_count" => $movie->parent()->viewable()->children_count($where),
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 054300a1..af8aed16 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -43,6 +43,7 @@ class Photos_Controller extends Items_Controller {
"children" => array(),
"children_count" => 0,
"parents" => $photo->parents()->as_array(),
+ "breadcrumbs" => Breadcrumb::array_from_item_parents($photo),
"next_item" => $next_item,
"previous_item" => $previous_item,
"sibling_count" => $photo->parent()->viewable()->children_count($where),
diff --git a/modules/gallery/controllers/uploader.php b/modules/gallery/controllers/uploader.php
index 6b1455e4..9c2bf7d7 100644
--- a/modules/gallery/controllers/uploader.php
+++ b/modules/gallery/controllers/uploader.php
@@ -51,7 +51,7 @@ class Uploader_Controller extends Controller {
$file_validation = new Validation($_FILES);
$file_validation->add_rules(
"Filedata", "upload::valid", "upload::required",
- "upload::type[gif,jpg,jpeg,png,flv,mp4,m4v]");
+ "upload::type[" . implode(",", legal_file::get_extensions()) . "]");
if ($form->validate() && $file_validation->validate()) {
$temp_filename = upload::save("Filedata");
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index 39c87fbd..3548faa1 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -170,14 +170,8 @@ class graphics_Core {
foreach (self::_get_rules($target) as $rule) {
$args = array($working_file, $output_file, unserialize($rule->args), $item);
- try {
- call_user_func_array($rule->operation, $args);
- $working_file = $output_file;
- } catch (Exception $e) {
- // Ignore this rule and move on.
- Kohana_Log::add("error", "Caught exception processing image: {$item->title}\n" .
- $e->getMessage() . "\n" . $e->getTraceAsString());
- }
+ call_user_func_array($rule->operation, $args);
+ $working_file = $output_file;
}
}
diff --git a/modules/gallery/helpers/legal_file.php b/modules/gallery/helpers/legal_file.php
new file mode 100644
index 00000000..6f66c85c
--- /dev/null
+++ b/modules/gallery/helpers/legal_file.php
@@ -0,0 +1,83 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class legal_file_Core {
+ /**
+ * Create a default list of allowed photo extensions and then let modules modify it.
+ */
+ static function get_photo_extensions() {
+ $extensions_wrapper = new stdClass();
+ $extensions_wrapper->extensions = array("gif", "jpg", "jpeg", "png");
+ module::event("legal_photo_extensions", $extensions_wrapper);
+ return $extensions_wrapper->extensions;
+ }
+
+ /**
+ * Create a default list of allowed movie extensions and then let modules modify it.
+ */
+ static function get_movie_extensions() {
+ $extensions_wrapper = new stdClass();
+ $extensions_wrapper->extensions = array("flv", "mp4", "m4v");
+ module::event("legal_movie_extensions", $extensions_wrapper);
+ return $extensions_wrapper->extensions;
+ }
+
+ /**
+ * Create a merged list of all allowed photo and movie extensions.
+ */
+ static function get_extensions() {
+ $extensions = legal_file::get_photo_extensions();
+ if (movie::find_ffmpeg()) {
+ $extensions = array_merge($extensions, legal_file::get_movie_extensions());
+ }
+ return $extensions;
+ }
+
+ /**
+ * Create a merged list of all photo and movie filename filters,
+ * (e.g. "*.gif"), based on allowed extensions.
+ */
+ static function get_filters() {
+ $filters = array();
+ foreach (legal_file::get_extensions() as $extension) {
+ array_push($filters, "*." . $extension, "*." . strtoupper($extension));
+ }
+ return $filters;
+ }
+
+ /**
+ * Create a default list of allowed photo MIME types and then let modules modify it.
+ */
+ static function get_photo_types() {
+ $types_wrapper = new stdClass();
+ $types_wrapper->types = array("image/jpeg", "image/gif", "image/png");
+ module::event("legal_photo_types", $types_wrapper);
+ return $types_wrapper->types;
+ }
+
+ /**
+ * Create a default list of allowed movie MIME types and then let modules modify it.
+ */
+ static function get_movie_types() {
+ $types_wrapper = new stdClass();
+ $types_wrapper->types = array("video/flv", "video/x-flv", "video/mp4");
+ module::event("legal_movie_types", $types_wrapper);
+ return $types_wrapper->types;
+ }
+}
diff --git a/modules/gallery/libraries/Breadcrumb.php b/modules/gallery/libraries/Breadcrumb.php
new file mode 100644
index 00000000..e151890d
--- /dev/null
+++ b/modules/gallery/libraries/Breadcrumb.php
@@ -0,0 +1,70 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Breadcrumb_Core {
+ public $title;
+ public $url;
+ public $first;
+ public $last;
+
+ static function instance($title, $url) {
+ return new Breadcrumb($title, $url);
+ }
+
+ public function __construct($title, $url) {
+ $this->title = $title;
+ $this->url = $url;
+ $this->first = false;
+ $this->last = false;
+ }
+
+ /**
+ * Return an array of Breadcrumb instances build from the parents of a given item.
+ * The first and last Breadcrumb instances will be marked first/last as appropriate.
+ * Each breadcrumb will have a ?show= query parameter that refers to the id of the next
+ * item in line.
+ *
+ * @return array Breadcrumb instances
+ */
+ static function array_from_item_parents($item) {
+ if ($item->id == item::root()->id) {
+ return array();
+ }
+
+ $bc = array_merge($item->parents()->as_array(), array($item));
+ for ($i = 0; $i < count($bc) - 1; $i++) {
+ $bc[$i] = new Breadcrumb($bc[$i]->title, $bc[$i]->url("show={$bc[$i+1]->id}"));
+ }
+ $bc[$i] = new Breadcrumb($item->title, $item->url());
+
+ $bc[0]->set_first();
+ end($bc)->set_last();
+ return $bc;
+ }
+
+ public function set_first() {
+ $this->first = true;
+ return $this;
+ }
+
+ public function set_last() {
+ $this->last = true;
+ return $this;
+ }
+}
diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php
index 3e35e380..450320b3 100644
--- a/modules/gallery/libraries/Form_Uploadify.php
+++ b/modules/gallery/libraries/Form_Uploadify.php
@@ -47,6 +47,7 @@ class Form_Uploadify_Core extends Form_Input {
$v->script_data = $this->data["script_data"];
$v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit");
$v->movies_allowed = (bool) movie::find_ffmpeg();
+ $v->extensions = legal_file::get_filters();
$v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt");
list ($toolkit_max_filesize_bytes, $toolkit_max_filesize) = graphics::max_filesize();
diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php
index 153446e6..3f995923 100644
--- a/modules/gallery/libraries/IdentityProvider.php
+++ b/modules/gallery/libraries/IdentityProvider.php
@@ -110,11 +110,11 @@ class IdentityProvider_Core {
Kohana_Log::add("error", "Error restoring original identity provider\n" .
$e2->getMessage() . "\n" . $e2->getTraceAsString());
}
-
+
message::error(
t("Error attempting to enable \"%new_provider\" identity provider, reverted to \"%old_provider\" identity provider",
array("new_provider" => $new_provider, "old_provider" => $current_provider)));
-
+
$restore_already_running = false;
}
throw $e;
@@ -260,14 +260,14 @@ class IdentityProvider_Core {
/**
* @see IdentityProvider_Driver::add_user_to_group.
*/
- public function add_user_to_group($user, $group_id) {
- return $this->driver->add_user_to_group($user, $group_id);
+ public function add_user_to_group($user, $group) {
+ return $this->driver->add_user_to_group($user, $group);
}
/**
* @see IdentityProvider_Driver::remove_user_to_group.
*/
- public function remove_user_from_group($user, $group_id) {
- return $this->driver->remove_user_from_group($user, $group_id);
+ public function remove_user_from_group($user, $group) {
+ return $this->driver->remove_user_from_group($user, $group);
}
} // End Identity
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index 2a5e6894..93e97af6 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -408,6 +408,27 @@ class Item_Model_Core extends ORM_MPTT {
// If any significant fields have changed, load up a copy of the original item and
// keep it around.
$original = ORM::factory("item", $this->id);
+
+ // Preserve the extension of the data file. Many helpers, (e.g. ImageMagick), assume
+ // the MIME type from the extension. So when we adopt the new data file, it's important
+ // to adopt the new extension. That ensures that the item's extension is always
+ // appropriate for its data. We don't try to preserve the name of the data file, though,
+ // because the name is typically a temporary randomly-generated name.
+ if (isset($this->data_file)) {
+ $extension = pathinfo($this->data_file, PATHINFO_EXTENSION);
+ $new_name = pathinfo($this->name, PATHINFO_FILENAME) . ".$extension";
+ if (!empty($extension) && strcmp($this->name, $new_name)) {
+ $this->name = $new_name;
+ }
+ if ($this->is_photo()) {
+ list ($this->width, $this->height, $this->mime_type, $extension) =
+ photo::get_file_metadata($this->data_file);
+ } else if ($this->is_movie()) {
+ list ($this->width, $this->height, $this->mime_type, $extension) =
+ movie::get_file_metadata($this->data_file);
+ }
+ }
+
if (array_intersect($this->changed, array("parent_id", "name", "slug"))) {
$original->_build_relative_caches();
$this->relative_path_cache = null;
@@ -429,8 +450,19 @@ class Item_Model_Core extends ORM_MPTT {
}
if ($original->parent_id != $this->parent_id || $original->name != $this->name) {
+ $this->_build_relative_caches();
+ // If there is a data file, then we want to preserve both the old data and the new data.
+ // (Third-party event handlers would like access to both). The old data file will be
+ // accessible via the $original item, and the new one via $this item. But in that case,
+ // we don't want to rename the original as below, because the old data would end up being
+ // clobbered by the new data file. Also, the rename isn't necessary, because the new item
+ // data is coming from the data file anyway. So we only perform the rename if there isn't
+ // a data file. Another way to solve this would be to copy the original file rather than
+ // conditionally rename it, but a copy would cost far more than the rename.
+ if (!isset($this->data_file)) {
+ @rename($original->file_path(), $this->file_path());
+ }
// Move all of the items associated data files
- @rename($original->file_path(), $this->file_path());
if ($this->is_album()) {
@rename(dirname($original->resize_path()), dirname($this->resize_path()));
@rename(dirname($original->thumb_path()), dirname($this->thumb_path()));
@@ -460,8 +492,6 @@ class Item_Model_Core extends ORM_MPTT {
}
// Replace the data file, if requested.
- // @todo: we don't handle the case where you swap in a file of a different mime type
- // should we prevent that in validation? or in set_data_file()
if ($this->data_file && ($this->is_photo() || $this->is_movie())) {
copy($this->data_file, $this->file_path());
@@ -481,6 +511,9 @@ class Item_Model_Core extends ORM_MPTT {
// Null out the data file variable here, otherwise this event will trigger another
// save() which will think that we're doing another file move.
$this->data_file = null;
+ if ($original->file_path() != $this->file_path()) {
+ @unlink($original->file_path());
+ }
module::event("item_updated_data_file", $this);
}
}
@@ -517,6 +550,8 @@ class Item_Model_Core extends ORM_MPTT {
$this->name = "$base_name-$rand";
}
$this->slug = "$base_slug-$rand";
+ $this->relative_path_cache = null;
+ $this->relative_url_cache = null;
}
}
@@ -768,16 +803,7 @@ class Item_Model_Core extends ORM_MPTT {
}
if ($this->is_movie() || $this->is_photo()) {
- if ($this->loaded()) {
- // Existing items can't change their extension
- $original = ORM::factory("item", $this->id);
- $new_ext = pathinfo($this->name, PATHINFO_EXTENSION);
- $old_ext = pathinfo($original->name, PATHINFO_EXTENSION);
- if (strcasecmp($new_ext, $old_ext)) {
- $v->add_error("name", "illegal_data_file_extension");
- return;
- }
- } else {
+ if (!$this->loaded()) {
// New items must have an extension
$ext = pathinfo($this->name, PATHINFO_EXTENSION);
if (!$ext) {
@@ -785,9 +811,10 @@ class Item_Model_Core extends ORM_MPTT {
return;
}
- if ($this->is_movie() && !preg_match("/^(flv|mp4|m4v)$/i", $ext)) {
- $v->add_error("name", "illegal_data_file_extension");
- } else if ($this->is_photo() && !preg_match("/^(gif|jpg|jpeg|png)$/i", $ext)) {
+ if ($this->is_photo() &&
+ !in_array(strtolower($ext), array_map("strtolower", legal_file::get_photo_extensions())) ||
+ $this->is_movie() &&
+ !in_array(strtolower($ext), array_map("strtolower", legal_file::get_movie_extensions()))) {
$v->add_error("name", "illegal_data_file_extension");
}
}
@@ -813,17 +840,6 @@ class Item_Model_Core extends ORM_MPTT {
} else if (filesize($this->data_file) == 0) {
$v->add_error("name", "empty_data_file");
}
-
- if ($this->loaded()) {
- if ($this->is_photo()) {
- list ($a, $b, $mime_type) = photo::get_file_metadata($this->data_file);
- } else if ($this->is_movie()) {
- list ($a, $b, $mime_type) = movie::get_file_metadata($this->data_file);
- }
- if ($mime_type != $this->mime_type) {
- $v->add_error("name", "cant_change_mime_type");
- }
- }
}
/**
@@ -877,9 +893,9 @@ class Item_Model_Core extends ORM_MPTT {
switch($field) {
case "mime_type":
if ($this->is_movie()) {
- $legal_values = array("video/flv", "video/x-flv", "video/mp4");
- } if ($this->is_photo()) {
- $legal_values = array("image/jpeg", "image/gif", "image/png");
+ $legal_values = legal_file::get_movie_types();
+ } else if ($this->is_photo()) {
+ $legal_values = legal_file::get_photo_types();
}
break;
diff --git a/modules/gallery/tests/Breadcrumb_Test.php b/modules/gallery/tests/Breadcrumb_Test.php
new file mode 100644
index 00000000..ed2e5608
--- /dev/null
+++ b/modules/gallery/tests/Breadcrumb_Test.php
@@ -0,0 +1,36 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+class Breadcrumb_Test extends Gallery_Unit_Test_Case {
+ private $album;
+ private $item;
+
+ public function build_breadcrumbs_for_item_test() {
+ $album = test::random_album();
+ $item = test::random_photo($album);
+
+ $expected = array();
+ $expected[] = Breadcrumb::instance(
+ item::root()->title, item::root()->url("show={$album->id}"))->set_first();
+ $expected[] =
+ Breadcrumb::instance($album->title, $album->url("show={$item->id}"));
+ $expected[] = Breadcrumb::instance($item->title, $item->url())->set_last();
+ $this->assert_equal($expected, Breadcrumb::array_from_item_parents($item));
+ }
+} \ No newline at end of file
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index 968d7510..19ab8ec4 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -394,15 +394,34 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_equal(20337, filesize($photo->file_path()));
}
- public function replacement_data_file_must_be_same_mime_type_test() {
+ public function replace_data_file_type_test() {
// Random photo is modules/gallery/tests/test.jpg
$photo = test::random_photo();
+ $this->assert_equal(1024, $photo->width);
+ $this->assert_equal(768, $photo->height);
+ $this->assert_equal(6232, filesize($photo->file_path()));
+ $this->assert_equal("image/jpeg", $photo->mime_type);
+ $orig_name = $photo->name;
+
+ // Random photo is gallery/images/graphicsmagick.png is 104x76 and 1486 bytes
$photo->set_data_file(MODPATH . "gallery/images/graphicsmagick.png");
+ $photo->save();
+
+ $this->assert_equal(104, $photo->width);
+ $this->assert_equal(76, $photo->height);
+ $this->assert_equal(1486, filesize($photo->file_path()));
+ $this->assert_equal("image/png", $photo->mime_type);
+ $this->assert_equal("png", pathinfo($photo->name, PATHINFO_EXTENSION));
+ $this->assert_equal(pathinfo($orig_name, PATHINFO_FILENAME), pathinfo($photo->name, PATHINFO_FILENAME));
+ }
+ public function unsafe_data_file_replacement_test() {
try {
+ $photo = test::random_photo();
+ $photo->set_data_file(MODPATH . "gallery/tests/Item_Model_Test.php");
$photo->save();
} catch (ORM_Validation_Exception $e) {
- $this->assert_same(array("name" => "cant_change_mime_type"), $e->validation->errors());
+ $this->assert_same(array("mime_type" => "invalid"), $e->validation->errors());
return; // pass
}
$this->assert_true(false, "Shouldn't get here");
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 954caf54..df087669 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -184,6 +184,7 @@ modules/gallery/views/form_uploadify.html.php 16 DIRTY_JS url::s
modules/gallery/views/form_uploadify.html.php 24 DIRTY_JS $flash_minimum_version
modules/gallery/views/form_uploadify.html.php 28 DIRTY_JS url::file("lib/uploadify/uploadify.swf")
modules/gallery/views/form_uploadify.html.php 29 DIRTY_JS url::site("uploader/add_photo/{$album->id}")
+modules/gallery/views/form_uploadify.html.php 31 DIRTY_JS implode(";",$extensions)
modules/gallery/views/form_uploadify.html.php 33 DIRTY_JS url::file("lib/uploadify/cancel.png")
modules/gallery/views/form_uploadify.html.php 34 DIRTY_JS $simultaneous_upload_limit
modules/gallery/views/form_uploadify.html.php 35 DIRTY_JS $size_limit_bytes
diff --git a/modules/gallery/views/form_uploadify.html.php b/modules/gallery/views/form_uploadify.html.php
index 83dfcc68..ba4a3621 100644
--- a/modules/gallery/views/form_uploadify.html.php
+++ b/modules/gallery/views/form_uploadify.html.php
@@ -28,7 +28,7 @@
uploader: "<?= url::file("lib/uploadify/uploadify.swf") ?>",
script: "<?= url::site("uploader/add_photo/{$album->id}") ?>",
scriptData: <?= json_encode($script_data) ?>,
- fileExt: "*.gif;*.jpg;*.jpeg;*.png;*.GIF;*.JPG;*.JPEG;*.PNG<? if ($movies_allowed): ?>;*.flv;*.mp4;*.m4v;*.FLV;*.MP4;*.M4V<? endif ?>",
+ fileExt: "<?= implode(";", $extensions) ?>",
fileDesc: <?= t("Photos and movies")->for_js() ?>,
cancelImg: "<?= url::file("lib/uploadify/cancel.png") ?>",
simUploadLimit: <?= $simultaneous_upload_limit ?>,
diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php
index 261d67ee..5db63ab0 100644
--- a/modules/search/controllers/search.php
+++ b/modules/search/controllers/search.php
@@ -36,10 +36,16 @@ class Search_Controller extends Controller {
$max_pages = max(ceil($count / $page_size), 1);
$template = new Theme_View("page.html", "collection", "search");
- $template->set_global(array("page" => $page,
- "max_pages" => $max_pages,
- "page_size" => $page_size,
- "children_count" => $count));
+ $root = item::root();
+ $template->set_global(
+ array("page" => $page,
+ "max_pages" => $max_pages,
+ "page_size" => $page_size,
+ "breadcrumbs" => array(
+ Breadcrumb::instance($root->title, $root->url())->set_first(),
+ Breadcrumb::instance($q, url::abs_site("search?q=" . urlencode($q)))->set_last(),
+ ),
+ "children_count" => $count));
$template->content = new View("search.html");
$template->content->items = $result;
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php
index bbde8feb..a3fd795a 100644
--- a/modules/search/helpers/search.php
+++ b/modules/search/helpers/search.php
@@ -54,7 +54,7 @@ class search_Core {
"WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " .
$access_sql .
"ORDER BY `score` DESC " .
- "LIMIT $limit OFFSET $offset";
+ "LIMIT $limit OFFSET " . (int)$offset;
$data = $db->query($query);
$count = $db->query("SELECT FOUND_ROWS() as c")->current()->c;
diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php
index 8f885dea..7786daa1 100644
--- a/modules/tag/controllers/tag.php
+++ b/modules/tag/controllers/tag.php
@@ -34,13 +34,18 @@ class Tag_Controller extends Controller {
url::redirect(url::merge(array("page" => $max_pages)));
}
+ $root = item::root();
$template = new Theme_View("page.html", "collection", "tag");
- $template->set_global(array("page" => $page,
- "max_pages" => $max_pages,
- "page_size" => $page_size,
- "tag" => $tag,
- "children" => $tag->items($page_size, $offset),
- "children_count" => $children_count));
+ $template->set_global(
+ array("page" => $page,
+ "max_pages" => $max_pages,
+ "page_size" => $page_size,
+ "tag" => $tag,
+ "children" => $tag->items($page_size, $offset),
+ "breadcrumbs" => array(
+ Breadcrumb::instance($root->title, $root->url())->set_first(),
+ Breadcrumb::instance($tag->name, $tag->url())->set_last()),
+ "children_count" => $children_count));
$template->content = new View("dynamic.html");
$template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name));
diff --git a/modules/user/libraries/drivers/IdentityProvider/Gallery.php b/modules/user/libraries/drivers/IdentityProvider/Gallery.php
index 8cba3c82..79d31f7c 100644
--- a/modules/user/libraries/drivers/IdentityProvider/Gallery.php
+++ b/modules/user/libraries/drivers/IdentityProvider/Gallery.php
@@ -156,7 +156,7 @@ class IdentityProvider_Gallery_Driver implements IdentityProvider_Driver {
/**
* @see IdentityProvider_Driver::remove_user_to_group.
*/
- public function remove_user_from_group($user, $group_id) {
+ public function remove_user_from_group($user, $group) {
$group->remove($user);
$group->save();
}
diff --git a/modules/user/models/group.php b/modules/user/models/group.php
index 4409dcb8..46642203 100644
--- a/modules/user/models/group.php
+++ b/modules/user/models/group.php
@@ -28,6 +28,12 @@ class Group_Model_Core extends ORM implements Group_Definition {
$old = clone $this;
module::event("group_before_delete", $this);
parent::delete($id);
+
+ db::build()
+ ->delete("groups_users")
+ ->where("group_id", "=", empty($id) ? $old->id : $id)
+ ->execute();
+
module::event("group_deleted", $old);
$this->users_cache = null;
}
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index a8a3a0e7..8fe0a87b 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -43,6 +43,12 @@ class User_Model_Core extends ORM implements User_Definition {
$old = clone $this;
module::event("user_before_delete", $this);
parent::delete($id);
+
+ db::build()
+ ->delete("groups_users")
+ ->where("user_id", "=", empty($id) ? $old->id : $id)
+ ->execute();
+
module::event("user_deleted", $old);
$this->groups_cache = null;
}
diff --git a/modules/user/views/reset_password.html.php b/modules/user/views/reset_password.html.php
index 3afca881..d939ad42 100644
--- a/modules/user/views/reset_password.html.php
+++ b/modules/user/views/reset_password.html.php
@@ -9,8 +9,9 @@
<?= t("Hello, %name,", array("name" => $user->full_name ? $user->full_name : $user->name)) ?>
</p>
<p>
- <?= t("We received a request to reset your password for <a href=\"%site_url\">%site_url</a>. If you made this request, you can confirm it by <a href=\"%confirm_url\">clicking this link</a>. If you didn't request this password reset, it's ok to ignore this mail.",
- array("site_url" => html::mark_clean(url::base(false, "http")),
+ <?= t("We received a request to reset your password for <a href=\"%site_url\">%base_url</a>. If you made this request, you can confirm it by <a href=\"%confirm_url\">clicking this link</a>. If you didn't request this password reset, it's ok to ignore this mail.",
+ array("site_url" => html::mark_clean(url::abs_site("/")),
+ "base_url" => html::mark_clean(url::base(false)),
"confirm_url" => $confirm_url)) ?>
</p>
</body>
diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php
index 045e3c45..534b7de4 100644
--- a/themes/wind/views/page.html.php
+++ b/themes/wind/views/page.html.php
@@ -107,28 +107,15 @@
<?= $theme->header_bottom() ?>
</div>
- <? if ($theme->item() && !empty($parents)): ?>
+ <? if (!empty($breadcrumbs)): ?>
<ul class="g-breadcrumbs">
- <? $i = 0 ?>
- <? foreach ($parents as $parent): ?>
- <li<? if ($i == 0) print " class=\"g-first\"" ?>>
- <? // Adding ?show=<id> causes Gallery3 to display the page
- // containing that photo. For now, we just do it for
- // the immediate parent so that when you go back up a
- // level you're on the right page. ?>
- <a href="<?= $parent->url($parent->id == $theme->item()->parent_id ?
- "show={$theme->item()->id}" : null) ?>">
- <? // limit the title length to something reasonable (defaults to 15) ?>
- <?= html::purify(text::limit_chars($parent->title,
- module::get_var("gallery", "visible_title_length"))) ?>
- </a>
- </li>
- <? $i++ ?>
+ <? foreach ($breadcrumbs as $breadcrumb): ?>
+ <li class="<?= $breadcrumb->last ? "g-active" : "" ?>
+ <?= $breadcrumb->first ? "g-first" : "" ?>">
+ <? if (!$breadcrumb->last): ?> <a href="<?= $breadcrumb->url ?>"><? endif ?>
+ <?= html::purify(text::limit_chars($breadcrumb->title, module::get_var("gallery", "visible_title_length"))) ?>
+ <? if (!$breadcrumb->last): ?></a><? endif ?>
<? endforeach ?>
- <li class="g-active<? if ($i == 0) print " g-first" ?>">
- <?= html::purify(text::limit_chars($theme->item()->title,
- module::get_var("gallery", "visible_title_length"))) ?>
- </li>
</ul>
<? endif ?>
</div>