Class vB_DataManager

Description

Abstract class to do data save/delete operations for a particular data type (such as user, thread, post etc.)

  • version: $Revision: 33877 $
  • date: $Date: 2009-11-27 11:25:30 -0600 (Fri, 27 Nov 2009) $

Located in /includes/class_dm.php (line 20)


	
			
Direct descendents
Class Description
 class vB_DataManager_Discussion DataManager for manipulating discussions.
 class vB_DataManager_Pt_IssueVote Class to do data save/delete operations for PT issue votes.
 class vB_DataManager_Moderator Class to do data save/delete operations for MODERATORS
 class vB_DataManager_Admin Class to do data save/delete operations for ADMINISTRATORS
 class vB_DataManager_SocialGroupCategory Class to do data save/delete operations for Social Group Categories
 class vB_DataManager_Blog_Abstract Base data manager for blogs and blogtexts. Uninstantiable.
 class vB_DataManager_Userpic vB_DataManager_Avatar vB_DataManager_ProfilePic Abstract class to do data save/delete operations for Userpics.
 class vB_DataManager_SocialGroup Class to do data save/delete operations for Social Groups
 class vB_DataManager_SocialGroupMember Class to do data save/delete operations for Social Groups
 class vB_DataManager_Pt_Milestone Class to do data save/delete operations for PT milestones.
 class vB_DataManager_VisitorMessage Class to do data save/delete operations for profile messages
 class vB_DataManager_ThreadRate Class to do data save/delete operations for THREAD RATINGS
 class vB_DataManager_Pt_IssueChange Class to do data save/delete operations for PT issue changes.
 class vB_DataManager_PM Class to do data save/delete operations for PRIVATE MESSAGES Note: you may only do inserts with this class.
 class vB_DataManager_PollVote Class to do data save/delete operations for pollvotes
 class vB_DataManager_DeletionLog Class to do data save/delete operations for deleted threads/posts
 class vB_DataManager_Cms_Layout Class to do data save/delete operations for layouts
 class vB_DataManager_Pt_IssueAssign Class to do data save/delete operations for PT issue assignments.
 class vB_DataManager_Pt_IssuePetition Class to do data save/delete operations for PT issue petitions.
 class vB_DataManager_Forum Class to do data save/delete operations for FORUMS
 class vB_DataManager_Blog_TrackBack Class to do data save/delete operations for blog users
 class vB_DataManager_Blog_Rate Class to do data save/delete operations for Blog ratings
 class vB_DataManager_vBCms_Widget Class to do data save/delete operations for widgets for the admincp
 class vB_DataManager_Announcement Class to do data save/delete operations for ANNOUNCEMENTS
 class vB_DataManager_Event Class to do data save/delete operations for EVENTS
 class vB_DataManager_RSSFeed Class to do data save/delete operations for RSS Feeds
 class vB_DataManager_Pt_IssueNote Class to do data save/delete operations for PT issue notes (generic).
 class vB_DataManager_GroupMessage Class to do data save/delete operations for profile messages
 class vB_DataManager_Pt_IssueReport Class to do data save/delete operations for PT issue reports.
 class vB_DataManager_Pt_Project Class to do data save/delete operations for PT issue assignments.
 class vB_DataManager_PrefixSet Class to do data save/delete operations for thread prefix sets
Abstract class vB_DataManager_AttachData Abstract class to do data save/delete operations for ATTACHMENTS.
 class vB_DataManager_Blog_Custom_Block Class to do data save/delete operations for profile messages
 class vB_DataManager_Pt_IssueType Class to do data save/delete operations for PT issue types.
 class vB_DataManager_Tag Class to do data operations for Categories
 class vB_DataManager_category Class to do data operations for Categories
 class vB_DataManager_ThreadPost Base data manager for threads and posts. Uninstantiable.
 class vB_DataManager_Pt_IssueStatus Class to do data save/delete operations for PT issue statuses.
 class vB_DataManager_Pt_IssueSubscribe Class to do data save/delete operations for PT issue subscriptiosn.
 class vB_DataManager_Pt_Issue Class to do data save/delete operations for PT issues.
 class vB_DataManager_Poll Class to do data save/delete operations for POLLS
 class vB_DataManager_StyleVarDefn Class to do data save/delete operations for StyleVarDefinitions.
 class vB_DataManager_StyleVar Abstract class to do data save/delete operations for StyleVar.
 class vB_DataManager_Blog_Category Class to do data save/delete operations for blog users
 class vB_DataManager_Infraction Class to do data save/delete operations for infractions
 class vB_DataManager_SocialGroupIcon vB_DataManager_SocialGroupIcon Class to do data save/delete operations for SocialGroupIcons.
 class vB_DataManager_PictureComment Class to do data save/delete operations for picture comments
 class vB_DataManager_Album Class to do data save/delete operations for albums
 class vB_DataManager_Prefix Class to do data save/delete operations for thread prefixes
 class vB_DataManager_User Class to do data save/delete operations for USERS
 class vB_DataManager_Blog_User Class to do data save/delete operations for blog users
