class AccountTimed extends AuthEntityTimed

Concrete class providing timed account limits

Traits

Account limits common between total and timed

Trait that overrides some BaseObject functions to allow inheriting properties from Groups

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 $grouplims

cache of group limits that apply to this account

Methods

static array
GetFieldTemplate()

Gets a template array of the object's properties (columns).

from  Timed
static string
GetDBClass()

Returns the name of the class that should be used in the database for the table name (cast down at save)

from  Timed
static string
GetObjClass(array $row)

No description

static int
CountByQuery(ObjectDatabase $database, QueryBuilder $query)

Counts objects in the DB matching the given query

static array
LoadByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads an array of objects from the DB matching the given query

static int
DeleteByQuery(ObjectDatabase $database, QueryBuilder $query)

Deletes objects from the DB matching the given query

static BaseObject|null
TryLoadUniqueByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads a unique object matching the given query

static BaseObject
NotNull(BaseObject|null $obj)

Asserts that the given object is not null

static BaseObject|null
TryLoadByID(ObjectDatabase $database, string $id)

Loads a unique object by its ID

static void
DeleteByID(ObjectDatabase $database, string $id)

Deletes a unique object by its ID

static array
LoadAll(ObjectDatabase $database, int|null $limit = null, int|null $offset = null)

Loads all objects of this type from the database

from  Base
static int
DeleteAll(ObjectDatabase $database)

Deletes all objects of this type from the database

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

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

static BaseObject|null
TryLoadUniqueByKey(ObjectDatabase $database, string $field, string $key)

Loads a unique object matching the given field

static bool
TryDeleteByUniqueKey(ObjectDatabase $database, string $field, string $key)

Deletes a unique object matching the given field

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

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

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

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

string
ID()

Returns the unique ID of the object

string
__toString()

Returns the string "id:class" where id is the object ID and class is its short class name

static string|null
toString(BaseObject|null $obj)

Returns the given object's as a string if not null, else null

GetScalar(string $field, bool $allowTemp = true)

No description

TryGetScalar(string $field, bool $allowTemp = true)

No description

int
GetScalarDelta(string $field)

Returns the delta of the given scalar (non-zero if modified)

GetObject(string $field)

No description

BaseObject|null
TryGetObject(string $field)

No description

bool
HasObject(string $field)

Checks if the object reference is not-null without actually loading it (faster)

string
GetObjectID(string $field)

Gets the ID of a referenced object without actually loading it (faster)

string|null
TryGetObjectID(string $field)

Same as GetObjectID() but returns null instead of throwing exceptions

string
GetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

string|null
TryGetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

DeleteObject(string $field)

Deletes the object referenced in the field

array
GetObjectRefs(string $field, int|null $limit = null, int|null $offset = null)

Gets an array of objects that reference this object

int
CountObjectRefs(string $field)

Gets the counter of objects referencing this object

GetJoinObject(string $field, BaseObject $obj)

Loads the object that joins together two classes using a FieldTypes\ObjectJoin

StandardObject|null
TryGetJoinObject(string $field, BaseObject $obj)

Same as GetJoinObject() but returns null instead of throwing exceptions

DeleteObjects(string $field)

Deletes all objects that reference this object

SetScalar(string $field, mixed $value, bool $temp = false)

Sets a scalar field to the given value

DeltaCounter(string $name, int $delta = 1, bool $ignoreLimit = false)

Increment a counter by the given value

from  Timed
bool
BoolSetObject(string $field, BaseObject|null $object, bool $notification = false)

Sets a field to reference the given object

SetObject(string $field, BaseObject|null $object, bool $notification = false)

Same as BoolSetObject() but returns $this

bool
AddObjectRef(string $field, BaseObject $object, bool $notification = false)

Adds an object reference, checking for a limit on the number of references

bool
RemoveObjectRef(string $field, BaseObject $object, bool $notification = false)

Removes the given object from a collection of referenced objects

__construct(ObjectDatabase $database, array $data)

Constructs the object by initializing its field template with values from the database

AddField(string $key, Scalar $field)

Adds the given field object to the correct internal array

void
SubConstruct()

register a group change handler that updates this specific object's grouplim cache

