summaryrefslogtreecommitdiff
path: root/modules/user/user.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-01-31 15:49:26 +0000
committerDries Buytaert <dries@buytaert.net>2007-01-31 15:49:26 +0000
commit05a708fb06137758cf7a15a623b4813af2fc005f (patch)
tree6ae6f50edbcb601329805cbbd7c22d11340327e3 /modules/user/user.module
parent4c9fc80fc48608982a731b03655b02e5ccdb6b17 (diff)
downloadbrdo-05a708fb06137758cf7a15a623b4813af2fc005f.tar.gz
brdo-05a708fb06137758cf7a15a623b4813af2fc005f.tar.bz2
- Patch #112715 by chx, webchick, asimmonds, et al: fixing E_ALL notices. Thanks.
Diffstat (limited to 'modules/user/user.module')
-rw-r--r--modules/user/user.module31
1 files changed, 18 insertions, 13 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index d2ed6208d..3bab8cd3a 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -113,7 +113,7 @@ function user_save($account, $array = array(), $category = 'account') {
$user_fields = user_fields();
if ($account->uid) {
user_module_invoke('update', $array, $account, $category);
-
+ $query = '';
$data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid)));
foreach ($array as $key => $value) {
if ($key == 'pass' && !empty($value)) {
@@ -143,7 +143,7 @@ function user_save($account, $array = array(), $category = 'account') {
db_query("UPDATE {users} SET $query WHERE uid = %d", array_merge($v, array($account->uid)));
// Reload user roles if provided
- if (is_array($array['roles'])) {
+ if (isset($array['roles']) && is_array($array['roles'])) {
db_query('DELETE FROM {users_roles} WHERE uid = %d', $account->uid);
foreach (array_keys($array['roles']) as $rid) {
@@ -708,8 +708,8 @@ function user_view_access($account) {
);
}
-function user_edit_access($uid) {
- return ($GLOBALS['user']->uid == $uid) || array('administer users');
+function user_edit_access($account) {
+ return ($GLOBALS['user']->uid == $account->uid) || array('administer users');
}
function user_load_self($arg) {
@@ -909,7 +909,8 @@ function user_menu() {
'type' => MENU_LOCAL_TASK,
);
- if (($categories = _user_categories($account)) && (count($categories) > 1)) {
+ $empty_account = new stdClass();
+ if (($categories = _user_categories($empty_account)) && (count($categories) > 1)) {
foreach ($categories as $key => $category) {
$items['user/%/edit/'. $category['name']] = array(
'title' => $category['title'],
@@ -1479,7 +1480,7 @@ function _user_edit_validate($uid, &$edit) {
function _user_edit_submit($uid, &$edit) {
$user = user_load(array('uid' => $uid));
// Delete picture if requested, and if no replacement picture was given.
- if ($edit['picture_delete']) {
+ if (!empty($edit['picture_delete'])) {
if ($user->picture && file_exists($user->picture)) {
file_delete($user->picture);
}
@@ -1498,7 +1499,8 @@ function user_edit($category = 'account') {
drupal_set_message(t('The account does not exist or has already been deleted.'));
drupal_goto('admin/user/user');
}
- $edit = $_POST['op'] ? $_POST : (array)$account;
+ $op = !empty($_POST['op']) ? $_POST['op'] : '';
+ $edit = $op ? $_POST : (array)$account;
if (arg(2) == 'delete') {
if ($edit['confirm']) {
@@ -1509,7 +1511,7 @@ function user_edit($category = 'account') {
return drupal_get_form('user_confirm_delete', $account->name, $account->uid);
}
}
- else if ($_POST['op'] == t('Delete')) {
+ else if ($op == t('Delete')) {
if ($_REQUEST['destination']) {
$destination = drupal_get_destination();
unset($_REQUEST['destination']);
@@ -1820,7 +1822,7 @@ function user_admin_access() {
while ($rule = db_fetch_object($result)) {
$rows[] = array($rule->status ? t('allow') : t('deny'), $access_types[$rule->type], $rule->mask, l(t('edit'), 'admin/user/rules/edit/'. $rule->aid), l(t('delete'), 'admin/user/rules/delete/'. $rule->aid));
}
- if (count($rows) == 0) {
+ if (empty($rows)) {
$rows[] = array(array('data' => '<em>'. t('There are currently no access rules.') .'</em>', 'colspan' => 5));
}
$output .= theme('table', $header, $rows);
@@ -2068,7 +2070,7 @@ function theme_user_admin_new_role($form) {
$rows[] = array($name, t('locked'), $edit_permissions);
}
}
- $rows[] = array(drupal_render($form['name']), array('data' => drupal_render($form['submit']), colspan => 2));
+ $rows[] = array(drupal_render($form['name']), array('data' => drupal_render($form['submit']), 'colspan' => 2));
$output = drupal_render($form);
$output .= theme('table', $header, $rows);
@@ -2410,14 +2412,15 @@ function user_admin($callback_arg = '') {
switch ($op) {
case 'search':
case t('Search'):
- $output = drupal_get_form('search_form', url('admin/user/search'), $_POST['keys'], 'user') . search_data($_POST['keys'], 'user');
+ $keys = isset($_POST['keys']) ? $_POST['keys'] : NULL;
+ $output = drupal_get_form('search_form', url('admin/user/search'), $keys, 'user') . search_data($keys, 'user');
break;
case t('Create new account'):
case 'create':
$output = drupal_get_form('user_register');
break;
default:
- if ($_POST['accounts'] && $_POST['operation'] == 'delete') {
+ if (!empty($_POST['accounts']) && isset($_POST['operation']) && ($_POST['operation'] == 'delete')) {
$output = drupal_get_form('user_multiple_delete_confirm');
}
else {
@@ -2510,6 +2513,8 @@ function _user_categories($account) {
}
function _user_sort($a, $b) {
+ $a = (array)$a + array('weight' => 0, 'title' => '');
+ $b = (array)$b + array('weight' => 0, 'title' => '');
return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
}
@@ -2677,7 +2682,7 @@ function theme_user_filter_form($form) {
*/
function theme_user_filters($form) {
$output = '<ul class="clear-block">';
- if (sizeof($form['current'])) {
+ if (!empty($form['current'])) {
foreach (element_children($form['current']) as $key) {
$output .= '<li>'. drupal_render($form['current'][$key]) .'</li>';
}