Umfragen
poll Class Reference

Public Member Functions

 set_status ($db, $status)
 sets the status of the poll and saves it to the database
 set_anonymous ($db, $au, $val)
 set or unset the poll anonymous status. Saves to db and checks if the result table is empty
 set_is_public ($db, $au, $val)
 make the poll public. Saving to database
 set_name ($name)
 sets the poll's name. does not save to database.
 make_id_hash ()
 generates a more or less random but unique identifier harder to guess than a bare ID
 delete ($db)
 sets the status of the poll to deleted. Savng to database
 set_config ($name, $value)
 sets a config variable
 get_config ($name)
 gets a config variable
 serialize_config ()
 serialize the config into a string
 get_widget_by_id ($ID)
 get a widget by it's ID, searches also recursively in container widgets
 get_widget_by_name ($name)
 get a widget by it's name. Searches recursively in container widgets and returnes the first widget found
 is_group_in_groups ($group)
 checks if the given group is in the poll's group array.
 get_active_since_timestammp ()
 gets a unix timestamp for active_since saved in MYSQL format
 get_timeout_timestamp ()
 gets a unix timestamp for timeout date saved in MYSQL format
 get_timeout_string ()
 gets a human readable string for the timeout date
 get_widget_default_font_config ($conf)
 checks all widgets for the most used font config values
 check_setup_complete ($r=false)
 checks if the setup si complete for activation of the poll
 load ($db)
 loads only the widget list from thew database the pollID has to be set
 load_from_id ($db, $pollID)
 loads the complete poll ready to use from the database
 load_values_from_id ($db, $username)
 loads the result values for a username
 load_widget_result_count ($db)
 executes the count method on every countable widget so the count data is available
 insert_widget ($index=-1, $w)
 inserts a widget into the widget list at a given position
 delete_widget ($db, $id)
 delete a widget by ID, delete also from database
 move_widget ($db, $index1, $index2)
 moves a widget from index1 to index2
 save_name ($db)
 save the poll name to the database
 save_groups ($db)
 save the group settings for the poll
 save_timeout ($db)
 save the timeout settings. The format must be correct for the database
 save_noDisplay ($db)
 save setting if we want to display the poll onto the start page db $db the database object
 save_theme ($db)
 save the selected theme db $db the database object
 save_config ($db)
 serialize and save the config db $db the database object
 display ()
 display the widgets if they implement output_widget
 handle_inpt ()
 executes handle_input on all widgets implementing input_widget
 display_name_edit ()
 display name edit for poll's name
 handle_name_edit ()
 hande the name edit name has to be less than 256 characters
 display_groups_edit ($auth, $whitelist=array())
 display a list of all groups for selection
 handle_groups_edit ($auth, $whitelist=array())
 handles the groups edit and sets the groups
 display_timeout_edit ()
 display the edit for the poll's timeout. Uses jquerry but has a non js fallback
 handle_timeout_edit ()
 handles the timeout edit of the poll and checks the date
 display_status_edit ()
 displays the status edit. active incomplete deactivated template and archive
 handle_status_edit ($db)
 handles the status edit throws error if not possible to activate sets direct to the database
 display_export_edit ()
 displays a export box for exporting the polls results
 handle_export_edit (db $db, $dl)
 handles the export edit and exports the results
 display_font_family_edit ()
 displays a select for the font family
 handle_font_family_edit ()
 handles the font family config and sets the font family for all widgets
 display_font_size_edit ()
 displays a drop down for selecting the poll's font size
 handle_font_size_edit ()
 handles pol's font size and sets it into all widget's config
 display_questions_bold_edit ()
 displays a checkbox for selecting if the questions of the poll should be bold
 handle_questions_bold_edit ()
 handles if the questions should be bold and saves the config to all widgets
 display_noDisplay_edit ()
 displays a checkbox for selectig if we display the poll onto the start page
 handle_noDisplay_edit ()
 display_anonymous2_edit ()
 display a drop down menu for selecting if the poll is anonymous, public or normal
 handle_anonymous2_edit ($db, $au)
 tries to set anonymous status according to the user's selection
 handle_anonymous_edit ()
 sets anonymous status use anonymous2 functions instead
 display_theme_edit ()
 displays a drop down list of available themes. Themes are located in /CSS/Themes
 handle_theme_edit ()
 handles the theme edit. reset to none on error
 display_notification_edit ()
 display checkboxes for email notification feature
 handle_notification_edit ()
 handles notification edit

