From f1a11879665599fafb1cc7c37e6b053dfd2eccea Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 20 Nov 2018 07:53:32 -0500 Subject: [PATCH] Order for the position was backwards. Should be ASC not DESC --- index.php | 6 ++-- models/front/packaging/list.php | 63 ++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 4e41ee2..3cc050c 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database Packaging * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.2.19 + * Version: 1.2.20 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -19,7 +19,7 @@ * @package glmMembersDatabasePackagingAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.2.19 + * @version 1.2.20 */ // Check that we're being called by WordPress. @@ -43,7 +43,7 @@ if (!defined('ABSPATH')) { * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_PACKAGING_PLUGIN_VERSION', '1.2.19'); +define('GLM_MEMBERS_PACKAGING_PLUGIN_VERSION', '1.2.20'); define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION', '1.1.7'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/models/front/packaging/list.php b/models/front/packaging/list.php index 3169a13..5a42f14 100644 --- a/models/front/packaging/list.php +++ b/models/front/packaging/list.php @@ -176,7 +176,7 @@ class GlmMembersFront_packaging_list extends GlmDataPackages if ( $orderBy != '' ) { $orderBy .= ','; } - $orderBy .= 'position DESC'; + $orderBy .= 'position ASC'; /* * Get the list of packages that meet the previous requirements @@ -216,6 +216,7 @@ class GlmMembersFront_packaging_list extends GlmDataPackages // Drop the data organized by packages $packages = false; +<<<<<<< Updated upstream // Sort by member name reset( $members ); uasort( @@ -223,11 +224,71 @@ class GlmMembersFront_packaging_list extends GlmDataPackages function($a, $b) { if ( $a['member'] == $b['member'] ) { return 0; +======= + // Determine how to sort the package list + // The sort order config values compared are the ones from Member DB plugin.ini + switch ($this->config['settings']['package_list_order']) { + + // Pseudo-Random list order + case $this->config['sort_order_numb']['Pseudo-Random']: + + /* + * Sort members by pseudo-random sequence + * + * WARNING: shuffle() will create new keys for the array! + * The $members keys will no longer match the member IDs. + * This should not be a problem, but be aware of it. + * + */ + $cookieName = 'GLM_PACKAGE_SORT_SEED'; + $cookieTime = 86400; + + // Get browser cookie if it exists or otherwise generate one + if (isset($_COOKIE[$cookieName])) { + $seed = ($_COOKIE[$cookieName]); + } else { + $seed = intval(time()*1000000+microtime()*1000000); +>>>>>>> Stashed changes } return ( $a['member'] < $b['member'] ) ? -1 : 1; } ); +<<<<<<< Updated upstream +======= + // Enforce seed as positive integer + $seed = abs(intval($seed -0)); + + // Store or update seed in browser cookie + setcookie($cookieName, $seed, time() + $cookieTime); + + // Use the seed to order the Member list - Note that shuffle() will produce the same results if strand() has the same seed. + srand($seed); + shuffle($members); + + break; + + // Default is alpha-numeric list order + default: + case $this->config['sort_order_numb']['Alpha-Numeric']: + + // Sort by member name + reset( $members ); + uasort( + $members, + function($a, $b) { + if ( $a['member'] == $b['member'] ) { + return 0; + } + return ( $a['member'] < $b['member'] ) ? -1 : 1; + } + ); + + break; + + } + +>>>>>>> Stashed changes $byMember = true; } -- 2.17.1