View Issue Details

IDProjectCategoryView StatusLast Update
0016599phpList 3 applicationUser Managementpublic15-07-15 12:56
Reporternicola 
PrioritynormalSeverityfeatureReproducibilityalways
Status newResolutionopen 
Product Version2.10.17 
Target VersionFuture developmentsFixed in Version 
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

Activities

nicola

21-04-12 20:46

reporter  

patch_importcsv.txt (1,531 bytes)
143a144
>   $_SESSION["exact_lists"] = $_POST["exact_lists"];
154a156,164
>   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);
> 
310a321
>   $count["list_remove"] = 0;
568a580
>           $subscribers[$listid][$userid] = 1;
611a624,638
>     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']++;
>             }
>           }
>         }
>       }
>     }
>     
621a649,651
>     if ($count["list_remove"]) {
>       $report .= sprintf('<br/>'.$GLOBALS['I18N']->get('%d emails removed from the lists'),$count["list_remove"]);
>     }
712a743,744
> <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)

michiel

23-04-12 13:03

manager   ~0051551


sounds good, and useful, thanks

michiel

08-07-15 09:02

manager   ~0056360

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

nicola

08-07-15 09: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.

michiel

15-07-15 12:51

manager   ~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.

gingerling

15-07-15 12: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.