Skip to content

Commit

Permalink
Merge pull request #407 from websharks/feature/406
Browse files Browse the repository at this point in the history
Bug fix access cap times loss of precision. See: #406
  • Loading branch information
JasWSInc committed Dec 12, 2014
2 parents 775f8f6 + e3bb65e commit 28cabca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions s2member/includes/classes/access-cap-times.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
*/
class c_ws_plugin__s2member_access_cap_times
{
/**
* @var string Current log time increment.
*/
protected static $log_time = NULL;

/**
* @var array Previous array of user CAPS.
Expand Down Expand Up @@ -130,16 +134,18 @@ public static function log_access_cap_times($meta_id, $object_id, $meta_key, $me

$ac_times = get_user_option('s2member_access_cap_times', $user_id);
if(!is_array($ac_times)) $ac_times = array();
$time = (float)time();

if(!isset(self::$log_time))
self::$log_time = (float)time();

foreach($caps['prev'] as $_cap => $_was_enabled)
if($_was_enabled && empty($caps['now'][$_cap]))
$ac_times[number_format(($time += .0001), 4, '.', '')] = '-'.$_cap;
$ac_times[number_format((self::$log_time += .0001), 4, '.', '')] = '-'.$_cap;
unset($_cap, $_was_enabled);

foreach($caps['now'] as $_cap => $_now_enabled)
if($_now_enabled && empty($caps['prev'][$_cap]))
$ac_times[number_format(($time += .0001), 4, '.', '')] = $_cap;
$ac_times[number_format((self::$log_time += .0001), 4, '.', '')] = $_cap;
unset($_cap, $_now_enabled);

update_user_option($user_id, 's2member_access_cap_times', $ac_times);
Expand Down

0 comments on commit 28cabca

Please # to comment.