--- weblink.module	2004-07-09 17:37:22.000000000 +0200
+++ weblink.module	2004-07-11 14:18:33.000000000 +0200
@@ -16,7 +16,7 @@
  <li>The module exports both a page and a block that displays the registered sites ordered by their last modification date.</li>
 </ul>");
 
-    case "admin/system/modules#description":
+    case "admin/modules#description":
       return t("A weblinks module with integrated monitoring");
       
     case 'node/add#weblink':
@@ -37,17 +37,37 @@
   }
 }
 
+/**
+ * Implementation of hook_menu().
+ */
+function weblink_menu() {
+  global $user;
+
+  $items = array();
+
+  $items[] = array('path' => 'weblink', 'title' => t('links'),
+    'callback' => 'weblink_page',
+    'access' => user_access('access content'),
+    'type' => MENU_CALLBACK);
+  $items[] = array('path' => 'node/add/weblink', 'title' => t('weblink'),
+    'access' => user_access('create weblinks'));
+  $items[] = array('path' => 'weblink/blogmark/js', 'title' => t('blogmark'),
+    'callback' => 'weblink_blogmark_js',
+    'access' => TRUE,
+    'type' => MENU_CALLBACK);
+  $items[] = array('path' => 'weblink/blogmark', 'title' => t('blogmark'),
+    'callback' => 'weblink_blogmark',
+    'access' => TRUE,
+    'type' => MENU_CALLBACK);
+
+  return $items;
+}
+
 function weblink_link($type, $node = 0) {
   $links = array();
   
-  // System menu items
-  if ($type == "system") {
-    if (user_access("create weblinks")) {
-      menu("node/add/weblink", t("weblink"), "node_page");
-    }
-    menu("weblink/blogmark/js", t("blogmark"), "weblink_blogmark_js", 0, MENU_HIDE);
-    menu("weblink/blogmark", t("blogmark"), "weblink_blogmark", 0, MENU_HIDE);
-    menu("weblink", t("weblink"), "weblink_page", 0, MENU_HIDE);
+  if ($type == 'page' && user_access('access content')) {
+    $links[] = l(t('weblinks'), 'weblink');
   }
 
   // Node links for a weblink
@@ -216,7 +236,7 @@
     // Save node and note in the watchdog log
     $nid = node_save($node);
     if ($nid) {
-      watchdog("special", "{$node->type}: added '{$node->title}' blogmark", l(t("view post"), "node/view/$nid"));
+      watchdog("special", "{$node->type}: added '{$node->title}' blogmark", l(t("view post"), "node/$nid"));
       print theme("page", t("Thanks for your contribution to our blogmark collection. Now feel free to browse on or close this window."), t("Blogmark added"));
       return;
     }
@@ -360,7 +380,7 @@
   }
 }
 