Variable Summary
Method Summary
 vB_DataManager vB_DataManager (vB_Registry &$registry, [integer $errtype = ERRTYPE_STANDARD])
 boolean check_required ()
 integer db_delete (string $tableprefix, string $table, [string $condition = ''], [boolean $doquery = true])
 integer db_insert (string $tableprefix, string $table, [boolean $doquery = true], [bool $replace = false])
 integer db_insert_ignore (string $tableprefix, string $table, [boolean $doquery = true])
 boolean db_update (string $tableprefix, string $table, [string $condition = ''], [boolean $doquery = true], [mixed $delayed = false], [boolean $affected_rows = false])
 integer delete ([ $doquery = true])
 void do_set (string $fieldname, mixed &$value, [string $table = null])
 void do_unset (string $fieldname, [string $table = null])
 void error (string $errorphrase)
 mixed &fetch_field (string $fieldname, [ $table = null])
 string fetch_insert_sql (string $tableprefix, string $table, [bool $replace = false], [bool $ignore = false])
 string fetch_update_sql (string $tableprefix, string $table, string $condition)
 bool has_errors ([bool $die = true])
 void post_delete ([boolean $doquery = true])
 void post_save_each ([boolean $doquery = true])
 void post_save_once ([boolean $doquery = true])
 void pre_delete ([boolean $doquery = true])
 boolean pre_save ([boolean $doquery = true])
 mixed save ([boolean $doquery = true], [mixed $delayed = false], [bool $affected_rows = false], [bool $replace = false], [bool $ignore = false])
 boolean set (string $fieldname, mixed $value, [boolean $clean = true], [boolean $doverify = true], [string $table = null])
 boolean setr (string $fieldname, mixed &$value, [boolean $clean = true], [boolean $doverify = true])
 void setr_info (string $fieldname, mixed &$value)
 boolean set_bitfield (string $fieldname, string $bitname, boolean $onoff)
 void set_condition ([ $clause = ''])
 boolean set_error_handler ([string $errtype = ERRTYPE_STANDARD])
 boolean set_existing (array &$existing)
 void set_failure_callback (callback $callback)
 void set_info (string $fieldname, mixed $value)
 string strip_empty_bbcode (string $text)
 string strip_empty_bbcode_callback (array $matches)
 boolean verify (string $fieldname, mixed &$value, [boolean $doverify = true])
 boolean verify_commalist (mixed &$list)
 boolean verify_date_array (array &$date)
 boolean verify_email (string &$email)
 bool verify_image_count ([ $pagetext = 'pagetext'], [ $allowsmilie = 'allowsmilie'], [ $parsetype = 'nonforum'], [ $table = null])
 boolean verify_ipaddress (string &$ipaddress)
 boolean verify_link (string &$link, [boolean $strict = false])
 boolean verify_list (mixed &$list, [string $glue = ','], [boolean $dropzero = false])
 boolean verify_md5 (string &$md5)
 boolean verify_nonempty (string &$string)
 boolean verify_nonzero (integer &$int)
 boolean verify_nonzero_or_negone (integer &$int)
 void verify_pagetext (string &$pagetext, [bool $noshouting = true], bool 2)
 boolean verify_serialized (mixed &$data)
 boolean verify_spacelist (mixed &$list)
 boolean verify_userid (integer &$userid)
 boolean verify_username (string &$username)
