From cc4d038a9c3c165b354515bd4e5f84344a971474 Mon Sep 17 00:00:00 2001 From: lbergman Date: Fri, 4 Aug 2000 19:36:22 +0000 Subject: [PATCH] Removed, now a plugin, no idea if this will be included with the source tree. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@679 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/addressbook_csvimport.php | 410 ---------------------------------- 1 file changed, 410 deletions(-) delete mode 100644 src/addressbook_csvimport.php diff --git a/src/addressbook_csvimport.php b/src/addressbook_csvimport.php deleted file mode 100644 index 1dc1f1e2..00000000 --- a/src/addressbook_csvimport.php +++ /dev/null @@ -1,410 +0,0 @@ -
\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
" . _("Please select a file for uploading. You can do this by clicking on the browse button on the ") . "" . _("Address Book") . " " . _("page.") . "
\n"; - echo "\n"; - exit; - } -**/ - - /** - ** Script-wide vars. Used all over the place or something you might want to change later. - ** $example -->Sets how many rows of user data the script will use to play with before final write. - ** $abook ---->Setup the addressbook functions for Pallo's Addressbook. - ** $tabindex ->A starting value for the loop to assign a tabindex value for the generated text input fields. - ** As long as this value is greater than the number of static submit buttons all should work fine. - **/ - $tabindex = 10; - $example = 6; - $abook = addressbook_init(true, true); - - /** See if the submit button has been clicked, if not, set up arrays with empty elements - ** To change the number of text boxes displayed in headers, add or delete ,"" 's - **/ - if(!$submit || $reset){ - $nickname = array("","",""); - $firstname = array("","",""); - $lastname = array("","",""); - $email = ""; - $label = array("","","","","","","","",""); - } - - if($flag <= 1) { // If first run of script, setup the filename to copy - $tempfilename = ($username . (time()+2592000)); - $nameholder = $tempfilename; - if(copy($smusercsv, "$attachment_dir$tempfilename")) { // Set up variable to use in printing status - $goodcopy = true; - } else { - $goodcopy = false; - } - } elseif($flag >= 2) { // If not use the name already set up - $tempfilename = $nameholder; - } - - // table with directions - if(!$finish) { - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo " \n"; - echo " "; - echo " \n"; - echo "
", _("All the steps required to complete the process are listed below"), "
"; - echo _("You uploaded a file named: "); - echo "$smusercsv_name "; - echo "
"; - if(!$goodcopy && $flag == 0) { // print correct status of file copying - echo _("Failed to create working copy, Please try again."); - } else { - echo _("Created working copy, continuing with process..."); - } - echo "
", _("Displaying a small set of your data."), "
", _("Arrange your data to fit the 5 address book fields. "), _("Do this by inserting the data's field number under the field for which you wish it to be included into the address book. "), _("For example: fields 5, 6, and 7 need to go into the info field 5. "), _("The boxes under field 5 would contain 5, 6, and 7 in seperate boxes. "), "
", _("Submit Your reorganized data."), "      ", "\n"; - echo " ", "      \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " ", _("Erase entries and re-enter field numbers."), "      ", "\n"; - echo " \n"; - echo "
", _("View full set of imported records in their new format."), "      \n"; - echo " \n"; - echo " "; - echo "
", _("Omit individual records which are not to be included."), "\n"; - echo " ", _("To the left of each field below the \"Omit\" heading is a checkbox."), "\n"; - echo " ", _("Click this checkbox to omit individual records."), "\n"; - echo "
", _("Final approval. "); - echo " ", _("After reviewing the rearranged data for accuracy, click \"Finish\"."), "      \n"; - echo " \n"; - echo "
\n"; - } else { - echo "

", _("Upload Completed!"), "

", _("Click on the link below to verify your work."), "
"; - echo "

