diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-08-22 17:03:42 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-08-22 17:03:42 +0000 |
commit | 51cf18e53176244f264c56cab1c4ff0d1767ac59 (patch) | |
tree | 833a665ab48dd0d3a54676d78aa9152b0699f21e /modules | |
parent | 95cb7f32229e229a39e70a76b2b0f6a14cdc5953 (diff) | |
download | brdo-51cf18e53176244f264c56cab1c4ff0d1767ac59.tar.gz brdo-51cf18e53176244f264c56cab1c4ff0d1767ac59.tar.bz2 |
- #9292: Make Drupal (somewhat) PHP5 compatible. xtemplate is still horribly broken.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/block.module | 5 | ||||
-rw-r--r-- | modules/block/block.module | 5 | ||||
-rw-r--r-- | modules/comment.module | 1 | ||||
-rw-r--r-- | modules/comment/comment.module | 1 | ||||
-rw-r--r-- | modules/forum.module | 16 | ||||
-rw-r--r-- | modules/forum/forum.module | 16 | ||||
-rw-r--r-- | modules/node.module | 14 | ||||
-rw-r--r-- | modules/node/node.module | 14 | ||||
-rw-r--r-- | modules/user.module | 19 | ||||
-rw-r--r-- | modules/user/user.module | 19 |
10 files changed, 82 insertions, 28 deletions
diff --git a/modules/block.module b/modules/block.module index 5ecf0f9ae..df0a67618 100644 --- a/modules/block.module +++ b/modules/block.module @@ -365,7 +365,10 @@ function block_list($region) { ** based on server load. */ if (!($block['throttle'] && (module_invoke('throttle', 'status') > 4))) { - $block = array_merge($block, module_invoke($block['module'], 'block', 'view', $block['delta'])); + $array = module_invoke($block['module'], 'block', 'view', $block['delta']); + if (is_array($array)) { + $block = array_merge($block, $array); + } } if (isset($block['content']) && $block['content']) { $blocks[$region]["$block[module]_$block[delta]"] = (object) $block; diff --git a/modules/block/block.module b/modules/block/block.module index 5ecf0f9ae..df0a67618 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -365,7 +365,10 @@ function block_list($region) { ** based on server load. */ if (!($block['throttle'] && (module_invoke('throttle', 'status') > 4))) { - $block = array_merge($block, module_invoke($block['module'], 'block', 'view', $block['delta'])); + $array = module_invoke($block['module'], 'block', 'view', $block['delta']); + if (is_array($array)) { + $block = array_merge($block, $array); + } } if (isset($block['content']) && $block['content']) { $blocks[$region]["$block[module]_$block[delta]"] = (object) $block; diff --git a/modules/comment.module b/modules/comment.module index 0f9980b67..923381af0 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -502,6 +502,7 @@ function comment_preview($edit) { $output = ''; + $comment = new StdClass(); foreach ($edit as $key => $value) { $comment->$key = $value; } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 0f9980b67..923381af0 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -502,6 +502,7 @@ function comment_preview($edit) { $output = ''; + $comment = new StdClass(); foreach ($edit as $key => $value) { $comment->$key = $value; } diff --git a/modules/forum.module b/modules/forum.module index e90df6d9c..9be309d16 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -157,6 +157,7 @@ function forum_link($type, $node = 0, $main = 0) { while ($topic = db_fetch_object($result)) { if ($stop == 1) { + $next = new StdClass(); $next->nid = $topic->nid; $next->title = $topic->title; break; @@ -311,7 +312,12 @@ function _forum_last_comment($nid) { function _forum_last_reply($nid) { $value = db_fetch_object(db_query_range('SELECT c.timestamp, c.name AS anonymous_name, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = 0 ORDER BY c.timestamp DESC', $nid, 0, 1)); - $value->name = $value->uid ? $value->name : $value->anonymous_name; + if ($value) { + $value->name = $value->uid ? $value->name : $value->anonymous_name; + } + else { + $value = new StdClass(); + } return $value; } @@ -373,9 +379,13 @@ function _forum_topics_read($term, $uid) { function _forum_last_post($term) { $topic = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), n.created AS timestamp, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {users} u ON n.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY timestamp DESC", $term, 0, 1)); - $reply = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), c.timestamp, c.name AS anonymous_name, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {comments} c ON n.nid = c.nid INNER JOIN {users} u ON c.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." AND c.status = 0 ORDER BY c.timestamp DESC", $term, 0, 1)); - $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + if ($reply) { + $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + } + else { + $reply = new StdClass(); + } $value = ($topic->timestamp > $reply->timestamp) ? $topic : $reply; diff --git a/modules/forum/forum.module b/modules/forum/forum.module index e90df6d9c..9be309d16 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -157,6 +157,7 @@ function forum_link($type, $node = 0, $main = 0) { while ($topic = db_fetch_object($result)) { if ($stop == 1) { + $next = new StdClass(); $next->nid = $topic->nid; $next->title = $topic->title; break; @@ -311,7 +312,12 @@ function _forum_last_comment($nid) { function _forum_last_reply($nid) { $value = db_fetch_object(db_query_range('SELECT c.timestamp, c.name AS anonymous_name, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = 0 ORDER BY c.timestamp DESC', $nid, 0, 1)); - $value->name = $value->uid ? $value->name : $value->anonymous_name; + if ($value) { + $value->name = $value->uid ? $value->name : $value->anonymous_name; + } + else { + $value = new StdClass(); + } return $value; } @@ -373,9 +379,13 @@ function _forum_topics_read($term, $uid) { function _forum_last_post($term) { $topic = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), n.created AS timestamp, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {users} u ON n.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY timestamp DESC", $term, 0, 1)); - $reply = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), c.timestamp, c.name AS anonymous_name, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {comments} c ON n.nid = c.nid INNER JOIN {users} u ON c.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." AND c.status = 0 ORDER BY c.timestamp DESC", $term, 0, 1)); - $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + if ($reply) { + $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + } + else { + $reply = new StdClass(); + } $value = ($topic->timestamp > $reply->timestamp) ? $topic : $reply; diff --git a/modules/node.module b/modules/node.module index 62a9e5426..6deaa6763 100644 --- a/modules/node.module +++ b/modules/node.module @@ -347,9 +347,12 @@ function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { $function = $name .'_nodeapi'; if (function_exists($function)) { $result = $function($node, $op, $a3, $a4); - if (isset($result)) { + if (is_array($result)) { $return = array_merge($return, $result); } + else { + $return[] = $result; + } } } return $return; @@ -397,7 +400,7 @@ function node_load($conditions, $revision = -1) { } // Return the desired revision. - if ($revision != -1 && isset($node->revisions[$revision])) { + if ($revision != -1 && is_array($node->revisions[$revision])) { $node = $node->revisions[$revision]['node']; } @@ -814,6 +817,7 @@ function node_default_settings() { $header = array_merge(array(t('type')), array_keys(node_invoke_nodeapi($node, 'settings'))); foreach (node_list() as $type) { + $node = new StdClass(); $node->type = $type; $cols = array(); foreach (node_invoke_nodeapi($node, 'settings') as $setting) { @@ -1221,7 +1225,11 @@ function node_form($edit) { } } - return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], array_merge($param['options'], array('id' => 'node-form'))); + $attributes = array('id' => 'node-form'); + if (is_array($param['options'])) { + $attributes = array_merge($param['options'], $attributes); + } + return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $attributes); } /** diff --git a/modules/node/node.module b/modules/node/node.module index 62a9e5426..6deaa6763 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -347,9 +347,12 @@ function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { $function = $name .'_nodeapi'; if (function_exists($function)) { $result = $function($node, $op, $a3, $a4); - if (isset($result)) { + if (is_array($result)) { $return = array_merge($return, $result); } + else { + $return[] = $result; + } } } return $return; @@ -397,7 +400,7 @@ function node_load($conditions, $revision = -1) { } // Return the desired revision. - if ($revision != -1 && isset($node->revisions[$revision])) { + if ($revision != -1 && is_array($node->revisions[$revision])) { $node = $node->revisions[$revision]['node']; } @@ -814,6 +817,7 @@ function node_default_settings() { $header = array_merge(array(t('type')), array_keys(node_invoke_nodeapi($node, 'settings'))); foreach (node_list() as $type) { + $node = new StdClass(); $node->type = $type; $cols = array(); foreach (node_invoke_nodeapi($node, 'settings') as $setting) { @@ -1221,7 +1225,11 @@ function node_form($edit) { } } - return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], array_merge($param['options'], array('id' => 'node-form'))); + $attributes = array('id' => 'node-form'); + if (is_array($param['options'])) { + $attributes = array_merge($param['options'], $attributes); + } + return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $attributes); } /** diff --git a/modules/user.module b/modules/user.module index 915d3414f..bb77c128f 100644 --- a/modules/user.module +++ b/modules/user.module @@ -54,14 +54,19 @@ function user_load($array = array()) { } $result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", 0, 1); - $user = db_fetch_object($result); - $user = drupal_unpack($user); - user_module_invoke('load', $array, $user); + if (db_num_rows($result)) { + $user = db_fetch_object($result); + $user = drupal_unpack($user); + user_module_invoke('load', $array, $user); - $user->roles = array(); - $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); - while ($role = db_fetch_object($result)) { - $user->roles[$role->rid] = $role->name; + $user->roles = array(); + $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); + while ($role = db_fetch_object($result)) { + $user->roles[$role->rid] = $role->name; + } + } + else { + $user = new StdClass(); } return $user; diff --git a/modules/user/user.module b/modules/user/user.module index 915d3414f..bb77c128f 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -54,14 +54,19 @@ function user_load($array = array()) { } $result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", 0, 1); - $user = db_fetch_object($result); - $user = drupal_unpack($user); - user_module_invoke('load', $array, $user); + if (db_num_rows($result)) { + $user = db_fetch_object($result); + $user = drupal_unpack($user); + user_module_invoke('load', $array, $user); - $user->roles = array(); - $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); - while ($role = db_fetch_object($result)) { - $user->roles[$role->rid] = $role->name; + $user->roles = array(); + $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); + while ($role = db_fetch_object($result)) { + $user->roles[$role->rid] = $role->name; + } + } + else { + $user = new StdClass(); } return $user; |