Save(bool $onlyMandatory = false)

Collects fields that have changed and saves them to the database

bool
isDeleted()

whether or not this object has been, or should be considered, deleted

void
NotifyDBDeleted()

Deletes this object without sending to the DB

void
Delete()

Deletes this object from the DB

void
DeleteLater()

Schedules the object to be deleted when Save() is called

bool
isCreated()

True if this object has been created and not yet saved to DB (should not be overriden)

static BaseObject
BaseCreate(ObjectDatabase $database)

Create the object by setting its created date

float
GetDate(string $name)

Returns the timestamp value stored in the given date field

float|null
TryGetDate(string $name)

Returns the timestamp value stored in the given date field

SetDate(string $name, float|null $value = null)

Sets the value of the given date field to the given value

float
GetDateCreated()

Returns the timestamp when this object was created

int
GetFeatureInt(string $name, bool $allowTemp = true)

Gets the value of the given feature field as an int (used for config)

int|null
TryGetFeatureInt(string $name, bool $allowTemp = true)

Gets the value of the given feature field as an int (used for config)

bool
GetFeatureBool(string $name, bool $allowTemp = true)

Gets the value of the given feature field as a bool (used for config)

bool|null
TryGetFeatureBool(string $name, bool $allowTemp = true)

Gets the value of the given feature field as a bool (used for config)

SetFeatureInt(string $name, int|null $value, bool $temp = false)

Sets the value of the given feature field to the given (?int) value

SetFeatureBool(string $name, bool|null $value, bool $temp = false)

Sets the value of the given feature field to the given (?bool) value

bool
isFeatureModified(string $name)

Returns true if the given feature has been modified

int
GetCounter(string $name)

Gets the value of the given counter field

from  Timed
int
GetCounterLimit(string $name)

Gets the value of the given counter limit field

int|null
TryGetCounterLimit(string $name)

Gets the value of the given counter limit field

SetCounterLimit(string $name, int|null $value, bool $temp = false)

Sets the value of the given counter limit field

bool
CheckCounter(string $name, int $delta = 0, bool $except = true)

Checks whether the given counter plus a delta would exceed the limit

array
GetAllScalars(string|null $prefix)

Gets an array of the values of all fields matching a prefix

Initialize()

Initializes the limit by gathering statistics

from  Timed
static string
GetBaseUsage()

No description

void
SetBaseLimits(Input $input)

No description

static string
BaseConfigUsage()

Returns the command usage for BaseConfigLimits()

from  Timed
static 
BaseConfigLimits(ObjectDatabase $database, StandardObject $obj, Input $input)

No description

from  Timed
GetLimitedObject()

Returns the object that is subject to the limits

from  Base
bool
canTrackItems()

Returns true if we should track size, item count, and share count

from  Base
bool
canTrackDLStats()

Returns true if we should count public downloads and bandwidth

from  Base
CountSize(int $delta, bool $noLimit = false)

Adds to the size counter, if item tracking is allowed

from  Base
CountItem(bool $count = true)

Increments the item counter, if item tracking is allowed. Decrements if not $count

from  Base
CountItems(int $items, bool $noLimit = false)

Increments the item counter by the given value, if item tracking is allowed

from  Base
CountShare(bool $count = true)

Increments the share counter, if item tracking is allowed. Decrements if not $count

from  Base
CountShares(int $shares, bool $noLimit = false)

Increments the share counter by the given value, if item tracking is allowed

from  Base
CountPublicDownload()

Increments the public download counter, if download tracking is allowed

from  Base
CountPublicDownloads(int $dls, bool $noLimit = false)

Increments the public download counter by the given value, if DL tracking is allowed

from  Base
CountBandwidth(int $delta, bool $noLimit = false)

Adds to the bandwidth counter, if download tracking is allowed

from  Base
void
CheckSize(int $delta)

Checks if the given size delta would exceed the size limit

from  Base
void
CheckBandwidth(int $delta)

Checks if the given bandwidth would exceed the limit

from  Base
AddFileCounts(File $file, bool $add = true, bool $noLimit = false)

Adds stats from the given file to this limit object

