summaryrefslogtreecommitdiff
path: root/modules/user/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-01-14 04:12:02 +0000
committerBharat Mediratta <bharat@menalto.com>2009-01-14 04:12:02 +0000
commitf3ba69c1d67c425ffa180d082a373e5cce0c86ce (patch)
tree5ecbbe0ba96a94e3f4aadd26042c8ad1a32ef1bc /modules/user/helpers
parent02af2d8b7639fdc18fba3d69a4ca0a3f5c92b948 (diff)
Make sure that helper functions are all static. Add new
File_Structure_Test to make sure we don't regress. According to the PHP docs, the "public" keyword is implied on static functions, so remove it. Also, require private static functions to start with an _. http://php.net/manual/en/language.oop5.visibility.php
Diffstat (limited to 'modules/user/helpers')
-rw-r--r--modules/user/helpers/group.php6
-rw-r--r--modules/user/helpers/user.php30
-rw-r--r--modules/user/helpers/user_block.php4
-rw-r--r--modules/user/helpers/user_event.php2
-rw-r--r--modules/user/helpers/user_installer.php4
-rw-r--r--modules/user/helpers/user_menu.php2
6 files changed, 24 insertions, 24 deletions
diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php
index 4ec841dc..682ef5ef 100644
--- a/modules/user/helpers/group.php
+++ b/modules/user/helpers/group.php
@@ -61,7 +61,7 @@ class group_Core {
return model_cache::get("group", 2);
}
- public static function get_edit_form_admin($group) {
+ static function get_edit_form_admin($group) {
$form = new Forge("admin/groups/edit/$group->id");
$form_group = $form->group("edit_group")->label(t("Edit Group"));
$form_group->input("name")->label(t("Name"))->id("gName")->value($group->name);
@@ -72,7 +72,7 @@ class group_Core {
return $form;
}
- public static function get_add_form_admin() {
+ static function get_add_form_admin() {
$form = new Forge("admin/groups/add");
$form_group = $form->group("add_group")->label(t("Add Group"));
$form_group->input("name")->label(t("Name"))->id("gName");
@@ -84,7 +84,7 @@ class group_Core {
return $form;
}
- public static function get_delete_form_admin($group) {
+ static function get_delete_form_admin($group) {
$form = new Forge("admin/groups/delete/$group->id", "", "post");
$form_group = $form->group("delete_group")->label(
t("Are you sure you want to delete group {{group_name}}?", array("group_name" => $group->name)));
diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php
index 36bcf2e5..c1e1abba 100644
--- a/modules/user/helpers/user.php
+++ b/modules/user/helpers/user.php
@@ -24,7 +24,7 @@
* Note: by design, this class does not do any permission checking.
*/
class user_Core {
- public static function get_edit_form($user, $action = NULL) {
+ static function get_edit_form($user, $action = NULL) {
$form = new Forge("users/$user->id?_method=put", "", "post", array("id" => "gUserForm"));
$group = $form->group("edit_user")->label(t("Edit User"));
$group->input("name")->label(t("Name"))->id("gName")->value($user->name);
@@ -37,7 +37,7 @@ class user_Core {
return $form;
}
- public static function get_edit_form_admin($user) {
+ static function get_edit_form_admin($user) {
$form = new Forge("admin/users/edit/$user->id");
$group = $form->group("edit_user")->label(t("Edit User"));
$group->input("name")->label(t("Name"))->id("gName")->value($user->name);
@@ -52,7 +52,7 @@ class user_Core {
return $form;
}
- public static function get_add_form_admin() {
+ static function get_add_form_admin() {
$form = new Forge("admin/users/add");
$group = $form->group("add_user")->label(t("Add User"));
$group->input("name")->label(t("Name"))->id("gName");
@@ -68,7 +68,7 @@ class user_Core {
return $form;
}
- public static function get_delete_form_admin($user) {
+ static function get_delete_form_admin($user) {
$form = new Forge("admin/users/delete/$user->id", "", "post");
$group = $form->group("delete_user")->label(
t("Are you sure you want to delete user {{name}}?", array("name" => $user->name)));
@@ -79,7 +79,7 @@ class user_Core {
/**
* Make sure that we have a session and group_ids cached in the session.
*/
- public static function load_user() {
+ static function load_user() {
// This is one of the first session operations that we'll do, so it may fail if there's no
// install yet. Try to handle this situation gracefully expecting that the scaffolding will
// Do The Right Thing.
@@ -109,7 +109,7 @@ class user_Core {
*
* @return array
*/
- public static function group_ids() {
+ static function group_ids() {
return Session::instance()->get("group_ids", array(1));
}
@@ -118,7 +118,7 @@ class user_Core {
*
* @return User_Model
*/
- public static function active() {
+ static function active() {
return Session::instance()->get("user", self::guest());
}
@@ -129,7 +129,7 @@ class user_Core {
*
* @return User_Model
*/
- public static function guest() {
+ static function guest() {
return model_cache::get("user", 1);
}
@@ -138,7 +138,7 @@ class user_Core {
*
* @return User_Model
*/
- public static function set_active($user) {
+ static function set_active($user) {
$session = Session::instance();
$session->set("user", $user);
$session->delete("group_ids");
@@ -153,7 +153,7 @@ class user_Core {
* @param string $password
* @return User_Model
*/
- public static function create($name, $full_name, $password) {
+ static function create($name, $full_name, $password) {
$user = ORM::factory("user")->where("name", $name)->find();
if ($user->loaded) {
throw new Exception("@todo USER_ALREADY_EXISTS $name");
@@ -179,7 +179,7 @@ class user_Core {
* @param string $password a plaintext password
* @return boolean true if the password is correct
*/
- public static function is_correct_password($user, $password) {
+ static function is_correct_password($user, $password) {
$valid = $user->password;
$salt = substr($valid, 0, 4);
@@ -211,7 +211,7 @@ class user_Core {
* @param string $password a plaintext password
* @return string hashed password
*/
- public static function hash_password($password) {
+ static function hash_password($password) {
return user::_md5Salt($password);
}
@@ -219,7 +219,7 @@ class user_Core {
* Log in as a given user.
* @param object $user the user object.
*/
- public static function login($user) {
+ static function login($user) {
$user->login_count += 1;
$user->last_login = time();
$user->save();
@@ -232,7 +232,7 @@ class user_Core {
* Log out the active user and destroy the session.
* @param object $user the user object.
*/
- public static function logout() {
+ static function logout() {
$user = user::active();
if (!$user->guest) {
try {
@@ -249,7 +249,7 @@ class user_Core {
* @param integer $id the user id
* @return User_Model the user object, or null if the id was invalid.
*/
- public static function lookup($id) {
+ static function lookup($id) {
$user = model_cache::get("user", $id);
if ($user->loaded) {
return $user;
diff --git a/modules/user/helpers/user_block.php b/modules/user/helpers/user_block.php
index 5e406fef..bb9e567f 100644
--- a/modules/user/helpers/user_block.php
+++ b/modules/user/helpers/user_block.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class user_block_Core {
- public static function head($theme) {
+ static function head($theme) {
// @todo: move this into the theme
$user = user::active();
if (!user::active()->guest) {
@@ -27,7 +27,7 @@ class user_block_Core {
}
}
- public static function header_top($theme) {
+ static function header_top($theme) {
$view = new View("login.html");
$view->user = user::active();
return $view->render();
diff --git a/modules/user/helpers/user_event.php b/modules/user/helpers/user_event.php
index 2d1ce171..21848e2e 100644
--- a/modules/user/helpers/user_event.php
+++ b/modules/user/helpers/user_event.php
@@ -21,7 +21,7 @@ class user_event_Core {
/**
* Initialization.
*/
- public static function gallery_ready() {
+ static function gallery_ready() {
user::load_user();
}
}
diff --git a/modules/user/helpers/user_installer.php b/modules/user/helpers/user_installer.php
index 1cbb2502..a9b605dc 100644
--- a/modules/user/helpers/user_installer.php
+++ b/modules/user/helpers/user_installer.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class user_installer {
- public static function install() {
+ static function install() {
$db = Database::instance();
$version = module::get_version("user");
@@ -87,7 +87,7 @@ class user_installer {
}
}
- public static function uninstall() {
+ static function uninstall() {
// Delete all users and groups so that we give other modules an opportunity to clean up
foreach (ORM::factory("user")->find_all() as $user) {
$user->delete();
diff --git a/modules/user/helpers/user_menu.php b/modules/user/helpers/user_menu.php
index bdbe411b..5f845804 100644
--- a/modules/user/helpers/user_menu.php
+++ b/modules/user/helpers/user_menu.php
@@ -18,7 +18,7 @@
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class user_menu_Core {
- public static function admin($menu, $theme) {
+ static function admin($menu, $theme) {
$menu->get("users_groups_menu")
->append(Menu::factory("link")
->id("list_users")