Changeset 20431
- Timestamp:
- Jan 27, 2013, 9:56:07 PM (11 years ago)
- Location:
- extensions/Piwecard
- Files:
-
- 4 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; -
extensions/Piwecard/install/functions.inc.php
r20202 r20431 1 1 <?php 2 /** 3 * Create the piwecard table in the database 4 * @param String name of the table 5 */ 2 6 function piwecard_db_create($table) { 3 7 $query = 'CREATE TABLE ' . $table . ' ( … … 18 22 } 19 23 24 /** 25 * Delete the piwecard table in the database 26 * @param String name of the table 27 */ 20 28 function piwecard_db_delete($table) { 21 29 $query = 'DROP TABLE ' . $table . ';'; … … 23 31 } 24 32 33 /** 34 * Update the piwecard table in the database from Piwecard version 2.3 35 * @param String old table name 36 * @param String new table name 37 */ 25 38 function piwecard_db_update_from_2_3($old_table, $new_table) { 26 39 $query = 'SELECT * FROM '.$old_table.';'; … … 49 62 } 50 63 64 /** 65 * Update the piwecard table in the database from Piwecard version 2.4.a.b3 66 * @param String table name 67 */ 51 68 function piwecard_db_update_from_2_4a_b3($table) { 52 69 $query = 'ALTER TABLE '.$table.' DROP PRIMARY KEY;'; … … 58 75 } 59 76 77 /** 78 * Create the piwecard entry in the config table of the database 79 * @param String entry name 80 */ 60 81 function piwecard_conf_create($name) { 61 82 $query = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("'.$name.'","","'.ucfirst($name).' configuration");'; … … 63 84 } 64 85 86 /** 87 * Delete the piwecard entry in the config table of the database 88 * @param String entry name 89 */ 65 90 function piwecard_conf_delete($name){ 66 91 $query = 'DELETE FROM '.CONFIG_TABLE.' WHERE param="'.$name.'";'; … … 68 93 } 69 94 95 /** 96 * Rename the piwecard entry in the config table of the database 97 * @param String old name 98 * @param String new name 99 */ 70 100 function piwecard_conf_rename($old_name, $new_name){ 71 101 $query = 'UPDATE '.CONFIG_TABLE.' SET param="'.$new_name.'" WHERE param="'.$old_name.'";'; -
extensions/Piwecard/js/piwecard.js
r20254 r20431 1 /** 2 * Check if a field is valid 3 * @param Object element to check 4 * @param Integer type of the element (0 is text, 1 is email, 2 is number) 5 * @param String Style of the error displayed (default = inline) 6 * @param Boolean True if the field can be empty, False otherwise 7 * @return True if OK, False otherwise 8 */ 1 9 function piwecard_checkField(element, elementType, display, nullIsOK) { 2 10 var TEXT = 0; … … 51 59 } 52 60 61 /** 62 * Style to add to the field if piwecard_checkField returns false 63 * @param Object element 64 * @param String Style of the error displayed (default = inline) 65 */ 53 66 function add_error_style(element, display) { 54 67 document.getElementById(element.id+'_error').style.display = display; … … 56 69 } 57 70 71 /** 72 * Remove the error style from the field if piwecard_checkField returns true 73 * @param Object element 74 */ 58 75 function remove_error_style(element) { 59 76 document.getElementById(element.id+'_error').style.display = 'none'; -
extensions/Piwecard/ws/ws_functions.inc.php
r20421 r20431 12 12 ); 13 13 14 /** 15 * Function called by Javascript 16 * @param Array Parameters passed through Javascript 17 * @param 18 * @return String the preview of the email 19 */ 14 20 function piwecard_ws_previewEmail($params, $service) { 15 21 $format_message = $params['format_message']; … … 19 25 } 20 26 27 /** 28 * Construct the preview of the email 29 * @param String Email format (text or html) 30 * @param String the email message 31 * @return String the preview of the email 32 */ 21 33 function previewEmail($format_message, $message) { 22 34 $piwecard = new Piwecard(); … … 47 59 } 48 60 61 /** 62 * Get style from the email template 63 * @param String The value of the node "Style" 64 * @return Array the styles of the email 65 */ 49 66 function piwecard_create_style_array($style) { 50 67 $style = str_replace(array("\n", "\t"), array('', ''), $style); … … 66 83 } 67 84 85 /** 86 * Parse the email message 87 * @param String message to parse 88 * @return String parsed message 89 */ 68 90 function parse($data) { 69 91 global $conf;
Note: See TracChangeset
for help on using the changeset viewer.