Variables
array $bitfields = array() (line 44)

Array of field names that are bitfields, together with the name of the variable in the registry with the definitions.

For example: var $bitfields = array('options' => 'bf_misc_useroptions', 'permissions' => 'bf_misc_moderatorpermissions')


Redefined in descendants as:
string $condition = null (line 114)

Condition to be used in SQL query - if empty, an INSERT query will be performed

array $condition_construct = array('dataid = %1$d', 'dataid') (line 129)

Condition template for update query This is for use with sprintf(). First key is the where clause, further keys are the field names of the data to be used.


Redefined in descendants as:
vB_Database $dbobject = null (line 72)

The vBulletin database object

array $errors = array() (line 86)

Array to store any errors encountered while building data

string $error_handler = ERRTYPE_STANDARD (line 93)

The error handler for this object

array $existing = array() (line 100)

Array to store existing data

callback $failure_callback = null (line 136)

Callback to execute just before an error is logged.

string $hook_delete = 'data_delete' (line 175)

Hook for post_delete.

string $hook_postsave = 'data_postsave' (line 168)

Hook for post_save.

string $hook_presave = 'data_presave' (line 161)

Hook for pre_save.

string $hook_start = 'data_start' (line 154)

Hook for constructor.

array $info = array() (line 107)

Array to store information


Redefined in descendants as:
function $lamda = null (line 79)

Will contain the temporary verification function for each field

null|bool $presave_called = null (line 147)

This variable prevents the pre_save() method from being called more than once.

In some classes, it is helpful to explicitly call pre_save() before calling save as additional checks are done. This variable is used to prevent pre_save() from being executed when save() is called. If null, pre_save() has yet to be called; else, it is the return value of pre_save().

array $rawfields = array() (line 58)

Array to store the names for fields that will be taking raw SQL

vB_Registry $registry = null (line 65)

The vBulletin registry object

array $setfields = array() (line 51)

Array to store the names of fields that have been sucessfully set

string $table = 'default_table' (line 121)

Default table to be used in queries


Redefined in descendants as:
array $validfields = array() (line 36)

Array of field names that are valid for this data object

Each array element has the field name as its key, and then a three element array as the value. These three elements are used as follows: FIELD 0 (VF_TYPE) - This specifies the expected data type of the field, and draws on the data types defined for the vB_Input_Cleaner class FIELD 1 (VF_REQ) - This specified whether or not the field is REQUIRED for a valid INSERT query. Options include REQ_NO, REQ_YES and REQ_AUTO, which is a special option, indicating that the value of the field is automatically created FIELD 2 (VF_CODE) - This contains code to be executed as a lamda function called as 'function($data, $dm)'. Alternatively, the value can be VF_METHOD, in which case, $this->verify_{$fieldname} will be called.


Redefined in descendants as:
Methods
Constructor vB_DataManager (line 183)

Constructor - checks that the registry object has been passed correctly.

vB_DataManager vB_DataManager (vB_Registry &$registry, [integer $errtype = ERRTYPE_STANDARD])
  • vB_Registry &$registry: Instance of the vBulletin data registry object - expected to have the database object as one of its $this->db member.
  • integer $errtype: One of the ERRTYPE_x constants
check_required (line 560)

Checks through the required fields for this object and ensures that all required fields have a value

  • return: Returns true if all required fields have a valid value set
boolean check_required ()
db_delete (line 817)

Generates the SQL to delete a record from a database table, then executes it

  • return: The number of records deleted
integer db_delete (string $tableprefix, string $table, [string $condition = ''], [boolean $doquery = true])
  • string $tableprefix: The system's table prefix
  • string $table: The name of the database table to be affected (do not include TABLE_PREFIX in your argument)
  • string $condition: Specify the WHERE condition for the DELETE here. For example, 'userid > 10 AND posts < 50'
  • boolean $doquery: Whether or not to actually run the query
db_insert (line 720)

Creates and runs an INSERT query to save the data from the object into the database

  • return: Returns the ID of the inserted record
