comparison modules/user/user.module @ 5:2427550111ae 6.2

Drupal 6.2
author Franck Deroche <webmaster@defr.org>
date Tue, 23 Dec 2008 14:30:08 +0100
parents c1f4ac30525a
children fff6d4c8c043
comparison
equal deleted inserted replaced
4:d94886ac61a0 5:2427550111ae
1 <?php 1 <?php
2 // $Id: user.module,v 1.892 2008/02/03 19:23:01 goba Exp $ 2 // $Id: user.module,v 1.892.2.2 2008/04/09 21:11:51 goba Exp $
3 3
4 /** 4 /**
5 * @file 5 * @file
6 * Enables the user registration and login system. 6 * Enables the user registration and login system.
7 */ 7 */
865 // The user is not blocked and logged in at least once. 865 // The user is not blocked and logged in at least once.
866 ($account->access && $account->status && user_access('access user profiles')) 866 ($account->access && $account->status && user_access('access user profiles'))
867 ); 867 );
868 } 868 }
869 869
870 /**
871 * Access callback for user account editing.
872 */
870 function user_edit_access($account) { 873 function user_edit_access($account) {
871 return (($GLOBALS['user']->uid == $account->uid) || user_access('administer users')) && $account->uid > 0; 874 return (($GLOBALS['user']->uid == $account->uid) || user_access('administer users')) && $account->uid > 0;
872 } 875 }
873 876
874 function user_load_self($arg) { 877 function user_load_self($arg) {
954 'weight' => -10, 957 'weight' => -10,
955 ); 958 );
956 $items['admin/user/user/create'] = array( 959 $items['admin/user/user/create'] = array(
957 'title' => 'Add user', 960 'title' => 'Add user',
958 'page arguments' => array('create'), 961 'page arguments' => array('create'),
962 'access arguments' => array('administer users'),
959 'type' => MENU_LOCAL_TASK, 963 'type' => MENU_LOCAL_TASK,
960 'file' => 'user.admin.inc', 964 'file' => 'user.admin.inc',
961 ); 965 );
962 $items['admin/user/settings'] = array( 966 $items['admin/user/settings'] = array(
963 'title' => 'User settings', 967 'title' => 'User settings',
986 'file' => 'user.admin.inc', 990 'file' => 'user.admin.inc',
987 ); 991 );
988 $items['admin/user/roles/edit'] = array( 992 $items['admin/user/roles/edit'] = array(
989 'title' => 'Edit role', 993 'title' => 'Edit role',
990 'page arguments' => array('user_admin_role'), 994 'page arguments' => array('user_admin_role'),
995 'access arguments' => array('administer permissions'),
991 'type' => MENU_CALLBACK, 996 'type' => MENU_CALLBACK,
992 'file' => 'user.admin.inc', 997 'file' => 'user.admin.inc',
993 ); 998 );
994 $items['admin/user/rules'] = array( 999 $items['admin/user/rules'] = array(
995 'title' => 'Access rules', 1000 'title' => 'Access rules',
1004 'weight' => -10, 1009 'weight' => -10,
1005 ); 1010 );
1006 $items['admin/user/rules/add'] = array( 1011 $items['admin/user/rules/add'] = array(
1007 'title' => 'Add rule', 1012 'title' => 'Add rule',
1008 'page callback' => 'user_admin_access_add', 1013 'page callback' => 'user_admin_access_add',
1014 'access arguments' => array('administer permissions'),
1009 'type' => MENU_LOCAL_TASK, 1015 'type' => MENU_LOCAL_TASK,
1010 'file' => 'user.admin.inc', 1016 'file' => 'user.admin.inc',
1011 ); 1017 );
1012 $items['admin/user/rules/check'] = array( 1018 $items['admin/user/rules/check'] = array(
1013 'title' => 'Check rules', 1019 'title' => 'Check rules',
1014 'page callback' => 'user_admin_access_check', 1020 'page callback' => 'user_admin_access_check',
1021 'access arguments' => array('administer permissions'),
1015 'type' => MENU_LOCAL_TASK, 1022 'type' => MENU_LOCAL_TASK,
1016 'file' => 'user.admin.inc', 1023 'file' => 'user.admin.inc',
1017 ); 1024 );
1018 $items['admin/user/rules/edit'] = array( 1025 $items['admin/user/rules/edit'] = array(
1019 'title' => 'Edit rule', 1026 'title' => 'Edit rule',
1020 'page callback' => 'user_admin_access_edit', 1027 'page callback' => 'user_admin_access_edit',
1028 'access arguments' => array('administer permissions'),
1021 'type' => MENU_CALLBACK, 1029 'type' => MENU_CALLBACK,
1022 'file' => 'user.admin.inc', 1030 'file' => 'user.admin.inc',
1023 ); 1031 );
1024 $items['admin/user/rules/delete'] = array( 1032 $items['admin/user/rules/delete'] = array(
1025 'title' => 'Delete rule', 1033 'title' => 'Delete rule',
1026 'page callback' => 'drupal_get_form', 1034 'page callback' => 'drupal_get_form',
1027 'page arguments' => array('user_admin_access_delete_confirm'), 1035 'page arguments' => array('user_admin_access_delete_confirm'),
1036 'access arguments' => array('administer permissions'),
1028 'type' => MENU_CALLBACK, 1037 'type' => MENU_CALLBACK,
1029 'file' => 'user.admin.inc', 1038 'file' => 'user.admin.inc',
1030 ); 1039 );
1031 1040
1032 $items['logout'] = array( 1041 $items['logout'] = array(
1035 'page callback' => 'user_logout', 1044 'page callback' => 'user_logout',
1036 'weight' => 10, 1045 'weight' => 10,
1037 'file' => 'user.pages.inc', 1046 'file' => 'user.pages.inc',
1038 ); 1047 );
1039 1048
1040 $items['user/%user_current'] = array( 1049 $items['user/%user_uid_optional'] = array(
1041 'title' => 'My account', 1050 'title' => 'My account',
1042 'title callback' => 'user_page_title', 1051 'title callback' => 'user_page_title',
1043 'title arguments' => array(1), 1052 'title arguments' => array(1),
1044 'page callback' => 'user_view', 1053 'page callback' => 'user_view',
1045 'page arguments' => array(1), 1054 'page arguments' => array(1),
1090 $items['user/%user_category/edit/'. $category['name']] = array( 1099 $items['user/%user_category/edit/'. $category['name']] = array(
1091 'title callback' => 'check_plain', 1100 'title callback' => 'check_plain',
1092 'title arguments' => array($category['title']), 1101 'title arguments' => array($category['title']),
1093 'page callback' => 'user_edit', 1102 'page callback' => 'user_edit',
1094 'page arguments' => array(1, 3), 1103 'page arguments' => array(1, 3),
1095 'access callback' => isset($category['access callback']) ? $category['access callback'] : TRUE, 1104 'access callback' => isset($category['access callback']) ? $category['access callback'] : 'user_edit_access',
1096 'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(), 1105 'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(1),
1097 'type' => MENU_LOCAL_TASK, 1106 'type' => MENU_LOCAL_TASK,
1098 'weight' => $category['weight'], 1107 'weight' => $category['weight'],
1099 'load arguments' => array('%map', '%index'), 1108 'load arguments' => array('%map', '%index'),
1100 'tab_parent' => 'user/%/edit', 1109 'tab_parent' => 'user/%/edit',
1101 'file' => 'user.pages.inc', 1110 'file' => 'user.pages.inc',
1108 1117
1109 function user_init() { 1118 function user_init() {
1110 drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module'); 1119 drupal_add_css(drupal_get_path('module', 'user') .'/user.css', 'module');
1111 } 1120 }
1112 1121
1113 function user_current_load($arg) { 1122 function user_uid_optional_load($arg) {
1114 return user_load($arg ? $arg : $GLOBALS['user']->uid); 1123 return user_load(isset($arg) ? $arg : $GLOBALS['user']->uid);
1115 } 1124 }
1116 1125
1117 /** 1126 /**
1118 * Return a user object after checking if any profile category in the path exists. 1127 * Return a user object after checking if any profile category in the path exists.
1119 */ 1128 */
1154 } 1163 }
1155 1164
1156 /** 1165 /**
1157 * Returns the user id of the currently logged in user. 1166 * Returns the user id of the currently logged in user.
1158 */ 1167 */
1159 function user_current_to_arg($arg) { 1168 function user_uid_optional_to_arg($arg) {
1160 // Give back the current user uid when called from eg. tracker, aka. 1169 // Give back the current user uid when called from eg. tracker, aka.
1161 // with an empty arg. Also use the current user uid when called from 1170 // with an empty arg. Also use the current user uid when called from
1162 // the menu with a % for the current account link. 1171 // the menu with a % for the current account link.
1163 return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg; 1172 return empty($arg) || $arg == '%' ? $GLOBALS['user']->uid : $arg;
1164 } 1173 }
1222 /** 1231 /**
1223 * Form builder; the main user login form. 1232 * Form builder; the main user login form.
1224 * 1233 *
1225 * @ingroup forms 1234 * @ingroup forms
1226 */ 1235 */
1227 function user_login(&$form_state, $msg = '') { 1236 function user_login(&$form_state) {
1228 global $user; 1237 global $user;
1229 1238
1230 // If we are already logged on, go to the user page instead. 1239 // If we are already logged on, go to the user page instead.
1231 if ($user->uid) { 1240 if ($user->uid) {
1232 drupal_goto('user/'. $user->uid); 1241 drupal_goto('user/'. $user->uid);
1233 } 1242 }
1234 1243
1235 // Display login form: 1244 // Display login form:
1236 if ($msg) {
1237 $form['message'] = array('#value' => '<p>'. check_plain($msg) .'</p>');
1238 }
1239 $form['name'] = array('#type' => 'textfield', 1245 $form['name'] = array('#type' => 'textfield',
1240 '#title' => t('Username'), 1246 '#title' => t('Username'),
1241 '#size' => 60, 1247 '#size' => 60,
1242 '#maxlength' => USERNAME_MAX_LENGTH, 1248 '#maxlength' => USERNAME_MAX_LENGTH,
1243 '#required' => TRUE, 1249 '#required' => TRUE,