Index: modules/notify/notify.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/notify/notify.module,v
retrieving revision 2.49
diff -u -r2.49 notify.module
--- modules/notify/notify.module	9 Apr 2004 14:51:12 -0000	2.49
+++ modules/notify/notify.module	2 Jul 2004 06:31:54 -0000
@@ -4,7 +4,7 @@
 function notify_help($section) {
   switch ($section) {
     case 'admin/system/modules#description':
-      $output = t("Enables notifications by email.");
+      $output = t("Enables e-mail notifications.");
       break;
   }
   return $output;
@@ -41,7 +41,6 @@
 }
 
 function notify_send() {
-  global $base_url;
   $period = variable_get("notify_send_last", time() - variable_get("notify_send", 86400));
 
   // Fetch all new nodes
@@ -76,12 +75,12 @@
         if ($notify->moderate) {
           $body .= strtr(t("%status %type by %author: %title"), array("%status" => "queued", "%type" => $node->type, "%title" => $node->title, "%author" => ($node->name ? $node->name : variable_get(anonymous, "Anonymous")))) ."\n";
           $body .= notify_content($node, $notify);
-          $body .= "  [ ". url("queue/view/$node->nid") ." ]\n\n";
+          $body .= "  [ ". url("queue/view/$node->nid", NULL, NULL, TRUE) ." ]\n\n";
         }
         elseif (!$notify->moderate && $node->nid) {
           $body .= strtr(t("%status %type by %author: %title"), array("%status" => "published", "%type" => $node->type, "%title" => $node->title, "%author" => ($node->name ? $node->name : variable_get(anonymous, "Anonymous")))) ."\n";
           $body .= notify_content($node, $notify);
-          $body .= "  [ ". url("node/view/$node->nid") ." ]\n\n";
+          $body .= "  [ ". url("node/view/$node->nid", NULL, NULL, TRUE) ." ]\n\n";
         }
       }
     }
@@ -100,7 +99,7 @@
         }
         foreach ($comment as $c) {
           $body .= "  ". strtr(t("%title by %author"), array("%title" => $c->subject, "%author" => ($c->name ? $c->name : variable_get(anonymous, "Anonymous")))) ."\n"
-                .  "    ". url("node/view/$nid/$c->cid#$c->cid") ."\n\n";
+                .  "    ". url("node/view/$nid/$c->cid#$c->cid", NULL, NULL, TRUE) ."\n\n";
         }
       }
     }
@@ -110,8 +109,8 @@
       $body = t("Greetings") ." ". $user->name .",\n\n$body";
 
       $body .= "\n-- \n";
