summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/comment/js/comment.js2
-rw-r--r--modules/comment/views/comments.html.php3
-rw-r--r--modules/gallery/controllers/admin.php21
-rw-r--r--modules/gallery/helpers/gallery_theme.php17
-rw-r--r--modules/gallery/views/user_profile.html.php2
-rw-r--r--modules/rest/helpers/rest.php20
6 files changed, 46 insertions, 19 deletions
diff --git a/modules/comment/js/comment.js b/modules/comment/js/comment.js
index bb204b78..3c8097c6 100644
--- a/modules/comment/js/comment.js
+++ b/modules/comment/js/comment.js
@@ -29,7 +29,7 @@ function ajaxify_comment_form() {
dataType: "json",
success: function(data) {
if (data.result == "success") {
- $("#g-comments #g-comment-detail ul").append(data.view);
+ $("#g-comments #g-comment-detail ul").append(data.view);
$("#g-comments #g-comment-detail ul li:last").effect("highlight", {color: "#cfc"}, 8000);
$("#g-comment-form").hide(2000).remove();
$("#g-no-comments-yet").hide(2000);
diff --git a/modules/comment/views/comments.html.php b/modules/comment/views/comments.html.php
index 0ed07c22..58ff1765 100644
--- a/modules/comment/views/comments.html.php
+++ b/modules/comment/views/comments.html.php
@@ -10,7 +10,9 @@
<?= t("No comments yet. Be the first to <a %attrs>comment</a>!",
array("attrs" => html::mark_clean("id= \"g-no-comments\" href=\"" . url::site("form/add/comments/{$item->id}") . "\" class=\"showCommentForm\""))) ?>
</p>
+<ul>&nbsp;</ul>
<? endif ?>
+<? if ($comments->count()): ?>
<ul>
<? foreach ($comments as $comment): ?>
<li id="g-comment-<?= $comment->id ?>">
@@ -39,4 +41,5 @@
</li>
<? endforeach ?>
</ul>
+<? endif ?>
</div>
diff --git a/modules/gallery/controllers/admin.php b/modules/gallery/controllers/admin.php
index 7706e9fc..838c2b50 100644
--- a/modules/gallery/controllers/admin.php
+++ b/modules/gallery/controllers/admin.php
@@ -29,6 +29,9 @@ class Admin_Controller extends Controller {
}
public function __call($controller_name, $args) {
+ if (Input::instance()->get("reauth_check")) {
+ return self::_reauth_check();
+ }
if (auth::must_reauth_for_admin_area()) {
return self::_prompt_for_reauth($controller_name, $args);
}
@@ -54,6 +57,24 @@ class Admin_Controller extends Controller {
call_user_func_array(array(new $controller_name, $method), $args);
}
+ private static function _reauth_check() {
+ $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");
+
+ $time_remaining = max($last_active_auth, $last_admin_area_activity) +
+ $admin_area_timeout - time();
+
+ $result = new stdClass();
+ $result->result = "success";
+ if ($time_remaining < 30) {
+ $result->location = url::abs_site("");
+ }
+
+ print json_encode($result);
+ }
+
private static function _prompt_for_reauth($controller_name, $args) {
if (request::method() == "get" && !request::is_ajax()) {
// Avoid anti-phishing protection by passing the url as session variable.
diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php
index 9ffeb911..ec650e1c 100644
--- a/modules/gallery/helpers/gallery_theme.php
+++ b/modules/gallery/helpers/gallery_theme.php
@@ -92,13 +92,18 @@ class gallery_theme_Core {
}
// 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 = '<script type="text/javascript">
- var page_loaded_timestamp = new Date();
- setInterval("if (new Date() - page_loaded_timestamp > ' . $admin_area_timeout .
- ') document.location = \'' . $redirect_url . '\';", 60 * 1000);
- </script>';
+ var adminReauthCheck = function() {
+ $.ajax({url: "' . url::site("admin?reauth_check=1") . '",
+ dataType: "json",
+ success: function(data){
+ if ("location" in data) {
+ document.location = data.location;
+ }
+ }});
+ };
+ setInterval("adminReauthCheck();", 60 * 1000);
+ </script>';
print $admin_session_redirect_check;
if ($session->get("l10n_mode", false)) {
diff --git a/modules/gallery/views/user_profile.html.php b/modules/gallery/views/user_profile.html.php
index 1c3e4ea2..1c346c26 100644
--- a/modules/gallery/views/user_profile.html.php
+++ b/modules/gallery/views/user_profile.html.php
@@ -22,7 +22,7 @@
padding: 0;
}
</style>
-<script>
+<script type="text/javascript">
$(document).ready(function() {
$("#g-profile-return").click(function(event) {
history.go(-1);
diff --git a/modules/rest/helpers/rest.php b/modules/rest/helpers/rest.php
index a61aba2f..3c53784d 100644
--- a/modules/rest/helpers/rest.php
+++ b/modules/rest/helpers/rest.php
@@ -21,17 +21,15 @@ class rest_Core {
static function reply($data=array()) {
Session::instance()->abort_save();
- if ($data) {
- if (Input::instance()->get("output") == "html") {
- header("Content-type: text/html");
- $html = preg_replace(
- "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'<a href=\"\\1\" >\\1</a>'",
- var_export($data, 1));
- print "<pre>$html</pre>";
- } else {
- header("Content-type: application/json");
- print json_encode($data);
- }
+ if (Input::instance()->get("output") == "html") {
+ header("Content-type: text/html");
+ $html = preg_replace(
+ "#([\w]+?://[\w]+[^ \'\"\n\r\t<]*)#ise", "'<a href=\"\\1\" >\\1</a>'",
+ var_export(!empty($data) ? $data : t("Empty response"), 1));
+ print "<pre>$html</pre>";
+ } else {
+ header("Content-type: application/json");
+ print json_encode($data);
}
}