Data Fields

 $widget_list
 list containing the widgets.
 $ID
 the unique poll ID .. should be always set
 $hashID
 a more or less unique ID difficult to guess. Used in public polls as ID
 $name
 the polls's name provided by the user
 $timeout
 time out string in MYSQL format
 $active_since
 MYSQL timestamp since when the poll came active. Used by "new" indicator.
 $groups = array()
 list of group IDs for who has access to the poll
 $status
 polls status integer .. for a list see config.php
 $owner = 0
 numerical user ID of the owner and creator of the poll.
 $owner_fn = ""
 Full name of the owner for displaying.
 $type = 0
 Integer for advanced mode or simple mode.
 $anonymous = false
 is this a anonymous poll?
 $is_public = false
 is this a public poll? note in the DB this is int 2 in the databases anonymous column
 $noDisplay = false
 shall we display the poll on the home page
 $theme = ""
 the themes css file name including .css extention
 $local_monthNames

Private Member Functions

 display_timeout_option ($i, $seleced)
 used for displaying a select option for the i-th element of a number list
 format_int_2digit ($i)
 formats a integer to two digits min

Private Attributes

 $config = array()
 containing the config array unserialized from the database

Detailed Description

Definition at line 25 of file poll.class.php.

Member Function Documentation

check_setup_complete (   $r = false)

checks if the setup si complete for activation of the poll

Parameters
bool$rif true return a array of the reasons or if false only return a bolean
Returns
array of reasons or boolean

the test are the following: name, if not public the groups, timeout and the widget list must not be empty

Definition at line 376 of file poll.class.php.

delete (   $db)

sets the status of the poll to deleted. Savng to database

Parameters
db$dbdatabase object

Definition at line 176 of file poll.class.php.

delete_widget (   $db,
  $id 
)

delete a widget by ID, delete also from database

Parameters
db$dbdatabase object
int$idthe widget's ID

Definition at line 556 of file poll.class.php.

display ( )

display the widgets if they implement output_widget

Definition at line 734 of file poll.class.php.

display_anonymous2_edit ( )

display a drop down menu for selecting if the poll is anonymous, public or normal

See Also
handle_anonymous2_edit()

Definition at line 1326 of file poll.class.php.

display_export_edit ( )

displays a export box for exporting the polls results

See Also
handle_export_edit()

Definition at line 1122 of file poll.class.php.

display_font_family_edit ( )

displays a select for the font family

See Also
handle_font_family_edit()

Definition at line 1171 of file poll.class.php.

display_font_size_edit ( )

displays a drop down for selecting the poll's font size

See Also
handle_font_size_edit()

Definition at line 1230 of file poll.class.php.

display_groups_edit (   $auth,
  $whitelist = array() 
)

display a list of all groups for selection

Parameters
auth$authauthentification object to get the group list
array$whitelistthe group whitelist can be empty
See Also
handle_groups_edit()

Definition at line 800 of file poll.class.php.

display_name_edit ( )

display name edit for poll's name

See Also
handle_name_edit()

Definition at line 767 of file poll.class.php.

display_noDisplay_edit ( )

displays a checkbox for selectig if we display the poll onto the start page

See Also
handle_noDisplay_edit()

Definition at line 1302 of file poll.class.php.

display_notification_edit ( )

display checkboxes for email notification feature

See Also
handle_notification_edit()

Definition at line 1461 of file poll.class.php.

display_questions_bold_edit ( )

displays a checkbox for selecting if the questions of the poll should be bold

See Also
handle_questions_bold_edit()

Definition at line 1275 of file poll.class.php.

display_status_edit ( )

displays the status edit. active incomplete deactivated template and archive

See Also
handle_status_edit()

Definition at line 1059 of file poll.class.php.

display_theme_edit ( )

displays a drop down list of available themes. Themes are located in /CSS/Themes

See Also
handle_theme_edit()

Definition at line 1399 of file poll.class.php.

display_timeout_edit ( )

display the edit for the poll's timeout. Uses jquerry but has a non js fallback

See Also
handle_timeout_edit()

Definition at line 904 of file poll.class.php.

display_timeout_option (   $i,
  $seleced 
)
private

used for displaying a select option for the i-th element of a number list

Parameters
int$ithe number most likely out of a iteration loop
int$selectedthe number of the selected element

Definition at line 891 of file poll.class.php.

format_int_2digit (   $i)
private

formats a integer to two digits min

Parameters
int$ithe integer to format
Returns
string formatted int

Definition at line 983 of file poll.class.php.

get_active_since_timestammp ( )

gets a unix timestamp for active_since saved in MYSQL format

Returns
int timestamp or 0 on failure

Definition at line 286 of file poll.class.php.

get_config (   $name)

gets a config variable

Parameters
string$namevariable name
Returns
mixed config

Definition at line 198 of file poll.class.php.

get_timeout_string ( )

gets a human readable string for the timeout date

Returns
string timeout or empty string

Definition at line 318 of file poll.class.php.

get_timeout_timestamp ( )

gets a unix timestamp for timeout date saved in MYSQL format

Returns
int timestamp or 0 on failure

Definition at line 302 of file poll.class.php.

get_widget_by_id (   $ID)