-      $body .= t("This is an automatic mail from") ." ". variable_get("site_name", "drupal") ."\n";
-      $body .= t("To stop receiving these mails go to") ." $base_url/notify\n";
+      $body .= t("This is an automatic e-mail from") ." ". variable_get("site_name", "drupal") ."\n";
+      $body .= t("To stop receiving these e-mails go to") ." ". url("user/notify", NULL, NULL, TRUE) ."\n";
 
       if (!user_mail($to, $subject, wordwrap($body, 72), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: <$from>\nErrors-to: $from\n")) {
         db_query("UPDATE {notify} SET attempts = attempts + 1 WHERE uid = %d", $user->uid);
@@ -142,10 +141,10 @@
 function notify_link($type) {
   if ($type == "system") {
     if (user_access('access notify')) {
-      menu("notify", t("my notify settings"), "notify_page", 0);
+      menu("user/notify", t("E-mail notification"), "notify_page");
     }
     if (user_access("administer notify")) {
-      menu("admin/user/notify", "notifications", "notify_admin", NULL, 8);
+      menu("admin/user/notify", t("notifications"), "notify_admin");
     }
   }
 
@@ -170,10 +169,10 @@
         $result = db_query("SELECT u.name, u.mail, n.status, n.node, n.teasers, n.comment FROM {users} u LEFT JOIN {notify} n ON u.uid = n.uid WHERE u.uid = %d AND u.status = 1 ORDER BY u.name", $user->uid);
         $notify = db_fetch_object($result);
 
-        $form .= form_select(t("Notify status"), "status", $notify->status, array(t("Disabled"), t("Enabled")), t("Do you wish to receive periodic emails when new content is posted?"));
-        $form .= form_select(t("Notify new content"), "node", $notify->node, array(t("Disabled"), t("Enabled")), t("Include new content in the notification mail."));
-        $form .= form_select(t("Content"), "teasers", $notify->teasers, array(t("Title only"), t("Title + Teaser"), t("Title + Body")), t("Select the amount of each post that you would like to see in your notification emails."));
-        $form .= form_select(t("Notify new comments"), "comment", $notify->comment, array(t("Disabled"), t("Enabled")), t("Include new comments in the notification mail."));
+        $form .= form_select(t("Notify status"), "status", $notify->status, array(t("Disabled"), t("Enabled")), t("Do you wish to receive periodic e-mails when new content is posted?"));
+        $form .= form_select(t("Notify new content"), "node", $notify->node, array(t("Disabled"), t("Enabled")), t("Include new content in the notification e-mail."));
+        $form .= form_select(t("Content"), "teasers", $notify->teasers, array(t("Title only"), t("Title + Teaser"), t("Title + Body")), t("Select the amount of each post that you would like to see in your notification e-mails."));
+        $form .= form_select(t("Notify new comments"), "comment", $notify->comment, array(t("Disabled"), t("Enabled")), t("Include new comments in the notification e-mail."));
         $form .= form_submit(t("Save settings"));
 
         print theme("page", form($form));
@@ -185,17 +184,29 @@
 }
 
 function notify_admin() {
+  // 040701AH Fixed to show/edit all users instead of only users that have set 
+  // notification settings, fixed theming.
+  
   $op = $_POST["op"];
 
   switch ($op) {
     case "Save":
       $edit = $_POST["edit"];
       foreach ($edit as $uid=>$settings) {
-        db_query("UPDATE {notify} SET node = %d, teasers = %d, comment = %d WHERE uid = %d", $settings['node'], $settings['teasers'], $settings['comment'], $uid);
+        // 040701AH Changed to create a new entry in the db in the user doesn't
+        // have one yet
+        $result = db_query("SELECT uid FROM {notify} WHERE uid = %d", $uid);
+
+        if (is_object(db_fetch_object($result))) {
+          db_query("UPDATE {notify} SET status = %d, node = %d, teasers = %d, comment = %d WHERE uid = %d", $settings['status'], $settings['node'], $settings['teasers'], $settings['comment'], $uid);
+        }
+        else if ($settings['status']) {
+          db_query("INSERT INTO {notify} (uid,status,node,teasers,comment) VALUES (%d,%d,%d,%d,%d)", $uid, $settings['status'], $settings['node'], $settings['teasers'], $settings['comment']);
+        }
       }
     default:
-      $result = db_query("SELECT u.uid, u.name, u.mail, n.* FROM {users} u LEFT JOIN {notify} n ON u.uid = n.uid WHERE n.status = 1 AND u.status = 1 ORDER BY u.name");
-      $header = array (t("username"), t("email address"), t("content"), t("teasers"), t("comment"), t("failed attempts"));
+      $result = db_query("SELECT u.uid, u.name, u.mail, n.status, n.node, n.comment, n.attempts, n.teasers FROM {users} u LEFT JOIN {notify} n ON n.uid = u.uid WHERE u.status = 1 ORDER BY u.name");
+	 $header = array (t("username"), t("e-mail address"), t("enable"), t("content"), t("teasers"), t("comment"), t("failed attempts"));
       $i = 0;
       while ($notify = db_fetch_object($result)) {
         $rows[$i][] = format_name($notify);
@@ -203,20 +214,20 @@
         // 030312AX TODO: it really is a shame that we cannot use form_* functions
         // here (as they wrap everything into <p>title description</p>). implement
         // this once (see mailing list)!
-        //$rows[$i][] = form_hidden("$notify->uid][status", 0) ."<input type=\"checkbox\" name=\"edit[$notify->uid][status]\"". ($notify->status ? " checked=\"checked\"" : "") .">";
-        $rows[$i][] = form_hidden("$notify->uid][node", 0) .'<input type="checkbox" name="edit['. $notify->uid .'][node]" value="1"'. ($notify->node ? ' checked="checked"' : '') .'>';
+        $rows[$i][] = '<input type="checkbox" name="edit['. $notify->uid .'][status]" value="1"'. ($notify->status ? ' checked="checked"' : '') .'>';
+        $rows[$i][] = '<input type="checkbox" name="edit['. $notify->uid .'][node]" value="1"'.   ($notify->node   ? ' checked="checked"' : '') .'>';
         $select = "";
         foreach (array(t("Title only"), t("Title + Teaser"), t("Title + Body")) as $key => $choice) {
           $select .= '<option value="'. $key .'"'. ($key == $notify->teasers ? " selected=\"selected\"" : "") .">$choice</option>";
         }
         $rows[$i][] = '<select name="edit['. $notify->uid .'][teasers]">'. $select .'</select>';
-        $rows[$i][] = form_hidden("$notify->uid][comment", 0) .'<input type="checkbox" name="edit['. $notify->uid .'][comment]" value="1"'. ($notify->comment ? ' checked="checked"' : '') .">";
+        $rows[$i][] = '<input type="checkbox" name="edit['. $notify->uid .'][comment]" value="1"'. ($notify->comment ? ' checked="checked"' : '') .">";
         $rows[$i][] = $notify->attempts;
         $i++;
       }
-      $rows[$i][] = form_submit("Save");
       $output = theme("table", $header, $rows);
-      print form($output);
+      $output .= form_submit("Save");
+      print theme("page", form($output));
   }
 }
 
