From 8e94fe162587c3285554cd3f0eb87a43ffc079b0 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Wed, 18 Apr 2001 20:40:21 +0000
Subject: [PATCH] - structure.inc: added category_name($cid) and
 topic_name($tid).   They both return a linked string with the respective
 category,   or topic name.  Updated all themes to use these new functions.

- (stripped tabs from emsa files, nevermind)
---
 includes/structure.inc       | 17 +++++++++++++++++
 themes/example/example.theme |  4 +---
 themes/goofy/goofy.theme     |  2 +-
 themes/jeroen/jeroen.theme   | 11 ++++-------
 themes/marvin/marvin.theme   |  2 +-
 updates/2.00-to-x.xx.sql     |  8 ++++++++
 6 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/includes/structure.inc b/includes/structure.inc
index ff05b36d22fc..6d6655a3e339 100644
--- a/includes/structure.inc
+++ b/includes/structure.inc
@@ -22,27 +22,37 @@ function category_save($edit) {
   foreach ($edit as $key=>$value) db_query("UPDATE category SET $key = '". check_input($value) ."' WHERE cid = '$edit[cid]'");
 }
 
+
 // delete category $cid:
 function category_del($cid) {
   db_query("DELETE FROM category WHERE cid = '". check_input($cid) ."'");
   db_query("UPDATE node SET cid = 0 WHERE cid = '". check_input($cid) ."'");
 }
 
+// return post threshold:
 function category_post_threshold($cid) {
   $category = db_fetch_object(db_query("SELECT post AS threshold FROM category WHERE cid = '". check_input($cid) ."'"));
   return $category->threshold;
 }
 
+// return dump threshold:
 function category_dump_threshold($cid) {
   $category = db_fetch_object(db_query("SELECT dump AS threshold FROM category WHERE cid = '". check_input($cid) ."'"));
   return $category->threshold;
 }
 
+// return expiration threshold:
 function category_expire_threshold($cid) {
   $category = db_fetch_object(db_query("SELECT expire AS threshold FROM category WHERE cid = '". check_input($cid) ."'"));
   return $category->threshold;
 }
 
