GroupTimed
class GroupTimed extends AuthEntityTimed implements IGroupCommon
Concrete class providing timed group member limits
Traits
Group limits common between total and timed
Constants
| IDLength |
The length of the ID used to identify the object |
| MAX_AGE_FOREVER |
|
Properties
| protected | $database | The object's primary reference to the database |
from BaseObject |
| protected Scalar> | $scalars | from BaseObject | |
| protected ObjectRef> | $objects | from BaseObject | |
| protected ObjectRefs> | $objectrefs | from BaseObject | |
| private | $modified | whether or not this object has been modified |
from BaseObject |
| private | $deleted | whether or not this object has been deleted |
from BaseObject |
| private | $dbDeleted | whether or not this object has been deleted by DB |
from BaseObject |
| private | $deleteLater | from BaseObject | |
| private | $created | True if this object has been created and not yet saved to DB |
from BaseObject |
| static protected | $cache | array<limited object ID, self[]> |
from Timed |
| protected | $acctlims | cache of account limits that apply to this group |
Methods
Gets a template array of the object's properties (columns).
Returns the name of the class that should be used in the database for the table name (cast down at save)
Counts objects in the DB matching the given query
Loads an array of objects from the DB matching the given query
Deletes objects from the DB matching the given query
Loads a unique object matching the given query
Loads all objects of this type from the database
Loads objects from the database with the given object ID as the value of the given field
Deletes objects from the database with the given object ID as the value of the given field
Loads a unique object matching the given field
Deletes a unique object matching the given field
Loads objects from the database with the given object referenced by the given field
Deletes objects from the database with the given object referenced by the given field
Loads a unique object from the database with the given object referenced by the given field
Deletes a unique object from the database with the given object referenced by the given field
Returns the string "id:class" where id is the object ID and class is its short class name
Same as GetScalar() but returns null instead of throwing exceptions
Returns the delta of the given scalar (non-zero if modified)
Same as GetObject() but returns null instead of throwing exceptions
Checks if the object reference is not-null without actually loading it (faster)
Gets the ID of a referenced object without actually loading it (faster)
Same as GetObjectID() but returns null instead of throwing exceptions
Gets the class name of a referenced object without actually loading it (faster)
Gets the class name of a referenced object without actually loading it (faster)
Gets an array of objects that reference this object
Gets the counter of objects referencing this object
Loads the object that joins together two classes using a FieldTypes\ObjectJoin
Same as GetJoinObject() but returns null instead of throwing exceptions
Deletes all objects that reference this object
Sets a scalar field to the given value
Increment a counter by the given value
Sets a field to reference the given object
Same as BoolSetObject() but returns $this
Adds an object reference, checking for a limit on the number of references
Removes the given object from a collection of referenced objects
Constructs the object by initializing its field template with values from the database
register a group change handler that updates this specific object's accountlim cache
Collects fields that have changed and saves them to the database
whether or not this object has been, or should be considered, deleted
True if this object has been created and not yet saved to DB (should not be overriden)
Returns the timestamp value stored in the given date field
Returns the timestamp value stored in the given date field
Sets the value of the given date field to the given value
Gets the value of the given feature field as an int (used for config)
Gets the value of the given feature field as an int (used for config)
Gets the value of the given feature field as a bool (used for config)
Gets the value of the given feature field as a bool (used for config)
Sets the value of the given feature field to the given (?int) value
Sets the value of the given feature field to the given (?bool) value
Returns true if the given feature has been modified
Gets the value of the given counter limit field
Gets the value of the given counter limit field
Sets the value of the given counter limit field
Checks whether the given counter plus a delta would exceed the limit
Gets an array of the values of all fields matching a prefix
Initializes group limits by adding a limit for each member account
Adds to the size counter, if item tracking is allowed
Increments the item counter, if item tracking is allowed. Decrements if not $count
Increments the item counter by the given value, if item tracking is allowed
Increments the share counter, if item tracking is allowed. Decrements if not $count
Increments the share counter by the given value, if item tracking is allowed
Increments the public download counter, if download tracking is allowed
Increments the public download counter by the given value, if DL tracking is allowed
Adds to the bandwidth counter, if download tracking is allowed
Adds stats from the given file to this limit object
Adds stats from the given folder to this limit object
Adds cumulative stats from the given folder to this limit object
Returns all Timed Limits with the given time period
Returns all timed limits for the given limited object (all time periods)
Loads the limit object for the given object and time period
Deletes all limit objects corresponding to the given limited object
Deletes all limit objects corresponding to the given limited object and time period
Creates and caches a new timed limit for the given object
Updates the group's stats by adding or subtracting an account's stats
Configures limits for the given group with the given input
loads account limits via a JOIN, caches, and returns them
Loads the timed limit for the given group and time period
Returns all timed limits for the given group
Details
in
Timed at line 33
static array
GetFieldTemplate()
Gets a template array of the object's properties (columns).
This template will be copied into the object when it is constructed. If a field maps to null, a basic Scalar fieldtype will be used.
in
Timed at line 31
static string
GetDBClass()
Returns the name of the class that should be used in the database for the table name (cast down at save)
Defaults to the actual class used. Can be overriden e.g. if multiple classes need to use the same table.
in
BaseObject at line 60
static string
GetObjClass(array $row)
No description
in
BaseObject at line 68
static int
CountByQuery(ObjectDatabase $database, QueryBuilder $query)
Counts objects in the DB matching the given query
in
BaseObject at line 79
static array
LoadByQuery(ObjectDatabase $database, QueryBuilder $query)
Loads an array of objects from the DB matching the given query
in
BaseObject at line 92
static int
DeleteByQuery(ObjectDatabase $database, QueryBuilder $query)
Deletes objects from the DB matching the given query
The objects are loaded when they are deleted and their Delete()s are run
in
BaseObject at line 103
static BaseObject|null
TryLoadUniqueByQuery(ObjectDatabase $database, QueryBuilder $query)
Loads a unique object matching the given query
in
BaseObject at line 116
static BaseObject
NotNull(BaseObject|null $obj)
Asserts that the given object is not null
in
BaseObject at line 127
static BaseObject|null
TryLoadByID(ObjectDatabase $database, string $id)
Loads a unique object by its ID
in
BaseObject at line 137
static void
DeleteByID(ObjectDatabase $database, string $id)
Deletes a unique object by its ID
in
Base at line 182
static array
LoadAll(ObjectDatabase $database, int|null $limit = null, int|null $offset = null)
Loads all objects of this type from the database
in
BaseObject at line 160
static int
DeleteAll(ObjectDatabase $database)
Deletes all objects of this type from the database
in
BaseObject at line 176
static array
LoadByObjectID(ObjectDatabase $database, string $field, string $id, string|null $class = null)
Loads objects from the database with the given object ID as the value of the given field
Can be used as an alternative to LoadByObject() to avoid actually loading the object
in
BaseObject at line 193
static int
DeleteByObjectID(ObjectDatabase $database, string $field, string $id, string|null $class = null)
Deletes objects from the database with the given object ID as the value of the given field
Can be used as an alternative to DeleteByObject() to avoid actually loading the object
in
BaseObject at line 206
static protected BaseObject|null
TryLoadUniqueByKey(ObjectDatabase $database, string $field, string $key)
Loads a unique object matching the given field
in
BaseObject at line 218
static protected bool
TryDeleteByUniqueKey(ObjectDatabase $database, string $field, string $key)
Deletes a unique object matching the given field
in
BaseObject at line 233
static array
LoadByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)
Loads objects from the database with the given object referenced by the given field
in
BaseObject at line 247
static int
DeleteByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)
Deletes objects from the database with the given object referenced by the given field
in
BaseObject at line 261
static BaseObject|null
TryLoadUniqueByObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)
Loads a unique object from the database with the given object referenced by the given field
in
BaseObject at line 275
static bool
TryDeleteByUniqueObject(ObjectDatabase $database, string $field, BaseObject $object, bool $isPoly = false)
Deletes a unique object from the database with the given object referenced by the given field
in
BaseObject at line 284
string
ID()
Returns the unique ID of the object
in
BaseObject at line 287
string
__toString()
Returns the string "id:class" where id is the object ID and class is its short class name
in
BaseObject at line 290
static string|null
toString(BaseObject|null $obj)
Returns the given object's as a string if not null, else null
in
BaseObject at line 309
protected mixed
GetScalar(string $field, bool $allowTemp = true)
Gets a scalar field
in
BaseObject at line 322
protected
TryGetScalar(string $field, bool $allowTemp = true)
Same as GetScalar() but returns null instead of throwing exceptions
in
BaseObject at line 336
protected int
GetScalarDelta(string $field)
Returns the delta of the given scalar (non-zero if modified)
in
BaseObject at line 351
protected BaseObject
GetObject(string $field)
Gets a single object reference
in
BaseObject at line 365
protected BaseObject|null
TryGetObject(string $field)
Same as GetObject() but returns null instead of throwing exceptions
in
BaseObject at line 379
protected bool
HasObject(string $field)
Checks if the object reference is not-null without actually loading it (faster)
in
BaseObject at line 394
protected string
GetObjectID(string $field)
Gets the ID of a referenced object without actually loading it (faster)
in
BaseObject at line 408
protected string|null
TryGetObjectID(string $field)
Same as GetObjectID() but returns null instead of throwing exceptions
in
BaseObject at line 422
protected string
GetObjectType(string $field)
Gets the class name of a referenced object without actually loading it (faster)
in
BaseObject at line 438
protected string|null
TryGetObjectType(string $field)
Gets the class name of a referenced object without actually loading it (faster)
in
BaseObject at line 451
protected BaseObject
DeleteObject(string $field)
Deletes the object referenced in the field
in
BaseObject at line 467
protected array
GetObjectRefs(string $field, int|null $limit = null, int|null $offset = null)
Gets an array of objects that reference this object
in
BaseObject at line 481
protected int
CountObjectRefs(string $field)
Gets the counter of objects referencing this object
in
BaseObject at line 497
protected StandardObject
GetJoinObject(string $field, BaseObject $obj)
Loads the object that joins together two classes using a FieldTypes\ObjectJoin
in
BaseObject at line 514
protected StandardObject|null
TryGetJoinObject(string $field, BaseObject $obj)
Same as GetJoinObject() but returns null instead of throwing exceptions
in
BaseObject at line 530
protected BaseObject
DeleteObjects(string $field)
Deletes all objects that reference this object
in
BaseObject at line 546
protected BaseObject
SetScalar(string $field, mixed $value, bool $temp = false)
Sets a scalar field to the given value
in
Timed at line 148
protected BaseObject
DeltaCounter(string $name, int $delta = 1, bool $ignoreLimit = false)
Increment a counter by the given value
in
BaseObject at line 598
protected bool
BoolSetObject(string $field, BaseObject|null $object, bool $notification = false)
Sets a field to reference the given object
Will also call SetObject or AddObjectRef on the given object as appropriate for two-way references
in
BaseObject at line 649
protected BaseObject
SetObject(string $field, BaseObject|null $object, bool $notification = false)
Same as BoolSetObject() but returns $this
in
StandardObject at line 185
protected bool
AddObjectRef(string $field, BaseObject $object, bool $notification = false)
Adds an object reference, checking for a limit on the number of references
in
BaseObject at line 696
protected bool
RemoveObjectRef(string $field, BaseObject $object, bool $notification = false)
Removes the given object from a collection of referenced objects
in
BaseObject at line 727
__construct(ObjectDatabase $database, array $data)
Constructs the object by initializing its field template with values from the database
in
BaseObject at line 750
private
AddField(string $key, Scalar $field)
Adds the given field object to the correct internal array
at line 263
protected void
SubConstruct()
register a group change handler that updates this specific object's accountlim cache
in
BaseObject at line 771
BaseObject
Save(bool $onlyMandatory = false)
Collects fields that have changed and saves them to the database
in
BaseObject at line 814
bool
isDeleted()
whether or not this object has been, or should be considered, deleted
This function can be overriden with a custom validity-check, and is used as a filter when loading objects
in
BaseObject at line 820
void
NotifyDBDeleted()
Deletes this object without sending to the DB
in
GroupCommon at line 113
void
Delete()
Deletes the group limits and potentially removes account limits
in
BaseObject at line 849
protected void
DeleteLater()
Schedules the object to be deleted when Save() is called
in
BaseObject at line 855
bool
isCreated()
True if this object has been created and not yet saved to DB (should not be overriden)
in
StandardObject at line 51
static protected BaseObject
BaseCreate(ObjectDatabase $database)
Create the object by setting its created date
in
StandardObject at line 23
protected float
GetDate(string $name)
Returns the timestamp value stored in the given date field
in
StandardObject at line 29
protected float|null
TryGetDate(string $name)
Returns the timestamp value stored in the given date field
in
StandardObject at line 38
protected StandardObject
SetDate(string $name, float|null $value = null)
Sets the value of the given date field to the given value
in
StandardObject at line 44
float
GetDateCreated()
Returns the timestamp when this object was created
in
StandardObject at line 58
protected int
GetFeatureInt(string $name, bool $allowTemp = true)
Gets the value of the given feature field as an int (used for config)
in
StandardObject at line 65
protected int|null
TryGetFeatureInt(string $name, bool $allowTemp = true)
Gets the value of the given feature field as an int (used for config)
in
StandardObject at line 75
protected bool
GetFeatureBool(string $name, bool $allowTemp = true)
Gets the value of the given feature field as a bool (used for config)
in
StandardObject at line 82
protected bool|null
TryGetFeatureBool(string $name, bool $allowTemp = true)
Gets the value of the given feature field as a bool (used for config)
in
StandardObject at line 93
protected StandardObject
SetFeatureInt(string $name, int|null $value, bool $temp = false)
Sets the value of the given feature field to the given (?int) value
in
StandardObject at line 101
protected StandardObject
SetFeatureBool(string $name, bool|null $value, bool $temp = false)
Sets the value of the given feature field to the given (?bool) value
in
StandardObject at line 105
protected bool
isFeatureModified(string $name)
Returns true if the given feature has been modified
in
Timed at line 146
protected int
GetCounter(string $name)
Gets the value of the given counter field
in
StandardObject at line 121
protected int
GetCounterLimit(string $name)
Gets the value of the given counter limit field
in
StandardObject at line 128
protected int|null
TryGetCounterLimit(string $name)
Gets the value of the given counter limit field
in
StandardObject at line 140
protected StandardObject
SetCounterLimit(string $name, int|null $value, bool $temp = false)
Sets the value of the given counter limit field
in
StandardObject at line 151
protected bool
CheckCounter(string $name, int $delta = 0, bool $except = true)
Checks whether the given counter plus a delta would exceed the limit
in
StandardObject at line 202
protected array
GetAllScalars(string|null $prefix)
Gets an array of the values of all fields matching a prefix
at line 295
protected Base
Initialize()
Initializes group limits by adding a limit for each member account
in
GroupCommon at line 73
static string
GetBaseUsage()
No description
in
GroupCommon at line 84
protected void
SetBaseLimits(Input $input)
No description
in
Timed at line 161
static string
BaseConfigUsage()
Returns the command usage for BaseConfigLimits()
at line 308
static protected
BaseConfigLimits(ObjectDatabase $database, StandardObject $obj, Input $input)
No description
in
Base at line 55
StandardObject
GetLimitedObject()
Returns the object that is subject to the limits
in
GroupCommon at line 52
protected bool
canTrackItems()
No description
in
GroupCommon at line 53
protected bool
canTrackDLStats()
No description
in
Base at line 64
Base
CountSize(int $delta, bool $noLimit = false)
Adds to the size counter, if item tracking is allowed
in
Base at line 67
Base
CountItem(bool $count = true)
Increments the item counter, if item tracking is allowed. Decrements if not $count
in
Base at line 70
Base
CountItems(int $items, bool $noLimit = false)
Increments the item counter by the given value, if item tracking is allowed
in
Base at line 73
Base
CountShare(bool $count = true)
Increments the share counter, if item tracking is allowed. Decrements if not $count
in
Base at line 76
Base
CountShares(int $shares, bool $noLimit = false)
Increments the share counter by the given value, if item tracking is allowed
in
Base at line 79
Base
CountPublicDownload()
Increments the public download counter, if download tracking is allowed
in
Base at line 82
Base
CountPublicDownloads(int $dls, bool $noLimit = false)
Increments the public download counter by the given value, if DL tracking is allowed
in
Base at line 85
Base
CountBandwidth(int $delta, bool $noLimit = false)
Adds to the bandwidth counter, if download tracking is allowed
in
Base at line 91
void
CheckSize(int $delta)
Checks if the given size delta would exceed the size limit
in
Base at line 97
void
CheckBandwidth(int $delta)
Checks if the given bandwidth would exceed the limit
in
Base at line 100
Base
AddFileCounts(File $file, bool $add = true, bool $noLimit = false)
Adds stats from the given file to this limit object
in
Base at line 124
Base
AddFolderCounts(Folder $folder, bool $add = true, bool $noLimit = false)
Adds stats from the given folder to this limit object
in
Base at line 139
Base
AddCumulativeFolderCounts(Folder $folder, bool $add = true, bool $noLimit = false)
Adds cumulative stats from the given folder to this limit object
in
Base at line 160
protected int
GetPublicDownloads()
Returns the public downloads counter for the limited object
in
Base at line 163
protected int
GetBandwidth()
Returns the bandwidth counter for the limited object
in
Base at line 166
protected int
GetSize()
Returns the size counter for the limited object
in
Base at line 169
protected int
GetItems()
Returns the item counter for the limited object
in
Base at line 172
protected int
GetShares()
Returns the share counter for the limited object
in
GroupCommon at line 126
array
GetClientObject(bool $isadmin = false)
No description
in
GroupCommon at line 41
static protected string
GetObjectClass()
No description
in
Timed at line 45
int
GetTimePeriod()
Returns the time period for this timed limit
in
Timed at line 50
int
GetMaxStatsAge()
Returns the maximum stats history age (-1 for forever - default)
in
Timed at line 62
static array
LoadAllForPeriod(ObjectDatabase $database, int $period, int|null $count = null, int|null $offset = null)
Returns all Timed Limits with the given time period
in
Timed at line 75
static array
LoadAllForClient(ObjectDatabase $database, StandardObject $obj)
Returns all timed limits for the given limited object (all time periods)
in
Timed at line 97
static Timed|null
LoadByClientAndPeriod(ObjectDatabase $database, StandardObject $obj, int $period)
Loads the limit object for the given object and time period
in
Timed at line 107
static void
DeleteByClient(ObjectDatabase $database, StandardObject $obj)
Deletes all limit objects corresponding to the given limited object
in
Timed at line 115
static void
DeleteByClientAndPeriod(ObjectDatabase $database, StandardObject $obj, int $period)
Deletes all limit objects corresponding to the given limited object and time period
in
Timed at line 129
static protected Timed
CreateTimed(ObjectDatabase $database, StandardObject $obj, int $timeperiod)
Creates and caches a new timed limit for the given object
in
Timed at line 143
protected TimedStats
GetCurrentStats()
Loads and returns the current stats for this limit
in
AuthEntityTimed at line 41
static string
GetTimedUsage()
Returns the command usage for SetTimedLimits()
in
AuthEntityTimed at line 43
protected void
SetTimedLimits(Input $input)
Sets config for a timed limit
in
Timed at line 159
static string
GetConfigUsage()
No description
in
GroupCommon at line 44
string
GetGroupID()
Returns the ID of the limited group
in
GroupCommon at line 47
Group
GetGroup()
Returns the limited group object
in
GroupCommon at line 50
int
GetPriority()
Returns the inheritance priority of the limited group
in
GroupCommon at line 56
protected bool
IsCounterOverLimit(string $name, int $delta = 0)
No description
in
GroupCommon at line 63
protected void
BaseProcessAccountChange(Base $aclim, bool $add)
Updates the group's stats by adding or subtracting an account's stats
in
GroupCommon at line 76
static protected int|null
GetTrackParam(Input $input, string $name)
No description
in
GroupCommon at line 104
static GroupCommon
ConfigLimits(ObjectDatabase $database, Group $group, Input $input)
Configures limits for the given group with the given input
at line 232
void
ProcessAccountChange(AccountTimed $aclim, bool $add)
No description
at line 241
protected array
GetAccounts()
loads account limits via a JOIN, caches, and returns them
at line 278
static GroupTimed|null
LoadByGroup(ObjectDatabase $database, Group $group, int $period)
Loads the timed limit for the given group and time period
at line 289
static array
LoadAllForGroup(ObjectDatabase $database, Group $group)
Returns all timed limits for the given group