summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/album.php9
-rw-r--r--modules/gallery/helpers/auth.php10
-rw-r--r--modules/gallery/helpers/gallery_event.php12
-rw-r--r--modules/gallery/helpers/gallery_installer.php14
-rw-r--r--modules/gallery/helpers/task.php9
5 files changed, 45 insertions, 9 deletions
diff --git a/modules/gallery/helpers/album.php b/modules/gallery/helpers/album.php
index 389f6e48..15e0c3ca 100644
--- a/modules/gallery/helpers/album.php
+++ b/modules/gallery/helpers/album.php
@@ -36,7 +36,8 @@ class album_Core {
$group->input("name")->label(t("Directory name"))
->error_messages("no_slashes", t("The directory name can't contain the \"/\" character"))
->error_messages("required", t("You must provide a directory name"))
- ->error_messages("length", t("Your directory name is too long"));
+ ->error_messages("length", t("Your directory name is too long"))
+ ->error_messages("conflict", t("There is already a movie, photo or album with this name"));
$group->input("slug")->label(t("Internet Address"))
->error_messages(
"not_url_safe",
@@ -51,7 +52,8 @@ class album_Core {
}
static function get_edit_form($parent) {
- $form = new Forge("albums/update/{$parent->id}", "", "post", array("id" => "g-edit-album-form"));
+ $form = new Forge(
+ "albums/update/{$parent->id}", "", "post", array("id" => "g-edit-album-form"));
$form->hidden("from_id");
$group = $form->group("edit_item")->label(t("Edit Album"));
@@ -61,8 +63,7 @@ class album_Core {
$group->textarea("description")->label(t("Description"))->value($parent->description);
if ($parent->id != 1) {
$group->input("name")->label(t("Directory Name"))->value($parent->name)
- ->error_messages(
- "conflict", t("There is already a movie, photo or album with this name"))
+ ->error_messages("conflict", t("There is already a movie, photo or album with this name"))
->error_messages("no_slashes", t("The directory name can't contain a \"/\""))
->error_messages("no_trailing_period", t("The directory name can't end in \".\""))
->error_messages("required", t("You must provide a directory name"))
diff --git a/modules/gallery/helpers/auth.php b/modules/gallery/helpers/auth.php
index 16f8915a..45561861 100644
--- a/modules/gallery/helpers/auth.php
+++ b/modules/gallery/helpers/auth.php
@@ -78,10 +78,16 @@ class auth_Core {
}
}
+ static function validate_too_many_failed_password_changes($password_input) {
+ if (self::too_many_failed_logins(identity::active_user()->name)) {
+ $password_input->add_error("too_many_failed_password_changes", 1);
+ }
+ }
+
/**
* Record a failed login for this user
*/
- static function record_failed_login($name) {
+ static function record_failed_auth_attempts($name) {
$failed_login = ORM::factory("failed_login")
->where("name", "=", $name)
->find();
@@ -96,7 +102,7 @@ class auth_Core {
/**
* Clear any failed logins for this user
*/
- static function record_successful_login($user) {
+ static function clear_failed_auth_attempts($user) {
db::build()
->delete("failed_logins")
->where("name", "=", $user->name)
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 6479e2c3..7b538c49 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -110,11 +110,19 @@ class gallery_event_Core {
graphics::choose_default_toolkit();
module::clear_var("gallery", "choose_default_tookit");
}
- auth::record_successful_login($user);
+ auth::clear_failed_auth_attempts($user);
}
static function user_login_failed($name) {
- auth::record_failed_login($name);
+ auth::record_failed_auth_attempts($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 item_index_data($item, $data) {
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index bffef8e6..761843b0 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 <a href=\"%url\">Gallery %version</a>");
module::set_var("gallery", "simultaneous_upload_limit", 5);
- module::set_version("gallery", 25);
+ module::set_version("gallery", 26);
}
static function upgrade($version) {
@@ -514,6 +514,18 @@ class gallery_installer {
}
module::set_version("gallery", $version = 25);
}
+
+ if ($version == 25) {
+ db::build()
+ ->update("items")
+ ->set("title", new Database_Expression("`name`"))
+ ->and_open()
+ ->where("title", "IS", null)
+ ->or_where("title", "=", "")
+ ->close()
+ ->execute();
+ module::set_version("gallery", $version = 26);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/helpers/task.php b/modules/gallery/helpers/task.php
index 645850d1..aa0eb94d 100644
--- a/modules/gallery/helpers/task.php
+++ b/modules/gallery/helpers/task.php
@@ -35,6 +35,15 @@ class task_Core {
return $tasks;
}
+ static function start($task_callback, $context=array()) {
+ $tasks = task::get_definitions();
+ $task = task::create($tasks[$task_callback], array());
+
+ $task->log(t("Task %task_name started (task id %task_id)",
+ array("task_name" => $task->name, "task_id" => $task->id)));
+ return $task;
+ }
+
static function create($task_def, $context) {
$task = ORM::factory("task");
$task->callback = $task_def->callback;