From 715788c779623ebf7a5d2a8d6baae1e56d96c238 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 12 Apr 2017 11:56:20 -0400 Subject: [PATCH] Setting up the cloning for the member info files. Need to clone the files with member info. --- classes/data/dataFiles.php | 91 +++++++++++++++------------------- classes/glmMemberInfoClone.php | 8 ++- 2 files changed, 47 insertions(+), 52 deletions(-) diff --git a/classes/data/dataFiles.php b/classes/data/dataFiles.php index d38d03e8..459bdc32 100644 --- a/classes/data/dataFiles.php +++ b/classes/data/dataFiles.php @@ -418,73 +418,62 @@ class GlmDataFiles extends GlmDataAbstract * @return boolean True if successful * */ - public function galleryImageDataClone($refTypeSrc, $refIDSrc, $refTypeDst, $refIDDst) + public function filesDataClone($refTypeSrc, $refIDSrc, $refTypeDst, $refIDDst) { // Get Source Image Gallery - $imageGallerySrc = $this->getFiles($refTypeSrc, $refIDSrc); + $fileSrc = $this->getFiles($refTypeSrc, $refIDSrc); // Get the destination target table name $dstTable = $this->config['ref_type_table'][$refTypeDst]; - // Get Image sizes and add original - $sizes = $this->config['imageSizes']; - $sizes['original'] = array(); - // If we have an image gallery with any files - if ($imageGallerySrc !== false - && is_array($imageGallerySrc) - && count($imageGallerySrc) > 0) { + if ($fileSrc !== false + && is_array($fileSrc) + && count($fileSrc) > 0) { // for each gallery image - foreach ($imageGallerySrc as $i) { - - $srcName = $i['file_name']; + foreach ($fileSrc as $i) { - // Strip the source table name and ID from the file name (part after first '-') - $dstName = $dstTable.'_'.$refIDDst.'-'.substr(strchr($i['file_name'], '-'), 1); + $srcName = $i['file_name']; - // For each image size - reset($sizes); - while (list($k, $v) = each($sizes)) { + // Strip the source table name and ID from the file name (part after first '-') + $dstName = $dstTable.'_'.$refIDDst.'-'.substr(strchr($i['file_name'], '-'), 1); - // Check if the source image exists - if (is_file(GLM_MEMBERS_PLUGIN_FILES_PATH.'/'.$k.'/'.$srcName)) { + // Check if the source image exists + if (is_file(GLM_MEMBERS_PLUGIN_FILES_PATH.'/'.$srcName)) { - // Copy src file to dst file for this size - copy(GLM_MEMBERS_PLUGIN_FILES_PATH.'/'.$k.'/'.$srcName, GLM_MEMBERS_PLUGIN_FILES_PATH.'/'.$k.'/'.$dstName); + // Copy src file to dst file for this size + copy(GLM_MEMBERS_PLUGIN_FILES_PATH.'/'.$srcName, GLM_MEMBERS_PLUGIN_FILES_PATH.'/'.$dstName); - } - } + } - // Add this image to the files table - // Store image name in files table - $sql = " - INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."files - ( - name, - file_name, - descr, - caption, - status, - position, - ref_type, - ref_dest - ) - VALUES - ( - '".$i['name']."', - '$dstName', - '".addslashes($i['descr'])."', - '".addslashes($i['caption'])."', - ".$i['status']['value'].", - ".$i['position'].", - $refTypeDst, - $refIDDst - ); - "; - $this->wpdb->query($sql); - // $queryError = $this->wpdb->last_error; + // Add this image to the files table + // Store image name in files table + $sql = " + INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX ."files + ( + name, + file_name, + caption, + status, + position, + ref_type, + ref_dest + ) + VALUES + ( + '".$i['name']."', + '$dstName', + '".addslashes($i['caption'])."', + ".$i['status']['value'].", + ".$i['position'].", + $refTypeDst, + $refIDDst + ); + "; + $this->wpdb->query($sql); + // $queryError = $this->wpdb->last_error; } diff --git a/classes/glmMemberInfoClone.php b/classes/glmMemberInfoClone.php index 32d223d9..c09cd1a9 100644 --- a/classes/glmMemberInfoClone.php +++ b/classes/glmMemberInfoClone.php @@ -118,6 +118,12 @@ class GlmMemberInfoClone // Clone the image gallery $Images->galleryImageDataClone($refType, $id, $refType, $newID); + // Load file class + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataFiles.php'; + $Files = new GlmDataFiles($this->wpdb, $this->config); + + // Clone the files + $Files->filesDataClone($refType, $id, $refType, $newID); } @@ -127,4 +133,4 @@ class GlmMemberInfoClone } -?> \ No newline at end of file +?> -- 2.17.1