Changeset 1169

Show
Ignore:
Timestamp:
01/16/07 18:49:24 (6 years ago)
Author:
benoitg
Message:
  • A few more steps towards a real user manager
  • Move password change to preferences.
  • InterfaceElements?: Begin moving away from a raw HTML generator and towards a more semantic one as discussed with Max Horvath.
Location:
trunk/wifidog-auth
Files:
1 added
2 removed
13 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1168 r1169  
     12007-01-16 Benoit Grégoire  <bock@step.polymtl.ca> 
     2        * A few more steps towards a real user manager 
     3        * Move password change to preferences. 
     4        * InterfaceElements:  Begin moving away from a raw HTML generator and towards a more semantic one as discussed with Max Horvath. 
     5 
    162007-01-15 Benoit Grégoire  <bock@step.polymtl.ca> 
    27        * Sync initial schema and translations 
  • trunk/wifidog-auth/wifidog/admin/templates/user_log.html

    r1116 r1169  
    2121{section name=i loop=$users_array} 
    2222<tr> 
    23         <td><a href="stats.php?Statistics={$users_array[i].account_origin}&distinguish_users_by=user_id&stats_selected_users={$users_array[i].username}&UserReport=on&user_id={$users_array[i].user_id}&action=generate">{$users_array[i].username}</a></td> 
     23                     
     24 
     25        <td><a href="{$base_ssl_path}admin/generic_object_admin.php?object_id={$users_array[i].user_id}&object_class=User&action=edit">{$users_array[i].username}</a></td> 
    2426        <td>{$users_array[i].account_origin}</td> 
    2527    <td>{$users_array[i].reg_date|date_format:"%Y/%m/%d"}</td> 
  • trunk/wifidog-auth/wifidog/classes/InterfaceElements.php

    r1090 r1169  
    6363 
    6464     */ 
    65         private static function _generateClosingElement($name, $content = "", $tags = array()) 
    66         { 
    67             // Init values 
    68                 $_retVal = ""; 
    69  
    70                 if ($name) { 
    71                     $_retVal .= "<" . $name; 
    72  
    73                     // Add tags 
    74                     if (is_array($tags)) { 
    75                         foreach ($tags as $_tagName => $_tagValue) { 
    76                             $_retVal .= ' ' . $_tagName . '="' . $_tagValue . '"'; 
    77                         } 
    78                     } else { 
    79                     throw new Exception("InterfaceElements::_generateClosingElement() - \$tags is not an array."); 
    80                     } 
    81  
    82                     $_retVal .= ">$content</$name>"; 
    83                 } else { 
    84                     throw new Exception("InterfaceElements::_generateClosingElement() - \$name is missing."); 
    85                 } 
    86  
    87                 return $_retVal; 
    88         } 
     65    private static function _generateClosingElement($name, $content = "", $tags = array()) 
     66    { 
     67        // Init values 
     68        $_retVal = ""; 
     69 
     70        if ($name) { 
     71            $_retVal .= "<" . $name; 
     72 
     73            // Add tags 
     74            if (is_array($tags)) { 
     75                foreach ($tags as $_tagName => $_tagValue) { 
     76                    $_retVal .= ' ' . $_tagName . '="' . $_tagValue . '"'; 
     77                } 
     78            } else { 
     79                throw new Exception("InterfaceElements::_generateClosingElement() - \$tags is not an array."); 
     80            } 
     81 
     82            $_retVal .= ">$content</$name>"; 
     83        } else { 
     84            throw new Exception("InterfaceElements::_generateClosingElement() - \$name is missing."); 
     85        } 
     86 
     87        return $_retVal; 
     88    } 
    8989 
    9090    /** 
     
    101101 
    102102     */ 
    103         private static function _generateNonClosingElement($name, $tags) 
    104         { 
    105             // Init values 
    106                 $_retVal = ""; 
    107  
    108                 if ($name && $tags) { 
    109                     $_retVal .= "<" . $name; 
    110  
    111                     // Add tags 
    112                     if (is_array($tags)) { 
    113                         foreach ($tags as $_tagName => $_tagValue) { 
    114                             $_retVal .= ' ' . $_tagName . '="' . $_tagValue . '"'; 
    115                         } 
    116                     } else { 
    117                     throw new Exception("InterfaceElements::_generateNonClosingElement() - \$tags is not an array."); 
    118                     } 
    119  
    120                     $_retVal .= " />"; 
    121                 } else { 
    122                     throw new Exception("InterfaceElements::_generateNonClosingElement() - \$name and/or \$tags is missing."); 
    123                 } 
    124  
    125                 return $_retVal; 
    126         } 
     103    private static function _generateNonClosingElement($name, $tags) 
     104    { 
     105        // Init values 
     106        $_retVal = ""; 
     107 
     108        if ($name && $tags) { 
     109            $_retVal .= "<" . $name; 
     110 
     111            // Add tags 
     112            if (is_array($tags)) { 
     113                foreach ($tags as $_tagName => $_tagValue) { 
     114                    $_retVal .= ' ' . $_tagName . '="' . $_tagValue . '"'; 
     115                } 
     116            } else { 
     117                throw new Exception("InterfaceElements::_generateNonClosingElement() - \$tags is not an array."); 
     118            } 
     119 
     120            $_retVal .= " />"; 
     121        } else { 
     122            throw new Exception("InterfaceElements::_generateNonClosingElement() - \$name and/or \$tags is missing."); 
     123        } 
     124 
     125        return $_retVal; 
     126    } 
    127127 
    128128    /** 
     
    142142 
    143143     */ 
    144         private static function _generateInputTag($type, $name, $value = "", $id = "", $class = "submit", $additional_tags = array()) 
    145         { 
    146             // Init values 
    147                 $_retVal = ""; 
    148  
    149                 if ($type && $name) { 
    150                     $_tags = array( 
     144    private static function _generateInputTag($type, $name, $value = "", $id = "", $class = "submit", $additional_tags = array()) 
     145    { 
     146        // Init values 
     147        $_retVal = ""; 
     148 
     149        if ($type && $name) { 
     150            $_tags = array( 
    151151                "type" => $type, 
    152152                "name" => $name 
    153                         ); 
    154  
    155                 // Check for existing value tag 
    156                 if ($value != "") { 
    157                     $_tags = array_merge($_tags, array("value" => $value)); 
    158                 } 
    159  
    160                 // Check for existing id tag 
    161                 if ($id != "") { 
    162                     $_tags = array_merge($_tags, array("id" => $id)); 
    163                 } 
    164  
    165                 // Check for existing class tag 
    166                 if ($class != "") { 
    167                     $_tags = array_merge($_tags, array("class" => $class)); 
    168                 } 
    169  
    170                 // Check for additional tags to be used 
    171                 if (count($additional_tags) > 0) { 
    172                     $_tags = array_merge($_tags, $additional_tags); 
    173                 } 
    174  
    175                     $_retVal = self::_generateNonClosingElement("input", $_tags); 
    176                 } else { 
    177                     throw new Exception("InterfaceElements::_generateInputTag() - \$type and/or \$name is missing."); 
    178                 } 
    179  
    180                 return $_retVal; 
    181         } 
    182  
    183     /** 
    184      * Generates a HTML div element 
     153                ); 
     154 
     155                // Check for existing value tag 
     156                if ($value != "") { 
     157                    $_tags = array_merge($_tags, array("value" => $value)); 
     158                } 
     159 
     160                // Check for existing id tag 
     161                if ($id != "") { 
     162                    $_tags = array_merge($_tags, array("id" => $id)); 
     163                } 
     164 
     165                // Check for existing class tag 
     166                if ($class != "") { 
     167                    $_tags = array_merge($_tags, array("class" => $class)); 
     168                } 
     169 
     170                // Check for additional tags to be used 
     171                if (count($additional_tags) > 0) { 
     172                    $_tags = array_merge($_tags, $additional_tags); 
     173                } 
     174 
     175                $_retVal = self::_generateNonClosingElement("input", $_tags); 
     176        } else { 
     177            throw new Exception("InterfaceElements::_generateInputTag() - \$type and/or \$name is missing."); 
     178        } 
     179 
     180        return $_retVal; 
     181    } 
     182 
     183    /** 
     184     * DEPRECATED!  Generates a HTML div element 
    185185     * 
    186186     * @param string $content Content of HTML div element 
     
    191191 
    192192     */ 
    193         public static function generateDiv($content = "", $class = "", $id = "") 
    194         { 
    195             // Init values 
    196                 $_retVal = ""; 
    197                 $_tags = array(); 
     193    private static function generateDiv($content = "", $class = "", $id = "") 
     194    { 
     195        // Init values 
     196        $_retVal = ""; 
     197        $_tags = array(); 
    198198 
    199199        // Check for present class tag 
     
    207207        } 
    208208 
    209             $_retVal = self::_generateClosingElement("div", $content, $_tags); 
    210  
    211                 return $_retVal; 
    212         } 
    213  
    214     /** 
     209        $_retVal = self::_generateClosingElement("div", $content, $_tags); 
     210 
     211        return $_retVal; 
     212    } 
     213 
     214    /** DEPRECATED benoitg 2007-01-16 
    215215     * Generates a HTML input (type = button) element 
    216216     * 
     
    226226 
    227227     */ 
    228         public static function generateInputButton($name, $value, $id = "", $class = "submit", $additional_tags = array()) 
    229         { 
    230             // Init values 
    231                 $_retVal = ""; 
    232  
    233                 if ($name && $value) { 
    234                     $_retVal = self::_generateInputTag("button", $name, $value, $id, $class, $additional_tags); 
    235                 } else { 
    236                     throw new Exception("InterfaceElements::generateInputSubmit() - \$name and/or \$value is missing."); 
    237                 } 
    238  
    239                 return $_retVal; 
    240         } 
    241  
    242     /** 
     228    public static function generateInputButton($name, $value, $id = "", $class = "submit", $additional_tags = array()) 
     229    { 
     230        // Init values 
     231        $_retVal = ""; 
     232 
     233        if ($name && $value) { 
     234            $_retVal = self::_generateInputTag("button", $name, $value, $id, $class, $additional_tags); 
     235        } else { 
     236            throw new Exception("InterfaceElements::generateInputSubmit() - \$name and/or \$value is missing."); 
     237        } 
     238 
     239        return $_retVal; 
     240    } 
     241 
     242    /** DEPRECATED benoitg 2007-01-16 
    243243     * Generates a HTML input (type = checkbox) element 
    244244     * 
     
    258258 
    259259     */ 
    260         public static function generateInputCheckbox($name, $value = "", $description = "", $checked = false, $id = "", $in_div = true, $class = "checkbox", $additional_tags = array(), $additional_tags_label = array()) 
    261         { 
    262             // Init values 
    263                 $_retVal = ""; 
    264  
    265                 if ($name) { 
    266                 // Check if HTML element shall be checked 
    267                 if ($checked === true) { 
    268                     $additional_tags = array_merge($additional_tags, array("checked" => "checked")); 
    269                 } 
    270  
    271                     $_retVal = self::_generateInputTag("checkbox", $name, $value, $id, $class, $additional_tags); 
    272  
    273                     // Generate label if $description and $id has been defined 
    274                     if ($description && $id) { 
     260    public static function generateInputCheckbox($name, $value = "", $description = "", $checked = false, $id = "", $in_div = true, $class = "checkbox", $additional_tags = array(), $additional_tags_label = array()) 
     261    { 
     262        // Init values 
     263        $_retVal = ""; 
     264 
     265        if ($name) { 
     266            // Check if HTML element shall be checked 
     267            if ($checked === true) { 
     268                $additional_tags = array_merge($additional_tags, array("checked" => "checked")); 
     269            } 
     270 
     271            $_retVal = self::_generateInputTag("checkbox", $name, $value, $id, $class, $additional_tags); 
     272 
     273            // Generate label if $description and $id has been defined 
     274            if ($description && $id) { 
    275275                $_retVal .= self::generateLabel($description, $id, $additional_tags_label); 
    276                     } 
    277  
    278                     // Check if HTML markup should be put into a div element 
    279                     if ($in_div === true) { 
    280                         $_retVal = self::generateDiv($_retVal); 
    281                     } 
    282                 } else { 
    283                     throw new Exception("InterfaceElements::generateInputRadio() - \$name is missing."); 
    284                 } 
    285  
    286                 return $_retVal; 
    287         } 
    288  
    289     /** 
     276            } 
     277 
     278            // Check if HTML markup should be put into a div element 
     279            if ($in_div === true) { 
     280                $_retVal = self::generateDiv($_retVal); 
     281            } 
     282        } else { 
     283            throw new Exception("InterfaceElements::generateInputCheckbox() - \$name is missing."); 
     284        } 
     285 
     286        return $_retVal; 
     287    } 
     288 
     289    /** DEPRECATED benoitg 2007-01-16 
    290290     * Generates a HTML input (type = hidden) element 
    291291     * 
     
    299299 
    300300     */ 
    301         public static function generateInputHidden($name, $value = "", $additional_tags = array()) 
    302         { 
    303             // Init values 
    304                 $_retVal = ""; 
    305  
    306                 if ($name) { 
    307                     $_retVal = self::_generateInputTag("hidden", $name, $value, "", "", $additional_tags); 
    308                 } else { 
    309                     throw new Exception("InterfaceElements::generateInputHidden() - \$name is missing."); 
    310                 } 
    311  
    312                 return $_retVal; 
    313         } 
    314  
    315     /** 
    316      * Generates a HTML input (type = radio) element 
    317      * 
    318      * @param string $name                  Name of HTML input element 
    319      * @param string $value                 Value of HTML input element 
    320      * @param string $description           Description of HTML input element 
    321      * @param bool   $checked               Shall the HTML element be checked? 
    322      * @param string $id                    ID of HTML input element 
    323      * @param string $class                 Class of HTML input element 
    324      * @param array  $additional_tags       Additional tags of HTML input element 
    325      * @param array  $additional_tags_label Additional tags of HTML input element 
    326      * 
    327      * @return string HTML markup 
    328      * 
    329      * @throws Exception if $name or $value is missing 
    330  
    331      */ 
    332         public static function generateInputRadio($name, $value = "", $description = "", $checked = false, $id = "", $class = "radio", $additional_tags = array(), $additional_tags_label = array()) 
    333         { 
    334             // Init values 
    335                 $_retVal = ""; 
    336  
    337                 if ($name) { 
    338                 // Check if HTML element shall be checked 
    339                 if ($checked === true) { 
    340                     $additional_tags = array_merge($additional_tags, array("checked" => "checked")); 
    341                 } 
    342  
    343                     $_retVal = self::_generateInputTag("radio", $name, $value, $id, $class, $additional_tags); 
    344  
    345                     // Generate label if $description and $id has been defined 
    346                     if ($description && $id) { 
    347                 $_retVal .= self::generateLabel($description, $id, $additional_tags_label); 
    348                     } 
    349                 } else { 
    350                     throw new Exception("InterfaceElements::generateInputRadio() - \$name is missing."); 
    351                 } 
    352  
    353                 return $_retVal; 
    354         } 
    355  
    356     /** 
     301    public static function generateInputHidden($name, $value = "", $additional_tags = array()) 
     302    { 
     303        // Init values 
     304        $_retVal = ""; 
     305 
     306        if ($name) { 
     307            $_retVal = self::_generateInputTag("hidden", $name, $value, "", "", $additional_tags); 
     308        } else { 
     309            throw new Exception("InterfaceElements::generateInputHidden() - \$name is missing."); 
     310        } 
     311 
     312        return $_retVal; 
     313    } 
     314 
     315    /** DEPRECATED benoitg 2007-01-16 
    357316     * Generates a HTML input (type = submit) element 
    358317     * 
     
    368327 
    369328     */ 
    370         public static function generateInputSubmit($name, $value, $id = "", $class = "submit", $additional_tags = array()) 
    371         { 
    372             // Init values 
    373                 $_retVal = ""; 
    374  
    375                 if ($name && $value) { 
    376                     $_retVal = self::_generateInputTag("submit", $name, $value, $id, $class, $additional_tags); 
    377                 } else { 
    378                     throw new Exception("InterfaceElements::generateInputSubmit() - \$name and/or \$value is missing."); 
    379                 } 
    380  
    381                 return $_retVal; 
    382         } 
    383  
    384     /** 
     329    public static function generateInputSubmit($name, $value, $id = "", $class = "submit", $additional_tags = array()) 
     330    { 
     331        // Init values 
     332        $_retVal = ""; 
     333 
     334        if ($name && $value) { 
     335            $_retVal = self::_generateInputTag("submit", $name, $value, $id, $class, $additional_tags); 
     336        } else { 
     337            throw new Exception("InterfaceElements::generateInputSubmit() - \$name and/or \$value is missing."); 
     338        } 
     339 
     340        return $_retVal; 
     341    } 
     342 
     343    /** DEPRECATED benoitg 2007-01-16 
    385344     * Generates a HTML input (type = text) element 
    386345     * 
     
    396355 
    397356     */ 
    398         public static function generateInputText($name, $value = "", $id = "", $class = "input_text", $additional_tags = array()) 
    399         { 
    400             // Init values 
    401                 $_retVal = ""; 
    402  
    403                 if ($name) { 
    404                     $_retVal = self::_generateInputTag("text", $name, $value, $id, $class, $additional_tags); 
    405                 } else { 
    406                     throw new Exception("InterfaceElements::generateInputText() - \$name is missing."); 
    407                 } 
    408  
    409                 return $_retVal; 
    410         } 
     357    public static function generateInputText($name, $value = "", $id = "", $class = "input_text", $additional_tags = array()) 
     358    { 
     359        // Init values 
     360        $_retVal = ""; 
     361 
     362        if ($name) { 
     363            $_retVal = self::_generateInputTag("text", $name, $value, $id, $class, $additional_tags); 
     364        } else { 
     365            throw new Exception("InterfaceElements::generateInputText() - \$name is missing."); 
     366        } 
     367 
     368        return $_retVal; 
     369    } 
    411370 
    412371    /** 
     
    423382 
    424383     */ 
    425         public static function generateLabel($content, $for, $additional_tags = array()) 
    426         { 
    427             // Init values 
    428                 $_retVal = ""; 
    429  
    430                 if ($content && $for) { 
    431                     $_tags = array("for" => $for); 
    432  
    433                 // Check for additional tags to be used 
    434                 if (count($additional_tags) > 0) { 
    435                     $_tags = array_merge($_tags, $additional_tags); 
    436                 } 
    437  
    438                     $_retVal = self::_generateClosingElement("label", $content, $_tags); 
    439                 } else { 
    440                     throw new Exception("InterfaceElements::generateLabel() - \$for is missing."); 
    441                 } 
    442  
    443                 return $_retVal; 
    444         } 
    445  
    446     /** 
    447      * Generates a HTML li list element 
    448      * 
    449      * @param string $contents Value of HTML li element 
    450      * @param string $id       ID of HTML li element 
    451      * @param string $class    Class of HTML li element 
    452      * 
    453      * @return string HTML markup 
    454      * 
    455      * @throws Exception if $contents is missing 
    456  
    457      */ 
    458         public static function generateLi($contents, $id = "", $class = "") 
    459         { 
    460             // Init values 
    461                 $_retVal = ""; 
    462                 $_tags = array(); 
    463  
    464                 if ($contents) { 
    465                 // Check for present id tag 
    466                 if ($id != "") { 
    467                     $_tags = array_merge($_tags, array("id" => $id)); 
    468                 } 
    469  
    470                 // Check for present class tag 
    471                 if ($class != "") { 
    472                     $_tags = array_merge($_tags, array("class" => $class)); 
    473                 } 
    474  
    475                     $_retVal = self::_generateClosingElement("li", $contents, $_tags); 
    476                 } else { 
    477                     throw new Exception("InterfaceElements::generateLi() - \$contents is missing."); 
    478                 } 
    479  
    480                 return $_retVal; 
    481         } 
    482  
    483     /** 
    484      * Generates a HTML textarea element 
    485      * 
    486      * @param string $name            Name of HTML textarea element 
    487      * @param string $value           Value of HTML textarea element 
    488      * @param int    $cols            Number of columns of HTML textarea element 
    489      * @param int    $rows            Number of rows of HTML textarea element 
    490      * @param string $id              ID of HTML textarea element 
    491      * @param string $class           Class of HTML textarea element 
    492      * 
    493      * @return string HTML markup 
    494      * 
    495      * @throws Exception if $name or $value is missing 
    496  
    497      */ 
    498         public static function generateTextarea($name, $value = "", $cols = 50, $rows = 5, $id = "", $class = "textarea") 
    499         { 
    500             // Init values 
    501                 $_retVal = ""; 
    502                 $_tags = array(); 
    503  
    504                 if ($name) { 
    505             $_tags = array( 
    506                 "name" => $name, 
    507                 "cols" => $cols, 
    508                 "rows" => $rows 
    509                 ); 
    510  
    511                 // Check for present id tag 
    512                 if ($id != "") { 
    513                     $_tags = array_merge($_tags, array("id" => $id)); 
    514                 } 
    515  
    516                 // Check for present class tag 
    517                 if ($class != "") { 
    518                     $_tags = array_merge($_tags, array("class" => $class)); 
    519                 } 
    520  
    521                     $_retVal = self::_generateClosingElement("textarea", $value, $_tags); 
    522                 } else { 
    523                     throw new Exception("InterfaceElements::generateTextarea() - \$name is missing."); 
    524                 } 
    525  
    526                 return $_retVal; 
    527         } 
    528  
    529     /** 
    530      * Generates a HTML ul list element 
    531      * 
    532      * @param string $values Values (li) of HTML ul element 
    533      * @param string $id     ID of HTML ul element 
    534      * @param string $class  Class of HTML ul element 
    535      * 
    536      * @return string HTML markup 
    537      * 
    538      * @throws Exception if $values is missing 
    539  
    540      */ 
    541         public static function generateUl($values, $id = "", $class = "") 
    542         { 
    543             // Init values 
    544                 $_retVal = ""; 
    545                 $_tags = array(); 
    546  
    547                 if ($values) { 
    548                 // Check for present id tag 
    549                 if ($id != "") { 
    550                     $_tags = array_merge($_tags, array("id" => $id)); 
    551                 } 
    552  
    553                 // Check for present class tag 
    554                 if ($class != "") { 
    555                     $_tags = array_merge($_tags, array("class" => $class)); 
    556                 } 
    557  
    558                     $_retVal = self::_generateClosingElement("ul", $values, $_tags); 
    559                 } else { 
    560                     throw new Exception("InterfaceElements::generateUl() - \$values is missing."); 
    561                 } 
    562  
    563                 return $_retVal; 
    564         } 
     384    private static function generateLabel($content, $for, $additional_tags = array()) 
     385    { 
     386        // Init values 
     387        $_retVal = ""; 
     388 
     389        if ($content && $for) { 
     390            $_tags = array("for" => $for); 
     391 
     392            // Check for additional tags to be used 
     393            if (count($additional_tags) > 0) { 
     394                $_tags = array_merge($_tags, $additional_tags); 
     395            } 
     396 
     397            $_retVal = self::_generateClosingElement("label", $content, $_tags); 
     398        } else { 
     399            throw new Exception("InterfaceElements::generateLabel() - \$for is missing."); 
     400        } 
     401 
     402        return $_retVal; 
     403    } 
    565404 
    566405    /** 
     
    575414 
    576415     */ 
    577         public static function generateAdminSection($title = "", $data = "", $tools = "", $main_id = "") 
    578         { 
    579             // Init values 
    580                 $_retVal = ""; 
    581                 $_title = ""; 
    582                 $_data = ""; 
    583                 $_tools = ""; 
    584  
    585                 // Process title of admin section container 
    586                 if ($title != "") { 
    587                     $_title = self::generateDiv($title . ":", "admin_element_label", ($main_id ? $main_id . "_title" : "")); 
    588                 } 
    589  
    590                 // Process data of admin section container 
    591                 if ($data != "") { 
    592                     $_data = self::generateDiv($data, "admin_element_data", ($main_id ? $main_id . "_data" : "")); 
    593                 } 
    594  
    595                 // Process tools of admin section container 
    596                 if ($tools != "") { 
    597                     $_tools = self::generateDiv($tools, "admin_element_tools", ($main_id ? $main_id . "_tools" : "")); 
    598                 } 
    599  
    600                 // Generate final HTML markup 
    601                 $_retVal = $_title . $_data . $_tools; 
    602  
    603                 return $_retVal; 
    604         } 
    605  
    606     /** 
     416    public static function generateAdminSection($title = "", $data = "", $tools = "", $main_id = "") 
     417    { 
     418        // Init values 
     419        $_retVal = ""; 
     420        $_title = ""; 
     421        $_data = ""; 
     422        $_tools = ""; 
     423 
     424        // Process title of admin section container 
     425        if ($title != "") { 
     426            $_title = self::generateDiv($title . ":", "admin_element_label", ($main_id ? $main_id . "_title" : "")); 
     427        } 
     428 
     429        // Process data of admin section container 
     430        if ($data != "") { 
     431            $_data = self::generateDiv($data, "admin_element_data", ($main_id ? $main_id . "_data" : "")); 
     432        } 
     433 
     434        // Process tools of admin section container 
     435        if ($tools != "") { 
     436            $_tools = self::generateDiv($tools, "admin_element_tools", ($main_id ? $main_id . "_tools" : "")); 
     437        } 
     438 
     439        // Generate final HTML markup 
     440        $_retVal = $_title . $_data . $_tools; 
     441 
     442        return $_retVal; 
     443    } 
     444 
     445    /**  DEPRECATED benoitg 2007-01-16 
    607446     * Generates an HTML "admin_element_item_container" element 
    608447     * 
     
    615454 
    616455     */ 
    617         public static function generateAdminSectionContainer($id = "", $title = "", $data = "", $tools = "") 
    618         { 
    619  
    620          // Process title of admin section container 
     456    public static function generateAdminSectionContainer($id = "", $title = "", $data = "", $tools = "") 
     457    { 
     458 
     459        // Process title of admin section container 
    621460        if ($title != "") 
    622             $title = "<legend>$title</legend>"; 
     461        $title = "<legend>$title</legend>"; 
    623462 
    624463        $_retVal = "<fieldset>$title\n"; 
     
    626465        $_retVal .= "</fieldset>\n"; 
    627466        return $_retVal; 
    628         } 
    629  
     467    } 
     468 
     469    /** 
     470     * Generates the divs for an HTML "admin_element_item_container" element 
     471     * 
     472     * @param string $title   Title of HTML element 
     473     * @param string $help    Help text for the item 
     474     * @param string $data    Data  of HTML element 
     475     * @param string $tools   The interactive portion of the form (buttons, etc.) if applicable 
     476     * @param string $main_id Id of parent HTML element 
     477     * 
     478     * @return string HTML markup 
     479 
     480     */ 
     481    public static function genSectionItem($data = "", $title = "", $help="", $tools = "") 
     482    { 
     483        // Init values 
     484        $_retVal = ""; 
     485        $_title = ""; 
     486        $_data = ""; 
     487        $_tools = ""; 
     488 
     489        // Process title of admin section container 
     490        if ($title != "") { 
     491            $_title = self::generateDiv($title . ":", "admin_element_label"); 
     492        } 
     493 
     494        // Process data of admin section container 
     495        if ($data != "") { 
     496            $_data = self::generateDiv($data, "admin_element_data"); 
     497        } 
     498 
     499        // Process tools of admin section container 
     500        if ($tools != "") { 
     501            $_tools = self::generateDiv($tools, "admin_element_tools"); 
     502        } 
     503 
     504        // Generate final HTML markup 
     505        $_retVal = $_title . " " . $_data . $_tools; 
     506 
     507        return $_retVal; 
     508    } 
     509     
     510    /** Generates an HTML "admin_section" element 
     511     * 
     512     * @param string $$content_array  array of HTML content to bu part of the set 
     513     * @param string $title    Title of the section 
     514     * @param string $help Help text for the section 
     515     * @param string $collapseable     Can the section be collapsed 
     516     * @param string $defaultCollapsed    Is the section collapsed by default 
     517     * @param string $additionalCSSClass  Additional CSS class for the fieldset 
     518     * @return string HTML markup 
     519 
     520     */ 
     521    public static function genSection($content_array, $title = "", $help="", $collapseable = false, $defaultCollapsed = false, $additionalCSSClass=null) 
     522    { 
     523        $retval = ''; 
     524        // Process title of admin section container 
     525        if ($title != "") 
     526        $title = "<legend>$title</legend>"; 
     527        $retval .= "<fieldset class='admin_element_group $additionalCSSClass'>$title"; 
     528        if($help) { 
     529            $retval .= "<div>$help</div>\n"; 
     530        } 
     531        if(is_array($content_array)) { 
     532            $retval .= "<ul class='admin_element_list'>"; 
     533            foreach ($content_array as $content_item) { 
     534                $retval .=  "<li class='admin_element_item_container'>\n".$content_item."\n</li>\n"; 
     535            } 
     536            $retval .= "</ul>"; 
     537        } else { 
     538            throw new Exception("InterfaceElements::generateLabel() - \$for is missing."); 
     539        } 
     540        $retval .= "</fieldset>\n"; 
     541        return $retval; 
     542    } 
    630543} 
    631544 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1165 r1169  
    903903                 */ 
    904904                if ($this->_warningMessage != "") { 
    905                     $html .= InterfaceElements::generateDiv($this->_warningMessage, "errormsg", "node_error"); 
     905                    $html .= "<div class='errormsg'>".$this->_warningMessage."</div>\n"; 
    906906                } 
    907907 
     
    958958                // Description 
    959959                $_title = _("Description"); 
    960                 $_data = InterfaceElements::generateTextarea("node_" . $node_id . "_description", $this->getDescription(), 50, 5, "node_description_textarea"); 
     960                $name = "node_" . $node_id . "_description"; 
     961                $_data = "<textarea name='$name' cols=80 rows=5 id='node_description_textarea'>\n".$this->getDescription()."\n</textarea>\n"; 
    961962                $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_description", $_title, $_data); 
    962963 
     
    10341035                    $_data  = InterfaceElements::generateInputSubmit("geocode_only", _("Geocode the address or postal code above"), "geocode_only_submit"); 
    10351036                    $_data .= InterfaceElements::generateInputButton("google_maps_geocode", _("Check using Google Maps"), "google_maps_geocode_button", "submit", array("onclick" => "window.open('hotspot_location_map.php?node_id={$this->getId()}', 'hotspot_location', 'toolbar = 0, scrollbars = 1, resizable = 1, location = 0, statusbar = 0, menubar = 0, width = 600, height = 600');")); 
    1036                     $_data .= InterfaceElements::generateDiv("(" . _("Use a geocoding service, then use Google Maps to pinpoint the exact location.") . ")", "admin_section_hint", "node_gis_geocode_hint"); 
     1037                    $_data .= "<div class='admin_section_hint' id='node_gis_geocode_hint'>". "(" . _("Use a geocoding service, then use Google Maps to pinpoint the exact location.") . ")" ."</div>\n"; 
    10371038                } else { 
    10381039                    $_data  = InterfaceElements::generateInputSubmit("geocode_only", _("Geocode the address or postal code above"), "geocode_only_submit"); 
    1039                     $_data .= InterfaceElements::generateDiv("(" . _("Use a geocoding service") . ")", "admin_section_hint", "node_gis_geocode_hint"); 
     1040                    $_data .= "<div class='admin_section_hint' id='node_gis_geocode_hint'>". "(" . _("Use a geocoding service") . ")" ."</div>\n"; 
    10401041                } 
    10411042 
     
    10891090                foreach ($this->getOwners() as $owner) { 
    10901091                    $_listDataContents = InterfaceElements::generateAdminSection("", $owner->getUsername(), InterfaceElements::generateInputSubmit("node_" . $this->getId() . "_owner_" . $owner->GetId() . "_remove", _("Remove owner"))); 
    1091                     $_listData .= InterfaceElements::generateLi($_listDataContents, "", "admin_element_item_container node_owner_list"); 
     1092                    $_listData .= "<li class='admin_element_item_container node_owner_list'>".$_listDataContents."</li>\n"; 
    10921093                } 
    10931094 
    1094             $_listData .= InterfaceElements::generateLi(User::getSelectUserUI("node_" . $this->getId() . "_new_owner", "node_" . $this->getId() . "_new_owner_submit", _("Add owner")) . InterfaceElements::generateDiv("", "clearbr"), "", "admin_element_item_container"); 
     1095            $_listData .= "<li class='admin_element_item_container'>".User::getSelectUserUI("node_" . $this->getId() . "_new_owner", "node_" . $this->getId() . "_new_owner_submit", _("Add owner")) . "<div class='clearbr' /></li>\n"; 
    10951096 
    10961097                $_title = _("Node owners"); 
    1097                 $_data = InterfaceElements::generateUl($_listData, "node_owner_ul", "admin_element_list"); 
     1098                $_data = "<ul id='node_owner_ul' class='admin_element_list'>\n".$_listData."</ul>\n"; 
    10981099            $_html_access_rights[] .= InterfaceElements::generateAdminSectionContainer("node_owner", $_title, $_data); 
    10991100                } 
     
    11041105                foreach ($this->getTechnicalOfficers() as $tech_officer) { 
    11051106                    $_listDataContents = InterfaceElements::generateAdminSection("", $tech_officer->getUsername(), InterfaceElements::generateInputSubmit("node_" . $this->getId() . "_tech_officer_" . $tech_officer->GetId() . "_remove", _("Remove technical officer"))); 
    1106                     $_listData .= InterfaceElements::generateLi($_listDataContents, "", "admin_element_item_container node_tech_officer_list"); 
    1107                 } 
    1108  
    1109             $_listData .= InterfaceElements::generateLi(User::getSelectUserUI("node_" . $this->getId() . "_new_tech_officer", "node_" . $this->getId() . "_new_tech_officer_submit", _("Add technical officer")) . InterfaceElements::generateDiv("", "clearbr"), "", "admin_element_item_container"); 
     1107                    $_listData .= "<li class='admin_element_item_container node_tech_officer_list'>".$_listDataContents."</li>\n"; 
     1108                } 
     1109 
     1110            $_listData .= "<li class='admin_element_item_container'>".User::getSelectUserUI("node_" . $this->getId() . "_new_tech_officer", "node_" . $this->getId() . "_new_tech_officer_submit", _("Add technical officer")) . "<div class='clearbr' /></li>\n"; 
    11101111 
    11111112                $_title = _("Technical officers"); 
    1112                 $_data = InterfaceElements::generateUl($_listData, "node_tech_officer_ul", "admin_element_list"); 
     1113                $_data = "<ul id='node_tech_officer_ul' class='admin_element_list'>\n".$_listData."</ul>\n"; 
    11131114            $_html_access_rights[] .= InterfaceElements::generateAdminSectionContainer("node_tech_officer", $_title, $_data); 
    11141115 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/UserReport.php

    r1127 r1169  
    124124                    $html .= "</tr>\n"; 
    125125 
    126                     $html .= "<tr>\n"; 
    127                     $html .= "  <th>"._("Real Name").":</th>\n"; 
    128                     $html .= "  <td>".$userinfo['real_name']."</td>\n"; 
    129                     $html .= "</tr>\n"; 
    130  
    131126                    $html .= "<tr class='odd'>\n"; 
    132127                    $html .= "  <th>"._("Email").":</th>\n"; 
     
    152147                    $html .= "  <th>"._("Account Status").":</th>\n"; 
    153148                    $html .= "  <td>".$userinfo['account_status_description']."</td>\n"; 
    154                     $html .= "</tr>\n"; 
    155  
    156                     $html .= "<tr>\n"; 
    157                     $html .= "  <th>"._("Website").":</th>\n"; 
    158                     $html .= "  <td>".$userinfo['website']."</td>\n"; 
    159149                    $html .= "</tr>\n"; 
    160150 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1157 r1169  
    7070        if(!isset(self::$instanceArray[$id])) 
    7171        { 
    72                 self::$instanceArray[$id] = new self($id); 
     72            self::$instanceArray[$id] = new self($id); 
    7373        } 
    7474        return self::$instanceArray[$id]; 
     
    159159 
    160160        if ($user_info != null) 
    161             $object = self::getObject($user_info['user_id']); 
     161        $object = self::getObject($user_info['user_id']); 
    162162        return $object; 
    163163    } 
     
    177177 
    178178        if ($user_info != null) 
    179             $object = self::getObject($user_info['user_id']); 
     179        $object = self::getObject($user_info['user_id']); 
    180180        return $object; 
    181181    } 
     
    217217 
    218218    /*    public static function purgeUnvalidatedUsers($days_since_creation) 
    219         { 
    220             $db = AbstractDb::getObject(); 
    221             $days_since_creation = $db->escapeString($days_since_creation); 
    222      
    223             //$db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',CURRENT_TIMESTAMP)"); 
    224         }*/ 
     219     { 
     220     $db = AbstractDb::getObject(); 
     221     $days_since_creation = $db->escapeString($days_since_creation); 
     222 
     223     //$db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',CURRENT_TIMESTAMP)"); 
     224     }*/ 
    225225 
    226226    /** @param $object_id The id of the user */ 
     
    252252    function getListUI() { 
    253253        /*    $roles = array (); 
    254          
     254 
    255255        if ($current_node->isOwner($online_user)) { 
    256256        $roles[] = _("owner"); 
    257257        } 
    258          
     258 
    259259        if ($current_node->isTechnicalOfficer($online_user)) { 
    260260        $roles[] = _("technical officer"); 
    261261        } 
    262          
     262 
    263263        if ($roles) { 
    264264        $rolenames = join($roles, ","); 
     
    269269        } 
    270270        else { 
    271                 $html .= $this->getUserName(); 
     271            $html .= $this->getUserName(); 
    272272        } 
    273273        return $html; 
     
    329329        $locale = $this->mRow['prefered_locale']; 
    330330        if (empty ($locale) && !empty ($session)) 
    331             $locale = $session->get(SESS_LANGUAGE_VAR); 
     331        $locale = $session->get(SESS_LANGUAGE_VAR); 
    332332        if (empty ($locale)) 
    333             $locale = DEFAULT_LANG; 
     333        $locale = DEFAULT_LANG; 
    334334        return $locale; 
    335335    } 
     
    374374            $retval = true; 
    375375        } else 
    376             if ($account_status == ACCOUNT_STATUS_VALIDATION) { 
    377                 $sql = "SELECT CASE WHEN ((CURRENT_TIMESTAMP - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired, EXTRACT(EPOCH FROM networks.validation_grace_time) as validation_grace_time FROM users  JOIN networks ON (users.account_origin = networks.network_id) WHERE (user_id='{$this->id}')"; 
    378                 $db->execSqlUniqueRes($sql, $user_info, false); 
    379  
    380                 if ($user_info['validation_grace_time_expired'] == 't') { 
    381                     $errmsg = sprintf(_("Sorry, your %.0f minutes grace period to retrieve your email and validate your account has now expired. You will have to connect to the internet and validate your account from another location. For more help, please %s click here %s."), $user_info['validation_grace_time']/60, '<a href="' . BASE_URL_PATH . 'faq.php' . '">', '</a>'); 
    382                     $retval = false; 
    383                 } else { 
    384                     $errmsg = _("Your account is currently valid."); 
    385                     $retval = true; 
    386                 } 
     376        if ($account_status == ACCOUNT_STATUS_VALIDATION) { 
     377            $sql = "SELECT CASE WHEN ((CURRENT_TIMESTAMP - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired, EXTRACT(EPOCH FROM networks.validation_grace_time) as validation_grace_time FROM users  JOIN networks ON (users.account_origin = networks.network_id) WHERE (user_id='{$this->id}')"; 
     378            $db->execSqlUniqueRes($sql, $user_info, false); 
     379 
     380            if ($user_info['validation_grace_time_expired'] == 't') { 
     381                $errmsg = sprintf(_("Sorry, your %.0f minutes grace period to retrieve your email and validate your account has now expired. You will have to connect to the internet and validate your account from another location. For more help, please %s click here %s."), $user_info['validation_grace_time']/60, '<a href="' . BASE_URL_PATH . 'faq.php' . '">', '</a>'); 
     382                $retval = false; 
    387383            } else { 
    388                 $errmsg = _("Sorry, your account is not valid: ") . $account_status_to_text[$account_status]; 
    389                 $retval = false; 
     384                $errmsg = _("Your account is currently valid."); 
     385                $retval = true; 
    390386            } 
     387        } else { 
     388            $errmsg = _("Sorry, your account is not valid: ") . $account_status_to_text[$account_status]; 
     389            $retval = false; 
     390        } 
    391391        return $retval; 
    392392    } 
     
    412412        $db->execSql("SELECT * FROM node_stakeholders WHERE is_owner = true AND user_id='{$this->getId()}'", $row, false); 
    413413        if ($row != null) 
    414             return true; 
     414        return true; 
    415415        return false; 
    416416 
     
    421421        $db->execSqlUniqueRes("SELECT DISTINCT user_id FROM (SELECT user_id FROM network_stakeholders WHERE user_id='{$this->getId()}' UNION SELECT user_id FROM node_stakeholders WHERE user_id='{$this->getId()}' UNION SELECT user_id FROM administrators WHERE user_id='{$this->getId()}') as tmp", $row, false); 
    422422        if ($row == null) 
    423             return true; 
     423        return true; 
    424424        return false; 
    425425    } 
     
    456456                $retval = $token; 
    457457            } else 
    458                 $retval = false; 
     458            $retval = false; 
    459459        } else { 
    460460            $retval = false; 
     
    467467 
    468468        $new_password_hash = User :: passwordHash($password); 
     469        if (empty($password)) { 
     470            throw new Exception(_("Password cannot be empty.")); 
     471        } 
     472 
    469473        if (!($update = $db->execSqlUpdate("UPDATE users SET pass='$new_password_hash' WHERE user_id='{$this->id}'"))) { 
    470474            throw new Exception(_("Could not change user's password.")); 
     
    568572                'y', 
    569573                'z', 
    570                  
    571             ); 
    572             $id = array ( 
     574 
     575                ); 
     576                $id = array ( 
    573577                'a', 
    574578                'e', 
     
    577581                'u', 
    578582                'y', 
    579                  
    580             ); 
    581             $count1 = count($startnend) - 1; 
    582             $count2 = count($id) - 1; 
    583  
    584             for ($i = 0; $i < 3; $i++) { 
    585                 if ($i != 1) { 
    586                     $rand_pass .= $startnend[rand(0, $count1)]; 
    587                 } else { 
    588                     $rand_pass .= $id[rand(0, $count2)]; 
     583 
     584                ); 
     585                $count1 = count($startnend) - 1; 
     586                $count2 = count($id) - 1; 
     587 
     588                for ($i = 0; $i < 3; $i++) { 
     589                    if ($i != 1) { 
     590                        $rand_pass .= $startnend[rand(0, $count1)]; 
     591                    } else { 
     592                        $rand_pass .= $id[rand(0, $count2)]; 
     593                    } 
    589594                } 
    590             } 
    591595        } 
    592596        return $rand_pass; 
     
    609613     */ 
    610614    public static function getSelectUserUI($user_prefix, $add_button_name = null, $add_button_value = null) { 
    611          
    612         $db = AbstractDb::getObject(); 
    613  
    614         $_networkSelector = InterfaceElements :: generateDiv(Network :: getSelectNetworkUI($user_prefix), "admin_section_network_selector", "admin_section_network_selector_" . $user_prefix); 
     615 
     616        $db = AbstractDb::getObject(); 
     617 
     618        $networkSelector = Network :: getSelectNetworkUI($user_prefix); 
    615619 
    616620        // Check if we need to add an "add" button 
    617621        if ($add_button_name && $add_button_value) { 
    618             $_userSelector = _("Username") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username", "", "", "input_text", array ( 
     622            $userSelector = _("Username") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username", "", "", "input_text", array ( 
    619623                "onkeypress" => "if ((event.which ? event.which : event.keyCode) == 13) {form.$add_button_name.click() }" 
    620             )); 
    621             $_userSelector .= InterfaceElements :: generateInputSubmit($add_button_name, $add_button_value); 
     624                )); 
     625                $userSelector .= InterfaceElements :: generateInputSubmit($add_button_name, $add_button_value); 
    622626        } else { 
    623             $_userSelector = _("Username") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username"); 
    624         } 
    625         $_html = InterfaceElements :: generateDiv($_networkSelector . $_userSelector, 'user_select_user_ui_container'); 
    626  
    627         return $_html; 
     627            $userSelector = _("Username") . ": " . InterfaceElements :: generateInputText("select_user_" . $user_prefix . "_username"); 
     628        } 
     629        $html = "<div class='user_select_user_ui_container'>".$networkSelector . $userSelector . "</div>\n"; 
     630        return $html; 
    628631    } 
    629632 
     
    641644                return self :: getUserByUsernameAndOrigin($username, $network); 
    642645            } else 
    643                 return null; 
     646            return null; 
    644647        } catch (Exception $e) { 
    645648            return null; 
     
    650653        $db = AbstractDb::getObject(); 
    651654        $currentUser = self :: getCurrentUser(); 
     655        $userPreferencesItems = array(); 
     656        if($this->getNetwork()->hasAdminAccess($currentUser)) { 
     657            $content = "<a href='".BASE_SSL_PATH."admin/stats.php?Statistics=".$this->getNetwork()->getId()."&distinguish_users_by=user_id&stats_selected_users=".$this->getUsername()."&UserReport=on&user_id=".$this->getId()."&action=generate'>"._("Get user statistics")."</a>\n"; 
     658        $userPreferencesItems[] = InterfaceElements::genSectionItem($content); 
     659        } 
    652660        $html = ''; 
    653         $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n"; 
    654         $html .= "<ul class='admin_element_list'>\n"; 
    655661        if (($this == $currentUser && !$this->isSplashOnlyUser() )|| $this->getNetwork()->hasAdminAccess($currentUser)) { 
    656662            //username 
    657             $html .= "<li class='admin_element_item_container'>\n"; 
    658             $html .= "<div class='admin_element_label'>" . _("Username") . " : </div>\n"; 
    659             $html .= "<div class='admin_element_data'>\n"; 
     663            $title = _("Username"); 
    660664            $name = "user_" . $this->getId() . "_username"; 
    661             $html .= "<input type='text' name='$name' value='" . htmlentities($this->getUsername()) . "' size=30>\n"; 
    662             $html .= _("Be carefull when changing this: it's the username you use to log in!"); 
    663             $html .= "</div>\n"; 
    664             $html .= "</li>\n"; 
    665         } 
    666         /* 
    667                 $html .= "<li class='admin_element_item_container'>\n"; 
    668                 $html .= "<div class='admin_element_label'>"._("Real name")." : </div>\n"; 
    669                 $html .= "<div class='admin_element_data'>\n"; 
    670                 $name = "user_".$this->getId()."_real_name"; 
    671                 $html .= "<input type='text' name='$name' value='".htmlentities($this->getRealName())."' size=30 readonly>\n"; 
    672                 $html .= "</div>\n"; 
    673                 $html .= "</li>\n"; 
     665            $content = "<input type='text' name='$name' value='" . htmlentities($this->getUsername()) . "' size=30>\n"; 
     666            $content .= _("Be carefull when changing this: it's the username you use to log in!"); 
     667            $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title); 
     668 
     669        } 
     670        /* Change password */ 
     671        $changePasswordItems=array(); 
     672        if($this == $currentUser) {//Don't enter the old password if changing password for another user 
     673            $title = _("Your current password"); 
     674            $name = "user_" . $this->getId() . "_oldpassword"; 
     675            $content = "<input type='password' name='$name' size='20'>\n"; 
     676            $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title); 
     677        } 
    674678         
    675                 $html .= "<li class='admin_element_item_container'>\n"; 
    676                 $html .= "<div class='admin_element_label'>"._("Website URL")." : </div>\n"; 
    677                 $html .= "<div class='admin_element_data'>\n"; 
    678                 $name = "user_".$this->getId()."_website"; 
    679                 $html .= "<input type='text' name='$name' value='".htmlentities($this->getWebsiteURL())."' size=30 readonly>\n"; 
    680                 $html .= "</div>\n"; 
    681                 $html .= "</li>\n"; 
    682         */ 
    683         $html .= "</fieldset>\n"; 
    684         return $html; 
     679        $title = _("Your new password"); 
     680        $name = "user_" . $this->getId() . "_newpassword"; 
     681        $content = "<input type='password' name='$name' size='20'>\n"; 
     682        $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title); 
     683 
     684        $title = _("Your new password (again)"); 
     685        $name = "user_" . $this->getId() . "_newpassword_again"; 
     686        $content = "<input type='password' name='$name' size='20'>\n"; 
     687        $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title); 
     688 
     689        $userPreferencesItems[] = InterfaceElements::genSection($changePasswordItems, _("Change my password")); 
     690 
     691 
     692        $finalHtml = InterfaceElements::genSection($userPreferencesItems, _("User preferences"), false, false, get_class($this)); 
     693        return $finalHtml; 
    685694    } 
    686695 
     
    692701            $name = "user_" . $this->getId() . "_username"; 
    693702            $this->setUsername($_REQUEST[$name]); 
    694         } 
     703 
     704            /* Change password form */ 
     705 
     706            $nameOldpassword = "user_" . $this->getId() . "_oldpassword"; 
     707            $nameNewpassword = "user_" . $this->getId() . "_newpassword"; 
     708            $nameNewpasswordAgain = "user_" . $this->getId() . "_newpassword_again"; 
     709 
     710            if ($this == $currentUser && $this->getPasswordHash() != User::passwordHash($_REQUEST[$nameOldpassword])) 
     711            throw new Exception(_("Wrong password.")); 
     712        } 
     713 
     714        if ($_REQUEST[$nameNewpassword] != $_REQUEST[$nameNewpasswordAgain]){ 
     715            throw new Exception(_("Passwords do not match.")); 
     716        } 
     717        $this->setPassword($_REQUEST[$nameNewpassword]); 
    695718    } 
    696719 
     
    724747 
    725748    /**Get an array of all Content linked to this node 
    726     * @return an array of Content or an empty arrray */ 
     749     * @return an array of Content or an empty arrray */ 
    727750    function getAllContent() { 
    728751        $db = AbstractDb::getObject(); 
     
    746769    public static function assignSmartyValues($smarty, $user = null) { 
    747770        if (!$user) 
    748             $user = User :: getCurrentUser(); 
     771        $user = User :: getCurrentUser(); 
    749772        $smarty->assign('userId', $user ? $user->getId() : ''); 
    750773        $smarty->assign('userName', $user ? $user->getListUI() : ''); 
  • trunk/wifidog-auth/wifidog/templates/classes/MainUI_Display.tpl

    r1131 r1169  
    4141 * @author     Max Horvath <max.horvath@maxspot.de> 
    4242 * @copyright  2006 Max Horvath, maxspot GmbH, Benoit Grégoire, Technologies Coeus inc. 
    43  * @version    Subversion $Id: change_password.php 914 2006-01-23 05:25:43Z max-horvath $ 
     43 * @version    Subversion $Id: $ 
    4444 * @link       http://www.wifidog.org/ 
    4545 */ 
  • trunk/wifidog-auth/wifidog/templates/classes/MainUI_ToolContent.tpl

    r1157 r1169  
    4141 * @author     Max Horvath <max.horvath@maxspot.de> 
    4242 * @copyright  2006 Max Horvath, maxspot GmbH 
    43  * @version    Subversion $Id: change_password.php 914 2006-01-23 05:25:43Z max-horvath $ 
     43 * @version    Subversion $Id: $ 
    4444 * @link       http://www.wifidog.org/ 
    4545 */ 
  • trunk/wifidog-auth/wifidog/templates/classes/MainUI_ToolSection.tpl

    r1157 r1169  
    4141 * @author     Max Horvath <max.horvath@maxspot.de> 
    4242 * @copyright  2006 Max Horvath, maxspot GmbH 
    43  * @version    Subversion $Id: change_password.php 914 2006-01-23 05:25:43Z max-horvath $ 
     43 * @version    Subversion $Id: $ 
    4444 * @link       http://www.wifidog.org/ 
    4545 */ 
     
    5555                <legend>{"User administration"|_}:</legend> 
    5656                    <ul> 
    57                         <li><a href="{$base_url_path}admin/user_log.php">{"User logs"|_}</a></li> 
     57                        <li><a href="{$base_url_path}admin/user_log.php">{"User manager"|_}</a></li> 
    5858                        <li><a href="{$base_url_path}admin/online_users.php">{"Online Users"|_}</a></li> 
    5959                        <li><a href="{$base_url_path}admin/stats.php">{"Statistics"|_}</a></li> 
  • trunk/wifidog-auth/wifidog/templates/sites/hotspots_map.tpl

    r1052 r1169  
    4141 * @author     Max Horvath <max.horvath@maxspot.de> 
    4242 * @copyright  2006 Max Horvath, maxspot GmbH 
    43  * @version    Subversion $Id: change_password.php 914 2006-01-23 05:25:43Z max-horvath $ 
     43 * @version    Subversion $Id: $ 
    4444 * @link       http://www.wifidog.org/ 
    4545 */ 
  • trunk/wifidog-auth/wifidog/templates/sites/index.tpl

    r1168 r1169  
    4141 * @author     Max Horvath <max.horvath@maxspot.de> 
    4242 * @copyright  2006 Max Horvath, maxspot GmbH 
    43  * @version    Subversion $Id: change_password.php 914 2006-01-23 05:25:43Z max-horvath $ 
     43 * @version    Subversion $Id: $ 
    4444 * @link       http://www.wifidog.org/ 
    4545 */ 
     
    5454        <ul> 
    5555                        {if $userIsValid} 
    56             <li><a href="{$base_ssl_path}change_password.php">{"Change password"|_}</a></li> 
    5756                        {else} 
    5857            <li><a href="{$base_url_path}faq.php">{"I have trouble connecting and I would like some help"|_}</a></li> 
  • trunk/wifidog-auth/wifidog/templates/sites/login.tpl

    r1156 r1169  
    4141 * @author     Max Horvath <max.horvath@maxspot.de> 
    4242 * @copyright  2006 Max Horvath, maxspot GmbH 
    43  * @version    Subversion $Id: change_password.php 914 2006-01-23 05:25:43Z max-horvath $ 
     43 * @version    Subversion $Id: $ 
    4444 * @link       http://www.wifidog.org/ 
    4545 */ 
  • trunk/wifidog-auth/wifidog/templates/sites/portal.tpl

    r1161 r1169  
    4141 * @author     Max Horvath <max.horvath@maxspot.de> 
    4242 * @copyright  2006 Max Horvath, maxspot GmbH 
    43  * @version    Subversion $Id: change_password.php 914 2006-01-23 05:25:43Z max-horvath $ 
     43 * @version    Subversion $Id: $ 
    4444 * @link       http://www.wifidog.org/ 
    4545 */