mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-07-14 02:50:13 -04:00
Change the fix for ticket #775 to always add the Add menu, but not add any items if the album directory is not writable.
This commit is contained in:
@@ -89,27 +89,29 @@ class gallery_Core {
|
||||
$item = $theme->item();
|
||||
|
||||
$can_edit = $item && access::can("edit", $item);
|
||||
$is_album_writable =
|
||||
is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path());
|
||||
$can_add = $item && access::can("add", $item);
|
||||
|
||||
if ($can_add && $is_album_writable) {
|
||||
if ($can_add) {
|
||||
$menu->append($add_menu = Menu::factory("submenu")
|
||||
->id("add_menu")
|
||||
->label(t("Add")));
|
||||
$add_menu->append(Menu::factory("dialog")
|
||||
->id("add_photos_item")
|
||||
->label(t("Add photos"))
|
||||
->url(url::site("simple_uploader/app/$item->id")));
|
||||
if ($item->is_album()) {
|
||||
$is_album_writable =
|
||||
is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path());
|
||||
if ($is_album_writable) {
|
||||
$add_menu->append(Menu::factory("dialog")
|
||||
->id("add_album_item")
|
||||
->label(t("Add an album"))
|
||||
->url(url::site("form/add/albums/$item->id?type=album")));
|
||||
->id("add_photos_item")
|
||||
->label(t("Add photos"))
|
||||
->url(url::site("simple_uploader/app/$item->id")));
|
||||
if ($item->is_album()) {
|
||||
$add_menu->append(Menu::factory("dialog")
|
||||
->id("add_album_item")
|
||||
->label(t("Add an album"))
|
||||
->url(url::site("form/add/albums/$item->id?type=album")));
|
||||
}
|
||||
} else {
|
||||
message::warning(t("The album '%album_name' is not writable.",
|
||||
array("album_name" => $item->title)));
|
||||
}
|
||||
} else if (!$is_album_writable) {
|
||||
message::warning(t("The album '%album_name' is not writable.",
|
||||
array("album_name" => $item->title)));
|
||||
}
|
||||
|
||||
$menu->append($options_menu = Menu::factory("submenu")
|
||||
|
||||
@@ -30,15 +30,13 @@ class server_add_event_Core {
|
||||
$item = $theme->item();
|
||||
$paths = unserialize(module::get_var("server_add", "authorized_paths"));
|
||||
|
||||
if ($item && user::active()->admin && $item->is_album() && !empty($paths)) {
|
||||
$add_menu = $menu->get("add_menu");
|
||||
if ($add_menu) {
|
||||
$add_menu
|
||||
->append(Menu::factory("dialog")
|
||||
->id("server_add")
|
||||
->label(t("Server add"))
|
||||
->url(url::site("server_add/browse/$item->id")));
|
||||
}
|
||||
if ($item && user::active()->admin && $item->is_album() && !empty($paths) &&
|
||||
is_writable($item->is_album() ? $item->file_path() : $item->parent()->file_path())) {
|
||||
$menu->get("add_menu")
|
||||
->append(Menu::factory("dialog")
|
||||
->id("server_add")
|
||||
->label(t("Server add"))
|
||||
->url(url::site("server_add/browse/$item->id")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user