from  Base
AddFolderCounts(Folder $folder, bool $add = true, bool $noLimit = false)

Adds stats from the given folder to this limit object

from  Base
AddCumulativeFolderCounts(Folder $folder, bool $add = true, bool $noLimit = false)

Adds cumulative stats from the given folder to this limit object

from  Base
int
GetPublicDownloads()

Returns the public downloads counter for the limited object

from  Base
int
GetBandwidth()

Returns the bandwidth counter for the limited object

from  Base
int
GetSize()

Returns the size counter for the limited object

from  Base
int
GetItems()

Returns the item counter for the limited object

from  Base
int
GetShares()

Returns the share counter for the limited object

from  Base
array
GetClientObject(bool $isadmin = false)

Returns a printable client object that includes property inherit sources

static string
GetObjectClass()

No description

int
GetTimePeriod()

Returns the time period for this timed limit

from  Timed
int
GetMaxStatsAge()

Returns the maximum stats history age (-1 for forever - default)

from  Timed
static array
LoadAllForPeriod(ObjectDatabase $database, int $period, int|null $count = null, int|null $offset = null)

Returns all Timed Limits with the given time period

from  Timed
static array
LoadAllForClient(ObjectDatabase $database, StandardObject $obj)

Returns all timed limits for the given limited object (all time periods)

from  Timed
static Timed|null
LoadByClientAndPeriod(ObjectDatabase $database, StandardObject $obj, int $period)

Loads the limit object for the given object and time period

from  Timed
static void
DeleteByClient(ObjectDatabase $database, StandardObject $obj)

Deletes all limit objects corresponding to the given limited object

from  Timed
static void
DeleteByClientAndPeriod(ObjectDatabase $database, StandardObject $obj, int $period)

Deletes all limit objects corresponding to the given limited object and time period

from  Timed
static Timed
CreateTimed(ObjectDatabase $database, StandardObject $obj, int $timeperiod)

Creates and caches a new timed limit for the given object

from  Timed
GetCurrentStats()

Loads and returns the current stats for this limit

from  Timed
static string
GetTimedUsage()

Returns the command usage for SetTimedLimits()

void
SetTimedLimits(Input $input)

Sets config for a timed limit

static string
GetConfigUsage()

No description

from  Timed
BaseObject|null
TryGetInheritsScalarFrom(string $field)

Returns the object that the value of the given field is inherited from

BaseObject|null
TryGetInheritsObjectFrom(string $field)

Returns the object that the value of the given field is inherited from

TryGetInheritable(string $field, bool $useobj = false)

Returns an inherited property value and source pair

string
GetAccountID()

Returns the ID of the limited account

GetAccount()

Returns the limited account

static AccountCommon
ConfigLimits(ObjectDatabase $database, Account $account, Input $input)

Configures limits for the given account with the given input

void
BaseProcessGroupRemove(Base $grlim)

Processes a group membership removal, possibly deleting this account limit

void
ProcessGroupRemove(GroupTimed $grlim)

No description

BaseObject|null
GetsMaxStatsAgeFrom()

Returns the object from which this account limit inherits its max stats age

array
GetGroups()

loads group limits via a JOIN, caches, and returns them

array
GetInheritedFields()

No description

static AccountTimed|null
LoadByAccount(ObjectDatabase $database, Account $account, int $period)

Returns the Timed limits for the given account and time period

static AccountTimed
ForceLoadByAccount(ObjectDatabase $database, Account $account, int $period)

Returns the Timed limits for the given account and time period, creating if it does not exist

static array
LoadAllForAccountAll(ObjectDatabase $database, Account $account)

Returns all timed limits for the given account and its groups

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.

Return Value

array

array of FieldTypes indexed by field names

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.

Return Value

string

in BaseObject at line 60
static string GetObjClass(array $row)

No description

Parameters

array $row

Return Value

string

in BaseObject at line 68
static int CountByQuery(ObjectDatabase $database, QueryBuilder $query)

Counts objects in the DB matching the given query

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

The query to use for matching objects

Return Value

int

count of matched objects

in BaseObject at line 79
static array LoadByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads an array of objects from the DB matching the given query

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

The query to use for matching objects

