Adding clear options to file and photos
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 5 Jul 2017 17:47:49 +0000 (13:47 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 5 Jul 2017 17:48:30 +0000 (13:48 -0400)
Adding a clear data option to the photo and file parts.

models/admin/import/index.php
views/admin/import/files.html
views/admin/import/filesValidate.html
views/admin/import/photos.html
views/admin/import/photosValidate.html

index 350fac7..d2cb752 100644 (file)
@@ -485,6 +485,7 @@ class GlmMembersAdmin_import_index
             // Set the view file
             $view = 'photosValidate.html';
             $fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
+            $clearData = ( filter_var( $_REQUEST['clear_data'], FILTER_VALIDATE_BOOLEAN ) );
 
             break;
 
@@ -504,10 +505,16 @@ class GlmMembersAdmin_import_index
             // Set the view file
             $view = 'filesValidate.html';
             $fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
+            $clearData = ( filter_var( $_REQUEST['clear_data'], FILTER_VALIDATE_BOOLEAN ) );
 
             break;
 
         case 'photosProcess':
+            if ( $clearData ) {
+                // Empty the tables for the member data.
+                // Not including the management options.
+                $this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'images');
+            }
             // Setup the image processing
             require_once GLM_MEMBERS_PLUGIN_PATH . '/models/admin/ajax/imageUpload.php';
             $ImageUpload = new GlmMembersAdmin_ajax_imageUpload($this->wpdb, $this->config);
@@ -591,6 +598,11 @@ class GlmMembersAdmin_import_index
             break;
 
         case 'filesProcess':
+            if ( $clearData ) {
+                // Empty the tables for the member data.
+                // Not including the management options.
+                $this->wpdb->query('DELETE FROM ' .  GLM_MEMBERS_PLUGIN_DB_PREFIX . 'files');
+            }
             // Setup the file processing
             require_once GLM_MEMBERS_PLUGIN_PATH . '/models/admin/ajax/fileUpload.php';
             $FileUpload = new GlmMembersAdmin_ajax_fileUpload($this->wpdb, $this->config);
index 87e11ce..d46a081 100644 (file)
             </td>
             {/foreach}
             </tr>
+            <tr>
+                <td>Clear Data</td>
+                <td colspan="4">
+                    <input type="hidden" name="clear_data" value="0">
+                    <input type="checkbox" name="clear_data" value="1" checked>
+                </td>
+            </tr>
 
         </table>
 
index a340f3e..04670fb 100644 (file)
             {/if}
         </td>
     </tr>
+
+        {if $clearData}
+        <tr>
+            <td colspan="2">
+                All Member Files Data will be cleared before importing any files.
+            </td>
+        </tr>
+        {else}
+        <tr>
+            <td colspan="2">
+                No Member Files Data will not be cleared before importing any files. No attempts will be made to prevent duplication of members.
+            </td>
+        </tr>
+        {/if}
         {if $readyToProcess}
         <tr>
             <td colspan="2">
-                <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=filesProcess" class="button">Process Files</a>
+                <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=filesProcess{if $clearData}&clear_data=1{/if}" class="button">Process Files</a>
             </td>
         </tr>
         {/if}
index 7963d81..4e27a83 100644 (file)
             </td>
             {/foreach}
             </tr>
+            <tr>
+                <td>Clear Data</td>
+                <td colspan="4">
+                    <input type="hidden" name="clear_data" value="0">
+                    <input type="checkbox" name="clear_data" value="1" checked>
+                </td>
+            </tr>
 
         </table>
 
index e8c03e4..21e8b2d 100644 (file)
             {/if}
         </td>
     </tr>
+
+        {if $clearData}
+        <tr>
+            <td colspan="2">
+                All Member Photo Data will be cleared before importing any files.
+            </td>
+        </tr>
+        {else}
+        <tr>
+            <td colspan="2">
+                No Member Photo Data will not be cleared before importing any files. No attempts will be made to prevent duplication of members.
+            </td>
+        </tr>
+        {/if}
+
         {if $readyToProcess}
         <tr>
             <td colspan="2">
-                <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=photosProcess" class="button">Process Photos</a>
+                <a href="{$thisUrl}?page={$thisPage}&glm_action=index&option=photosProcess{if $clearData}&clear_data=1{/if}" class="button">Process Photos</a>
             </td>
         </tr>
         {/if}