integer db_insert (string $tableprefix, string $table, [boolean $doquery = true], [bool $replace = false])
  • string $tableprefix: The system's table prefix
  • string $table: The name of the database table to be affected (do not include TABLE_PREFIX in your argument)
  • boolean $doquery: Whether or not to actually run the query
  • bool $replace: Perform REPLACE INTO instead of INSERT
db_insert_ignore (line 772)

Creates and runs an INSERT query to save the data from the object into the database

  • return: Returns the affected rows
integer db_insert_ignore (string $tableprefix, string $table, [boolean $doquery = true])
  • string $tableprefix: The system's table prefix
  • string $table: The name of the database table to be affected (do not include TABLE_PREFIX in your argument)
  • boolean $doquery: Whether or not to actually run the query
db_update (line 626)

Creates and runs an UPDATE query to save the data from the object into the database

  • return: Returns true on success
boolean db_update (string $tableprefix, string $table, [string $condition = ''], [boolean $doquery = true], [mixed $delayed = false], [boolean $affected_rows = false])
  • string $tableprefix: The system's table prefix
  • string $table: The name of the database table to be affected (do not include TABLE_PREFIX in your argument)
  • string $condition: Specify the WHERE condition here. For example, 'userid > 10 AND posts < 50'
  • boolean $doquery: Whether or not to actually run the query
  • mixed $delayed: If this evaluates to true, the query will be delayed. If it is a string, that will be the name of the shutdown query.
  • boolean $affected_rows: Whether to return the number of affected rows
delete (line 978)

Deletes the specified data item from the database

  • return: The number of rows deleted
integer delete ([ $doquery = true])
  • $doquery

Redefined in descendants as:
do_set (line 545)

Takes valid data and sets it as part of the data to be saved

void do_set (string $fieldname, mixed &$value, [string $table = null])
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed &$value: The data itself
  • string $table: Table name to force. Leave as null to use the default table

Redefined in descendants as:
do_unset (line 526)

Unsets a values that has already been set

void do_unset (string $fieldname, [string $table = null])
  • string $fieldname: The name of the field that is to be unset
  • string $table: Table name to force. Leave as null to use the default table
error (line 1055)

Shows an error message and halts execution - use this in the same way as print_stop_message();

void error (string $errorphrase)
  • string $errorphrase: Phrase name for error message
fetch_field (line 307)

Fetches info about the current data object - if a new value is set, it returns this, otherwise it will return the existing data

  • return: The requested data
mixed &fetch_field (string $fieldname, [ $table = null])
  • string $fieldname: Fieldname
  • $table
fetch_insert_sql (line 685)

Builds an INSERT/REPLACE query

  • return: SQL Insert query
string fetch_insert_sql (string $tableprefix, string $table, [bool $replace = false], [bool $ignore = false])
  • string $tableprefix: The system's table prefix
  • string $table: The name of the database table to be affected (do not include TABLE_PREFIX in your argument)
  • bool $replace: Perform REPLACE INTO instead of INSERT
  • bool $ignore: Perform INSERT IGNORE instead of INSERT
fetch_update_sql (line 583)

Builds an UPDATE query

  • return: SQL Update query
string fetch_update_sql (string $tableprefix, string $table, string $condition)
  • string $tableprefix: The system's table prefix
  • string $table: The name of the database table to be affected (do not include TABLE_PREFIX in your argument)
  • string $condition: Specify the WHERE condition here. For example, 'userid > 10 AND posts < 50'
has_errors (line 839)

Check if the DM currently has errors. Will kill execution if it does and $die is true.

  • return: True if there *are* errors, false otherwise
bool has_errors ([bool $die = true])
  • bool $die: Whether or not to end execution if errors are found; ignored if the error type is ERRTYPE_SILENT
post_delete (line 1019)

Additional data to update after a delete call (such as denormalized values in other tables).

void post_delete ([boolean $doquery = true])
  • boolean $doquery: Do the query?

Redefined in descendants as:
post_save_each (line 951)

Additional data to update after a save call (such as denormalized values in other tables).

In batch updates, is executed for each record updated.

void post_save_each ([boolean $doquery = true])
  • boolean $doquery: Do the query?

Redefined in descendants as:
post_save_once (line 965)

Additional data to update after a save call (such as denormalized values in other tables).

In batch updates, is executed once after all records are updated.

