From be5f38adea89bdb95be359aea3d97615b6b530a3 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 31 Jan 2010 14:03:32 -0800
Subject: Minir l10n message cleanup. Avoid
in messages since the server
normalizes them to
, i.e. leading to a mismatch.
---
modules/gallery/views/upgrader.html.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index 6cf0068d..4490557c 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -112,7 +112,9 @@
else: // can_upgrade ?>
= t("Who are you?") ?>
- = t("You're not logged in as an administrator, so we have to verify you to make sure it's ok for you to do an upgrade. To prove you can run an upgrade, create a file called
%name in your gallery3/var/tmp directory.", array("name" => "$upgrade_token")) ?>
+ = t("You're not logged in as an administrator, so we have to verify you to make sure it's ok for you to do an upgrade. To prove you can run an upgrade, create a file called %name in your %tmp_dir_path directory.",
+ array("name" => "$upgrade_token",
+ "tmp_dir_path" => "gallery3/var/tmp")) ?>
">= t("Ok, I've done that") ?>
endif // can_upgrade ?>
--
cgit v1.2.3
From 1f51d663a0d651cfc8ff172357ce1b57823f8480 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Wed, 3 Feb 2010 08:18:53 -0800
Subject: Correct missing function name.
---
modules/gallery/helpers/auth.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index 717cf40a..45561861 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -102,7 +102,7 @@ class auth_Core {
/**
* Clear any failed logins for this user
*/
- static function clear_failed_logins($user) {
+ static function clear_failed_auth_attempts($user) {
db::build()
->delete("failed_logins")
->where("name", "=", $user->name)
--
cgit v1.2.3
From cc1d25ae0a706ea5969b88e871549800630b7e03 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Thu, 4 Feb 2010 07:46:10 -0800
Subject: remove debugging statement
---
modules/notification/helpers/notification.php | 2 --
1 file changed, 2 deletions(-)
(limited to 'modules')
diff --git a/modules/notification/helpers/notification.php b/modules/notification/helpers/notification.php
index dfeab9fc..3e4854d7 100644
--- a/modules/notification/helpers/notification.php
+++ b/modules/notification/helpers/notification.php
@@ -107,8 +107,6 @@ class notification {
t("Photo \"%title\" updated", array("title" => $original->title))
: t("Movie \"%title\" updated", array("title" => $original->title)));
- Kohana_Log::add("error",print_r($v->render(),1));
-
self::_notify($subscribers, $item, $v->render(), $v->subject);
}
--
cgit v1.2.3
From aa4ed454737d45bf8140fd84f2eea2e04ed4a7d6 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Wed, 3 Feb 2010 09:43:22 -0800
Subject: Differentiate between selected and non selected items.
---
modules/organize/css/organize.css | 12 +++---------
modules/organize/views/organize_thumb_grid.html.php | 8 ++++----
themes/wind/css/screen.css | 1 +
3 files changed, 8 insertions(+), 13 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css
index d8923ea7..bc8e5b0c 100644
--- a/modules/organize/css/organize.css
+++ b/modules/organize/css/organize.css
@@ -87,16 +87,10 @@
}
.g-organize-microthumb-grid-cell {
- margin: 6px;
- padding: 0 !important;
- position: relative;
-}
-
-.g-organize-microthumb {
display: block;
height: 100px;
- margin: 0;
- padding: .4em 0;
+ margin: 6px;
+ padding: .4em 0 !important;
position: relative;
text-align: center;
width: 110px;
@@ -106,7 +100,7 @@
z-index: 2000 !important;
}
-.g-organize-microthumb .ui-icon {
+.g-organize-microthumb-grid-cell .ui-icon {
bottom: 0;
left: 0;
position: absolute;
diff --git a/modules/organize/views/organize_thumb_grid.html.php b/modules/organize/views/organize_thumb_grid.html.php
index 9a9cd819..f29680f7 100644
--- a/modules/organize/views/organize_thumb_grid.html.php
+++ b/modules/organize/views/organize_thumb_grid.html.php
@@ -1,11 +1,11 @@
foreach ($album->children(25, $offset) as $child): ?>
-
- ui-state-active">
+
+
= $child->thumb_img(array("class" => "g-thumbnail", "ref" => $child->id), 90, true) ?>
is_album() ? " class=\"ui-icon ui-icon-note\"" : "" ?>>
-
+
endforeach ?>
diff --git a/themes/wind/css/screen.css b/themes/wind/css/screen.css
index 12fa695d..630e8bbd 100644
--- a/themes/wind/css/screen.css
+++ b/themes/wind/css/screen.css
@@ -447,3 +447,4 @@ td {
.rtl #g-view-menu #g-slideshow-link {
background-image: url('../images/ico-view-slideshow-rtl.png');
}
+
--
cgit v1.2.3
From 95b26db82c3f835f66cdb32aef13aa84a6a206e5 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Wed, 3 Feb 2010 13:56:04 -0800
Subject: 1) Simplify the layout of the organize dialog content. 2) Use CSS to
layout the thmbnail grid to the full dialog size. Fixes ticker #848. 3)
Separate css that can be themed into organize_theme.css. This isolates the
themed components into a separate file for easy of overriding by a theme.
---
modules/organize/css/organize.css | 47 ++++++++++++----------
modules/organize/css/organize_theme.css | 10 +++++
modules/organize/helpers/organize_theme.php | 1 +
modules/organize/js/organize.js | 30 +++++++-------
modules/organize/views/organize_dialog.html.php | 10 ++---
.../organize/views/organize_thumb_grid.html.php | 12 +++---
6 files changed, 60 insertions(+), 50 deletions(-)
create mode 100644 modules/organize/css/organize_theme.css
(limited to 'modules')
diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css
index bc8e5b0c..ef1f856b 100644
--- a/modules/organize/css/organize.css
+++ b/modules/organize/css/organize.css
@@ -3,18 +3,18 @@
*/
#g-organize {
- height: auto;
margin: 0 !important;
+ min-height: auto;
padding: 0 !important;
position: relative;
width: 100%;
}
#g-organize-content-pane {
- height: auto;
+ height: 100%;
margin: 0 !important;
padding: 0 !important;
- position: relative;
+ position: absolute;
width: 100%;
}
@@ -23,11 +23,15 @@
*/
#g-organize #g-organize-tree-container {
- height: 100%;
- overflow: auto;
margin: 0;
+ min-height: 100%;
padding: 0;
- width: 19%;
+ position: relative;
+ width: 20%;
+}
+
+#g-organize #g-organize-tree-container h3 {
+ margin-bottom: 0.1em;
}
#g-organize-album-tree {
@@ -54,10 +58,10 @@
*/
#g-organize #g-organize-detail {
- height: 100%;
margin: 0 !important;
- overflow: hidden;
+ min-height: 100%;
padding: 0 !important;
+ position: relative;
width: 80%;
}
@@ -71,21 +75,17 @@
width: inherit;
}
-#g-organize-microthumb-panel {
- height: 100%;
- margin: 0 !important;
- position: relative;
- padding: 0 !important;
- width: 100%;
-}
-
#g-organize-microthumb-grid {
- height: 100%;
- overflow: auto;
+ bottom: 1.8em;
+ left: 0;
+ margin: 0 !important;
+ overflow-x: hidden;
+ overflow-y: auto;
padding: .4em !important;
- position: relative;
+ position: absolute;
+ right: 0;
+ top: 1.6em;
}
-
.g-organize-microthumb-grid-cell {
display: block;
height: 100px;
@@ -112,8 +112,13 @@
*/
#g-organize-controls {
+ bottom: 0;
+ height: 1.9em;
+ left: 0;
margin: 0 !important;
- padding: .2em .4em;
+ padding: .1em .4em;
+ position: absolute;
+ right: 0;
}
#g-organize-controls select {
diff --git a/modules/organize/css/organize_theme.css b/modules/organize/css/organize_theme.css
new file mode 100644
index 00000000..727dca97
--- /dev/null
+++ b/modules/organize/css/organize_theme.css
@@ -0,0 +1,10 @@
+/** *******************************************************************
+ * Organize styles that are theme overrideable
+ *********************************************************************/
+.g-organize-microthumb-grid-cell.ui-selected {
+ background: #DFEFFC !important;
+}
+
+#g-organize-microthumb-grid {
+ border: 1px solid #79B7E7;
+}
diff --git a/modules/organize/helpers/organize_theme.php b/modules/organize/helpers/organize_theme.php
index 61b6fe7d..c2914675 100644
--- a/modules/organize/helpers/organize_theme.php
+++ b/modules/organize/helpers/organize_theme.php
@@ -27,6 +27,7 @@ class organize_theme {
// approach that lets us continue to use the Kohana cascading filesystem.
$theme->script("organize.js");
$theme->css("organize.css");
+ $theme->css("organize_theme.css");
}
}
}
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 76eadf85..a89305f6 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -4,15 +4,15 @@
handle: ".ui-selected",
distance: 10,
cursorAt: { left: -10, top: -10},
- appendTo: "#g-organize-microthumb-panel",
+ appendTo: "#g-organize",
helper: function(event, ui) {
var selected = $(".ui-draggable.ui-selected img");
if (selected.length) {
var set = $('')
.css({
- zIndex: 2000,
- width: 80,
- height: Math.ceil(selected.length / 5) * 16
+ zIndex: 2000,
+ width: 80,
+ height: Math.ceil(selected.length / 5) * 16
});
var offset = $(this).offset();
var click = {left: event.pageX - offset.left, top: event.pageY - offset.top};
@@ -37,16 +37,16 @@
},
start: function(event, ui) {
- $("#g-organize-microthumb-panel .ui-selected").hide();
+ $("#g-organize-microthumb-grid .ui-selected").hide();
},
drag: function(event, ui) {
- var top = $("#g-organize-microthumb-panel").offset().top;
- var height = $("#g-organize-microthumb-panel").height();
+ var top = $("#g-organize-microthumb-grid").offset().top;
+ var height = $("#g-organize-microthumb-grid").height();
if (ui.offset.top > height + top - 20) {
- $("#g-organize-microthumb-panel").get(0).scrollTop += 100;
+ $("#g-organize-microthumb-grid").get(0).scrollTop += 100;
} else if (ui.offset.top < top + 20) {
- $("#g-organize-microthumb-panel").get(0).scrollTop = Math.max(0, $("#g-organize-microthumb-panel").get(0).scrollTop - 100);
+ $("#g-organize-microthumb-grid").get(0).scrollTop = Math.max(0, $("#g-organize-microthumb-grid").get(0).scrollTop - 100);
}
}
},
@@ -63,7 +63,7 @@
target_id = $(".currentDropTarget").attr("ref");
} else {
before_or_after = "after";
- target_id = $("#g-organize-microthumb-grid li:last").attr("ref");
+ target_id = $("#g-organize-microthumb-grid div:last").attr("ref");
}
$.organize.do_drop({
url: rearrange_url
@@ -92,7 +92,7 @@
},
do_drop: function(options) {
- $("#g-organize-microthumb-panel").selectable("destroy");
+ $("#g-organize-microthumb-grid").selectable("destroy");
var source_ids = [];
$(options.source).each(function(i) {
source_ids.push($(this).attr("ref"));
@@ -102,7 +102,7 @@
$.post(options.url,
{ "source_ids[]": source_ids },
function(data) {
- $.organize._refresh(data);
+ $.organize._refresh(data);
},
"json");
}
@@ -141,8 +141,6 @@
$("#g-dialog").dialog("option", "zIndex", 70);
$("#g-dialog").bind("dialogopen", function(event, ui) {
$("#g-organize").height($("#g-dialog").innerHeight() - 20);
- $("#g-organize-microthumb-grid").height($("#g-dialog").innerHeight() - 91);
- $("#g-organize-tree-container").height($("#g-dialog").innerHeight() - 60);
});
$("#g-dialog").bind("dialogclose", function(event, ui) {
@@ -210,11 +208,11 @@
if ($(parent).hasClass("g-view-only")) {
return;
}
- $("#g-organize-microthumb-panel").selectable("destroy");
+ $("#g-organize-microthumb-grid").selectable("destroy");
var id = $(event.currentTarget).attr("ref");
$(".g-organize-album-text.ui-state-focus").removeClass("ui-state-focus");
$(".g-organize-album-text[ref=" + id + "]").addClass("ui-state-focus");
- var url = $("#g-organize-microthumb-panel").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0);
+ var url = $("#g-organize-microthumb-grid").attr("ref").replace("__ITEM_ID__", id).replace("__OFFSET__", 0);
$.get(url, {},
function(data) {
$("#g-organize-microthumb-grid").html(data.grid);
diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php
index 435f5ae3..3d824886 100644
--- a/modules/organize/views/organize_dialog.html.php
+++ b/modules/organize/views/organize_dialog.html.php
@@ -15,14 +15,12 @@
-
diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php
index 49ed01fc..3912c1f6 100644
--- a/modules/organize/views/organize_tree.html.php
+++ b/modules/organize/views/organize_tree.html.php
@@ -1,9 +1,9 @@
-
"
+"
ref="= $album->id ?>">
-
+
- "
+ "
ref="= $album->id ?>">
= html::clean($album->title) ?>
@@ -12,10 +12,10 @@
if ($selected && $child->contains($selected)): ?>
= View::factory("organize_tree.html", array("selected" => $selected, "album" => $child)); ?>
else: ?>
- "
+ "
ref="= $child->id ?>">
-
- " ref="= $child->id ?>">
+
+ " ref="= $child->id ?>">
= html::clean($child->title) ?>
--
cgit v1.2.3
From bc14f33ae134dd9c93bf35ad90c91d84fdac587f Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Fri, 5 Feb 2010 11:15:28 -0800
Subject: Fix an issue where the dragged item was always inserted after the
target image.
---
modules/organize/js/organize.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 9b9b6495..f85e02b5 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -60,7 +60,7 @@
$.organize.do_drop({
url: rearrange_url
.replace("__TARGET_ID__", target.id)
- .replace("__BEFORE__", target.before ? "before" : "after"),
+ .replace("__BEFORE__", target.position ? "before" : "after"),
source: $(ui.helper).children("img")
});
}
--
cgit v1.2.3
From 64c37aed0787ee01c89df382f9645f35a7e6ba14 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Fri, 5 Feb 2010 14:38:24 -0800
Subject: continuing cleaninup organize javascript especially the drag and drop
functionality.
---
modules/organize/js/organize.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 9b9b6495..6f581208 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -4,7 +4,7 @@
handle: ".ui-selected",
distance: 10,
cursorAt: { left: -10, top: -10},
- appendTo: "#g-organize",
+ appendTo: "#g-organize-content-pane",
helper: function(event, ui) {
var selected = $(".ui-draggable.ui-selected img");
if (selected.length) {
@@ -14,8 +14,6 @@
width: 80,
height: Math.ceil(selected.length / 5) * 16
});
- var offset = $(this).offset();
- var click = {left: event.pageX - offset.left, top: event.pageY - offset.top};
selected.each(function(i) {
var row = parseInt(i / 5);
@@ -43,11 +41,13 @@
drag: function(event, ui) {
var top = $("#g-organize-microthumb-grid").offset().top;
var height = $("#g-organize-microthumb-grid").height();
+ var scrollTop = $("#g-organize-microthumb-grid").scrollTop();
if (ui.offset.top > height + top - 20) {
- $("#g-organize-microthumb-grid").get(0).scrollTop += 100;
+ scrollTop += 100;
} else if (ui.offset.top < top + 20) {
- $("#g-organize-microthumb-grid").get(0).scrollTop = Math.max(0, $("#g-organize-microthumb-grid").get(0).scrollTop - 100);
+ scrollTop = Math.max(0, scrollTop - 100);
}
+ $("#g-organize-microthumb-grid").scrollTop(scrollTop);
}
},
--
cgit v1.2.3
From 73527fba611d7d441c6fd2e988510cb0c4e46f99 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Fri, 5 Feb 2010 23:38:06 -0800
Subject: 1) Manually added the .selectee class on subsequent downloads. fixes
ticket #970 2) Reworked the calculated of the drop target marker to account
for scrolling.
---
modules/organize/js/organize.js | 64 +++++++++++++++++------------------------
1 file changed, 27 insertions(+), 37 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index fd8a0fff..276fc3fa 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -59,8 +59,8 @@
var target = $("#g-organize-drop-target-marker").data("drop_position");
$.organize.do_drop({
url: rearrange_url
- .replace("__TARGET_ID__", target.id)
- .replace("__BEFORE__", target.position ? "before" : "after"),
+ .replace("__TARGET_ID__", target.id)
+ .replace("__BEFORE__", target.position ? "before" : "after"),
source: $(ui.helper).children("img")
});
}
@@ -72,8 +72,8 @@
greedy: true,
drop: function(event, ui) {
if ($(event.target).hasClass("g-view-only")) {
+ $("#g-organize-drop-target-marker").remove();
$(".ui-selected").show();
- $(".g-organize-microthumb-grid-cell").css("borderStyle", "none");
} else {
$.organize.do_drop({
url: move_url.replace("__ALBUM_ID__", $(event.target).attr("ref")),
@@ -134,48 +134,35 @@
if ($(".g-drag-helper").length) {
var cellSize = $("#g-organize").data("cellSize");
var thumbnailCount = $(".g-organize-microthumb-grid-cell:visible").length;
- var rows = Math.ceil(thumbnailCount / cellSize.columns);
-
+ var scrollTop = $("#g-organize-microthumb-grid").scrollTop();
var itemPos = {
- col: Math.floor((event.pageX - $(this).offset().left) / cellSize.width),
- row: Math.floor((event.pageY - $(this).offset().top) / cellSize.height)
+ col: Math.floor((event.pageX - $("#g-organize-microthumb-grid").offset().left) / cellSize.width),
+ row: Math.floor((event.pageY + scrollTop - $("#g-organize-microthumb-grid").offset().top) / cellSize.height)
};
- var itemIndex = itemPos.row * cellSize.columns + itemPos.col;
- var item;
- if (itemIndex < thumbnailCount) {
- item = $(".g-organize-microthumb-grid-cell:visible").get(itemIndex);
- } else {
- item = $(".g-organize-microthumb-grid-cell:visible:last");
- }
+ var itemIndex = itemPos.row * cellSize.columns + itemPos.col;
+ var item = itemIndex < thumbnailCount ? $(".g-organize-microthumb-grid-cell:visible").get(itemIndex) :
+ $(".g-organize-microthumb-grid-cell:visible:last");
- var old_position = {top: 0, left: 0};
- if ($("#g-organize-drop-target-marker").length) {
- old_position = $("#g-organize-drop-target-marker").position();
- }
var before = event.pageX < ($(item).offset().left + $(item).width() / 2);
-
var left = (before && itemIndex < thumbnailCount ? $(item).position().left : $(item).position().left + cellSize.width) - 3;
- var top = $(item).position().top + 6;
+ var top = $(item).position().top + 6 + scrollTop;
- if (old_position.top != top || old_position.left != left) {
- if ($("#g-organize-drop-target-marker").length) {
- $("#g-organize-drop-target-marker").remove();
- }
- var set = $('')
- .css({zIndex: 2000,
- width: 2,
- height: 112,
- borderWidth: 1,
- borderStyle: "solid",
- position: "absolute",
- top: top,
- left: left
- })
- .data("drop_position", {id: $(item).attr("ref"), position: before});
- $("#g-organize-microthumb-grid").append(set);
+ if ($("#g-organize-drop-target-marker").length) {
+ $("#g-organize-drop-target-marker").remove();
}
+ var set = $('')
+ .css({zIndex: 2000,
+ width: 2,
+ height: 112,
+ borderWidth: 1,
+ borderStyle: "solid",
+ position: "absolute",
+ top: top, left: left
+ })
+ .data("drop_position", {id: $(item).attr("ref"), position: before});
+ $("#g-organize-microthumb-grid").append(set);
}
},
@@ -190,12 +177,13 @@
$("#g-dialog").bind("dialogopen", function(event, ui) {
var outerHeight = $(".g-organize-microthumb-grid-cell").outerHeight(true);
var outerWidth = $(".g-organize-microthumb-grid-cell").outerWidth(true);
+ var gridInnerWidth = $("#g-organize-microthumb-grid").innerWidth() - 2 * parseFloat($("#g-organize-microthumb-grid").css("paddingLeft"));
$("#g-organize")
.height($("#g-dialog").innerHeight() - 20)
.data("cellSize", {
height: outerHeight,
width: outerWidth,
- columns: Math.floor($("#g-organize-microthumb-grid").innerWidth() / outerWidth)
+ columns: Math.floor(gridInnerWidth / outerWidth)
});
});
@@ -222,6 +210,8 @@
.mouseleave($.organize.grid_mouse_leave_handler)
.droppable($.organize.content_droppable);
$(".g-organize-microthumb-grid-cell")
+ // need to manually add this class in case we care calling with additional elements
+ .addClass("ui-selectee")
.draggable($.organize.micro_thumb_draggable);
$(".g-organize-album").droppable($.organize.branch_droppable);
$(".g-organize-album-text").click($.organize.show_album);
--
cgit v1.2.3
From f631c2a0e5d1de4d17478993fc0cac2c9a989df2 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sat, 6 Feb 2010 09:30:25 -0800
Subject: Fix up Admin_Users_Controller() form handling now that user_form.html
is gone. Fixes ticket #1005.
---
modules/user/controllers/admin_users.php | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
(limited to 'modules')
diff --git a/modules/user/controllers/admin_users.php b/modules/user/controllers/admin_users.php
index 48847433..df3d96c9 100644
--- a/modules/user/controllers/admin_users.php
+++ b/modules/user/controllers/admin_users.php
@@ -60,9 +60,7 @@ class Admin_Users_Controller extends Admin_Controller {
}
public function add_user_form() {
- $v = new View("user_form.html");
- $v->form = $this->_get_user_add_form_admin();
- print $v;
+ print $this->_get_user_add_form_admin();
}
public function delete_user($id) {
@@ -147,13 +145,7 @@ class Admin_Users_Controller extends Admin_Controller {
throw new Kohana_404_Exception();
}
- $v = new View("user_form.html");
- $v->form = $this->_get_user_edit_form_admin($user);
- // Don't allow the user to control their own admin bit, else you can lock yourself out
- if ($user->id == identity::active_user()->id) {
- $v->form->edit_user->admin->disabled(1);
- }
- print $v;
+ print $this->_get_user_edit_form_admin($user);
}
public function add_user_to_group($user_id, $group_id) {
@@ -293,6 +285,9 @@ class Admin_Users_Controller extends Admin_Controller {
->error_messages("length", t("This name is too long"));
$group->password("password")->label(t("Password"))->id("g-password")
->error_messages("min_length", t("This password is too short"));
+ $group->script("")
+ ->text(
+ '$("form").ready(function(){$(\'input[name="password"]\').user_password_strength();});');
$group->password("password2")->label(t("Confirm password"))->id("g-password2")
->error_messages("matches", t("The passwords you entered do not match"))
->matches($group->password);
@@ -305,6 +300,11 @@ class Admin_Users_Controller extends Admin_Controller {
self::_add_locale_dropdown($group, $user);
$group->checkbox("admin")->label(t("Admin"))->id("g-admin")->checked($user->admin);
+ // Don't allow the user to control their own admin bit, else you can lock yourself out
+ if ($user->id == identity::active_user()->id) {
+ $group->admin->disabled(1);
+ }
+
module::event("user_edit_form_admin", $user, $form);
$group->submit("")->value(t("Modify User"));
return $form;
@@ -321,6 +321,9 @@ class Admin_Users_Controller extends Admin_Controller {
->error_messages("length", t("This name is too long"));
$group->password("password")->label(t("Password"))->id("g-password")
->error_messages("min_length", t("This password is too short"));
+ $group->script("")
+ ->text(
+ '$("form").ready(function(){$(\'input[name="password"]\').user_password_strength();});');
$group->password("password2")->label(t("Confirm password"))->id("g-password2")
->error_messages("matches", t("The passwords you entered do not match"))
->matches($group->password);
--
cgit v1.2.3
From 83f61ff5cf9c51c998dac9dad23d74ab7339ead5 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sat, 6 Feb 2010 09:47:56 -0800
Subject: Insure that the 'Ascending'/'Descending' string are translated on the
organize dialog.
---
modules/organize/views/organize_dialog.html.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php
index e36264f9..7a16f56c 100644
--- a/modules/organize/views/organize_dialog.html.php
+++ b/modules/organize/views/organize_dialog.html.php
@@ -30,7 +30,9 @@
= t("Sort order") ?>
= form::dropdown(array("id" => "g-organize-sort-column"), album::get_sort_order_options(), $album->sort_column) ?>
- = form::dropdown(array("id" => "g-organize-sort-order"), array("ASC" => "Ascending", "DESC" => "Descending"), $album->sort_order) ?>
+ = form::dropdown(array("id" => "g-organize-sort-order"),
+ array("ASC" => t("Ascending"), "DESC" => t("Descending")),
+ $album->sort_order) ?>
--
cgit v1.2.3
From 15e22076552929bf1f45888945f65de621aa2aac Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sat, 6 Feb 2010 10:12:53 -0800
Subject: correct layout of html for readability
---
modules/organize/views/organize_dialog.html.php | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php
index 7a16f56c..38d05b81 100644
--- a/modules/organize/views/organize_dialog.html.php
+++ b/modules/organize/views/organize_dialog.html.php
@@ -29,10 +29,14 @@
- = t("Sort order") ?>
-
- = form::dropdown(array("id" => "g-organize-sort-column"), album::get_sort_order_options(), $album->sort_column) ?>
-
- = form::dropdown(array("id" => "g-organize-sort-order"),
- array("ASC" => t("Ascending"), "DESC" => t("Descending")),
- $album->sort_order) ?>
+ = form::dropdown(array("id" => "g-organize-sort-column"),
+ album::get_sort_order_options(), $album->sort_column) ?>
+
+
+ = form::dropdown(array("id" => "g-organize-sort-order"),
+ array("ASC" => t("Ascending"), "DESC" => t("Descending")), $album->sort_order) ?>
+
+
--
cgit v1.2.3
From 0f9d23d074c81eafab05ce5d64909da624a86422 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sat, 6 Feb 2010 10:34:57 -0800
Subject: Cleanup the position of the drop marker.
---
modules/organize/js/organize.js | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 276fc3fa..2a18cb40 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -132,21 +132,19 @@
grid_mouse_move_handler: function(event) {
if ($(".g-drag-helper").length) {
- var cellSize = $("#g-organize").data("cellSize");
- var thumbnailCount = $(".g-organize-microthumb-grid-cell:visible").length;
+ var organizeData = $("#g-organize").data("organizeData");
+ var thumbGrid = $("#g-organize-microthumb-grid");
+ var visibleCells = $(".g-organize-microthumb-grid-cell:visible");
+ var scrollTop = thumbGrid.scrollTop();
- var scrollTop = $("#g-organize-microthumb-grid").scrollTop();
- var itemPos = {
- col: Math.floor((event.pageX - $("#g-organize-microthumb-grid").offset().left) / cellSize.width),
- row: Math.floor((event.pageY + scrollTop - $("#g-organize-microthumb-grid").offset().top) / cellSize.height)
- };
-
- var itemIndex = itemPos.row * cellSize.columns + itemPos.col;
- var item = itemIndex < thumbnailCount ? $(".g-organize-microthumb-grid-cell:visible").get(itemIndex) :
- $(".g-organize-microthumb-grid-cell:visible:last");
+ var itemColumn = Math.floor((event.pageX - thumbGrid.offset().left) / organizeData.width);
+ var itemRow = Math.floor((event.pageY + scrollTop - thumbGrid.offset().top) / organizeData.height);
+ var itemIndex = Math.min(itemRow * organizeData.columns + itemColumn, visibleCells.length - 1);
+ var item = visibleCells.get(itemIndex);
var before = event.pageX < ($(item).offset().left + $(item).width() / 2);
- var left = (before && itemIndex < thumbnailCount ? $(item).position().left : $(item).position().left + cellSize.width) - 3;
+ var left = (before && itemIndex < visibleCells.length ?
+ $(item).position().left : $(item).position().left + organizeData.width) - 3;
var top = $(item).position().top + 6 + scrollTop;
if ($("#g-organize-drop-target-marker").length) {
@@ -162,7 +160,7 @@
top: top, left: left
})
.data("drop_position", {id: $(item).attr("ref"), position: before});
- $("#g-organize-microthumb-grid").append(set);
+ thumbGrid.append(set);
}
},
@@ -180,7 +178,8 @@
var gridInnerWidth = $("#g-organize-microthumb-grid").innerWidth() - 2 * parseFloat($("#g-organize-microthumb-grid").css("paddingLeft"));
$("#g-organize")
.height($("#g-dialog").innerHeight() - 20)
- .data("cellSize", {
+ .data("organizeData", {
+ leftright: !$("body").hasClass("rtl"),
height: outerHeight,
width: outerWidth,
columns: Math.floor(gridInnerWidth / outerWidth)
--
cgit v1.2.3
From 5c0c33782d7dd3556adecb9593f25f2cff06401a Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 12:19:55 -0800
Subject: Fix for ticket 892: Avoid double escaping of HTML entities, instead
use Unicode in the source code for the locale names (as we do in other places
already).
Note: Also fixing the localized name of Ukrainian. For some reason it was garbled before.
---
modules/gallery/helpers/locales.php | 88 ++++++++++++++++++-------------------
1 file changed, 44 insertions(+), 44 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index dc32b12f..d209d414 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -63,50 +63,50 @@ class locales_Core {
// @todo Might want to add a localizable language name as well.
private static function _init_language_data() {
- $l["af_ZA"] = "Afrikaans"; // Afrikaans
- $l["ar_SA"] = "العربية"; // Arabic
- $l["be_BY"] = "Беларускі"; // Belarusian
- $l["bg_BG"] = "Български"; // Bulgarian
- $l["ca_ES"] = "Catalan"; // Catalan
- $l["cs_CZ"] = "Česky"; // Czech
- $l["da_DK"] = "Dansk"; // Danish
- $l["de_DE"] = "Deutsch"; // German
- $l["el_GR"] = "Greek"; // Greek
- $l["en_GB"] = "English (UK)"; // English (UK)
- $l["en_US"] = "English (US)"; // English (US)
- $l["es_AR"] = "Español (AR)"; // Spanish (AR)
- $l["es_ES"] = "Español"; // Spanish (ES)
- $l["es_MX"] = "Español (MX)"; // Spanish (MX)
- $l["et_EE"] = "Eesti"; // Estonian
- $l["eu_ES"] = "Euskara"; // Basque
- $l["fa_IR"] = "فارسي"; // Farsi
- $l["fi_FI"] = "Suomi"; // Finnish
- $l["fr_FR"] = "Français"; // French
- $l["ga_IE"] = "Gaeilge"; // Irish
- $l["he_IL"] = "עברית"; // Hebrew
- $l["hu_HU"] = "Magyar"; // Hungarian
- $l["is_IS"] = "Icelandic"; // Icelandic
- $l["it_IT"] = "Italiano"; // Italian
- $l["ja_JP"] = "日本語"; // Japanese
- $l["ko_KR"] = "한국말"; // Korean
- $l["lt_LT"] = "Lietuvių"; // Lithuanian
- $l["lv_LV"] = "Latviešu"; // Latvian
- $l["nl_NL"] = "Nederlands"; // Dutch
- $l["no_NO"] = "Norsk bokmål"; // Norwegian
- $l["pl_PL"] = "Polski"; // Polish
- $l["pt_BR"] = "Português Brasileiro"; // Portuguese (BR)
- $l["pt_PT"] = "Português"; // Portuguese (PT)
- $l["ro_RO"] = "Română"; // Romanian
- $l["ru_RU"] = "Русский"; // Russian
- $l["sk_SK"] = "Slovenčina"; // Slovak
- $l["sl_SI"] = "Slovenščina"; // Slovenian
- $l["sr_CS"] = "Srpski"; // Serbian
- $l["sv_SE"] = "Svenska"; // Swedish
- $l["tr_TR"] = "Türkçe"; // Turkish
- $l["uk_UA"] = "УкÑаÑнÑÑка"; // Ukrainian
- $l["vi_VN"] = "Tiếng Việt"; // Vietnamese
- $l["zh_CN"] = "简体中文"; // Chinese (CN)
- $l["zh_TW"] = "繁體中文"; // Chinese (TW)
+ $l["af_ZA"] = "Afrikaans"; // Afrikaans
+ $l["ar_SA"] = "العربي"; // Arabic
+ $l["be_BY"] = "Беларускі"; // Belarusian
+ $l["bg_BG"] = "български"; // Bulgarian
+ $l["ca_ES"] = "Catalan"; // Catalan
+ $l["cs_CZ"] = "čeština"; // Czech
+ $l["da_DK"] = "Dansk"; // Danish
+ $l["de_DE"] = "Deutsch"; // German
+ $l["el_GR"] = "Greek"; // Greek
+ $l["en_GB"] = "English (UK)"; // English (UK)
+ $l["en_US"] = "English (US)"; // English (US)
+ $l["es_AR"] = "Español (AR)"; // Spanish (AR)
+ $l["es_ES"] = "Español"; // Spanish (ES)
+ $l["es_MX"] = "Español (MX)"; // Spanish (MX)
+ $l["et_EE"] = "Eesti"; // Estonian
+ $l["eu_ES"] = "Euskara"; // Basque
+ $l["fa_IR"] = "فارس"; // Farsi
+ $l["fi_FI"] = "Suomi"; // Finnish
+ $l["fr_FR"] = "Français"; // French
+ $l["ga_IE"] = "Gaeilge"; // Irish
+ $l["he_IL"] = "עברית"; // Hebrew
+ $l["hu_HU"] = "Magyar"; // Hungarian
+ $l["is_IS"] = "Icelandic"; // Icelandic
+ $l["it_IT"] = "Italiano"; // Italian
+ $l["ja_JP"] = "日本語"; // Japanese
+ $l["ko_KR"] = "한국어"; // Korean
+ $l["lt_LT"] = "Lietuvių"; // Lithuanian
+ $l["lv_LV"] = "Latviešu"; // Latvian
+ $l["nl_NL"] = "Nederlands"; // Dutch
+ $l["no_NO"] = "Norsk bokmål"; // Norwegian
+ $l["pl_PL"] = "Polski"; // Polish
+ $l["pt_BR"] = "Português do Brasil"; // Portuguese (BR)
+ $l["pt_PT"] = "Português ibérico"; // Portuguese (PT)
+ $l["ro_RO"] = "Română"; // Romanian
+ $l["ru_RU"] = "Русский"; // Russian
+ $l["sk_SK"] = "Slovenčina"; // Slovak
+ $l["sl_SI"] = "Slovenščina"; // Slovenian
+ $l["sr_CS"] = "Srpski"; // Serbian
+ $l["sv_SE"] = "Svenska"; // Swedish
+ $l["tr_TR"] = "Türkçe"; // Turkish
+ $l["uk_UA"] = "українська"; // Ukrainian
+ $l["vi_VN"] = "Tiếng Việt"; // Vietnamese
+ $l["zh_CN"] = "简体中文"; // Chinese (CN)
+ $l["zh_TW"] = "繁體中文"; // Chinese (TW)
asort($l, SORT_LOCALE_STRING);
self::$locales = $l;
--
cgit v1.2.3
From 7099fc71f11ef8d3dd613d96a04a4824a827c714 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 13:05:44 -0800
Subject: Fix for ticket 1004: Replace all uses of split with explode (none
actually required regular expressions). Thanks to Brian Hartsock for
providing a patch!
---
modules/gallery/tests/File_Structure_Test.php | 2 +-
modules/tag/controllers/tags.php | 6 +++---
modules/tag/helpers/tag_event.php | 6 +++---
modules/tag/helpers/tag_item_rest.php | 2 +-
modules/user/tests/No_Direct_ORM_Access_Test.php | 4 ++--
5 files changed, 10 insertions(+), 10 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index 4590e95d..9b2b1480 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -195,7 +195,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case {
foreach ($dir as $file) {
$file_as_string = file_get_contents($file);
if (preg_match('/\t/', $file_as_string)) {
- foreach (split("\n", $file_as_string) as $l => $line) {
+ foreach (explode("\n", $file_as_string) as $l => $line) {
if (preg_match('/\t/', $line)) {
$errors[] = "$file:$l has tab(s) ($line)";
}
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 1eede907..04400d73 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -60,7 +60,7 @@ class Tags_Controller extends Controller {
$form = tag::get_add_form($item);
if ($form->validate()) {
- foreach (split(",", $form->add_tag->inputs["name"]->value) as $tag_name) {
+ foreach (explode(",", $form->add_tag->inputs["name"]->value) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
$tag = tag::add($item, $tag_name);
@@ -77,9 +77,9 @@ class Tags_Controller extends Controller {
public function autocomplete() {
$tags = array();
- $tag_parts = preg_split("#,#", Input::instance()->get("q"));
+ $tag_parts = explode(",", Input::instance()->get("q"));
$limit = Input::instance()->get("limit");
- $tag_part = end($tag_parts);
+ $tag_part = ltrim(end($tag_parts));
$tag_list = ORM::factory("tag")
->where("name", "LIKE", "{$tag_part}%")
->order_by("name", "ASC")
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index 403ccd52..10075c02 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -34,7 +34,7 @@ class tag_event_Core {
if (!empty($iptc["2#025"])) {
foreach($iptc["2#025"] as $tag) {
$tag = str_replace("\0", "", $tag);
- foreach (preg_split("/,/", $tag) as $word) {
+ foreach (explode(",", $tag) as $word) {
$word = trim($word);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") {
$word = utf8_encode($word);
@@ -82,7 +82,7 @@ class tag_event_Core {
static function item_edit_form_completed($item, $form) {
tag::clear_all($item);
- foreach (preg_split("/,/", $form->edit_item->tags->value) as $tag_name) {
+ foreach (explode(",", $form->edit_item->tags->value) as $tag_name) {
if ($tag_name) {
tag::add($item, trim($tag_name));
}
@@ -124,7 +124,7 @@ class tag_event_Core {
}
static function add_photos_form_completed($album, $form) {
- foreach (split(",", $form->add_photos->tags->value) as $tag_name) {
+ foreach (explode(",", $form->add_photos->tags->value) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
$tag = tag::add($album, $tag_name);
diff --git a/modules/tag/helpers/tag_item_rest.php b/modules/tag/helpers/tag_item_rest.php
index 672cec53..fe07fefb 100644
--- a/modules/tag/helpers/tag_item_rest.php
+++ b/modules/tag/helpers/tag_item_rest.php
@@ -34,7 +34,7 @@ class tag_item_rest_Core {
}
static function resolve($tuple) {
- list ($tag_id, $item_id) = split(",", $tuple);
+ list ($tag_id, $item_id) = explode(",", $tuple);
$tag = ORM::factory("tag", $tag_id);
$item = ORM::factory("item", $item_id);
if (!$tag->loaded() || !$item->loaded() || !$tag->has($item) || !access::can("view", $item)) {
diff --git a/modules/user/tests/No_Direct_ORM_Access_Test.php b/modules/user/tests/No_Direct_ORM_Access_Test.php
index c372258e..eb7f09b0 100644
--- a/modules/user/tests/No_Direct_ORM_Access_Test.php
+++ b/modules/user/tests/No_Direct_ORM_Access_Test.php
@@ -31,7 +31,7 @@ class No_Direct_ORM_Access_Test extends Gallery_Unit_Test_Case {
//if (basename(dirname($file)) == "helpers") {
$file_as_string = file_get_contents($file);
if (preg_match("/ORM::factory\\(\"user\"/", $file_as_string)) {
- foreach (split("\n", $file_as_string) as $l => $line) {
+ foreach (explode("\n", $file_as_string) as $l => $line) {
if (preg_match('/ORM::factory\\(\"user\"/', $line)) {
$errors[] = "$file($l) => $line";
}
@@ -54,7 +54,7 @@ class No_Direct_ORM_Access_Test extends Gallery_Unit_Test_Case {
foreach ($dir as $file) {
$file_as_string = file_get_contents($file);
if (preg_match("/ORM::factory\\(\"group\"/", $file_as_string)) {
- foreach (split("\n", $file_as_string) as $l => $line) {
+ foreach (explode("\n", $file_as_string) as $l => $line) {
if (preg_match('/ORM::factory\\(\"group\"/', $line)) {
$errors[] = "$file($l) => $line";
}
--
cgit v1.2.3
From 9bede5763a63bec7b1a7ea2ba9f4e8cea33087d5 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 13:15:02 -0800
Subject: Fix g2_import admin screen: It wouldn't work if it didn't know the
location of G2 yet.
---
modules/g2_import/controllers/admin_g2_import.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index 6dd155b9..f216091a 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -32,13 +32,14 @@ class Admin_g2_import_Controller extends Admin_Controller {
$view = new Admin_View("admin.html");
$view->content = new View("admin_g2_import.html");
$view->content->form = $this->_get_import_form();
- $view->content->version = g2_import::version();
+ $view->content->version = '';
if (g2_import::is_initialized()) {
$view->content->g2_stats = $g2_stats;
$view->content->g2_sizes = $g2_sizes;
$view->content->thumb_size = module::get_var("gallery", "thumb_size");
$view->content->resize_size = module::get_var("gallery", "resize_size");
+ $view->content->version = g2_import::version();
}
g2_import::restore_error_reporting();
print $view;
--
cgit v1.2.3
From d8d1155615739a9e6f1f12d4f1ce2ec7cc9cd444 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 14:20:19 -0800
Subject: Fix maintenance view, which was broken when the g2_import module was
installed but not configured correctly.
---
modules/g2_import/helpers/g2_import_task.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
(limited to 'modules')
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index e0212b33..2e81adef 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -19,14 +19,15 @@
*/
class g2_import_task_Core {
static function available_tasks() {
+ $version = '';
g2_import::lower_error_reporting();
if (g2_import::is_configured()) {
g2_import::init();
+ $version = g2_import::version();
}
- $version = g2_import::version();
g2_import::restore_error_reporting();
- if (class_exists("GalleryCoreApi")) {
+ if (g2_import::is_initialized()) {
return array(Task_Definition::factory()
->callback("g2_import_task::import")
->name(t("Import from Gallery 2"))
--
cgit v1.2.3
From e092405fdf23412a27903227bc6d2f422f4e9f2d Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 14:59:28 -0800
Subject: Fix g2 redirect to use external redirect (and declare it as
permanent). Redirects weren't working for me in Firefox 3.5 when not signed
into G3 (and all items are public).
---
modules/g2_import/views/admin_g2_import.html.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php
index 6a5214a3..41ef7f85 100644
--- a/modules/g2_import/views/admin_g2_import.html.php
+++ b/modules/g2_import/views/admin_g2_import.html.php
@@ -103,7 +103,7 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase = html::clean(g2_import::$g2_base_url) ?>
- RewriteRule ^(.*)$ = url::site("g2/map?path=\$1") ?> [QSA,L]
+ RewriteRule ^(.*)$ = url::site("g2/map?path=\$1") ?> [QSA,L,R=301]
</IfModule>
--
cgit v1.2.3
From d069155228acb9c9e86814a89cb2400434d18321 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 15:08:10 -0800
Subject: Fix g2 redirects for non-admins. The g2 URL mapping controller was
accidentally declared as admin controller. (The previous attempt to fix this
isn't a bad change either, thus keeping the external permenant redirect).
---
modules/g2_import/controllers/g2.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 5fd4400c..70461600 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class G2_Controller extends Admin_Controller {
+class G2_Controller extends Controller {
/**
* Redirect Gallery 2 urls to their appropriate matching Gallery 3 url.
*
--
cgit v1.2.3
From 33b39efb491d730c8653ca3c06a22297338aa8b8 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 15:46:13 -0800
Subject: Add core.DownloadItem redirect for G2's Photo and Movie items (was
previously omitted, but we already had core.DownloadItem redirects for
derivatives)
---
modules/g2_import/controllers/g2.php | 1 +
modules/g2_import/helpers/g2_import.php | 4 ++++
2 files changed, 5 insertions(+)
(limited to 'modules')
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 70461600..8260cf9f 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -64,6 +64,7 @@ class G2_Controller extends Controller {
case "resize":
url::redirect($item->resize_url(true));
+ case "file":
case "full":
url::redirect($item->file_url(true));
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 0fcc0539..f13c63b1 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -541,6 +541,10 @@ class g2_import_Core {
$item->save();
self::set_map($g2_item_id, $item->id, "item", $g2_item_url);
+
+ self::set_map($g2_item_id, $item->id, "file",
+ self::g2_url(array("view" => "core.DownloadItem", "itemId" => $g2_item_id)));
+
$derivatives = g2(GalleryCoreApi::fetchDerivativesByItemIds(array($g2_item_id)));
if (!empty($derivatives[$g2_item_id])) {
foreach ($derivatives[$g2_item_id] as $derivative) {
--
cgit v1.2.3
From 7232b6c026c3fe371b6846a8a4536a1b661804c4 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 16:29:51 -0800
Subject: Fixing G2 url mapping for G2 default style URLs (where ShowItem and
DownloadItem URLs aren't rewritten in G2).
Note: For a perfect solution, we should add 2 map entries for each of G2's ShowItem and DownloadItem URLs, one for short and one for long style URLs.
E.g. A G2 installation might have been using short style URLs not for its complete lifetime. And long style URLs are supposed to work in G2 even when short style URLs are enabled (and its used that way in bbcode / as a way to get permenant, id based URLs from G2).
---
modules/g2_import/controllers/g2.php | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
(limited to 'modules')
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 8260cf9f..347da649 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -35,15 +35,25 @@ class G2_Controller extends Controller {
$id = $input->get("g2_itemId");
if ($id) {
- $where = array("g2_id", "=", $id);
+ // Requests by id are either core.DownloadItem or
+ // core.ShowItem requests.
+ // Later versions of Gallery 2 don't specify g2_view if
+ // it's the default (core.ShowItem).
+ // And in some cases (bbcode, embedding) people are using
+ // the id style URLs although URL rewriting is enabled.
+ $where = array(array("g2_id", "=", $id));
+ $view = $input->get("g2_view");
+ if ($view) {
+ $where[] = array("g2_url", "like", "%g2_view=$view%");
+ } // else: Assuming that the first search hit is sufficiently good.
} else if ($path) {
- $where = array("g2_url", "=", $path);
+ $where = array(array("g2_url", "=", $path));
} else {
throw new Kohana_404_Exception();
}
$g2_map = ORM::factory("g2_map")
- ->merge_where(array($where))
+ ->merge_where($where)
->find();
if (!$g2_map->loaded()) {
--
cgit v1.2.3
From 81b595743f75aea96a8159c8ab827fa3d25233ab Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sat, 6 Feb 2010 16:30:25 -0800
Subject: Force each branch of a tree onto a new line.
---
modules/organize/css/organize.css | 2 ++
1 file changed, 2 insertions(+)
(limited to 'modules')
diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css
index 22d6e051..87f9e55b 100644
--- a/modules/organize/css/organize.css
+++ b/modules/organize/css/organize.css
@@ -40,10 +40,12 @@
#g-organize-album-tree ul li {
padding: 0 0 .2em 1.2em;
+ width: 100%;
}
.rtl #g-organize-album-tree ul li {
padding: 0 1.2em .2em 0;
+ width: 100%;
}
.g-organize-album span {
--
cgit v1.2.3
From 6340d8caf2261199e029841baca66e302c861679 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sat, 6 Feb 2010 16:43:55 -0800
Subject: 100% was just to wide, so scale the width back to 90% for organize
album tree branches.
---
modules/organize/css/organize.css | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/css/organize.css b/modules/organize/css/organize.css
index 87f9e55b..7a8c3a5f 100644
--- a/modules/organize/css/organize.css
+++ b/modules/organize/css/organize.css
@@ -40,12 +40,12 @@
#g-organize-album-tree ul li {
padding: 0 0 .2em 1.2em;
- width: 100%;
+ width: 90%;
}
.rtl #g-organize-album-tree ul li {
padding: 0 1.2em .2em 0;
- width: 100%;
+ width: 90%;
}
.g-organize-album span {
--
cgit v1.2.3
From 163391ee391627f9c2b4eac359104809e2706a9b Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 17:43:33 -0800
Subject: Partial fix for ticket 585: Require current password when changing an
account's email address.
Still leaving the user/group admin page wide open though.
---
modules/gallery/views/user_profile.html.php | 3 ++
modules/user/controllers/users.php | 70 ++++++++++++++++++++++++++---
2 files changed, 68 insertions(+), 5 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/views/user_profile.html.php b/modules/gallery/views/user_profile.html.php
index 78e1c579..1c3e4ea2 100644
--- a/modules/gallery/views/user_profile.html.php
+++ b/modules/gallery/views/user_profile.html.php
@@ -63,6 +63,9 @@
id}") ?>">
= t("Change password") ?>
+ id}") ?>">
+ = t("Change email") ?>
+
endif ?>
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 166ff8b2..83adc354 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -28,7 +28,6 @@ class Users_Controller extends Controller {
try {
$valid = $form->validate();
$user->full_name = $form->edit_user->full_name->value;
- $user->email = $form->edit_user->email->value;
$user->url = $form->edit_user->url->value;
if ($user->locale != $form->edit_user->locale->value) {
@@ -97,6 +96,41 @@ class Users_Controller extends Controller {
}
}
+ public function change_email($id) {
+ $user = user::lookup($id);
+ if ($user->guest || $user->id != identity::active_user()->id) {
+ access::forbidden();
+ }
+
+ $form = $this->_get_change_email_form($user);
+ try {
+ $valid = $form->validate();
+ $user->email = $form->change_email->email->value;
+ $user->validate();
+ } catch (ORM_Validation_Exception $e) {
+ // Translate ORM validation errors into form error messages
+ foreach ($e->validation->errors() as $key => $error) {
+ $form->change_email->inputs[$key]->add_error($error, 1);
+ }
+ $valid = false;
+ }
+
+ if ($valid) {
+ $user->save();
+ module::event("user_change_email_form_completed", $user, $form);
+ message::success(t("Email address changed"));
+ module::event("user_login", $user); // since there's no user_authenticated event
+ print json_encode(
+ array("result" => "success",
+ "resource" => url::site("users/{$user->id}")));
+ } else {
+ log::warning("user", t("Failed email change for %name", array("name" => $user->name)));
+ $name = $user->name;
+ module::event("user_login_failed", $name);
+ print json_encode(array("result" => "error", "form" => (string) $form));
+ }
+ }
+
public function form_edit($id) {
$user = user::lookup($id);
if ($user->guest || $user->id != identity::active_user()->id) {
@@ -115,6 +149,15 @@ class Users_Controller extends Controller {
print $this->_get_change_password_form($user);
}
+ public function form_change_email($id) {
+ $user = user::lookup($id);
+ if ($user->guest || $user->id != identity::active_user()->id) {
+ access::forbidden();
+ }
+
+ print $this->_get_change_email_form($user);
+ }
+
private function _get_change_password_form($user) {
$form = new Forge(
"users/change_password/$user->id", "", "post", array("id" => "g-change-password-user-form"));
@@ -140,16 +183,33 @@ class Users_Controller extends Controller {
return $form;
}
+ private function _get_change_email_form($user) {
+ $form = new Forge(
+ "users/change_email/$user->id", "", "post", array("id" => "g-change-email-user-form"));
+ $group = $form->group("change_email")->label(t("Change your email address"));
+ $group->password("password")->label(t("Current password"))->id("g-password")
+ ->callback("auth::validate_too_many_failed_password_changes")
+ ->callback("user::valid_password")
+ ->error_messages("invalid", t("Incorrect password"))
+ ->error_messages(
+ "too_many_failed_password_changes",
+ t("Too many incorrect passwords. Try again later"));
+ $group->input("email")->label(t("New email address"))->id("g-email")->value($user->email)
+ ->error_messages("email", t("You must enter a valid email address"))
+ ->error_messages("length", t("Your email address is too long"))
+ ->error_messages("required", t("You must enter a valid email address"));
+
+ module::event("user_change_password_form", $user, $form);
+ $group->submit("")->value(t("Save"));
+ return $form;
+ }
+
private function _get_edit_form($user) {
$form = new Forge("users/update/$user->id", "", "post", array("id" => "g-edit-user-form"));
$group = $form->group("edit_user")->label(t("Edit your profile"));
$group->input("full_name")->label(t("Full Name"))->id("g-fullname")->value($user->full_name)
->error_messages("length", t("Your name is too long"));
self::_add_locale_dropdown($group, $user);
- $group->input("email")->label(t("Email"))->id("g-email")->value($user->email)
- ->error_messages("email", t("You must enter a valid email address"))
- ->error_messages("length", t("Your email address is too long"))
- ->error_messages("required", t("You must enter a valid email address"));
$group->input("url")->label(t("URL"))->id("g-url")->value($user->url);
module::event("user_edit_form", $user, $form);
--
cgit v1.2.3
From a6170dc065856c6c4b6f69a4571fe19dee87d0ee Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 18:37:25 -0800
Subject: Fix maintenance view for the case when g2_import is configured and
the user replaced the original g2 directory with the .htaccess file only.
---
modules/g2_import/helpers/g2_import_task.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index 2e81adef..1ec6870e 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -23,7 +23,11 @@ class g2_import_task_Core {
g2_import::lower_error_reporting();
if (g2_import::is_configured()) {
g2_import::init();
- $version = g2_import::version();
+ // Guard from common case where the import has been
+ // completed and the original files have been removed.
+ if (class_exists("GalleryCoreApi")) {
+ $version = g2_import::version();
+ }
}
g2_import::restore_error_reporting();
--
cgit v1.2.3
From 2c3c126aafaa4d7ed86075927887636042117a1c Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sat, 6 Feb 2010 20:07:58 -0800
Subject: Fix ticket 930: Use the first frame as video thumbnail if the video
is shorter than 3 seconds. And fall back to the default thumbnail if that
operation fails.
Thanks to lsowen for providing a patch!
---
modules/gallery/helpers/movie.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
(limited to 'modules')
diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php
index 7033b7da..3c494e96 100644
--- a/modules/gallery/helpers/movie.php
+++ b/modules/gallery/helpers/movie.php
@@ -84,6 +84,20 @@ class movie_Core {
" -an -ss 00:00:03 -an -r 1 -vframes 1" .
" -y -f mjpeg " . escapeshellarg($output_file) . " 2>&1";
exec($cmd);
+
+ clearstatcache(); // use $filename parameter when PHP_version is 5.3+
+ if (filesize($output_file) == 0) {
+ // Maybe the movie is shorter, fall back to the first frame.
+ $cmd = escapeshellcmd($ffmpeg) . " -i " . escapeshellarg($input_file) .
+ " -an -an -r 1 -vframes 1" .
+ " -y -f mjpeg " . escapeshellarg($output_file) . " 2>&1";
+ exec($cmd);
+
+ clearstatcache();
+ if (filesize($output_file) == 0) {
+ throw new Exception("@todo FFMPEG_FAILED");
+ }
+ }
}
static function find_ffmpeg() {
--
cgit v1.2.3
From adac97b5372322be5154996974a6496198105d16 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 7 Feb 2010 08:28:32 -0800
Subject: Add prefix support for the target of RENAME TABLE.
---
modules/gallery/libraries/MY_Database.php | 9 ++++++++-
modules/gallery/tests/Database_Test.php | 7 +++++++
2 files changed, 15 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/gallery/libraries/MY_Database.php b/modules/gallery/libraries/MY_Database.php
index e2ef68cd..cb70104a 100644
--- a/modules/gallery/libraries/MY_Database.php
+++ b/modules/gallery/libraries/MY_Database.php
@@ -54,11 +54,18 @@ abstract class Database extends Database_Core {
*/
return $sql;
} else if (strpos($sql, "CREATE TABLE") === 0) {
- // Creating a new table add it to the table cache.
+ // Creating a new table; add it to the table cache.
$open_brace = strpos($sql, "{") + 1;
$close_brace = strpos($sql, "}", $open_brace);
$name = substr($sql, $open_brace, $close_brace - $open_brace);
$this->_table_names["{{$name}}"] = "{$prefix}$name";
+ } else if (strpos($sql, "RENAME TABLE") === 0) {
+ // Renaming a table; add it to the table cache.
+ // You must use the form "TO {new_table_name}" exactly for this to work.
+ $open_brace = strpos($sql, "TO {") + 4;
+ $close_brace = strpos($sql, "}", $open_brace);
+ $name = substr($sql, $open_brace, $close_brace - $open_brace);
+ $this->_table_names["{{$name}}"] = "{$prefix}$name";
}
if (!isset($this->_table_names)) {
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php
index 861f7bba..730785e2 100644
--- a/modules/gallery/tests/Database_Test.php
+++ b/modules/gallery/tests/Database_Test.php
@@ -130,6 +130,13 @@ class Database_Test extends Gallery_Unit_Test_Case {
$this->assert_same($expected, $sql);
}
+ function prefix_replacement_for_rename_table_test() {
+ $db = Database::instance("mock");
+ $this->assert_same(
+ "RENAME TABLE g_test TO g_new_test",
+ $db->add_table_prefixes("RENAME TABLE {test} TO {new_test}"));
+ }
+
function prefix_no_replacement_test() {
$sql = db::build("mock")
->from("test_tables")
--
cgit v1.2.3
From aff5d1cef4cc2514fe6d714788fffcf418d8fc5b Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 7 Feb 2010 08:45:10 -0800
Subject: Create the concept of a "failed authentication" as semantically
separate from a successful or failed login.
1) Rename user_login_failed event to user_authenticate_failed
2) Rename failed_logins table to failed_auth (bump Gallery module to
v27 to rename the table)
3) auth::too_many_failed_logins -> auth::too_many_failures
4) auth::record_failed_auth_attempts -> auth::record_failed_attempts
auth::clear_failed_auth_attempts -> auth::clear_failed_attempts
---
modules/gallery/controllers/login.php | 2 +-
modules/gallery/helpers/auth.php | 41 +++++++++++++--------------
modules/gallery/helpers/gallery_event.php | 14 ++++-----
modules/gallery/helpers/gallery_installer.php | 9 ++++--
modules/gallery/models/failed_auth.php | 20 +++++++++++++
modules/gallery/models/failed_login.php | 20 -------------
modules/gallery/module.info | 2 +-
modules/rest/controllers/rest.php | 2 +-
modules/user/controllers/users.php | 7 +++--
9 files changed, 59 insertions(+), 58 deletions(-)
create mode 100644 modules/gallery/models/failed_auth.php
delete mode 100644 modules/gallery/models/failed_login.php
(limited to 'modules')
diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php
index 1426f0d8..fa175ac8 100644
--- a/modules/gallery/controllers/login.php
+++ b/modules/gallery/controllers/login.php
@@ -65,7 +65,7 @@ class Login_Controller extends Controller {
$form->login->inputs["name"]->add_error("invalid_login", 1);
$name = $form->login->inputs["name"]->value;
log::warning("user", t("Failed login for %name", array("name" => $name)));
- module::event("user_login_failed", $name);
+ module::event("user_authenticate_failed", $name);
$valid = false;
}
}
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index 45561861..2c1e3f67 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -20,7 +20,7 @@
class auth_Core {
static function get_login_form($url) {
$form = new Forge($url, "", "post", array("id" => "g-login-form"));
- $form->set_attr('class', "g-narrow");
+ $form->set_attr("class", "g-narrow");
$group = $form->group("login")->label(t("Login"));
$group->input("name")->label(t("Username"))->id("g-username")->class(null)
->callback("auth::validate_too_many_failed_logins")
@@ -60,52 +60,51 @@ class auth_Core {
}
/**
- * After there have been 5 failed login attempts, any failure leads to getting locked out for a
+ * After there have been 5 failed auth attempts, any failure leads to getting locked out for a
* minute.
*/
- static function too_many_failed_logins($name) {
- $failed_login = ORM::factory("failed_login")
+ static function too_many_failures($name) {
+ $failed = ORM::factory("failed_auth")
->where("name", "=", $name)
->find();
- return ($failed_login->loaded() &&
- $failed_login->count > 5 &&
- (time() - $failed_login->time < 60));
+ return ($failed->loaded() &&
+ $failed->count > 5 &&
+ (time() - $failed->time < 60));
}
static function validate_too_many_failed_logins($name_input) {
- if (self::too_many_failed_logins($name_input->value)) {
+ if (self::too_many_failures($name_input->value)) {
$name_input->add_error("too_many_failed_logins", 1);
}
}
static function validate_too_many_failed_password_changes($password_input) {
- if (self::too_many_failed_logins(identity::active_user()->name)) {
+ if (self::too_many_failures(identity::active_user()->name)) {
$password_input->add_error("too_many_failed_password_changes", 1);
}
}
/**
- * Record a failed login for this user
+ * Record a failed authentication for this user
*/
- static function record_failed_auth_attempts($name) {
- $failed_login = ORM::factory("failed_login")
+ static function record_failed_attempt($name) {
+ $failed = ORM::factory("failed_auth")
->where("name", "=", $name)
->find();
- if (!$failed_login->loaded()) {
- $failed_login->name = $name;
+ if (!$failed->loaded()) {
+ $failed->name = $name;
}
- $failed_login->time = time();
- $failed_login->count++;
- $failed_login->save();
+ $failed->time = time();
+ $failed->count++;
+ $failed->save();
}
/**
* Clear any failed logins for this user
*/
- static function clear_failed_auth_attempts($user) {
- db::build()
- ->delete("failed_logins")
+ static function clear_failed_attempts($user) {
+ ORM::factory("failed_auth")
->where("name", "=", $user->name)
- ->execute();
+ ->delete_all();
}
}
\ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 7b538c49..9ce30929 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -110,19 +110,15 @@ class gallery_event_Core {
graphics::choose_default_toolkit();
module::clear_var("gallery", "choose_default_tookit");
}
- auth::clear_failed_auth_attempts($user);
+ auth::clear_failed_attempts($user);
}
- static function user_login_failed($name) {
- auth::record_failed_auth_attempts($name);
+ static function user_authenticate_failed($name) {
+ auth::record_failed_attempt($name);
}
- static function user_password_changed($user) {
- auth::clear_failed_auth_attempts($user);
- }
-
- static function user_password_change_failed($name) {
- auth::record_failed_auth_attempts($name);
+ static function user_authenticate($user) {
+ auth::clear_failed_attempts($user);
}
static function item_index_data($item, $data) {
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 761843b0..05354f81 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -42,7 +42,7 @@ class gallery_installer {
KEY (`tags`))
DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {failed_logins} (
+ $db->query("CREATE TABLE {failed_auth} (
`id` int(9) NOT NULL auto_increment,
`count` int(9) NOT NULL,
`name` varchar(255) NOT NULL,
@@ -526,6 +526,11 @@ class gallery_installer {
->execute();
module::set_version("gallery", $version = 26);
}
+
+ if ($version == 26) {
+ $db->query("RENAME TABLE {failed_logins} TO {failed_auths}");
+ module::set_version("gallery", $version = 27);
+ }
}
static function uninstall() {
@@ -534,7 +539,7 @@ class gallery_installer {
$db->query("DROP TABLE IF EXISTS {access_intents}");
$db->query("DROP TABLE IF EXISTS {graphics_rules}");
$db->query("DROP TABLE IF EXISTS {incoming_translations}");
- $db->query("DROP TABLE IF EXISTS {failed_logins}");
+ $db->query("DROP TABLE IF EXISTS {failed_auths}");
$db->query("DROP TABLE IF EXISTS {items}");
$db->query("DROP TABLE IF EXISTS {logs}");
$db->query("DROP TABLE IF EXISTS {modules}");
diff --git a/modules/gallery/models/failed_auth.php b/modules/gallery/models/failed_auth.php
new file mode 100644
index 00000000..3c25f9d8
--- /dev/null
+++ b/modules/gallery/models/failed_auth.php
@@ -0,0 +1,20 @@
+post("user");
$password = Input::instance()->post("password");
- if (empty($username) || auth::too_many_failed_logins($username)) {
+ if (empty($username) || auth::too_many_failures($username)) {
throw new Rest_Exception("Forbidden", 403);
}
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 83adc354..2675d918 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -84,6 +84,7 @@ class Users_Controller extends Controller {
$user->save();
module::event("user_change_password_form_completed", $user, $form);
message::success(t("Password changed"));
+ module::event("user_authenticate", $user);
module::event("user_password_change", $user);
print json_encode(
array("result" => "success",
@@ -91,7 +92,7 @@ class Users_Controller extends Controller {
} else {
log::warning("user", t("Failed password change for %name", array("name" => $user->name)));
$name = $user->name;
- module::event("user_password_change_failed", $name);
+ module::event("user_authenticate_failed", $name);
print json_encode(array("result" => "error", "form" => (string) $form));
}
}
@@ -119,14 +120,14 @@ class Users_Controller extends Controller {
$user->save();
module::event("user_change_email_form_completed", $user, $form);
message::success(t("Email address changed"));
- module::event("user_login", $user); // since there's no user_authenticated event
+ module::event("user_authenticate", $user);
print json_encode(
array("result" => "success",
"resource" => url::site("users/{$user->id}")));
} else {
log::warning("user", t("Failed email change for %name", array("name" => $user->name)));
$name = $user->name;
- module::event("user_login_failed", $name);
+ module::event("user_authenticate_failed", $name);
print json_encode(array("result" => "error", "form" => (string) $form));
}
}
--
cgit v1.2.3
From eda6e3af06aa51281e614ae9a5e7b4ad4fbbae17 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Sun, 7 Feb 2010 08:49:37 -0800
Subject: Rename user_authenticate_xxx events to user_auth_xxx for brevity.
---
modules/gallery/controllers/login.php | 2 +-
modules/gallery/helpers/gallery_event.php | 4 ++--
modules/user/controllers/users.php | 8 ++++----
3 files changed, 7 insertions(+), 7 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php
index fa175ac8..5a08b693 100644
--- a/modules/gallery/controllers/login.php
+++ b/modules/gallery/controllers/login.php
@@ -65,7 +65,7 @@ class Login_Controller extends Controller {
$form->login->inputs["name"]->add_error("invalid_login", 1);
$name = $form->login->inputs["name"]->value;
log::warning("user", t("Failed login for %name", array("name" => $name)));
- module::event("user_authenticate_failed", $name);
+ module::event("user_auth_failed", $name);
$valid = false;
}
}
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 9ce30929..5fa82160 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -113,11 +113,11 @@ class gallery_event_Core {
auth::clear_failed_attempts($user);
}
- static function user_authenticate_failed($name) {
+ static function user_auth_failed($name) {
auth::record_failed_attempt($name);
}
- static function user_authenticate($user) {
+ static function user_auth($user) {
auth::clear_failed_attempts($user);
}
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 2675d918..1130852b 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -84,7 +84,7 @@ class Users_Controller extends Controller {
$user->save();
module::event("user_change_password_form_completed", $user, $form);
message::success(t("Password changed"));
- module::event("user_authenticate", $user);
+ module::event("user_auth", $user);
module::event("user_password_change", $user);
print json_encode(
array("result" => "success",
@@ -92,7 +92,7 @@ class Users_Controller extends Controller {
} else {
log::warning("user", t("Failed password change for %name", array("name" => $user->name)));
$name = $user->name;
- module::event("user_authenticate_failed", $name);
+ module::event("user_auth_failed", $name);
print json_encode(array("result" => "error", "form" => (string) $form));
}
}
@@ -120,14 +120,14 @@ class Users_Controller extends Controller {
$user->save();
module::event("user_change_email_form_completed", $user, $form);
message::success(t("Email address changed"));
- module::event("user_authenticate", $user);
+ module::event("user_auth", $user);
print json_encode(
array("result" => "success",
"resource" => url::site("users/{$user->id}")));
} else {
log::warning("user", t("Failed email change for %name", array("name" => $user->name)));
$name = $user->name;
- module::event("user_authenticate_failed", $name);
+ module::event("user_auth_failed", $name);
print json_encode(array("result" => "error", "form" => (string) $form));
}
}
--
cgit v1.2.3
From b6c0d3a48ca4fa9296b23a1c4d73fb0573f1b92f Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 13:55:17 -0800
Subject: Refactor the is_rtl() helper into the Gallery_I18n class. This
allows checking for a config value "force_rtl" which will layout the gallery
pages in rtl mode without having to change to an language that is no longer
understandable to the developer.
Adding the line "$config['force_rtl'] = true;" to the config/locales.php file
will make it happen.
---
modules/gallery/helpers/locales.php | 4 +---
modules/gallery/libraries/Gallery_I18n.php | 10 ++++++++++
2 files changed, 11 insertions(+), 3 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index d209d414..4af750a3 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -131,9 +131,7 @@ class locales_Core {
}
static function is_rtl($locale=null) {
- $locale or $locale = Gallery_I18n::instance()->locale();
- list ($language, $territory) = explode('_', $locale . "_");
- return in_array($language, array("he", "fa", "ar"));
+ return Gallery_I18n::instance()->is_rtl($locale);
}
/**
diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php
index 4e0c1f82..1eacad5b 100644
--- a/modules/gallery/libraries/Gallery_I18n.php
+++ b/modules/gallery/libraries/Gallery_I18n.php
@@ -87,6 +87,16 @@ class Gallery_I18n_Core {
return $this->_config['default_locale'];
}
+ public function is_rtl($locale=null) {
+ $is_rtl = !empty($this->_config["force_rtl"]) and $this->_config["force_rtl"];
+ if (empty($is_rtl)) {
+ $locale or $locale = $this->locale();
+ list ($language, $territory) = explode('_', $locale . "_");
+ $is_rtl = in_array($language, array("he", "fa", "ar"));
+ }
+ return $is_rtl;
+ }
+
/**
* Translates a localizable message.
*
--
cgit v1.2.3
From 6783de24572eb3a84dd43d125686b5f1df33f305 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 14:17:58 -0800
Subject: Remove the redundant reference to ["force_rtl".
---
modules/gallery/libraries/Gallery_I18n.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/gallery/libraries/Gallery_I18n.php b/modules/gallery/libraries/Gallery_I18n.php
index 1eacad5b..cfed046a 100644
--- a/modules/gallery/libraries/Gallery_I18n.php
+++ b/modules/gallery/libraries/Gallery_I18n.php
@@ -88,7 +88,7 @@ class Gallery_I18n_Core {
}
public function is_rtl($locale=null) {
- $is_rtl = !empty($this->_config["force_rtl"]) and $this->_config["force_rtl"];
+ $is_rtl = !empty($this->_config["force_rtl"]);
if (empty($is_rtl)) {
$locale or $locale = $this->locale();
list ($language, $territory) = explode('_', $locale . "_");
--
cgit v1.2.3
From e2e637064aa3cd66ddd3636d85314a168f2c9c91 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 14:25:05 -0800
Subject: The adjustment for before or after based on whether the locales rtl
or not is now done in the browser.
---
modules/organize/controllers/organize.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/controllers/organize.php b/modules/organize/controllers/organize.php
index 38e8ca58..9d9da65e 100644
--- a/modules/organize/controllers/organize.php
+++ b/modules/organize/controllers/organize.php
@@ -73,9 +73,9 @@ class Organize_Controller extends Controller {
access::required("view", $album);
access::required("edit", $album);
- if (locales::is_rtl()) { // invert the position if the locale is rtl
- $before_or_after = $before_or_after == "after" ? "before" : "after";
- }
+ //if (locales::is_rtl()) { // invert the position if the locale is rtl
+ // $before_or_after = $before_or_after == "after" ? "before" : "after";
+ //}
$source_ids = Input::instance()->post("source_ids", array());
--
cgit v1.2.3
From 370e0e2f32e5092e1655116edbea9a607c6ed85a Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 15:02:41 -0800
Subject: Fix installer code for version 27, and introduce new module variable
in version 28 as a preparation for admin area compartmentalization.
---
installer/install.sql | 11 ++++++-----
modules/gallery/helpers/gallery_installer.php | 11 +++++++++--
modules/gallery/module.info | 2 +-
3 files changed, 16 insertions(+), 8 deletions(-)
(limited to 'modules')
diff --git a/installer/install.sql b/installer/install.sql
index 20b632fa..1f21ad4e 100644
--- a/installer/install.sql
+++ b/installer/install.sql
@@ -74,10 +74,10 @@ CREATE TABLE {comments} (
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
-DROP TABLE IF EXISTS {failed_logins};
+DROP TABLE IF EXISTS {failed_auths};
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
-CREATE TABLE {failed_logins} (
+CREATE TABLE {failed_auths} (
`id` int(9) NOT NULL auto_increment,
`count` int(9) NOT NULL,
`name` varchar(255) NOT NULL,
@@ -239,8 +239,8 @@ CREATE TABLE {modules} (
UNIQUE KEY `name` (`name`)
) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
-INSERT INTO {modules} VALUES (1,1,'gallery',25);
-INSERT INTO {modules} VALUES (2,1,'user',2);
+INSERT INTO {modules} VALUES (1,1,'gallery',28);
+INSERT INTO {modules} VALUES (2,1,'user',3);
INSERT INTO {modules} VALUES (3,1,'comment',2);
INSERT INTO {modules} VALUES (4,1,'organize',1);
INSERT INTO {modules} VALUES (5,1,'info',1);
@@ -377,7 +377,7 @@ CREATE TABLE {vars} (
`value` text,
PRIMARY KEY (`id`),
UNIQUE KEY `module_name` (`module_name`,`name`)
-) AUTO_INCREMENT=39 DEFAULT CHARSET=utf8;
+) AUTO_INCREMENT=40 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
INSERT INTO {vars} VALUES (NULL,'gallery','active_site_theme','wind');
INSERT INTO {vars} VALUES (NULL,'gallery','active_admin_theme','admin_wind');
@@ -391,6 +391,7 @@ INSERT INTO {vars} VALUES (NULL,'gallery','time_format','H:i:s');
INSERT INTO {vars} VALUES (NULL,'gallery','show_credits','1');
INSERT INTO {vars} VALUES (NULL,'gallery','credits','Powered by Gallery %version');
INSERT INTO {vars} VALUES (NULL,'gallery','simultaneous_upload_limit','5');
+INSERT INTO {vars} VALUES (NULL,'gallery','admin_area_timeout','1200');
INSERT INTO {vars} VALUES (NULL,'gallery','blocks_dashboard_sidebar','a:4:{i:2;a:2:{i:0;s:7:\"gallery\";i:1;s:11:\"block_adder\";}i:3;a:2:{i:0;s:7:\"gallery\";i:1;s:5:\"stats\";}i:4;a:2:{i:0;s:7:\"gallery\";i:1;s:13:\"platform_info\";}i:5;a:2:{i:0;s:7:\"gallery\";i:1;s:12:\"project_news\";}}');
INSERT INTO {vars} VALUES (NULL,'gallery','date_time_format','Y-M-d H:i:s');
INSERT INTO {vars} VALUES (NULL,'gallery','date_format','Y-M-d');
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 05354f81..ed4a62a5 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -42,7 +42,7 @@ class gallery_installer {
KEY (`tags`))
DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {failed_auth} (
+ $db->query("CREATE TABLE {failed_auths} (
`id` int(9) NOT NULL auto_increment,
`count` int(9) NOT NULL,
`name` varchar(255) NOT NULL,
@@ -287,7 +287,8 @@ class gallery_installer {
// @todo this string needs to be picked up by l10n_scanner
module::set_var("gallery", "credits", "Powered by Gallery %version");
module::set_var("gallery", "simultaneous_upload_limit", 5);
- module::set_version("gallery", 26);
+ module::set_var("gallery", "admin_area_timeout", 20 * 60);
+ module::set_version("gallery", 28);
}
static function upgrade($version) {
@@ -531,6 +532,12 @@ class gallery_installer {
$db->query("RENAME TABLE {failed_logins} TO {failed_auths}");
module::set_version("gallery", $version = 27);
}
+
+ if ($version == 27) {
+ // Set the admin area timeout to 20 minutes
+ module::set_var("gallery", "admin_area_timeout", 20 * 60);
+ module::set_version("gallery", $version = 28);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index dac9e6ed..ae300399 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 27
+version = 28
--
cgit v1.2.3
From d6beef86132f1c73170a3957db84b716c538c07e Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 15:05:39 -0800
Subject: The drop target marker appears in the correct spot whether we are in
ltr or rtl mode.
---
modules/organize/js/organize.js | 56 ++++++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 18 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 2a18cb40..5fc0084c 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -56,6 +56,7 @@
tolerance: "pointer",
greedy: true,
drop: function(event, ui) {
+ $(".g-mouse-drag-over").removeClass("g-mouse-drag-over");
var target = $("#g-organize-drop-target-marker").data("drop_position");
$.organize.do_drop({
url: rearrange_url
@@ -137,19 +138,25 @@
var visibleCells = $(".g-organize-microthumb-grid-cell:visible");
var scrollTop = thumbGrid.scrollTop();
- var itemColumn = Math.floor((event.pageX - thumbGrid.offset().left) / organizeData.width);
- var itemRow = Math.floor((event.pageY + scrollTop - thumbGrid.offset().top) / organizeData.height);
- var itemIndex = Math.min(itemRow * organizeData.columns + itemColumn, visibleCells.length - 1);
- var item = visibleCells.get(itemIndex);
+ var item = $(".g-mouse-drag-over");
+ if (item.length == 0) {
+ console.log("no item");
+
+ var itemColumn = Math.floor((event.pageX - thumbGrid.offset().left) / organizeData.width);
+ itemColumn = organizeData.rtl ? organizeData.width - itemColumn : itemColumn;
+ var itemRow = Math.floor((event.pageY + scrollTop - thumbGrid.offset().top) / organizeData.height);
+ var itemIndex = Math.min(itemRow * organizeData.columns + itemColumn, visibleCells.length - 1);
+ item = visibleCells.get(itemIndex);
+ }
var before = event.pageX < ($(item).offset().left + $(item).width() / 2);
- var left = (before && itemIndex < visibleCells.length ?
- $(item).position().left : $(item).position().left + organizeData.width) - 3;
+ var left = $(item).position().left + (before ? 0 : organizeData.width) - 3;
var top = $(item).position().top + 6 + scrollTop;
if ($("#g-organize-drop-target-marker").length) {
$("#g-organize-drop-target-marker").remove();
}
+
var set = $('')
.css({zIndex: 2000,
width: 2,
@@ -159,9 +166,11 @@
position: "absolute",
top: top, left: left
})
- .data("drop_position", {id: $(item).attr("ref"), position: before});
+ .data("drop_position", {id: $(item).attr("ref"),
+ position: organizeData.rtl ? !before : before});
thumbGrid.append(set);
}
+ return true;
},
/**
@@ -173,17 +182,17 @@
$(".sf-menu li.sfHover ul").css("z-index", 68);
$("#g-dialog").dialog("option", "zIndex", 70);
$("#g-dialog").bind("dialogopen", function(event, ui) {
- var outerHeight = $(".g-organize-microthumb-grid-cell").outerHeight(true);
- var outerWidth = $(".g-organize-microthumb-grid-cell").outerWidth(true);
- var gridInnerWidth = $("#g-organize-microthumb-grid").innerWidth() - 2 * parseFloat($("#g-organize-microthumb-grid").css("paddingLeft"));
- $("#g-organize")
- .height($("#g-dialog").innerHeight() - 20)
- .data("organizeData", {
- leftright: !$("body").hasClass("rtl"),
- height: outerHeight,
- width: outerWidth,
- columns: Math.floor(gridInnerWidth / outerWidth)
- });
+ var outerHeight = $(".g-organize-microthumb-grid-cell").outerHeight(true);
+ var outerWidth = $(".g-organize-microthumb-grid-cell").outerWidth(true);
+ var gridInnerWidth = $("#g-organize-microthumb-grid").innerWidth() - 2 * parseFloat($("#g-organize-microthumb-grid").css("paddingLeft"));
+ $("#g-organize")
+ .height($("#g-dialog").innerHeight() - 20)
+ .data("organizeData", {
+ rtl: $("body").hasClass("rtl"),
+ height: outerHeight,
+ width: outerWidth,
+ columns: Math.floor(gridInnerWidth / outerWidth)
+ });
});
$("#g-dialog").bind("dialogclose", function(event, ui) {
@@ -211,6 +220,17 @@
$(".g-organize-microthumb-grid-cell")
// need to manually add this class in case we care calling with additional elements
.addClass("ui-selectee")
+ .mouseleave(function(event) {
+ if ($(".g-drag-helper").length) {
+ $(this).removeClass("g-mouse-drag-over");
+ }
+ })
+ .mouseenter(function(event) {
+ $(".g-mouse-drag-over").removeClass("g-mouse-drag-over");
+ if ($(".g-drag-helper").length) {
+ $(this).addClass("g-mouse-drag-over");
+ }
+ })
.draggable($.organize.micro_thumb_draggable);
$(".g-organize-album").droppable($.organize.branch_droppable);
$(".g-organize-album-text").click($.organize.show_album);
--
cgit v1.2.3
From 2337fa93e6f5da3dd89454235d76a61b9181f0ab Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 15:13:13 -0800
Subject: remove debudding statement and if no target is found then assume the
insert position is after the last element.
---
modules/organize/js/organize.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 5fc0084c..942e49e5 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -58,6 +58,12 @@
drop: function(event, ui) {
$(".g-mouse-drag-over").removeClass("g-mouse-drag-over");
var target = $("#g-organize-drop-target-marker").data("drop_position");
+ if (target == null) {
+ target = {
+ position: false,
+ id: $(".g-organize-microthumb-grid-cell:visible:last").attr("ref")
+ };
+ }
$.organize.do_drop({
url: rearrange_url
.replace("__TARGET_ID__", target.id)
@@ -140,8 +146,6 @@
var item = $(".g-mouse-drag-over");
if (item.length == 0) {
- console.log("no item");
-
var itemColumn = Math.floor((event.pageX - thumbGrid.offset().left) / organizeData.width);
itemColumn = organizeData.rtl ? organizeData.width - itemColumn : itemColumn;
var itemRow = Math.floor((event.pageY + scrollTop - thumbGrid.offset().top) / organizeData.height);
--
cgit v1.2.3
From f93528ffab19b7a733fc8fb21c22853d8ec0d2f5 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 15:37:32 -0800
Subject: Last partial fix for ticket 585: Compartmentalize the admin area and
require active authentication every 20 minutes to access the admin area.
Also renaming auth::validate_too_many_failed_password_changes to validate_too_many_failed_auth_attempts since it's used in this generalized way in 3 places now.
---
modules/gallery/controllers/admin.php | 6 ++-
modules/gallery/controllers/reauthenticate.php | 72 ++++++++++++++++++++++++++
modules/gallery/helpers/auth.php | 27 +++++++++-
modules/gallery/helpers/gallery_event.php | 2 +
modules/gallery/views/reauthenticate.html.php | 10 ++++
modules/user/controllers/users.php | 8 +--
6 files changed, 118 insertions(+), 7 deletions(-)
create mode 100644 modules/gallery/controllers/reauthenticate.php
create mode 100644 modules/gallery/views/reauthenticate.html.php
(limited to 'modules')
diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php
index e4216991..b5f3db39 100644
--- a/modules/gallery/controllers/admin.php
+++ b/modules/gallery/controllers/admin.php
@@ -21,7 +21,7 @@ class Admin_Controller extends Controller {
private $theme;
public function __construct($theme=null) {
- if (!(identity::active_user()->admin)) {
+ if (!identity::active_user()->admin) {
access::forbidden();
}
@@ -29,6 +29,10 @@ class Admin_Controller extends Controller {
}
public function __call($controller_name, $args) {
+ if (auth::must_reauth_for_admin_area()) {
+ return url::redirect("reauthenticate");
+ }
+
if (request::method() == "post") {
access::verify_csrf();
}
diff --git a/modules/gallery/controllers/reauthenticate.php b/modules/gallery/controllers/reauthenticate.php
new file mode 100644
index 00000000..4b88a9cc
--- /dev/null
+++ b/modules/gallery/controllers/reauthenticate.php
@@ -0,0 +1,72 @@
+admin) {
+ access::forbidden();
+ }
+ return self::_show_form(self::_form());
+ }
+
+ public function auth() {
+ if (!identity::active_user()->admin) {
+ access::forbidden();
+ }
+ access::verify_csrf();
+
+ $form = self::_form();
+ $valid = $form->validate();
+ $user = identity::active_user();
+ if ($valid) {
+ message::success(t("Successfully re-authenticated!"));
+ module::event("user_auth", $user);
+ url::redirect("admin");
+ } else {
+ $name = $user->name;
+ log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
+ module::event("user_auth_failed", $name);
+ return self::_show_form($form);
+ }
+ }
+
+ private static function _show_form($form) {
+ $view = new Theme_View("page.html", "other", "reauthenticate");
+ $view->page_title = t("Re-authenticate");
+ $view->content = new View("reauthenticate.html");
+ $view->content->form = $form;
+ $view->content->user_name = identity::active_user()->name;
+ print $view;
+ }
+
+ private static function _form() {
+ $form = new Forge("reauthenticate/auth", "", "post", array("id" => "g-reauthenticate-form"));
+ $form->set_attr('class', "g-narrow");
+ $group = $form->group("reauthenticate")->label(t("Re-authenticate"));
+ $group->password("password")->label(t("Password"))->id("g-password")->class(null)
+ ->callback("auth::validate_too_many_failed_auth_attempts")
+ ->callback("user::valid_password")
+ ->error_messages("invalid", t("Incorrect password"))
+ ->error_messages(
+ "too_many_failed_auth_attempts",
+ t("Too many incorrect passwords. Try again later"));
+ $group->submit("")->value(t("Submit"));
+ return $form;
+ }
+}
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index 2c1e3f67..c3e9e6e9 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -78,9 +78,9 @@ class auth_Core {
}
}
- static function validate_too_many_failed_password_changes($password_input) {
+ static function validate_too_many_failed_auth_attempts($form_input) {
if (self::too_many_failures(identity::active_user()->name)) {
- $password_input->add_error("too_many_failed_password_changes", 1);
+ $form_input->add_error("too_many_failed_auth_attempts", 1);
}
}
@@ -107,4 +107,27 @@ class auth_Core {
->where("name", "=", $user->name)
->delete_all();
}
+
+ /**
+ * Checks whether the current user (= admin) must
+ * actively re-authenticate before access is given
+ * to the admin area.
+ */
+ static function must_reauth_for_admin_area() {
+ if (!identity::active_user()->admin) {
+ access::forbidden();
+ }
+
+ $session = Session::instance();
+ $last_active_auth = $session->get("active_auth_timestamp", 0);
+ $last_admin_area_activity = $session->get("admin_area_activity_timestamp", 0);
+ $admin_area_timeout = module::get_var("gallery", "admin_area_timeout");
+
+ if (max($last_active_auth, $last_admin_area_activity) + $admin_area_timeout < time()) {
+ return true;
+ }
+
+ $session->set("admin_area_activity_timestamp", time());
+ return false;
+ }
}
\ No newline at end of file
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 5fa82160..63f33c12 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -110,6 +110,7 @@ class gallery_event_Core {
graphics::choose_default_toolkit();
module::clear_var("gallery", "choose_default_tookit");
}
+ Session::instance()->set("active_auth_timestamp", time());
auth::clear_failed_attempts($user);
}
@@ -119,6 +120,7 @@ class gallery_event_Core {
static function user_auth($user) {
auth::clear_failed_attempts($user);
+ Session::instance()->set("active_auth_timestamp", time());
}
static function item_index_data($item, $data) {
diff --git a/modules/gallery/views/reauthenticate.html.php b/modules/gallery/views/reauthenticate.html.php
new file mode 100644
index 00000000..8611d0f7
--- /dev/null
+++ b/modules/gallery/views/reauthenticate.html.php
@@ -0,0 +1,10 @@
+
+
+
+ = t("The administration session has expired, please re-authenticate to access the administration area.") ?>
+
+
+ = t("You are currently logged in as %user_name.", array("user_name" => $user_name)) ?>
+
+ = $form ?>
+
\ No newline at end of file
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 1130852b..0730f391 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -164,11 +164,11 @@ class Users_Controller extends Controller {
"users/change_password/$user->id", "", "post", array("id" => "g-change-password-user-form"));
$group = $form->group("change_password")->label(t("Change your password"));
$group->password("old_password")->label(t("Old password"))->id("g-password")
- ->callback("auth::validate_too_many_failed_password_changes")
+ ->callback("auth::validate_too_many_failed_auth_attempts")
->callback("user::valid_password")
->error_messages("invalid", t("Incorrect password"))
->error_messages(
- "too_many_failed_password_changes",
+ "too_many_failed_auth_attempts",
t("Too many incorrect passwords. Try again later"));
$group->password("password")->label(t("New password"))->id("g-password")
->error_messages("min_length", t("Your new password is too short"));
@@ -189,11 +189,11 @@ class Users_Controller extends Controller {
"users/change_email/$user->id", "", "post", array("id" => "g-change-email-user-form"));
$group = $form->group("change_email")->label(t("Change your email address"));
$group->password("password")->label(t("Current password"))->id("g-password")
- ->callback("auth::validate_too_many_failed_password_changes")
+ ->callback("auth::validate_too_many_failed_auth_attempts")
->callback("user::valid_password")
->error_messages("invalid", t("Incorrect password"))
->error_messages(
- "too_many_failed_password_changes",
+ "too_many_failed_auth_attempts",
t("Too many incorrect passwords. Try again later"));
$group->input("email")->label(t("New email address"))->id("g-email")->value($user->email)
->error_messages("email", t("You must enter a valid email address"))
--
cgit v1.2.3
From 8fc346e9b67204c31e2bfeb59a5cbaa49e308085 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 16:44:07 -0800
Subject: Addendum for ticket 585: Handle case C), redirect the admin to a
non-admin page when the admin area session expires, before the admin has a
chance to send an XHR admin request, for which we wouldn't have a good
answer.
---
modules/gallery/helpers/gallery_theme.php | 11 +++++++++++
1 file changed, 11 insertions(+)
(limited to 'modules')
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 0018fd9a..9ffeb911 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -90,6 +90,17 @@ class gallery_theme_Core {
$profiler = new Profiler();
$profiler->render();
}
+
+ // Redirect to the root album when the admin session expires.
+ $redirect_url = url::abs_site("");
+ $admin_area_timeout = 1000 * module::get_var("gallery", "admin_area_timeout");
+ $admin_session_redirect_check = '';
+ print $admin_session_redirect_check;
+
if ($session->get("l10n_mode", false)) {
return L10n_Client_Controller::l10n_form();
}
--
cgit v1.2.3
From 9695041a86ffeb1bfc5ced654cb04a9833eb9288 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 16:56:19 -0800
Subject: Change welcome message dialog to link to the user_profile page
instead of the change user dialog. a) the edit user form doesn't include the
password anymore b) the new admin would probably also like to change the
email, so directing him to the profile page with options to change the pw /
email.
Ideally, we'd have a special purpose edit profile page for the install experience, without prompting for the randomly generated password. But that's something for another task.
---
modules/gallery/views/welcome_message.html.php | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/views/welcome_message.html.php b/modules/gallery/views/welcome_message.html.php
index 24d01bab..caeeff66 100644
--- a/modules/gallery/views/welcome_message.html.php
+++ b/modules/gallery/views/welcome_message.html.php
@@ -15,15 +15,12 @@
- id}") ?>"
+ id}") ?>"
title="= t("Edit your profile")->for_html_attr() ?>"
id="g-after-install-change-password-link"
class="g-button ui-state-default ui-corners-all">
- = t("Change password now") ?>
+ = t("Change password and email now") ?>
-
--
cgit v1.2.3
From 316b0583b374a5754ea112c00464d118917cdbc1 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 21:38:51 -0800
Subject: Revert "Refactor the admin maintenance screen so that events are used
to populate the action buttons and other content such as the list of
scheduled tasks."
Leaving this api out of RC1.
This reverts commit 19fee6b5e4ceb8a5f90cafe4ad770856ece108ef.
Conflicts:
modules/gallery/views/admin_maintenance.html.php
---
modules/gallery/controllers/admin_maintenance.php | 11 ++---------
modules/gallery/views/admin_maintenance.html.php | 16 +++++++++-------
2 files changed, 11 insertions(+), 16 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 8e4845a9..487e77a6 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -44,17 +44,10 @@ class Admin_Maintenance_Controller extends Admin_Controller {
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")
->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
+ $view->content->schedule_definitions =
+ module::is_active("scheduler") ? scheduler::get_definitions() : "";
$view->content->finished_tasks = ORM::factory("task")
->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
- $task_buttons =
- new ArrayObject(array((object)array("text" => t("run"),
- "url" =>url::site("admin/maintenance/start"))));
- module::event("admin_maintenance_task_buttons", $task_buttons);
- $view->content->task_buttons = $task_buttons;
-
- $maintenance_content = new ArrayObject();
- module::event("admin_maintenance_content", $maintenance_content);
- $view->content->task_maintenance_content = $maintenance_content;
print $view;
}
diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php
index 19375670..15d04caa 100644
--- a/modules/gallery/views/admin_maintenance.html.php
+++ b/modules/gallery/views/admin_maintenance.html.php
@@ -29,21 +29,23 @@
= $task->description ?>
- foreach ($task_buttons as $button): ?>
- url}/$task->callback?csrf=$csrf" ?>"
+ callback?csrf=$csrf") ?>"
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
- = html::clean($button->text) ?>
+ = t("run") ?>
- endforeach ?>
+ if (module::is_active("scheduler")): ?>
+ callback?csrf=$csrf") ?>"
+ class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
+ = t("schedule") ?>
+
+ endif ?>
|
endforeach ?>
- foreach ($task_maintenance_content as $content): ?>
- = html::purify($content) ?>
- endforeach ?>
+ = $schedule_definitions ?>
if ($running_tasks->count()): ?>
--
cgit v1.2.3
From bca3eeb92399093214ac0f5a74a380b14ffd0405 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 21:39:26 -0800
Subject: Import G2 permissions in the import process. Ignores user and item
specific permissions.
---
modules/g2_import/helpers/g2_import.php | 190 +++++++++++++++++++----
modules/g2_import/helpers/g2_import_task.php | 13 +-
modules/g2_import/views/admin_g2_import.html.php | 2 +-
3 files changed, 162 insertions(+), 43 deletions(-)
(limited to 'modules')
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index f13c63b1..31368a5b 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -357,45 +357,48 @@ class g2_import_Core {
}
if ($g2_album->getParentId() == null) {
- return t("Skipping Gallery 2 root album");
- }
- $parent_album = ORM::factory("item", self::map($g2_album->getParentId()));
-
- $album = ORM::factory("item");
- $album->type = "album";
- $album->parent_id = self::map($g2_album->getParentId());
- $album->name = $g2_album->getPathComponent();
- $album->title = self::_decode_html_special_chars($g2_album->getTitle());
- $album->description = self::_decode_html_special_chars(self::extract_description($g2_album));
- $album->owner_id = self::map($g2_album->getOwnerId());
- $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
- $album->created = $g2_album->getCreationTimestamp();
-
- $order_map = array(
- "originationTimestamp" => "captured",
- "creationTimestamp" => "created",
- "description" => "description",
- "modificationTimestamp" => "updated",
- "orderWeight" => "weight",
- "pathComponent" => "name",
- "summary" => "description",
- "title" => "title",
- "viewCount" => "view_count");
- $direction_map = array(
- ORDER_ASCENDING => "asc",
- ORDER_DESCENDING => "desc");
- if (array_key_exists($g2_order = $g2_album->getOrderBy(), $order_map)) {
- $album->sort_column = $order_map[$g2_order];
- $album->sort_order = $direction_map[$g2_album->getOrderDirection()];
- }
- $album->save();
-
- self::import_keywords_as_tags($g2_album->getKeywords(), $album);
+ $album = item::root();
+ } else {
+ $parent_album = ORM::factory("item", self::map($g2_album->getParentId()));
+
+ $album = ORM::factory("item");
+ $album->type = "album";
+ $album->parent_id = self::map($g2_album->getParentId());
+ $album->name = $g2_album->getPathComponent();
+ $album->title = self::_decode_html_special_chars($g2_album->getTitle());
+ $album->description = self::_decode_html_special_chars(self::extract_description($g2_album));
+ $album->owner_id = self::map($g2_album->getOwnerId());
+ $album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
+ $album->created = $g2_album->getCreationTimestamp();
+
+ $order_map = array(
+ "originationTimestamp" => "captured",
+ "creationTimestamp" => "created",
+ "description" => "description",
+ "modificationTimestamp" => "updated",
+ "orderWeight" => "weight",
+ "pathComponent" => "name",
+ "summary" => "description",
+ "title" => "title",
+ "viewCount" => "view_count");
+ $direction_map = array(
+ ORDER_ASCENDING => "asc",
+ ORDER_DESCENDING => "desc");
+ if (array_key_exists($g2_order = $g2_album->getOrderBy(), $order_map)) {
+ $album->sort_column = $order_map[$g2_order];
+ $album->sort_order = $direction_map[$g2_album->getOrderDirection()];
+ }
+ $album->save();
+
+ self::import_keywords_as_tags($g2_album->getKeywords(), $album);
+ }
self::set_map(
$g2_album_id, $album->id,
"album",
self::g2_url(array("view" => "core.ShowItem", "itemId" => $g2_album->getId())));
+
+ self::_import_permissions($g2_album, $album);
}
/**
@@ -590,6 +593,125 @@ class g2_import_Core {
array("&", "\"", "<", ">"), $value);
}
+ private static $_permission_map = array(
+ "core.view" => "view",
+ "core.viewSource" => "view_full",
+ "core.edit" => "edit",
+ "core.addDataItem" => "add",
+ "core.addAlbumItem" => "add");
+
+ /**
+ * Imports G2 permissions, mapping G2's permission model to G3's
+ * much simplified permissions.
+ *
+ * - Ignores user permissions, G3 only supports group permissions.
+ * - Ignores item permissions, G3 only supports album permissions.
+ *
+ * G2 permission -> G3 permission
+ * ---------------------------------
+ * core.view view
+ * core.viewSource view_full
+ * core.edit edit
+ * core.addDataItem add
+ * core.addAlbumItem add
+ * core.viewResizes
+ * core.delete
+ * comment.*
+ */
+ private static function _import_permissions($g2_album, $g3_album) {
+ // No need to do anything if this album has the same G2 ACL as its parent.
+ if ($g2_album->getParentId() != null &&
+ g2(GalleryCoreApi::fetchAccessListId($g2_album->getId())) ==
+ g2(GalleryCoreApi::fetchAccessListId($g2_album->getParentId()))) {
+ return;
+ }
+
+ $granted_permissions = self::_map_permissions($g2_album->getId());
+
+ if ($g2_album->getParentId() == null) {
+ // Compare to current permissions, and change them if necessary.
+ $g3_parent_album = item::root();
+ } else {
+ $g3_parent_album = $g3_album->parent();
+ }
+ $granted_parent_permissions = array();
+ $perm_ids = array_unique(array_values(self::$_permission_map));
+ foreach (identity::groups() as $group) {
+ $granted_parent_permissions[$group->id] = array();
+ foreach ($perm_ids as $perm_id) {
+ if (access::group_can($group, $perm_id, $g3_parent_album)) {
+ $granted_parent_permissions[$group->id][$perm_id] = 1;
+ }
+ }
+ }
+
+ // Note: Only registering permissions if they're not the same as
+ // the inherited ones.
+ foreach ($granted_permissions as $group_id => $permissions) {
+ if (!isset($granted_parent_permissions[$group_id])) {
+ foreach (array_keys($permissions) as $perm_id) {
+ access::allow(identity::lookup_group($group_id), $perm_id, $g3_album);
+ }
+ } else if ($permissions != $granted_parent_permissions[$group_id]) {
+ $parent_permissions = $granted_parent_permissions[$group_id];
+ // @todo Probably worth caching the group instances.
+ $group = identity::lookup_group($group_id);
+ // Note: Cannot use array_diff_key.
+ foreach (array_keys($permissions) as $perm_id) {
+ if (!isset($parent_permissions[$perm_id])) {
+ access::allow($group, $perm_id, $g3_album);
+ }
+ }
+ foreach (array_keys($parent_permissions) as $perm_id) {
+ if (!isset($permissions[$perm_id])) {
+ access::deny($group, $perm_id, $g3_album);
+ }
+ }
+ }
+ }
+
+ foreach ($granted_parent_permissions as $group_id => $parent_permissions) {
+ if (isset($granted_permissions[$group_id])) {
+ continue; // handled above
+ }
+ $group = identity::lookup_group($group_id);
+ foreach (array_keys($parent_permissions) as $perm_id) {
+ access::deny($group, $perm_id, $g3_album);
+ }
+ }
+ }
+
+ /**
+ * Loads all the granted group G2 permissions for a specific
+ * album and returns an array with G3 groups ids and G3 permission ids.
+ */
+ private static function _map_permissions($g2_album_id) {
+ $g2_permissions = g2(GalleryCoreApi::fetchAllPermissionsForItem($g2_album_id));
+ $permissions = array();
+ foreach ($g2_permissions as $entry) {
+ // @todo Do something about user permissions? E.g. map G2's user albums
+ // to a user-specific group in G3?
+ if (!isset($entry["groupId"])) {
+ continue;
+ }
+ $g2_permission_id = $entry["permission"];
+ if (!isset(self::$_permission_map[$g2_permission_id])) {
+ continue;
+ }
+ $group_id = self::map($entry["groupId"]);
+ if ($group_id == null) {
+ // E.g. the G2 admin group isn't mapped.
+ continue;
+ }
+ $permission_id = self::$_permission_map[$g2_permission_id];
+ if (!isset($permissions[$group_id])) {
+ $permissions[$group_id] = array();
+ }
+ $permissions[$group_id][$permission_id] = 1;
+ }
+ return $permissions;
+ }
+
/**
* Import a single comment.
*/
diff --git a/modules/g2_import/helpers/g2_import_task.php b/modules/g2_import/helpers/g2_import_task.php
index 1ec6870e..b1179e22 100644
--- a/modules/g2_import/helpers/g2_import_task.php
+++ b/modules/g2_import/helpers/g2_import_task.php
@@ -73,13 +73,8 @@ class g2_import_task_Core {
}
$task->set("done", $done);
- $root_g2_id = g2(GalleryCoreApi::getDefaultAlbumId());
- $root = ORM::factory("g2_map")->where("g2_id", "=", $root_g2_id)->find();
- if (!$root->loaded()) {
- $root->g2_id = $root_g2_id;
- $root->g3_id = 1;
- $root->save();
- }
+ // Ensure G2 ACLs are compacted to speed up import.
+ g2(GalleryCoreApi::compactAccessLists());
}
$modes = array("groups", "users", "albums", "items", "comments", "tags", "highlights", "done");
@@ -128,7 +123,9 @@ class g2_import_task_Core {
case "albums":
if (empty($queue)) {
- $task->set("queue", $queue = g2(GalleryCoreApi::fetchAlbumTree()));
+ $g2_root_id = g2(GalleryCoreApi::getDefaultAlbumId());
+ $tree = g2(GalleryCoreApi::fetchAlbumTree());
+ $task->set("queue", $queue = array($g2_root_id => $tree));
}
$log_message = g2_import::import_album($queue);
if ($log_message) {
diff --git a/modules/g2_import/views/admin_g2_import.html.php b/modules/g2_import/views/admin_g2_import.html.php
index 41ef7f85..3b7afec2 100644
--- a/modules/g2_import/views/admin_g2_import.html.php
+++ b/modules/g2_import/views/admin_g2_import.html.php
@@ -13,7 +13,7 @@
-
- = t("Permissions are not imported. You will have to set them again manually (for now).") ?>
+ = t("Please review album permissions after the import! Permissions are imported, but user specific and item specific permissions are not supported in Gallery 3 and thus ignored.") ?>
-
= t("The only supported file formats are JPG, PNG and GIF, FLV and MP4. Other formats will be skipped.") ?>
--
cgit v1.2.3
From b8047db5393ddbe27d6ee391845802054b92bf79 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Sun, 7 Feb 2010 21:40:34 -0800
Subject: Revert "Add the scheduler component to the admin maintenance screen."
This reverts commit 48cb5021c6bd7e65a13a0ff50a9e76f72da7d3a1.
---
modules/gallery/controllers/admin_maintenance.php | 2 --
modules/gallery/views/admin_maintenance.html.php | 8 --------
2 files changed, 10 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index 487e77a6..d90fe0ea 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -44,8 +44,6 @@ class Admin_Maintenance_Controller extends Admin_Controller {
$view->content->task_definitions = task::get_definitions();
$view->content->running_tasks = ORM::factory("task")
->where("done", "=", 0)->order_by("updated", "DESC")->find_all();
- $view->content->schedule_definitions =
- module::is_active("scheduler") ? scheduler::get_definitions() : "";
$view->content->finished_tasks = ORM::factory("task")
->where("done", "=", 1)->order_by("updated", "DESC")->find_all();
print $view;
diff --git a/modules/gallery/views/admin_maintenance.html.php b/modules/gallery/views/admin_maintenance.html.php
index 15d04caa..ac597715 100644
--- a/modules/gallery/views/admin_maintenance.html.php
+++ b/modules/gallery/views/admin_maintenance.html.php
@@ -33,20 +33,12 @@
class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
= t("run") ?>
- if (module::is_active("scheduler")): ?>
- callback?csrf=$csrf") ?>"
- class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all">
- = t("schedule") ?>
-
- endif ?>
endforeach ?>
- = $schedule_definitions ?>
-
if ($running_tasks->count()): ?>
= t("Running tasks") ?>
--
cgit v1.2.3
From 0a6630af2d63add9b31e382e46e8922f5845d361 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Sun, 7 Feb 2010 22:30:08 -0800
Subject: Improve likelihood that image block shows up for small photo
collections by retrying the random query a few times.
---
modules/image_block/helpers/image_block_block.php | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/image_block/helpers/image_block_block.php b/modules/image_block/helpers/image_block_block.php
index 185df850..82c92f19 100644
--- a/modules/image_block/helpers/image_block_block.php
+++ b/modules/image_block/helpers/image_block_block.php
@@ -26,7 +26,13 @@ class image_block_block_Core {
$block = "";
switch ($block_id) {
case "random_image":
- $item = item::random_query(array(array("type", "!=", "album")))->find_all(1)->current();
+ // The random_query approach is flawed and doesn't always return a
+ // result when there actually is one. Retry a *few* times.
+ // @todo Consider another fallback if further optimizations are necessary.
+ $attempts = 0;
+ do {
+ $item = item::random_query(array(array("type", "!=", "album")))->find_all(1)->current();
+ } while (!$item && $attempts++ < 3);
if ($item && $item->loaded()) {
$block = new Block();
$block->css_id = "g-image-block";
--
cgit v1.2.3
From d0f6839c25c328c1bc0baff87974a8b268933361 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Mon, 8 Feb 2010 00:05:17 -0800
Subject: Fix Arabic language name. Thanks shaibn for reporting the issue.
Verified with CLDR data.
---
modules/gallery/helpers/locales.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 4af750a3..883d2f9a 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -64,7 +64,7 @@ class locales_Core {
// @todo Might want to add a localizable language name as well.
private static function _init_language_data() {
$l["af_ZA"] = "Afrikaans"; // Afrikaans
- $l["ar_SA"] = "العربي"; // Arabic
+ $l["ar_SA"] = "العربية"; // Arabic
$l["be_BY"] = "Беларускі"; // Belarusian
$l["bg_BG"] = "български"; // Bulgarian
$l["ca_ES"] = "Catalan"; // Catalan
--
cgit v1.2.3
From f9d00aa7429599f46e09b23e8313932ac5e186c3 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Mon, 8 Feb 2010 00:30:36 -0800
Subject: Fix for ticket 1008: Redirect to destination after re-auth.
---
modules/gallery/controllers/admin.php | 12 +++++++++++-
modules/gallery/controllers/reauthenticate.php | 3 ++-
2 files changed, 13 insertions(+), 2 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php
index b5f3db39..5467e88a 100644
--- a/modules/gallery/controllers/admin.php
+++ b/modules/gallery/controllers/admin.php
@@ -30,7 +30,7 @@ class Admin_Controller extends Controller {
public function __call($controller_name, $args) {
if (auth::must_reauth_for_admin_area()) {
- return url::redirect("reauthenticate");
+ return self::_prompt_for_reauth($controller_name, $args);
}
if (request::method() == "post") {
@@ -53,5 +53,15 @@ class Admin_Controller extends Controller {
call_user_func_array(array(new $controller_name, $method), $args);
}
+
+ private static function _prompt_for_reauth($controller_name, $args) {
+ if (request::method() == "get" && !request::is_ajax()) {
+ $url_args = array("admin", $controller_name) + $args;
+ $continue_url = join("/", $url_args);
+ // Avoid anti-phishing protection by passing the url as session variable.
+ Session::instance()->set("continue_url", $continue_url);
+ }
+ url::redirect("reauthenticate");
+ }
}
diff --git a/modules/gallery/controllers/reauthenticate.php b/modules/gallery/controllers/reauthenticate.php
index 4b88a9cc..dbd1cd21 100644
--- a/modules/gallery/controllers/reauthenticate.php
+++ b/modules/gallery/controllers/reauthenticate.php
@@ -37,7 +37,8 @@ class Reauthenticate_Controller extends Controller {
if ($valid) {
message::success(t("Successfully re-authenticated!"));
module::event("user_auth", $user);
- url::redirect("admin");
+ $continue_url = Session::instance()->get_once("continue_url", "admin");
+ url::redirect($continue_url);
} else {
$name = $user->name;
log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
--
cgit v1.2.3
From 47293fcb03d51e5b4691e9905019c1ff1732b0f4 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Mon, 8 Feb 2010 09:15:02 -0800
Subject: Correct tree branch alignment in IE
---
modules/organize/views/organize_tree.html.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/views/organize_tree.html.php b/modules/organize/views/organize_tree.html.php
index 3912c1f6..33d7b4c9 100644
--- a/modules/organize/views/organize_tree.html.php
+++ b/modules/organize/views/organize_tree.html.php
@@ -1,5 +1,5 @@
-"
+"
ref="= $album->id ?>">
@@ -7,12 +7,12 @@
ref="= $album->id ?>">
= html::clean($album->title) ?>
-
+
foreach ($album->children(null, null, array(array("type", "=", "album"))) as $child): ?>
if ($selected && $child->contains($selected)): ?>
= View::factory("organize_tree.html", array("selected" => $selected, "album" => $child)); ?>
else: ?>
- - "
+
- "
ref="= $child->id ?>">
" ref="= $child->id ?>">
--
cgit v1.2.3
From afdb98412e5611894ca96659e1db452d9e7330c2 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Mon, 8 Feb 2010 11:26:40 -0800
Subject: Fix the missing object problem in ie7. Fixes ticket: 1003. There is
still issues with selectables and draggables working together in IEx
---
modules/organize/js/organize.js | 45 +++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 24 deletions(-)
(limited to 'modules')
diff --git a/modules/organize/js/organize.js b/modules/organize/js/organize.js
index 942e49e5..5b90f402 100644
--- a/modules/organize/js/organize.js
+++ b/modules/organize/js/organize.js
@@ -7,31 +7,28 @@
appendTo: "#g-organize-content-pane",
helper: function(event, ui) {
var selected = $(".ui-draggable.ui-selected img");
- if (selected.length) {
- var set = $('')
- .css({
- zIndex: 2000,
- width: 80,
- height: Math.ceil(selected.length / 5) * 16
- });
+ var set = $('')
+ .css({
+ zIndex: 2000,
+ width: 80,
+ height: Math.ceil(selected.length / 5) * 16
+ });
- selected.each(function(i) {
- var row = parseInt(i / 5);
- var j = i - (row * 5);
- var o = $(this).offset();
- var copy = $(this).clone()
- .css({
- width: $(this).width(), height: $(this).height(), display: "block",
- margin: 0, position: 'absolute', outline: '5px solid #fff',
- left: o.left - event.pageX, top: o.top - event.pageY
- })
- .appendTo(set)
- .animate({ width: 10, height: 10, outlineWidth: 1, margin: 1,
- left: (20 * j), top: (row * 20) }, 500);
- });
- return set;
- }
- return null;
+ selected.each(function(i) {
+ var row = parseInt(i / 5);
+ var j = i - (row * 5);
+ var o = $(this).offset();
+ var copy = $(this).clone()
+ .css({
+ width: $(this).width(), height: $(this).height(), display: "block",
+ margin: 0, position: 'absolute', outline: '5px solid #fff',
+ left: o.left - event.pageX, top: o.top - event.pageY
+ })
+ .appendTo(set)
+ .animate({ width: 10, height: 10, outlineWidth: 1, margin: 1,
+ left: (20 * j), top: (row * 20) }, 500);
+ });
+ return set;
},
start: function(event, ui) {
--
cgit v1.2.3
From f9377bcbd37886f09cfcf72a89f73629825e63dc Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Mon, 8 Feb 2010 13:05:18 -0800
Subject: Suppress errors when checking for readability of /proc/loadavg. Often
this file will be protected by openbasedir, and is_readable will trigger an
open basedir warning.
---
modules/gallery/helpers/gallery_block.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/gallery_block.php b/modules/gallery/helpers/gallery_block.php
index be0f11b8..46742743 100644
--- a/modules/gallery/helpers/gallery_block.php
+++ b/modules/gallery/helpers/gallery_block.php
@@ -70,7 +70,7 @@ class gallery_block_Core {
$block->css_id = "g-platform";
$block->title = t("Platform information");
$block->content = new View("admin_block_platform.html");
- if (is_readable("/proc/loadavg")) {
+ if (@is_readable("/proc/loadavg")) {
$block->content->load_average =
join(" ", array_slice(explode(" ", current(file("/proc/loadavg"))), 0, 3));
} else {
--
cgit v1.2.3
From 6dfab72922bf20104d6032eb292d59c6bd6578ba Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Mon, 8 Feb 2010 15:37:11 -0800
Subject: Override Input::clean_input_keys() to sanitize malicious values out
of strings instead of dying. This at least gives us graceful degradation.
Fixes ticket #764, patch thanks to djnz.
---
modules/gallery/libraries/MY_Input.php | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 modules/gallery/libraries/MY_Input.php
(limited to 'modules')
diff --git a/modules/gallery/libraries/MY_Input.php b/modules/gallery/libraries/MY_Input.php
new file mode 100644
index 00000000..dce569fd
--- /dev/null
+++ b/modules/gallery/libraries/MY_Input.php
@@ -0,0 +1,31 @@
+
Date: Mon, 8 Feb 2010 22:15:38 -0800
Subject: Change admin area timeout from 20 to 90 minutes
---
modules/gallery/helpers/gallery_installer.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index ed4a62a5..dd53cf43 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -287,7 +287,7 @@ class gallery_installer {
// @todo this string needs to be picked up by l10n_scanner
module::set_var("gallery", "credits", "Powered by Gallery %version");
module::set_var("gallery", "simultaneous_upload_limit", 5);
- module::set_var("gallery", "admin_area_timeout", 20 * 60);
+ module::set_var("gallery", "admin_area_timeout", 90 * 60);
module::set_version("gallery", 28);
}
@@ -534,8 +534,8 @@ class gallery_installer {
}
if ($version == 27) {
- // Set the admin area timeout to 20 minutes
- module::set_var("gallery", "admin_area_timeout", 20 * 60);
+ // Set the admin area timeout to 90 minutes
+ module::set_var("gallery", "admin_area_timeout", 90 * 60);
module::set_version("gallery", $version = 28);
}
}
--
cgit v1.2.3
From 42bc1279257268e2c68b5f4b06e62e95ca8228d4 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Tue, 9 Feb 2010 00:46:09 -0800
Subject: Fix g2_import bugs related to item and user model validation.
---
modules/g2_import/helpers/g2_import.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 31368a5b..3b0f966a 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -304,7 +304,11 @@ class g2_import_Core {
if ($user) {
$message = t("Loaded existing user: '%name'.", array("name" => $user->name));
} else {
- $user = identity::create_user($g2_user->getUsername(), $g2_user->getfullname(), "");
+ $user = identity::create_user($g2_user->getUsername(), $g2_user->getfullname(),
+ // Note: The API expects a password in cleartext.
+ // Just use the hashed password as an unpredictable
+ // value here. The user will have to reset the password.
+ $g2_user->getHashedPassword(), $g2_user->getEmail());
$message = t("Created user: '%name'.", array("name" => $user->name));
}
@@ -366,6 +370,7 @@ class g2_import_Core {
$album->parent_id = self::map($g2_album->getParentId());
$album->name = $g2_album->getPathComponent();
$album->title = self::_decode_html_special_chars($g2_album->getTitle());
+ $album->title or $album->title = $album->name;
$album->description = self::_decode_html_special_chars(self::extract_description($g2_album));
$album->owner_id = self::map($g2_album->getOwnerId());
$album->view_count = g2(GalleryCoreApi::fetchItemViewCount($g2_album_id));
@@ -491,6 +496,7 @@ class g2_import_Core {
$item->set_data_file($g2_path);
$item->name = $g2_item->getPathComponent();
$item->title = self::_decode_html_special_chars($g2_item->getTitle());
+ $item->title or $item->title = $item->name;
$item->description = self::_decode_html_special_chars(self::extract_description($g2_item));
$item->owner_id = self::map($g2_item->getOwnerId());
$item->save();
@@ -512,6 +518,7 @@ class g2_import_Core {
$item->set_data_file($g2_path);
$item->name = $g2_item->getPathComponent();
$item->title = self::_decode_html_special_chars($g2_item->getTitle());
+ $item->title or $item->title = $item->name;
$item->description = self::_decode_html_special_chars(self::extract_description($g2_item));
$item->owner_id = self::map($g2_item->getOwnerId());
} catch (Exception $e) {
--
cgit v1.2.3
From 55d1ce7fb7c3872295c1e7dbab41de94dd7e06d8 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Tue, 9 Feb 2010 01:51:04 -0800
Subject: More g2_import model validation fixes, and make import less noisy
(don't copy each comment text to the import log).
---
modules/g2_import/helpers/g2_import.php | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
(limited to 'modules')
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 3b0f966a..80feb7d0 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -732,6 +732,12 @@ class g2_import_Core {
array("id" => $g2_comment_id, "exception" => (string)$e));
}
+ $item_id = self::map($g2_comment->getParentId());
+ if (empty($item_id)) {
+ // Item was not mapped.
+ return;
+ }
+
$text = $g2_comment->getSubject();
if ($text) {
$text .= " ";
@@ -742,18 +748,17 @@ class g2_import_Core {
// we don't trigger spam filtering events
$comment = ORM::factory("comment");
$comment->author_id = self::map($g2_comment->getCommenterId());
- $comment->guest_name = $g2_comment->getAuthor();
- $comment->item_id = self::map($g2_comment->getParentId());
+ $comment->guest_name = "";
+ if ($comment->author_id == identity::guest()->id) {
+ $comment->guest_name = $g2_comment->getAuthor();
+ $comment->guest_name or $comment->guest_name = (string) t("Anonymous coward");
+ }
+ $comment->item_id = $item_id;
$comment->text = self::_transform_bbcode($text);
$comment->state = "published";
$comment->server_http_host = $g2_comment->getHost();
$comment->created = $g2_comment->getDate();
$comment->save();
-
- self::map($g2_comment->getId(), $comment->id);
- return t("Imported comment '%comment' for item with id: %id",
- array("id" => $comment->item_id,
- "comment" => text::limit_words(nl2br(html::purify($comment->text)), 50)));
}
/**
--
cgit v1.2.3
From 55d42ec9da0952361687257588788100a270ac9e Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Tue, 9 Feb 2010 02:16:49 -0800
Subject: Fix password reset confirmation
---
modules/user/controllers/password.php | 2 +-
modules/user/views/confirm_reset_password.html.php | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 modules/user/views/confirm_reset_password.html.php
(limited to 'modules')
diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php
index 8309d2cc..07fdc1ed 100644
--- a/modules/user/controllers/password.php
+++ b/modules/user/controllers/password.php
@@ -110,7 +110,7 @@ class Password_Controller extends Controller {
"mistyped", t("The password and the confirm password must match"));
$group->submit("")->value(t("Update"));
- $template->content = new View("user_form.html");
+ $template->content = new View("confirm_reset_password.html");
$template->content->form = $form;
return $template;
}
diff --git a/modules/user/views/confirm_reset_password.html.php b/modules/user/views/confirm_reset_password.html.php
new file mode 100644
index 00000000..4993189e
--- /dev/null
+++ b/modules/user/views/confirm_reset_password.html.php
@@ -0,0 +1,2 @@
+
+= $form ?>
\ No newline at end of file
--
cgit v1.2.3
From e1c08776468c2e2c5c5cb0926b78e24e29989f3c Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 9 Feb 2010 08:53:27 -0800
Subject: Add unit tests for item::move() in preparation for renaming when
there are conflicts (see ticket #957)
---
modules/gallery/tests/Item_Helper_Test.php | 47 ++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
(limited to 'modules')
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index cdbdd324..d6817ef9 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -42,4 +42,51 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$this->assert_equal("foo", item::convert_filename_to_slug("{[foo]}"));
$this->assert_equal("foo-bar", item::convert_filename_to_slug("{[foo!@#!$@#^$@($!(@bar]}"));
}
+
+ public function move_test() {
+ identity::set_active_user(identity::admin_user());
+ $photo = test::random_photo(item::root());
+ $dst_album = test::random_album();
+
+ item::move($photo, $dst_album);
+ $this->assert_same($dst_album->id, $photo->parent_id);
+ }
+
+
+ public function move_updates_album_covers_test() {
+ identity::set_active_user(identity::admin_user());
+
+ // 2 photos in the source album
+ $src_album = test::random_album();
+ $photo1 = test::random_photo($src_album);
+ $photo2 = test::random_photo($src_album);
+ $src_album->reload();
+
+ // destination album
+ $dst_album = test::random_album();
+
+ item::move($photo1, $dst_album);
+
+ // Refresh cached copies
+ $src_album->reload();
+ $dst_album->reload();
+
+ // photo 2 becomes the album cover for the source album and photo 1
+ // becomes the album cover for the destination
+ $this->assert_same($photo1->id, $dst_album->album_cover_item_id);
+ $this->assert_same($photo2->id, $src_album->album_cover_item_id);
+ }
+
+ public function move_leaves_empty_album_with_no_album_cover_test() {
+ identity::set_active_user(identity::admin_user());
+
+ $src_album = test::random_album();
+ $photo = test::random_photo($src_album);
+
+ item::move($photo, item::root());
+
+ $src_album->reload();
+ $this->assert_false($src_album->album_cover_item_id);
+ }
+
}
--
cgit v1.2.3
From dcee225935007fea06360591ab31546ac8495784 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Tue, 9 Feb 2010 10:17:48 -0800
Subject: Better handling of G2's multi level sort order in g2_import
---
modules/g2_import/helpers/g2_import.php | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
(limited to 'modules')
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 80feb7d0..d3ed92e8 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -389,9 +389,14 @@ class g2_import_Core {
$direction_map = array(
ORDER_ASCENDING => "asc",
ORDER_DESCENDING => "desc");
- if (array_key_exists($g2_order = $g2_album->getOrderBy(), $order_map)) {
+ // Only consider G2's first sort order
+ $g2_order = explode("|", $g2_album->getOrderBy() . "");
+ $g2_order = $g2_order[0];
+ $g2_order_direction = explode("|", $g2_album->getOrderDirection() . "");
+ $g2_order_direction = $g2_order_direction[0];
+ if (array_key_exists($g2_order, $order_map)) {
$album->sort_column = $order_map[$g2_order];
- $album->sort_order = $direction_map[$g2_album->getOrderDirection()];
+ $album->sort_order = $direction_map[$g2_order_direction];
}
$album->save();
--
cgit v1.2.3
From 157872434dc659cecf9e26acbe8006b2f0bc4e5f Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Tue, 9 Feb 2010 13:41:35 -0800
Subject: Import hashed passwords from G2 (which will only work if they're
PasswordHash passwords, not if they're G2 style md5 / salted md5).
---
modules/g2_import/helpers/g2_import.php | 4 ++++
1 file changed, 4 insertions(+)
(limited to 'modules')
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index d3ed92e8..faf08291 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -309,6 +309,10 @@ class g2_import_Core {
// Just use the hashed password as an unpredictable
// value here. The user will have to reset the password.
$g2_user->getHashedPassword(), $g2_user->getEmail());
+ if (class_exists("User_Model") && $user instanceof User_Model) {
+ // This will work if G2's password is a PasswordHash password as well.
+ $user->hashed_password = $g2_user->getHashedPassword();
+ }
$message = t("Created user: '%name'.", array("name" => $user->name));
}
--
cgit v1.2.3
From c0a598417cc1f9a5534348ec5edb9c138293bc01 Mon Sep 17 00:00:00 2001
From: Andy Staudacher
Date: Tue, 9 Feb 2010 13:54:14 -0800
Subject: Change access::can to access::required in g2 redirect, to please the
controller auth code audit test.
---
modules/g2_import/controllers/g2.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/g2_import/controllers/g2.php b/modules/g2_import/controllers/g2.php
index 347da649..1d97653a 100644
--- a/modules/g2_import/controllers/g2.php
+++ b/modules/g2_import/controllers/g2.php
@@ -61,9 +61,10 @@ class G2_Controller extends Controller {
}
$item = ORM::factory("item", $g2_map->g3_id);
- if (!$item->loaded() || !access::can("view", $item)) {
+ if (!$item->loaded()) {
throw new Kohana_404_Exception();
}
+ access::required("view", $item);
// Redirect the user to the new url
--
cgit v1.2.3
From 86721ce280f02dbf4127c83bb03372e09e616519 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 9 Feb 2010 15:21:40 -0800
Subject: Whitespace.
---
modules/gallery/helpers/locales.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index 883d2f9a..e72d7ed9 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -131,7 +131,7 @@ class locales_Core {
}
static function is_rtl($locale=null) {
- return Gallery_I18n::instance()->is_rtl($locale);
+ return Gallery_I18n::instance()->is_rtl($locale);
}
/**
--
cgit v1.2.3
From 8a8d8b4bc4425bddb4661df3bf081d131f369171 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 9 Feb 2010 15:49:43 -0800
Subject: Rename item name and slug if necessary to avoid a conflict when we
move photos. Fixes ticket #957.
---
modules/gallery/helpers/item.php | 51 +++++++++++++++++++++++++++++-
modules/gallery/tests/Item_Helper_Test.php | 28 +++++++++++++---
2 files changed, 73 insertions(+), 6 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php
index 41d49ce9..36193071 100644
--- a/modules/gallery/helpers/item.php
+++ b/modules/gallery/helpers/item.php
@@ -40,7 +40,56 @@ class item_Core {
}
$source->parent_id = $target->id;
- $source->save();
+
+ // Moving may result in name or slug conflicts. If that happens, try up to 5 times to pick a
+ // random name (or slug) to avoid the conflict.
+ $orig_name = $source->name;
+ $orig_name_filename = pathinfo($source->name, PATHINFO_FILENAME);
+ $orig_name_extension = pathinfo($source->name, PATHINFO_EXTENSION);
+ $orig_slug = $source->slug;
+ for ($i = 0; $i < 5; $i++) {
+ try {
+ $source->save();
+ if ($orig_name != $source->name) {
+ switch ($source->type) {
+ case "album":
+ message::info(
+ t("Album %old_name renamed to %new_name to avoid a conflict",
+ array("old_name" => $orig_name, "new_name" => $source->name)));
+ break;
+
+ case "photo":
+ message::info(
+ t("Photo %old_name renamed to %new_name to avoid a conflict",
+ array("old_name" => $orig_name, "new_name" => $source->name)));
+ break;
+
+ case "movie":
+ message::info(
+ t("Movie %old_name renamed to %new_name to avoid a conflict",
+ array("old_name" => $orig_name, "new_name" => $source->name)));
+ break;
+ }
+ }
+ break;
+ } catch (ORM_Validation_Exception $e) {
+ $rand = rand(10, 99);
+ $errors = $e->validation->errors();
+ if (isset($errors["name"])) {
+ $source->name = $orig_name_filename . "-{$rand}." . $orig_name_extension;
+ unset($errors["name"]);
+ }
+ if (isset($errors["slug"])) {
+ $source->slug = $orig_slug . "-{$rand}";
+ unset($errors["slug"]);
+ }
+
+ if ($errors) {
+ // There were other validation issues-- we don't know how to handle those
+ throw $e;
+ }
+ }
+ }
// If the target has no cover item, make this it.
if ($target->album_cover_item_id == null) {
diff --git a/modules/gallery/tests/Item_Helper_Test.php b/modules/gallery/tests/Item_Helper_Test.php
index d6817ef9..50587702 100644
--- a/modules/gallery/tests/Item_Helper_Test.php
+++ b/modules/gallery/tests/Item_Helper_Test.php
@@ -19,6 +19,10 @@
*/
class Item_Helper_Test extends Gallery_Unit_Test_Case {
+ public function setup() {
+ identity::set_active_user(identity::admin_user());
+ }
+
public function viewable_test() {
$album = test::random_album();
$item = test::random_photo($album);
@@ -44,7 +48,6 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
}
public function move_test() {
- identity::set_active_user(identity::admin_user());
$photo = test::random_photo(item::root());
$dst_album = test::random_album();
@@ -54,8 +57,6 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
public function move_updates_album_covers_test() {
- identity::set_active_user(identity::admin_user());
-
// 2 photos in the source album
$src_album = test::random_album();
$photo1 = test::random_photo($src_album);
@@ -78,8 +79,6 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
}
public function move_leaves_empty_album_with_no_album_cover_test() {
- identity::set_active_user(identity::admin_user());
-
$src_album = test::random_album();
$photo = test::random_photo($src_album);
@@ -89,4 +88,23 @@ class Item_Helper_Test extends Gallery_Unit_Test_Case {
$this->assert_false($src_album->album_cover_item_id);
}
+ public function move_conflicts_result_in_a_rename_test() {
+ $rand = rand();
+ $photo1 = test::random_photo_unsaved(item::root());
+ $photo1->name = "{$rand}.jpg";
+ $photo1->slug = (string)$rand;
+ $photo1->save();
+
+ $src_album = test::random_album();
+ $photo2 = test::random_photo_unsaved($src_album);
+ $photo2->name = "{$rand}.jpg";
+ $photo2->slug = (string)$rand;
+ $photo2->save();
+
+ item::move($photo2, item::root());
+
+ $this->assert_same(item::root()->id, $photo2->parent_id);
+ $this->assert_not_same("{$rand}.jpg", $photo2->name);
+ $this->assert_not_same($rand, $photo2->slug);
+ }
}
--
cgit v1.2.3
From 92c2dd61ffa2140ec484ede0b75bb10b35229e63 Mon Sep 17 00:00:00 2001
From: Chad Kieffer
Date: Tue, 9 Feb 2010 21:57:04 -0700
Subject: Formated upgrader for RTL languages. Closes ticket #883
---
modules/gallery/css/upgrader.css | 39 ++++++++++++++++++++++++++++-----
modules/gallery/views/upgrader.html.php | 4 ++--
2 files changed, 36 insertions(+), 7 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/css/upgrader.css b/modules/gallery/css/upgrader.css
index 73da0ff4..2b3b5afd 100644
--- a/modules/gallery/css/upgrader.css
+++ b/modules/gallery/css/upgrader.css
@@ -26,6 +26,12 @@ div#footer {
margin: 1em;
}
+table {
+ width: 600px;
+ margin-bottom: 10px;
+}
+
+th.name,
td.name {
text-align: left;
padding-left: 30px;
@@ -53,11 +59,6 @@ tr.upgradeable td.gallery {
color: #00d;
}
-table {
- width: 600px;
- margin-bottom: 10px;
-}
-
p {
font-size: .9em;
}
@@ -125,3 +126,31 @@ pre {
margin: 0px;
padding: 0px;
}
+
+.rtl {
+ direction: rtl;
+}
+
+.rtl th.name,
+.rtl td.name {
+ text-align: right;
+ padding-right: 30px;
+}
+
+
+.rtl li:before {
+ content: "";
+}
+
+.rtl li:after {
+ content: "\00BB \0020";
+}
+
+.rtl ul {
+ margin-right: 0;
+ padding-right: 0;
+}
+
+.rtl div#dialog a.close {
+ float: left;
+}
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index 4490557c..55731440 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -6,7 +6,7 @@
media="screen,print,projection" />
-
+ >

" />
@@ -59,7 +59,7 @@
">
- = t("Module name") ?> |
+ = t("Module name") ?> |
= t("Installed version") ?> |
= t("Available version") ?> |
--
cgit v1.2.3
From 8763e475adc7bb26ed9705c9d61a1db2b20e60c4 Mon Sep 17 00:00:00 2001
From: Bharat Mediratta
Date: Tue, 9 Feb 2010 15:52:38 -0800
Subject: Move diff::compare to be test::diff
---
modules/gallery_unit_test/helpers/diff.php | 26 ----------------------
modules/gallery_unit_test/helpers/test.php | 6 +++++
.../libraries/Gallery_Unit_Test_Case.php | 2 +-
3 files changed, 7 insertions(+), 27 deletions(-)
delete mode 100644 modules/gallery_unit_test/helpers/diff.php
(limited to 'modules')
diff --git a/modules/gallery_unit_test/helpers/diff.php b/modules/gallery_unit_test/helpers/diff.php
deleted file mode 100644
index 7b573732..00000000
--- a/modules/gallery_unit_test/helpers/diff.php
+++ /dev/null
@@ -1,26 +0,0 @@
-save()->reload();
}
+
+ static function diff($a, $b) {
+ fwrite(fopen($a_name = tempnam("/tmp", "test"), "w"), $a);
+ fwrite(fopen($b_name = tempnam("/tmp", "test"), "w"), $b);
+ return `diff $a_name $b_name`;
+ }
}
diff --git a/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php b/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
index 509b4125..545af0fe 100644
--- a/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
+++ b/modules/gallery_unit_test/libraries/Gallery_Unit_Test_Case.php
@@ -24,7 +24,7 @@ class Gallery_Unit_Test_Case extends Unit_Test_Case {
sprintf("Expected (%s) %s but received (%s) %s\n Diff: %s",
gettype($expected), var_export($expected, true),
gettype($actual), var_export($actual, true),
- diff::compare(var_export($expected, true), var_export($actual, true))),
+ test::diff(var_export($expected, true), var_export($actual, true))),
$debug);
}
return $this;
--
cgit v1.2.3
From f6c615c379bb6950dacff34bfda73a616dce6e6b Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Wed, 10 Feb 2010 08:32:30 -0800
Subject: Use the helper ulr:current instead of manually creating the continue
url.
---
modules/gallery/controllers/admin.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php
index 5467e88a..7706e9fc 100644
--- a/modules/gallery/controllers/admin.php
+++ b/modules/gallery/controllers/admin.php
@@ -56,10 +56,8 @@ class Admin_Controller extends Controller {
private static function _prompt_for_reauth($controller_name, $args) {
if (request::method() == "get" && !request::is_ajax()) {
- $url_args = array("admin", $controller_name) + $args;
- $continue_url = join("/", $url_args);
// Avoid anti-phishing protection by passing the url as session variable.
- Session::instance()->set("continue_url", $continue_url);
+ Session::instance()->set("continue_url", url::current(true));
}
url::redirect("reauthenticate");
}
--
cgit v1.2.3
From 17f0a1b10f3df250129188316c14b01f0e3b45f0 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Wed, 10 Feb 2010 08:45:14 -0800
Subject: If the user does not have permission to view the album, photo or
movie, redirect to a logon page to allow the user to login. Pass the target
url as a session variable to allow the user to be redirected where they want
to go if the login was successful. Fixes ticket #1009.
---
modules/gallery/controllers/albums.php | 21 ++++++++++-----------
modules/gallery/controllers/login.php | 3 ++-
modules/gallery/controllers/movies.php | 11 ++++++++++-
modules/gallery/controllers/photos.php | 10 +++++++++-
4 files changed, 31 insertions(+), 14 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index a378f3ee..1d369b95 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -28,20 +28,19 @@ class Albums_Controller extends Items_Controller {
// sure that we're actually receiving an object
Kohana::show_404();
}
- $page_size = module::get_var("gallery", "page_size", 9);
+
if (!access::can("view", $album)) {
- if ($album->id == 1) {
- $view = new Theme_View("page.html", "other", "login");
- $view->page_title = t("Log in to Gallery");
- $view->content = new View("login_ajax.html");
- $view->content->form = auth::get_login_form("login/auth_html");
- print $view;
- return;
- } else {
- access::forbidden();
- }
+ $view = new Theme_View("page.html", "other", "login");
+ $view->page_title = t("Log in to Gallery");
+ $view->content = new View("login_ajax.html");
+ $view->content->form = auth::get_login_form("login/auth_html");
+ // Avoid anti-phishing protection by passing the url as session variable.
+ Session::instance()->set("continue_url", url::current(true));
+ print $view;
+ return;
}
+ $page_size = module::get_var("gallery", "page_size", 9);
$input = Input::instance();
$show = $input->get("show");
diff --git a/modules/gallery/controllers/login.php b/modules/gallery/controllers/login.php
index 5a08b693..093c15da 100644
--- a/modules/gallery/controllers/login.php
+++ b/modules/gallery/controllers/login.php
@@ -44,9 +44,10 @@ class Login_Controller extends Controller {
public function auth_html() {
access::verify_csrf();
+ $continue_url = Session::instance()->get("continue_url", null);
list ($valid, $form) = $this->_auth("login/auth_html");
if ($valid) {
- url::redirect(item::root()->abs_url());
+ url::redirect($continue_url ? $continue_url : item::root()->abs_url());
} else {
$view = new Theme_View("page.html", "other", "login");
$view->page_title = t("Log in to Gallery");
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index b51282b3..9e882ef4 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -24,7 +24,16 @@ class Movies_Controller extends Items_Controller {
// sure that we're actually receiving an object
Kohana::show_404();
}
- access::required("view", $movie);
+
+ if (!access::can("view", $movie)) {
+ $view = new Theme_View("page.html", "other", "login");
+ $view->page_title = t("Log in to Gallery");
+ $view->content = new View("login_ajax.html");
+ $view->content->form = auth::get_login_form("login/auth_html");
+
+ print $view;
+ return;
+ }
$where = array(array("type", "!=", "album"));
$position = $movie->parent()->get_position($movie, $where);
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index b5da3884..8beae207 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -24,7 +24,15 @@ class Photos_Controller extends Items_Controller {
// sure that we're actually receiving an object
Kohana::show_404();
}
- access::required("view", $photo);
+
+ if (!access::can("view", $photo)) {
+ $view = new Theme_View("page.html", "other", "login");
+ $view->page_title = t("Log in to Gallery");
+ $view->content = new View("login_ajax.html");
+ $view->content->form = auth::get_login_form("login/auth_html");
+ print $view;
+ return;
+ }
$where = array(array("type", "!=", "album"));
$position = $photo->parent()->get_position($photo, $where);
--
cgit v1.2.3
From 8ef08d20883d9b9aa0b7560ce3bf6da8a6632149 Mon Sep 17 00:00:00 2001
From: Tim Almdal
Date: Wed, 10 Feb 2010 08:53:39 -0800
Subject: Refactor the code to display the login page if the user does not have
view permission into the common auth::require_login() method.
---
modules/gallery/controllers/albums.php | 8 +-------
modules/gallery/controllers/movies.php | 7 +------
modules/gallery/controllers/photos.php | 6 +-----
modules/gallery/helpers/auth.php | 13 +++++++++++++
4 files changed, 16 insertions(+), 18 deletions(-)
(limited to 'modules')
diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php
index 1d369b95..e1985cfb 100644
--- a/modules/gallery/controllers/albums.php
+++ b/modules/gallery/controllers/albums.php
@@ -30,13 +30,7 @@ class Albums_Controller extends Items_Controller {
}
if (!access::can("view", $album)) {
- $view = new Theme_View("page.html", "other", "login");
- $view->page_title = t("Log in to Gallery");
- $view->content = new View("login_ajax.html");
- $view->content->form = auth::get_login_form("login/auth_html");
- // Avoid anti-phishing protection by passing the url as session variable.
- Session::instance()->set("continue_url", url::current(true));
- print $view;
+ print auth::require_login();
return;
}
diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php
index 9e882ef4..8041066e 100644
--- a/modules/gallery/controllers/movies.php
+++ b/modules/gallery/controllers/movies.php
@@ -26,12 +26,7 @@ class Movies_Controller extends Items_Controller {
}
if (!access::can("view", $movie)) {
- $view = new Theme_View("page.html", "other", "login");
- $view->page_title = t("Log in to Gallery");
- $view->content = new View("login_ajax.html");
- $view->content->form = auth::get_login_form("login/auth_html");
-
- print $view;
+ print auth::require_login();
return;
}
diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php
index 8beae207..778e9ae7 100644
--- a/modules/gallery/controllers/photos.php
+++ b/modules/gallery/controllers/photos.php
@@ -26,11 +26,7 @@ class Photos_Controller extends Items_Controller {
}
if (!access::can("view", $photo)) {
- $view = new Theme_View("page.html", "other", "login");
- $view->page_title = t("Log in to Gallery");
- $view->content = new View("login_ajax.html");
- $view->content->form = auth::get_login_form("login/auth_html");
- print $view;
+ print auth::require_login();
return;
}
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index c3e9e6e9..f5454f85 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -130,4 +130,17 @@ class auth_Core {
$session->set("admin_area_activity_timestamp", time());
return false;
}
+
+ /**
+ * Redirect to the login page.
+ */
+ static function require_login() {
+ $view = new Theme_View("page.html", "other", "login");
+ $view->page_title = t("Log in to Gallery");
+ $view->content = new View("login_ajax.html");
+ $view->content->form = auth::get_login_form("login/auth_html");
+ // Avoid anti-phishing protection by passing the url as session variable.
+ Session::instance()->set("continue_url", url::current(true));
+ return $view;
+ }
}
\ No newline at end of file
--
cgit v1.2.3