Return Value

array

array of objects indexed by their IDs

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

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

The query to use for matching objects

Return Value

int

number of objects deleted

in BaseObject at line 103
static BaseObject|null TryLoadUniqueByQuery(ObjectDatabase $database, QueryBuilder $query)

Loads a unique object matching the given query

Parameters

ObjectDatabase $database

Reference to the database

QueryBuilder $query

the query to uniquely identify the object

Return Value

BaseObject|null

in BaseObject at line 116
static BaseObject NotNull(BaseObject|null $obj)

Asserts that the given object is not null

Parameters

BaseObject|null $obj

the object to check for null

Return Value

BaseObject

object if not null

Exceptions

ObjectNotFoundException

if the object is null

in BaseObject at line 127
static BaseObject|null TryLoadByID(ObjectDatabase $database, string $id)

Loads a unique object by its ID

Parameters

ObjectDatabase $database

Reference to the database

string $id

the ID of the object

Return Value

BaseObject|null

object or null if not found

in BaseObject at line 137
static void DeleteByID(ObjectDatabase $database, string $id)

Deletes a unique object by its ID

Parameters

ObjectDatabase $database

Reference to the database

string $id

the ID of the object

Return Value

void

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

Parameters

ObjectDatabase $database

Reference to the database

int|null $limit

the maximum number of objects to load

int|null $offset

the number of objects to skip loading

Return Value

array

array of objects indexed by their IDs

in BaseObject at line 160
static int DeleteAll(ObjectDatabase $database)

Deletes all objects of this type from the database

Parameters

ObjectDatabase $database

Reference to the database

Return Value

int

number of deleted objects

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

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

string $id

The ID of the object referenced

string|null $class

optionally, the class to match if this column is polymorphic

Return Value

array

array of objects indexed by their IDs

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

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

string $id

The ID of the object referenced

string|null $class

optionally, the class to match if this column is polymorphic

Return Value

int

number of rows deleted

in BaseObject at line 206
static protected BaseObject|null TryLoadUniqueByKey(ObjectDatabase $database, string $field, string $key)

Loads a unique object matching the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

the name of the field to check

string $key

the value of the field that uniquely identifies the object

Return Value

BaseObject|null

in BaseObject at line 218
static protected bool TryDeleteByUniqueKey(ObjectDatabase $database, string $field, string $key)

Deletes a unique object matching the given field

Parameters

ObjectDatabase $database

Reference to the database

string $field

the name of the field to check

string $key

the value of the field that uniquely identifies the object

Return Value

bool

true if an object was deleted

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

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

array

array of objects indexed by their IDs

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

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

int

number of deleted objects

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

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

BaseObject|null

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

Parameters

ObjectDatabase $database

Reference to the database

string $field

The name of the field to check

BaseObject $object

the object referenced by the field

bool $isPoly

whether or not this field is polymorphic

Return Value

bool

true if an object was deleted

in BaseObject at line 284
string ID()

Returns the unique ID of the object

Return Value

string

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

Return Value

string

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

Parameters

BaseObject|null $obj

Return Value

string|null

in GroupInherit at line 817
protected GetScalar(string $field, bool $allowTemp = true)

No description

Parameters

string $field
bool $allowTemp

in GroupInherit at line 825
protected TryGetScalar(string $field, bool $allowTemp = true)

No description

Parameters

string $field
bool $allowTemp

in BaseObject at line 336
protected int GetScalarDelta(string $field)

Returns the delta of the given scalar (non-zero if modified)

Parameters

string $field

the field name of the scalar

Return Value

int

of times modified for scalars, delta for counters

Exceptions

KeyNotFoundException

if the field name is invalid

in GroupInherit at line 832
protected BaseObject GetObject(string $field)

No description

Parameters

string $field

Return Value

BaseObject

in GroupInherit at line 840
protected BaseObject|null TryGetObject(string $field)

No description

Parameters

string $field

Return Value

BaseObject|null

in BaseObject at line 379
protected bool HasObject(string $field)

Checks if the object reference is not-null without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

bool

true if the object reference is not null

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 394
protected string GetObjectID(string $field)

Gets the ID of a referenced object without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

string