" . _("Addresses") . "
\n"; - } - - /** - ** Use fgetcsv to make an array out of the uploaded file - ** Display a sample to see if the data looks good to the user. - **/ - - // open the correct filename to work with - if($flag <= 1) { // before submit - $fp = fopen("$attachment_dir$tempfilename", "r"); - } elseif($flag >= 2) { // after submit - $fp = fopen("$attachment_dir$nameholder", "r"); - } - - echo "
\n"; // user's data table - - // This loop sets up a table of the data they uploaded to save time while the user rearranges it. - $row = 0; - do { - ($data = fgetcsv($fp, 4096)); - if(count($data) >= 5) { - $cols = count($data); - } else { - $cols = 5; - } -// $cols = count($data); - $row++; - - if($flag == 0 && !$finish) { // Table header on initial import - echo "
\n"; - } elseif($flag == 2 && !$finish) { // Table header after field changes made - echo "
\n"; - } - - switch($flag) { // This switch sets up a method so that proper looping can be done for the table output - - case 0: - case 1: - case 2: // Should probably be header since thats really what they are, maybe later - - if(!$finish) { // Set up column headers unless we are finished - echo " \n"; // fill in above the omit field - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; // email isn't an array so no loop needed - echo " \n"; - echo " \n"; - - // print field numbers for importable fields - $fcols = $cols; - $i = 5; - for($cols > 4;$fcols > 5 ; --$fcols) { - echo " \n"; - $i++; - } - // give the imported columns a name so the user knows what they will be put into - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - - // print some instruction in the header above the fields that need to be combined into other fields - $fcols = $cols; - for($cols > 4;$fcols > 5 ; --$fcols) { - echo " \n"; - } - echo " "; - echo "
\n"; - } - - case 3: // user's table data - - if($row % 2 && !$finish) { // Set up the alternating colored rows - echo " \n"; - } elseif(!$finish){ - echo " \n"; - } - echo " \n"; - } elseif(!$finish) { // if empty, put space in cell keeping colors correct. - echo " \n"; - } else - $reorg = ""; - } - echo " \n"; - $flag = 3; - break; - } - // If finished, do the import. This uses Pallo's excellent class and object stuff - if($finish && !$sel[$row]) { - $r = $abook->add($addaddr,$abook->localbackend); - if(!r) { - print $this->error; - } - unset($addaddr); - } - // How far should we loop through the users' data. - if($row < $example && (!$all && !$finish)){ - $loop = true; - } elseif(!feof($fp) && ($all || $finish)) { - $loop = true; - } else { - $loop = false; - } - - } while($loop); - - echo "
"; - echo "", _("This table shows your data after uploading it."), ""; - echo ""; - echo "", _("This table shows your data after you reorganized it."), ""; - echo "
", " ", "", _("Field Number: "), "0", "
\n"; // number the fields so they know what to put where - reset($nickname); - while(list($k,$v)=each($nickname)) { // print out the text boxes for this var - echo"
\n"; - $tabindex++; - } - echo "
", _("Field Number: "), "1", "
\n"; // number the fields so they know what to put where - reset($firstname); - while(list($k,$v)=each($firstname)) { // print out the text boxes for this var - echo"
\n"; - $tabindex++; - } - echo "
", _("Field Number: "), "2", "
\n"; // number the fields so they know what to put where - reset($lastname); - while(list($k,$v)=each($lastname)) { // print out the text boxes for this var - echo"
\n"; - $tabindex++; - } - echo "
", _("Field Number: "), "3", "
\n"; // number the fields so they know what to put where - echo " \n"; - $tabindex++; - echo "
", _("Field Number: "), "4", "
\n"; // number the fields so they know what to put where - reset($label); - while(list($k,$v)=each($label)) { // print out the text boxes for this var - echo"
\n"; - $tabindex++; - } - echo "
", _("Field Number: "), "$i", "
", _("Omit"), "", _("Nickname:"), "", _("First name:"), "", _("Last name:"), "", _("E-mail address:"), "", _("Additional info:"), "", _("Move to field"), "
", _("1-5 to include."), "
"; // Print the omit checkbox, to be checked before write - - for($c=0; $c<$cols; $c++) { // Spit out the table cells - // concatenate fields based on user input into text boxes. - if($submit) { - switch($c) { // This switch puts the correct data into the correct fields - case 0: // concactenate nickname field - - reset($nickname); - $j = 0; - while(list($k,$v)=each($nickname)) { - if($v != "" && $j == 0) { - $reorg = "$data[$v]"; // put data in without coma - } elseif($v != "") { - $reorg .= "; $data[$v]"; // put data in with coma - } else " "; // put in space to keep the row colors going - $j++; - } - $addaddr["nickname"] = $reorg; // assign value for writing - break; - - case 1: // concactenate firstname field - - reset($firstname); - $j = 0; - while(list($k,$v)=each($firstname)) { - if($v != "" && $j == 0) { - $reorg = "$data[$v]"; - } elseif($v != "") { - $reorg .= "; $data[$v]"; - } else " "; - $j++; - } - $addaddr["firstname"] = $reorg; - break; - - case 2: // concactenate lastname field - - reset($lastname); - $j = 0; - while(list($k,$v)=each($lastname)) { - if($v != "" && $j == 0) { - $reorg = "$data[$v]"; - } elseif($v != "") { - $reorg .= "; $data[$v]"; - } else " "; - $j++; - } - $addaddr["lastname"] = $reorg; - break; - - case 3: // should only have one field in $email - - $reorg = $data[$email]; - $addaddr["email"] = $reorg; - break; - - case 4: // concactenate label field - - reset($label); - $j = 0; - while(list($k,$v)=each($label)) { - if($v != "" && $j == 0) { - $reorg = "$data[$v]"; - } elseif($v != "") { - $reorg .= "; $data[$v]"; - } else " "; - $j++; - } - $addaddr["label"] = $reorg; - } - } else $reorg = $data[$c]; - - if($reorg != "" && !$finish) { // if not empty, put data in cell. - trim($reorg); - echo " $reorg 
"; - - fclose($fp); -// unset each element in the arrays. For some reason, this doesn't work when included in the same loop as the \n"; - } - reset($lastname); - while(list($k,$v)=each($lastname)){ - echo" \n"; - } - reset($firstname); - while(list($k,$v)=each($firstname)){ - echo" \n"; - } - reset($label); - while(list($k,$v)=each($label)){ - echo" \n"; - } - } - - // Clean up after ourselves. - if($finish) { - unlink ("$attachment_dir$tempfilename"); - } - -?> - - - -- 2.25.1