SubFolder
class SubFolder extends Folder
A subfolder has a parent
Constants
| IDLength |
|
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 |
| protected | $refreshed | from Folder | |
| protected | $subrefreshed | from Folder | |
| protected | $fsDeleted | from Folder |
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)
No description
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
Function to allow subclasses to do something after being constructed without overriding the constructor
Collects fields that have changed and saves them to the database
whether or not this object has been, or should be considered, deleted
Deletes the folder and its contents from DB and disk
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
Returns the name of this item
Returns the parent folder of this item
Returns the parent ID of this item
Renames the item. If $overwrite, deletes an object if the target already exists.
Copies the item to a new name. If $overwrite, deletes an object if the target already exists.
Copies the item to a new parent. If $overwrite, deletes an object if the target already exists.
Asserts that this item can be moved to the given name
Asserts that this item can be moved to the given parent
Creates a new non-root folder in DB only
Returns the filesystem manager's implementor that stores this object
Sets the item's access time to the given value or now if null
Sets the item's created time to the given value or now if null
Sets the item's modified time to the given value or now if null
Returns the like objects for this item
Returns the comment objects for this item
Maps the given function to all applicable total limit objects
Maps the given function to all applicable timed limit objects
Adds this item's stats to all filesystem limits
Adds this item's stats to the given limit, substracting if not $add
Returns a config bool for the item by checking applicable limits
Returns true if the item should allow group shares (shares with a group)
Returns true if the item should allow public shares (shares with all users)
Attemps to load this item by the given info
Returns an array of all items belonging to the given owner
Returns all items with a parent that is not owned by the item owner
Returns a printable client object of this item
No description
Returns a printable client object of this folder
Returns an array of the files in this folder (not recursive)
Returns an array of the folders in this folder (not recursive)
Returns the total number of shares on this folder or its contents (recursive)
Asserts that this folder is not the given folder, or any of its parents
Deletes all subfiles and subfolders, refresh if not isNotify
Recursively lists subitems in this folder
Creates a new non-root folder both in DB and on disk
Details
in
Folder at line 37
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
Folder at line 29
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.
at line 12
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
BaseObject at line 150
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
StandardObject at line 173
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
Folder at line 155
protected bool
AddObjectRef(string $field, BaseObject $object, bool $notification = false)
Adds an object reference, checking for a limit on the number of references
in
Folder at line 164
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
in
BaseObject at line 763
protected void
SubConstruct()
Function to allow subclasses to do something after being constructed without overriding the constructor
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
at line 89
void
Delete()
Deletes the folder and its contents from DB and disk
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
StandardObject at line 114
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
in
Folder at line 183
Item
Refresh(bool $doContents = false)
Refreshes the folder's metadata from disk
in
Item at line 62
Account|null
GetOwner()
Returns the owner of this item, or null if it's on an external FS
in
Item at line 65
string|null
GetOwnerID()
Returns the ID of the owner of this item (or null)
at line 14
string|null
GetName()
Returns the name of this item
in
Folder at line 52
int
GetSize()
Returns the total size of the folder and its content in bytes
at line 15
Folder|null
GetParent()
Returns the parent folder of this item
at line 16
string|null
GetParentID()
Returns the parent ID of this item
at line 18
Item
SetName(string $name, bool $overwrite = false)
Renames the item. If $overwrite, deletes an object if the target already exists.
at line 26
Item
SetParent(Folder $parent, bool $overwrite = false)
Moves the item to a new parent. If $overwrite, deletes an object if the target already exists.
in
Item at line 86
string|null
GetDescription()
Returns this item's description
in
Item at line 89
Item
SetDescription(string|null $val)
Sets this item's description to the given value
at line 35
Item
CopyToName(Account|null $owner, string $name, bool $overwrite = false)
Copies the item to a new name. If $overwrite, deletes an object if the target already exists.
at line 45
Item
CopyToParent(Account|null $owner, Folder $parent, bool $overwrite = false)
Copies the item to a new parent. If $overwrite, deletes an object if the target already exists.
in
Item at line 115
protected Item|null
CheckName(string $name, bool $overwrite, bool $reuse)
Asserts that this item can be moved to the given name
in
Item at line 140
protected Item|null
CheckParent(Folder $parent, bool $overwrite, bool $reuse)
Asserts that this item can be moved to the given parent
at line 65
static Item
NotifyCreate(ObjectDatabase $database, Folder $parent, Account|null $account, string $name)
Creates a new non-root folder in DB only
in
Item at line 182
protected FSManager
GetFilesystem()
Returns the filesystem manager that stores this object
in
Item at line 185
protected string
GetFilesystemID()
Returns the ID of the object's filesystem manager
in
Item at line 194
protected FSImpl
GetFSImpl(bool $requireExist = true)
Returns the filesystem manager's implementor that stores this object
in
Item at line 206
bool
isWorldAccess()
Returns true if this file should be accessible by all accounts
in
Item at line 214
Item
SetAccessed(float|null $time = null)
Sets the item's access time to the given value or now if null
in
Item at line 222
Item
SetCreated(float|null $time = null)
Sets the item's created time to the given value or now if null
in
Item at line 225
Item
SetModified(float|null $time = null)
Sets the item's modified time to the given value or now if null
in
Item at line 228
int
GetBandwidth()
Returns the bandwidth used by the item in bytes
in
Item at line 231
int
GetPublicDownloads()
Returns the public download count of the item
in
Item at line 239
array
GetLikes(int|null $limit = null, int|null $offset = null)
Returns the like objects for this item
in
Item at line 247
array
GetComments(int|null $limit = null, int|null $offset = null)
Returns the comment objects for this item
in
Item at line 253
array
GetTags()
Returns the tag objects for this item
in
Item at line 259
array
GetShares()
Returns the share objects for this item
in
Item at line 262
int
GetNumShares()
Returns the number of shares on this object
in
Item at line 278
protected Item
CountPublicDownload()
Counts a public download on the item and its parents
in
Item at line 289
Item
CountBandwidth(int $bytes)
Counts the given bandwidth on the item and its parents
in
Item at line 302
Item
CountLike(bool $value, bool $count = true)
Increments the item's like counter
in
Item at line 326
protected Item
MapToLimits(callable $func)
Maps the given function to all applicable limit objects
in
Item at line 335
protected Item
MapToTotalLimits(callable $func)
Maps the given function to all applicable total limit objects
in
Item at line 348
protected Item
MapToTimedLimits(callable $func)
Maps the given function to all applicable timed limit objects
in
Item at line 364
protected Item
AddStatsToOwner(bool $add = true)
Adds this item's stats to all owner limits
in
Item at line 384
protected Item
AddStatsToFilesystem(bool $add = true)
Adds this item's stats to all filesystem limits
in
Folder at line 173
protected void
AddStatsToLimit(Base $limit, bool $add = true)
Adds this item's stats to the given limit, substracting if not $add
in
Item at line 407
protected bool
GetLimitsBool(callable $func, Account|null $account)
Returns a config bool for the item by checking applicable limits
in
Item at line 415
bool
GetAllowPublicModify()
Returns true if the item should allow public modifications
in
Item at line 419
bool
GetAllowPublicUpload()
Returns true if the item should allow public uploading
in
Item at line 423
bool
GetAllowRandomWrite(Account $account)
Returns true if the item should allow random/partial writes
in
Item at line 427
bool
GetAllowItemSharing(Account $account)
Returns true if the item should allow sharing
in
Item at line 431
bool
GetAllowShareToGroups(Account $account)
Returns true if the item should allow group shares (shares with a group)
in
Item at line 435
bool
GetAllowShareToEveryone(Account $account)
Returns true if the item should allow public shares (shares with all users)
in
Folder at line 209
void
NotifyFSDeleted()
Deletes this folder and its contents from the DB only
in
Item at line 457
static Item|null
TryLoadByParentAndName(ObjectDatabase $database, Folder $parent, string $name)
Attemps to load this item by the given info
in
Item at line 470
static array
LoadByOwner(ObjectDatabase $database, Account $account)
Returns an array of all items belonging to the given owner
in
Folder at line 224
static array
LoadAdoptedByOwner(ObjectDatabase $database, Account $account)
Returns all items with a parent that is not owned by the item owner
Does not return items that are world accessible
in
Item at line 497
array|null
SubGetClientObject(bool $owner = false, bool $details = false)
Returns a printable client object of this item
in
Folder at line 270
array
GetClientObject(bool $owner = false, bool $details = false, bool $files = false, bool $folders = false, bool $recursive = false, int|null $limit = null, int|null $offset = null)
No description
in
Folder at line 290
array|null
TryGetClientObject(bool $owner = false, bool $details = false, bool $files = false, bool $folders = false, bool $recursive = false, int|null $limit = null, int|null $offset = null)
Returns a printable client object of this folder
in
Folder at line 60
array
GetFiles(int|null $limit = null, int|null $offset = null)
Returns an array of the files in this folder (not recursive)
in
Folder at line 69
array
GetFolders(int|null $limit = null, int|null $offset = null)
Returns an array of the folders in this folder (not recursive)
in
Folder at line 73
int
GetNumFiles()
Returns the number of files in this folder (not recursive) (fast)
in
Folder at line 76
int
GetNumFolders()
Returns the number of folders in this folder (not recursive) (fast)
in
Folder at line 79
int
GetNumItems()
Returns the number of items in this folder (not recursive) (fast)
in
Folder at line 82
int
GetTotalShares()
Returns the total number of shares on this folder or its contents (recursive)
in
Folder at line 93
Folder
DeltaSize(int $size)
Increments the size of this folder and parents by the given #bytes
in
Folder at line 101
Folder
SetOwnerRecursive(Account $account)
Sets this folder and its contents' owners to the given account
in
Folder at line 111
protected void
CheckIsNotChildOrSelf(Folder $folder)
Asserts that this folder is not the given folder, or any of its parents
in
Folder at line 123
private void
AddItemCounts(Item $item, bool $add = true)
Adds the statistics from the given item to this folder
in
Folder at line 150
protected Folder
CountSubShare(bool $count = true)
Counts a share on a subitem of this folder
in
Folder at line 196
bool
isFSDeleted()
No description
in
Folder at line 199
void
DeleteChildren(bool $isNotify = false)
Deletes all subfiles and subfolders, refresh if not isNotify
in
Folder at line 245
private array
RecursiveItems(bool|null $files = true, bool|null $folders = true, int|null $limit = null, int|null $offset = null)
Recursively lists subitems in this folder
at line 78
static SubFolder
Create(ObjectDatabase $database, Folder $parent, Account|null $account, string $name)
Creates a new non-root folder both in DB and on disk