Class vB_DataManager_Poll

Description

Class to do data save/delete operations for POLLS

Example usage (inserts a poll):

$poll =& datamanager_init('Poll', $vbulletin, ERRTYPE_STANDARD); $options = array ("first", "second", "third", "fourth", "fifth", "sixth");

foreach ($options AS $option) { $poll->set_option($option); } $poll->set_vote(0, 4); $poll->set_vote(0); $poll->set_vote(1, 7); $poll->set_vote(2, 8); $poll->set_vote(3, 5); $poll->set_vote(4, 9); $poll->set_vote(5, 15);

$poll->save();

  • version: $Revision: 25978 $
  • date: $Date: 2008-03-05 23:49:13 -0600 (Wed, 05 Mar 2008) $

Located in /includes/class_dm_poll.php (line 44)

vB_DataManager
   |
   --vB_DataManager_Poll
Variable Summary
Method Summary
 vB_DataManager_Poll vB_DataManager_Poll (vB_Registry &$registry, [integer $errtype = ERRTYPE_STANDARD])
 void clear_options ()
 boolean get_option (mixed $lookup, [bool $position = true])
 boolean get_vote (mixed $lookup, [bool $position = true])
 void post_delete ([boolean $doquery = true])
 void post_save_each ([boolean $doquery = true])
 boolean pre_save ([bool $doquery = true])
 void set_existing ( &$existing)
 boolean set_option (string $option_text, [integer $option_number = NULL], [integer $votes = null])
 boolean set_vote (int $position, [int $increment = true])
 boolean verify_poll_options (integer &$poll_options)
 boolean verify_poll_votes (integer &$vote)
Variables
array $condition_construct = array('pollid = %1$d', 'pollid') (line 71)

Condition for update query


Redefinition of:
vB_DataManager::$condition_construct
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.
mixed $deleted_options = array() (line 101)
array $poll = array() (line 85)

Array to store stuff to save to poll table

array $poll_options = array() (line 92)

Array to store poll options

array $poll_votes = array() (line 99)

Array to store poll votes

string $table = 'poll' (line 78)

The main table this class deals with


Redefinition of:
vB_DataManager::$table
Default table to be used in queries
array $validfields = array(
'pollid' => array(TYPE_UINT, REQ_INCR, VF_METHOD, 'verify_nonzero'),'question'=>array(TYPE_NOHTMLCOND,REQ_YES),'dateline'=>array(TYPE_UINT,REQ_AUTO),'options'=>array(TYPE_STR,REQ_YES,VF_METHOD,'verify_poll_options'),'votes'=>array(TYPE_STR,REQ_YES,VF_METHOD,'verify_poll_votes'),'active'=>array(TYPE_BOOL,REQ_NO),# Default 1
'numberoptions'=>array(TYPE_UINT,REQ_NO),# Built in pre_save
'timeout'=>array(TYPE_UINT,REQ_NO),# Default 0
'multiple'=>array(TYPE_BOOL,REQ_NO),# Default 0
'voters'=>array(TYPE_UINT,REQ_NO),# Default 0
'public'=>array(TYPE_UINT,REQ_NO),# Default 0
'lastvote'=>array(TYPE_UINT,REQ_AUTO),# A date line ?
)
(line 51)

Array of recognised and required fields for poll, and their types


Redefinition of:
vB_DataManager::$validfields
Array of field names that are valid for this data object

Inherited Variables

Inherited from vB_DataManager

vB_DataManager::$bitfields
vB_DataManager::$condition
vB_DataManager::$dbobject
vB_DataManager::$errors
vB_DataManager::$error_handler
vB_DataManager::$existing
vB_DataManager::$failure_callback
vB_DataManager::$info
vB_DataManager::$lamda
vB_DataManager::$presave_called
vB_DataManager::$rawfields
vB_DataManager::$registry
vB_DataManager::$setfields
Methods
Constructor vB_DataManager_Poll (line 109)

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

