View Issue Details

IDProjectCategoryView StatusLast Update
0016599phpList 3 applicationAdmin Managementpublic15-07-15 13:56
Reporternicola Assigned To 
Status newResolutionopen 
Product Version2.10.17 
Target VersionFuture developments 
Summary0016599: Allow to upload exact recipient-lists via CSV Import
DescriptionWe manage our readers in a different database and upload the latest adresses once a month via CSV Import. Adding new readers worked like a charm, but removing old readers worked not automatically yet.

The patch attached fixes this. It adds an additional checkbox to the import form. If checked emails not in the csv file get removed form the selected lists (but not from the database)
Additional InformationPatch is against phplist/admin/commonlib/pages/importcsv.php from version 2.10.17
TagsSubscriber Management and data accessibility



21-04-12 21:46


patch_importcsv.txt (1,531 bytes)   
>   $_SESSION["exact_lists"] = $_POST["exact_lists"];
>   while (list($key,$listid) = each($_SESSION["lists"])) {
>     $req = Sql_Query(sprintf('select userid from %s where listid=%s order by userid asc',$tables["listuser"],$listid));
>     $subscribers[$listid] = array();
>     while ($row = Sql_Fetch_Array($req)) {
>       $subscribers[$listid][$row["userid"]] = 0;
>     }
>   }
> //   print_r($subscribers);
>   $count["list_remove"] = 0;
>           $subscribers[$listid][$userid] = 1;
>     if ($_SESSION["exact_lists"]) {
>       foreach($subscribers as $listid => $list) {
>         foreach($list as $userid => $keep) {
>           if ($keep == 0) {
>             $query = sprintf("delete from %s where userid = %s and listid = %s", $tables["listuser"], $userid, $listid);
> //             print $query."<br />";
>             $result = Sql_query($query);
>             if (Sql_Affected_Rows() == 1) {
>               $count['list_remove']++;
>             }
>           }
>         }
>       }
>     }
>     if ($count["list_remove"]) {
>       $report .= sprintf('<br/>'.$GLOBALS['I18N']->get('%d emails removed from the lists'),$count["list_remove"]);
>     }
> <tr><td colspan=2><?php echo $GLOBALS['I18N']->get('Check below to set the given list to exactly the recipients in the file.')?></td></tr>
> <tr><td><?php echo $GLOBALS['I18N']->get('Exact Lists')?>:</td><td><input type="checkbox" name="exact_lists" value="yes"></td></tr>
patch_importcsv.txt (1,531 bytes)   


23-04-12 14:03

administrator   ~0051551

sounds good, and useful, thanks


08-07-15 10:02

administrator   ~0056360

it's probably easier to do a "delete all from list" before starting the import


08-07-15 10:33

reporter   ~0056362

True, but that might become a problem if you ever allow for per-list configuration. In any case, I don't depend on this feature anymore. So feel free to implement whatever you prefer.


15-07-15 13:51

administrator   ~0056448

this could be done two ways:

1. create a new list every time there's a new import. The nice side effect is that there is a history of list membership, which might allow for cross-referencing

2. add a checkbox "erase all before import" (text to be confirmed) which then does a "delete all from list" before doing the import.

I'll leave it up to the community to decide which route to go.


15-07-15 13:56

manager   ~0056449

I think making a new list every time sounds messy, especially if you have several lists that you keep updating.

2. could be better. You could call it something like "synchronise list" - it could delete all first, or simply tell you which subscribers are in the phpList list but not in csv list and ask if you want to remove them from the list.