summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/access.php30
-rw-r--r--modules/gallery/helpers/album.php1
-rw-r--r--modules/gallery/helpers/gallery.php3
-rw-r--r--modules/gallery/helpers/gallery_event.php14
-rw-r--r--modules/gallery/helpers/gallery_installer.php16
-rw-r--r--modules/gallery/helpers/gallery_task.php6
-rw-r--r--modules/gallery/helpers/graphics.php3
-rw-r--r--modules/gallery/helpers/locales.php1
-rw-r--r--modules/gallery/helpers/module.php12
-rw-r--r--modules/gallery/helpers/movie.php3
10 files changed, 69 insertions, 20 deletions
diff --git a/modules/gallery/helpers/access.php b/modules/gallery/helpers/access.php
index 86ea9572..52a36298 100644
--- a/modules/gallery/helpers/access.php
+++ b/modules/gallery/helpers/access.php
@@ -263,15 +263,15 @@ class access_Core {
}
/**
- * Recalculate the permissions for a given item and its hierarchy. $item must be an album.
+ * Recalculate the permissions for an album's hierarchy.
*/
- static function recalculate_permissions($item) {
+ static function recalculate_album_permissions($album) {
foreach (self::_get_all_groups() as $group) {
foreach (ORM::factory("permission")->find_all() as $perm) {
if ($perm->name == "view") {
- self::_update_access_view_cache($group, $item);
+ self::_update_access_view_cache($group, $album);
} else {
- self::_update_access_non_view_cache($group, $perm->name, $item);
+ self::_update_access_non_view_cache($group, $perm->name, $album);
}
}
}
@@ -279,6 +279,28 @@ class access_Core {
}
/**
+ * Recalculate the permissions for a single photo.
+ */
+ static function recalculate_photo_permissions($photo) {
+ $parent = $photo->parent();
+ $parent_access_cache = ORM::factory("access_cache")->where("item_id", "=", $parent->id)->find();
+ $photo_access_cache = ORM::factory("access_cache")->where("item_id", "=", $photo->id)->find();
+ foreach (self::_get_all_groups() as $group) {
+ foreach (ORM::factory("permission")->find_all() as $perm) {
+ $field = "{$perm->name}_{$group->id}";
+ if ($perm->name == "view") {
+ $photo->$field = $parent->$field;
+ } else {
+ $photo_access_cache->$field = $parent_access_cache->$field;
+ }
+ }
+ }
+ $photo_access_cache->save();
+ $photo->save();
+ model_cache::clear();
+ }
+
+ /**
* Register a permission so that modules can use it.
*
* @param string $name The internal name for for this permission
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 0ac5e8b0..89185e50 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -114,6 +114,7 @@ class album_Core {
"captured" => t("Date captured"),
"created" => t("Date uploaded"),
"title" => t("Title"),
+ "name" => t("File name"),
"updated" => t("Date modified"),
"view_count" => t("Number of views"),
"rand_key" => t("Random"));
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php
index 9430231c..ca8c92c9 100644
--- a/modules/gallery/helpers/gallery.php
+++ b/modules/gallery/helpers/gallery.php
@@ -44,7 +44,8 @@ class gallery_Core {
if (Router::$controller != "login" &&
Router::$controller != "combined" &&
identity::active_user()->guest &&
- !access::user_can(identity::guest(), "view", item::root())) {
+ !access::user_can(identity::guest(), "view", item::root()) &&
+ php_sapi_name() != "cli") {
if (Router::$controller == "admin") {
// At this point we're in the admin theme and it doesn't have a themed login page, so
// we can't just swap in the login controller and have it work. So redirect back to the
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 0ba98025..b59bb9b9 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -118,8 +118,8 @@ class gallery_event_Core {
$batch_missing_album_cover[$parent->id] = 1;
Session::instance()->set("batch_missing_album_cover", $batch_missing_album_cover);
} else {
- // Choose the first child as the new cover.
- if ($child = $parent->children(1)->current()) {
+ // Choose the first viewable child as the new cover.
+ if ($child = $parent->viewable()->children(1)->current()) {
item::make_album_cover($child);
}
}
@@ -157,7 +157,11 @@ class gallery_event_Core {
}
static function item_moved($item, $old_parent) {
- access::recalculate_permissions($item->parent());
+ if ($item->is_album()) {
+ access::recalculate_album_permissions($item->parent());
+ } else {
+ access::recalculate_photo_permissions($item);
+ }
// If the new parent doesn't have an album cover, make this it.
if (!$item->parent()->album_cover_item_id) {
@@ -211,9 +215,9 @@ class gallery_event_Core {
if (Router::$controller == "admin") {
$continue_url = url::abs_site("");
- } else if (isset($theme->item)) {
+ } else if ($item = $theme->item()) {
if (access::user_can(identity::guest(), "view", $theme->item)) {
- $continue_url = $theme->item->abs_url();
+ $continue_url = $item->abs_url();
} else {
$continue_url = item::root()->abs_url();
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index c23bcca8..83961d6b 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -302,14 +302,14 @@ class gallery_installer {
module::set_var("gallery", "maintenance_mode", 0);
module::set_var("gallery", "visible_title_length", 15);
module::set_var("gallery", "favicon_url", "lib/images/favicon.ico");
-
- // Sendmail configuration
module::set_var("gallery", "email_from", "");
module::set_var("gallery", "email_reply_to", "");
module::set_var("gallery", "email_line_length", 70);
module::set_var("gallery", "email_header_separator", serialize("\n"));
+ module::set_var("gallery", "show_user_profiles_to", "registered_users");
+ module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin");
- module::set_version("gallery", 38);
+ module::set_version("gallery", 40);
}
static function upgrade($version) {
@@ -627,6 +627,16 @@ class gallery_installer {
}
module::set_version("gallery", $version = 38);
}
+
+ if ($version == 38) {
+ module::set_var("gallery", "show_user_profiles_to", "registered_users");
+ module::set_version("gallery", $version = 39);
+ }
+
+ if ($version == 39) {
+ module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin");
+ module::set_version("gallery", $version = 40);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/helpers/gallery_task.php b/modules/gallery/helpers/gallery_task.php
index 0886aad0..3b173928 100644
--- a/modules/gallery/helpers/gallery_task.php
+++ b/modules/gallery/helpers/gallery_task.php
@@ -571,7 +571,7 @@ class gallery_task_Core {
// The new cache rows are there, but they're incorrectly populated so we have to fix
// them. If this turns out to be too slow, we'll have to refactor
// access::recalculate_permissions to allow us to do it in slices.
- access::recalculate_permissions(item::root());
+ access::recalculate_album_permissions(item::root());
$state = self::FIX_STATE_DONE;
}
break;
@@ -596,7 +596,7 @@ class gallery_task_Core {
static function find_dupe_slugs() {
return db::build()
->select_distinct(
- array("parent_slug" => new Database_Expression("CONCAT(`parent_id`, ':', `slug`)")))
+ array("parent_slug" => new Database_Expression("CONCAT(`parent_id`, ':', LOWER(`slug`))")))
->select("id")
->select(array("C" => "COUNT(\"*\")"))
->from("items")
@@ -608,7 +608,7 @@ class gallery_task_Core {
static function find_dupe_names() {
return db::build()
->select_distinct(
- array("parent_name" => new Database_Expression("CONCAT(`parent_id`, ':', `name`)")))
+ array("parent_name" => new Database_Expression("CONCAT(`parent_id`, ':', LOWER(`name`))")))
->select("id")
->select(array("C" => "COUNT(\"*\")"))
->from("items")
diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php
index bb085ea5..2868a28d 100644
--- a/modules/gallery/helpers/graphics.php
+++ b/modules/gallery/helpers/graphics.php
@@ -314,9 +314,10 @@ class graphics_Core {
$toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function");
} else {
$graphics_path = module::get_var("gallery", "graphics_toolkit_path", null);
+ $extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null);
putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") .
- ":/usr/local/bin:/opt/local/bin:/opt/bin");
+ ":" . $extra_binary_paths);
// @todo: consider refactoring the two segments below into a loop since they are so
// similar.
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 1f5473ff..d1e72260 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -92,6 +92,7 @@ class locales_Core {
$l["ko_KR"] = "한국어"; // Korean
$l["lt_LT"] = "Lietuvių"; // Lithuanian
$l["lv_LV"] = "Latviešu"; // Latvian
+ $l["mk_MK"] = "Македонски јазик"; // Macedonian
$l["nl_NL"] = "Nederlands"; // Dutch
$l["no_NO"] = "Norsk bokmål"; // Norwegian
$l["pl_PL"] = "Polski"; // Polish
diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php
index 736b6854..7863520e 100644
--- a/modules/gallery/helpers/module.php
+++ b/modules/gallery/helpers/module.php
@@ -99,6 +99,10 @@ class module_Core {
$m->code_version = $m->version;
$m->version = self::get_version($module_name);
$m->locked = false;
+
+ if ($m->active && $m->version != $m->code_version) {
+ site_status::warning(t("Some of your modules are out of date. <a href=\"%upgrader_url\">Upgrade now!</a>", array("upgrader_url" => url::site("upgrader"))), "upgrade_now");
+ }
}
// Lock certain modules
@@ -139,7 +143,7 @@ class module_Core {
}
/**
- * Allow modules to indicate the impact of deactivating the specifeid module
+ * Allow modules to indicate the impact of deactivating the specified module
* @param string $module_name
* @return array an array of warning or error messages to be displayed
*/
@@ -214,10 +218,10 @@ class module_Core {
static function upgrade($module_name) {
$version_before = module::get_version($module_name);
$installer_class = "{$module_name}_installer";
+ $available = module::available();
if (method_exists($installer_class, "upgrade")) {
call_user_func_array(array($installer_class, "upgrade"), array($version_before));
} else {
- $available = module::available();
if (isset($available->$module_name->code_version)) {
module::set_version($module_name, $available->$module_name->code_version);
} else {
@@ -234,6 +238,10 @@ class module_Core {
"version_before" => $version_before,
"version_after" => $version_after)));
}
+
+ if ($version_after != $available->$module_name->code_version) {
+ throw new Exception("@todo MODULE_FAILED_TO_UPGRADE");
+ }
}
/**
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 3e55eefe..50339541 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -86,9 +86,10 @@ class movie_Core {
static function find_ffmpeg() {
if (!($ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) || !file_exists($ffmpeg_path)) {
$graphics_path = module::get_var("gallery", "graphics_toolkit_path", null);
+ $extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null);
putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") .
- ":/usr/local/bin:/opt/local/bin:/opt/bin");
+ ":" . $extra_binary_paths);
if (function_exists("exec")) {
$ffmpeg_path = exec("which ffmpeg");
}