-function weblink_form(&$node, $error, &$param) {
+function weblink_form(&$node, &$param) {
 
   $output .= form_textfield(t("Link"), "weblink", $node->weblink, 60, 128, t("Links should be submitted in a form similar to http://www.example.com/") . ($error['weblink'] ? $error["weblink"] : ''));
     
@@ -412,7 +432,7 @@
   if (db_num_rows($result) > 0) {
     $weblink = db_fetch_object($result);
     $othernode = node_load(array("nid" => $weblink->nid));
-    return array("weblink" => theme("error", t("A weblink %link-to-existing with that link already exists", array("%link-to-existing" => l($othernode->title, "admin/node/edit/$othernode->nid")))));
+    form_set_error('weblink', t('A weblink %link-to-existing using that link already exists', array("%link-to-existing" => l($othernode->title, 'node/' . $othernode->nid . '/edit'))));
   }
 }
 
@@ -491,7 +511,7 @@
   while($node = db_fetch_object($result)) {
     $node->body = htmlspecialchars($node->body);
     $comments = (int) module_invoke('comment', 'num_all', $node->nid);
-    $links[] = l($node->title, "weblink/goto/$node->nid", _weblink_attributes($node, 'body')) . " " . l("($comments)", "node/view/$node->nid", array('title' => format_plural($comments, '1 comment', '%count comments'), 'class' => "comment-count"));
+    $links[] = l($node->title, "weblink/goto/$node->nid", _weblink_attributes($node, 'body')) . " " . l("($comments)", "node/$node->nid", array('title' => format_plural($comments, '1 comment', '%count comments'), 'class' => "comment-count"));
   }
   
   $navlinks = array(l(t('read more'), "weblink/view/$tid"));
@@ -532,13 +552,13 @@
 
   $url = "";
   if (!ereg("^http://|https://|ftp://", $node->weblink)) {
-    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL for '%node'", array("%node" => $node->title)), l(t("edit site"), "admin/node/edit/". $node->nid));
+    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL for '%node'", array("%node" => $node->title)), l(t('edit site'), 'node/' . $node->nid . '/edit'));
   } else {
     $url = $node->weblink;
   }
 
   if (!ereg("^http://|https://|ftp://", $node->feed) && !$url) {
-    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL to monitor for '%node'", array("%node" => $node->title)), l(t("edit site"), "admin/node/edit/". $node->nid));
+    watchdog("warning", t("weblink") . ": " . t("invalid or missing URL to monitor for '%node'", array("%node" => $node->title)), l(t('edit site'), 'node/' . $node->nid . '/edit'));
   } else {
     // Overwrite previously set link
     $url = $node->weblink;
@@ -764,9 +784,9 @@
   $output .= " - ". $node->weblink ."</dt>";
   $output .= "<dd>" . $node->teaser;
   $output .= "<div class=\"links\">(". format_plural($node->click, "1 hit", "%count hits") . " - ";
-  $output .= l(t("detail"), "node/view/$node->nid", array("title" => t("Read details, read and add comments.")));
+  $output .= l(t("detail"), "node/$node->nid", array("title" => t("Read details, read and add comments.")));
   if (user_access("administer nodes")) {
-    $output .=  " - " . l(t("administer"), "admin/node/edit/$node->nid", array("title" => t("Administer this node.")));  
+    $output .=  " - " . l(t("administer"), 'node/' . $node->nid . '/edit', array("title" => t("Administer this node.")));  
   }
   $output .= ")</div>";
   $output .= "</dd>";
@@ -828,7 +848,7 @@
 }
 
 function _weblink_get_links($tid) {
-  $SQL = "SELECT n.nid, n.title, n.teaser, n.status, n.moderate, w.weblink, w.click FROM {node} n, {term_node} t, {weblink} w WHERE t.nid = n.nid AND n.nid = w.nid AND tid = %d AND n.type='weblink' AND n.status = 1 AND n.moderate = 0 ORDER BY n.created DESC";
+  $SQL = "SELECT n.nid, n.title, n.teaser, n.status, n.moderate, w.weblink, w.click FROM {node} n, {term_node} t, {weblink} w WHERE t.nid = n.nid AND n.nid = w.nid AND tid = %d AND n.type='weblink' AND n.status = 1 AND n.moderate = 0 ORDER BY n.title";
   if ($weblink_pager_term = variable_get("weblink_pager_term", 0)) {
     $result = pager_query(sprintf($SQL, $tid), $weblink_pager_term);
   }
@@ -849,7 +869,8 @@
     db_query("UPDATE {weblink} SET click = click + 1 where nid = '%d'", $id);
     $result = db_query("SELECT %s FROM {weblink} WHERE nid = '%d'", $type, $id);
     $wl = db_fetch_object($result);
-    header("HTTP/1.0 301 Moved Permanently");
+    // Didn't this use to work?
+    //header("HTTP/1.0 301 Moved Permanently");
     header("Location: " . $wl->$type);
   }
 }