get a widget by it's ID, searches also recursively in container widgets

Parameters
intthe widgett's ID
Returns
widget object or null if not found

Definition at line 229 of file poll.class.php.

get_widget_by_name (   $name)

get a widget by it's name. Searches recursively in container widgets and returnes the first widget found

Parameters
intthe widgett's name
Returns
widget object or null if not found

Definition at line 251 of file poll.class.php.

get_widget_default_font_config (   $conf)

checks all widgets for the most used font config values

Parameters
string$confconfig variable name: font-family, font-size or font-bold
Returns
string of the requested config or empty string

Definition at line 344 of file poll.class.php.

handle_anonymous2_edit (   $db,
  $au 
)

tries to set anonymous status according to the user's selection

Parameters
db$dbdatabase object
auth$auauthentification object
Returns
bool true on success, else error message string
See Also
display_anonymous2_edit()

Definition at line 1354 of file poll.class.php.

handle_anonymous_edit ( )

sets anonymous status use anonymous2 functions instead

Definition at line 1381 of file poll.class.php.

handle_export_edit ( db  $db,
  $dl 
)

handles the export edit and exports the results

Parameters
db$dbthe database object
bool$dltrue if we want to present the csv file to download
Returns
bool true
See Also
display_export_edit()

Definition at line 1142 of file poll.class.php.

handle_font_family_edit ( )

handles the font family config and sets the font family for all widgets

See Also
display_fong_famiy_edit()

Definition at line 1203 of file poll.class.php.

handle_font_size_edit ( )

handles pol's font size and sets it into all widget's config

See Also
display_font_size_edit()

Definition at line 1255 of file poll.class.php.

handle_groups_edit (   $auth,
  $whitelist = array() 
)

handles the groups edit and sets the groups

Parameters
auth$auththe authentification object
array$whitelistthe group whitelist can be an empty array
Returns
bool true on success els array with error description

Definition at line 834 of file poll.class.php.

handle_inpt ( )

executes handle_input on all widgets implementing input_widget

Returns
array of errors or if there are no errors an empty array

Definition at line 746 of file poll.class.php.

handle_name_edit ( )

hande the name edit name has to be less than 256 characters

Returns
bool true on success on error error string
See Also
display_name_edit()

Definition at line 776 of file poll.class.php.

handle_noDisplay_edit ( )

no display edit

See Also
display_noDisplay_edit()

Definition at line 1314 of file poll.class.php.

handle_notification_edit ( )

handles notification edit

See Also
display_notification_edit()

Definition at line 1480 of file poll.class.php.

handle_questions_bold_edit ( )

handles if the questions should be bold and saves the config to all widgets

See Also
display_questions_bold_edit()

Definition at line 1288 of file poll.class.php.

handle_status_edit (   $db)

handles the status edit throws error if not possible to activate sets direct to the database

Parameters
db$dbdatabase object
See Also
display_status_edit()

Definition at line 1088 of file poll.class.php.

handle_theme_edit ( )

handles the theme edit. reset to none on error

See Also
display_theme_edit()

Definition at line 1434 of file poll.class.php.

handle_timeout_edit ( )

handles the timeout edit of the poll and checks the date

Returns
bool true or error string
See Also
display_timeout_edit()

Definition at line 996 of file poll.class.php.

insert_widget (   $index = -1,
  $w 
)

inserts a widget into the widget list at a given position

Parameters
int$indexindex where to insert -1 for the end of the list
widget$wthe widget object we want insert

Definition at line 518 of file poll.class.php.

is_group_in_groups (   $group)

checks if the given group is in the poll's group array.

Parameters
int$groupthe numerical ID of the group we want to check
Returns
bool true if group is in the array, including "*" wildcard check

if the group "*" is in the poll's grouplist then any group will be accepted

Definition at line 273 of file poll.class.php.

load (   $db)

loads only the widget list from thew database the pollID has to be set

Parameters
db$dbdatabase object

Definition at line 419 of file poll.class.php.

load_from_id (   $db,
  $pollID 
)

loads the complete poll ready to use from the database

Parameters
db$dbdatabase object
int$pollIDthe ID of the poll we want to load
Returns
bool true on success, bool false on failure

Definition at line 429 of file poll.class.php.

load_values_from_id (   $db,
  $username 
)

loads the result values for a username

Parameters
db$dbthe databaseobject
string$usernamethe user's username
Returns
bool true on success false on failure

Definition at line 469 of file poll.class.php.

load_widget_result_count (   $db)

executes the count method on every countable widget so the count data is available

Parameters
db$dbdatabase object

Definition at line 494 of file poll.class.php.

make_id_hash ( )

generates a more or less random but unique identifier harder to guess than a bare ID

Returns
string the identifier md5 hashed or empty string on failure

Definition at line 162 of file poll.class.php.

