From 6c387962199f3b57aff1df4bc0c79ded4935f2a1 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 17 May 2001 19:14:50 +0000 Subject: - Fixed bug in account.module. - Simplified field_set() API. - Made UnConeD's cool common timestamp format conform with the general coding style. Sorry to be so picky about this but I really can't help it. ;) --- includes/comment.inc | 4 ++-- includes/common.inc | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'includes') diff --git a/includes/comment.inc b/includes/comment.inc index 57f2bf62e..0f7d31ccf 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -35,7 +35,7 @@ function comment_moderate($moderate) { $id = check_input($id); $vote = check_input($vote); $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '$id'")); if ($comment && !field_get($comment, "users", $user->userid)) { - $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment, "users", $user->userid, $vote) ."' WHERE cid = '$id'"); + $result = db_query("UPDATE comments SET score = score $vote, votes = votes + 1, users = '". field_set($comment->users, $user->userid, $vote) ."' WHERE cid = '$id'"); } } } @@ -337,4 +337,4 @@ function comment_render($lid, $cid) { } } -?> \ No newline at end of file +?> diff --git a/includes/common.inc b/includes/common.inc index 44a353fbb..1c5ea330b 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -97,9 +97,9 @@ function format_plural($count, $singular, $plural) { } function format_interval($timestamp) { - $units = array("year|years"=>31536000, "week|weeks"=>604800, "day|days"=>86400, "hour|hours"=>3600, "min|min"=>60, "sec|sec"=>1); + $units = array("year|years" => 31536000, "week|weeks" => 604800, "day|days" => 86400, "hour|hours" => 3600, "min|min" => 60, "sec|sec" => 1); foreach ($units as $key=>$value) { - $key=explode("|", $key); + $key = explode("|", $key); if ($timestamp >= $value) { $output .= ($output ? " " : "") . format_plural(floor($timestamp / $value), $key[0], $key[1]); $timestamp %= $value; @@ -124,12 +124,16 @@ function format_date($timestamp, $type = "medium", $format = "") { $date = t(date("l", $timestamp)) .", ". t(date("F", $timestamp)) ." ". date("d, Y - H:i", $timestamp); break; case "custom": - for ($i=strlen($format);$i>=0;$c=$format[--$i]) { - if (strstr("DFlMSw",$c)) - $date=t(date($c,$timestamp)).$date; - else if (strstr("AaBdgGhHiIjLmnrstTUYyZz",$c)) - $date=date($c,$timestamp).$date; - else $date=$c.$date; + for ($i = strlen($format); $i >= 0; $c = $format[--$i]) { + if (strstr("DFlMSw", $c)) { + $date=t(date($c, $timestamp)).$date; + } + else if (strstr("AaBdgGhHiIjLmnrstTUYyZz", $c)) { + $date = date($c, $timestamp).$date; + } + else { + $date = $c.$date; + } } break; default: @@ -169,8 +173,8 @@ function format_text($text) { return preg_replace($src, $dst, $text); } -function form($action, $form, $method = "post", $options="") { - return "
\n$form
\n"; +function form($action, $form, $method = "post", $options = 0) { + return "
\n$form
\n"; } function form_item($title, $value, $description = 0) { @@ -211,9 +215,7 @@ function field_get($object, $variable, $field) { return $rval; } -function field_set($object, $variable, $name, $value) { - $field = $object->$variable; - +function field_set($field, $name, $value) { if (!$value) { // remove entry: $data = explode(";", $field); @@ -272,4 +274,4 @@ $theme = theme_init(); // set error handler: set_error_handler("error_handler"); -?> \ No newline at end of file +?> -- cgit v1.2.3