* @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;
}