move_widget (   $db,
  $index1,
  $index2 
)

moves a widget from index1 to index2

Parameters
db$dbdatabase object
int$index1index of the widget we want to move
int$index2index we want to move to bool true on success else false on failure

Definition at line 596 of file poll.class.php.

save_config (   $db)

serialize and save the config db $db the database object

Returns
true on success false on failure

Definition at line 720 of file poll.class.php.

save_groups (   $db)

save the group settings for the poll

Parameters
db$dbdatabase object
Returns
true on success and false on failure

Definition at line 670 of file poll.class.php.

save_name (   $db)

save the poll name to the database

Parameters
db$dbdatabaseobject
Returns
bool true on succes else false on failure

Definition at line 661 of file poll.class.php.

save_noDisplay (   $db)

save setting if we want to display the poll onto the start page db $db the database object

Returns
true on success false on failure

Definition at line 702 of file poll.class.php.

save_theme (   $db)

save the selected theme db $db the database object

Returns
true on success false on failure

Definition at line 711 of file poll.class.php.

save_timeout (   $db)

save the timeout settings. The format must be correct for the database

Parameters
db$dbdatabase object
Returns
bool tue on success and false on failure

Definition at line 693 of file poll.class.php.

serialize_config ( )

serialize the config into a string

Parameters
stringof serialized config

Definition at line 213 of file poll.class.php.

set_anonymous (   $db,
  $au,
  $val 
)

set or unset the poll anonymous status. Saves to db and checks if the result table is empty

Parameters
db$dbdatabase object
auth$auautehntification object (obsolete?)
bool$valtrue means anonymous poll
Returns
string with error message or empty strng when status set

You can only change anonymousity if the result table ist empty ! This function also makes a Klassenliste if the user is a teacher

Definition at line 80 of file poll.class.php.

set_config (   $name,
  $value 
)

sets a config variable

Parameters
string$namevariable name
mixed$valuethe value we want set

Definition at line 185 of file poll.class.php.

set_is_public (   $db,
  $au,
  $val 
)

make the poll public. Saving to database

Parameters
db$dbdatabase object
auth$auautehntification object
bool$valtrue means public poll
Returns
string with error message or empty strng when status set

You can only publish a anonymous poll. If zou do not so, an error message ist provided Use set_anonymous for this

Definition at line 119 of file poll.class.php.

set_name (   $name)

sets the poll's name. does not save to database.

Parameters
string$namea name string with less than 256 characters
Returns
bool true on success, false on error

the string is htmlspecialchars escaped and saved so. So zou can print it anywhere

Definition at line 149 of file poll.class.php.

set_status (   $db,
  $status 
)

sets the status of the poll and saves it to the database

Parameters
db$dbdatabase object
integer$statusa valid status int
Returns
bool true on success, false on error

Definition at line 61 of file poll.class.php.

Field Documentation

$active_since

MYSQL timestamp since when the poll came active. Used by "new" indicator.

Definition at line 32 of file poll.class.php.

$anonymous = false

is this a anonymous poll?

Definition at line 38 of file poll.class.php.

$config = array()
private

containing the config array unserialized from the database

Definition at line 48 of file poll.class.php.

$groups = array()

list of group IDs for who has access to the poll

Definition at line 33 of file poll.class.php.

$hashID

a more or less unique ID difficult to guess. Used in public polls as ID

Definition at line 29 of file poll.class.php.

$ID

the unique poll ID .. should be always set

Definition at line 28 of file poll.class.php.

$is_public = false

is this a public poll? note in the DB this is int 2 in the databases anonymous column

Definition at line 39 of file poll.class.php.

$local_monthNames
Initial value:
array( 0 => "Januar", 1 => "Februar", 2 => "März",
3 => "April", 4 => "Mai", 5 => "Juni",
6 => "Juli", 7 => "August", 8 => "September",
9 => "Oktober", 10 => "November", 11 => "Dezember" )

Definition at line 43 of file poll.class.php.

$name

the polls's name provided by the user

Definition at line 30 of file poll.class.php.

$noDisplay = false

shall we display the poll on the home page

Definition at line 40 of file poll.class.php.

$owner = 0

numerical user ID of the owner and creator of the poll.

Definition at line 35 of file poll.class.php.

$owner_fn = ""

Full name of the owner for displaying.

Definition at line 36 of file poll.class.php.

$status

polls status integer .. for a list see config.php

Definition at line 34 of file poll.class.php.

$theme = ""

the themes css file name including .css extention

Definition at line 41 of file poll.class.php.

$timeout

time out string in MYSQL format

Definition at line 31 of file poll.class.php.

$type = 0

Integer for advanced mode or simple mode.

Definition at line 37 of file poll.class.php.

$widget_list

list containing the widgets.

Definition at line 27 of file poll.class.php.


The documentation for this class was generated from the following file: