summaryrefslogtreecommitdiff
path: root/modules/user/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user/controllers')
-rw-r--r--modules/user/controllers/admin_users.php16
-rw-r--r--modules/user/controllers/password.php12
-rw-r--r--modules/user/controllers/users.php9
3 files changed, 26 insertions, 11 deletions
diff --git a/modules/user/controllers/admin_users.php b/modules/user/controllers/admin_users.php
index 4d80521e..ac5dc33c 100644
--- a/modules/user/controllers/admin_users.php
+++ b/modules/user/controllers/admin_users.php
@@ -63,7 +63,9 @@ class Admin_Users_Controller extends Admin_Controller {
}
public function add_user_form() {
- print $this->_get_user_add_form_admin();
+ $v = new View("user_form.html");
+ $v->form = $this->_get_user_add_form_admin();
+ print $v;
}
public function delete_user($id) {
@@ -156,12 +158,13 @@ class Admin_Users_Controller extends Admin_Controller {
kohana::show_404();
}
- $form = $this->_get_user_edit_form_admin($user);
+ $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) {
- $form->edit_user->admin->disabled(1);
+ $v->form->edit_user->admin->disabled(1);
}
- print $form;
+ print $v;
}
public function add_user_to_group($user_id, $group_id) {
@@ -308,7 +311,6 @@ class Admin_Users_Controller extends Admin_Controller {
$group->input("url")->label(t("URL"))->id("g-url")->value($user->url);
$group->checkbox("admin")->label(t("Admin"))->id("g-admin")->checked($user->admin);
$form->add_rules_from($user);
- $form->edit_user->password->rules("-required");
module::event("user_edit_form_admin", $user, $form);
$group->submit("")->value(t("Modify User"));
@@ -330,6 +332,10 @@ class Admin_Users_Controller extends Admin_Controller {
$group->checkbox("admin")->label(t("Admin"))->id("g-admin");
$form->add_rules_from(ORM::factory("user"));
+ $minimum_length = module::get_var("user", "mininum_password_length", 5);
+ $form->add_user->password
+ ->rules($minimum_length ? "length[$minimum_length, 40]" : "length[40]");
+
module::event("user_add_form_admin", $user, $form);
$group->submit("")->value(t("Add User"));
return $form;
diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php
index 477651bf..5f36b554 100644
--- a/modules/user/controllers/password.php
+++ b/modules/user/controllers/password.php
@@ -101,27 +101,29 @@ class Password_Controller extends Controller {
if (!empty($hash)) {
$hidden->value($hash);
}
- $group->password("password")->label(t("Password"))->id("g-password")
- ->rules("required|length[1,40]");
+ $minimum_length = module::get_var("user", "mininum_password_length", 5);
+ $input_password = $group->password("password")->label(t("Password"))->id("g-password")
+ ->rules($minimum_length ? "required|length[$minimum_length, 40]" : "length[40]");
$group->password("password2")->label(t("Confirm Password"))->id("g-password2")
->matches($group->password);
$group->inputs["password2"]->error_messages(
"mistyped", t("The password and the confirm password must match"));
$group->submit("")->value(t("Update"));
- $template->content = $form;
+ $template->content = new View("user_form.html");
+ $template->content->form = $form;
return $template;
}
private function _change_password() {
$view = $this->_new_password_form();
- if ($view->content->validate()) {
+ if ($view->content->form->validate()) {
$user = user::lookup_by_hash(Input::instance()->post("hash"));
if (empty($user)) {
throw new Exception("@todo FORBIDDEN", 503);
}
- $user->password = $view->content->reset->password->value;
+ $user->password = $view->content->form->reset->password->value;
$user->hash = null;
$user->save();
message::success(t("Password reset successfully"));
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 28164e9c..7bcc74d7 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -63,7 +63,9 @@ class Users_Controller extends Controller {
access::forbidden();
}
- print $this->_get_edit_form($user);
+ $v = new View("user_form.html");
+ $v->form = $this->_get_edit_form($user);
+ print $v;
}
private function _get_edit_form($user) {
@@ -78,6 +80,11 @@ class Users_Controller extends Controller {
$group->input("url")->label(t("URL"))->id("g-url")->value($user->url);
$form->add_rules_from($user);
+ $minimum_length = module::get_var("user", "mininum_password_length", 5);
+ $form->edit_user->password
+ ->rules($minimum_length ? "length[$minimum_length, 40]" : "length[40]");
+
+
module::event("user_edit_form", $user, $form);
$group->submit("")->value(t("Save"));
return $form;