vB_DataManager_Poll vB_DataManager_Poll (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
clear_options (line 211)

Resets the options and votes.

void clear_options ()
get_option (line 180)

Returns the text at a given position or the position of a given option

  • return: Returns true if user exists
boolean get_option (mixed $lookup, [bool $position = true])
  • mixed $lookup: The option text to find or the position to return
  • bool $position: Default true, if true then $lookup is an int and the position, else the option text
get_vote (line 261)

Get a vote for an option

  • return: Returns true if user exists
boolean get_vote (mixed $lookup, [bool $position = true])
  • mixed $lookup: The numeric position or text of the option
  • bool $position: Indicates if it is a position or a option text to look up
post_delete (line 372)

Removing the votes from the

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

Redefinition of:
vB_DataManager::post_delete()
Additional data to update after a delete call (such as denormalized values in other tables).
post_save_each (line 330)

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

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

Redefinition of:
vB_DataManager::post_save_each()
Additional data to update after a save call (such as denormalized values in other tables).
pre_save (line 294)

Format the data for saving

  • return: Function result
boolean pre_save ([bool $doquery = true])
  • bool $doquery

Redefinition of:
vB_DataManager::pre_save()
Any checks to run immediately before saving. If returning false, the save will not take place.
set_existing (line 418)
void set_existing ( &$existing)
  • &$existing

Redefinition of:
vB_DataManager::set_existing()
Sets the existing data
set_option (line 125)

Setting the text for a poll option

  • return: Returns true if user exists
boolean set_option (string $option_text, [integer $option_number = NULL], [integer $votes = null])
  • string $option_text: The option text for a poll
  • integer $option_number: (optional) The position of the option, if you need to over write a option, a blank text will delete will also delete the votes
  • integer $votes: An optional number of votes to set this option to
set_vote (line 225)

Setting the vote for an option

  • return: Returns true if user exists
boolean set_vote (int $position, [int $increment = true])
  • int $position: The position that the vote should be set for
  • int $increment: (optional) The position of the option, if you need to over write a option, a blank text will delete will also delete the votes
verify_poll_options (line 393)

Verifies that there at at least 2 options

  • return: Returns true if user exists
boolean verify_poll_options (integer &$poll_options)
  • integer &$poll_options: User ID
verify_poll_votes (line 405)

Checks that the vote is between 0 and 5

  • return: Returns true on success
boolean verify_poll_votes (integer &$vote)
  • integer &$vote: The vote

Inherited Methods

Inherited From vB_DataManager

 vB_DataManager::vB_DataManager()
 vB_DataManager::check_required()
 vB_DataManager::db_delete()
 vB_DataManager::db_insert()
 vB_DataManager::db_insert_ignore()
 vB_DataManager::db_update()
 vB_DataManager::delete()
 vB_DataManager::do_set()
 vB_DataManager::do_unset()
 vB_DataManager::error()
 vB_DataManager::fetch_field()
 vB_DataManager::fetch_insert_sql()
 vB_DataManager::fetch_update_sql()
 vB_DataManager::has_errors()
 vB_DataManager::post_delete()
 vB_DataManager::post_save_each()
 vB_DataManager::post_save_once()
 vB_DataManager::pre_delete()
 vB_DataManager::pre_save()
 vB_DataManager::save()
 vB_DataManager::set()
 vB_DataManager::setr()
 vB_DataManager::setr_info()
 vB_DataManager::set_bitfield()
 vB_DataManager::set_condition()
 vB_DataManager::set_error_handler()
 vB_DataManager::set_existing()
 vB_DataManager::set_failure_callback()
 vB_DataManager::set_info()
 vB_DataManager::strip_empty_bbcode()
 vB_DataManager::strip_empty_bbcode_callback()
 vB_DataManager::verify()
 vB_DataManager::verify_commalist()
 vB_DataManager::verify_date_array()
 vB_DataManager::verify_email()
 vB_DataManager::verify_image_count()
 vB_DataManager::verify_ipaddress()
 vB_DataManager::verify_link()
 vB_DataManager::verify_list()
 vB_DataManager::verify_md5()
 vB_DataManager::verify_nonempty()
 vB_DataManager::verify_nonzero()
 vB_DataManager::verify_pagetext()
 vB_DataManager::verify_serialized()
 vB_DataManager::verify_spacelist()
 vB_DataManager::verify_userid()
 vB_DataManager::verify_username()

Documentation generated on Fri, 09 May 2008 09:01:03 -0500 by phpDocumentor 1.4.1