vB_DataManager_StyleVarDefn
extends vB_DataManager
in package
Class to do data save/delete operations for StyleVarDefinitions.
Tags
Table of Contents
- $bitfields : array<string|int, mixed>
- Array of field names that are bitfields, together with the name of the variable in the registry with the definitions.
- $condition : string
- Condition to be used. Can be either ['keyfield' => 'value'] or a valid assertor vB_dB_Query::CONDITIONS_KEY setting.
- $error_handler : string
- The error handler for this object
- $errors : array<string|int, mixed>
- Array to store any errors encountered while building data
- $existing : array<string|int, mixed>
- Array to store existing data
- $info : array<string|int, mixed>
- Array to store information
- $rawfields : array<string|int, mixed>
- Array to store the names for fields that will be taking raw SQL
- $table : string
- The main table this class deals with
- $validfields : array<string|int, mixed>
- Array of recognized and required fields for attachment inserts
- __construct() : mixed
- Constructor - Checks for necessity of registry object
- __serialize() : array<string|int, mixed>
- __sleep() : array<string|int, mixed>
- __unserialize() : void
- __wakeup() : void
- check_required() : bool
- Checks through the required fields for this object and ensures that all required fields have a value
- db_insert() : int
- Creates and runs an INSERT query to save the data from the object into the database
- db_update() : bool
- Creates and runs an UPDATE query to save the data from the object into the database
- delete() : int
- Deletes a stylevardfn and its associated data from the database
- do_set() : mixed
- Takes valid data and sets it as part of the data to be saved
- do_unset() : mixed
- Unsets a values that has already been set
- error() : mixed
- Shows an error message and halts execution - use this in the same way as print_stop_message();
- fetch_field() : mixed
- Fetches info about the current data object - if a new value is set, it returns this, otherwise it will return the existing data
- get_errors() : array<string|int, mixed>
- Returns the array of errors
- get_exception() : mixed
- has_errors() : bool
- Check if the DM currently has errors. Will kill execution if it does and $die is true.
- is_bitfield_set() : bool
- Determines if a bitfield value has been set
- is_field_defined() : mixed
- is_field_set() : mixed
- Determines if a field is set
- is_substyle_of() : bool
- Verifies that a given style parent id is not one of its own children
- post_delete() : mixed
- Additional data to update after a delete call (such as denormalized values in other tables).
- post_save_each() : mixed
- Additional data to update after a save call (such as denormalized values in other tables).
- post_save_once() : mixed
- Additional data to update after a save call (such as denormalized values in other tables).
- pre_delete() : mixed
- Additional data to update before a delete call (such as denormalized values in other tables).
- pre_save() : bool
- Any checks to run immediately before saving. If returning false, the save will not take place.
- save() : mixed
- Saves the data from the object into the specified database tables
- set() : bool
- Sets the supplied data to be part of the data to be saved. Use setr() if a reference to $value is to be passed
- set_bitfield() : bool
- Sets a bit in a bitfield
- set_condition() : mixed
- Sets the condition to be used in WHERE clauses, based upon the $this->existing data and the $this->condition_constuct condition template.
- set_existing() : bool
- Sets the existing data
- set_info() : mixed
- Rather like set(), but sets data into the $this->info array instead. Use setr_info if $value if a reference to value is to be passed
- setr() : bool
- Sets the supplied data to be part of the data to be saved
- setr_info() : mixed
- Rather like set(), but sets reference to data into the $this->info array instead
- verify() : bool
- Verifies that the supplied data is one of the fields used by this object
- verify_datatype() : mixed
- verify_date_array() : bool
- Verifies a date array as a valid unix timestamp
- verify_email() : bool
- Verifies that an email address is valid
- verify_link() : bool
- Verifies that a hyperlink is valid
- verify_md5() : bool
- Verifies that a string is an MD5 string
- verify_parentid() : bool
- Verifies that the parent style specified exists and is a valid parent for this style
- verify_product() : mixed
- verify_serialized() : bool
- Verifies that input is a serialized array (or force an array to serialize)
- verify_units() : mixed
- verify_userid() : bool
- Verifies that the specified user exists
- verify_username() : bool
- Verifies that the provided username is valid, and attempts to correct it if it is not valid
Properties
$bitfields
Array of field names that are bitfields, together with the name of the variable in the registry with the definitions.
public
array<string|int, mixed>
$bitfields
= array()
For example: var $bitfields = array('options' => 'bf_misc_useroptions', 'permissions' => 'bf_misc_moderatorpermissions')
$condition
Condition to be used. Can be either ['keyfield' => 'value'] or a valid assertor vB_dB_Query::CONDITIONS_KEY setting.
public
string
$condition
= \null
$error_handler
The error handler for this object
public
string
$error_handler
= \vB_DataManager_Constants::ERRTYPE_STANDARD
$errors
Array to store any errors encountered while building data
public
array<string|int, mixed>
$errors
= []
$existing
Array to store existing data
public
array<string|int, mixed>
$existing
= []
$info
Array to store information
public
array<string|int, mixed>
$info
= []
$rawfields
Array to store the names for fields that will be taking raw SQL
public
array<string|int, mixed>
$rawfields
= []
$table
The main table this class deals with
public
string
$table
= 'vBForum:stylevardfn'
$validfields
Array of recognized and required fields for attachment inserts
public
array<string|int, mixed>
$validfields
= array(
'stylevarid' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_YES),
'styleid' => array(\vB_Cleaner::TYPE_INT, \vB_DataManager_Constants::REQ_NO, \vB_DataManager_Constants::VF_METHOD),
'parentid' => array(\vB_Cleaner::TYPE_INT, \vB_DataManager_Constants::REQ_YES, \vB_DataManager_Constants::VF_METHOD),
// 'parentlist' => array(vB_Cleaner::TYPE_STR, vB_DataManager_Constants::REQ_AUTO, 'return preg_match(\'#^(\d+,)*-1$#\', $data);'),
'parentlist' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_NO),
'stylevargroup' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_YES),
'product' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_YES, \vB_DataManager_Constants::VF_METHOD),
'datatype' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_YES, \vB_DataManager_Constants::VF_METHOD),
'validation' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_NO),
'failsafe' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_NO),
'units' => array(\vB_Cleaner::TYPE_STR, \vB_DataManager_Constants::REQ_NO, \vB_DataManager_Constants::VF_METHOD),
'uneditable' => array(\vB_Cleaner::TYPE_BOOL, \vB_DataManager_Constants::REQ_YES),
)
Methods
__construct()
Constructor - Checks for necessity of registry object
public
__construct([mixed &$registry = NULL ][, mixed $errtype = NULL ]) : mixed
Parameters
- $registry : mixed = NULL
-
-- Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
- $errtype : mixed = NULL
-
--One of the ERRTYPE_x constants
Return values
mixed —__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —__sleep()
public
__sleep() : array<string|int, mixed>
Return values
array<string|int, mixed> —__unserialize()
public
__unserialize(array<string|int, mixed> $serialized) : void
Parameters
- $serialized : array<string|int, mixed>
Return values
void —__wakeup()
public
__wakeup() : void
Return values
void —check_required()
Checks through the required fields for this object and ensures that all required fields have a value
public
check_required() : bool
Return values
bool —Returns true if all required fields have a valid value set
db_insert()
Creates and runs an INSERT query to save the data from the object into the database
public
db_insert(mixed $tableprefix, mixed $table[, mixed $doquery = true ][, mixed $replace = false ]) : int
Parameters
- $tableprefix : mixed
- $table : mixed
- $doquery : mixed = true
- $replace : mixed = false
Return values
int —Returns the ID of the inserted record
db_update()
Creates and runs an UPDATE query to save the data from the object into the database
public
db_update(mixed $tableprefix, mixed $table[, mixed $condition = null ][, mixed $doquery = true ][, mixed $delayed = false ][, mixed $affected_rows = false ]) : bool
Parameters
- $tableprefix : mixed
- $table : mixed
- $condition : mixed = null
- $doquery : mixed = true
- $delayed : mixed = false
- $affected_rows : mixed = false
Return values
bool —Returns true on success
delete()
Deletes a stylevardfn and its associated data from the database
public
delete([mixed $doquery = true ]) : int
Parameters
- $doquery : mixed = true
Return values
int —The number of rows deleted
do_set()
Takes valid data and sets it as part of the data to be saved
public
do_set(mixed $fieldname, mixed &$value[, mixed $table = null ]) : mixed
Parameters
- $fieldname : mixed
- $value : mixed
- $table : mixed = null
Return values
mixed —do_unset()
Unsets a values that has already been set
public
do_unset(mixed $fieldname[, mixed $table = null ]) : mixed
Parameters
- $fieldname : mixed
- $table : mixed = null
Return values
mixed —error()
Shows an error message and halts execution - use this in the same way as print_stop_message();
public
error(mixed $errorphrase) : mixed
Parameters
- $errorphrase : mixed
Return values
mixed —fetch_field()
Fetches info about the current data object - if a new value is set, it returns this, otherwise it will return the existing data
public
& fetch_field(mixed $fieldname[, mixed $table = null ]) : mixed
Parameters
- $fieldname : mixed
- $table : mixed = null
Return values
mixed —The requested data
get_errors()
Returns the array of errors
public
get_errors() : array<string|int, mixed>
Return values
array<string|int, mixed> —--
get_exception()
public
get_exception() : mixed
Return values
mixed —has_errors()
Check if the DM currently has errors. Will kill execution if it does and $die is true.
public
has_errors([mixed $die = true ]) : bool
Parameters
- $die : mixed = true
Return values
bool —True if there are errors, false otherwise
is_bitfield_set()
Determines if a bitfield value has been set
public
is_bitfield_set(mixed $fieldname, mixed $bitname) : bool
Parameters
- $fieldname : mixed
- $bitname : mixed
Return values
bool —is_field_defined()
public
is_field_defined(mixed $fieldname) : mixed
Parameters
- $fieldname : mixed
Return values
mixed —is_field_set()
Determines if a field is set
public
is_field_set(mixed $field) : mixed
Parameters
- $field : mixed
Return values
mixed —is_substyle_of()
Verifies that a given style parent id is not one of its own children
public
is_substyle_of(mixed $styleid, mixed $parentid) : bool
Parameters
- $styleid : mixed
- $parentid : mixed
Return values
bool —Returns true if the children of the given parent style does not include the specified style... or something
post_delete()
Additional data to update after a delete call (such as denormalized values in other tables).
public
post_delete([mixed $doquery = true ]) : mixed
Parameters
- $doquery : mixed = true
Return values
mixed —post_save_each()
Additional data to update after a save call (such as denormalized values in other tables).
public
post_save_each([mixed $doquery = true ]) : mixed
In batch updates, is executed for each record updated.
Parameters
- $doquery : mixed = true
Return values
mixed —post_save_once()
Additional data to update after a save call (such as denormalized values in other tables).
public
post_save_once([mixed $doquery = true ]) : mixed
In batch updates, is executed once after all records are updated.
Parameters
- $doquery : mixed = true
Return values
mixed —pre_delete()
Additional data to update before a delete call (such as denormalized values in other tables).
public
pre_delete([mixed $doquery = true ]) : mixed
Parameters
- $doquery : mixed = true
Return values
mixed —pre_save()
Any checks to run immediately before saving. If returning false, the save will not take place.
public
pre_save([mixed $doquery = true ]) : bool
Parameters
- $doquery : mixed = true
Return values
bool —True on success; false if an error occurred
save()
Saves the data from the object into the specified database tables
public
save([mixed $doquery = true ][, mixed $delayed = false ][, mixed $affected_rows = false ][, mixed $replace = false ]) : mixed
Parameters
- $doquery : mixed = true
- $delayed : mixed = false
- $affected_rows : mixed = false
- $replace : mixed = false
Return values
mixed —If this was an INSERT query, the INSERT ID is returned
set()
Sets the supplied data to be part of the data to be saved. Use setr() if a reference to $value is to be passed
public
set(mixed $fieldname, mixed $value[, mixed $clean = true ][, mixed $doverify = true ][, mixed $table = null ]) : bool
Parameters
- $fieldname : mixed
- $value : mixed
- $clean : mixed = true
- $doverify : mixed = true
- $table : mixed = null
Return values
bool —Returns false if the data is rejected for whatever reason
set_bitfield()
Sets a bit in a bitfield
public
set_bitfield(mixed $fieldname, mixed $bitname, mixed $onoff) : bool
Parameters
- $fieldname : mixed
- $bitname : mixed
- $onoff : mixed
Return values
bool —set_condition()
Sets the condition to be used in WHERE clauses, based upon the $this->existing data and the $this->condition_constuct condition template.
public
set_condition([mixed $params = null ]) : mixed
Parameters
- $params : mixed = null
Return values
mixed —set_existing()
Sets the existing data
public
set_existing(mixed $existing) : bool
Parameters
- $existing : mixed
Return values
bool —Returns true if successful
set_info()
Rather like set(), but sets data into the $this->info array instead. Use setr_info if $value if a reference to value is to be passed
public
set_info(mixed $fieldname, mixed $value) : mixed
Parameters
- $fieldname : mixed
- $value : mixed
Return values
mixed —setr()
Sets the supplied data to be part of the data to be saved
public
setr(mixed $fieldname, mixed &$value[, mixed $clean = true ][, mixed $doverify = true ]) : bool
Parameters
- $fieldname : mixed
- $value : mixed
- $clean : mixed = true
- $doverify : mixed = true
Return values
bool —Returns false if the data is rejected for whatever reason
setr_info()
Rather like set(), but sets reference to data into the $this->info array instead
public
setr_info(mixed $fieldname, mixed &$value) : mixed
Parameters
- $fieldname : mixed
- $value : mixed
Return values
mixed —verify()
Verifies that the supplied data is one of the fields used by this object
public
verify(mixed $fieldname, mixed &$value[, mixed $doverify = true ]) : bool
Also ensures that the data is of the correct type, and attempts to correct errors in the supplied data.
Parameters
- $fieldname : mixed
- $value : mixed
- $doverify : mixed = true
Return values
bool —Returns true if the data is one of the fields used by this object, and is the correct type (or has been successfully corrected to be so)
verify_datatype()
public
verify_datatype(mixed $datatype) : mixed
Parameters
- $datatype : mixed
Return values
mixed —verify_date_array()
Verifies a date array as a valid unix timestamp
public
verify_date_array(mixed &$date) : bool
Parameters
- $date : mixed
Return values
bool —verify_email()
Verifies that an email address is valid
public
verify_email(mixed &$email) : bool
Parameters
- $email : mixed
Return values
bool —verify_link()
Verifies that a hyperlink is valid
public
verify_link(mixed &$link[, mixed $strict = false ]) : bool
Parameters
- $link : mixed
- $strict : mixed = false
Return values
bool —verify_md5()
Verifies that a string is an MD5 string
public
verify_md5(mixed &$md5) : bool
Parameters
- $md5 : mixed
Return values
bool —verify_parentid()
Verifies that the parent style specified exists and is a valid parent for this style
public
verify_parentid(mixed &$parentid) : bool
Parameters
- $parentid : mixed
Return values
bool —Returns true if the parent id is valid, and the parent style specified exists
verify_product()
public
verify_product(mixed $product) : mixed
Parameters
- $product : mixed
Return values
mixed —verify_serialized()
Verifies that input is a serialized array (or force an array to serialize)
public
verify_serialized(mixed &$data) : bool
Parameters
- $data : mixed
Return values
bool —verify_units()
public
verify_units(mixed $unit) : mixed
Parameters
- $unit : mixed
Return values
mixed —verify_userid()
Verifies that the specified user exists
public
verify_userid(mixed &$userid) : bool
Parameters
- $userid : mixed
Return values
bool —Returns true if user exists
verify_username()
Verifies that the provided username is valid, and attempts to correct it if it is not valid
public
verify_username(mixed &$username) : bool
Parameters
- $username : mixed
Return values
bool —Returns true if the username is valid, or has been corrected to be valid