Changeset 20431


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

[piwecard] Some code documentation

Location:
extensions/Piwecard
Files:
4 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;
  • extensions/Piwecard/install/functions.inc.php

    r20202 r20431  
    11<?php
     2/**
     3 * Create the piwecard table in the database
     4 * @param String name of the table
     5 */
    26function piwecard_db_create($table) {
    37        $query = 'CREATE TABLE ' . $table . ' (
     
    1822}
    1923
     24/**
     25 * Delete the piwecard table in the database
     26 * @param String name of the table
     27 */
    2028function piwecard_db_delete($table) {
    2129        $query = 'DROP TABLE ' . $table . ';';
     
    2331}
    2432
     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 */
    2538function piwecard_db_update_from_2_3($old_table, $new_table) {
    2639        $query = 'SELECT * FROM '.$old_table.';';
     
    4962}
    5063
     64/**
     65 * Update the piwecard table in the database from Piwecard version 2.4.a.b3
     66 * @param String table name
     67 */
    5168function piwecard_db_update_from_2_4a_b3($table) {
    5269        $query = 'ALTER TABLE '.$table.' DROP PRIMARY KEY;';
     
    5875}
    5976
     77/**
     78 * Create the piwecard entry in the config table of the database
     79 * @param String entry name
     80 */
    6081function piwecard_conf_create($name) {
    6182        $query = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("'.$name.'","","'.ucfirst($name).' configuration");';
     
    6384}
    6485
     86/**
     87 * Delete the piwecard entry in the config table of the database
     88 * @param String entry name
     89 */
    6590function piwecard_conf_delete($name){
    6691        $query = 'DELETE FROM '.CONFIG_TABLE.' WHERE param="'.$name.'";';
     
    6893}
    6994
     95/**
     96 * Rename the piwecard entry in the config table of the database
     97 * @param String old name
     98 * @param String new name
     99 */
    70100function piwecard_conf_rename($old_name, $new_name){
    71101        $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 */
    19function piwecard_checkField(element, elementType, display, nullIsOK) {
    210        var TEXT = 0;
     
    5159}
    5260
     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 */
    5366function add_error_style(element, display) {
    5467        document.getElementById(element.id+'_error').style.display = display;
     
    5669}
    5770
     71/**
     72 * Remove the error style from the field if piwecard_checkField returns true
     73 * @param Object element
     74 */
    5875function remove_error_style(element) {
    5976        document.getElementById(element.id+'_error').style.display = 'none';
  • extensions/Piwecard/ws/ws_functions.inc.php

    r20421 r20431  
    1212);
    1313
     14/**
     15 * Function called by Javascript
     16 * @param Array Parameters passed through Javascript
     17 * @param
     18 * @return String the preview of the email
     19 */
    1420function piwecard_ws_previewEmail($params, $service) {
    1521        $format_message = $params['format_message'];
     
    1925}
    2026
     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 */
    2133function previewEmail($format_message, $message) {
    2234        $piwecard = new Piwecard();
     
    4759}
    4860
     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 */
    4966function piwecard_create_style_array($style) {
    5067        $style = str_replace(array("\n", "\t"), array('', ''), $style);
     
    6683}
    6784
     85/**
     86 * Parse the email message
     87 * @param String message to parse
     88 * @return String parsed message
     89 */
    6890function parse($data) {
    6991        global $conf;
Note: See TracChangeset for help on using the changeset viewer.