+// return linked string with name of category $cid:
+function category_name($cid) {
+  $category = category_get_object("cid", $cid);
+  return ($category) ? "<A HREF=\"index.php?category=$category->cid\">$category->name</A>" : "";
+}
+
 function category_form_select($type, $edit = array(), $size = 1) {
   $result = db_query("SELECT * FROM category WHERE type = '$type'");
   while ($category = db_fetch_object($result)) {
@@ -89,6 +99,13 @@ function topic_del($tid) {
   db_query("UPDATE node SET tid = 0 WHERE tid = '". check_input($tid) ."'");
 }
 
+// return linked string with name of topic $tid:
+function topic_name($tid, $name = 0) {
+  $topic = topic_get_object("tid", $tid);
+  $name = $name ? "<A HREF=\"index.php?topic=$topic->tid\">$topic->name</A> - $name" : "<A HREF=\"index.php?topic=$topic->tid\">$topic->name</A>";
+  return ($topic->pid) ? topic_name($topic->pid, $name) : $name;
+}
+
 // renders a HTML form to select one or more topics:
 function topic_form_select($edit = array(), $size = 1) {
   foreach (topic_tree() as $tid=>$name) {
diff --git a/themes/example/example.theme b/themes/example/example.theme
index 8b7d608c8746..32b7376de2c3 100644
--- a/themes/example/example.theme
+++ b/themes/example/example.theme
@@ -60,15 +60,13 @@ function story($story, $main = 0) {
                   <TD>
 
 <?php
-
                      echo strtr(t("by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "small")));
 ?>
 
                    </TD>
                    <TD ALIGN="right">
 <?php
-                     echo "<A HREF=\"index.php?category=$story->cid\">". check_output($story->category) ."</A> / <A HREF=\"index.php?topic=$story->tid\">". check_output($story->topic) ."</A>";
-
+                     echo category_name($story->cid) ." / ". topic_name($story->tid);
 ?>
                    </TD>
                  </TR>
diff --git a/themes/goofy/goofy.theme b/themes/goofy/goofy.theme
index 69b988730ddc..f60fbfb92450 100644
--- a/themes/goofy/goofy.theme
+++ b/themes/goofy/goofy.theme
@@ -117,7 +117,7 @@ function story($story, $main = 0) {
         <tr>
          <td class="lgl"><img src="themes/goofy/images/null.gif" alt=""></td>
          <td class="lgcnt"><small><?php echo strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?></small></td>
-         <td class="lgcnt" nowrap><div align="right"><?php echo  "<A HREF=\"index.php?category=$story->cid\">". check_output($story->category) ."</A> / <A HREF=\"index.php?topic=$story->tid\">". check_output($story->topic) ."</A>"; ?></div></td>
+         <td class="lgcnt" nowrap><div align="right"><?php echo category_name($story->cid) ." / ". topic_name($story->tid); ?></div></td>
          <td class="lgr"><img src="themes/goofy/images/null.gif" alt=""></td>
         </tr>
         <tr>
diff --git a/themes/jeroen/jeroen.theme b/themes/jeroen/jeroen.theme
index 003ae356088b..c93b8f4bc490 100644
--- a/themes/jeroen/jeroen.theme
+++ b/themes/jeroen/jeroen.theme
@@ -103,9 +103,7 @@ function story($story, $main = 0) {
                               <tr>
                                 <td align="left" background="themes/jeroen/images/menutitle.gif" nowrap>
                                   <FONT COLOR="#FEFEFE">
-
 <?php
-
                                     switch (rand(0,13)) {
                                       case 0: $how = "Yelled"; break;         case 1: $how = "Whispered"; break;
                                       case 2: $how = "Reported"; break;       case 3: $how = "Posted"; break;
@@ -116,14 +114,13 @@ function story($story, $main = 0) {
                                       case 12: $how = "Forged"; break;
                                       default: $how = "Sneaked through";
                                     }
-                                    echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp), "large")) ."</FONT>
+                                    echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp), "large")) ."</FONT>";
+?>
                                   </FONT>
                                 </td>
-                                <td align=\"right\" background=\"themes/jeroen/images/menutitle.gif\" nowrap>
-                                  <b><a href=\"index.php?category=$story->cid\">". check_output($story->category) ."</a> / <a href=\"index.php?topic=$story->tid\">". check_output($story->topic) ."</a></b>";
-
+<?php
+                                echo "<td align=\"right\" background=\"themes/jeroen/images/menutitle.gif\" nowrap><b>". category_name($story->cid) ." / ". topic_name($story->tid) ."</b>";
 ?>
-
                                 </td>
                               </tr>
                               <tr>
diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme
index 58472091908a..5a7e33545ae6 100644
--- a/themes/marvin/marvin.theme
+++ b/themes/marvin/marvin.theme
@@ -51,7 +51,7 @@ function story($story, $main = 0) {
      print " <TR VALIGN=\"bottom\"><TD COLSPAN=\"2\" BGCOLOR=\"#000000\" WIDTH=\"100%\"><IMG SRC=\"themes/marvin/images/pixel.gif\" WIDTH=\"1\" HEIGHT=\"0\" ALT=\"\"></TD></TR>\n";
      print " <TR>\n";
      print "  <TD>\n";
-     print "   <FONT COLOR=\"#7C7C7C\"><SMALL>". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?><?php print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL><A HREF=\"index.php?category=$story->cid\"><FONT COLOR=\"#83997A\">". check_output($story->category) ."</FONT></A> / <A HREF=\"index.php?topic=$story->tid\"><FONT COLOR=\"#83997A\">". check_output($story->topic) ."</FONT></A></SMALL>\n";
+     print "   <FONT COLOR=\"#7C7C7C\"><SMALL>". strtr(t("Submitted by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large"))); ?><?php print "</SMALL></FONT></TD><TD ALIGN=\"right\" VALIGN=\"top\" NOWRAP><SMALL>". category_name($story->cid) ." / ". topic_name($story->tid) ."</SMALL>\n";
      print "  </TD>\n";
      print " </TR>\n";
      print " <TR><TD COLSPAN=\"2\">&nbsp;</TD></TR>\n";
diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql
index f5e3f08177cc..5688d6f5ba6f 100644
--- a/updates/2.00-to-x.xx.sql
+++ b/updates/2.00-to-x.xx.sql
@@ -4,6 +4,14 @@ ALTER TABLE node ADD tid int(10) unsigned DEFAULT '0' NOT NULL;
 ALTER TABLE story DROP section;
 ALTER TABLE comments ADD KEY(lid);
 
+CREATE TABLE cvs (
+  user varchar(32) DEFAULT '' NOT NULL,
+  files text,
+  status int(2) DEFAULT '0' NOT NULL,
+  message text,
+  timestamp int(11) DEFAULT '0' NOT NULL
+);
+
 CREATE TABLE category (
   cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
   name varchar(32) DEFAULT '' NOT NULL,
-- 
GitLab