the ID of the referenced object

Exceptions

KeyNotFoundException

if the field name is invalid

NullValueException

if the field value is null

in BaseObject at line 408
protected string|null TryGetObjectID(string $field)

Same as GetObjectID() but returns null instead of throwing exceptions

Parameters

string $field

Return Value

string|null

See also

BaseObject::GetObjectID

in BaseObject at line 422
protected string GetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

string

the class name of the referenced object

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 438
protected string|null TryGetObjectType(string $field)

Gets the class name of a referenced object without actually loading it (faster)

Parameters

string $field

the field name holding the reference

Return Value

string|null

the class name of the referenced object

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 451
protected BaseObject DeleteObject(string $field)

Deletes the object referenced in the field

Parameters

string $field

the field name holding the reference

Return Value

BaseObject

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

Parameters

string $field

the field name of the collection

int|null $limit

the maximum number of objects to load

int|null $offset

the number of objects to skip loading

Return Value

array

array of objects indexed by their IDs

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 481
protected int CountObjectRefs(string $field)

Gets the counter of objects referencing this object

Parameters

string $field

the field name of the collection

Return Value

int

the number of objects

Exceptions

KeyNotFoundException

if the field name is invalid

in BaseObject at line 497
protected StandardObject GetJoinObject(string $field, BaseObject $obj)

Loads the object that joins together two classes using a FieldTypes\ObjectJoin

Parameters

string $field

the field name using the join reference

BaseObject $obj

the object that is joined together with this one

Return Value

StandardObject

the join object that connects us to $obj

Exceptions

KeyNotFoundException

if the field name is invalid

NullValueException

if the given object is not joined to us

in BaseObject at line 514
protected StandardObject|null TryGetJoinObject(string $field, BaseObject $obj)

Same as GetJoinObject() but returns null instead of throwing exceptions

Parameters

string $field
BaseObject $obj

Return Value

StandardObject|null

See also

BaseObject::GetJoinObject

in BaseObject at line 530
protected BaseObject DeleteObjects(string $field)

Deletes all objects that reference this object

Parameters

string $field

the field name of the collection

Return Value

BaseObject

in BaseObject at line 546
protected BaseObject SetScalar(string $field, mixed $value, bool $temp = false)

Sets a scalar field to the given value

Parameters

string $field

the name of the field

mixed $value

the value of the scalar to set

bool $temp

if true, the value is temporary and will not be saved

Return Value

BaseObject

Exceptions

KeyNotFoundException

if the property name is invalid

in Timed at line 148
protected BaseObject DeltaCounter(string $name, int $delta = 1, bool $ignoreLimit = false)

Increment a counter by the given value

Parameters

string $name

the name of the counter field to increment

int $delta

the value to increment by

bool $ignoreLimit

if true, ignore the counter's limit

Return Value

BaseObject

Exceptions

CounterOverLimitException

if the counter's limit exists and is exceeded

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

Parameters

string $field

the name of the reference field

BaseObject|null $object

the object for the field to reference

bool $notification

true if this is a notification from another object that cross-references this one (internal only!)

Return Value

bool

true if this object was modified

Exceptions

KeyNotFoundException

if the property name is invalid

in BaseObject at line 649
protected BaseObject SetObject(string $field, BaseObject|null $object, bool $notification = false)

Same as BoolSetObject() but returns $this

Parameters

string $field
BaseObject|null $object
bool $notification

Return Value

BaseObject

See also

BaseObject::BoolSetObject

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

Parameters

string $field

the name of the field of the collection

BaseObject $object

the object to add to the collection

bool $notification

true if this is a notification from another object that cross-references this one (internal only!)

Return Value

bool

true if this object was modified

Exceptions

CounterOverLimitException

if the limit exists and is exceeded

See also

BaseObject::AddObjectRef

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

Parameters

string $field

the name of the field of the collection

BaseObject $object

the object to add to the collection

bool $notification

true if this is a notification from another object that cross-references this one (internal only!)

Return Value

bool

true if this object was modified

Exceptions

KeyNotFoundException

if the property name is invalid

in BaseObject at line 727
__construct(ObjectDatabase $database, array $data)

