Commit f7440d4d authored by Steven Wittens's avatar Steven Wittens

#130971: Kitchen sink (E_NOTICE compliance / Code style / Bugfix in book toc)

parent f2ca2907
...@@ -355,7 +355,9 @@ function drupal_get_filename($type, $name, $filename = NULL) { ...@@ -355,7 +355,9 @@ function drupal_get_filename($type, $name, $filename = NULL) {
} }
} }
return $files[$type][$name]; if (isset($files[$type][$name])) {
return $files[$type][$name];
}
} }
/** /**
......
...@@ -351,6 +351,7 @@ function drupal_not_found() { ...@@ -351,6 +351,7 @@ function drupal_not_found() {
if (empty($return)) { if (empty($return)) {
drupal_set_title(t('Page not found')); drupal_set_title(t('Page not found'));
$return = '';
} }
// To conserve CPU and bandwidth, omit the blocks // To conserve CPU and bandwidth, omit the blocks
print theme('page', $return, FALSE); print theme('page', $return, FALSE);
...@@ -871,6 +872,7 @@ function format_rss_item($title, $link, $description, $args = array()) { ...@@ -871,6 +872,7 @@ function format_rss_item($title, $link, $description, $args = array()) {
* with the same format as $array itself for nesting. * with the same format as $array itself for nesting.
*/ */
function format_xml_elements($array) { function format_xml_elements($array) {
$output = '';
foreach ($array as $key => $value) { foreach ($array as $key => $value) {
if (is_numeric($key)) { if (is_numeric($key)) {
if ($value['key']) { if ($value['key']) {
...@@ -1972,7 +1974,12 @@ function drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = ar ...@@ -1972,7 +1974,12 @@ function drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = ar
// Bundle up the variables into a structured array for altering. // Bundle up the variables into a structured array for altering.
$message = array('#mail_id' => $mailkey, '#to' => $to, '#subject' => $subject, '#body' => $body, '#from' => $from, '#headers' => $headers); $message = array('#mail_id' => $mailkey, '#to' => $to, '#subject' => $subject, '#body' => $body, '#from' => $from, '#headers' => $headers);
drupal_alter('mail', $message); drupal_alter('mail', $message);
list($mailkey, $to, $subject, $body, $from, $headers) = $message; $mailkey = $message['#mail_id'];
$to = $message['#to'];
$subject = $message['#subject'];
$body = $message['#body'];
$from = $message['#from'];
$headers = $message['#headers'];
// Allow for custom mail backend // Allow for custom mail backend
if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) { if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) {
......
...@@ -382,7 +382,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { ...@@ -382,7 +382,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
@chmod($dest, 0664); @chmod($dest, 0664);
} }
if (is_object($file)) { if (isset($file) && is_object($file)) {
$file->filename = $basename; $file->filename = $basename;
$file->filepath = $dest; $file->filepath = $dest;
$source = $file; $source = $file;
......
...@@ -319,7 +319,7 @@ function drupal_prepare_form($form_id, &$form) { ...@@ -319,7 +319,7 @@ function drupal_prepare_form($form_id, &$form) {
$form['form_token'] = array('#type' => 'token', '#default_value' => drupal_get_token($form['#token'])); $form['form_token'] = array('#type' => 'token', '#default_value' => drupal_get_token($form['#token']));
} }
} }
else if ($user->uid && !$form['#programmed']) { else if (isset($user->uid) && $user->uid && !$form['#programmed']) {
$form['#token'] = $form_id; $form['#token'] = $form_id;
$form['form_token'] = array( $form['form_token'] = array(
'#id' => form_clean_id('edit-'. $form_id .'-form-token'), '#id' => form_clean_id('edit-'. $form_id .'-form-token'),
...@@ -1263,7 +1263,14 @@ function expand_radios($element) { ...@@ -1263,7 +1263,14 @@ function expand_radios($element) {
if (count($element['#options']) > 0) { if (count($element['#options']) > 0) {
foreach ($element['#options'] as $key => $choice) { foreach ($element['#options'] as $key => $choice) {
if (!isset($element[$key])) { if (!isset($element[$key])) {
$element[$key] = array('#type' => 'radio', '#title' => $choice, '#return_value' => $key, '#default_value' => $element['#default_value'], '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#spawned' => TRUE); $element[$key] = array(
'#type' => 'radio',
'#title' => $choice,
'#return_value' => $key,
'#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
'#attributes' => $element['#attributes'],
'#parents' => $element['#parents'],
);
} }
} }
} }
......
...@@ -204,7 +204,7 @@ function drupal_rewrite_settings($settings = array(), $prefix = '') { ...@@ -204,7 +204,7 @@ function drupal_rewrite_settings($settings = array(), $prefix = '') {
// Write new value to settings.php in the following format: // Write new value to settings.php in the following format:
// $'setting' = 'value'; // 'comment' // $'setting' = 'value'; // 'comment'
$setting = $settings[$variable[1]]; $setting = $settings[$variable[1]];
$buffer .= '$'. $variable[1] ." = '". $setting['value'] ."';". ($setting['comment'] ? ' // '. $setting['comment'] ."\n" : "\n"); $buffer .= '$'. $variable[1] ." = '". $setting['value'] ."';". (!empty($setting['comment']) ? ' // '. $setting['comment'] ."\n" : "\n");
unset($settings[$variable[1]]); unset($settings[$variable[1]]);
} }
else { else {
......
...@@ -1301,7 +1301,7 @@ function _locale_import_parse_quoted($string) { ...@@ -1301,7 +1301,7 @@ function _locale_import_parse_quoted($string) {
*/ */
function _locale_export_po($language) { function _locale_export_po($language) {
global $user; global $user;
$header = '';
// Get language specific strings, or all strings // Get language specific strings, or all strings
if ($language) { if ($language) {
$meta = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $language)); $meta = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $language));
......
...@@ -632,7 +632,8 @@ function menu_rebuild() { ...@@ -632,7 +632,8 @@ function menu_rebuild() {
$item = &$menu[$path]; $item = &$menu[$path];
$number_parts = $item['_number_parts']; $number_parts = $item['_number_parts'];
if (isset($item['parent'])) { if (isset($item['parent'])) {
$parent_parts = explode('/', $menu_path_map[$item['parent']], 6); $item['parent'] = $menu_path_map[$item['parent']];
$parent_parts = explode('/', $item['parent'], 6);
$slashes = count($parent_parts) - 1; $slashes = count($parent_parts) - 1;
} }
else { else {
...@@ -723,7 +724,7 @@ function menu_rebuild() { ...@@ -723,7 +724,7 @@ function menu_rebuild() {
$item['parent'] = implode('/', array_slice($item['_parts'], 0, $item['_number_parts'] - 1)); $item['parent'] = implode('/', array_slice($item['_parts'], 0, $item['_number_parts'] - 1));
} }
else { else {
$item['_depth'] = $item['parent'] ? $menu[$menu_path_map[$item['parent']]]['_depth'] + 1 : 1; $item['_depth'] = $item['parent'] ? $menu[$item['parent']]['_depth'] + 1 : 1;
} }
} }
else { else {
......
...@@ -70,11 +70,11 @@ function sess_write($key, $value) { ...@@ -70,11 +70,11 @@ function sess_write($key, $value) {
// session table rows without breaking throttle module and "Who's Online" // session table rows without breaking throttle module and "Who's Online"
// block. // block.
if ($user->uid || $value || count($_COOKIE)) { if ($user->uid || $value || count($_COOKIE)) {
db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time()); db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time());
} }
} }
else { else {
db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time(), $key); db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time(), $key);
// TODO: this can be an expensive query. Perhaps only execute it every x minutes. Requires investigation into cache expiration. // TODO: this can be an expensive query. Perhaps only execute it every x minutes. Requires investigation into cache expiration.
if ($user->uid) { if ($user->uid) {
......
...@@ -611,7 +611,7 @@ function theme_links($links, $attributes = array('class' => 'links')) { ...@@ -611,7 +611,7 @@ function theme_links($links, $attributes = array('class' => 'links')) {
// Pass in $link as $options, they share the same keys. // Pass in $link as $options, they share the same keys.
$output .= l($link['title'], $link['href'], $link); $output .= l($link['title'], $link['href'], $link);
} }
else if ($link['title']) { else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link['html'])) { if (empty($link['html'])) {
$link['title'] = check_plain($link['title']); $link['title'] = check_plain($link['title']);
...@@ -810,6 +810,9 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { ...@@ -810,6 +810,9 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) {
} }
$output .= " </tr></thead>\n"; $output .= " </tr></thead>\n";
} }
else {
$ts = array();
}
// Format the table rows: // Format the table rows:
$output .= "<tbody>\n"; $output .= "<tbody>\n";
......
...@@ -310,7 +310,7 @@ function aggregator_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -310,7 +310,7 @@ function aggregator_block($op = 'list', $delta = 0, $edit = array()) {
/** /**
* Generate a form to add/edit/delete aggregator categories. * 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', $form['title'] = array('#type' => 'textfield',
'#title' => t('Title'), '#title' => t('Title'),
'#default_value' => $edit['title'], '#default_value' => $edit['title'],
...@@ -392,13 +392,13 @@ function aggregator_form_category_submit($form_id, $form_values) { ...@@ -392,13 +392,13 @@ function aggregator_form_category_submit($form_id, $form_values) {
* Add/edit/delete aggregator categories. * Add/edit/delete aggregator categories.
*/ */
function aggregator_save_category($edit) { 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']); 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']); 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 // A single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id('{aggregator_category}_cid'); $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']); 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) { ...@@ -408,7 +408,7 @@ function aggregator_save_category($edit) {
/** /**
* Generate a form to add/edit feed sources. * 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'); $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'] == '') { if ($edit['refresh'] == '') {
...@@ -568,7 +568,7 @@ function aggregator_remove($feed) { ...@@ -568,7 +568,7 @@ function aggregator_remove($feed) {
while ($item = db_fetch_object($result)) { while ($item = db_fetch_object($result)) {
$items[] = "iid = $item->iid"; $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_category_item} WHERE '. implode(' OR ', $items));
} }
db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']); db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
...@@ -677,6 +677,7 @@ function aggregator_element_data($parser, $data) { ...@@ -677,6 +677,7 @@ function aggregator_element_data($parser, $data) {
// it or its contents will end up in the item array. // it or its contents will end up in the item array.
break; break;
default: default:
$channel += array($tag => '');
$channel[$tag] .= $data; $channel[$tag] .= $data;
} }
} }
......
...@@ -191,6 +191,10 @@ function _block_rehash() { ...@@ -191,6 +191,10 @@ function _block_rehash() {
// Reinsert new set of blocks into table. // Reinsert new set of blocks into table.
foreach ($blocks as $block) { 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_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(); db_unlock_tables();
...@@ -238,7 +242,7 @@ function block_admin_display($theme = NULL) { ...@@ -238,7 +242,7 @@ function block_admin_display($theme = NULL) {
); );
if ($throttle) { 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'])); $form[$i]['configure'] = array('#value' => l(t('configure'), 'admin/build/block/configure/'. $block['module'] .'/'. $block['delta']));
if ($block['module'] == 'block') { if ($block['module'] == 'block') {
...@@ -567,6 +571,10 @@ function block_box_delete_submit($form_id, $form_values) { ...@@ -567,6 +571,10 @@ function block_box_delete_submit($form_id, $form_values) {
* Define the custom block form. * Define the custom block form.
*/ */
function block_box_form($edit = array()) { function block_box_form($edit = array()) {
$edit += array(
'info' => '',
'body' => '',
);
$form['info'] = array( $form['info'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Block description'), '#title' => t('Block description'),
......
...@@ -133,7 +133,7 @@ function blog_page_user($uid) { ...@@ -133,7 +133,7 @@ function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? 'uid' : 'name') => $uid, 'status' => 1)); $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))); drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));
if (($account->uid == $user->uid) && user_access('edit own blog')) { if (($account->uid == $user->uid) && user_access('edit own blog')) {
......
...@@ -196,14 +196,14 @@ function book_submit(&$node) { ...@@ -196,14 +196,14 @@ function book_submit(&$node) {
*/ */
function book_form(&$node) { function book_form(&$node) {
$type = node_get_types('type', $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); $form['parent'] = array('#type' => 'value', '#value' => $node->parent);
} }
else { else {
$form['parent'] = array('#type' => 'select', $form['parent'] = array('#type' => 'select',
'#title' => t('Parent'), '#title' => t('Parent'),
'#default_value' => ($node->parent ? $node->parent : arg(4)), '#default_value' => (isset($node->parent) ? $node->parent : arg(4)),
'#options' => book_toc($node->nid), '#options' => book_toc(isset($node->nid) ? $node->nid : 0),
'#weight' => -4, '#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 &lt;top-level&gt; is an independent, top-level book.') : t('The parent that this page belongs in.'), '#description' => user_access('create new books') ? t('The parent section in which to place this page. Note that each page whose parent is &lt;top-level&gt; is an independent, top-level book.') : t('The parent that this page belongs in.'),
); );
...@@ -226,7 +226,7 @@ function book_form(&$node) { ...@@ -226,7 +226,7 @@ function book_form(&$node) {
if (user_access('administer nodes')) { if (user_access('administer nodes')) {
$form['weight'] = array('#type' => 'weight', $form['weight'] = array('#type' => 'weight',
'#title' => t('Weight'), '#title' => t('Weight'),
'#default_value' => $node->weight, '#default_value' => isset($node->weight) ? $node->weight : 0,
'#delta' => 15, '#delta' => 15,
'#weight' => 5, '#weight' => 5,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'), '#description' => t('Pages at a given level are ordered first by weight and then by title.'),
...@@ -251,13 +251,13 @@ function book_form(&$node) { ...@@ -251,13 +251,13 @@ function book_form(&$node) {
function book_outline($node) { function book_outline($node) {
$form['parent'] = array('#type' => 'select', $form['parent'] = array('#type' => 'select',
'#title' => t('Parent'), '#title' => t('Parent'),
'#default_value' => $node->parent, '#default_value' => isset($node->parent) ? $node->parent : 0,
'#options' => book_toc($node->nid), '#options' => book_toc($node->nid),
'#description' => t('The parent page in the book.'), '#description' => t('The parent page in the book.'),
); );
$form['weight'] = array('#type' => 'weight', $form['weight'] = array('#type' => 'weight',
'#title' => t('Weight'), '#title' => t('Weight'),
'#default_value' => $node->weight, '#default_value' => isset($node->weight) ? $node->weight : 0,
'#delta' => 15, '#delta' => 15,
'#description' => t('Pages at a given level are ordered first by weight and then by title.'), '#description' => t('Pages at a given level are ordered first by weight and then by title.'),
); );
...@@ -266,7 +266,7 @@ function book_outline($node) { ...@@ -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.'), '#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)) { if (isset($node->parent)) {
$form['update'] = array('#type' => 'submit', $form['update'] = array('#type' => 'submit',
'#value' => t('Update book outline'), '#value' => t('Update book outline'),
......
...@@ -145,7 +145,7 @@ function theme_color_scheme_form($form) { ...@@ -145,7 +145,7 @@ function theme_color_scheme_form($form) {
$info = $form['info']['#value']; $info = $form['info']['#value'];
$path = drupal_get_path('theme', $theme) .'/'; $path = drupal_get_path('theme', $theme) .'/';
drupal_add_css($path . $info['preview_css']); drupal_add_css($path . $info['preview_css']);
$output = '';
// Wrapper // Wrapper
$output .= '<div class="color-form clear-block">'; $output .= '<div class="color-form clear-block">';
......
...@@ -384,7 +384,7 @@ function comment_form_alter($form, $form_id) { ...@@ -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.'), '#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) { if ($form['type']['#value'] .'_node_form' == $form_id) {
$node = $form['#node']; $node = $form['#node'];
$form['comment_settings'] = array( $form['comment_settings'] = array(
...@@ -1535,7 +1535,23 @@ function comment_form($edit, $title = NULL) { ...@@ -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['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'])) { if (!isset($edit['format'])) {
$edit['format'] = FILTER_FORMAT_DEFAULT; $edit['format'] = FILTER_FORMAT_DEFAULT;
} }
......
...@@ -98,7 +98,15 @@ function contact_menu() { ...@@ -98,7 +98,15 @@ function contact_menu() {
function _contact_user_tab_access($account) { function _contact_user_tab_access($account) {
global $user; 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) { ...@@ -121,7 +129,7 @@ function contact_user($type, &$edit, &$user, $category = NULL) {
return $form; return $form;
} }
elseif ($type == 'validate') { elseif ($type == 'validate') {
return array('contact' => $edit['contact']); return array('contact' => isset($edit['contact']) ? $edit['contact'] : FALSE);
} }
elseif ($type == 'insert') { elseif ($type == 'insert') {
$edit['contact'] = variable_get('contact_default_status', 1); $edit['contact'] = variable_get('contact_default_status', 1);
...@@ -149,6 +157,16 @@ function contact_admin_edit($cid = NULL) { ...@@ -149,6 +157,16 @@ function contact_admin_edit($cid = NULL) {
if (arg(3) == "edit" && $cid > 0) { if (arg(3) == "edit" && $cid > 0) {
$edit = db_fetch_array(db_query("SELECT * FROM {contact} WHERE cid = %d", $cid)); $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', $form['category'] = array('#type' => 'textfield',
'#title' => t('Category'), '#title' => t('Category'),
'#maxlength' => 255, '#maxlength' => 255,
......
...@@ -210,7 +210,7 @@ function forum_admin_settings() { ...@@ -210,7 +210,7 @@ function forum_admin_settings() {
function forum_form_alter(&$form, $form_id) { function forum_form_alter(&$form, $form_id) {
// hide critical options from forum vocabulary // hide critical options from forum vocabulary
if ($form_id == 'taxonomy_form_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( $form['help_forum_vocab'] = array(
'#value' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'), '#value' => t('This is the designated forum vocabulary. Some of the normal vocabulary options have been removed.'),
'#weight' => -1, '#weight' => -1,
...@@ -280,14 +280,12 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) { ...@@ -280,14 +280,12 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) {
break; break;
} }
if ($content) { if (!empty($content)) {
$content .= '<div class="more-link">'. l(t('more'), 'forum', array('title' => t('Read the latest forum topics.'))) .'</div>'; $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) { ...@@ -439,6 +437,12 @@ function forum_delete(&$node) {
* @param $edit Associative array containing a container term to be added or edited. * @param $edit Associative array containing a container term to be added or edited.
*/ */
function forum_form_container($edit = array()) { function forum_form_container($edit = array()) {
$edit += array(
'name' => '',
'description' => '',
'tid' => 0,
'weight' => 0,
);
// Handle a delete operation. // Handle a delete operation.
$form['name'] = array( $form['name'] = array(
'#title' => t('Container name'), '#title' => t('Container name'),
...@@ -481,7 +485,7 @@ function forum_form_container($edit = array()) { ...@@ -481,7 +485,7 @@ function forum_form_container($edit = array()) {
} }
function forum_form_main($type, $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']); return drupal_get_form('forum_confirm_delete', $edit['tid']);
} }
switch ($type) { switch ($type) {
...@@ -500,6 +504,12 @@ function forum_form_main($type, $edit = array()) { ...@@ -500,6 +504,12 @@ function forum_form_main($type, $edit = array()) {
* @param $edit Associative array containing a forum term to be added or edited. * @param $edit Associative array containing a forum term to be added or edited.
*/ */
function forum_form_forum($edit = array()) { function forum_form_forum($edit = array()) {
$edit += array(
'name' => '',
'description' => '',
'tid' => NULL,
'weight' => 0,
);
$form['name'] = array('#type' => 'textfield', $form['name'] = array('#type' => 'textfield',
'#title' => t('Forum name'), '#title' => t('Forum name'),
'#default_value' => $edit['name'], '#default_value' => $edit['name'],
...@@ -1077,7 +1087,7 @@ function theme_forum_topic_navigation($node) { ...@@ -1077,7 +1087,7 @@ function theme_forum_topic_navigation($node) {
// get previous and next topic // 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)); $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);