mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-28 14:45:36 +01:00
Fix the premium checks, introduced in v1.8.3
This commit is contained in:
@@ -445,16 +445,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
if(isset($this->data['premium_ends_at']) || isset($this->data['premend']) ||
|
||||
(isCanary() && isset($this->data['lastday']))) {
|
||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
||||
$col = (isset($this->data['premium_ends_at']) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
||||
$ret = ceil(($this->data[$col] - time()) / (24 * 60 * 60));
|
||||
return max($ret, 0);
|
||||
}
|
||||
|
||||
if (isCanary() && isset($this->data['lastday'])) {
|
||||
$ret = ceil(($this->data['lastday'] - time()) / 86400);
|
||||
return max($ret, 0);
|
||||
}
|
||||
|
||||
if($this->data['premdays'] == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -479,12 +474,14 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
public function isPremium()
|
||||
{
|
||||
if(isset($this->data['premium_ends_at'])) {
|
||||
return $this->data['premium_ends_at'] > time();
|
||||
if(isset($this->data['premium_ends_at']) || isset($this->data['premend']) ||
|
||||
(isCanary() && isset($this->data['lastday']))) {
|
||||
$col = (isset($this->data['premium_ends_at']) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
||||
return $this->data[$col] > time();
|
||||
}
|
||||
|
||||
if(isset($this->data['premend'])) {
|
||||
return $this->data['premend'] > time();
|
||||
if($this->data['premdays'] == self::GRATIS_PREMIUM_DAYS){
|
||||
return true;
|
||||
}
|
||||
|
||||
return ($this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday'])) > 0);
|
||||
|
||||
@@ -10,6 +10,8 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*/
|
||||
class Account extends Model {
|
||||
|
||||
const GRATIS_PREMIUM_DAYS = 65535;
|
||||
|
||||
protected $table = 'accounts';
|
||||
|
||||
public $timestamps = false;
|
||||
@@ -34,9 +36,9 @@ class Account extends Model {
|
||||
public function getPremiumDaysAttribute()
|
||||
{
|
||||
if(isset($this->premium_ends_at) || isset($this->premend) ||
|
||||
(isCanary() && isset($this->data['lastday']))) {
|
||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->data['lastday']) ? 'lastday' : 'premend'));
|
||||
$ret = ceil(($this->{$col}- time()) / (24 * 60 * 60));
|
||||
(isCanary() && isset($this->lastday))) {
|
||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->lastday) ? 'lastday' : 'premend'));
|
||||
$ret = ceil(($this->{$col} - time()) / (24 * 60 * 60));
|
||||
return max($ret, 0);
|
||||
}
|
||||
|
||||
@@ -44,8 +46,8 @@ class Account extends Model {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if($this->premdays == 65535){
|
||||
return 65535;
|
||||
if($this->premdays == self::GRATIS_PREMIUM_DAYS){
|
||||
return self::GRATIS_PREMIUM_DAYS;
|
||||
}
|
||||
|
||||
$ret = ceil($this->premdays - ((int)date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)));
|
||||
@@ -54,12 +56,14 @@ class Account extends Model {
|
||||
|
||||
public function getIsPremiumAttribute()
|
||||
{
|
||||
if(isset($this->premium_ends_at)) {
|
||||
return $this->premium_ends_at > time();
|
||||
if(isset($this->premium_ends_at) || isset($this->premend) ||
|
||||
(isCanary() && isset($this->lastday))) {
|
||||
$col = (isset($this->premium_ends_at) ? 'premium_ends_at' : (isset($this->lastday) ? 'lastday' : 'premend'));
|
||||
return $this->{$col} > time();
|
||||
}
|
||||
|
||||
if(isset($this->premend)) {
|
||||
return $this->premend > time();
|
||||
if($this->premdays == self::GRATIS_PREMIUM_DAYS){
|
||||
return true;
|
||||
}
|
||||
|
||||
return ($this->premdays - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->lastday))) - date("z", $this->lastday)) > 0);
|
||||
|
||||
Reference in New Issue
Block a user