void post_save_once ([boolean $doquery = true])
  • boolean $doquery: Do the query?

Redefined in descendants as:
pre_delete (line 1009)

Additional data to update before a delete call (such as denormalized values in other tables).

void pre_delete ([boolean $doquery = true])
  • boolean $doquery: Do the query?

Redefined in descendants as:
pre_save (line 931)

Any checks to run immediately before saving. If returning false, the save will not take place.

  • return: True on success; false if an error occurred
boolean pre_save ([boolean $doquery = true])
  • boolean $doquery: Do the query?

Redefined in descendants as:
save (line 870)

Saves the data from the object into the specified database tables

  • return: If this was an INSERT query, the INSERT ID is returned
mixed save ([boolean $doquery = true], [mixed $delayed = false], [bool $affected_rows = false], [bool $replace = false], [bool $ignore = false])
  • boolean $doquery: Do the query?
  • mixed $delayed: Whether to run the query now; see db_update() for more info
  • bool $affected_rows: Whether to return the number of affected rows.
  • bool $replace: Perform REPLACE INTO instead of INSERT
  • bool $ignore: Perfrom INSERT IGNORE instead of INSERT

Redefined in descendants as:
set (line 339)

Sets the supplied data to be part of the data to be saved. Use setr() if a reference to $value is to be passed

  • return: Returns false if the data is rejected for whatever reason
boolean set (string $fieldname, mixed $value, [boolean $clean = true], [boolean $doverify = true], [string $table = null])
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed $value: The data itself
  • boolean $clean: Clean data, or insert it RAW (used for non-arbitrary updates, like posts = posts + 1)
  • boolean $doverify: Whether to verify the data with the appropriate function. Still cleans data if previous arg is true.
  • string $table: Table name to force. Leave as null to use the default table

Redefined in descendants as:
setr (line 381)

Sets the supplied data to be part of the data to be saved

  • return: Returns false if the data is rejected for whatever reason
boolean setr (string $fieldname, mixed &$value, [boolean $clean = true], [boolean $doverify = true])
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed &$value: The data (reference) itself
  • boolean $clean: Clean data, or insert it RAW (used for non-arbitrary updates, like posts = posts + 1)
  • boolean $doverify: Whether to verify the data with the appropriate function. Still cleans data if previous arg is true.
setr_info (line 459)

Rather like set(), but sets reference to data into the $this->info array instead

void setr_info (string $fieldname, mixed &$value)
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed &$value: The data (reference) itself
set_bitfield (line 423)

Sets a bit in a bitfield

boolean set_bitfield (string $fieldname, string $bitname, boolean $onoff)
  • string $fieldname: Name of the database bitfield (options, permissions etc.)
  • string $bitname: Name of the bit within the bitfield (canview, canpost etc.)
  • boolean $onoff: Whether the bit should be set or not

Redefined in descendants as:
set_condition (line 272)

Sets the condition to be used in WHERE clauses, based upon the $this->existing data and the $this->condition_constuct condition template.

void set_condition ([ $clause = ''])
  • $clause

Redefined in descendants as:
set_error_handler (line 1034)

Sets the error handler for the object

boolean set_error_handler ([string $errtype = ERRTYPE_STANDARD])
  • string $errtype: Error type
set_existing (line 235)

Sets the existing data

  • return: Returns true if successful
boolean set_existing (array &$existing)
  • array &$existing: Optional array of data describing the existing data we will be updating

Redefined in descendants as:
set_failure_callback (line 1103)

Sets the function to call on an error.

void set_failure_callback (callback $callback)
  • callback $callback: A valid callback (either a function name, or specially formed array)
set_info (line 444)

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

void set_info (string $fieldname, mixed $value)
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed $value: The data itself
strip_empty_bbcode (line 1552)

Strips empty BB code from the entire message except inside PHP/HTML/Noparse tags.

  • return: Text with tags stripped
string strip_empty_bbcode (string $text)
  • string $text: Text to strip tags from
strip_empty_bbcode_callback (line 1568)

Callback function for strip_empty_bbcode.

  • return: Compiled text with empty tags stripped where appropriate
string strip_empty_bbcode_callback (array $matches)
  • array $matches: Array of matches. 1 is the close of the previous tag (if there is one). 3 is the text to strip from.
