summaryrefslogtreecommitdiff
path: root/modules/user
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user')
-rw-r--r--modules/user/config/identity.php2
-rw-r--r--modules/user/controllers/admin_users.php30
-rw-r--r--modules/user/controllers/password.php4
-rw-r--r--modules/user/controllers/users.php2
-rw-r--r--modules/user/css/user.css1
-rw-r--r--modules/user/helpers/group.php2
-rw-r--r--modules/user/helpers/user.php2
-rw-r--r--modules/user/helpers/user_event.php2
-rw-r--r--modules/user/helpers/user_installer.php2
-rw-r--r--modules/user/helpers/user_theme.php10
-rw-r--r--modules/user/libraries/drivers/IdentityProvider/Gallery.php2
-rw-r--r--modules/user/models/group.php10
-rw-r--r--modules/user/models/user.php10
-rw-r--r--modules/user/tests/No_Direct_ORM_Access_Test.php2
-rw-r--r--modules/user/tests/User_Groups_Test.php2
-rw-r--r--modules/user/tests/User_Installer_Test.php2
-rw-r--r--modules/user/views/admin_users.html.php5
17 files changed, 67 insertions, 23 deletions
diff --git a/modules/user/config/identity.php b/modules/user/config/identity.php
index 36ebc038..718c0300 100644
--- a/modules/user/config/identity.php
+++ b/modules/user/config/identity.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/controllers/admin_users.php b/modules/user/controllers/admin_users.php
index 23032ab3..a3633b52 100644
--- a/modules/user/controllers/admin_users.php
+++ b/modules/user/controllers/admin_users.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,8 +22,34 @@ class Admin_Users_Controller extends Admin_Controller {
$view = new Admin_View("admin.html");
$view->page_title = t("Users and groups");
$view->content = new View("admin_users.html");
- $view->content->users = ORM::factory("user")->order_by("name", "ASC")->find_all();
+
+ // @todo: add this as a config option
+ $page_size = module::get_var("user", "page_size", 10);
+ $page = Input::instance()->get("page", "1");
+ $builder = db::build();
+ $user_count = $builder->from("users")->count_records();
+
+ $view->content->pager = new Pagination();
+ $view->content->pager->initialize(
+ array("query_string" => "page",
+ "total_items" => $user_count,
+ "items_per_page" => $page_size,
+ "style" => "classic"));
+
+ // Make sure that the page references a valid offset
+ if ($page < 1) {
+ url::redirect(url::merge(array("page" => 1)));
+ } else if ($page > $view->content->pager->total_pages) {
+ url::redirect(url::merge(array("page" => $view->content->pager->total_pages)));
+ }
+
+ // Join our users against the items table so that we can get a count of their items
+ // in the same query.
+ $view->content->users = ORM::factory("user")
+ ->order_by("users.name", "ASC")
+ ->find_all($page_size, $view->content->pager->sql_offset);
$view->content->groups = ORM::factory("group")->order_by("name", "ASC")->find_all();
+
print $view;
}
diff --git a/modules/user/controllers/password.php b/modules/user/controllers/password.php
index 2e5eac5f..4e93d5ce 100644
--- a/modules/user/controllers/password.php
+++ b/modules/user/controllers/password.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -51,7 +51,7 @@ class Password_Controller extends Controller {
$user_name = $form->reset->inputs["name"]->value;
$user = user::lookup_by_name($user_name);
if ($user && !empty($user->email)) {
- $user->hash = md5(uniqid(mt_rand(), true));
+ $user->hash = random::hash();
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key=$user->hash");
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 6bb4967f..3e0e0e54 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/css/user.css b/modules/user/css/user.css
index 084eac31..93e3d02e 100644
--- a/modules/user/css/user.css
+++ b/modules/user/css/user.css
@@ -12,6 +12,7 @@
#g-user-admin {
width: auto;
+ margin-bottom: 4em;
}
#g-group-admin {
diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php
index 88bfac35..801387d8 100644
--- a/modules/user/helpers/group.php
+++ b/modules/user/helpers/group.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php
index be50d6d1..49eec360 100644
--- a/modules/user/helpers/user.php
+++ b/modules/user/helpers/user.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/helpers/user_event.php b/modules/user/helpers/user_event.php
index 3b6ddc66..9913e52d 100644
--- a/modules/user/helpers/user_event.php
+++ b/modules/user/helpers/user_event.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php
index afa0bd16..b889af49 100644
--- a/modules/user/helpers/user_installer.php
+++ b/modules/user/helpers/user_installer.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/helpers/user_theme.php b/modules/user/helpers/user_theme.php
index 5a7161ed..e2479bc3 100644
--- a/modules/user/helpers/user_theme.php
+++ b/modules/user/helpers/user_theme.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,12 +19,12 @@
*/
class user_theme_Core {
static function head($theme) {
- $theme->css("user.css");
- $theme->script("password_strength.js");
+ return $theme->css("user.css")
+ . $theme->script("password_strength.js");
}
static function admin_head($theme) {
- $theme->css("user.css");
- $theme->script("password_strength.js");
+ return $theme->css("user.css")
+ . $theme->script("password_strength.js");
}
} \ No newline at end of file
diff --git a/modules/user/libraries/drivers/IdentityProvider/Gallery.php b/modules/user/libraries/drivers/IdentityProvider/Gallery.php
index 73ac9bd0..8cba3c82 100644
--- a/modules/user/libraries/drivers/IdentityProvider/Gallery.php
+++ b/modules/user/libraries/drivers/IdentityProvider/Gallery.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/models/group.php b/modules/user/models/group.php
index 17d9320b..4409dcb8 100644
--- a/modules/user/models/group.php
+++ b/modules/user/models/group.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
*/
class Group_Model_Core extends ORM implements Group_Definition {
protected $has_and_belongs_to_many = array("users");
+ protected $users_cache = null;
/**
* @see ORM::delete()
@@ -28,10 +29,14 @@ class Group_Model_Core extends ORM implements Group_Definition {
module::event("group_before_delete", $this);
parent::delete($id);
module::event("group_deleted", $old);
+ $this->users_cache = null;
}
public function users() {
- return $this->users->find_all();
+ if (!$this->users_cache) {
+ $this->users_cache = $this->users->find_all()->as_array();
+ }
+ return $this->users_cache;
}
/**
@@ -60,6 +65,7 @@ class Group_Model_Core extends ORM implements Group_Definition {
module::event("group_updated", $original, $this);
}
+ $this->users_cache = null;
return $this;
}
diff --git a/modules/user/models/user.php b/modules/user/models/user.php
index 55bb3d6a..145738ca 100644
--- a/modules/user/models/user.php
+++ b/modules/user/models/user.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
class User_Model_Core extends ORM implements User_Definition {
protected $has_and_belongs_to_many = array("groups");
protected $password_length = null;
+ protected $groups_cache = null;
public function __set($column, $value) {
switch ($column) {
@@ -43,6 +44,7 @@ class User_Model_Core extends ORM implements User_Definition {
module::event("user_before_delete", $this);
parent::delete($id);
module::event("user_deleted", $old);
+ $this->groups_cache = null;
}
/**
@@ -56,7 +58,10 @@ class User_Model_Core extends ORM implements User_Definition {
}
public function groups() {
- return $this->groups->find_all();
+ if (!$this->groups_cache) {
+ $this->groups_cache = $this->groups->find_all()->as_array();
+ }
+ return $this->groups_cache;
}
/**
@@ -108,6 +113,7 @@ class User_Model_Core extends ORM implements User_Definition {
module::event("user_updated", $original, $this);
}
+ $this->groups_cache = null;
return $this;
}
diff --git a/modules/user/tests/No_Direct_ORM_Access_Test.php b/modules/user/tests/No_Direct_ORM_Access_Test.php
index 0e5aa263..f696d194 100644
--- a/modules/user/tests/No_Direct_ORM_Access_Test.php
+++ b/modules/user/tests/No_Direct_ORM_Access_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/tests/User_Groups_Test.php b/modules/user/tests/User_Groups_Test.php
index c3e90718..e58df209 100644
--- a/modules/user/tests/User_Groups_Test.php
+++ b/modules/user/tests/User_Groups_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/tests/User_Installer_Test.php b/modules/user/tests/User_Installer_Test.php
index 98e5edff..de86f8ea 100644
--- a/modules/user/tests/User_Installer_Test.php
+++ b/modules/user/tests/User_Installer_Test.php
@@ -1,7 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2010 Bharat Mediratta
+ * Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/modules/user/views/admin_users.html.php b/modules/user/views/admin_users.html.php
index f067cae8..a7bd6b27 100644
--- a/modules/user/views/admin_users.html.php
+++ b/modules/user/views/admin_users.html.php
@@ -108,6 +108,11 @@
</tr>
<? endforeach ?>
</table>
+
+ <div class="g-paginator">
+ <?= $pager ?>
+ </div>
+
</div>
</div>