diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2007-03-27 05:13:55 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2007-03-27 05:13:55 +0000 |
commit | f7440d4d73ec57219af232c135be3b2567dda45f (patch) | |
tree | a6b7d947eda1c7bfc2197bfb584f7b17143c97a5 /modules | |
parent | f2ca29071fe33603cf22f1603a3e6a61ee9c0814 (diff) | |
download | brdo-f7440d4d73ec57219af232c135be3b2567dda45f.tar.gz brdo-f7440d4d73ec57219af232c135be3b2567dda45f.tar.bz2 |
#130971: Kitchen sink (E_NOTICE compliance / Code style / Bugfix in book toc)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/aggregator/aggregator.module | 13 | ||||
-rw-r--r-- | modules/block/block.module | 10 | ||||
-rw-r--r-- | modules/blog/blog.module | 2 | ||||
-rw-r--r-- | modules/book/book.module | 14 | ||||
-rw-r--r-- | modules/color/color.module | 2 | ||||
-rw-r--r-- | modules/comment/comment.module | 20 | ||||
-rw-r--r-- | modules/contact/contact.module | 22 | ||||
-rw-r--r-- | modules/forum/forum.module | 34 | ||||
-rw-r--r-- | modules/node/content_types.inc | 22 | ||||
-rw-r--r-- | modules/node/node.module | 23 | ||||
-rw-r--r-- | modules/path/path.module | 8 | ||||
-rw-r--r-- | modules/poll/poll.module | 18 | ||||
-rw-r--r-- | modules/profile/profile.module | 11 | ||||
-rw-r--r-- | modules/search/search.module | 17 | ||||
-rw-r--r-- | modules/statistics/statistics.module | 9 | ||||
-rw-r--r-- | modules/system/system.module | 26 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 56 | ||||
-rw-r--r-- | modules/upload/upload.module | 21 | ||||
-rw-r--r-- | modules/user/user.module | 71 |
19 files changed, 266 insertions, 133 deletions
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index 1569db535..230810bd6 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -310,7 +310,7 @@ function aggregator_block($op = 'list', $delta = 0, $edit = array()) { /** * Generate a form to add/edit/delete aggregator categories. */ - function aggregator_form_category($edit = array()) { +function aggregator_form_category($edit = array('title' => '', 'description' => '', 'cid' => NULL)) { $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#default_value' => $edit['title'], @@ -392,13 +392,13 @@ function aggregator_form_category_submit($form_id, $form_values) { * Add/edit/delete aggregator categories. */ function aggregator_save_category($edit) { - if ($edit['cid'] && $edit['title']) { + if (!empty($edit['cid']) && !empty($edit['title'])) { db_query("UPDATE {aggregator_category} SET title = '%s', description = '%s' WHERE cid = %d", $edit['title'], $edit['description'], $edit['cid']); } - else if ($edit['cid']) { + else if (!empty($edit['cid'])) { db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']); } - else if ($edit['title']) { + else if (!empty($edit['title'])) { // A single unique id for bundles and feeds, to use in blocks $next_id = db_next_id('{aggregator_category}_cid'); db_query("INSERT INTO {aggregator_category} (cid, title, description, block) VALUES (%d, '%s', '%s', 5)", $next_id, $edit['title'], $edit['description']); @@ -408,7 +408,7 @@ function aggregator_save_category($edit) { /** * Generate a form to add/edit feed sources. */ -function aggregator_form_feed($edit = array()) { +function aggregator_form_feed($edit = array('refresh' => 900, 'title' => '', 'url' => '', 'fid' => NULL)) { $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); if ($edit['refresh'] == '') { @@ -568,7 +568,7 @@ function aggregator_remove($feed) { while ($item = db_fetch_object($result)) { $items[] = "iid = $item->iid"; } - if ($items) { + if (!empty($items)) { db_query('DELETE FROM {aggregator_category_item} WHERE '. implode(' OR ', $items)); } db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']); @@ -677,6 +677,7 @@ function aggregator_element_data($parser, $data) { // it or its contents will end up in the item array. break; default: + $channel += array($tag => ''); $channel[$tag] .= $data; } } diff --git a/modules/block/block.module b/modules/block/block.module index d0311a206..a8d795e37 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -191,6 +191,10 @@ function _block_rehash() { // Reinsert new set of blocks into table. foreach ($blocks as $block) { + $block += array( + 'visibility' => NULL, + 'throttle' => NULL, + ); db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle, title) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d, '%s')", $block['module'], $block['delta'], $theme_key, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['throttle'], $block['title']); } db_unlock_tables(); @@ -238,7 +242,7 @@ function block_admin_display($theme = NULL) { ); if ($throttle) { - $form[$i]['throttle'] = array('#type' => 'checkbox', '#default_value' => $block['throttle']); + $form[$i]['throttle'] = array('#type' => 'checkbox', '#default_value' => isset($block['throttle']) ? $block['throttle'] : FALSE); } $form[$i]['configure'] = array('#value' => l(t('configure'), 'admin/build/block/configure/'. $block['module'] .'/'. $block['delta'])); if ($block['module'] == 'block') { @@ -567,6 +571,10 @@ function block_box_delete_submit($form_id, $form_values) { * Define the custom block form. */ function block_box_form($edit = array()) { + $edit += array( + 'info' => '', + 'body' => '', + ); $form['info'] = array( '#type' => 'textfield', '#title' => t('Block description'), diff --git a/modules/blog/blog.module b/modules/blog/blog.module index faeceb891..4c9fa1d88 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -133,7 +133,7 @@ function blog_page_user($uid) { $account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1)); - if ($account->uid) { + if (!empty($account->uid)) { drupal_set_title($title = t("@name's blog", array('@name' => $account->name))); if (($account->uid == $user->uid) && user_access('edit own blog')) { diff --git a/modules/book/book.module b/modules/book/book.module index 5d4ca8124..53c353ded 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -196,14 +196,14 @@ function book_submit(&$node) { */ function book_form(&$node) { $type = node_get_types('type', $node); - if ($node->nid && !$node->parent && !user_access('create new books')) { + if (!empty($node->nid) && !$node->parent && !user_access('create new books')) { $form['parent'] = array('#type' => 'value', '#value' => $node->parent); } else { $form['parent'] = array('#type' => 'select', '#title' => t('Parent'), - '#default_value' => ($node->parent ? $node->parent : arg(4)), - '#options' => book_toc($node->nid), + '#default_value' => (isset($node->parent) ? $node->parent : arg(4)), + '#options' => book_toc(isset($node->nid) ? $node->nid : 0), '#weight' => -4, '#description' => user_access('create new books') ? t('The parent section in which to place this page. Note that each page whose parent is <top-level> is an independent, top-level book.') : t('The parent that this page belongs in.'), ); @@ -226,7 +226,7 @@ function book_form(&$node) { if (user_access('administer nodes')) { $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), - '#default_value' => $node->weight, + '#default_value' => isset($node->weight) ? $node->weight : 0, '#delta' => 15, '#weight' => 5, '#description' => t('Pages at a given level are ordered first by weight and then by title.'), @@ -251,13 +251,13 @@ function book_form(&$node) { function book_outline($node) { $form['parent'] = array('#type' => 'select', '#title' => t('Parent'), - '#default_value' => $node->parent, + '#default_value' => isset($node->parent) ? $node->parent : 0, '#options' => book_toc($node->nid), '#description' => t('The parent page in the book.'), ); $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), - '#default_value' => $node->weight, + '#default_value' => isset($node->weight) ? $node->weight : 0, '#delta' => 15, '#description' => t('Pages at a given level are ordered first by weight and then by title.'), ); @@ -266,7 +266,7 @@ function book_outline($node) { '#description' => t('An explanation to help other authors understand your motivations to put this post into the book.'), ); - $form['nid'] = array('#type' => 'value', '#value' => $nid); + $form['nid'] = array('#type' => 'value', '#value' => isset($node->nid) ? $node->nid : 0); if (isset($node->parent)) { $form['update'] = array('#type' => 'submit', '#value' => t('Update book outline'), diff --git a/modules/color/color.module b/modules/color/color.module index 32f618f7e..6bd3801dd 100644 --- a/modules/color/color.module +++ b/modules/color/color.module @@ -145,7 +145,7 @@ function theme_color_scheme_form($form) { $info = $form['info']['#value']; $path = drupal_get_path('theme', $theme) .'/'; drupal_add_css($path . $info['preview_css']); - + $output = ''; // Wrapper $output .= '<div class="color-form clear-block">'; diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 8f060c300..0efe2f6c7 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -384,7 +384,7 @@ function comment_form_alter($form, $form_id) { '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'), ); } - elseif (isset($form['type'])) { + elseif (isset($form['type']) && isset($form['#node'])) { if ($form['type']['#value'] .'_node_form' == $form_id) { $node = $form['#node']; $form['comment_settings'] = array( @@ -1535,7 +1535,23 @@ function comment_form($edit, $title = NULL) { $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => !empty($edit['subject']) ? $edit['subject'] : ''); } - $form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => !empty($edit['comment']) ? $edit['comment'] : $user->signature, '#required' => TRUE); + if (!empty($edit['comment'])) { + $default = $edit['comment']; + } + elseif (isset($user->signature)) { + $default = $user->signature; + } + else { + $default = ''; + } + + $form['comment_filter']['comment'] = array( + '#type' => 'textarea', + '#title' => t('Comment'), + '#rows' => 15, + '#default_value' => $default, + '#required' => TRUE, + ); if (!isset($edit['format'])) { $edit['format'] = FILTER_FORMAT_DEFAULT; } diff --git a/modules/contact/contact.module b/modules/contact/contact.module index e00423d8e..f9d5e7fda 100644 --- a/modules/contact/contact.module +++ b/modules/contact/contact.module @@ -98,7 +98,15 @@ function contact_menu() { function _contact_user_tab_access($account) { global $user; - return $account && (($user->uid != $account->uid && $account->contact) || user_access('administer users')); + if (!isset($account->contact)) { + $account->contact = FALSE; + } + return + $account && + ( + ($user->uid != $account->uid && $account->contact) || + user_access('administer users') + ); } /** @@ -121,7 +129,7 @@ function contact_user($type, &$edit, &$user, $category = NULL) { return $form; } elseif ($type == 'validate') { - return array('contact' => $edit['contact']); + return array('contact' => isset($edit['contact']) ? $edit['contact'] : FALSE); } elseif ($type == 'insert') { $edit['contact'] = variable_get('contact_default_status', 1); @@ -149,6 +157,16 @@ function contact_admin_edit($cid = NULL) { if (arg(3) == "edit" && $cid > 0) { $edit = db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid)); } + else { + $edit = array( + 'category' => '', + 'recipients' => '', + 'reply' => '', + 'weight' => 0, + 'selected' => 0, + 'cid' => NULL, + ); + } $form['category'] = array('#type' => 'textfield', '#title' => t('Category'), '#maxlength' => 255, diff --git a/modules/forum/forum.module b/modules/forum/forum.module index a7dd2b79b..c815d697a 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -210,7 +210,7 @@ function forum_admin_settings() { function forum_form_alter(&$form, $form_id) { // hide critical options from forum vocabulary if ($form_id == 'taxonomy_form_vocabulary') { - if ($form['vid']['#value'] == _forum_get_vid()) { + if (isset($form['vid']) && $form['vid']['#value'] == _forum_get_vid()) { $form['help_forum_vocab'] = array( '#value' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'), '#weight' => -1, @@ -280,14 +280,12 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) { break; } - if ($content) { + if (!empty($content)) { $content .= '<div class="more-link">'. l(t('more'), 'forum', array('title' => t('Read the latest forum topics.'))) .'</div>'; + $block['subject'] = $title; + $block['content'] = $content; + return $block; } - - $block['subject'] = $title; - $block['content'] = $content; - - return $block; } } } @@ -439,6 +437,12 @@ function forum_delete(&$node) { * @param $edit Associative array containing a container term to be added or edited. */ function forum_form_container($edit = array()) { + $edit += array( + 'name' => '', + 'description' => '', + 'tid' => 0, + 'weight' => 0, + ); // Handle a delete operation. $form['name'] = array( '#title' => t('Container name'), @@ -481,7 +485,7 @@ function forum_form_container($edit = array()) { } function forum_form_main($type, $edit = array()) { - if ($_POST['op'] == t('Delete') || $_POST['confirm']) { + if ((isset($_POST['op']) && $_POST['op'] == t('Delete')) || !empty($_POST['confirm'])) { return drupal_get_form('forum_confirm_delete', $edit['tid']); } switch ($type) { @@ -500,6 +504,12 @@ function forum_form_main($type, $edit = array()) { * @param $edit Associative array containing a forum term to be added or edited. */ function forum_form_forum($edit = array()) { + $edit += array( + 'name' => '', + 'description' => '', + 'tid' => NULL, + 'weight' => 0, + ); $form['name'] = array('#type' => 'textfield', '#title' => t('Forum name'), '#default_value' => $edit['name'], @@ -1077,7 +1087,7 @@ function theme_forum_topic_navigation($node) { // get previous and next topic $sql = "SELECT n.nid, n.title, n.sticky, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {term_node} r ON n.nid = r.nid AND r.tid = %d WHERE n.status = 1 AND n.type = 'forum' ORDER BY n.sticky DESC, ". _forum_get_topic_order_sql(variable_get('forum_order', 1)); - $result = db_query(db_rewrite_sql($sql), $node->tid); + $result = db_query(db_rewrite_sql($sql), isset($node->tid) ? $node->tid : 0); $stop = 0; while ($topic = db_fetch_object($result)) { @@ -1097,13 +1107,13 @@ function theme_forum_topic_navigation($node) { } } - if ($prev || $next) { + if (!empty($prev) || !empty($next)) { $output .= '<div class="forum-topic-navigation clear-block">'; - if ($prev) { + if (!empty($prev)) { $output .= l(t('‹ ') . $prev->title, 'node/'. $prev->nid, array('class' => 'topic-previous', 'title' => t('Go to previous forum topic'))); } - if ($prev && $next) { + if (!empty($prev) && !empty($next)) { // Word break (a is an inline element) $output .= ' '; } diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index b026292f6..b3bf3442f 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -20,24 +20,20 @@ function node_overview_types() { if (function_exists($type->module .'_form')) { $name = check_plain($name); $type_url_str = str_replace('_', '-', $type->type); - // Populate the operations field. - $operations = array(); - + $row = array( + l($name, 'admin/content/types/'. $type_url_str), + check_plain($type->type), + check_plain($type->description), + ); // Set the edit column. - $operations[] = array('data' => l(t('edit'), 'admin/content/types/'. $type_url_str)); + $row[] = array('data' => l(t('edit'), 'admin/content/types/'. $type_url_str)); // Set the delete column. if ($type->custom) { - $operations[] = array('data' => l(t('delete'), 'admin/content/types/'. $type_url_str .'/delete')); + $row[] = array('data' => l(t('delete'), 'admin/content/types/'. $type_url_str .'/delete')); } else { - $operations[] = array('data' => ''); - } - - $row = array(array('data' => l($name, 'admin/content/types/'. $type_url_str), 'class' => $class), array('data' => check_plain($type->type), 'class' => $class), array('data' => check_plain($type->description), 'class' => $class)); - foreach ($operations as $operation) { - $operation['class'] = $class; - $row[] = $operation; + $row[] = array('data' => ''); } $rows[] = $row; } @@ -172,7 +168,7 @@ function node_type_form($type = NULL) { ); $form['orig_type'] = array( '#type' => 'value', - '#value' => $type->orig_type, + '#value' => isset($type->orig_type) ? $type->orig_type : '', ); $form['module'] = array( '#type' => 'value', diff --git a/modules/node/node.module b/modules/node/node.module index 3ccec64ab..a7b052014 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -65,7 +65,7 @@ function node_cron() { */ function node_title_list($result, $title = NULL) { while ($node = db_fetch_object($result)) { - $items[] = l($node->title, 'node/'. $node->nid, $node->comment_count ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : ''); + $items[] = l($node->title, 'node/'. $node->nid, !empty($node->comment_count) ? array('title' => format_plural($node->comment_count, '1 comment', '@count comments')) : ''); } return theme('node_list', $items, $title); @@ -290,6 +290,15 @@ function node_type_save($info) { $is_existing = FALSE; $existing_type = !empty($info->old_type) ? $info->old_type : $info->type; $is_existing = db_num_rows(db_query("SELECT * FROM {node_type} WHERE type = '%s'", $existing_type)); + if (!isset($info->help)) { + $info->help = ''; + } + if (!isset($info->min_word_count)) { + $info->min_word_count = 0; + } + if (!isset($info->body_label)) { + $info->body_label = ''; + } if ($is_existing) { db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type); @@ -734,7 +743,7 @@ function node_prepare($node, $teaser = FALSE) { */ function node_build_content($node, $teaser = FALSE, $page = FALSE) { // Remove the delimiter (if any) that separates the teaser from the body. - $node->body = str_replace('<!--break-->', '', $node->body); + $node->body = isset($node->body) ? str_replace('<!--break-->', '', $node->body) : ''; // The 'view' hook can be implemented to overwrite the default function // to display nodes. @@ -1519,6 +1528,7 @@ function node_admin_nodes() { $form['options']['submit'] = array('#type' => 'submit', '#value' => t('Update')); $destination = drupal_get_destination(); + $nodes = array(); while ($node = db_fetch_object($result)) { $nodes[$node->nid] = ''; $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid) .' '. theme('mark', node_mark($node->nid, $node->changed))); @@ -1756,6 +1766,7 @@ function node_feed($nodes = 0, $channel = array()) { $item_length = variable_get('feed_item_length', 'teaser'); $namespaces = array('xmlns:dc="http://purl.org/dc/elements/1.1/"'); + $items = ''; while ($node = db_fetch_object($nodes)) { // Load the specified node: $item = node_load($node->nid); @@ -1780,7 +1791,7 @@ function node_feed($nodes = 0, $channel = array()) { $extra = node_invoke_nodeapi($item, 'rss item'); $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' => date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid .' at '. $base_url, 'attributes' => array('isPermaLink' => 'false')))); foreach ($extra as $element) { - if ($element['namespace']) { + if (isset($element['namespace'])) { $namespaces = array_merge($namespaces, $element['namespace']); } } @@ -1934,6 +1945,10 @@ function node_form($node, $form_values = NULL) { foreach (array('nid', 'vid', 'uid', 'created', 'type') as $key) { $form[$key] = array('#type' => 'value', '#value' => isset($node->$key) ? $node->$key : NULL); } + if (!isset($node->nid)) { + $node->body = NULL; + $node->title = NULL; + } // Changed must be sent to the client, for later overwrite error checking. $form['changed'] = array('#type' => 'hidden', '#default_value' => isset($node->changed) ? $node->changed : NULL); @@ -2169,7 +2184,7 @@ function node_preview($node) { // Extract a teaser, if it hasn't been set (e.g. by a module-provided // 'teaser' form item). if (!isset($node->teaser)) { - $node->teaser = node_teaser($node->body, $node->format); + $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format); } // Display a preview of the node: diff --git a/modules/path/path.module b/modules/path/path.module index f78300f1c..b00f7b998 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -184,7 +184,7 @@ function path_set_alias($path = NULL, $alias = NULL, $pid = NULL, $language = '' /** * Return a form for editing or creating an individual URL alias. */ -function path_form($edit = '') { +function path_form($edit = array('src' => '', 'dst' => '', 'pid' => NULL)) { $form['#submit']['path_form_submit'] = array(); $form['#validate']['path_form_validate'] = array(); $form['#theme'] = 'path_form'; @@ -272,7 +272,7 @@ function path_nodeapi(&$node, $op, $arg) { * Implementation of hook_form_alter(). */ function path_form_alter(&$form, $form_id) { - if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { + if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) { $path = isset($form['#node']->path) ? $form['#node']->path : NULL; $form['path'] = array( '#type' => 'fieldset', @@ -362,7 +362,7 @@ function path_load($pid) { function path_form_validate($form_id, $form_values) { $src = $form_values['src']; $dst = $form_values['dst']; - $pid = $form_values['pid']; + $pid = isset($form_values['pid']) ? $form_values['pid'] : 0; // Language is only set if locale module is enabled, otherwise save for all languages. $language = isset($form_values['language']) ? $form_values['language'] : ''; @@ -376,7 +376,7 @@ function path_form_validate($form_id, $form_values) { */ function path_form_submit($form_id, $form_values) { // Language is only set if locale module is enabled - path_set_alias($form_values['src'], $form_values['dst'], $form_values['pid'], isset($form_values['language']) ? $form_values['language'] : ''); + path_set_alias($form_values['src'], $form_values['dst'], isset($form_values['pid']) ? $form_values['pid'] : 0, isset($form_values['language']) ? $form_values['language'] : ''); drupal_set_message(t('The alias has been saved.')); return 'admin/build/path'; diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 9f7b10796..0033f7734 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -133,7 +133,7 @@ function poll_form($node, $form_values = NULL) { } } else { - $choices = max(2, count($node->choice) ? count($node->choice) : 5); + $choices = max(2, empty($node->choice) ? 5 : count($node->choice)); } $form['choices'] = array( @@ -166,14 +166,14 @@ function poll_form($node, $form_values = NULL) { $form['choice'][$a]['chtext'] = array( '#type' => 'textfield', '#title' => t('Choice @n', array('@n' => ($a + 1))), - '#default_value' => $node->choice[$a]['chtext'], + '#default_value' => isset($node->choice) ? $node->choice[$a]['chtext'] : '', ); if ($admin) { $form['choice'][$a]['chvotes'] = array( '#type' => 'textfield', '#title' => t('Votes for choice @n', array('@n' => ($a + 1))), - '#default_value' => (int)$node->choice[$a]['chvotes'], + '#default_value' => isset($node->choice) ? (int)$node->choice[$a]['chvotes'] : 0, '#size' => 5, '#maxlength' => 7 ); } @@ -197,7 +197,7 @@ function poll_form($node, $form_values = NULL) { $form['settings']['runtime'] = array( '#type' => 'select', '#title' => t('Poll duration'), - '#default_value' => $node->runtime, + '#default_value' => isset($node->runtime) ? $node->runtime : 0, '#options' => $_duration, '#description' => t('After this period, the poll will be closed automatically.'), ); @@ -396,23 +396,25 @@ function theme_poll_view_voting($form) { */ function poll_view_results(&$node, $teaser, $page, $block) { // Count the votes and find the maximum + $total_votes = 0; + $max_votes = 0; foreach ($node->choice as $choice) { $total_votes += $choice['chvotes']; $max_votes = max($max_votes, $choice['chvotes']); } + $poll_results = ''; foreach ($node->choice as $i => $choice) { if ($choice['chtext'] != '') { $poll_results .= theme('poll_bar', check_plain($choice['chtext']), round($choice['chvotes'] * 100 / max($total_votes, 1)), format_plural($choice['chvotes'], '1 vote', '@count votes'), $block); } } - $output .= theme('poll_results', check_plain($node->title), $poll_results, $total_votes, $node->links, $block, $node->nid, $node->vote); - - return $output; + return theme('poll_results', check_plain($node->title), $poll_results, $total_votes, isset($node->links) ? $node->links : array(), $block, $node->nid, isset($node->vote) ? $node->vote : NULL); } function theme_poll_results($title, $results, $votes, $links, $block, $nid, $vote) { + $output = ''; if ($block) { $output .= '<div class="poll">'; $output .= '<div class="title">'. $title .'</div>'; @@ -597,7 +599,7 @@ function poll_view($node, $teaser = FALSE, $page = FALSE, $block = FALSE) { $node->links = $links; } - if ($node->allowvotes && ($block || arg(2) != 'results')) { + if (!empty($node->allowvotes) && ($block || arg(2) != 'results')) { if ($_POST['op'] == t('Vote')) { poll_vote($node); } diff --git a/modules/profile/profile.module b/modules/profile/profile.module index 4f70ded20..1a95e221b 100644 --- a/modules/profile/profile.module +++ b/modules/profile/profile.module @@ -129,6 +129,7 @@ function profile_block($op = 'list', $delta = 0, $edit = array()) { } else if ($op == 'view') { if (user_access('access user profiles')) { + $output = ''; if ((arg(0) == 'node') && is_numeric(arg(1)) && (arg(2) == NULL)) { $node = node_load(arg(1)); $account = user_load(array('uid' => $node->uid)); @@ -225,6 +226,16 @@ function profile_field_form($arg = NULL) { $edit = array('name' => 'profile_'); $form['type'] = array('#type' => 'value', '#value' => $type); } + $edit += array( + 'category' => '', + 'title' => '', + 'explanation' => '', + 'weight' => '', + 'page' => '', + 'autocomplete' => '', + 'required' => '', + 'register' => '', + ); $form['fields'] = array('#type' => 'fieldset', '#title' => t('Field settings'), ); diff --git a/modules/search/search.module b/modules/search/search.module index 177793015..9f5419f78 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -515,7 +515,7 @@ function search_index($sid, $type, $text) { } } else { - if ($tagstack[0] == $tagname) { + if (isset($tagstack[0]) && $tagstack[0] == $tagname) { // None of the tags we look for make sense when nested identically. // If they are, it's probably broken HTML. $tagstack = array(); @@ -575,6 +575,9 @@ function search_index($sid, $type, $text) { $results[$linknid][$word] += $score * $focus; } else { + if (!isset($results[0][$word])) { + $results[0][$word] = 0; + } $results[0][$word] += $score * $focus; // Focus is a decaying value in terms of the amount of unique words up to this point. // From 100 words and more, it decays, to e.g. 0.5 at 500 words and 0.3 at 1000 words. @@ -933,7 +936,7 @@ function search_view($type = 'node') { return $output; } - return drupal_get_form('search_form', NULL, $keys, $type); + return drupal_get_form('search_form', NULL, empty($keys) ? array() : $keys, $type); } /** @@ -1240,19 +1243,19 @@ function _search_excerpt_replace(&$text) { function theme_search_item($item, $type) { $output = ' <dt class="title"><a href="'. check_url($item['link']) .'">'. check_plain($item['title']) .'</a></dt>'; $info = array(); - if ($item['type']) { + if (!empty($item['type'])) { $info[] = $item['type']; } - if ($item['user']) { + if (!empty($item['user'])) { $info[] = $item['user']; } - if ($item['date']) { + if (!empty($item['date'])) { $info[] = format_date($item['date'], 'small'); } - if (is_array($item['extra'])) { + if (isset($item['extra']) && is_array($item['extra'])) { $info = array_merge($info, $item['extra']); } - $output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] . '</p>' : '') . '<p class="search-info">' . implode(' - ', $info) .'</p></dd>'; + $output .= ' <dd>'. (!empty($item['snippet']) ? '<p>'. $item['snippet'] . '</p>' : '') . '<p class="search-info">' . implode(' - ', $info) .'</p></dd>'; return $output; } diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 9bfaf9056..d53371433 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -200,6 +200,7 @@ function statistics_node_tracker() { array('data' => t('Operations'))); $result = pager_query('SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\'' . tablesort_sql($header), 30, 0, NULL, $node->nid); + $rows = array(); while ($log = db_fetch_object($result)) { $rows[] = array( array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'), @@ -209,9 +210,11 @@ function statistics_node_tracker() { } drupal_set_title(check_plain($node->title)); - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 30, 0); - return $output; + if (!empty($rows)) { + $output = theme('table', $header, $rows); + $output .= theme('pager', NULL, 30, 0); + return $output; + } } else { drupal_not_found(); diff --git a/modules/system/system.module b/modules/system/system.module index fe50a468f..bbad3def2 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -462,6 +462,7 @@ function system_admin_theme_submit($form_id, $form_values) { */ function system_theme_select_form($description = '', $default_value = '', $weight = 0) { if (user_access('select different theme')) { + $enabled = array(); foreach (list_themes() as $theme) { if ($theme->status) { $enabled[] = $theme; @@ -980,7 +981,7 @@ function system_theme_data() { db_query("DELETE FROM {system} WHERE type = 'theme'"); foreach ($themes as $theme) { - db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, 'theme', $theme->filename, $theme->status, 0, 0); + db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $theme->name, $theme->owner, 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0, 0); } return $themes; @@ -1039,7 +1040,7 @@ function system_region_list($theme_key) { */ function system_default_region($theme) { $regions = array_keys(system_region_list($theme)); - return $regions[0]; + return isset($regions[0]) ? $regions[0] : ''; } /** @@ -1147,6 +1148,7 @@ function system_themes() { drupal_clear_css_cache(); $themes = system_theme_data(); ksort($themes); + $status = array(); foreach ($themes as $info) { $info->screenshot = dirname($info->filename) .'/screenshot.png'; @@ -1155,10 +1157,10 @@ function system_themes() { $form[$info->name]['screenshot'] = array('#value' => $screenshot); $form[$info->name]['description'] = array('#type' => 'item', '#title' => $info->name, '#value' => dirname($info->filename)); $options[$info->name] = ''; - if ($info->status) { + if (!empty($info->status)) { $status[] = $info->name; } - if ($info->status && (function_exists($info->prefix .'_settings') || function_exists($info->prefix .'_features'))) { + if (!empty($info->status) && (function_exists($info->prefix .'_settings') || function_exists($info->prefix .'_features'))) { $form[$info->name]['operations'] = array('#value' => l(t('configure'), 'admin/build/themes/settings/'. $info->name) ); } else { @@ -1330,8 +1332,9 @@ function system_modules($form_values = NULL) { } } + $modules_required = drupal_required_modules(); // Merge in required modules. - foreach (drupal_required_modules() as $required) { + foreach ($modules_required as $required) { $disabled[] = $required; $form['disabled_modules']['#value'][$required] = TRUE; } @@ -1503,7 +1506,7 @@ function system_modules_submit($form_id, $form_values) { $current_module_list = module_list(TRUE, FALSE); - if (is_array($form_values['throttle'])) { + if (isset($form_values['throttle'])) { foreach ($form_values['throttle'] as $key => $choice) { db_query("UPDATE {system} SET throttle = %d WHERE type = 'module' and name = '%s'", $choice ? 1 : 0, $key); } @@ -1858,7 +1861,13 @@ function system_status($check = FALSE) { * Helper function to sort requirements. */ function _system_sort_requirements($a, $b) { - return (isset($a['weight']) || isset($b['weight'])) ? $a['weight'] - $b['weight'] : strcmp($a['title'], $b['title']); + if (!isset($a['weight'])) { + if (!isset($b['weight'])) { + return strcmp($a['title'], $b['title']); + } + return -$b['weight']; + } + return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight']; } /** @@ -2202,6 +2211,9 @@ function theme_admin_page($blocks) { // perform automatic striping. $block['position'] = ++$stripe % 2 ? 'left' : 'right'; } + if (!isset($container[$block['position']])) { + $container[$block['position']] = ''; + } $container[$block['position']] .= $block_output; } } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index bbde8d8d1..a3f5f34e3 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -28,8 +28,12 @@ function taxonomy_perm() { function taxonomy_link($type, $node = NULL) { if ($type == 'taxonomy terms' && $node != NULL) { $links = array(); - if (array_key_exists('taxonomy', $node)) { + if (!empty($node->taxonomy)) { foreach ($node->taxonomy as $term) { + // On preview, we get tids. + if (is_numeric($term)) { + $term = taxonomy_get_term($term); + } $links['taxonomy_term_'. $term->tid] = array( 'title' => $term->name, 'href' => taxonomy_term_path($term), @@ -176,7 +180,7 @@ function taxonomy_overview_terms($vocabulary) { $header = array(t('Name'), t('Operations')); drupal_set_title(check_plain($vocabulary->name)); - $start_from = $_GET['page'] ? $_GET['page'] : 0; + $start_from = isset($_GET['page']) ? $_GET['page'] : 0; $total_entries = 0; // total count for pager $page_increment = 25; // number of tids per page $displayed_count = 0; // number of tids shown @@ -191,7 +195,7 @@ function taxonomy_overview_terms($vocabulary) { $displayed_count++; // we're counting tids displayed } - if (!$rows) { + if (empty($rows)) { $rows[] = array(array('data' => t('No terms available.'), 'colspan' => '2')); } @@ -209,6 +213,18 @@ function taxonomy_overview_terms($vocabulary) { * Display form for adding and editing vocabularies. */ function taxonomy_form_vocabulary($edit = array()) { + $edit += array( + 'name' => '', + 'description' => '', + 'help' => '', + 'nodes' => array(), + 'hierarchy' => 0, + 'relations' => 0, + 'tags' => 0, + 'multiple' => 0, + 'required' => 0, + 'weight' => 0, + ); $form['name'] = array('#type' => 'textfield', '#title' => t('Vocabulary name'), '#default_value' => $edit['name'], @@ -267,7 +283,7 @@ function taxonomy_form_vocabulary($edit = array()) { ); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); - if ($edit['vid']) { + if (isset($edit['vid'])) { $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); $form['vid'] = array('#type' => 'value', '#value' => $edit['vid']); $form['module'] = array('#type' => 'value', '#value' => $edit['module']); @@ -369,6 +385,12 @@ function taxonomy_vocabulary_confirm_delete_submit($form_id, $form_values) { } function taxonomy_form_term($vocabulary, $edit = array()) { + $edit += array( + 'name' => '', + 'description' => '', + 'tid' => NULL, + 'weight' => 0, + ); $form['name'] = array( '#type' => 'textfield', '#title' => t('Term name'), @@ -394,10 +416,10 @@ function taxonomy_form_term($vocabulary, $edit = array()) { $exclude[] = $edit['tid']; if ($vocabulary->hierarchy == 1) { - $form['parent'] = _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, l(t('Parent term'), 'admin/help/taxonomy', array('fragment' => 'parent')) .'.', 0, '<'. t('root') .'>', $exclude); + $form['parent'] = _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary->vid, l(t('Parent term'), 'admin/help/taxonomy', array('fragment' => 'parent')) .'.', 0, '<'. t('root') .'>', $exclude); } elseif ($vocabulary->hierarchy == 2) { - $form['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary_id, l(t('Parent terms'), 'admin/help/taxonomy', array('fragment' => 'parent')) .'.', 1, '<'. t('root') .'>', $exclude); + $form['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary->vid, l(t('Parent terms'), 'admin/help/taxonomy', array('fragment' => 'parent')) .'.', 1, '<'. t('root') .'>', $exclude); } } @@ -460,12 +482,12 @@ function taxonomy_form_term_submit($form_id, $form_values) { * Status constant indicating if term was inserted or updated. */ function taxonomy_save_term(&$form_values) { - if ($form_values['tid'] && $form_values['name']) { + if (!empty($form_values['tid']) && $form_values['name']) { db_query("UPDATE {term_data} SET name = '%s', description = '%s', weight = %d WHERE tid = %d", $form_values['name'], $form_values['description'], $form_values['weight'], $form_values['tid']); $hook = 'update'; $status = SAVED_UPDATED; } - else if ($form_values['tid']) { + else if (!empty($form_values['tid'])) { return taxonomy_del_term($form_values['tid']); } else { @@ -476,7 +498,7 @@ function taxonomy_save_term(&$form_values) { } db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $form_values['tid'], $form_values['tid']); - if ($form_values['relations']) { + if (!empty($form_values['relations'])) { foreach ($form_values['relations'] as $related_id) { if ($related_id != 0) { db_query('INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)', $form_values['tid'], $related_id); @@ -505,7 +527,7 @@ function taxonomy_save_term(&$form_values) { } db_query('DELETE FROM {term_synonym} WHERE tid = %d', $form_values['tid']); - if ($form_values['synonyms']) { + if (!empty($form_values['synonyms'])) { foreach (explode ("\n", str_replace("\r", '', $form_values['synonyms'])) as $synonym) { if ($synonym) { db_query("INSERT INTO {term_synonym} (tid, name) VALUES (%d, '%s')", $form_values['tid'], chop($synonym)); @@ -652,7 +674,7 @@ function taxonomy_get_vocabularies($type = NULL) { * Generate a form for selecting terms to associate with a node. */ function taxonomy_form_alter(&$form, $form_id) { - if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) { + if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) { $node = $form['#node']; if (!isset($node->taxonomy)) { @@ -757,9 +779,9 @@ function taxonomy_node_get_terms($node, $key = 'tid') { * Make sure incoming vids are free tagging enabled. */ function taxonomy_node_validate(&$node) { - if ($node->taxonomy) { + if (!empty($node->taxonomy)) { $terms = $node->taxonomy; - if ($terms['tags']) { + if (!empty($terms['tags'])) { foreach ($terms['tags'] as $vid => $vid_value) { $vocabulary = taxonomy_vocabulary_load($vid); if (empty($vocabulary->tags)) { @@ -1276,11 +1298,15 @@ function taxonomy_nodeapi($node, $op, $arg = 0) { return $output; case 'insert': - taxonomy_node_save($node, $node->taxonomy); + if (!empty($node->taxonomy)) { + taxonomy_node_save($node, $node->taxonomy); + } break; case 'update': - taxonomy_node_save($node, $node->taxonomy); + if (!empty($node->taxonomy)) { + taxonomy_node_save($node, $node->taxonomy); + } break; case 'delete': diff --git a/modules/upload/upload.module b/modules/upload/upload.module index e2a729489..e61fe9bcd 100644 --- a/modules/upload/upload.module +++ b/modules/upload/upload.module @@ -309,7 +309,7 @@ function _upload_prepare(&$node) { // Scale image uploads. $file = _upload_image($file); - $key = 'upload_'. count($_SESSION['file_previews']); + $key = 'upload_'. (isset($_SESSION['file_previews']) ? 0 : count($_SESSION['file_previews'])); $file->fid = $key; $file->source = $key; $file->list = variable_get('upload_list_default',1); @@ -343,7 +343,7 @@ function upload_form_alter(&$form, $form_id) { ); } - if (isset($form['type'])) { + if (isset($form['type']) && isset($form['#node'])) { $node = $form['#node']; if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) { drupal_add_js('misc/progress.js'); @@ -402,7 +402,7 @@ function _upload_validate(&$node) { $file = (object)$file; // Validate new uploads. - if (strpos($fid, 'upload') !== FALSE && !$file->remove) { + if (strpos($fid, 'upload') !== FALSE && empty($file->remove)) { global $user; // Bypass validation for uid = 1. @@ -673,7 +673,7 @@ function upload_unmunge_filename($filename) { } function upload_save(&$node) { - if (!is_array($node->files)) { + if (empty($node->files) || !is_array($node->files)) { return; } @@ -771,14 +771,14 @@ function _upload_form($node) { // Generate valid URL for both existing attachments and preview of new attachments (these have 'upload' in fid) $description = file_create_url((strpos($file->fid, 'upload') === FALSE ? $file->filepath : file_create_filename($file->filename, file_create_path()))); $description = "<small>". check_plain($description) ."</small>"; - $form['files'][$key]['description'] = array('#type' => 'textfield', '#default_value' => (strlen($file->description)) ? $file->description : $file->filename, '#maxlength' => 256, '#description' => $description ); + $form['files'][$key]['description'] = array('#type' => 'textfield', '#default_value' => !empty($file->description) ? $file->description : $file->filename, '#maxlength' => 256, '#description' => $description ); $form['files'][$key]['size'] = array('#value' => format_size($file->filesize)); - $form['files'][$key]['remove'] = array('#type' => 'checkbox', '#default_value' => $file->remove); + $form['files'][$key]['remove'] = array('#type' => 'checkbox', '#default_value' => !empty($file->remove)); $form['files'][$key]['list'] = array('#type' => 'checkbox', '#default_value' => $file->list); // if the file was uploaded this page request, set value. this fixes the problem // formapi has recognizing new checkboxes. see comments in _upload_prepare. - if ($_SESSION['file_current_upload'] == $file->fid) { + if (isset($_SESSION['file_current_upload']) && $_SESSION['file_current_upload'] == $file->fid) { $form['files'][$key]['list']['#value'] = variable_get('upload_list_default',1); } $form['files'][$key]['filename'] = array('#type' => 'value', '#value' => $file->filename); @@ -883,6 +883,13 @@ function upload_js() { _upload_validate($node); $form = _upload_form($node); + $form += array( + '#post' => $_POST, + '#programmed' => FALSE, + '#tree' => FALSE, + '#parents' => array(), + ); + $GLOBALS['form_button_counter'] = array(0, 0); drupal_alter('form', $form, 'upload_js'); $form = form_builder('upload_js', $form); $output = theme('status_messages') . drupal_render($form); diff --git a/modules/user/user.module b/modules/user/user.module index 173b1656a..df04992ac 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -111,7 +111,7 @@ function user_load($array = array()) { function user_save($account, $array = array(), $category = 'account') { // Dynamically compose a SQL query: $user_fields = user_fields(); - if ($account->uid) { + if (is_object($account) && $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))); @@ -1281,12 +1281,11 @@ function user_register() { // Remove form_group around default fields if there are no other groups. if (!$extra) { - $form['name'] = $form['account']['name']; - $form['mail'] = $form['account']['mail']; - $form['pass'] = $form['account']['pass']; - $form['status'] = $form['account']['status']; - $form['roles'] = $form['account']['roles']; - $form['notify'] = $form['account']['notify']; + foreach (array('name', 'mail', 'pass', 'status', 'roles', 'notify') as $key) { + if (isset($form['account'][$key])) { + $form[$key] = $form['account'][$key]; + } + } unset($form['account']); } else { @@ -1313,11 +1312,14 @@ function user_register_submit($form_id, $form_values) { else { $pass = user_password(); }; - $notify = $form_values['notify']; + $notify = isset($form_values['notify']) ? $form_values['notify'] : NULL; $from = variable_get('site_mail', ini_get('sendmail_from')); if (isset($form_values['roles'])) { $roles = array_filter($form_values['roles']); // Remove unset roles } + else { + $roles = array(); + } if (!$admin && array_intersect(array_keys($form_values), array('uid', 'roles', 'init', 'session', 'status'))) { watchdog('security', t('Detected malicious attempt to alter protected user fields.'), WATCHDOG_WARNING); @@ -1428,7 +1430,8 @@ function user_edit_form($uid, $edit, $register = FALSE) { $roles = user_roles(1); unset($roles[DRUPAL_AUTHENTICATED_RID]); if ($roles) { - $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => t('Roles'), '#default_value' => array_keys((array)$edit['roles']), '#options' => $roles, '#description' => t('The user receives the combined permissions of the %au role, and all roles selected here.', array('%au' => t('authenticated user')))); + $default = empty($edit['roles']) ? array() : array_keys($edit['roles']); + $form['account']['roles'] = array('#type' => 'checkboxes', '#title' => t('Roles'), '#default_value' => $default, '#options' => $roles, '#description' => t('The user receives the combined permissions of the %au role, and all roles selected here.', array('%au' => t('authenticated user')))); } } @@ -1792,7 +1795,7 @@ function user_admin_access_form($edit, $submit) { $form['status'] = array( '#type' => 'radios', '#title' => t('Access type'), - '#default_value' => $edit['status'], + '#default_value' => isset($edit['status']) ? $edit['status'] : array(), '#options' => array('1' => t('Allow'), '0' => t('Deny')), ); $type_options = array('user' => t('Username'), 'mail' => t('E-mail'), 'host' => t('Host')); @@ -1830,9 +1833,7 @@ function user_admin_access() { if (empty($rows)) { $rows[] = array(array('data' => '<em>'. t('There are currently no access rules.') .'</em>', 'colspan' => 5)); } - $output .= theme('table', $header, $rows); - - return $output; + return theme('table', $header, $rows); } /** @@ -1917,7 +1918,7 @@ function user_admin_perm($rid = NULL) { // Have to build checkboxes here after checkbox arrays are built foreach ($role_names as $rid => $name) { - $form['checkboxes'][$rid] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => $status[$rid]); + $form['checkboxes'][$rid] = array('#type' => 'checkboxes', '#options' => $options, '#default_value' => isset($status[$rid]) ? $status[$rid] : array()); $form['role_names'][$rid] = array('#value' => $name, '#tree' => TRUE); } $form['submit'] = array('#type' => 'submit', '#value' => t('Save permissions')); @@ -2023,7 +2024,6 @@ function user_admin_role() { ); $form['#submit']['user_admin_role_submit'] = array(); $form['#validate']['user_admin_role_validate'] = array(); - $form['#theme'] = 'user_admin_role'; } return $form; } @@ -2126,7 +2126,7 @@ function user_admin_account() { $status = array(t('blocked'), t('active')); $roles = user_roles(1); - + $accounts = array(); while ($account = db_fetch_object($result)) { $accounts[$account->uid] = ''; $form['name'][$account->uid] = array('#value' => theme('username', $account)); @@ -2564,10 +2564,12 @@ function user_filters() { $roles = user_roles(1); unset($roles[DRUPAL_AUTHENTICATED_RID]); // Don't list authorized role. if (count($roles)) { - $filters['role'] = array('title' => t('role'), - 'where' => "ur.rid = %d", - 'options' => $roles, - ); + $filters['role'] = array( + 'title' => t('role'), + 'where' => "ur.rid = %d", + 'options' => $roles, + 'join' => '', + ); } $options = array(); @@ -2581,16 +2583,19 @@ function user_filters() { } } ksort($options); - $filters['permission'] = array('title' => t('permission'), - 'join' => 'LEFT JOIN {permission} p ON ur.rid = p.rid', - 'where' => " ((p.perm IS NOT NULL AND p.perm LIKE '%%%s%%') OR u.uid = 1) ", - 'options' => $options, - ); - - $filters['status'] = array('title' => t('status'), - 'where' => 'u.status = %d', - 'options' => array(1 => t('active'), 0 => t('blocked')), - ); + $filters['permission'] = array( + 'title' => t('permission'), + 'join' => 'LEFT JOIN {permission} p ON ur.rid = p.rid', + 'where' => " ((p.perm IS NOT NULL AND p.perm LIKE '%%%s%%') OR u.uid = 1) ", + 'options' => $options, + ); + + $filters['status'] = array( + 'title' => t('status'), + 'where' => 'u.status = %d', + 'join' => '', + 'options' => array(1 => t('active'), 0 => t('blocked')), + ); return $filters; } @@ -2618,8 +2623,8 @@ function user_build_filter_query() { $args[] = $value; $join[] = $filters[$key]['join']; } - $where = count($where) ? 'AND '. implode(' AND ', $where) : ''; - $join = count($join) ? ' '. implode(' ', array_unique($join)) : ''; + $where = !empty($where) ? 'AND '. implode(' AND ', $where) : ''; + $join = !empty($join) ? ' '. implode(' ', array_unique($join)) : ''; return array('where' => $where, 'join' => $join, @@ -2695,7 +2700,7 @@ function theme_user_filters($form) { } } - $output .= '<li><dl class="multiselect">'. (sizeof($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">'; + $output .= '<li><dl class="multiselect">'. (!empty($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">'; foreach (element_children($form['filter']) as $key) { $output .= drupal_render($form['filter'][$key]); } |