Skip to content

Commit d8cd549

Browse files
committed
- Added Marco's long-awaited taxonmy module and patches - a replacement for the meta system. The patches add some extra functionality to the comment system (for example, comments can be set read-only) and fix a couple of small problems. + I integrated the required SQL updates from the varius *.mysql files into the "update.php" script. Upgrading should be easy ... + I did not apply/commit the "user.diff" as requested by Marco ... + I didn't know what to do with "forum.module" and "forum2.module": what do you want me to do with it Marco? Which one should go in? + Can we remove "node_index()" now; both from "node.module" and the themes? + Thanks Marco!
1 parent e5fd671 commit d8cd549

File tree

21 files changed

+1514
-173
lines changed

21 files changed

+1514
-173
lines changed

database/database.mysql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Host: localhost Database: drupal
44
#--------------------------------------------------------
5-
# Server version 3.23.38
5+
# Server version 3.23.38
66

77
#
88
# Table structure for table 'access'

includes/common.inc

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ function object2array($node) {
7878
return $array;
7979
}
8080

81-
function path_uri() {
81+
function path_uri($brief = 0) {
8282
global $HTTP_HOST, $REQUEST_URI;
83-
return "http://". $HTTP_HOST . substr($REQUEST_URI, 0, strrpos($REQUEST_URI, "/")) ."/";
83+
$path = $HTTP_HOST . substr($REQUEST_URI, 0, strrpos($REQUEST_URI, "/")) ."/";
84+
if (!$brief) {
85+
$path = "http://". $path;
86+
}
87+
return $path;
8488
}
8589

8690
function path_img() {
@@ -148,7 +152,7 @@ function variable_del($name) {
148152
* Format a single result entry of a search query:
149153
*
150154
* @param $item a single search result as returned by <module>_search of type
151-
* array("count" => ..., "link" => ..., "title" => ...,
155+
* array("count" => ..., "link" => ..., "title" => ...,
152156
* "user" => ..., "date" => ..., "keywords" => ...)
153157
* @param $type module type of this item
154158
*/
@@ -164,14 +168,14 @@ function search_item($item, $type) {
164168
* Render a generic search form.
165169
*
166170
* "Generic" means "universal usable" - that is, usable not only from
167-
* module.php?mod=search, but also as a simple seach box (without
168-
* "Restrict search to", help text, etc) from theme's header etc.
169-
* This means: provide options to only conditionally render certain
171+
* module.php?mod=search, but also as a simple seach box (without
172+
* "Restrict search to", help text, etc) from theme's header etc.
173+
* This means: provide options to only conditionally render certain
170174
* parts of this form.
171175
*
172176
* @param $action Form action. Defaults to module.php?mod=search.
173177
* @param $query Query string. Defaults to global $keys.
174-
* @param $options != 0: Render additional form fields/text
178+
* @param $options != 0: Render additional form fields/text
175179
* ("Restrict search to", help text, etc).
176180
*/
177181
function search_form($action = 0, $query = 0, $options = 0) {
@@ -239,11 +243,11 @@ function search_data() {
239243
/**
240244
* Display the search form and the resulting data.
241245
*
242-
* @param $type If set, search only nodes of this type.
246+
* @param $type If set, search only nodes of this type.
243247
* Otherwise, search all types.
244248
* @param $action Form action. Defaults to module.php?mod=search.
245249
* @param $query Query string. Defaults to global $keys.
246-
* @param $options != 0: Render additional form fields/text
250+
* @param $options != 0: Render additional form fields/text
247251
* ("Restrict search to", help text, etc).
248252
*/
249253
function search_type($type = 0, $action = 0, $query = 0, $options = 0) {
@@ -256,6 +260,22 @@ function search_type($type = 0, $action = 0, $query = 0, $options = 0) {
256260
return search_form($action, $query, $options) . search_data();
257261
}
258262

263+
function drupal_str_replace($from, $to, $subject) {
264+
265+
/*
266+
** Multiple item replace which works for *all* PHP versions
267+
** (PHP 4.05+ supports this natively using similar syntax).
268+
** $from and $to should be same sized arrays, $subject is the
269+
** source text.
270+
*/
271+
272+
for ($i = 0; $i < count($from); $i++) {
273+
$subject = str_replace($from[$i], $to[$i], $subject);
274+
}
275+
276+
return $subject;
277+
}
278+
259279
function drupal_goto($url) {
260280

261281
/*
@@ -551,12 +571,12 @@ function form_textarea($title, $name, $value, $cols, $rows, $description = 0) {
551571
return form_item($title, "<textarea wrap=\"virtual\" cols=\"$cols\" rows=\"$rows\" name=\"edit[$name]\">". check_form($value) ."</textarea>", $description);
552572
}
553573

554-
function form_select($title, $name, $value, $options, $description = 0, $extra = 0) {
574+
function form_select($title, $name, $value, $options, $description = 0, $extra = 0, $multiple = 0) {
555575
if (count($options) > 0) {
556-
foreach ($options as $key => $choice) {
576+
foreach ($options as $key=>$choice) {
557577
$select .= "<option value=\"$key\"". (is_array($value) ? (in_array($key, $value) ? " selected=\"selected\"" : "") : ($key == $value ? " selected=\"selected\"" : "")) .">". check_form($choice) ."</option>";
558578
}
559-
return form_item($title, "<select name=\"edit[$name]\"". ($extra ? " $extra" : "") .">$select</select>", $description);
579+
return form_item($title, "<select name=\"edit[$name]".($multiple ? "[]" : "")."\"" .($multiple ? " multiple " : "").($extra ? " $extra" : "") .">$select</select>", $description);
560580
}
561581
}
562582

@@ -595,20 +615,20 @@ function field_merge($a, $b) {
595615

596616
function link_page() {
597617
global $custom_links;
598-
618+
599619
if (is_array($custom_links)) {
600620
return $custom_links;
601621
}
602622
else {
603623
$links[] = "<a href=\"index.php\">". t("home") ."</a>";
604-
foreach (module_list() as $name) {
624+
foreach (module_list() as $name) {
605625
if (module_hook($name, "link")) {
606626
$links = array_merge($links, module_invoke($name, "link", "page"));
607-
}
627+
}
608628
}
609629
return $links;
610630
}
611-
}
631+
}
612632

613633
function link_node($node, $main = 0) {
614634
foreach (module_list() as $name) {

modules/blog.module

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ function blog_form(&$node, &$help, &$error) {
243243
$output .= form_textarea(t("Teaser"), "teaser", $node->teaser, 60, 5, $error["teaser"]);
244244
}
245245

246+
$output .= implode("<p>", taxonomy_node_form("blog", $node));
247+
246248
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
247249

248250
return $output;

modules/blog/blog.module

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ function blog_form(&$node, &$help, &$error) {
243243
$output .= form_textarea(t("Teaser"), "teaser", $node->teaser, 60, 5, $error["teaser"]);
244244
}
245245

246+
$output .= implode("<p>", taxonomy_node_form("blog", $node));
247+
246248
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
247249

248250
return $output;

modules/comment.module

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,30 @@ function comment_edit($cid) {
145145
}
146146

147147
function comment_reply($pid, $nid) {
148-
global $theme;
149-
150-
if ($pid) {
151-
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$pid'"));
152-
comment_view($comment, t("reply to this comment"));
153-
}
154-
else {
155-
node_view(node_load(array("nid" => $nid)));
156-
$pid = 0;
157-
}
148+
global $theme, $node;
149+
150+
// we must provide a taxonomy context for user_access()
151+
$context->nid = $nid;
152+
if (user_access("access comments", $context)) {
153+
if ($pid) {
154+
$comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '$pid'"));
155+
comment_view($comment, t("reply to this comment"));
156+
}
157+
else {
158+
node_view(node_load(array("nid" => $nid)));
159+
$pid = 0;
160+
}
158161

159-
if (user_access("post comments")) {
160-
$theme->box(t("Reply"), comment_form(array("pid" => $pid, "nid" => $nid)));
161-
}
162-
else {
163-
$theme->box(t("Reply"), t("You are not authorized to post comments."));
162+
if (node_comment_mode($nid) == 1) {
163+
$theme->box(t("Reply"), t("This discussion is closed: you can't post new comments."));
164+
} else if (user_access("post comments", $context)) {
165+
$theme->box(t("Reply"), comment_form(array("pid" => $pid, "nid" => $nid)));
166+
}
167+
else {
168+
$theme->box(t("Reply"), t("You are not authorized to post comments."));
169+
}
170+
} else {
171+
$theme->box(t("Reply"), t("You are not authorized to view comments."));
164172
}
165173
}
166174

@@ -205,7 +213,8 @@ function comment_preview($edit) {
205213
function comment_post($edit) {
206214
global $theme, $user;
207215

208-
if (user_access("post comments")) {
216+
$context->nid = $edit["nid"];
217+
if (user_access("post comments", $context) && node_comment_mode($edit["nid"]) == 2) {
209218

210219
/*
211220
** Validate the comment's subject. If not specified, extract
@@ -378,6 +387,11 @@ function comment_links($comment, $return = 1) {
378387
$links[] = "<a href=\"admin.php?mod=comment&op=edit&id=$comment->cid\" title=\"". t("Administer this comment.") ."\"><span style=\"color: $theme->type;\">". t("administer") ."</span></a>";
379388
}
380389

390+
// here we should check if this node has read-only comments, but we already check on submit
391+
// and this way we save a query. it's just a cosmetic issue. otherwise just uncomment next
392+
// line and related bracket some lines below
393+
394+
//if (node_comment_mode($comment->nid)) {
381395
if (user_access("post comments")) {
382396
if (comment_access("edit", $comment)) {
383397
$links[] = "<a href=\"module.php?mod=comment&op=edit&id=$comment->cid\" title=\"". t("Make changes to your comment.") ."\"><span style=\"color: $theme->type\">". t("edit your comment") ."</span></a>";
@@ -386,6 +400,7 @@ function comment_links($comment, $return = 1) {
386400
$links[] = "<a href=\"module.php?mod=comment&op=reply&id=$comment->nid&pid=$comment->cid\" title=\"". t("Reply to this comment.") ."\"><span style=\"color: $theme->type;\">". t("reply to this comment") ."</span></a>";
387401
}
388402
}
403+
//}
389404

390405

391406
return $theme->links($links);
@@ -553,10 +568,10 @@ function comment_search($keys) {
553568
// index.
554569
//
555570
// "select"'s value is used to relate the data from the specific nodes
556-
// table to the data that the search_index table has in it, and the the
571+
// table to the data that the search_index table has in it, and the the
557572
// do_search functino will rank it.
558573
//
559-
// The select must always provide the following fields - lno, title,
574+
// The select must always provide the following fields - lno, title,
560575
// created, uid, name, count
561576
//
562577
// The select statement may optionally provide "nid", which is a secondary
@@ -565,7 +580,7 @@ function comment_search($keys) {
565580
$find = do_search(array("keys" => $keys,
566581
"type" => "comment",
567582
"select" => "select s.lno as lno, c.nid as nid, c.subject as title, c.timestamp as created, u.uid as uid, u.name as name, s.count as count FROM search_index s, comments c LEFT JOIN users u ON c.uid = u.uid WHERE s.lno = c.cid AND s.type = 'comment' AND s.word like '%'"));
568-
583+
569584
return $find;
570585
}
571586

@@ -597,11 +612,15 @@ function comment_link($type, $node = 0, $main = 0) {
597612
else {
598613
/*
599614
** Node page: add a "post comment" link if the user is allowed to
600-
** post comments.
615+
** post comments and if this node is not read-only
601616
*/
602617

603618
if (user_access("post comments")) {
604-
$links[] = "<a href=\"module.php?mod=comment&op=reply&id=$node->nid#comment\" title=\"". t("Share your thoughts and opinions related to this posting.") ."\">". t("add new comment") ."</a>";
619+
if ($node->comment == 2) {
620+
$links[] = "<a href=\"module.php?mod=comment&op=reply&id=$node->nid#comment\" title=\"". t("Share your thoughts and opinions related to this posting.") ."\">". t("add new comment") ."</a>";
621+
} else {
622+
$links[] = t("This discussion is closed: you can't post new comments.");
623+
}
605624
}
606625
}
607626
}
@@ -751,14 +770,14 @@ function comment_update_index() {
751770
// Return an array of values to dictate how to update the search index
752771
// for this particular type of node.
753772
//
754-
// "last_update"'s value is used with variable_set to set the
773+
// "last_update"'s value is used with variable_set to set the
755774
// last time this node type (comment) had an index update run.
756775
//
757776
// "node_type"'s value is used to identify the node type in the search
758777
// index (commentt in this case).
759778
//
760779
// "select"'s value is used to select the node id and text fields from
761-
// the table we are indexing. In this case, we also check against the
780+
// the table we are indexing. In this case, we also check against the
762781
// last run date for the comments update.
763782
return array("last_update" => "comment_cron_last",
764783
"node_type" => "comment",

0 commit comments

Comments
 (0)