Constructs the object by initializing its field template with values from the database

Parameters

ObjectDatabase $database

Reference to the database

array $data

array of columns from the DB in the form of name=>value

in BaseObject at line 750
private AddField(string $key, Scalar $field)

Adds the given field object to the correct internal array

Parameters

string $key
Scalar $field

at line 331
protected void SubConstruct()

register a group change handler that updates this specific object's grouplim cache

Return Value

void

in BaseObject at line 771
BaseObject Save(bool $onlyMandatory = false)

Collects fields that have changed and saves them to the database

Parameters

bool $onlyMandatory

true if only required fields should be saved

Return Value

BaseObject

Exceptions

RowInsertFailedException

if the insert fails (duplicate?)

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

Return Value

bool

in BaseObject at line 820
void NotifyDBDeleted()

Deletes this object without sending to the DB

Return Value

void

in BaseObject at line 823
void Delete()

Deletes this object from the DB

Return Value

void

in BaseObject at line 849
protected void DeleteLater()

Schedules the object to be deleted when Save() is called

Return Value

void

in BaseObject at line 855
bool isCreated()

True if this object has been created and not yet saved to DB (should not be overriden)

Return Value

bool

in StandardObject at line 51
static protected BaseObject BaseCreate(ObjectDatabase $database)

Create the object by setting its created date

Parameters

ObjectDatabase $database

Return Value

BaseObject

See also

BaseObject::BaseCreate

in StandardObject at line 23
protected float GetDate(string $name)

Returns the timestamp value stored in the given date field

Parameters

string $name

Return Value

float

See also

BaseObject::GetScalar

in StandardObject at line 29
protected float|null TryGetDate(string $name)

Returns the timestamp value stored in the given date field

Parameters

string $name

Return Value

float|null

See also

BaseObject::TryGetScalar

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

Parameters

string $name

the name of the date field to set

float|null $value

the value of the timestamp, or null to use the current time

Return Value

StandardObject

See also

BaseObject::SetScalar

in StandardObject at line 44
float GetDateCreated()

Returns the timestamp when this object was created

Return Value

float

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)

Parameters

string $name
bool $allowTemp

Return Value

int

See also

BaseObject::GetScalar

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)

Parameters

string $name
bool $allowTemp

Return Value

int|null

See also

BaseObject::GetScalar

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)

Parameters

string $name
bool $allowTemp

Return Value

bool

See also

BaseObject::GetScalar

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)

Parameters

string $name
bool $allowTemp

Return Value

bool|null

See also

BaseObject::GetScalar

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

Parameters

string $name
int|null $value
bool $temp

Return Value

StandardObject

See also

BaseObject::SetScalar

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

Parameters

string $name
bool|null $value
bool $temp

Return Value

StandardObject

See also

BaseObject::SetScalar

in StandardObject at line 105
protected bool isFeatureModified(string $name)

Returns true if the given feature has been modified

Parameters

string $name

Return Value

bool

in Timed at line 146
protected int GetCounter(string $name)

Gets the value of the given counter field

Parameters

string $name

Return Value

int

in StandardObject at line 121
protected int GetCounterLimit(string $name)

Gets the value of the given counter limit field

Parameters

string $name

Return Value

int

See also

BaseObject::GetScalar

in StandardObject at line 128
protected int|null TryGetCounterLimit(string $name)

Gets the value of the given counter limit field

Parameters

string $name

Return Value

int|null

See also

BaseObject::TryGetScalar

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

Parameters

string $name
int|null $value
bool $temp

Return Value

StandardObject

See also

BaseObject::SetScalar

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

Parameters

string $name

the name of the counter and counter limit field to check

int $delta

the value to try incrementing the counter by

bool $except

if true, throw an exception instead of returning false

Return Value

bool

if true, the limit exists and is not exceeded

Exceptions

CounterOverLimitException

if $except and retval is false

in StandardObject at line 202
protected array GetAllScalars(string|null $prefix)

Gets an array of the values of all fields matching a prefix

Parameters

string|null $prefix

the prefix to match fields against, or null to get all

Return Value

array

mapping field names (stripped of their prefix) to their values

See also

BaseObject::TryGetScalar

