Changeset 20431 for extensions/Piwecard/include/piwecard.class.php
- Timestamp:
- Jan 27, 2013, 9:56:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/Piwecard/include/piwecard.class.php
r20421 r20431 6 6 var $user_groups = array(); 7 7 8 // Class constructor 8 /** 9 * Constructor 10 */ 9 11 function __construct() { 10 12 $this->get_config(); 11 13 } 12 14 13 // Load general configuration from config_database 15 /** 16 * Load configuration from database 17 * Assign value to the variable $config 18 */ 14 19 function get_config() { 15 20 $query = 'SELECT value FROM '.CONFIG_TABLE.' WHERE param="piwecard";'; … … 25 30 } 26 31 27 // Initialize default values of params 32 /** 33 * Load default configuration from the install directory 34 * Assign value to the variable $config 35 */ 28 36 private function get_default_config() { 29 37 require(PIWECARD_INSTALL_PATH.'default_values.inc.php'); … … 34 42 } 35 43 36 //Get the default value of a parameter 44 /** 45 * Get the default value of a parameter 46 * @param name of the parameter 47 * @return the default config of the parameter 48 */ 37 49 function get_default_config_param($param) { 38 50 require(PIWECARD_INSTALL_PATH.'default_values.inc.php'); … … 40 52 } 41 53 42 // Save general configuration to config_database 54 /** 55 * Save the current configuration (ie the value of $config) to the database 56 */ 43 57 function set_config() { 44 58 conf_update_param('piwecard', pwg_db_real_escape_string(serialize($this->config))); 45 59 } 46 60 61 /** 62 * Initialize the section parameter of the page 63 */ 47 64 function section_init_ecard() { 48 65 global $tokens, $page; … … 52 69 } 53 70 71 /** 72 * Load the ecard 73 */ 54 74 function index_ecard() { 55 global $page; 56 75 global $page; 57 76 if (isset($page['section']) and $page['section'] == 'ecard') { 58 77 include('publish.inc.php'); … … 60 79 } 61 80 62 //Générer une chaine de caractère unique et aléatoire 81 /** 82 * Get a random string 83 * @param Integer number of caracter of the random string 84 * @return String the random string 85 */ 63 86 private function random($car) { 64 87 $string = ""; … … 71 94 } 72 95 96 /** 97 * Parse the message 98 * @param String string to parse 99 * @param Array parser parameters 100 * @param Array an array with the id and the url of the image 101 * @return String the parsed string 102 */ 73 103 function parse($data, $values, $image_element) { 74 104 include (PIWECARD_PATH.'include/parse_param.inc.php'); … … 84 114 } 85 115 86 // Get the number of ecard in the database 116 /** 117 * Get the number of ecards in the database 118 * @return Integer number of ecards 119 */ 87 120 function get_nb_ecard() { 88 121 $query = 'SELECT COUNT(DISTINCT ecard_id) AS nb FROM '.PIWECARD_TABLE.' ORDER BY date_creation;'; … … 96 129 } 97 130 98 // Get the number of valid ecard in the database 131 /** 132 * Get the number of validecards in the database 133 * @return Integer number of valid ecards 134 */ 99 135 function get_nb_valid_ecard() { 100 136 $query = 'SELECT COUNT(DISTINCT ecard_id) AS nb FROM '.PIWECARD_TABLE.' WHERE date_validity IS NULL OR date_validity > NOW();'; … … 108 144 } 109 145 110 111 // Get ecard information into array 112 function get_ecard($ecard_id = null) { 146 /** 147 * Get ecard informations into an array 148 * @param Integer ecard id 149 * @return Array informations of the ecard 150 */ 151 function get_ecard($ecard_id) { 113 152 if ($ecard_id!== null) { 114 153 $query = 'SELECT * FROM ' . PIWECARD_TABLE .' WHERE ecard_id="' . $ecard_id . '" LIMIT 1;'; … … 122 161 } 123 162 124 function is_valid($ecard_id = null) { 163 /** 164 * Is the ecard valid? 165 * @param Integer ecard id 166 * @return Boolean True if valid, False otherwise 167 */ 168 function is_valid($ecard_id) { 125 169 if (isset($ecard_id)) { 126 170 $ecard_info = $this->get_ecard($ecard_id); … … 146 190 } 147 191 148 // delete one ecard 149 // force to delete valid ecard 150 function delete_ecard($ecard_id = null) { 192 /** 193 * Delete one ecard 194 * @param Integer ecard id 195 */ 196 function delete_ecard($ecard_id) { 151 197 if (isset($ecard_id)) { 152 198 $query = 'DELETE FROM ' . PIWECARD_TABLE .' WHERE ecard_id="' . $ecard_id . '";'; … … 156 202 } 157 203 158 // Delete all invalid ecard 204 /** 205 * Delete all invalid ecards 206 */ 159 207 function delete_allinvalid_ecard() { 160 208 $query = 'DELETE FROM ' . PIWECARD_TABLE .' WHERE date_validity < NOW();'; … … 162 210 } 163 211 212 /** 213 * Is the email valid? 214 * @param String email address 215 * @return Boolean True if valid, False otherwise 216 */ 164 217 function is_valid_email($email_address) { 165 218 $syntax = '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#'; … … 171 224 } 172 225 173 // Add tpl to picture.php page to display ecard informations 226 /** 227 * Add tpl to picture.php page to display ecard informations 228 */ 174 229 function display_ecard_to_picture() { 175 230 global $page, $user, $template; … … 413 468 } 414 469 415 //Send an email 470 /** 471 * Send an email 472 * @param Array informations of the email 473 */ 416 474 function mail($email_infos) { 417 475 global $lang_info; … … 459 517 } 460 518 519 /** 520 * Get the content of the email when the format is plain text 521 * @param String the email message 522 * @param Smarty a smarty object 523 */ 461 524 function get_text_message($message_text, $smarty) { 462 525 global $page, $conf; … … 474 537 } 475 538 539 /** 540 * Get the content of the email when the format is html 541 * @param String the email message 542 * @param Smarty a smarty object 543 */ 476 544 function get_html_message($message_html, $smarty) { 477 545 global $page, $conf;
Note: See TracChangeset
for help on using the changeset viewer.