From: Steve Sutton Date: Tue, 25 Sep 2018 17:47:04 +0000 (-0400) Subject: Update for images in connections X-Git-Tag: v2.10.45^2~15 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=19c23d9411ff158741484ddefa117bf1b6577ae5;p=WP-Plugins%2Fglm-member-db.git Update for images in connections Bring any missing images in to the member info --- diff --git a/models/admin/management/development.php b/models/admin/management/development.php index e100e736..ccbdf77e 100644 --- a/models/admin/management/development.php +++ b/models/admin/management/development.php @@ -13,6 +13,7 @@ * @version 0.1 */ +require_once GLM_MEMBERS_PLUGIN_PATH . '/models/admin/ajax/imageUpload.php'; /** * This class performs the work for the default action of the "Members" menu * option, which is to display the members dashboard. @@ -153,6 +154,7 @@ class GlmMembersAdmin_management_development break; case 'updateImages': + $ImageUpload = new GlmMembersAdmin_ajax_imageUpload( $this->wpdb, $this->config ); $sql = " SELECT id,organization,options FROM ".$this->wpdb->prefix."connections @@ -165,42 +167,51 @@ class GlmMembersAdmin_management_development // Need to get the member_info id based on the ref_dest $options_data = unserialize( $member['options'] ); if ( $options_data['logo'] ) { - // echo '
$options_data: logo ' . print_r( $options_data['logo'], true ) . '
'; + $logoPath = $options_data['logo']['meta']['path']; } else if ( $options_data['image'] ) { - // echo '
$options_data: image ' . print_r( $options_data['image'], true ) . '
'; + $logoPath = $options_data['image']['meta']['original']['path']; + } + if ( $logoPath ) { + $memberLogo = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT logo + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info + WHERE member = ( SELECT id + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + WHERE old_member_id = %s + )", + $member['id'] + ) + ); + if ( !$memberLogo ) { + echo '
image not found: ' . print_r( 'image not found', true ) . '
'; + if ( is_file( $logoPath ) ) { + $logo = $ImageUpload->storeImage($logoPath); + if ($logo === false) { + $logo = ''; + } else { + $logo = $logo['newFileName']; + } + } else { + $logo = ''; + } + echo '
$logo: ' . print_r( $logo, true ) . '
'; + if ( $logo ) { + $this->wpdb->query( + $this->wpdb->prepare( + "UPDATE " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info + SET logo = %s + WHERE member = ( SELECT id + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + WHERE old_member_id = %d + )", + $logo, + $member['id'] + ) + ); + } + } } - $memberInfoId = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT logo - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info - WHERE member = ( SELECT id - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - WHERE old_member_id = %s - )", - $member['id'] - ) - ); - echo '
$memberInfoId: ' . print_r( $memberInfoId, true ) . '
'; - // $email = ''; - // if ( is_array( $options_data ) ) { - // reset( $options_data ); - // $eData = current( $options_data ); - // $email = $eData['address']; - // } - // if ( $email ) { - // $this->wpdb->query( - // $this->wpdb->prepare( - // "UPDATE " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info - // SET email = %s - // WHERE member = ( SELECT id - // FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - // WHERE old_member_id = %d - // )", - // $email, - // $member['id'] - // ) - // ); - // } } break;