View Issue Details

IDProjectCategoryView StatusLast Update
0015274phplist applicationSubscribe Processpublic02-11-12 12:29
ReporterJuB 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionFutureDevelopments 
Target Version4.0.xFixed in Version2.11.8 
Summary0015274: Unsubscribe from inactive/private lists
DescriptionI have a combination of public lists (active with a subscribe page), private lists (deactivated, no subscribe page), and semi-private lists (active, but with own subscribe page). One user may be on any number of these lists.

The problem is that, in order for a user to unsubscribe from specific lists via the preferences page, the lists must be 1) active 2) listed on the default subscribe page. These are not desirable, because I don't want to advertise the private and semi-private lists to anyone who is not already on these lists, either on a subscribe page or their preferences page.

I've found this patch on internet and it works great for me, I suggest that this is the way it should be in a standard version.

The patcher says:

QUOTE:
"After giving it some thought, I determined that I needed to modify the code to display ALL lists a user is subscribed to on their preferences page, in addition to the default behavior of showing active lists enabled for that subscribe page. Once they unsubscribe from a list not enabled for that page, it disappears as expected.

I have provided my modifications as a patch below. I'm not too familiar with the phplist code, but it seems to work as expected.

Is there a better way to solve this problem, or can a solution like this be added to a future release? Perhaps as a configuration option ("Show all lists user is subscribed to on preferences page.")"
// END OF QUOTE

I'm attaching his patch - it works for me too.
TagsNo tags attached.

Activities

03-05-09 20:55

 

suscribelib2.php_patch.txt (3,091 bytes)
--- subscribelib2.orig.php	2009-02-26 11:12:21.000000000 -0700
+++ subscribelib2.php	2009-02-26 11:14:16.000000000 -0700
@@ -444,10 +444,15 @@
 
   # subscribe to the lists
   # first take them off the ones, then re-subscribe
-  if ($subscribepagedata["lists"]) {
-    $subscribepagedata["lists"] = preg_replace("/^\,/","",$subscribepagedata["lists"]);
-    Sql_query(sprintf('delete from %s where userid = %d and listid in (%s)',$GLOBALS["tables"]["listuser"],$userid,$subscribepagedata["lists"]));
-    $liststat = explode(',',$subscribepagedata["lists"]);
+  if (is_array($_POST["listname"])) {
+    # discover all of the lists on our subscribe page
+    foreach($_POST["listname"] as $key => $val) {
+      $listnames[]=$key;
+    }
+    $listnames = implode(',',$listnames); 
+
+    Sql_query(sprintf('delete from %s where userid = %d and listid in (%s)',$GLOBALS["tables"]["listuser"],$userid,$listnames));
+    $liststat = explode(',',$listnames);
   } else {
     Sql_query(sprintf('delete from %s where userid = %d',$GLOBALS["tables"]["listuser"],$userid));
   }
@@ -602,29 +607,34 @@
   } else {
     $list = '';
   }
-  $subselect = "";$listset = array();
-
   $showlists = explode(",",$lists_to_show);
-  foreach ($showlists as $listid)
-    if (preg_match("/^\d+$/",$listid))
-      array_push($listset,$listid);
-  if (sizeof($listset) >= 1) {
-    $subselect = "where id in (".join(",",$listset).") ";
-  }
 
   $some = 0;
   $html = '<ul class="list">';
-  $result = Sql_query("SELECT * FROM {$GLOBALS["tables"]["list"]} $subselect order by listorder, name");
+  $result = Sql_query("SELECT * FROM {$GLOBALS["tables"]["list"]} order by listorder, name");
   while ($row = Sql_fetch_array($result)) {
-    if ($row["active"]) {
+    # check to see if list is in $showlists
+    $show = 0;
+    foreach($showlists as $list) { 
+      if ($list == $row["id"])
+        $show = 1;
+    }
+
+    # check to see if user is subscribed to this list
+    $subscribed = 0;
+    if ($userid) {
+      $req = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and listid = %d', $GLOBALS["tables"]["listuser"],$userid,$row["id"]));
+      if (Sql_Affected_Rows())
+        $subscribed=1;
+    }
+
+    # display list if user is subscribed, or if it is an active list from $showlists
+    if ($subscribed || $row["active"] && $show) {
       $html .= '<li class="list"><input type="checkbox" name="list['.$row["id"] . ']" value=signup ';
       if (isset($list[$row["id"]]) && $list[$row['id']] == "signup")
         $html .= "checked";
-      if ($userid) {
-        $req = Sql_Fetch_Row_Query(sprintf('select userid from %s where userid = %d and listid = %d',
-          $GLOBALS["tables"]["listuser"],$userid,$row["id"]));
-        if (Sql_Affected_Rows())
-          $html .= "checked";
+      if ($subscribed) {
+        $html .= "checked";
       }
       $html .= " /><b>".stripslashes($row["name"]).'</b><div class="listdescription">';
       $desc = nl2br(StripSlashes($row["description"]));

h2b2

30-04-10 02:26

manager   ~0050983

Related to this forum thread: http://forums.phplist.com/viewtopic.php?f=7&t=23937

michiel

02-11-12 12:29

manager   ~0051838

option PREFERENCEPAGE_SHOW_PRIVATE_LISTS added