verify (line 480)

Verifies that the supplied data is one of the fields used by this object

Also ensures that the data is of the correct type, and attempts to correct errors in the supplied data.

  • return: 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)
boolean verify (string $fieldname, mixed &$value, [boolean $doverify = true])
  • string $fieldname: The name of the field to which the supplied data should be applied
  • mixed &$value: The data itself
  • boolean $doverify: Whether to verify the data with the appropriate function. Data is still cleaned though.
verify_commalist (line 1274)

Verifies that a variable is a comma-separated list of integers

boolean verify_commalist (mixed &$list)
  • mixed &$list: List (can be string or array)
verify_date_array (line 1462)

Verifies a date array as a valid unix timestamp

boolean verify_date_array (array &$date)
  • array &$date: Date array containing day/month/year and optionally: hour/minute/second
verify_email (line 1419)

Verifies that an email address is valid

boolean verify_email (string &$email)
  • string &$email: Email address
verify_image_count (line 1579)

Verifies the number of images in the post text. Call it from pre_save() after pagetext/allowsmilie has been set

  • return: Whether the post passes the image count check
bool verify_image_count ([ $pagetext = 'pagetext'], [ $allowsmilie = 'allowsmilie'], [ $parsetype = 'nonforum'], [ $table = null])
  • $pagetext
  • $allowsmilie
  • $parsetype
  • $table
verify_ipaddress (line 1377)

Verifies an IP address - currently only works with IPv4

boolean verify_ipaddress (string &$ipaddress)
  • string &$ipaddress: IP address

Redefined in descendants as:
verify_link (line 1432)

Verifies that a hyperlink is valid

boolean verify_link (string &$link, [boolean $strict = false])
  • string &$link: Hyperlink URL
  • boolean $strict: Strict link (only HTTP/HTTPS); default false
verify_list (line 1300)

Creates a valid string of comma-separated integers

boolean verify_list (mixed &$list, [string $glue = ','], [boolean $dropzero = false])
  • mixed &$list: Either specify a string of integers separated by parameter 2, or an array of integers
  • string $glue: The 'glue' for the string. Usually a comma or a space.
  • boolean $dropzero: Whether or not to exclude zero from the list
verify_md5 (line 1407)

Verifies that a string is an MD5 string

boolean verify_md5 (string &$md5)
  • string &$md5: The MD5 string
verify_nonempty (line 1260)

Verifies that a string is not empty

boolean verify_nonempty (string &$string)
  • string &$string: Text to check
verify_nonzero (line 1235)

Verifies that an integer is greater than zero

boolean verify_nonzero (integer &$int)
  • integer &$int: Value to check
verify_nonzero_or_negone (line 1248)

Verifies that an integer is greater than zero or the special value -1 this rule matches a fair number of id columns

boolean verify_nonzero_or_negone (integer &$int)
  • integer &$int: Value to check
verify_pagetext (line 1495)

Basic options to perform on all pagetext type fields

void verify_pagetext (string &$pagetext, [bool $noshouting = true], bool 2)
  • bool 2: Whether to run the case stripper
  • string &$pagetext: Page text
  • bool $noshouting: Whether the text is valid

Redefined in descendants as:
verify_serialized (line 1346)

Verifies that input is a serialized array (or force an array to serialize)

boolean verify_serialized (mixed &$data)
  • mixed &$data: Either specify a serialized array, or an array to serialize, or an empty string
verify_spacelist (line 1286)

Verifies that a variable is a space-separated list of integers

boolean verify_spacelist (mixed &$list)
  • mixed &$list: List (can be string or array)
verify_userid (line 1118)

Verifies that the specified user exists

  • return: Returns true if user exists
boolean verify_userid (integer &$userid)
  • integer &$userid: User ID

Redefined in descendants as:
verify_username (line 1144)

Verifies that the provided username is valid, and attempts to correct it if it is not valid

  • return: Returns true if the username is valid, or has been corrected to be valid
boolean verify_username (string &$username)
  • string &$username: Username

Redefined in descendants as:

Documentation generated on Tue, 26 Jan 2010 15:15:08 -0600 by phpDocumentor 1.4.3