in Timed at line 52
protected Base Initialize()

Initializes the limit by gathering statistics

Return Value

Base

in AccountCommon at line 82
static string GetBaseUsage()

No description

Return Value

string

in AccountCommon at line 84
protected void SetBaseLimits(Input $input)

No description

Parameters

Input $input

Return Value

void

in Timed at line 161
static string BaseConfigUsage()

Returns the command usage for BaseConfigLimits()

Return Value

string

in Timed at line 164
static protected BaseConfigLimits(ObjectDatabase $database, StandardObject $obj, Input $input)

No description

Parameters

ObjectDatabase $database
StandardObject $obj
Input $input

in Base at line 55
StandardObject GetLimitedObject()

Returns the object that is subject to the limits

Return Value

StandardObject

in Base at line 58
protected bool canTrackItems()

Returns true if we should track size, item count, and share count

Return Value

bool

in Base at line 61
protected bool canTrackDLStats()

Returns true if we should count public downloads and bandwidth

Return Value

bool

in Base at line 64
Base CountSize(int $delta, bool $noLimit = false)

Adds to the size counter, if item tracking is allowed

Parameters

int $delta
bool $noLimit

Return Value

Base

in Base at line 67
Base CountItem(bool $count = true)

Increments the item counter, if item tracking is allowed. Decrements if not $count

Parameters

bool $count

Return Value

Base

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

Parameters

int $items
bool $noLimit

Return Value

Base

in Base at line 73
Base CountShare(bool $count = true)

Increments the share counter, if item tracking is allowed. Decrements if not $count

Parameters

bool $count

Return Value

Base

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

Parameters

int $shares
bool $noLimit

Return Value

Base

in Base at line 79
Base CountPublicDownload()

Increments the public download counter, if download tracking is allowed

Return Value

Base

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

Parameters

int $dls
bool $noLimit

Return Value

Base

in Base at line 85
Base CountBandwidth(int $delta, bool $noLimit = false)

Adds to the bandwidth counter, if download tracking is allowed

Parameters

int $delta
bool $noLimit

Return Value

Base

in Base at line 91
void CheckSize(int $delta)

Checks if the given size delta would exceed the size limit

Parameters

int $delta

Return Value

void

See also

StandardObject::CheckCounter

in Base at line 97
void CheckBandwidth(int $delta)

Checks if the given bandwidth would exceed the limit

Parameters

int $delta

Return Value

void

See also

StandardObject::CheckCounter

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

Parameters

File $file
bool $add
bool $noLimit

Return Value

Base

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

Parameters

Folder $folder
bool $add
bool $noLimit

Return Value

Base

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

Parameters

Folder $folder
bool $add
bool $noLimit

Return Value

Base

in Base at line 160
protected int GetPublicDownloads()

Returns the public downloads counter for the limited object

Return Value

int

in Base at line 163
protected int GetBandwidth()

Returns the bandwidth counter for the limited object

Return Value

int

in Base at line 166
protected int GetSize()

Returns the size counter for the limited object

Return Value

int

in Base at line 169
protected int GetItems()

Returns the item counter for the limited object

Return Value

int

in Base at line 172
protected int GetShares()

Returns the share counter for the limited object

Return Value

int

in AccountCommon at line 61
array GetClientObject(bool $isadmin = false)

Returns a printable client object that includes property inherit sources

Parameters

bool $isadmin

if true, show property inherit sources

Return Value

array

{features:{track_items:bool,track_dlstats:bool}, features_from:"id:class", limits_from:"id:class"}

See also

Total::GetClientObject
Timed::GetClientObject

in AccountCommon at line 36
static protected string GetObjectClass()

No description

Return Value

string

in Timed at line 45
int GetTimePeriod()

Returns the time period for this timed limit

Return Value

int

in Timed at line 50
int GetMaxStatsAge()

Returns the maximum stats history age (-1 for forever - default)

Return Value

int

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

Parameters

ObjectDatabase $database

database reference

int $period

time period

int|null $count

max objects to load

int|null $offset

offset for loading

Return Value

array

limits indexed by ID

in Timed at line 75
static array LoadAllForClient(ObjectDatabase $database, StandardObject $obj)

