Exemplo n.º 1
0
 static function UpdateLevelsCount()
 {
     global $WishListMemberInstance;
     $levels = WishListMember_Level::GetAllLevels(true);
     $wpm_levels = $WishListMemberInstance->GetOption('wpm_levels');
     foreach ($levels as $level) {
         $wpm_levels[$level->ID]['count'] = $level->CountMembers();
     }
     $WishListMemberInstance->SaveOption('wpm_levels', $wpm_levels);
 }
Exemplo n.º 2
0
 /**
  * Synchronize Membership Data
  * @global object $wpdb
  */
 function SyncMembership($force_sync = false)
 {
     global $wpdb;
     $userlevelsTable = $this->Tables->userlevels;
     $userlevelsTableOptions = $this->Tables->userlevel_options;
     $userTableOptions = $this->Tables->user_options;
     if (!get_transient('WLM_delete') or $force_sync) {
         $deleted = 0;
         //$deleted += $wpdb->query("DELETE FROM `{$userlevelsTable}` WHERE `user_id` NOT IN (SELECT `ID` FROM {$wpdb->users})");
         $deleted += $wpdb->query("DELETE {$userlevelsTable} FROM `{$userlevelsTable}` LEFT JOIN `{$wpdb->users}` ON `{$userlevelsTable}`.`user_id` = `{$wpdb->users}`.`ID` WHERE `{$wpdb->users}`.`ID` IS NULL");
         //$deleted += $wpdb->query("DELETE FROM `{$userTableOptions}` WHERE `user_id` NOT IN (SELECT `ID` FROM {$wpdb->users})");
         $deleted += $wpdb->query("DELETE {$userTableOptions} FROM `{$userTableOptions}` LEFT JOIN `{$wpdb->users}` ON `{$userTableOptions}`.`user_id` = `{$wpdb->users}`.`ID` WHERE `{$wpdb->users}`.`ID` IS NULL");
         //$deleted += $wpdb->query("DELETE FROM `{$userlevelsTableOptions}` WHERE `userlevel_id` NOT IN (SELECT `ID` FROM {$userlevelsTable})");
         $deleted += $wpdb->query("DELETE {$userlevelsTableOptions} FROM `{$userlevelsTableOptions}` LEFT JOIN `{$userlevelsTable}` ON `{$userlevelsTableOptions}`.`userlevel_id` = `{$userlevelsTable}`.`ID` WHERE `{$userlevelsTable}`.`ID` IS NULL");
         set_transient('WLM_delete', 1, 60 * 60);
         wlm_cache_flush();
         WishListMember_Level::UpdateLevelsCount();
     }
 }
Exemplo n.º 3
0
 /**
  * Migrate Level Information
  * @global object $wpdb
  */
 function MigrateLevelData()
 {
     ignore_user_abort(true);
     global $wpdb;
     if ($this->DataMigrated != 1 || get_option($this->PluginOptionName . '_MigrateLevelData') == 1) {
         return;
     }
     $this->CreateWLMDBTables();
     $userlevelsTable = $this->Tables->userlevels;
     $userlevelsTableOptions = $this->Tables->userlevel_options;
     $userTableOptions = $this->Tables->user_options;
     // user level data
     $memberLevels = (array) $this->GetOption('Members');
     $cancelled = (array) $this->GetOption('Cancelled');
     $unconfirmed = (array) $this->GetOption('UnConfirmed');
     $forapproval = (array) $this->GetOption('Pending');
     $levels = WishListMember_Level::GetAllLevels();
     $allmembers = array();
     foreach ($levels as $level) {
         $members = array_unique(explode(',', $memberLevels[$level]));
         $allmembers = array_merge($allmembers, $members);
         foreach ($members as $member) {
             /* Membership Level */
             $data = array('user_id' => $member, 'level_id' => $level);
             if ($wpdb->insert($userlevelsTable, $data)) {
                 $userlevel_id = $wpdb->insert_id;
                 /* Transaction IDs */
                 $trans = get_usermeta($member, 'wlm_sctxns');
                 $data = array('userlevel_id' => $userlevel_id, 'option_name' => 'transaction_id', 'option_value' => maybe_serialize($trans[$level]));
                 $wpdb->insert($userlevelsTableOptions, $data);
                 /* Level Registration Dates */
                 $regdates = get_usermeta($member, 'wpm_leveltimestamp');
                 $this->UserLevelTimestamp($member, $level, $regdates[$level]);
                 /* Cancelled Status */
                 $status = preg_match('/,(' . $member . ';[0-9]*),/', ',' . $cancelled[$level] . ',', $match) > 0;
                 if ($status) {
                     list($id, $date) = explode(';', $match[1]);
                     $this->LevelCancelled($level, $member, true, $date);
                 }
                 /* Unconfirmed Status */
                 $status = preg_match('/,' . $member . ',/', ',' . $unconfirmed[$level] . ',') > 0;
                 if ($status) {
                     $this->LevelUnConfirmed($level, $member, true);
                 }
                 /* For Approval Status */
                 $status = preg_match('/,' . $member . ',/', ',' . $forapproval[$level] . ',') > 0;
                 if ($status) {
                     $this->LevelForApproval($level, $member, true);
                 }
             }
         }
     }
     $allmembers = array_unique($allmembers);
     // per user data
     $nonseq = array_unique(explode(',', $memberLevels['nonsequential']));
     foreach ($allmembers as $member) {
         // sequential upgrade
         $seq = in_array($member, $nonseq) ? 0 : 1;
         $data = array('user_id' => $member, 'option_name' => 'sequential', 'option_value' => maybe_serialize($seq));
         $wpdb->insert($userTableOptions, $data);
     }
     // migrate all wpm_ and wlm_ data except wpm_leveltimestamp and wlm_sctxns
     $query = "INSERT INTO `{$userTableOptions}` (`user_id`,`option_name`,`option_value`)\n\t\t\t\tSELECT `user_id`,`meta_key`,`meta_value` FROM `{$wpdb->usermeta}`\n\t\t\t\t\tWHERE `meta_key`<>'wpm_leveltimestamp'\n\t\t\t\t\tAND `meta_key`<>'wlm_sctxns'\n\t\t\t\t\tAND (`meta_key` LIKE 'wlm%' OR `meta_key` LIKE 'wpm%')";
     $wpdb->query($query);
     /*
      * remove old data format for membership levels, cancelled status,
      * unconfirmed status, and pending status from our options table
      */
     $this->DeleteOption('Members');
     $this->DeleteOption('Cancelled');
     $this->DeleteOption('UnConfirmed');
     $this->DeleteOption('Pending');
     /* end of data migration */
     update_option($this->PluginOptionName . '_MigrateLevelData', 1);
 }
Exemplo n.º 4
0
</a></td>
								<td width="10%"></td>
							</tr>

							<tr class="wlmlevels">
								<td colspan="3">								
									<strong><?php 
    _e('Users per Membership Level', 'wishlist-member');
    ?>
</strong>
								</td>
							</tr>
							<?php 
    $totalmembers = $cancelmembers = 0;
    foreach (array_keys($wpm_levels) as $level) {
        $level = new WishListMember_Level($level);
        $lcount = $level->CountMembers();
        $xcount = $level->CountMembers(true);
        $clcount = $lcount - $xcount;
        $totalmembers += $xcount;
        $cancelmembers += $clcount;
        $level_link = $members_link->URL . '&level=' . $level->ID;
        ?>
								<tr class="wlmlevels">
									<td class="levelname"><a href="<?php 
        echo $level_link;
        ?>
"><?php 
        echo $level->name;
        ?>
</a></td>