summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/comment.inc4
-rw-r--r--includes/common.inc38
-rw-r--r--includes/user.inc2
-rw-r--r--modules/node.module7
-rw-r--r--modules/node/node.module7
-rw-r--r--modules/queue.module6
6 files changed, 32 insertions, 32 deletions
diff --git a/includes/comment.inc b/includes/comment.inc
index 0f7d31ccf..9ecc1c690 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -34,7 +34,7 @@ function comment_moderate($moderate) {
if ($vote != $comment_votes[$none]) {
$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)) {
+ 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'");
}
}
@@ -162,7 +162,7 @@ function comment_moderation($comment) {
// preview comment:
$output .= " ";
}
- else if ($user->id && $user->userid != $comment->userid && !field_get($comment, "users", $user->userid)) {
+ else if ($user->id && $user->userid != $comment->userid && !field_get($comment->users, $user->userid)) {
// comment hasn't been moderated yet:
foreach ($comment_votes as $key=>$value) $options .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
$output .= "<SELECT NAME=\"moderate[$comment->cid]\">$options</SELECT>\n";
diff --git a/includes/common.inc b/includes/common.inc
index 1c5ea330b..9fb36b820 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -88,7 +88,7 @@ function check_name($name) {
function check_output($message, $nl2br = 0) {
global $allowed_html, $na;
- $var = strip_tags(stripslashes(format_text($message)), $allowed_html);
+ $var = strip_tags(stripslashes(node_macro($message)), $allowed_html);
return ($var) ? (($nl2br) ? nl2br($var) : $var) : $na;
}
@@ -163,16 +163,6 @@ function format_tag($link, $text) {
return "'<a href=\"node.php?title='. urlencode('$link') .'\">'. ('$text' ? '$text' : '$link') .'</a>'";
}
-function format_text($text) {
-
- $src = array( // "/(<\/?)(\w+)([^>]*>)/e", // convert HTML to lower case
- "/\[\[(([^\|]*?)(\|([^\|]*?))?)\]\]/e"); // [link|description]
- $dst = array( // "'\\1'. strtolower('\\2') .'\\3'", // convert HTML to lower case
- format_tag('\\2', '\\4')); // [link|description]
-
- return preg_replace($src, $dst, $text);
-}
-
function form($action, $form, $method = "post", $options = 0) {
return "<FORM ACTION=\"$action\" METHOD=\"$method\"". ($options ? " $options" : "") .">\n$form</FORM>\n";
}
@@ -206,36 +196,32 @@ function form_submit($value) {
return "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". check_textfield($value) ."\">\n";
}
-function field_get($object, $variable, $field) {
- $data = explode(";", $object->$variable);
- for (reset($data); current($data); next($data)) {
- $entry = explode(":", current($data));
- if (reset($entry) == $field) $rval = end($entry);
+function field_get($string, $name) {
+ foreach (explode(";", $string) as $data) {
+ $entry = explode(":", $data);
+ if ($entry[0] == $name) return $entry[1];
}
- return $rval;
}
-function field_set($field, $name, $value) {
+function field_set($string, $name, $value) {
if (!$value) {
// remove entry:
- $data = explode(";", $field);
- for (reset($data); current($data); next($data)) {
- $entry = explode(":", current($data));
+ foreach (explode(";", $string) as $data) {
+ $entry = explode(":", $data);
if ($entry[0] != $name) $rval .= "$entry[0]:$entry[1];";
}
}
- else if (strstr($field, "$name:")) {
+ else if (strstr($string, "$name:")) {
// found: update exsisting entry:
- $data = explode(";", $field);
- for (reset($data); current($data); next($data)) {
- $entry = explode(":", current($data));
+ foreach (explode(";", $string) as $data) {
+ $entry = explode(":", $data);
if ($entry[0] == $name) $entry[1] = $value;
$rval .= "$entry[0]:$entry[1];";
}
}
else {
// not found:
- $rval = "$field$name:$value;";
+ $rval = "$string$name:$value;";
}
return $rval;
diff --git a/includes/user.inc b/includes/user.inc
index 74254dc2b..307a3f33c 100644
--- a/includes/user.inc
+++ b/includes/user.inc
@@ -54,7 +54,7 @@ function user_save($account, $array) {
function user_access($account, $section = 0) {
global $user;
- if ($section) return (field_get($account, "access", $section) || $account->id == 1);
+ if ($section) return (field_get($account->access, $section) || $account->id == 1);
else return ($account->access || $account->id == 1);
}
diff --git a/modules/node.module b/modules/node.module
index e469bbfea..53c32219f 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -11,6 +11,13 @@ class Node {
}
}
+function node_macro($text) {
+ $src = array("/\[\[(([^\|]*?)(\|([^\|]*?))?)\]\]/e"); // [link|description]
+ $dst = array(format_tag('\\2', '\\4')); // [link|description]
+
+ return preg_replace($src, $dst, $text);
+}
+
function node_overview($query = array()) {
global $user;
diff --git a/modules/node/node.module b/modules/node/node.module
index e469bbfea..53c32219f 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -11,6 +11,13 @@ class Node {
}
}
+function node_macro($text) {
+ $src = array("/\[\[(([^\|]*?)(\|([^\|]*?))?)\]\]/e"); // [link|description]
+ $dst = array(format_tag('\\2', '\\4')); // [link|description]
+
+ return preg_replace($src, $dst, $text);
+}
+
function node_overview($query = array()) {
global $user;
diff --git a/modules/queue.module b/modules/queue.module
index d5844bfde..bf4cb7cc2 100644
--- a/modules/queue.module
+++ b/modules/queue.module
@@ -20,7 +20,7 @@ function queue_vote($id, $vote) {
if ($node = node_get_object(nid, $id)) {
- if (!field_get($node, "users", $user->userid)) {
+ if (!field_get($node->users, $user->userid)) {
// Update submission's score- and votes-field:
db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->userid, $vote) ."' WHERE nid = $id");
@@ -49,7 +49,7 @@ function queue_overview() {
$content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
$content .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
while ($node = db_fetch_object($result)) {
- if ($user->id == $node->author || field_get($node, "users", $user->userid)) $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". queue_score($node->nid) ."</TD></TR>\n";
+ if ($user->id == $node->author || field_get($node->users, $user->userid)) $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". queue_score($node->nid) ."</TD></TR>\n";
else $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n";
}
$content .= "</TABLE>\n";
@@ -65,7 +65,7 @@ function queue_node($id) {
$node = node_get_object(nid, $id);
- if ($user->id == $node->author || field_get($node, "users", $user->userid)) {
+ if ($user->id == $node->author || field_get($node->users, $user->userid)) {
header("Location: node.php?id=$node->nid");
}
else {