Returns all timed limits for the given limited object (all time periods)

Parameters

ObjectDatabase $database

database reference

StandardObject $obj

the limited object

Return Value

array

limits indexed by ID

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

Parameters

ObjectDatabase $database

database reference

StandardObject $obj

the limited object

int $period

the time period

Return Value

Timed|null

limit object or null if none

in Timed at line 107
static void DeleteByClient(ObjectDatabase $database, StandardObject $obj)

Deletes all limit objects corresponding to the given limited object

Parameters

ObjectDatabase $database
StandardObject $obj

Return Value

void

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

Parameters

ObjectDatabase $database
StandardObject $obj
int $period

Return Value

void

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

Parameters

ObjectDatabase $database

database reference

StandardObject $obj

object to limit

int $timeperiod

time period for limit

Return Value

Timed

new limit object

in Timed at line 143
protected TimedStats GetCurrentStats()

Loads and returns the current stats for this limit

Return Value

TimedStats

in AuthEntityTimed at line 41
static string GetTimedUsage()

Returns the command usage for SetTimedLimits()

Return Value

string

in AuthEntityTimed at line 43
protected void SetTimedLimits(Input $input)

Sets config for a timed limit

Parameters

Input $input

Return Value

void

in Timed at line 159
static string GetConfigUsage()

No description

Return Value

string

in GroupInherit at line 848
protected BaseObject|null TryGetInheritsScalarFrom(string $field)

Returns the object that the value of the given field is inherited from

Parameters

string $field

Return Value

BaseObject|null

in GroupInherit at line 854
protected BaseObject|null TryGetInheritsObjectFrom(string $field)

Returns the object that the value of the given field is inherited from

Parameters

string $field

Return Value

BaseObject|null

in GroupInherit at line 868
protected InheritedProperty TryGetInheritable(string $field, bool $useobj = false)

Returns an inherited property value and source pair

Values can be inherited from this account, from any group it is a member of, or if using a default value, null

Parameters

string $field

the inherited property to find

bool $useobj

true if this is an object reference, not a scalar

Return Value

InheritedProperty

value/source pair

in AccountCommon at line 39
protected string GetAccountID()

Returns the ID of the limited account

Return Value

string

in AccountCommon at line 42
protected Account GetAccount()

Returns the limited account

Return Value

Account

in AccountCommon at line 104
static AccountCommon ConfigLimits(ObjectDatabase $database, Account $account, Input $input)

Configures limits for the given account with the given input

Parameters

ObjectDatabase $database
Account $account
Input $input

Return Value

AccountCommon

in AccountCommon at line 116
protected void BaseProcessGroupRemove(Base $grlim)

Processes a group membership removal, possibly deleting this account limit

The account limit will be deleted if it does not have any properties that were set specifically for it, and no other group limits applicable to it exist

Parameters

Base $grlim

group to remove

Return Value

void

at line 291
void ProcessGroupRemove(GroupTimed $grlim)

No description

Parameters

GroupTimed $grlim

Return Value

void

at line 297
BaseObject|null GetsMaxStatsAgeFrom()

Returns the object from which this account limit inherits its max stats age

Return Value

BaseObject|null

at line 309
protected array GetGroups()

loads group limits via a JOIN, caches, and returns them

Return Value

array

group limits indexed by ID

at line 345
protected array GetInheritedFields()

No description

Return Value

array

at line 354
static AccountTimed|null LoadByAccount(ObjectDatabase $database, Account $account, int $period)

Returns the Timed limits for the given account and time period

Parameters

ObjectDatabase $database
Account $account
int $period

Return Value

AccountTimed|null

at line 360
static AccountTimed ForceLoadByAccount(ObjectDatabase $database, Account $account, int $period)

Returns the Timed limits for the given account and time period, creating if it does not exist

Parameters

ObjectDatabase $database
Account $account
int $period

Return Value

AccountTimed

at line 373
static array LoadAllForAccountAll(ObjectDatabase $database, Account $account)

Returns all timed limits for the given account and its groups

Parameters

ObjectDatabase $database

database reference

Account $account

account of interest

Return Value

array

limits indexed by ID