Ignore:
Timestamp:
Jan 27, 2013, 9:56:07 PM (11 years ago)
Author:
julien1311
Message:

[piwecard] Some code documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Piwecard/include/piwecard.class.php

    r20421 r20431  
    66        var $user_groups = array();
    77       
    8         // Class constructor
     8        /**
     9         * Constructor
     10         */
    911        function __construct() {
    1012                $this->get_config();
    1113        }
    1214       
    13         // Load general configuration from config_database
     15        /**
     16         * Load configuration from database
     17         * Assign value to the variable $config
     18         */
    1419        function get_config() {
    1520                $query = 'SELECT value FROM '.CONFIG_TABLE.' WHERE param="piwecard";';
     
    2530        }
    2631       
    27         // Initialize default values of params
     32        /**
     33         * Load default configuration from the install directory
     34         * Assign value to the variable $config
     35         */
    2836        private function get_default_config() {
    2937            require(PIWECARD_INSTALL_PATH.'default_values.inc.php');
     
    3442        }
    3543
    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         */
    3749        function get_default_config_param($param) {
    3850            require(PIWECARD_INSTALL_PATH.'default_values.inc.php');
     
    4052        }
    4153       
    42         // Save  general configuration to config_database
     54        /**
     55         * Save the current configuration (ie the value of $config) to the database
     56         */
    4357        function set_config() {
    4458                conf_update_param('piwecard', pwg_db_real_escape_string(serialize($this->config)));
    4559        }
    4660       
     61        /**
     62         * Initialize the section parameter of the page
     63         */
    4764        function section_init_ecard() {
    4865                global $tokens, $page;
     
    5269        }
    5370       
     71        /**
     72         * Load the ecard
     73         */
    5474        function index_ecard() {
    55                 global $page;
    56                
     75                global $page;   
    5776                if (isset($page['section']) and $page['section'] == 'ecard') {
    5877                        include('publish.inc.php');
     
    6079        }
    6180
    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         */
    6386        private function random($car) {
    6487                $string = "";
     
    7194        }
    7295       
     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         */
    73103        function parse($data, $values, $image_element) {
    74104                include (PIWECARD_PATH.'include/parse_param.inc.php');
     
    84114        }
    85115       
    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         */
    87120        function get_nb_ecard() {
    88121                $query = 'SELECT COUNT(DISTINCT ecard_id) AS nb FROM '.PIWECARD_TABLE.' ORDER BY date_creation;';
     
    96129        }
    97130
    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         */
    99135        function get_nb_valid_ecard() {
    100136                $query = 'SELECT COUNT(DISTINCT ecard_id) AS nb FROM '.PIWECARD_TABLE.' WHERE date_validity IS NULL OR date_validity > NOW();';
     
    108144        }
    109145       
    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) {
    113152                if ($ecard_id!== null) {
    114153                        $query = 'SELECT * FROM ' . PIWECARD_TABLE .' WHERE ecard_id="' . $ecard_id . '" LIMIT 1;';
     
    122161        }
    123162
    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) {
    125169                if (isset($ecard_id)) {
    126170                        $ecard_info = $this->get_ecard($ecard_id);
     
    146190        }
    147191       
    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) {
    151197                if (isset($ecard_id)) {
    152198                        $query = 'DELETE FROM ' . PIWECARD_TABLE .' WHERE ecard_id="' . $ecard_id  . '";';
     
    156202        }
    157203       
    158         // Delete all invalid ecard
     204        /**
     205         * Delete all invalid ecards
     206         */
    159207        function delete_allinvalid_ecard() {
    160208                $query = 'DELETE FROM ' . PIWECARD_TABLE .' WHERE date_validity < NOW();';
     
    162210        }
    163211       
     212        /**
     213         * Is the email valid?
     214         * @param String email address
     215         * @return Boolean True if valid, False otherwise
     216         */
    164217        function is_valid_email($email_address) {
    165218                $syntax = '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#';
     
    171224        }
    172225       
    173         // Add tpl to picture.php page to display ecard informations
     226        /**
     227         * Add tpl to picture.php page to display ecard informations
     228         */
    174229        function display_ecard_to_picture() {
    175230                global $page, $user, $template;
     
    413468        }
    414469       
    415         //Send an email
     470        /**
     471         * Send an email
     472         * @param Array informations of the email
     473         */
    416474        function mail($email_infos) {
    417475                global $lang_info;
     
    459517        }
    460518       
     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         */
    461524        function get_text_message($message_text, $smarty) {
    462525                global $page, $conf;
     
    474537        }
    475538       
     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         */
    476544        function get_html_message($message_html, $smarty) {
    477545                global $page, $conf;
Note: See TracChangeset for help on using the changeset viewer.