Added untested (commented out) code sample for doing pseudo-random ordering of packag...
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 2 Mar 2018 18:19:20 +0000 (13:19 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 2 Mar 2018 18:19:20 +0000 (13:19 -0500)
models/front/packaging/list.php

index 3169a13..6718db4 100644 (file)
@@ -216,6 +216,47 @@ class GlmMembersFront_packaging_list extends GlmDataPackages
             // Drop the data organized by packages
             $packages = false;
 
+
+
+
+                /*
+                 * Sort members by pseudo-random sequence
+                 *
+                 * A management option in packaging will need to be created to select this
+                 * or "Sort by member name" below.
+                 *
+                 * *** THIS IS UNTESTED CODE ***
+                 *
+                 * 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);
+                }
+
+                // 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);
+            */
+
+
+
             // Sort by member name
             reset( $members );
             uasort(