Changeset 1127

Show
Ignore:
Timestamp:
11/14/06 15:11:42 (7 years ago)
Author:
benoitg
Message:
  • Make the MainUI, SmartyWifidog? and Session and AbstractDb? classes singletons
  • Implement two pass content display. All Content can now implement a prepareGetUserUI(), allowing them to interact with MainUI and other Content before display. Allow creating content such as stylesheets, feed accumulators, etc.
  • SmartyWifidog?.php Turn on security, begin preparing for standardisation of Smarty variables
  • New Content type: Stylesheet. Allows specific nodes, or even specific content groups to have custom stylesheets.
  • Langstring.php: Make getAdminUI calling conventions coherent with other content types.


Location:
trunk/wifidog-auth
Files:
2 added
88 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1126 r1127  
     12006-11-13 Benoit Grégoire  <bock@step.polymtl.ca> 
     2        * Make the MainUI, SmartyWifidog and Session and AbstractDb classes singletons 
     3        * Implement two pass content display.  All Content can now implement a prepareGetUserUI(), allowing them to interact with MainUI and other Content before display.   
     4          Allow creating content such as stylesheets, feed accumulators, etc.  
     5        * SmartyWifidog.php Turn on security, begin preparing for standardisation of Smarty variables 
     6        * New Content type:  Stylesheet.  Allows specific nodes, or even specific content groups to have custom stylesheets. 
     7        * Langstring.php:  Make getAdminUI calling conventions coherent with other content types. 
     8         
    192006-11-11 Benoit Grégoire  <bock@step.polymtl.ca> 
    210        * Authenticator.php:  Critical: Fix SQL query syntax in acctStart() 
  • trunk/wifidog-auth/wifidog/admin/admin_common.php

    r914 r1127  
    4949require_once('include/common_interface.php'); 
    5050require_once('classes/Security.php'); 
    51  
    5251/* 
    5352 * Local variables: 
  • trunk/wifidog-auth/wifidog/admin/generic_object_admin.php

    r1100 r1127  
    7070 
    7171// Init values 
     72$ui = MainUI::getObject(); 
    7273$html = ""; 
    7374$errmsg = ""; 
     
    184185 
    185186    if (method_exists($object, "getUserUI")) { 
    186         $html .= $object->getUserUI(); 
     187        $ui->addContent('main_area_middle', $object, 1); 
    187188    } 
    188189 
     
    418419 * Render output 
    419420 */ 
    420 $ui = new MainUI(); 
     421 
    421422$ui->setTitle(_("Generic object editor")); 
    422423$ui->setHtmlHeader($_htmlHeader); 
  • trunk/wifidog-auth/wifidog/admin/hotspot_location_map.php

    r1030 r1127  
    5656require_once('classes/Server.php'); 
    5757 
    58 $ui = new MainUI(); 
     58$ui = MainUI::getObject(); 
    5959$ui->setTitle(_("Hotspot location map")); 
    6060 
  • trunk/wifidog-auth/wifidog/admin/import_user_database.php

    r1123 r1127  
    260260        $html .=  "</fieldset>\n"; 
    261261 
    262     $ui=new MainUI(); 
     262    $ui=MainUI::getObject(); 
    263263    $ui->setToolSection('ADMIN'); 
    264264    $ui->addContent('main_area_middle', $html); 
  • trunk/wifidog-auth/wifidog/admin/index.php

    r1030 r1127  
    5454 
    5555// Load MainUI class 
    56 $ui = new MainUI(); 
     56$ui = MainUI::getObject(); 
    5757 
    5858// Get information about curent user 
  • trunk/wifidog-auth/wifidog/admin/online_users.php

    r1030 r1127  
    5252Security::requireAdmin(); 
    5353 
    54 global $db; 
     54$db = AbstractDb::getObject(); 
    5555$online_users = null; 
    5656$db->execSql("SELECT connections.user_id, name, username, account_origin, timestamp_in, incoming, outgoing FROM connections,users,nodes WHERE token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND nodes.node_id=connections.node_id ORDER BY account_origin, timestamp_in DESC", $online_users); 
    5757$smarty->assign("users_array", $online_users); 
    5858 
    59 $ui = new MainUI(); 
     59$ui = MainUI::getObject(); 
    6060$ui->setToolSection('ADMIN'); 
    6161$ui->addContent('main_area_middle', $smarty->fetch("admin/templates/online_users.html")); 
  • trunk/wifidog-auth/wifidog/admin/stats.php

    r1095 r1127  
    124124        $html .= "</p>"; 
    125125} 
    126 $ui = new MainUI(); 
     126$ui = MainUI::getObject(); 
    127127$ui->setToolSection('ADMIN'); 
    128128$ui->addContent('main_area_middle', $html); 
  • trunk/wifidog-auth/wifidog/admin/user_log.php

    r1030 r1127  
    119119    $html .= $smarty->fetch("admin/templates/user_log.html"); 
    120120 
    121     $ui=new MainUI(); 
     121    $ui=MainUI::getObject(); 
    122122    $ui->setToolSection('ADMIN'); 
    123123    $ui->addContent('main_area_middle', $html); 
  • trunk/wifidog-auth/wifidog/change_password.php

    r1031 r1127  
    5454require_once('include/common_interface.php'); 
    5555require_once('classes/User.php'); 
    56  
     56$smarty = SmartyWifidog::getObject(); 
     57$smarty = SmartyWifidog::getObject(); 
    5758$smarty->assign('error', ''); 
    5859 
     
    130131                } 
    131132 
    132         $ui = new MainUI(); 
     133        $ui = MainUI::getObject(); 
    133134        $ui->addContent('main_area_middle', $smarty->fetch("templates/sites/validate.tpl")); 
    134135        $ui->display(); 
     
    152153isset ($_REQUEST["auth_source"]) && $smarty->assign('selected_auth_source', $_REQUEST["auth_source"]); 
    153154 
    154 $ui = new MainUI(); 
     155$ui = MainUI::getObject(); 
    155156$smarty->assign('SelectNetworkUI', Network::getSelectNetworkUI('auth_source')); 
    156157$ui->addContent('main_area_middle', $smarty->fetch("templates/change_password.html")); 
  • trunk/wifidog-auth/wifidog/classes/AbstractDb.php

    r1079 r1127  
    5454class AbstractDb 
    5555{ 
     56    private static $object; 
     57    public static function getObject() { 
     58        if (self::$object==null) 
     59        { 
     60                self::$object=new self(); 
     61        } 
     62        return self::$object; 
     63    } 
     64    /** Constructor */ 
     65    private function __construct()  { 
     66    } 
     67     
    5668    // Connects to PostgreSQL database 
    5769    function connect($db_name) 
  • trunk/wifidog-auth/wifidog/classes/Authenticator.php

    r1126 r1127  
    120120    public function logout($conn_id = null) 
    121121    { 
    122         // Define globals 
    123         global $db; 
    124         global $session; 
     122         
     123        $db = AbstractDb::getObject(); 
     124        $session = Session::getObject(); 
    125125 
    126126        $conn_id = $db->escapeString($conn_id); 
     
    184184    public function acctStart($conn_id) 
    185185    { 
    186         // Define globals 
    187         global $db; 
     186         
     187        $db = AbstractDb::getObject(); 
    188188 
    189189        $conn_id = $db->escapeString($conn_id); 
     
    236236    public function acctUpdate($conn_id, $incoming, $outgoing) 
    237237    { 
    238         // Define globals 
    239         global $db; 
     238         
     239        $db = AbstractDb::getObject(); 
    240240 
    241241        // Write traffic counters to database 
     
    254254    public function acctStop($conn_id) 
    255255    { 
    256         // Define globals 
    257         global $db; 
     256         
     257        $db = AbstractDb::getObject(); 
    258258 
    259259        // Stop traffic counters update 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLDAP.php

    r1090 r1127  
    232232        public function login($username, $password, &$errmsg = null) 
    233233        { 
    234             // Define globals 
    235                 global $db; 
     234             
     235                $db = AbstractDb::getObject(); 
    236236 
    237237                // Init values 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorLocalUser.php

    r1090 r1127  
    107107    public function login($username, $password, &$errmsg = null) 
    108108    { 
    109         // Define globals 
    110         global $db; 
     109         
     110        $db = AbstractDb::getObject(); 
    111111 
    112112        // Init values 
  • trunk/wifidog-auth/wifidog/classes/Authenticators/AuthenticatorRadius.php

    r1123 r1127  
    172172    public function login($username, $password, &$errmsg = null) 
    173173    { 
    174         // Define globals 
    175         global $db; 
     174         
     175        $db = AbstractDb::getObject(); 
    176176 
    177177        // Init values 
     
    308308    public function acctStart($conn_id, &$errmsg = null) 
    309309    { 
    310         // Define globals 
    311         global $db; 
     310         
     311        $db = AbstractDb::getObject(); 
    312312 
    313313        // Init values 
     
    378378        parent::acctUpdate($conn_id, $incoming, $outgoing); 
    379379 
    380         // Define globals 
    381         global $db; 
    382  
    383380        // Init values 
     381        $db = AbstractDb::getObject(); 
    384382        $info = null; 
    385383        $conn_id = $db->escapeString($conn_id); 
     
    448446        parent::acctStop($conn_id); 
    449447 
    450         // Define globals 
    451         global $db; 
     448         
     449        $db = AbstractDb::getObject(); 
    452450 
    453451        // Init values 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r1123 r1127  
    9898     */ 
    9999    private function __construct($content_id) { 
    100         // Define globals 
    101         global $db; 
     100         
     101        $db = AbstractDb::getObject(); 
    102102 
    103103        // Init values 
     
    150150     */ 
    151151    public static function createNewObject($content_type = "Content", $id = null) { 
    152         // Define globals 
    153         global $db; 
     152         
     153        $db = AbstractDb::getObject(); 
    154154 
    155155        if (empty ($id)) { 
     
    241241     */ 
    242242    public static function getObject($content_id) { 
    243         // Define globals 
    244         global $db; 
     243         
     244        $db = AbstractDb::getObject(); 
    245245 
    246246        // Init values 
     
    383383     */ 
    384384    public static function getAllContent($content_type = "") { 
    385         // Define globals 
    386         global $db; 
     385         
     386        $db = AbstractDb::getObject(); 
    387387 
    388388        // Init values 
     
    419419     */ 
    420420    public static function getNewContentUI($user_prefix, $content_type_filter = null, $title = null) { 
    421         // Define globals 
    422         global $db; 
     421         
     422        $db = AbstractDb::getObject(); 
    423423 
    424424        // Init values 
     
    537537     */ 
    538538    public static function getLinkedContentUI($user_prefix, $link_table, $link_table_obj_key_col, $link_table_obj_key, $default_display_page = 'portal', $default_display_area = 'main_area_middle') { 
    539         // Define globals 
    540         global $db; 
     539         
     540        $db = AbstractDb::getObject(); 
    541541 
    542542        // Init values 
     
    616616     */ 
    617617    static function processLinkedContentUI($user_prefix, $link_table, $link_table_obj_key_col, $link_table_obj_key) { 
    618         global $db; 
     618        $db = AbstractDb::getObject(); 
    619619        $link_table = $db->escapeString($link_table); 
    620620        $link_table_obj_key_col = $db->escapeString($link_table_obj_key_col); 
     
    722722     */ 
    723723    public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $content_type_filter = null, $order = "creation_timestamp", $type_interface = "select") { 
    724         // Define globals 
    725         global $db; 
     724         
     725        $db = AbstractDb::getObject(); 
    726726 
    727727        // Init values 
     
    889889     * */ 
    890890    private function setContentType($content_type) { 
    891         global $db; 
     891        $db = AbstractDb::getObject(); 
    892892        $content_type = $db->escapeString($content_type); 
    893893        if (!self :: isContentTypeAvailable($content_type)) { 
     
    907907     * @return true on success, false on failure */ 
    908908    public function addOwner(User $user, $is_author = false) { 
    909         global $db; 
     909        $db = AbstractDb::getObject(); 
    910910        $content_id = "'" . $this->id . "'"; 
    911911        $user_id = "'" . $db->escapeString($user->getId()) . "'"; 
     
    924924     */ 
    925925    public function deleteOwner(User $user, $is_author = false) { 
    926         global $db; 
     926        $db = AbstractDb::getObject(); 
    927927        $content_id = "'" . $this->id . "'"; 
    928928        $user_id = "'" . $db->escapeString($user->getId()) . "'"; 
     
    959959     */ 
    960960    public function getLastDisplayTimestamp($user = null, $node = null) { 
    961         global $db; 
     961        $db = AbstractDb::getObject(); 
    962962        $retval = ''; 
    963963        $sql = "SELECT EXTRACT(EPOCH FROM last_display_timestamp) as last_display_unix_timestamp FROM content_display_log WHERE content_id='{$this->id}' \n"; 
     
    991991     * @return true if the user is a owner, false if he isn't of the user is null */ 
    992992    public function isOwner($user) { 
    993         global $db; 
     993        $db = AbstractDb::getObject(); 
    994994        $retval = false; 
    995995        if ($user != null) { 
     
    10071007     * @return null or array of User objects */ 
    10081008    public function getAuthors() { 
    1009         global $db; 
     1009        $db = AbstractDb::getObject(); 
    10101010        $retval = array (); 
    10111011        $sql = "SELECT user_id FROM content_has_owners WHERE content_id='$this->id' AND is_author=TRUE"; 
     
    10291029        return false; 
    10301030    } 
     1031     
     1032    /** This function will be called by MainUI for each Content BEFORE any getUserUI function is called to allow two pass Content display. 
     1033     * Two pass Content display allows such things as modyfying headers, title, creating content type that accumulate content from other pieces (like RSS feeds) 
     1034     * @return null 
     1035     */     
     1036     public function prepareGetUserUI() { 
     1037        return null; 
     1038    }   
    10311039    /** Retreives the user interface of this object.  Anything that overrides this method should call the parent method with it's output at the END of processing. 
    10321040     * @param $subclass_admin_interface Html content of the interface element of a children 
     
    11201128                $user_id = $user->getId(); 
    11211129                $node_id = $node->getId(); 
    1122                 global $db; 
     1130                $db = AbstractDb::getObject(); 
    11231131 
    11241132                $sql = "SELECT * FROM content_display_log WHERE user_id='$user_id' AND node_id='$node_id' AND content_id='$this->id'"; 
     
    11631171     */ 
    11641172    public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    1165         global $db; 
     1173        $db = AbstractDb::getObject(); 
    11661174 
    11671175        $html = ''; 
     
    13061314                $html .= "<ul class='admin_element_list'>\n"; 
    13071315 
    1308                 global $db; 
     1316                $db = AbstractDb::getObject(); 
    13091317                $sql = "SELECT * FROM content_has_owners WHERE content_id='$this->id'"; 
    13101318                $db->execSql($sql, $content_owner_rows, false); 
     
    13541362    public function processAdminUI() { 
    13551363        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
    1356             global $db; 
     1364            $db = AbstractDb::getObject(); 
    13571365            if ($this->getObjectType() == 'Content') /* The object hasn't yet been typed */ { 
    13581366                $content_type = FormSelectGenerator :: getResult("content_" . $this->id . "_content_type", "Content"); 
     
    14901498     */ 
    14911499    public function isUserSubscribed(User $user) { 
    1492         global $db; 
     1500        $db = AbstractDb::getObject(); 
    14931501        $sql = "SELECT content_id FROM user_has_content WHERE user_id = '{$user->getId()}' AND content_id = '{$this->getId()}';"; 
    14941502        $db->execSqlUniqueRes($sql, $row, false); 
     
    15281536        if ($should_display != $this->titleShouldDisplay()) /* Only update database if there is an actual change */ { 
    15291537            $should_display ? $should_display_sql = 'TRUE' : $should_display_sql = 'FALSE'; 
    1530             global $db; 
     1538            $db = AbstractDb::getObject(); 
    15311539            $db->execSqlUpdate("UPDATE content SET title_is_displayed = $should_display_sql WHERE content_id = '$this->id'", false); 
    15321540            $this->refresh(); 
     
    15531561            $is_persistent ? $is_persistent_sql = 'TRUE' : $is_persistent_sql = 'FALSE'; 
    15541562 
    1555             global $db; 
     1563            $db = AbstractDb::getObject(); 
    15561564            $db->execSqlUpdate("UPDATE content SET is_persistent = $is_persistent_sql WHERE content_id = '$this->id'", false); 
    15571565            $this->refresh(); 
     
    15761584            $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)"); 
    15771585        } else { 
    1578             global $db; 
     1586            $db = AbstractDb::getObject(); 
    15791587            if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
    15801588                $sql = "DELETE FROM content WHERE content_id='$this->id'"; 
  • trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroup.php

    r1094 r1127  
    8585        private $expand_status = false; 
    8686        private $temporary_display_num_elements; 
    87  
     87        private $display_elements; 
    8888        private $content_selection_mode; 
    8989        private $content_group_row; 
     
    9292 
    9393        protected function __construct($content_id) { 
    94                 // Define globals 
    95                 global $db; 
     94                 
     95                $db = AbstractDb::getObject(); 
    9696 
    9797                // Init values 
     
    145145                        $is_artistic_content ? $is_artistic_content_sql = 'TRUE' : $is_artistic_content_sql = 'FALSE'; 
    146146 
    147                         global $db; 
     147                        $db = AbstractDb::getObject(); 
    148148                        $db->execSqlUpdate("UPDATE content_group SET is_artistic_content = $is_artistic_content_sql WHERE content_group_id = '$this->id'", false); 
    149149                        $this->refresh(); 
     
    170170                        $is_locative_content ? $is_locative_content_sql = 'TRUE' : $is_locative_content_sql = 'FALSE'; 
    171171 
    172                         global $db; 
     172                        $db = AbstractDb::getObject(); 
    173173                        $db->execSqlUpdate("UPDATE content_group SET is_locative_content = $is_locative_content_sql WHERE content_group_id = '$this->id'", false); 
    174174                        $this->refresh(); 
     
    190190                $retval = false; 
    191191                if (isset ($this->CONTENT_ORDERING_MODES[$content_ordering_mode]) && $content_ordering_mode != $this->getContentOrderingMode()) /* Only update database if the mode is valid and there is an actual change */ { 
    192                         global $db; 
     192                        $db = AbstractDb::getObject(); 
    193193                        $content_ordering_mode = $db->escapeString($content_ordering_mode); 
    194194                        $db->execSqlUpdate("UPDATE content_group SET content_ordering_mode = '$content_ordering_mode' WHERE content_group_id = '$this->id'", false); 
     
    219219                $retval = false; 
    220220                if (isset ($this->CONTENT_CHANGES_ON_MODES[$content_changes_on_mode]) && $content_changes_on_mode != $this->getContentChangesOnMode()) /* Only update database if the mode is valid and there is an actual change */ { 
    221                         global $db; 
     221                        $db = AbstractDb::getObject(); 
    222222                        $content_changes_on_mode = $db->escapeString($content_changes_on_mode); 
    223223                        $db->execSqlUpdate("UPDATE content_group SET content_changes_on_mode = '$content_changes_on_mode' WHERE content_group_id = '$this->id'", false); 
     
    248248                $retval = false; 
    249249                if (isset ($this->ALLOW_REPEAT_MODES[$allow_repeat]) && $allow_repeat != $this->getAllowRepeat()) /* Only update database if the mode is valid and there is an actual change */ { 
    250                         global $db; 
     250                        $db = AbstractDb::getObject(); 
    251251                        $allow_repeat = $db->escapeString($allow_repeat); 
    252252                        $db->execSqlUpdate("UPDATE content_group SET allow_repeat = '$allow_repeat' WHERE content_group_id = '$this->id'", false); 
     
    280280                $retval = false; 
    281281                if (($display_num_elements > 0) && $display_num_elements != $this->getDisplayNumElements()) /* Only update database if the mode is valid and there is an actual change */ { 
    282                         global $db; 
     282                        $db = AbstractDb::getObject(); 
    283283                        $display_num_elements = $db->escapeString($display_num_elements); 
    284284                        $db->execSqlUpdate("UPDATE content_group SET display_num_elements = '$display_num_elements' WHERE content_group_id = '$this->id'", false); 
     
    491491        * @return an array of ContentGroupElement or an empty arrray */ 
    492492        function getDisplayElements() { 
    493                 // Define globals 
    494                 global $db; 
     493            //This function is very expensive, cache the results 
     494                if(!is_array($this->display_elements)){ 
     495                 
     496                $db = AbstractDb::getObject(); 
    495497 
    496498                // Init values 
     
    642644                $retval = array_merge($new_objects, $redisplay_objects); 
    643645                //echo count($retval).' returned <br>'; 
    644                 return $retval; 
     646                $this->display_elements=$retval; 
     647                } 
     648                return $this->display_elements; 
    645649        } 
    646650 
     
    689693        } 
    690694 
     695    /** This function will be called by MainUI for each Content BEFORE any getUserUI function is called to allow two pass Content display. 
     696     * Two pass Content display allows such things as modyfying headers, title, creating content type that accumulate content from other pieces (like RSS feeds) 
     697     * @return null 
     698     */ 
     699        public function prepareGetUserUI() { 
     700                        $display_elements = $this->getDisplayElements(); 
     701                                foreach ($display_elements as $display_element) { 
     702                                        $display_element->prepareGetUserUI(); 
     703                                } 
     704                return parent :: prepareGetUserUI(); 
     705        } 
     706 
    691707        /** Retreives the user interface of this object.  Anything that overrides this method should call the parent method with it's output at the END of processing. 
    692708         * @param $subclass_admin_interface Html content of the interface element of a children 
     
    722738         * @return an array of ContentGroupElement or an empty arrray */ 
    723739        function getElements($additional_where=null) { 
    724                 // Define globals 
    725                 global $db; 
     740                 
     741                $db = AbstractDb::getObject(); 
    726742 
    727743                // Init values 
  • trunk/wifidog-auth/wifidog/classes/Content/ContentGroup/ContentGroupElement.php

    r1092 r1127  
    6363class ContentGroupElement extends Content { 
    6464 
    65         /** 
    66          
    67          */ 
    68         private $content_group_element_row; 
    69  
    70         /** 
    71          * Constructor 
    72          * 
    73          * @param string $content_id Content Id 
    74          * 
    75          * @return void     */ 
    76         protected function __construct($content_id) { 
    77                 // Define globals 
    78                 global $db; 
    79  
    80                 // Init values 
    81                 $row = null; 
    82  
    83                 parent :: __construct($content_id); 
    84                 $content_id = $db->escapeString($content_id); 
    85  
    86                 $sql_select = "SELECT * FROM content_group_element WHERE content_group_element_id='$content_id'"; 
    87                 $db->execSqlUniqueRes($sql_select, $row, false); 
    88  
    89                 if ($row == null) { 
    90                         // The database was corrupted, let's fix it ... 
    91                         $sql = "DELETE FROM content WHERE content_id='$content_id'"; 
    92                         $db->execSqlUpdate($sql, true); 
    93                 } 
    94  
    95                 $this->content_group_element_row = $row; 
    96  
    97                 /* A content group element is NEVER persistent */ 
    98                 parent :: setIsPersistent(false); 
    99         } 
    100         /** When a content object is set as Simple, it means that is is used merely to contain it's own data.  No title, description or other metadata will be set or displayed, during display or administration 
    101          * @return true or false */ 
    102         public function isSimpleContent() { 
    103                 return true; 
    104         } 
    105         /** 
    106          * Replace and delete the old displayed_content (if any) by the new 
    107          * content (or no content) 
    108          * 
    109          * @param object $new_displayed_content Content object or null. If 
    110          *                                      null the old content is still 
    111          *                                      deleted. 
    112          * 
    113          * @return void 
    114          
    115          */ 
    116         private function replaceDisplayedContent($new_displayed_content) { 
    117                 // Define globals 
    118                 global $db; 
    119  
    120                 // Init values 
    121                 $old_displayed_content = null; 
    122                 $errmsg = null; 
    123  
    124                 if (!empty ($this->content_group_element_row['displayed_content_id'])) { 
    125                         $old_displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
    126                 } 
    127  
    128                 if ($new_displayed_content != null) { 
    129                         $new_displayed_content_id_sql = "'" . $new_displayed_content->GetId() . "'"; 
    130                 } else { 
    131                         $new_displayed_content_id_sql = "NULL"; 
    132                 } 
    133  
    134                 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = $new_displayed_content_id_sql WHERE content_group_element_id = '$this->id'", FALSE); 
    135  
    136                 if ($old_displayed_content != null) { 
    137                         $old_displayed_conten->delete($errmsg); 
    138                 } 
    139         } 
    140  
    141         /** 
    142          * Get the order of the element in the content group 
    143          * 
    144          * @return string the order of the element in the content group 
    145          */ 
    146         public function getDisplayOrder() { 
    147                 return $this->content_group_element_row['display_order']; 
    148         } 
    149  
    150         /** 
    151          * Set the order of the element in the content group 
    152          * 
    153          * @param string $order Order how items should be displayed 
    154          * 
    155          * @return void 
    156          */ 
    157         public function setDisplayOrder($order) { 
    158                 // Define globals 
    159                 global $db; 
    160  
    161                 if ($order != $this->getDisplayOrder()) { 
    162                         /* 
    163                          * Only update database if there is an actual change 
    164                          */ 
    165                         $order = $db->escapeString($order); 
    166                         $db->execSqlUpdate("UPDATE content_group_element SET display_order = $order WHERE content_group_element_id = '$this->id'", false); 
    167                 } 
    168         } 
    169  
    170         /** 
    171          * Like the same method as defined in Content, this method will create a 
    172          * ContentGroupElement based on the content type specified by 
    173          * getNewContentUI OR get an existing element by getSelectExistingContentUI 
    174          * 
    175          * @param string $user_prefix                A identifier provided by the programmer to 
    176          *                                           recognise it's generated form 
    177          * @param string $content_group              Must be present 
    178          * @param bool   $associate_existing_content If set to true, will get an 
    179          *                                           existing element instead of creating a 
    180          *                                           new content. 
    181          * 
    182          * @return object The ContentGroup object, or null if the user didn't greate one 
    183          * @static 
    184          */ 
    185         public static function processNewContentUI($user_prefix, ContentGroup $content_group, $associate_existing_content = false) { 
    186                 // Define globals 
    187                 global $db; 
    188  
    189                 // Init values 
    190                 $content_group_element_object = null; 
    191                 $max_display_order_row = null; 
    192  
    193                 if ($associate_existing_content == true) { 
    194                         $name = "{$user_prefix}_add"; 
    195                 } else { 
    196                         $name = "get_new_content_{$user_prefix}_add"; 
    197                 } 
    198  
    199                 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    200                         /* Get the display order to add the GontentGroupElement at the end */ 
    201                         $sql = "SELECT MAX(display_order) as max_display_order FROM content_group_element WHERE content_group_id='" . $content_group->getId() . "'"; 
    202                         $db->execSqlUniqueRes($sql, $max_display_order_row, false); 
    203                         $display_order = $max_display_order_row['max_display_order'] + 1; 
    204  
    205                         if ($associate_existing_content == true) { 
    206                                 $name = "{$user_prefix}"; 
    207                         } else { 
    208                                 $name = "get_new_content_{$user_prefix}_content_type"; 
    209                         } 
    210  
    211                         $content_id = get_guid(); 
    212                         $content_type = 'ContentGroupElement'; 
    213                         $sql = "INSERT INTO content (content_id, content_type) VALUES ('$content_id', '$content_type');"; 
    214  
    215                         if (!$db->execSqlUpdate($sql, false)) { 
    216                                 throw new Exception(_('Unable to insert new content into database!')); 
    217                         } 
    218  
    219                         $sql = "INSERT INTO content_group_element (content_group_element_id, content_group_id, display_order) VALUES ('$content_id', '" . $content_group->GetId() . "', $display_order);"; 
    220  
    221                         if (!$db->execSqlUpdate($sql, false)) { 
    222                                 throw new Exception(_('Unable to insert new content into database!')); 
    223                         } 
    224  
    225                         $content_group_element_object = self :: getObject($content_id); 
    226  
    227                         $content_ui_result = FormSelectGenerator :: getResult($name, null); 
    228  
    229                         if ($associate_existing_content == true) { 
    230                                 $displayed_content_object = self :: getObject($content_ui_result); 
    231                         } else { 
    232                                 $displayed_content_object = self :: createNewObject($content_ui_result); 
    233                         } 
    234  
    235                         $content_group_element_object->replaceDisplayedContent($displayed_content_object); 
    236                 } 
    237  
    238                 return $content_group_element_object; 
    239         } 
    240         /** If set, content will only be displayed from this date on. */ 
    241         function getValidFromDate() { 
    242                 return $this->content_group_element_row['valid_from_timestamp']; 
    243         } 
    244  
    245         /** If set, content will only be displayed from this date on.  
    246          * @param string @date Start date.  To always display, set to null or an empty string */ 
    247         function setValidFromDate($date) { 
    248                 // Define globals 
    249                 global $db; 
    250                 if ($date != $this->getValidFromDate()) { 
    251                         if (!empty ($date)) { 
    252                                 $date = "'" . $db->escapeString($date) . "'"; 
    253                         } else { 
    254                                 $date = 'NULL'; 
    255                         } 
    256                         $db->execSqlUpdate("UPDATE content_group_element SET valid_from_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 
    257                         $this->refresh(); 
    258                 } 
    259         } 
    260         /** If set, content will only be displayed untill this date (and will then be archived). */ 
    261         function getValidUntilDate() { 
    262                 return $this->content_group_element_row['valid_until_timestamp']; 
    263         } 
    264  
    265         /** If set, content will only be displayed untill this date (and will then be archived).  
    266          * @param string @date End date.  To always display, set to null or an empty string */ 
    267         function setValidUntilDate($date) { 
    268                 // Define globals 
    269                 global $db; 
    270                 if ($date != $this->getValidUntilDate()) { 
    271                         if (!empty ($date)) { 
    272                                 $date = "'" . $db->escapeString($date) . "'"; 
    273                         } else { 
    274                                 $date = 'NULL'; 
    275                         } 
    276                         $db->execSqlUpdate("UPDATE content_group_element SET valid_until_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 
    277                         $this->refresh(); 
    278                 } 
    279         } 
    280  
    281         /** 
    282          * Shows the administration interface for ContentGroupElement 
    283          * 
    284          * @param string $subclass_admin_interface HTML code to be added after the 
    285          *                                         administration interface 
    286          * 
    287          * @return string HTML code for the administration interface 
    288          */ 
    289         public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    290                 // Define globals 
    291                 global $db; 
    292  
    293                 // Init values 
    294                 $html = ''; 
    295                 $html .= "<li class='admin_element_item_container'>\n"; 
    296                 $html .= "<fieldset class='admin_element_group'>\n"; 
    297                 $html .= "<legend>" . sprintf(_("%s %d display conditions"), get_class($this), $this->getDisplayOrder()) . "</legend>\n"; 
    298  
    299                 $allowed_node_rows = null; 
    300                 $html .= "<ul class='admin_element_list'>\n"; 
    301                 /* display_order */ 
    302                 $html .= "<li class='admin_element_item_container'>\n"; 
    303                 $html .= "<div class='admin_element_label'>Display order: </div>\n"; 
    304                 $html .= "<div class='admin_element_data'>\n"; 
    305                 $name = "content_group_element_" . $this->id . "_display_order"; 
    306                 $html .= "<input type='text' name='$name' value='" . $this->getDisplayOrder() . "' size='2'>\n"; 
    307                 $html .= _("(Ignored if display type is random)") . "\n"; 
    308                 $html .= "</div>\n"; 
    309                 $html .= "</li>\n"; 
    310  
    311                 $html .= "<li class='admin_element_item_container'>\n"; 
    312                 // valid_from_timestamp 
    313                 $html .= "<div class='admin_element_label'>" . _("Only display from") . "</div>\n"; 
    314                 $html .= "<div class='admin_element_data'>\n"; 
    315                 $name = "content_group_element_" . $this->id . "_valid_from"; 
    316                 $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidFromDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 
    317                 $html .= "</div>\n"; 
    318  
    319                 // valid_until_timestamp 
    320                 $html .= "<div class='admin_element_label'>until</div>\n"; 
    321                 $html .= "<div class='admin_element_data'>\n"; 
    322                 $name = "content_group_element_" . $this->id . "_valid_until"; 
    323                 $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidUntilDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 
    324                 $html .= "</div>\n"; 
    325  
    326                 $html .= _("(Content can be displayed at any date if no start or end date is specified.  Warning:  If you do not specify a specifig time of day, midnight is assumed.)") . "\n"; 
    327                 $html .= "</li>\n"; 
    328  
    329                 /* content_group_element_has_allowed_nodes */ 
    330                 $html .= "<li class='admin_element_item_container'>\n"; 
    331                 $html .= "<div class='admin_element_label'>" . _("Only display at node(s):") . "</div>\n"; 
    332                 $html .= "<ul class='admin_element_list'>\n"; 
    333  
    334                 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 
    335                 $db->execSql($sql, $allowed_node_rows, false); 
    336  
    337                 if ($allowed_node_rows != null) { 
    338                         foreach ($allowed_node_rows as $allowed_node_row) { 
    339                                 $node = Node :: getObject($allowed_node_row['node_id']); 
    340                                 $html .= "<li class='admin_element_item_container'>\n"; 
    341                                 $html .= "<div class='admin_element_data'>\n"; 
    342                                 $html .= "" . $node->GetId() . ": " . $node->GetName() . ""; 
    343                                 $html .= "</div>\n"; 
    344                                 $html .= "<div class='admin_element_tools'>\n"; 
    345                                 $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 
    346                                 $html .= "<input type='submit' name='$name' value='" . _("Remove") . "'>"; 
    347                                 $html .= "</div>\n"; 
    348                                 $html .= "</li>\n"; 
    349                         } 
    350                 } 
    351  
    352                 $html .= "<li class='admin_element_item_container'>\n"; 
    353  
    354                 $sql_additional_where = "AND node_id NOT IN (SELECT node_id FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id')"; 
    355                 $name = "content_group_element_{$this->id}_new_allowed_node"; 
    356                 $html .= Node :: getSelectNodeUI($name, $sql_additional_where); 
    357                 $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 
    358                 $html .= "<input type='submit' name='$name' value='" . _("Add new allowed node") . "'>"; 
    359                 $html .= "</li'>\n"; 
    360                 $html .= "</ul>\n"; 
    361                 $html .= _("(Content can be displayed at ANY node unless one or more nodes are selected)") . "\n"; 
    362  
    363                 $html .= "</li>\n"; 
    364                 $html .= "</fieldset>\n"; 
    365                 $html .= "</li>\n"; 
    366  
    367                 /* displayed_content_id */ 
    368                 $html .= "<li class='admin_element_item_container'>\n"; 
    369                 if (empty ($this->content_group_element_row['displayed_content_id'])) { 
    370                         $html .= "<div class='errormsg'>Sorry, display element is missing.</div>\n"; 
    371                         /*              $html .= "<fieldset class='admin_element_group'>\n"; 
    372                                                 $html .= "<legend>"._("Add a new displayed content OR select an existing one")."</legend>\n"; 
    373                                     $html .= self :: getNewContentUI("content_group_element_{$this->id}_new_displayed_content")."<br>"; 
    374                                     $html .= self :: getSelectExistingContentUI("content_group_element_{$this->id}_new_displayed_existing_element", "AND content_id != '$this->id'"); 
    375                                                 $html .= "</fieldset>\n";*/ 
    376                 } else { 
    377                         $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
    378                         $html .= $displayed_content->getAdminUI(null, sprintf(_("%s %d displayed content (%s)"), get_class($this), $this->getDisplayOrder(), get_class($displayed_content))); 
    379                         /*$html .= "<div class='admin_element_tools'>\n"; 
    380                         $name = "content_group_element_{$this->id}_erase_displayed_content"; 
    381                         $html .= "<input type='submit' name='$name' value='"._("Delete")."'>"; 
    382                         $html .= "</div>\n";*/ 
    383                 } 
    384                 $html .= "</li>\n"; 
    385  
    386                 $html .= $subclass_admin_interface; 
    387  
    388                 return parent :: getAdminUI($html, $title); 
    389         } 
    390  
    391         /** 
    392          * Processes the input of the administration interface for ContentGroupElement 
    393          * 
    394          * @return void 
    395          */ 
    396         public function processAdminUI() { 
    397                 // Define globals 
    398                 global $db; 
    399  
    400                 // Init values 
    401                 $allowed_node_rows = null; 
    402                 $errmsg = null; 
    403  
    404                 parent :: processAdminUI(); 
    405  
    406                 /* display_order */ 
    407                 $name = "content_group_element_" . $this->id . "_display_order"; 
    408                 $this->setDisplayOrder($_REQUEST[$name]); 
    409  
    410                 // valid_from_timestamp 
    411                 $name = "content_group_element_" . $this->id . "_valid_from"; 
    412                 $this->setValidFromDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 
    413  
    414                 // valid_until_timestamp 
    415  
    416                 $name = "content_group_element_" . $this->id . "_valid_until"; 
    417                 $this->setValidUntilDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 
    418  
    419                 /* content_group_element_has_allowed_nodes */ 
    420                 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 
    421                 $db->execSql($sql, $allowed_node_rows, false); 
    422  
    423                 if ($allowed_node_rows != null) { 
    424                         foreach ($allowed_node_rows as $allowed_node_row) { 
    425                                 $node = Node :: getObject($allowed_node_row['node_id']); 
    426                                 $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 
    427  
    428                                 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    429                                         $sql = "DELETE FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id' AND node_id='" . $node->GetId() . "'"; 
    430                                         $db->execSqlUpdate($sql, false); 
    431                                 } 
    432                         } 
    433                 } 
    434  
    435                 $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 
    436  
    437                 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    438                         $name = "content_group_element_{$this->id}_new_allowed_node"; 
    439                         $node = Node :: processSelectNodeUI($name); 
    440                         $node_id = $node->GetId(); 
    441                         $db->execSqlUpdate("INSERT INTO content_group_element_has_allowed_nodes (content_group_element_id, node_id) VALUES ('$this->id', '$node_id')", FALSE); 
    442                 } 
    443  
    444                 /* displayed_content_id */ 
    445                 if (empty ($this->content_group_element_row['displayed_content_id'])) { 
    446                         // Could be either a new content or existing content ( try both successively ) 
    447                         $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_content"); 
    448  
    449                         if ($displayed_content == null) { 
    450                                 $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_existing_element", true); 
    451                         } 
    452  
    453                         if ($displayed_content != null) { 
    454                                 $displayed_content_id = $displayed_content->GetId(); 
    455                                 $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = '$displayed_content_id' WHERE content_group_element_id = '$this->id'", FALSE); 
    456                         } 
    457                 } else { 
    458                         $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
    459                         $name = "content_group_element_{$this->id}_erase_displayed_content"; 
    460  
    461                         if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
    462                                 if ($displayed_content->delete($errmsg) != false) { 
    463                                         $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = NULL WHERE content_group_element_id = '$this->id'", FALSE); 
    464                                 } else { 
    465                                         echo $errmsg; 
    466                                 } 
    467                         } else { 
    468                                 $displayed_content->processAdminUI(); 
    469                         } 
    470                 } 
    471         } 
    472  
    473         /** 
    474          * Retreives the user interface of this object. 
    475          * 
    476          * @return string The HTML fragment for this interface 
    477          */ 
    478         public function getUserUI($subclass_user_interface = null) { 
    479                 // Init values 
    480                 $html = ''; 
    481  
    482                 if (!empty ($this->content_group_element_row['displayed_content_id'])) { 
    483                         $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
    484  
    485                         // If the content group logging is disabled, all the children will inherit this property temporarly 
    486                         if ($this->getLoggingStatus() == false) { 
    487                                 $displayed_content->setLoggingStatus(false); 
    488                         } 
    489  
    490                         $displayed_content_html = $displayed_content->getUserUI(); 
    491                 } 
    492  
    493                 $html .= "<div class='user_ui_container " . get_class($this) . "'>\n"; 
    494                 $html .= $displayed_content_html; 
    495                 $html .= $subclass_user_interface; 
    496                 $html .= "</div>\n"; 
    497  
    498                 return parent :: getUserUI($html); 
    499         } 
    500  
    501         /** 
    502          * Returns if this this Content element is displayable at this hotspot 
    503          * 
    504          * @param string $node Node Id 
    505          * 
    506          * @return bool True if it is displayable 
    507          */ 
    508         public function isDisplayableAt($node) { 
    509                 // Define globals 
    510                 global $db; 
    511  
    512                 // Init values 
    513                 $retval = false; 
    514                 $allowed_node_rows = null; 
    515  
    516                 $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 
    517                 $db->execSql($sql, $allowed_node_rows, false); 
    518  
    519                 if ($allowed_node_rows != null) { 
    520                         if ($node) { 
    521                                 $node_id = $node->getId(); 
    522                                 /** 
    523                                  * @todo  Proper algorithm, this is a dirty and slow hack 
    524                                  */ 
    525                                 foreach ($allowed_node_rows as $allowed_node_row) { 
    526                                         if ($allowed_node_row['node_id'] == $node_id) { 
    527                                                 $retval = true; 
    528                                         } 
    529                                 } 
    530                         } else { 
    531                                 /* There are allowed nodes, but we don't know at which node we want to display */ 
    532                                 $retval = false; 
    533                         } 
    534                 } else { 
    535                         /* No allowed node means all nodes are allowed */ 
    536                         $retval = true; 
    537                 } 
    538  
    539                 return $retval; 
    540         } 
    541  
    542         /** 
    543          * Detects if a user is owner of a ContentGroupElement 
    544          * 
    545          * Override the method in Content. 
    546          * 
    547          * The owners of the content element are always considered to be the ContentGroup's 
    548          * 
    549          * @param object $user User object: the user to be tested. 
    550          * 
    551          * @return bool True if the user is a owner, false if he isn't or if the user is null 
    552          */ 
    553         public function isOwner($user) { 
    554                 $content_group = Content :: getObject($this->content_group_element_row['content_group_id']); 
    555                 return $content_group->isOwner($user); 
    556         } 
    557  
    558         /** 
    559          * Deletes a ContentGroupElement object 
    560          * 
    561          * @param string $errmsg Reference to error message 
    562          * 
    563          * @return bool True if deletion was successful 
    564          * @internal Persistent content will not be deleted 
    565          * 
    566          * @todo Implement proper access control 
    567          */ 
    568         public function delete(& $errmsg) { 
    569                 if ($this->isPersistent() == false && !empty ($this->content_group_element_row['displayed_content_id'])) { 
    570                         $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
    571                         $displayed_content->delete($errmsg); 
    572                         parent :: delete($errmsg); 
    573                 } 
    574         } 
    575         /** Reloads the object from the database.  Should normally be called after a set operation */ 
    576         protected function refresh() { 
    577                 $this->__construct($this->id); 
    578         } 
     65    /** 
     66     
     67     */ 
     68    private $content_group_element_row; 
     69    /** The content object to be displayed by this element */ 
     70    private $displayed_content; 
     71 
     72    /** 
     73     * Constructor 
     74     * 
     75     * @param string $content_id Content Id 
     76     * 
     77     * @return void     */ 
     78    protected function __construct($content_id) { 
     79         
     80        $db = AbstractDb::getObject(); 
     81 
     82        // Init values 
     83        $row = null; 
     84 
     85        parent :: __construct($content_id); 
     86        $content_id = $db->escapeString($content_id); 
     87 
     88        $sql_select = "SELECT * FROM content_group_element WHERE content_group_element_id='$content_id'"; 
     89        $db->execSqlUniqueRes($sql_select, $row, false); 
     90 
     91        if ($row == null) { 
     92            // The database was corrupted, let's fix it ... 
     93            $sql = "DELETE FROM content WHERE content_id='$content_id'"; 
     94            $db->execSqlUpdate($sql, true); 
     95        } 
     96 
     97        $this->content_group_element_row = $row; 
     98 
     99        /* A content group element is NEVER persistent */ 
     100        parent :: setIsPersistent(false); 
     101    } 
     102    /** When a content object is set as Simple, it means that is is used merely to contain it's own data.  No title, description or other metadata will be set or displayed, during display or administration 
     103     * @return true or false */ 
     104    public function isSimpleContent() { 
     105        return true; 
     106    } 
     107    /** 
     108     * Replace and delete the old displayed_content (if any) by the new 
     109     * content (or no content) 
     110     * 
     111     * @param object $new_displayed_content Content object or null. If 
     112     *                                      null the old content is still 
     113     *                                      deleted. 
     114     * 
     115     * @return void 
     116     
     117     */ 
     118    private function replaceDisplayedContent($new_displayed_content) { 
     119         
     120        $db = AbstractDb::getObject(); 
     121 
     122        // Init values 
     123        $old_displayed_content = null; 
     124        $errmsg = null; 
     125 
     126        if (!empty ($this->content_group_element_row['displayed_content_id'])) { 
     127            $old_displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
     128        } 
     129 
     130        if ($new_displayed_content != null) { 
     131            $new_displayed_content_id_sql = "'" . $new_displayed_content->GetId() . "'"; 
     132        } else { 
     133            $new_displayed_content_id_sql = "NULL"; 
     134        } 
     135 
     136        $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = $new_displayed_content_id_sql WHERE content_group_element_id = '$this->id'", FALSE); 
     137 
     138        if ($old_displayed_content != null) { 
     139            $old_displayed_conten->delete($errmsg); 
     140        } 
     141    } 
     142 
     143    /** 
     144     * Get the displayed content object 
     145     * 
     146     * @return Content object 
     147     */ 
     148    public function getDisplayedContent() { 
     149        if ($this->displayed_content == null) { 
     150            $this->displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
     151 
     152        } 
     153        return $this->displayed_content; 
     154    } 
     155    /** 
     156     * Get the order of the element in the content group 
     157     * 
     158     * @return string the order of the element in the content group 
     159     */ 
     160    public function getDisplayOrder() { 
     161        return $this->content_group_element_row['display_order']; 
     162    } 
     163 
     164    /** 
     165     * Set the order of the element in the content group 
     166     * 
     167     * @param string $order Order how items should be displayed 
     168     * 
     169     * @return void 
     170     */ 
     171    public function setDisplayOrder($order) { 
     172         
     173        $db = AbstractDb::getObject(); 
     174 
     175        if ($order != $this->getDisplayOrder()) { 
     176            /* 
     177             * Only update database if there is an actual change 
     178             */ 
     179            $order = $db->escapeString($order); 
     180            $db->execSqlUpdate("UPDATE content_group_element SET display_order = $order WHERE content_group_element_id = '$this->id'", false); 
     181        } 
     182    } 
     183 
     184    /** 
     185     * Like the same method as defined in Content, this method will create a 
     186     * ContentGroupElement based on the content type specified by 
     187     * getNewContentUI OR get an existing element by getSelectExistingContentUI 
     188     * 
     189     * @param string $user_prefix                A identifier provided by the programmer to 
     190     *                                           recognise it's generated form 
     191     * @param string $content_group              Must be present 
     192     * @param bool   $associate_existing_content If set to true, will get an 
     193     *                                           existing element instead of creating a 
     194     *                                           new content. 
     195     * 
     196     * @return object The ContentGroup object, or null if the user didn't greate one 
     197     * @static 
     198     */ 
     199    public static function processNewContentUI($user_prefix, ContentGroup $content_group, $associate_existing_content = false) { 
     200         
     201        $db = AbstractDb::getObject(); 
     202 
     203        // Init values 
     204        $content_group_element_object = null; 
     205        $max_display_order_row = null; 
     206 
     207        if ($associate_existing_content == true) { 
     208            $name = "{$user_prefix}_add"; 
     209        } else { 
     210            $name = "get_new_content_{$user_prefix}_add"; 
     211        } 
     212 
     213        if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
     214            /* Get the display order to add the GontentGroupElement at the end */ 
     215            $sql = "SELECT MAX(display_order) as max_display_order FROM content_group_element WHERE content_group_id='" . $content_group->getId() . "'"; 
     216            $db->execSqlUniqueRes($sql, $max_display_order_row, false); 
     217            $display_order = $max_display_order_row['max_display_order'] + 1; 
     218 
     219            if ($associate_existing_content == true) { 
     220                $name = "{$user_prefix}"; 
     221            } else { 
     222                $name = "get_new_content_{$user_prefix}_content_type"; 
     223            } 
     224 
     225            $content_id = get_guid(); 
     226            $content_type = 'ContentGroupElement'; 
     227            $sql = "INSERT INTO content (content_id, content_type) VALUES ('$content_id', '$content_type');"; 
     228 
     229            if (!$db->execSqlUpdate($sql, false)) { 
     230                throw new Exception(_('Unable to insert new content into database!')); 
     231            } 
     232 
     233            $sql = "INSERT INTO content_group_element (content_group_element_id, content_group_id, display_order) VALUES ('$content_id', '" . $content_group->GetId() . "', $display_order);"; 
     234 
     235            if (!$db->execSqlUpdate($sql, false)) { 
     236                throw new Exception(_('Unable to insert new content into database!')); 
     237            } 
     238 
     239            $content_group_element_object = self :: getObject($content_id); 
     240 
     241            $content_ui_result = FormSelectGenerator :: getResult($name, null); 
     242 
     243            if ($associate_existing_content == true) { 
     244                $displayed_content_object = self :: getObject($content_ui_result); 
     245            } else { 
     246                $displayed_content_object = self :: createNewObject($content_ui_result); 
     247            } 
     248 
     249            $content_group_element_object->replaceDisplayedContent($displayed_content_object); 
     250        } 
     251 
     252        return $content_group_element_object; 
     253    } 
     254    /** If set, content will only be displayed from this date on. */ 
     255    function getValidFromDate() { 
     256        return $this->content_group_element_row['valid_from_timestamp']; 
     257    } 
     258 
     259    /** If set, content will only be displayed from this date on.  
     260     * @param string @date Start date.  To always display, set to null or an empty string */ 
     261    function setValidFromDate($date) { 
     262         
     263        $db = AbstractDb::getObject(); 
     264        if ($date != $this->getValidFromDate()) { 
     265            if (!empty ($date)) { 
     266                $date = "'" . $db->escapeString($date) . "'"; 
     267            } else { 
     268                $date = 'NULL'; 
     269            } 
     270            $db->execSqlUpdate("UPDATE content_group_element SET valid_from_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 
     271            $this->refresh(); 
     272        } 
     273    } 
     274    /** If set, content will only be displayed untill this date (and will then be archived). */ 
     275    function getValidUntilDate() { 
     276        return $this->content_group_element_row['valid_until_timestamp']; 
     277    } 
     278 
     279    /** If set, content will only be displayed untill this date (and will then be archived).  
     280     * @param string @date End date.  To always display, set to null or an empty string */ 
     281    function setValidUntilDate($date) { 
     282         
     283        $db = AbstractDb::getObject(); 
     284        if ($date != $this->getValidUntilDate()) { 
     285            if (!empty ($date)) { 
     286                $date = "'" . $db->escapeString($date) . "'"; 
     287            } else { 
     288                $date = 'NULL'; 
     289            } 
     290            $db->execSqlUpdate("UPDATE content_group_element SET valid_until_timestamp = {$date} WHERE content_group_element_id = '{$this->getId()}'"); 
     291            $this->refresh(); 
     292        } 
     293    } 
     294 
     295    /** 
     296     * Shows the administration interface for ContentGroupElement 
     297     * 
     298     * @param string $subclass_admin_interface HTML code to be added after the 
     299     *                                         administration interface 
     300     * 
     301     * @return string HTML code for the administration interface 
     302     */ 
     303    public function getAdminUI($subclass_admin_interface = null, $title = null) { 
     304         
     305        $db = AbstractDb::getObject(); 
     306 
     307        // Init values 
     308        $html = ''; 
     309        $html .= "<li class='admin_element_item_container'>\n"; 
     310        $html .= "<fieldset class='admin_element_group'>\n"; 
     311        $html .= "<legend>" . sprintf(_("%s %d display conditions"), get_class($this), $this->getDisplayOrder()) . "</legend>\n"; 
     312 
     313        $allowed_node_rows = null; 
     314        $html .= "<ul class='admin_element_list'>\n"; 
     315        /* display_order */ 
     316        $html .= "<li class='admin_element_item_container'>\n"; 
     317        $html .= "<div class='admin_element_label'>Display order: </div>\n"; 
     318        $html .= "<div class='admin_element_data'>\n"; 
     319        $name = "content_group_element_" . $this->id . "_display_order"; 
     320        $html .= "<input type='text' name='$name' value='" . $this->getDisplayOrder() . "' size='2'>\n"; 
     321        $html .= _("(Ignored if display type is random)") . "\n"; 
     322        $html .= "</div>\n"; 
     323        $html .= "</li>\n"; 
     324 
     325        $html .= "<li class='admin_element_item_container'>\n"; 
     326        // valid_from_timestamp 
     327        $html .= "<div class='admin_element_label'>" . _("Only display from") . "</div>\n"; 
     328        $html .= "<div class='admin_element_data'>\n"; 
     329        $name = "content_group_element_" . $this->id . "_valid_from"; 
     330        $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidFromDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 
     331        $html .= "</div>\n"; 
     332 
     333        // valid_until_timestamp 
     334        $html .= "<div class='admin_element_label'>until</div>\n"; 
     335        $html .= "<div class='admin_element_data'>\n"; 
     336        $name = "content_group_element_" . $this->id . "_valid_until"; 
     337        $html .= DateTime :: getSelectDateTimeUI(new DateTime($this->getValidUntilDate()), $name, DateTime :: INTERFACE_DATETIME_FIELD, null); 
     338        $html .= "</div>\n"; 
     339 
     340        $html .= _("(Content can be displayed at any date if no start or end date is specified.  Warning:  If you do not specify a specifig time of day, midnight is assumed.)") . "\n"; 
     341        $html .= "</li>\n"; 
     342 
     343        /* content_group_element_has_allowed_nodes */ 
     344        $html .= "<li class='admin_element_item_container'>\n"; 
     345        $html .= "<div class='admin_element_label'>" . _("Only display at node(s):") . "</div>\n"; 
     346        $html .= "<ul class='admin_element_list'>\n"; 
     347 
     348        $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 
     349        $db->execSql($sql, $allowed_node_rows, false); 
     350 
     351        if ($allowed_node_rows != null) { 
     352            foreach ($allowed_node_rows as $allowed_node_row) { 
     353                $node = Node :: getObject($allowed_node_row['node_id']); 
     354                $html .= "<li class='admin_element_item_container'>\n"; 
     355                $html .= "<div class='admin_element_data'>\n"; 
     356                $html .= "" . $node->GetId() . ": " . $node->GetName() . ""; 
     357                $html .= "</div>\n"; 
     358                $html .= "<div class='admin_element_tools'>\n"; 
     359                $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 
     360                $html .= "<input type='submit' name='$name' value='" . _("Remove") . "'>"; 
     361                $html .= "</div>\n"; 
     362                $html .= "</li>\n"; 
     363            } 
     364        } 
     365 
     366        $html .= "<li class='admin_element_item_container'>\n"; 
     367 
     368        $sql_additional_where = "AND node_id NOT IN (SELECT node_id FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id')"; 
     369        $name = "content_group_element_{$this->id}_new_allowed_node"; 
     370        $html .= Node :: getSelectNodeUI($name, $sql_additional_where); 
     371        $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 
     372        $html .= "<input type='submit' name='$name' value='" . _("Add new allowed node") . "'>"; 
     373        $html .= "</li'>\n"; 
     374        $html .= "</ul>\n"; 
     375        $html .= _("(Content can be displayed at ANY node unless one or more nodes are selected)") . "\n"; 
     376 
     377        $html .= "</li>\n"; 
     378        $html .= "</fieldset>\n"; 
     379        $html .= "</li>\n"; 
     380 
     381        /* displayed_content_id */ 
     382        $html .= "<li class='admin_element_item_container'>\n"; 
     383        if (empty ($this->content_group_element_row['displayed_content_id'])) { 
     384            $html .= "<div class='errormsg'>Sorry, display element is missing.</div>\n"; 
     385            /*          $html .= "<fieldset class='admin_element_group'>\n"; 
     386                                $html .= "<legend>"._("Add a new displayed content OR select an existing one")."</legend>\n"; 
     387                        $html .= self :: getNewContentUI("content_group_element_{$this->id}_new_displayed_content")."<br>"; 
     388                        $html .= self :: getSelectExistingContentUI("content_group_element_{$this->id}_new_displayed_existing_element", "AND content_id != '$this->id'"); 
     389                                $html .= "</fieldset>\n";*/ 
     390        } else { 
     391            $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
     392            $html .= $displayed_content->getAdminUI(null, sprintf(_("%s %d displayed content (%s)"), get_class($this), $this->getDisplayOrder(), get_class($displayed_content))); 
     393            /*$html .= "<div class='admin_element_tools'>\n"; 
     394            $name = "content_group_element_{$this->id}_erase_displayed_content"; 
     395            $html .= "<input type='submit' name='$name' value='"._("Delete")."'>"; 
     396            $html .= "</div>\n";*/ 
     397        } 
     398        $html .= "</li>\n"; 
     399 
     400        $html .= $subclass_admin_interface; 
     401 
     402        return parent :: getAdminUI($html, $title); 
     403    } 
     404 
     405    /** 
     406     * Processes the input of the administration interface for ContentGroupElement 
     407     * 
     408     * @return void 
     409     */ 
     410    public function processAdminUI() { 
     411         
     412        $db = AbstractDb::getObject(); 
     413 
     414        // Init values 
     415        $allowed_node_rows = null; 
     416        $errmsg = null; 
     417 
     418        parent :: processAdminUI(); 
     419 
     420        /* display_order */ 
     421        $name = "content_group_element_" . $this->id . "_display_order"; 
     422        $this->setDisplayOrder($_REQUEST[$name]); 
     423 
     424        // valid_from_timestamp 
     425        $name = "content_group_element_" . $this->id . "_valid_from"; 
     426        $this->setValidFromDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 
     427 
     428        // valid_until_timestamp 
     429 
     430        $name = "content_group_element_" . $this->id . "_valid_until"; 
     431        $this->setValidUntilDate(DateTime :: processSelectDateTimeUI($name, DateTime :: INTERFACE_DATETIME_FIELD)->getIso8601FormattedString()); 
     432 
     433        /* content_group_element_has_allowed_nodes */ 
     434        $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 
     435        $db->execSql($sql, $allowed_node_rows, false); 
     436 
     437        if ($allowed_node_rows != null) { 
     438            foreach ($allowed_node_rows as $allowed_node_row) { 
     439                $node = Node :: getObject($allowed_node_row['node_id']); 
     440                $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove"; 
     441 
     442                if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
     443                    $sql = "DELETE FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id' AND node_id='" . $node->GetId() . "'"; 
     444                    $db->execSqlUpdate($sql, false); 
     445                } 
     446            } 
     447        } 
     448 
     449        $name = "content_group_element_{$this->id}_new_allowed_node_submit"; 
     450 
     451        if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
     452            $name = "content_group_element_{$this->id}_new_allowed_node"; 
     453            $node = Node :: processSelectNodeUI($name); 
     454            $node_id = $node->GetId(); 
     455            $db->execSqlUpdate("INSERT INTO content_group_element_has_allowed_nodes (content_group_element_id, node_id) VALUES ('$this->id', '$node_id')", FALSE); 
     456        } 
     457 
     458        /* displayed_content_id */ 
     459        if (empty ($this->content_group_element_row['displayed_content_id'])) { 
     460            // Could be either a new content or existing content ( try both successively ) 
     461            $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_content"); 
     462 
     463            if ($displayed_content == null) { 
     464                $displayed_content = Content :: processNewContentUI("content_group_element_{$this->id}_new_displayed_existing_element", true); 
     465            } 
     466 
     467            if ($displayed_content != null) { 
     468                $displayed_content_id = $displayed_content->GetId(); 
     469                $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = '$displayed_content_id' WHERE content_group_element_id = '$this->id'", FALSE); 
     470            } 
     471        } else { 
     472            $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
     473            $name = "content_group_element_{$this->id}_erase_displayed_content"; 
     474 
     475            if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 
     476                if ($displayed_content->delete($errmsg) != false) { 
     477                    $db->execSqlUpdate("UPDATE content_group_element SET displayed_content_id = NULL WHERE content_group_element_id = '$this->id'", FALSE); 
     478                } else { 
     479                    echo $errmsg; 
     480                } 
     481            } else { 
     482                $displayed_content->processAdminUI(); 
     483            } 
     484        } 
     485    } 
     486 
     487    /** This function will be called by MainUI for each Content BEFORE any getUserUI function is called to allow two pass Content display. 
     488     * Two pass Content display allows such things as modyfying headers, title, creating content type that accumulate content from other pieces (like RSS feeds) 
     489     * @return null 
     490     */ 
     491    public function prepareGetUserUI() { 
     492        $displayed_content = $this->getDisplayedContent(); 
     493        $displayed_content->prepareGetUserUI(); 
     494        return parent :: prepareGetUserUI(); 
     495    } 
     496 
     497    /** 
     498     * Retreives the user interface of this object. 
     499     * 
     500     * @return string The HTML fragment for this interface 
     501     */ 
     502    public function getUserUI($subclass_user_interface = null) { 
     503        // Init values 
     504        $html = ''; 
     505 
     506        if (!empty ($this->content_group_element_row['displayed_content_id'])) { 
     507            $displayed_content = $this->getDisplayedContent(); 
     508 
     509            // If the content group logging is disabled, all the children will inherit this property temporarly 
     510            if ($this->getLoggingStatus() == false) { 
     511                $displayed_content->setLoggingStatus(false); 
     512            } 
     513 
     514            $displayed_content_html = $displayed_content->getUserUI(); 
     515        } 
     516 
     517        $html .= "<div class='user_ui_container " . get_class($this) . "'>\n"; 
     518        $html .= $displayed_content_html; 
     519        $html .= $subclass_user_interface; 
     520        $html .= "</div>\n"; 
     521 
     522        return parent :: getUserUI($html); 
     523    } 
     524 
     525    /** 
     526     * Returns if this this Content element is displayable at this hotspot 
     527     * 
     528     * @param string $node Node Id 
     529     * 
     530     * @return bool True if it is displayable 
     531     */ 
     532    public function isDisplayableAt($node) { 
     533         
     534        $db = AbstractDb::getObject(); 
     535 
     536        // Init values 
     537        $retval = false; 
     538        $allowed_node_rows = null; 
     539 
     540        $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='$this->id'"; 
     541        $db->execSql($sql, $allowed_node_rows, false); 
     542 
     543        if ($allowed_node_rows != null) { 
     544            if ($node) { 
     545                $node_id = $node->getId(); 
     546                /** 
     547                 * @todo  Proper algorithm, this is a dirty and slow hack 
     548                 */ 
     549                foreach ($allowed_node_rows as $allowed_node_row) { 
     550                    if ($allowed_node_row['node_id'] == $node_id) { 
     551                        $retval = true; 
     552                    } 
     553                } 
     554            } else { 
     555                /* There are allowed nodes, but we don't know at which node we want to display */ 
     556                $retval = false; 
     557            } 
     558        } else { 
     559            /* No allowed node means all nodes are allowed */ 
     560            $retval = true; 
     561        } 
     562 
     563        return $retval; 
     564    } 
     565 
     566    /** 
     567     * Detects if a user is owner of a ContentGroupElement 
     568     * 
     569     * Override the method in Content. 
     570     * 
     571     * The owners of the content element are always considered to be the ContentGroup's 
     572     * 
     573     * @param object $user User object: the user to be tested. 
     574     * 
     575     * @return bool True if the user is a owner, false if he isn't or if the user is null 
     576     */ 
     577    public function isOwner($user) { 
     578        $content_group = Content :: getObject($this->content_group_element_row['content_group_id']); 
     579        return $content_group->isOwner($user); 
     580    } 
     581 
     582    /** 
     583     * Deletes a ContentGroupElement object 
     584     * 
     585     * @param string $errmsg Reference to error message 
     586     * 
     587     * @return bool True if deletion was successful 
     588     * @internal Persistent content will not be deleted 
     589     * 
     590     * @todo Implement proper access control 
     591     */ 
     592    public function delete(& $errmsg) { 
     593        if ($this->isPersistent() == false && !empty ($this->content_group_element_row['displayed_content_id'])) { 
     594            $displayed_content = self :: getObject($this->content_group_element_row['displayed_content_id']); 
     595            $displayed_content->delete($errmsg); 
     596            parent :: delete($errmsg); 
     597        } 
     598    } 
     599    /** Reloads the object from the database.  Should normally be called after a set operation */ 
     600    protected function refresh() { 
     601        $this->__construct($this->id); 
     602    } 
    579603} 
    580604 
  • trunk/wifidog-auth/wifidog/classes/Content/EmbeddedContent/EmbeddedContent.php

    r1118 r1127  
    6969    protected function __construct($content_id) 
    7070    { 
    71         // Define globals 
    72         global $db; 
     71         
     72        $db = AbstractDb::getObject(); 
    7373 
    7474        // Init values 
     
    244244    { 
    245245        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
    246             // Define globals 
    247             global $db; 
     246             
     247            $db = AbstractDb::getObject(); 
    248248 
    249249            // Init values 
  • trunk/wifidog-auth/wifidog/classes/Content/File/File.php

    r1123 r1127  
    8989    public function __construct($content_id) 
    9090    { 
    91         // Define globals 
    92         global $db; 
     91         
     92        $db = AbstractDb::getObject(); 
    9393 
    9494        // Init values 
  • trunk/wifidog-auth/wifidog/classes/Content/FlickrPhotostream/FlickrPhotostream.php

    r1123 r1127  
    108108        if (Dependencies::check("Phlickr", $errmsg)) { 
    109109            // Defined globals 
    110             global $db; 
     110            $db = AbstractDb::getObject(); 
    111111 
    112112            // Load Phlickr classes 
  • trunk/wifidog-auth/wifidog/classes/Content/HTMLeditor/HTMLeditor.php

    r1096 r1127  
    5959class HTMLeditor extends Langstring 
    6060{ 
    61  
    62     /** 
    63      * HTML allowed to be used 
    64      */ 
    65     const ALLOWED_HTML_TAGS = "<p><div><pre><address><h1><h2><h3><h4><h5><h6><br><b><strong><i><em><u><span><ol><ul><li><a><img><embed><table><tbody><thead><th><tr><td><hr>"; 
    66  
    6761    /** 
    6862     * Defines if the FCKeditor library has been installed 
     
    8175    { 
    8276        parent::__construct($content_id); 
     77                $this->allowed_html_tags = "<p><div><pre><address><h1><h2><h3><h4><h5><h6><br><b><strong><i><em><u><span><ol><ul><li><a><img><embed><table><tbody><thead><th><tr><td><hr>"; 
    8378 
    8479        // Check FCKeditor support 
     
    8984        } 
    9085    } 
    91  
    92     /** 
    93      * Shows the administration interface for HTMLeditor. 
    94      * 
    95      * @param string $type_interface SIMPLE for a small HTML editor, LARGE 
    96      *                               for a larger HTML editor (default). 
    97      * @param int    $num_nouveau    Number of new HTML editors to be created. 
    98      * 
    99      * @return string HTML code for the administration interface. 
     86    /** 
     87     * Retreives the admin interface of this object. Anything that overrides 
     88     * this method should call the parent method with it's output at the END of 
     89     * processing. 
     90     * @param string $subclass_admin_interface HTML content of the interface 
     91     * element of a children. 
     92     * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE 
     93     *                               pour voir toutes les chaînes, LARGE pour 
     94     *                               avoir un textarea. 
     95     * @return string The HTML fragment for this interface. 
    10096     */ 
    101     public function getAdminUI($type_interface = 'LARGE') 
     97    public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") 
    10298    { 
    10399        if ($this->_FCKeditorAvailable) { 
     
    105101            $_result = null; 
    106102            $_html = ''; 
     103            $_html .= $subclass_admin_interface; 
    107104            $_languages = new LocaleList(); 
    108105                        $_html .= "<ul class='admin_element_list'>\n"; 
     
    197194        } 
    198195 
    199         return Content :: getAdminUI($_html); 
     196        return Content :: getAdminUI($_html, $title); 
    200197    } 
    201198 
  • trunk/wifidog-auth/wifidog/classes/Content/IFrame/IFrame.php

    r1090 r1127  
    6262    public function __construct($content_id) 
    6363    { 
    64         // Define globals 
    65         global $db; 
     64         
     65        $db = AbstractDb::getObject(); 
    6666 
    6767        // Init value 
  • trunk/wifidog-auth/wifidog/classes/Content/Langstring/Langstring.php

    r1094 r1127  
    6161 */ 
    6262class Langstring extends Content { 
    63     /** 
    64      * HTML allowed to be used 
    65      */ 
    66     const ALLOWED_HTML_TAGS = "<a><br><b><h1><h2><h3><h4><i><img><li><ol><p><strong><u><ul><li>"; 
    67  
     63    protected $allowed_html_tags; 
    6864    /** 
    6965     * Constructor 
     
    7369    public function __construct($content_id) 
    7470    { 
    75         // Define globals 
    76         global $db; 
    77  
    7871        parent::__construct($content_id); 
     72         
     73        $db = AbstractDb::getObject(); 
     74            /** 
     75         * HTML allowed to be used 
     76        */ 
     77                $this->allowed_html_tags = "<a><br><b><h1><h2><h3><h4><i><img><li><ol><p><strong><u><ul><li>"; 
    7978        $this->mBd = &$db; 
    8079    } 
     
    242241 
    243242    /** 
    244      * Affiche l'interface d'administration de l'objet 
    245      * 
     243     * Retreives the admin interface of this object. Anything that overrides 
     244     * this method should call the parent method with it's output at the END of 
     245     * processing. 
     246     * @param string $subclass_admin_interface HTML content of the interface 
     247     * element of a children. 
    246248     * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE 
    247249     *                               pour voir toutes les chaînes, LARGE pour 
    248250     *                               avoir un textarea. 
    249      * @return string HTML code of administration interface 
    250      */ 
    251     public function getAdminUI($type_interface = "LARGE", $title=null) 
     251     * @return string The HTML fragment for this interface. 
     252     */ 
     253    public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") 
    252254    { 
    253255        // Init values. 
    254256        $html = ''; 
     257        $html .= $subclass_admin_interface; 
    255258        $result = ""; 
    256259        //$variantsCounter = 0; 
    257260        //$_hideNewContent = false; 
    258         $html .= "<div class='admin_section_hint'>" . _("Only these HTML tags are allowed : ") . htmlentities(self::ALLOWED_HTML_TAGS) . "</div>"; 
     261        if(!empty($this->allowed_html_tags)) { 
     262                $html .= "<div class='admin_section_hint'>" . _("Only these HTML tags are allowed : ") . htmlentities($this->allowed_html_tags) . "</div>"; 
     263        } 
    259264                $html .= "<ul class='admin_element_list'>\n"; 
    260265        $liste_languages = new LocaleList(); 
     
    433438                        // Strip HTML tags ! 
    434439                        $string = $_REQUEST["langstrings_".$this->id."_substring_$value[langstring_entries_id]_string"]; 
    435                         $string = $this->mBd->escapeString(strip_tags($string, self :: ALLOWED_HTML_TAGS)); 
     440                        $string = $this->mBd->escapeString(strip_tags($string, $this->allowed_html_tags)); 
    436441 
    437442                        // If PEAR::HTML_Safe is available strips down all potentially dangerous content 
     
    536541            $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)"); 
    537542        } else { 
    538             global $db; 
     543            $db = AbstractDb::getObject(); 
    539544 
    540545            if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
  • trunk/wifidog-auth/wifidog/classes/Content/PatternLanguage/PatternLanguage.php

    r1090 r1127  
    148148    public function displayNarrative(User $user) 
    149149    { 
    150         // Define globals 
    151         global $db; 
     150         
     151        $db = AbstractDb::getObject(); 
    152152 
    153153        // Init values 
     
    181181    public function getNarrativeList() 
    182182    { 
    183         // Define globals 
    184         global $db; 
     183         
     184        $db = AbstractDb::getObject(); 
    185185 
    186186        // Init values 
  • trunk/wifidog-auth/wifidog/classes/Content/Picture/Picture.php

    r1090 r1127  
    6868    protected function __construct($content_id) 
    6969    { 
    70         // Define globals 
    71         global $db; 
     70         
     71        $db = AbstractDb::getObject(); 
    7272 
    7373        // Init values 
  • trunk/wifidog-auth/wifidog/classes/Content/RssAggregator/RssAggregator.php

    r1092 r1127  
    8585     * @return void     */ 
    8686    protected function __construct($content_id) { 
    87         // Define globals 
    88         global $db; 
     87         
     88        $db = AbstractDb::getObject(); 
    8989 
    9090        // Init values 
     
    168168             * Only update database if the mode is valid and there is an actual change 
    169169             */ 
    170             global $db; 
     170            $db = AbstractDb::getObject(); 
    171171 
    172172            $num_items = $db->escapeString($num_items); 
     
    229229             * Only update database if the mode is valid and there is an actual change 
    230230             */ 
    231             global $db; 
     231            $db = AbstractDb::getObject(); 
    232232 
    233233            $strength = $db->escapeString($strength); 
     
    285285             * Only update database if the mode is valid and there is an actual change 
    286286             */ 
    287             global $db; 
     287            $db = AbstractDb::getObject(); 
    288288 
    289289            if ($max_item_age == null) { 
     
    319319     */ 
    320320    public function addFeed($url) { 
    321         // Define globals 
    322         global $db; 
     321         
     322        $db = AbstractDb::getObject(); 
    323323 
    324324        // Init values 
     
    344344     */ 
    345345    public function removeFeed($url) { 
    346         // Define globals 
    347         global $db; 
     346         
     347        $db = AbstractDb::getObject(); 
    348348 
    349349        // Init values 
     
    370370     */ 
    371371    public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    372         // Define globals 
    373         global $db; 
     372         
     373        $db = AbstractDb::getObject(); 
    374374 
    375375        // Init values 
     
    652652     */ 
    653653    private function processFeedAdminUI($feed_row) { 
    654         // Define globals 
    655         global $db; 
     654         
     655        $db = AbstractDb::getObject(); 
    656656 
    657657        $original_url = $db->escapeString($feed_row['url']); 
  • trunk/wifidog-auth/wifidog/classes/FormSelectGenerator.php

    r1074 r1127  
    5757        function __construct() 
    5858        { 
    59                 global $db; 
     59                $db = AbstractDb::getObject(); 
    6060                $this->mAbstractBd = $db; 
    6161        } 
     
    148148        static function generateFromTable($table, $primaryKeyField, $displayField, $selectedPrimaryKey, $userPrefix, $objectPrefix, $displayFieldIsLangstring=false, $allowNullValues=false, $nullCaptionString = ' - - - ', $additionalSelectAttribute = null) 
    149149        { 
    150                 global $db; 
     150                $db = AbstractDb::getObject(); 
    151151                $results = null; 
    152152                $db->execSql("SELECT $primaryKeyField,  $displayField FROM $table", $results, false); 
  • trunk/wifidog-auth/wifidog/classes/Locale.php

    r1084 r1127  
    6868    define('GETTEXT_AVAILABLE', true); 
    6969} 
    70  
     70require_once('classes/Session.php'); 
    7171/** 
    7272 * Designates a human language, possibly localized ie fr_CA 
     
    124124 
    125125    public static function getCurrentLocale() { 
    126         global $session; 
     126        $session = Session::getObject(); 
    127127        global $AVAIL_LOCALE_ARRAY; 
    128128        $object = null; 
     
    216216     */ 
    217217    public static function setCurrentLocale($locale) { 
    218         global $session; 
     218        $session = Session::getObject(); 
    219219         global $AVAIL_LOCALE_ARRAY; 
    220220        $retval = false; 
  • trunk/wifidog-auth/wifidog/classes/LocaleList.php

    r1094 r1127  
    5353 
    5454    function __construct() { 
    55         global $db; 
     55        $db = AbstractDb::getObject(); 
    5656        $this->mBd = & $db; //for backward compatibility 
    5757    } 
     
    132132     */ 
    133133    function GetDefault() { 
    134         global $session; 
     134        $session = Session::getObject(); 
    135135 
    136136        if ($user = User :: getCurrentUser()) { 
  • trunk/wifidog-auth/wifidog/classes/MainUI.php

    r1100 r1127  
    6464 
    6565/** 
    66  * Style contains functions managing headers, footers, stylesheet, etc. 
     66 * Singleton class for managing headers, footers, stylesheet, etc. 
    6767 * 
    6868 * @package    WiFiDogAuthServer 
     
    7272class MainUI 
    7373{ 
     74/** holder for the singleton */ 
     75        private static $object; 
    7476 
    7577        /** 
     
    109111        private $_pageName; 
    110112 
     113        /** list of URLs to stylesheet to be included */ 
     114        private $stylesheetUrlArray=array(); 
     115 
    111116        /** 
    112117         * Headers of HTML page 
     
    134139 
    135140        private $_shrinkLeftArea = false; 
    136  
     141    /** 
     142     * Get the MainUI object 
     143     * @return object The MainUI object 
     144     */ 
     145    public static function getObject() { 
     146        if (self::$object==null) 
     147        { 
     148                self::$object=new self(); 
     149        } 
     150        return self::$object; 
     151    } 
    137152        /** 
    138153         * Contructor 
     
    142157         * @access public 
    143158         */ 
    144         public function __construct() 
    145         { 
    146                 global $db; 
     159        private function __construct() 
     160        { 
     161                $db = AbstractDb::getObject(); 
    147162                // Init Smarty 
    148                 $this->smarty = new SmartyWifidog(); 
     163                $this->smarty = SmartyWifidog::getObject(); 
    149164 
    150165                // Set default title 
     
    167182         * content_available_display_areas table 
    168183         * 
    169          * @param string $content HTML content to be added to the area 
     184         * @param string $content Either a Content object (recommended) or raw HTML content to be added to the area 
    170185         * 
    171186         * @param integer $display_order_index The order in which the content should 
     
    198213        } 
    199214 
    200         /** 
     215        /** Main processing function do generate the final content. 
     216         * It will successively call prepareGetUserUI() on all content objects,  
     217         * and then getUserUI() on all objects.  Note that the point of calling 
     218         * prepareGetUserUI is to allow that function to call methods of MainUI  
     219         * (such ans changing headers, etc.).  However, please note that you should not  
     220         * call MainUI::addContent() from prepareGetUserUI, as prepareGetUserUI() wouldn't 
     221         * in turn get called on objects added this way. 
    201222         * Orders the content and put it in the _contentDisplayArray array 
    202223         * 
     
    210231                        "_contentArrayCmp" 
    211232                )); 
     233                 
     234                //Fist pass (preparation pass) 
    212235                foreach ($this->_contentArray as $content_fragment) 
    213236                { 
    214                         $this->_contentDisplayArray[$content_fragment['display_area']] .= $content_fragment['content']; 
     237                        $content=$content_fragment['content']; 
     238 
     239                if (is_object($content)) 
     240                { 
     241                if ($content instanceof Content) 
     242                        { 
     243                            //echo "<h1>prepareGetUserUI on ".$content->getId()."</h1>"; 
     244                                $content->prepareGetUserUI(); 
     245                        } 
     246                        else 
     247                        { 
     248                        throw new exception ("Object must be a subclass of Content"); 
     249                        } 
     250                } 
     251 
     252                } 
     253                foreach ($this->_contentArray as $content_fragment) 
     254                { 
     255                    $content=$content_fragment['content']; 
     256                        if (is_object($content)) 
     257                { 
     258                        if ($content instanceof Content) 
     259                        { 
     260                                $this->_contentDisplayArray[$content_fragment['display_area']] .= $content->getUserUI(); 
     261                        } 
     262                        else 
     263                        { 
     264                        throw new exception ("Object must be a subclass of Content"); 
     265                        } 
     266                } 
     267                else 
     268                { 
     269                    $this->_contentDisplayArray[$content_fragment['display_area']] .= $content; 
     270                } 
    215271                } 
    216272 
     
    225281        private function addEverywhereContent() 
    226282        { 
    227                 global $db; 
     283                $db = AbstractDb::getObject(); 
    228284                // Get all network content and node "everywhere" content 
    229285                $content_rows = null; 
     
    248304                                if ($content->isDisplayableAt($node)) 
    249305                                { 
    250                                         $this->addContent($content_row['display_area'], $content->getUserUI(), $content_row['display_order']); 
     306                                        $this->addContent($content_row['display_area'], $content, $content_row['display_order']); 
    251307                                } 
    252308                        } 
     
    344400                $this->_htmlHeaders = $headers_string; 
    345401        } 
    346  
     402         
     403        /** 
     404         * Add a stylesheet URL to the main page 
     405         * 
     406         * @param string Stylesheet URL 
     407         * 
     408         * @return void 
     409         * 
     410         * @access public 
     411         */ 
     412        public function appendStylesheetURL($stylesheet_url) 
     413        { 
     414            //Note:  using the URL as value AND key will remove duplicate while keeping the stylesheet inclusion order, because of the way foreach is implemented in PHP 
     415                $this->stylesheetUrlArray[$stylesheet_url] = $stylesheet_url; 
     416        } 
    347417        /** 
    348418         * Set the section to be displayed in the tool pane 
     
    428498        private function getToolContent() 
    429499        { 
    430                 // Define globals 
    431                 global $session; 
     500                 
     501                $session = Session::getObject(); 
    432502                global $AVAIL_LOCALE_ARRAY; 
    433503 
     
    572642        public function display() 
    573643        { 
    574  
    575644                // Init values 
    576  
     645                // Asign base CSS and theme pack CSS stylesheet 
     646                $this->appendStylesheetURL(BASE_THEME_URL . STYLESHEET_NAME); 
     647                $networkThemePack = Network :: getCurrentNetwork()->getThemePack(); 
     648                if ($networkThemePack) { 
     649                                $this->appendStylesheetURL($networkThemePack->getStylesheetUrl()); 
     650                } 
     651                 
     652                //Handle content (must be done before headers and anything else is handled) 
     653                /* 
     654                 * Build tool pane if it has been enabled 
     655                 */ 
     656                if ($this->isToolSectionEnabled()) 
     657                { 
     658                        $this->addContent('left_area_top', $this->getToolContent()); 
     659                } 
     660                $this->addEverywhereContent(); 
     661                $this->generateDisplayContent(); 
     662                 
    577663                // Add SQL queries log 
    578664                if(defined("LOG_SQL_QUERIES") && LOG_SQL_QUERIES == true) 
     
    581667                // Init ALL smarty values 
    582668                $this->smarty->assign('htmlHeaders', ""); 
    583                 $this->smarty->assign('title', ""); 
    584                 $this->smarty->assign('stylesheetURL', ""); 
    585669                // $this->smarty->assign('isSuperAdmin', false); 
    586670                // $this->smarty->assign('isOwner', false); 
     
    597681                // Asign CSS class for body 
    598682                $this->smarty->assign('page_name', $this->_pageName); 
    599  
    600                 // Asign path to CSS stylesheets 
    601                 $stylesheetUrlArray[] = BASE_THEME_URL . STYLESHEET_NAME; 
    602                 $networkThemePack = Network :: getCurrentNetwork()->getThemePack(); 
    603                 if ($networkThemePack) 
    604                 { 
    605                         $stylesheetUrlArray[] = $networkThemePack->getStylesheetUrl(); 
    606                 } 
    607                 $this->smarty->assign('stylesheetUrlArray', $stylesheetUrlArray); 
     683                 
     684                $this->smarty->assign('stylesheetUrlArray', $this->stylesheetUrlArray); 
    608685 
    609686                /* 
     
    615692                User :: assignSmartyValues($this->smarty); 
    616693 
    617                 //Handle content 
    618  
    619                 $this->addContent('page_header', $this->customBanner()); 
    620                 /* 
    621                  * Build tool pane if it has been enabled 
    622                  */ 
    623                 if ($this->isToolSectionEnabled()) 
    624                 { 
    625                         $this->addContent('left_area_top', $this->getToolContent()); 
    626                 } 
    627                 $this->addEverywhereContent(); 
    628                 $this->generateDisplayContent(); 
    629694                // Provide the content array to Smarty 
    630695                $this->smarty->assign('contentDisplayArray', $this->_contentDisplayArray); 
     
    684749                echo "<html>\n" . "<head><meta http-equiv='Refresh' content='$timeout; URL=$redirect_url'/></head>\n" . "<body>\n" . "<noscript>\n" . "<span style='display:none;'>\n" . "<h1>" . $redirect_to_title . "</h1>\n" . sprintf(_("Click <a href='%s'>here</a> to continue"), $redirect_url) . "<br/>\n" . _("The transfer from secure login back to regular http may cause a warning.") . "\n" . "</span>\n" . "</noscript>\n" . "</body>\n" . "</html>\n"; 
    685750                exit; 
    686         } 
    687  
    688         public function customBanner() 
    689         { 
    690                 $custom_banner = ''; 
    691  
    692                 return $custom_banner; 
    693751        } 
    694752} 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r1124 r1127  
    109109    { 
    110110        $retval = array (); 
    111         global $db; 
     111        $db = AbstractDb::getObject(); 
    112112        $sql = "SELECT network_id FROM networks ORDER BY is_default_network DESC"; 
    113113        $network_rows = null; 
     
    135135    { 
    136136        $retval = null; 
    137         global $db; 
     137        $db = AbstractDb::getObject(); 
    138138        $sql = "SELECT network_id FROM networks WHERE is_default_network=TRUE ORDER BY creation_date LIMIT 1"; 
    139139        $network_row = null; 
     
    188188    public static function createNewObject($network_id = null) 
    189189    { 
    190         global $db; 
     190        $db = AbstractDb::getObject(); 
    191191        if (empty ($network_id)) { 
    192192            $network_id = get_guid(); 
     
    231231        } 
    232232 
    233         global $db; 
     233        $db = AbstractDb::getObject(); 
    234234        $additional_where = $db->escapeString($additional_where); 
    235235        $sql = "SELECT network_id, name FROM networks WHERE 1=1 $additional_where ORDER BY is_default_network DESC"; 
     
    329329                    } 
    330330                } catch (Exception $e) { 
    331                     $ui = new MainUI(); 
     331                    $ui = MainUI::getObject(); 
    332332                    $ui->setToolSection('ADMIN'); 
    333333                    $ui->displayError($e->getMessage(), false); 
     
    353353    private function __construct($p_network_id) 
    354354    { 
    355         // Define globals 
    356         global $db; 
     355         
     356        $db = AbstractDb::getObject(); 
    357357 
    358358        $network_id_str = $db->escapeString($p_network_id); 
     
    406406 
    407407        if ($value != $this->getName()) { 
    408             global $db; 
     408            $db = AbstractDb::getObject(); 
    409409            $value = $db->escapeString($value); 
    410410            $retval = $db->execSqlUpdate("UPDATE networks SET tech_support_email = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     
    442442 
    443443        if ($value != $this->getName()) { 
    444             global $db; 
     444            $db = AbstractDb::getObject(); 
    445445            $value = $db->escapeString($value); 
    446446            $retval = $db->execSqlUpdate("UPDATE networks SET name = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     
    482482 
    483483        if ($value != $this->getThemePack()) { 
    484             global $db; 
     484            $db = AbstractDb::getObject(); 
    485485            empty($value)?$value="NULL":$value="'".$db->escapeString($value->getId())."'"; 
    486486            $retval = $db->execSqlUpdate("UPDATE networks SET theme_pack = {$value} WHERE network_id = '{$this->getId()}'", false); 
     
    512512    public function setCreationDate($value) 
    513513    { 
    514         // Define globals 
    515         global $db; 
     514         
     515        $db = AbstractDb::getObject(); 
    516516 
    517517        // Init values 
     
    554554 
    555555        if ($value != $this->getName()) { 
    556             global $db; 
     556            $db = AbstractDb::getObject(); 
    557557            $value = $db->escapeString($value); 
    558558            $retval = $db->execSqlUpdate("UPDATE networks SET homepage_url = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     
    585585    public function setAuthenticatorClassName($value) 
    586586    { 
    587         // Define globals 
    588         global $db; 
     587         
     588        $db = AbstractDb::getObject(); 
    589589 
    590590        // Init values 
     
    621621    public function setAuthenticatorConstructorParams($value) 
    622622    { 
    623         // Define globals 
    624         global $db; 
     623         
     624        $db = AbstractDb::getObject(); 
    625625 
    626626        // init values 
     
    735735    public static function getSelectAuthenticator($user_prefix, $pre_selected_authenticator = null) 
    736736    { 
    737         // Define globals 
    738         global $db; 
     737         
     738        $db = AbstractDb::getObject(); 
    739739 
    740740        // Init values 
     
    788788 
    789789        if (!$this->isDefaultNetwork()) { 
    790             global $db; 
     790            $db = AbstractDb::getObject(); 
    791791            $sql = "UPDATE networks SET is_default_network = FALSE;\n"; 
    792792            $sql .= "UPDATE networks SET is_default_network = TRUE WHERE network_id = '{$this->getId()}';\n"; 
     
    828828 
    829829        if ($value != $this->getValidationGraceTime()) { 
    830             global $db; 
     830            $db = AbstractDb::getObject(); 
    831831            $value = $db->escapeString($value); 
    832832            $retval = $db->execSqlUpdate("UPDATE networks SET validation_grace_time = '{$value} seconds' WHERE network_id = '{$this->getId()}'", false); 
     
    864864 
    865865        if ($value != $this->getValidationEmailFromAddress()) { 
    866             global $db; 
     866            $db = AbstractDb::getObject(); 
    867867            $value = $db->escapeString($value); 
    868868            $retval = $db->execSqlUpdate("UPDATE networks SET validation_email_from_address = '{$value}' WHERE network_id = '{$this->getId()}'", false); 
     
    900900 
    901901        if ($value != $this->getMultipleLoginAllowed()) { 
    902             global $db; 
     902            $db = AbstractDb::getObject(); 
    903903            $value ? $value = 'TRUE' : $value = 'FALSE'; 
    904904            $retval = $db->execSqlUpdate("UPDATE networks SET allow_multiple_login = {$value} WHERE network_id = '{$this->getId()}'", false); 
     
    936936 
    937937        if ($value != $this->getSplashOnlyNodesAllowed()) { 
    938             global $db; 
     938            $db = AbstractDb::getObject(); 
    939939            $value ? $value = 'TRUE' : $value = 'FALSE'; 
    940940            $retval = $db->execSqlUpdate("UPDATE networks SET allow_splash_only_nodes = {$value} WHERE network_id = '{$this->getId()}'", false); 
     
    964964    public function setGisLocation($pt) 
    965965    { 
    966         // Define globals 
    967         global $db; 
     966         
     967        $db = AbstractDb::getObject(); 
    968968 
    969969        if (!empty ($pt)) { 
     
    10021002    public function setGisMapType($value) 
    10031003    { 
    1004         // Define globals 
    1005         global $db; 
     1004         
     1005        $db = AbstractDb::getObject(); 
    10061006 
    10071007        // Init values 
     
    10301030    public static function getSelectGisMapType($user_prefix, $pre_selected_map_type = "G_NORMAL_MAP") 
    10311031    { 
    1032         // Define globals 
    1033         global $db; 
     1032         
     1033        $db = AbstractDb::getObject(); 
    10341034 
    10351035        // Init values 
     
    10821082    public function getNumUsers() 
    10831083    { 
    1084         // Define globals 
    1085         global $db; 
     1084         
     1085        $db = AbstractDb::getObject(); 
    10861086 
    10871087        // Init values 
     
    11301130    public function getNumValidUsers() 
    11311131    { 
    1132         // Define globals 
    1133         global $db; 
     1132         
     1133        $db = AbstractDb::getObject(); 
    11341134 
    11351135        // Init values 
     
    11791179    public function getNumOnlineUsers() 
    11801180    { 
    1181         // Define globals 
    1182         global $db; 
     1181         
     1182        $db = AbstractDb::getObject(); 
    11831183 
    11841184        // Init values 
     
    12271227    public function getNumNodes() 
    12281228    { 
    1229         // Define globals 
    1230         global $db; 
     1229         
     1230        $db = AbstractDb::getObject(); 
    12311231 
    12321232        // Init values 
     
    12751275    public function getNumDeployedNodes() 
    12761276    { 
    1277         // Define globals 
    1278         global $db; 
     1277         
     1278        $db = AbstractDb::getObject(); 
    12791279 
    12801280        // Init values 
     
    13251325    public function getNumOnlineNodes($nonMonitoredOnly = false) 
    13261326    { 
    1327         // Define globals 
    1328         global $db; 
     1327         
     1328        $db = AbstractDb::getObject(); 
    13291329 
    13301330        // Init values 
     
    14041404 
    14051405        if ($value != $this->getCustomPortalRedirectAllowed()) { 
    1406             global $db; 
     1406            $db = AbstractDb::getObject(); 
    14071407            $value ? $value = 'TRUE' : $value = 'FALSE'; 
    14081408            $retval = $db->execSqlUpdate("UPDATE networks SET allow_custom_portal_redirect = {$value} WHERE network_id = '{$this->getId()}'", false); 
     
    14221422    public function hasAdminAccess(User $user) 
    14231423    { 
    1424         // Define globals 
    1425         global $db; 
     1424         
     1425        $db = AbstractDb::getObject(); 
    14261426 
    14271427        // Init values 
     
    14571457    /*public function getAllContent($exclude_subscribed_content = false, $subscriber = null) 
    14581458    { 
    1459         // Define globals 
    1460         global $db; 
     1459         
     1460        $db = AbstractDb::getObject(); 
    14611461 
    14621462        // Init values 
     
    17921792    public function addContent(Content $content) 
    17931793    { 
    1794         // Define globals 
    1795         global $db; 
     1794         
     1795        $db = AbstractDb::getObject(); 
    17961796 
    17971797        $content_id = $db->escapeString($content->getId()); 
     
    18111811    public function removeContent(Content $content) 
    18121812    { 
    1813         // Define globals 
    1814         global $db; 
     1813         
     1814        $db = AbstractDb::getObject(); 
    18151815 
    18161816        $content_id = $db->escapeString($content->getId()); 
     
    18401840                $errmsg = _('Cannot delete default network, create another one and select it before remove this one.'); 
    18411841            } else { 
    1842                 global $db; 
     1842                $db = AbstractDb::getObject(); 
    18431843                $id = $db->escapeString($this->getId()); 
    18441844                if (!$db->execSqlUpdate("DELETE FROM networks WHERE network_id='{$id}'", false)) { 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1123 r1127  
    128128        public static function getCurrentRealNode() 
    129129        { 
    130                 global $db; 
     130                $db = AbstractDb::getObject(); 
    131131                $retval = null; 
    132132                $sql = "SELECT node_id, last_heartbeat_ip from nodes WHERE last_heartbeat_ip='$_SERVER[REMOTE_ADDR]' ORDER BY last_heartbeat_timestamp DESC"; 
     
    175175                $user = User :: getCurrentUser(); 
    176176                if ($user->isSuperAdmin()) { 
    177                         global $db; 
     177                        $db = AbstractDb::getObject(); 
    178178                        $id = $db->escapeString($this->getId()); 
    179179                        if (!$db->execSqlUpdate("DELETE FROM nodes WHERE node_id='{$id}'", false)) 
     
    210210        public static function createNewObject($node_id = null, $network = null) 
    211211        { 
    212             // Define globals 
    213                 global $db; 
     212             
     213                $db = AbstractDb::getObject(); 
    214214 
    215215                if (empty ($node_id)) { 
     
    250250        public static function getSelectNodeUI($user_prefix, $sql_additional_where = null,$type_interface = "select") 
    251251        { 
    252                 global $db; 
     252                $db = AbstractDb::getObject(); 
    253253                $html = ''; 
    254254                $name = "{$user_prefix}"; 
     
    374374                                } 
    375375                } catch (Exception $e) { 
    376                     $ui = new MainUI(); 
     376                    $ui = MainUI::getObject(); 
    377377                    $ui->setToolSection('ADMIN'); 
    378378                    $ui->displayError($e->getMessage(), false); 
     
    397397        public function getSelectDeploymentStatus($user_prefix) 
    398398        { 
    399             // Define globals 
    400                 global $db; 
     399             
     400                $db = AbstractDb::getObject(); 
    401401 
    402402                // Init values 
     
    442442        private function __construct($node_id) 
    443443        { 
    444                 global $db; 
     444                $db = AbstractDb::getObject(); 
    445445                $this->mDb = & $db; 
    446446 
     
    762762                if ($value != $this->isConfiguredSplashOnly()) 
    763763                { 
    764                         global $db; 
     764                        $db = AbstractDb::getObject(); 
    765765                        $value ? $value = 'TRUE' : $value = 'FALSE'; 
    766766                        $retval = $db->execSqlUpdate("UPDATE nodes SET is_splash_only_node = {$value} WHERE node_id = '{$this->getId()}'", false); 
     
    786786                if ($value != $this->getCustomPortalRedirectUrl()) 
    787787                { 
    788                         global $db; 
     788                        $db = AbstractDb::getObject(); 
    789789                        $value = $db->escapeString($value); 
    790790                        $retval = $db->execSqlUpdate("UPDATE nodes SET custom_portal_redirect_url = '{$value}' WHERE node_id = '{$this->getId()}'", false); 
     
    12731273        public function addContent(Content $content) 
    12741274        { 
    1275                 global $db; 
     1275                $db = AbstractDb::getObject(); 
    12761276                $content_id = $db->escapeString($content->getId()); 
    12771277                $sql = "INSERT INTO node_has_content (node_id, content_id) VALUES ('$this->id','$content_id')"; 
     
    12831283        public function removeContent(Content $content) 
    12841284        { 
    1285                 global $db; 
     1285                $db = AbstractDb::getObject(); 
    12861286                $content_id = $db->escapeString($content->getId()); 
    12871287                $sql = "DELETE FROM node_has_content WHERE node_id='$this->id' AND content_id='$content_id'"; 
     
    12971297        /*function getAllContent($exclude_subscribed_content = false, $subscriber = null, $display_page = 'portal') 
    12981298        { 
    1299                 global $db; 
     1299                $db = AbstractDb::getObject(); 
    13001300                $retval = array (); 
    13011301                $content_rows = null; 
     
    13211321        function getAllLocativeArtisticContent() 
    13221322        { 
    1323                 global $db; 
     1323                $db = AbstractDb::getObject(); 
    13241324                $retval = array (); 
    13251325                $sql = "SELECT * FROM content_group JOIN content ON (content.content_id = content_group.content_group_id) JOIN node_has_content ON (node_has_content.content_id = content_group.content_group_id AND node_has_content.node_id = '{$this->getId()}') WHERE is_persistent = true AND is_artistic_content = true AND is_locative_content = true ORDER BY subscribe_timestamp DESC"; 
     
    13561356        public function getOnlineUsers() 
    13571357        { 
    1358             // Define globals 
    1359                 global $db; 
     1358             
     1359                $db = AbstractDb::getObject(); 
    13601360 
    13611361                // Init values 
     
    13841384        public function getNumOnlineUsers() 
    13851385        { 
    1386             // Define globals 
    1387                 global $db; 
     1386             
     1387                $db = AbstractDb::getObject(); 
    13881388 
    13891389                // Init values 
     
    14041404        function getOwners() 
    14051405        { 
    1406                 global $db; 
     1406                $db = AbstractDb::getObject(); 
    14071407                $retval = array (); 
    14081408                $owners = null; 
     
    14241424        function getTechnicalOfficers() 
    14251425        { 
    1426                 global $db; 
     1426                $db = AbstractDb::getObject(); 
    14271427                $retval = array (); 
    14281428                $officers = null; 
     
    14431443        function addOwner(User $user) 
    14441444        { 
    1445                 global $db; 
     1445                $db = AbstractDb::getObject(); 
    14461446                $rows = null; 
    14471447                $db->execSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); 
     
    14611461        function addTechnicalOfficer(User $user) 
    14621462        { 
    1463                 global $db; 
     1463                $db = AbstractDb::getObject(); 
    14641464                $rows = null; 
    14651465                $db->execSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); 
     
    14791479        function removeOwner(User $user) 
    14801480        { 
    1481                 global $db; 
     1481                $db = AbstractDb::getObject(); 
    14821482                if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_owner = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 
    14831483                        throw new Exception(_('Could not remove owner')); 
     
    14891489        function removeTechnicalOfficer(User $user) 
    14901490        { 
    1491                 global $db; 
     1491                $db = AbstractDb::getObject(); 
    14921492                if (!$db->execSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 
    14931493                        throw new Exception(_('Could not remove tech officer')); 
     
    14981498        function isOwner(User $user) 
    14991499        { 
    1500                 global $db; 
     1500                $db = AbstractDb::getObject(); 
    15011501                if ($user != null) 
    15021502                { 
     
    15171517        function isTechnicalOfficer(User $user) 
    15181518        { 
    1519                 global $db; 
     1519                $db = AbstractDb::getObject(); 
    15201520                if ($user != null) 
    15211521                { 
     
    15441544        private static function nodeExists($id) 
    15451545        { 
    1546             // Define globals 
    1547                 global $db; 
     1546             
     1547                $db = AbstractDb::getObject(); 
    15481548 
    15491549                // Init values 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListHTML.php

    r1123 r1127  
    109109    public function __construct(&$network) 
    110110    { 
    111         // Define globals 
    112         global $db; 
    113         global $smarty; 
     111         
     112        $db = AbstractDb::getObject(); 
     113        $smarty = SmartyWifidog::getObject(); 
    114114 
    115115        // Init Smarty 
     
    123123 
    124124        // Init MainUI class 
    125         $this->_mainUI = new MainUI(); 
     125        $this->_mainUI = MainUI::getObject(); 
    126126 
    127127        // Query the database, sorting by node name 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListJiWireCSV.php

    r1123 r1127  
    8787    public function __construct(&$network) 
    8888    { 
    89         // Define globals 
    90         global $db; 
     89         
     90        $db = AbstractDb::getObject(); 
    9191 
    9292        // Init network 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListKML.php

    r1123 r1127  
    9292    public function __construct(&$network) 
    9393    { 
    94         // Define globals 
    95         global $db; 
     94         
     95        $db = AbstractDb::getObject(); 
    9696 
    9797        // Init XML Document 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListPDF.php

    r1123 r1127  
    787787        } 
    788788    } else { 
    789         $ui = new MainUI(); 
     789        $ui = MainUI::getObject(); 
    790790 
    791791        $errmsg = _("To protect the server the PDF file has not been created, because the server is too busy right now!"); 
     
    795795    } 
    796796} else { 
    797     $ui = new MainUI(); 
     797    $ui = MainUI::getObject(); 
    798798 
    799799    $errmsg = _("PDF file cannot be created because the FPDF library is not installed!"); 
     
    892892    public function __construct(&$network) 
    893893    { 
    894         // Define globals 
    895         global $db; 
     894         
     895        $db = AbstractDb::getObject(); 
    896896 
    897897        // Init network 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListRSS.php

    r1123 r1127  
    9191    public function __construct(&$network) 
    9292    { 
    93         // Define globals 
    94         global $db; 
     93         
     94        $db = AbstractDb::getObject(); 
    9595 
    9696        // Init XML Document 
     
    135135    public function getOutput($return_object = false) 
    136136    { 
    137         // Define globals 
    138         global $db; 
     137         
     138        $db = AbstractDb::getObject(); 
    139139 
    140140        // Root node 
  • trunk/wifidog-auth/wifidog/classes/NodeLists/NodeListXML.php

    r1123 r1127  
    9090    public function __construct(&$network) 
    9191    { 
    92         // Define globals 
    93         global $db; 
     92         
     93        $db = AbstractDb::getObject(); 
    9494 
    9595        // Init XML Document 
  • trunk/wifidog-auth/wifidog/classes/Server.php

    r1096 r1127  
    8282        private function __construct($p_server_id) 
    8383        { 
    84             // Define globals 
    85                 global $db; 
     84             
     85                $db = AbstractDb::getObject(); 
    8686 
    8787                // Init values 
     
    137137        public static function getAllServers() 
    138138        { 
    139             // Define globals 
    140                 global $db; 
     139             
     140                $db = AbstractDb::getObject(); 
    141141 
    142142            // Init values 
     
    169169        public static function getDefaultServer($silent=false) 
    170170        { 
    171             // Define globals 
    172                 global $db; 
     171             
     172                $db = AbstractDb::getObject(); 
    173173 
    174174                // Init values 
     
    211211            return null; //We were probably called from the command line 
    212212        } 
    213             // Define globals 
    214                 global $db; 
     213             
     214                $db = AbstractDb::getObject(); 
    215215 
    216216                // Init values 
     
    245245        public static function createNewObject($server_id = null) 
    246246        { 
    247             // Define globals 
    248                 global $db; 
     247             
     248                $db = AbstractDb::getObject(); 
    249249 
    250250                if (empty($server_id)) { 
     
    284284    public static function getSelectServerUI($user_prefix, $pre_selected_server = null, $additional_where = null) 
    285285    { 
    286         // Define globals 
    287                 global $db; 
     286         
     287                $db = AbstractDb::getObject(); 
    288288 
    289289        // Init values 
     
    428428        public function setName($value) 
    429429        { 
    430             // Define globals 
    431                 global $db; 
     430             
     431                $db = AbstractDb::getObject(); 
    432432 
    433433            // Init values 
     
    464464        public function setCreationDate($value) 
    465465        { 
    466             // Define globals 
    467                 global $db; 
     466             
     467                $db = AbstractDb::getObject(); 
    468468 
    469469            // Init values 
     
    498498        public function setHostname($value) 
    499499        { 
    500             // Define globals 
    501                 global $db; 
     500             
     501                $db = AbstractDb::getObject(); 
    502502 
    503503                // Init values 
     
    540540        public function setAsDefaultServer() 
    541541        { 
    542             // Define globals 
    543                 global $db; 
     542             
     543                $db = AbstractDb::getObject(); 
    544544 
    545545            // Init values 
     
    582582        public function setSSLAvailable($value) 
    583583        { 
    584             // Define globals 
    585                 global $db; 
     584             
     585                $db = AbstractDb::getObject(); 
    586586 
    587587            // Init values 
     
    621621        public function setGoogleAPIKey($value) 
    622622        { 
    623             // Define globals 
    624                 global $db; 
     623             
     624                $db = AbstractDb::getObject(); 
    625625 
    626626                // Init values 
     
    755755                } 
    756756        } catch (Exception $e) { 
    757             $ui = new MainUI(); 
     757            $ui = MainUI::getObject(); 
    758758            $ui->setToolSection('ADMIN'); 
    759759            $ui->displayError($e->getMessage(), false); 
     
    804804        { 
    805805            require_once('classes/User.php'); 
    806         // Define globals 
    807                 global $db; 
     806         
     807                $db = AbstractDb::getObject(); 
    808808 
    809809            // Init values 
  • trunk/wifidog-auth/wifidog/classes/Session.php

    r1090 r1127  
    5151class Session 
    5252{ 
    53  
     53    private static $object; 
     54    public static function getObject() { 
     55        if (self::$object==null) 
     56        { 
     57                self::$object=new self(); 
     58        } 
     59        return self::$object; 
     60    } 
    5461    /** 
    5562     * Constructor 
     
    5764     * @return void 
    5865     */ 
    59     public function __construct() 
     66    private function __construct() 
    6067    { 
    6168        $session_id = session_id(); 
  • trunk/wifidog-auth/wifidog/classes/SmartyWifidog.php

    r1090 r1127  
    123123 */ 
    124124class SmartyWifidog extends Smarty { 
    125  
    126    function __construct() 
     125    private static $object; 
     126    public static function getObject() { 
     127        if (self::$object==null) 
     128        { 
     129                self::$object=new self(); 
     130        } 
     131        return self::$object; 
     132    } 
     133   private function __construct() 
    127134   { 
    128135 
     
    130137 
    131138        $this->Smarty(); 
    132  
    133         $this->template_dir = WIFIDOG_ABS_FILE_PATH; 
     139                //Now that we have user-definable templates, we must turn on security 
     140                $this->security = true; 
     141                //pretty_print_r($this->security_settings); 
     142                $this->security_settings['MODIFIER_FUNCS'][] = 'sprintf'; 
     143                $this->template_dir = WIFIDOG_ABS_FILE_PATH; 
    134144        $this->compile_dir = $this->template_dir . 'tmp/smarty/templates_c/'; 
    135145        $this->config_dir = $this->template_dir . 'tmp/smarty/configs/'; 
  • trunk/wifidog-auth/wifidog/classes/StatisticGraph.php

    r1075 r1127  
    9393    protected function __construct() 
    9494    { 
    95         $session = new Session(); 
     95        $session = Session::getObject(); 
    9696        self :: $stats = $session->get('current_statistics_object'); 
    9797    } 
     
    106106    public function getReportUI(Statistics $statistics_object, $child_html = null) 
    107107    { 
    108         $session = new Session(); 
     108        $session = Session::getObject(); 
    109109        $session->set('current_statistics_object', $statistics_object); 
    110110        self :: $stats = $statistics_object; /* Update it in case someone whants to use it right now */ 
  • trunk/wifidog-auth/wifidog/classes/StatisticGraph/ConnectionsPerHour.php

    r1013 r1127  
    7777    { 
    7878        require_once ("Image/Graph.php"); 
    79         global $db; 
     79        $db = AbstractDb::getObject(); 
    8080 
    8181$Graph =& Image_Graph::factory("Image_Graph", array(600, 200)); 
  • trunk/wifidog-auth/wifidog/classes/StatisticGraph/RegistrationsCumulative.php

    r1013 r1127  
    7777    { 
    7878        require_once ("Image/Graph.php"); 
    79         global $db; 
     79        $db = AbstractDb::getObject(); 
    8080 
    8181        $Graph = & Image_Graph :: factory("Image_Graph", array (600, 200)); 
  • trunk/wifidog-auth/wifidog/classes/StatisticGraph/RegistrationsPerMonth.php

    r1013 r1127  
    7777    { 
    7878        require_once ("Image/Graph.php"); 
    79         global $db; 
     79        $db = AbstractDb::getObject(); 
    8080 
    8181        $Graph = & Image_Graph :: factory("Image_Graph", array (600, 200)); 
  • trunk/wifidog-auth/wifidog/classes/StatisticGraph/VisitsPerMonth.php

    r1013 r1127  
    9292    { 
    9393        require_once ("Image/Graph.php"); 
    94         global $db; 
     94        $db = AbstractDb::getObject(); 
    9595$Graph =& Image_Graph::factory("Image_Graph", array(600, 200)); 
    9696$Plotarea =& $Graph->add(Image_Graph::factory("Image_Graph_Plotarea")); 
  • trunk/wifidog-auth/wifidog/classes/StatisticGraph/VisitsPerWeekday.php

    r1013 r1127  
    9292    { 
    9393        require_once ("Image/Graph.php"); 
    94         global $db; 
     94        $db = AbstractDb::getObject(); 
    9595 
    9696        $Graph = & Image_Graph :: factory("Image_Graph", array (600, 200)); 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/ConnectionGraphs.php

    r1031 r1127  
    7878    public function getReportUI($child_html = null) 
    7979    { 
    80         global $db; 
     80        $db = AbstractDb::getObject(); 
    8181        $html = ''; 
    8282 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/ConnectionLog.php

    r1037 r1127  
    8080    public function getReportUI($child_html = null) 
    8181    { 
    82         global $db; 
     82        $db = AbstractDb::getObject(); 
    8383        $html = ''; 
    8484 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/HighestBandwidthUsers.php

    r1013 r1127  
    8181    public function getReportUI($child_html = null) 
    8282    { 
    83         global $db; 
     83        $db = AbstractDb::getObject(); 
    8484        $html = ''; 
    8585        $distinguish_users_by = $this->stats->getDistinguishUsersBy(); 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/MostFrequentUsers.php

    r1013 r1127  
    8282    public function getReportUI($child_html = null) 
    8383    { 
    84         global $db; 
     84        $db = AbstractDb::getObject(); 
    8585        $html = ''; 
    8686        $distinguish_users_by = $this->stats->getDistinguishUsersBy(); 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/MostMobileUsers.php

    r1013 r1127  
    8181    public function getReportUI($child_html = null) 
    8282    { 
    83         global $db; 
     83        $db = AbstractDb::getObject(); 
    8484        $html = ''; 
    8585        $distinguish_users_by = $this->stats->getDistinguishUsersBy(); 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/MostPopularNodes.php

    r1013 r1127  
    8181    public function getReportUI($child_html = null) 
    8282    { 
    83         global $db; 
     83        $db = AbstractDb::getObject(); 
    8484        $html = ''; 
    8585        $node_usage_stats = null; 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/NetworkStatus.php

    r1037 r1127  
    8080    public function getReportUI($child_html = null) 
    8181    { 
    82         global $db; 
     82        $db = AbstractDb::getObject(); 
    8383        $html = ''; 
    8484        $selected_network = $this->stats->getSelectedNetworks(); 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/NodeStatus.php

    r1123 r1127  
    8080    public function getReportUI($child_html = null) 
    8181    { 
    82         global $db; 
     82        $db = AbstractDb::getObject(); 
    8383        $html = ''; 
    8484        $selected_nodes = $this->stats->getSelectedNodes(); 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/RegistrationLog.php

    r1075 r1127  
    8080    public function getReportUI($child_html = null) 
    8181    { 
    82         global $db; 
     82        $db = AbstractDb::getObject(); 
    8383        $html = ''; 
    8484        /* Users who signed up here */ 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/UserRegistrationReport.php

    r1075 r1127  
    7878    public function getReportUI($child_html = null) 
    7979    { 
    80         global $db; 
     80        $db = AbstractDb::getObject(); 
    8181        $html = ''; 
    8282        /* Monthly registration graph */ 
  • trunk/wifidog-auth/wifidog/classes/StatisticReport/UserReport.php

    r1114 r1127  
    8080    public function getReportUI($child_html = null) 
    8181    { 
    82         // Define globals 
    83         global $db; 
     82         
     83        $db = AbstractDb::getObject(); 
    8484        global $account_status_to_text; 
    8585        global $token_to_text; 
  • trunk/wifidog-auth/wifidog/classes/Statistics.php

    r1124 r1127  
    216216    public function getSqlDateConstraint($column = 'timestamp_in') 
    217217    { 
    218         global $db; 
     218        $db = AbstractDb::getObject(); 
    219219        $column = $db->escapeString($column); 
    220220        $sql = ''; 
     
    239239    public function getSqlNodeConstraint($column) 
    240240    { 
    241         global $db; 
     241        $db = AbstractDb::getObject(); 
    242242        $column = $db->escapeString($column); 
    243243        $sql = ''; 
     
    265265    public function getSqlNetworkConstraint($column) 
    266266    { 
    267         global $db; 
     267        $db = AbstractDb::getObject(); 
    268268        $column = $db->escapeString($column); 
    269269        $sql = ''; 
     
    291291    public function getSqlUserConstraint() 
    292292    { 
    293         global $db; 
     293        $db = AbstractDb::getObject(); 
    294294        $column = $db->escapeString($this->report_distinguish_users_by); 
    295295        $sql = ''; 
     
    381381    private function getSelectedNodesUI() 
    382382    { 
    383         // Define globals 
    384         global $db; 
     383         
     384        $db = AbstractDb::getObject(); 
    385385 
    386386        // Init values 
     
    547547            if ($this->report_distinguish_users_by == 'user_id') 
    548548            { 
    549                     global $db; 
     549                    $db = AbstractDb::getObject(); 
    550550                $username = $db->escapeString($_REQUEST['stats_selected_users']); 
    551551                $row = null; 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r1123 r1127  
    9898    public static function getCurrentUser() { 
    9999        require_once ('classes/Session.php'); 
    100         $session = new Session(); 
     100        $session = Session::getObject(); 
    101101        $user = null; 
    102102        try { 
     
    122122    public static function setCurrentUser(User $user) { 
    123123        try { 
    124             $session = new Session(); 
     124            $session = Session::getObject(); 
    125125            $session->set(SESS_USER_ID_VAR, $user->getId()); 
    126126            $session->set(SESS_PASSWORD_HASH_VAR, $user->getPasswordHash()); 
     
    147147     */ 
    148148    public static function getUserByUsernameAndOrigin($username, Network $account_origin) { 
    149         global $db; 
     149        $db = AbstractDb::getObject(); 
    150150        $object = null; 
    151151 
     
    165165     */ 
    166166    public static function getUserByEmailAndOrigin($email, Network $account_origin) { 
    167         global $db; 
     167        $db = AbstractDb::getObject(); 
    168168        $object = null; 
    169169 
     
    194194     */ 
    195195    static function createUser($id, $username, Network $account_origin, $email, $password) { 
    196         global $db; 
     196        $db = AbstractDb::getObject(); 
    197197 
    198198        $object = null; 
     
    214214    /*    public static function purgeUnvalidatedUsers($days_since_creation) 
    215215        { 
    216             global $db; 
     216            $db = AbstractDb::getObject(); 
    217217            $days_since_creation = $db->escapeString($days_since_creation); 
    218218     
     
    222222    /** @param $object_id The id of the user */ 
    223223    function __construct($object_id) { 
    224         global $db; 
     224        $db = AbstractDb::getObject(); 
    225225        $this->mDb = & $db; 
    226226        $object_id_str = $db->escapeString($object_id); 
     
    282282        $retval = true; 
    283283        if ($value != $this->getUsername()) { 
    284             global $db; 
     284            $db = AbstractDb::getObject(); 
    285285            $value = $db->escapeString($value); 
    286286            $retval = @ $db->execSqlUpdate("UPDATE users SET username = '{$value}' WHERE user_id='{$this->id}'", false); 
     
    308308        $retval = true; 
    309309        if ($value != $this->isAdvertised()) { 
    310             global $db; 
     310            $db = AbstractDb::getObject(); 
    311311            $value ? $value = 'TRUE' : $value = 'FALSE'; 
    312312            $retval = $db->execSqlUpdate("UPDATE users SET is_invisible = {$value} WHERE user_id = '{$this->getId()}'", false); 
     
    322322    /**What locale (language) does the user prefer? */ 
    323323    public function getPreferedLocale() { 
    324         global $session; 
     324        $session = Session::getObject(); 
    325325        $locale = $this->mRow['prefered_locale']; 
    326326        if (empty ($locale) && !empty ($session)) 
     
    352352 
    353353    function setAccountStatus($status) { 
    354         global $db; 
     354        $db = AbstractDb::getObject(); 
    355355 
    356356        $status_str = $db->escapeString($status); 
     
    364364     $errmsg: Returs the reason why the account is or isn't valid */ 
    365365    function isUserValid(& $errmsg = null) { 
    366         global $db; 
     366        $db = AbstractDb::getObject(); 
    367367        $retval = false; 
    368368        $account_status = $this->getAccountStatus(); 
     
    389389 
    390390    public function isSuperAdmin() { 
    391         global $db; 
     391        $db = AbstractDb::getObject(); 
    392392        //$this->session->dump(); 
    393393 
     
    405405     */ 
    406406    public function isOwner() { 
    407         global $db; 
     407        $db = AbstractDb::getObject(); 
    408408        $db->execSql("SELECT * FROM node_stakeholders WHERE is_owner = true AND user_id='{$this->getId()}'", $row, false); 
    409409        if ($row != null) 
     
    414414 
    415415    public function isNobody() { 
    416         global $db; 
     416        $db = AbstractDb::getObject(); 
    417417        $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); 
    418418        if ($row == null) 
     
    439439    function generateConnectionToken() { 
    440440        if ($this->isUserValid()) { 
    441             global $db; 
    442             global $session; 
     441            $db = AbstractDb::getObject(); 
     442            $session = Session::getObject(); 
    443443 
    444444            $token = self :: generateToken(); 
     
    460460 
    461461    function setPassword($password) { 
    462         global $db; 
     462        $db = AbstractDb::getObject(); 
    463463 
    464464        $new_password_hash = User :: passwordHash($password); 
     
    476476     */ 
    477477    static function getAllUsers() { 
    478         global $db; 
     478        $db = AbstractDb::getObject(); 
    479479 
    480480        $db->execSql("SELECT * FROM users", $objects, false); 
     
    532532 
    533533    static function userExists($id) { 
    534         global $db; 
     534        $db = AbstractDb::getObject(); 
    535535        $id_str = $db->escapeString($id); 
    536536        $sql = "SELECT * FROM users WHERE user_id='{$id_str}'"; 
     
    540540 
    541541    public static function emailExists($id) { 
    542         global $db; 
     542        $db = AbstractDb::getObject(); 
    543543        $id_str = $db->escapeString($id); 
    544544        $sql = "SELECT * FROM users WHERE email='{$id_str}'"; 
     
    613613     */ 
    614614    public static function getSelectUserUI($user_prefix, $add_button_name = null, $add_button_value = null) { 
    615         // Define globals 
    616         global $db; 
     615         
     616        $db = AbstractDb::getObject(); 
    617617 
    618618        $_networkSelector = InterfaceElements :: generateDiv(Network :: getSelectNetworkUI($user_prefix), "admin_section_network_selector", "admin_section_network_selector_" . $user_prefix); 
     
    652652 
    653653    public function getAdminUI() { 
    654         global $db; 
     654        $db = AbstractDb::getObject(); 
    655655        $currentUser = self :: getCurrentUser(); 
    656656        $html = ''; 
     
    690690 
    691691    public function processAdminUI() { 
    692         global $db; 
     692        $db = AbstractDb::getObject(); 
    693693        $currentUser = self :: getCurrentUser(); 
    694694        if ($this == $currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) { 
     
    711711    /** Add content to this user ( subscription ) */ 
    712712    public function addContent(Content $content) { 
    713         global $db; 
     713        $db = AbstractDb::getObject(); 
    714714        $content_id = $db->escapeString($content->getId()); 
    715715        $sql = "INSERT INTO user_has_content (user_id, content_id) VALUES ('$this->id','$content_id')"; 
     
    720720    /** Remove content from this node */ 
    721721    public function removeContent(Content $content) { 
    722         global $db; 
     722        $db = AbstractDb::getObject(); 
    723723        $content_id = $db->escapeString($content->getId()); 
    724724        $sql = "DELETE FROM user_has_content WHERE user_id='$this->id' AND content_id='$content_id'"; 
     
    730730    * @return an array of Content or an empty arrray */ 
    731731    function getAllContent() { 
    732         global $db; 
     732        $db = AbstractDb::getObject(); 
    733733        $retval = array (); 
    734734        $sql = "SELECT * FROM user_has_content WHERE user_id='$this->id' ORDER BY subscribe_timestamp"; 
  • trunk/wifidog-auth/wifidog/clickthrough.php

    r1080 r1127  
    4848require_once (dirname(__FILE__) . '/include/common.php'); 
    4949 
    50 global $db;  
     50$db = AbstractDb::getObject();  
    5151if (!empty ($_REQUEST['destination_url'])) { 
    5252        
  • trunk/wifidog-auth/wifidog/content/PatternLanguage/archives.php

    r1031 r1127  
    5151require_once('classes/Content/PatternLanguage.php'); 
    5252require_once('classes/MainUI.php'); 
    53  
     53$smarty = SmartyWifidog::getObject(); 
     54$session = Session::getObject(); 
    5455// This trick is done to allow displaying of Pattern Language right away if there is only one available. 
    5556if(!empty($_REQUEST['content_id'])) 
     
    9798$body_html .= "</div>\n"; 
    9899 
    99 $ui = new MainUI(); 
     100$ui = MainUI::getObject(); 
    100101$ui->addContent('left_area_middle', $tool_html); 
    101102$ui->setTitle(_("Pattern Language - Archives")); 
  • trunk/wifidog-auth/wifidog/content/PatternLanguage/hotspots.php

    r1031 r1127  
    5050require_once('classes/MainUI.php'); 
    5151require_once('classes/Content/PatternLanguage.php'); 
    52  
     52$smarty = SmartyWifidog::getObject(); 
     53$session = Session::getObject(); 
    5354// This trick is done to allow displaying of Pattern Language right away if there is only one available. 
    5455if(!empty($_REQUEST['content_id'])) 
     
    102103$body_html .= "</div>\n"; 
    103104 
    104 $ui=new MainUI(); 
     105$ui=MainUI::getObject(); 
    105106$ui->addContent('left_area_middle', $tool_html); 
    106107$ui->setTitle(_("Pattern Language - Hotspots list")); 
  • trunk/wifidog-auth/wifidog/content/PatternLanguage/index.php

    r1031 r1127  
    5050require_once('classes/MainUI.php'); 
    5151require_once('classes/Content/PatternLanguage.php'); 
    52  
     52$smarty = SmartyWifidog::getObject(); 
     53$session = Session::getObject(); 
    5354// This trick is done to allow displaying of Pattern Language right away if there is only one available. 
    5455if(!empty($_REQUEST['content_id'])) 
     
    9293 
    9394 
    94 $ui=new MainUI(); 
     95$ui=MainUI::getObject(); 
    9596$ui->addContent('left_area_middle', $tool_html); 
    9697$ui->setTitle(_("Pattern Language - About")); 
  • trunk/wifidog-auth/wifidog/content/PatternLanguage/narrative.php

    r1031 r1127  
    5151require_once('classes/Content/PatternLanguage.php'); 
    5252require_once('classes/MainUI.php'); 
    53  
     53$smarty = SmartyWifidog::getObject(); 
     54$session = Session::getObject(); 
    5455// This trick is done to allow displaying of Pattern Language right away if there is only one available. 
    5556if(!empty($_REQUEST['content_id'])) 
     
    113114} 
    114115 
    115 $ui = new MainUI(); 
     116$ui = MainUI::getObject(); 
    116117$ui->addContent('left_area_middle', $tool_html); 
    117118$ui->setTitle(_("Pattern Language - Narrative")); 
  • trunk/wifidog-auth/wifidog/content/PatternLanguage/subscription.php

    r1031 r1127  
    5151require_once('classes/Content/PatternLanguage.php'); 
    5252require_once('classes/MainUI.php'); 
    53  
     53$smarty = SmartyWifidog::getObject(); 
     54$session = Session::getObject(); 
    5455// This trick is done to allow displaying of Pattern Language right away if there is only one available. 
    5556if(!empty($_REQUEST['content_id'])) 
     
    141142$body_html .= "</div>\n"; 
    142143 
    143 $ui = new MainUI(); 
     144$ui = MainUI::getObject(); 
    144145$ui->addContent('left_area_middle', $tool_html); 
    145146$ui->setTitle(_("Pattern Language - Subscription")); 
  • trunk/wifidog-auth/wifidog/content/index.php

    r1092 r1127  
    5151require_once('classes/MainUI.php'); 
    5252require_once('include/common_interface.php'); 
     53$smarty = SmartyWifidog::getObject(); 
    5354require_once('classes/Node.php'); 
    5455 
     
    5859 
    5960if ($node == null) { 
    60     $ui = new MainUI(); 
     61    $ui = MainUI::getObject(); 
    6162    $ui->displayError(_("No Hotspot specified!")); 
    6263    exit; 
     
    6768Node :: setCurrentNode($node); 
    6869 
    69 $ui = new MainUI(); 
    70 if (isset ($session)) 
    71 { 
    72     $smarty->assign("original_url_requested", $session->get(SESS_ORIGINAL_URL_VAR)); 
    73 } 
     70$ui = MainUI::getObject(); 
     71$session = Session::getObject(); 
     72$smarty->assign("original_url_requested", $session->get(SESS_ORIGINAL_URL_VAR)); 
    7473 
    7574$tool_html = ''; 
  • trunk/wifidog-auth/wifidog/cron/vacuum.php

    r947 r1127  
    4747require_once(dirname(__FILE__) . '/../include/common.php'); 
    4848 
    49 // Define globals 
    50 global $db; 
     49 
     50$db = AbstractDb::getObject(); 
    5151 
    5252// Run vacuum 
  • trunk/wifidog-auth/wifidog/faq.php

    r1030 r1127  
    5151require_once('include/common_interface.php'); 
    5252require_once('classes/MainUI.php'); 
    53  
    54 $ui = new MainUI(); 
     53$smarty = SmartyWifidog::getObject(); 
     54$ui = MainUI::getObject(); 
    5555$ui->addContent('main_area_middle', $smarty->fetch("templates/faq.html")); 
    5656$ui->display(); 
  • trunk/wifidog-auth/wifidog/file_download.php

    r1074 r1127  
    5050if (!empty ($_REQUEST['file_id'])) 
    5151{ 
    52         global $db; 
     52        $db = AbstractDb::getObject(); 
    5353        $file_id = $db->escapeString($_REQUEST['file_id']); 
    5454        $sql = "SELECT * FROM content_file WHERE files_id = '$file_id'"; 
  • trunk/wifidog-auth/wifidog/gw_message.php

    r979 r1127  
    5454require_once('classes/MainUI.php'); 
    5555 
    56 $ui = new MainUI(); 
     56$ui = MainUI::getObject(); 
    5757$errmsg = ""; 
    5858 
  • trunk/wifidog-auth/wifidog/help.php

    r1030 r1127  
    5252require_once('classes/MainUI.php'); 
    5353require_once('classes/Network.php'); 
    54  
     54$smarty = SmartyWifidog::getObject(); 
    5555Network::assignSmartyValues($smarty); 
    5656$smarty->assign('read_the_faq', 
    5757        sprintf('Read the <a href="%sfaq.php">faq</a> document for more information.', BASE_URL_PATH)); 
    5858 
    59 $ui = new MainUI(); 
     59$ui = MainUI::getObject(); 
    6060$ui->addContent('main_area_middle', $smarty->fetch("templates/sites/help.tpl")); 
    6161$ui->display(); 
  • trunk/wifidog-auth/wifidog/hotspot_status.php

    r1031 r1127  
    5656require_once('classes/Network.php'); 
    5757require_once('classes/NodeList.php'); 
    58  
     58$smarty = SmartyWifidog::getObject(); 
    5959if (!empty ($_REQUEST['format'])) { 
    6060    $format = $db->escapeString($_REQUEST['format']); 
  • trunk/wifidog-auth/wifidog/hotspots_map.php

    r1051 r1127  
    5757require_once('classes/User.php'); 
    5858require_once('classes/Server.php'); 
    59  
     59$smarty = SmartyWifidog::getObject(); 
    6060// Get information about user 
    6161$currentUser = User::getCurrentUser(); 
     
    167167 * Render output 
    168168 */ 
    169 $ui = new MainUI(); 
     169$ui = MainUI::getObject(); 
    170170$ui->setTitle(_("Hotspots status map")); 
    171171$ui->setHtmlHeader($html_headers); 
  • trunk/wifidog-auth/wifidog/include/common.php

    r1123 r1127  
    102102require_once ('classes/Dependencies.php'); 
    103103require_once ('classes/Server.php'); 
    104 global $db; 
    105  
    106 $db = new AbstractDb(); 
     104$db = AbstractDb::getObject(); 
    107105 
    108106/** 
     
    195193/** Cleanup dangling tokens and connections from the database, left if a gateway crashed, etc. */ 
    196194function garbage_collect() { 
    197     global $db; 
     195    $db = AbstractDb::getObject(); 
    198196 
    199197    // 10 minutes 
  • trunk/wifidog-auth/wifidog/include/common_interface.php

    r1091 r1127  
    6161require_once('classes/SmartyWifidog.php'); 
    6262require_once('classes/User.php'); 
    63  
    64 $session = new Session(); 
    65 $smarty = new SmartyWifidog; 
    66  
    6763require_once('include/language.php'); 
    68  
    69 try 
    70 { 
    71     $username = null; 
    72     $current_user = User :: getCurrentUser(); 
    73     if ($current_user != null) 
    74     { 
    75         $username = $current_user->getUsername(); 
    76     } 
    77  
    78     $smarty->assign("auth_user", $username); 
    79 } 
    80 catch (Exception $e) 
    81 { 
    82     ; 
    83 } 
    8464 
    8565/* 
  • trunk/wifidog-auth/wifidog/include/language.php

    r1031 r1127  
    4848 
    4949if (!empty ($_REQUEST['wifidog_language'])) { 
    50      
     50        $session = Session::getObject(); 
    5151            //echo "Setting to $_REQUEST[wifidog_language]<br/>"; 
    5252        $session->set(SESS_LANGUAGE_VAR, $_REQUEST['wifidog_language']); 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1090 r1127  
    5656function validate_schema() 
    5757{ 
    58     // Define globals 
    59     global $db; 
     58     
     59    $db = AbstractDb::getObject(); 
    6060 
    6161    // Init values 
     
    9090function check_users_not_empty() 
    9191{ 
    92     // Define globals 
    93     global $db; 
     92     
     93    $db = AbstractDb::getObject(); 
    9494 
    9595    // Extract the first account origin, assume it's the default 
     
    140140function update_schema() 
    141141{ 
    142     // Define globals 
    143     global $db; 
     142     
     143    $db = AbstractDb::getObject(); 
    144144 
    145145    // Init values 
  • trunk/wifidog-auth/wifidog/index.php

    r1073 r1127  
    5757require_once('classes/Node.php'); 
    5858require_once('classes/User.php'); 
    59  
     59$smarty = SmartyWifidog::getObject(); 
    6060// Init ALL smarty SWITCH values 
    6161$smarty->assign('sectionTOOLCONTENT', false); 
     
    102102 * Render output 
    103103 */ 
    104 $ui = new MainUI(); 
     104$ui = MainUI::getObject(); 
    105105$ui->addContent('left_area_middle', $html); 
    106106$ui->addContent('main_area_top', $html_body); 
  • trunk/wifidog-auth/wifidog/login/index.php

    r1092 r1127  
    7979require_once('classes/Network.php'); 
    8080require_once('classes/MainUI.php'); 
    81 // require_once('lib/magpie/rss_fetch.inc'); // Added so RSS code which depends on the Magpie RSS functions will work. // 
    82  
     81$smarty = SmartyWifidog::getObject(); 
     82$session = Session::getObject(); 
    8383// Init values 
    8484$continueToAdmin = false; 
     
    149149 
    150150    catch (Exception $e) { 
    151         $ui = new MainUI(); 
     151        $ui = MainUI::getObject(); 
    152152        $ui->displayError($e->getMessage()); 
    153153        exit; 
     
    254254$html = $smarty->fetch("templates/sites/login.tpl"); 
    255255 
    256 $ui = new MainUI(); 
     256$ui = MainUI::getObject(); 
    257257if($node) { 
    258258        $ui->setTitle(sprintf(_("%s login page for %s"), $network->getName(), $node->getName())); 
     
    292292                $content = Content :: getObject($content_row['content_id']); 
    293293                if ($content->isDisplayableAt($node)) { 
    294                     $ui->addContent($content_row['display_area'], $content->getUserUI(), $content_row['display_order']); 
     294                    $ui->addContent($content_row['display_area'], $content, $content_row['display_order']); 
    295295                } 
    296296            } 
  • trunk/wifidog-auth/wifidog/lost_password.php

    r1031 r1127  
    5656require_once('classes/User.php'); 
    5757require_once('classes/MainUI.php'); 
    58  
     58$smarty = SmartyWifidog::getObject(); 
    5959/** 
    6060 * Process recovering username 
     
    140140         * Render output 
    141141         */ 
    142         $ui = new MainUI(); 
     142        $ui = MainUI::getObject(); 
    143143        $ui->addContent('left_area_middle', $html); 
    144144        $ui->addContent('main_area_middle', $html_body); 
     
    210210 * Render output 
    211211 */ 
    212 $ui = new MainUI(); 
     212$ui = MainUI::getObject(); 
    213213$ui->addContent('left_area_middle', $html); 
    214214$ui->addContent('main_area_middle', $html_body); 
  • trunk/wifidog-auth/wifidog/lost_username.php

    r1031 r1127  
    5656require_once('classes/User.php'); 
    5757require_once('classes/MainUI.php'); 
    58  
     58$smarty = SmartyWifidog::getObject(); 
    5959/** 
    6060 * Process recovering username 
     
    124124         * Render output 
    125125         */ 
    126         $ui = new MainUI(); 
     126        $ui = MainUI::getObject(); 
    127127        $ui->addContent('left_area_middle', $html); 
    128128        $ui->addContent('main_area_middle', $html_body); 
     
    194194 * Render output 
    195195 */ 
    196 $ui = new MainUI(); 
     196$ui = MainUI::getObject(); 
    197197$ui->addContent('left_area_middle', $html); 
    198198$ui->addContent('main_area_middle', $html_body); 
  • trunk/wifidog-auth/wifidog/node_list.php

    r1123 r1127  
    5757require_once('classes/Node.php'); 
    5858require_once('classes/Utils.php'); 
    59  
    60 global $db; 
     59$smarty = SmartyWifidog::getObject(); 
     60$db = AbstractDb::getObject(); 
    6161 
    6262// Set the sort parameter, defaults to name 
     
    148148require_once('classes/MainUI.php'); 
    149149 
    150 $ui = new MainUI(); 
     150$ui = MainUI::getObject(); 
    151151$ui->addContent('main_area_middle', $smarty->fetch("templates/node_list.html")); 
    152152$ui->display(); 
  • trunk/wifidog-auth/wifidog/portal/index.php

    r1090 r1127  
    5858require_once ('classes/MainUI.php'); 
    5959require_once ('classes/Session.php'); 
    60  
     60$smarty = SmartyWifidog::getObject(); 
    6161/* 
    6262 * Check for missing URL switch 
    6363 */ 
    6464if (isset ($_REQUEST['missing']) && $_REQUEST['missing'] == "url") { 
    65     $ui = new MainUI(); 
     65    $ui = MainUI::getObject(); 
    6666    $ui->displayError(_('For some reason, we were unable to determine the web site you initially wanted to see.  You should now enter a web address in your URL bar.'), false); 
    6767    exit; 
     
    7474 
    7575// Init session 
    76 $session = new Session(); 
     76$session = Session::getObject(); 
    7777 
    7878// Get the current user 
     
    8787        $network = $node->getNetwork(); 
    8888    } catch (Exception $e) { 
    89         $ui = new MainUI(); 
     89        $ui = MainUI::getObject(); 
    9090        $ui->displayError($e->getMessage()); 
    9191        exit; 
    9292    } 
    9393} else { 
    94     $ui = new MainUI(); 
     94    $ui = MainUI::getObject(); 
    9595    $ui->displayError(_("No Hotspot specified!")); 
    9696    exit; 
     
    202202 */ 
    203203 
    204 $ui = new MainUI(); 
     204$ui = MainUI::getObject(); 
    205205$ui->setTitle(sprintf(_("%s portal for %s"), $network->getName(), $node->getName())); 
    206206$ui->setPageName('portal'); 
     
    234234        $content = Content :: getObject($content_row['content_id']); 
    235235        if ($content->isDisplayableAt($node)) { 
    236             $ui->addContent($content_row['display_area'], $content->getUserUI(), $content_row['display_order']); 
     236            $ui->addContent($content_row['display_area'], $content, $content_row['display_order']); 
    237237        } 
    238238    } 
     
    254254        $content = Content :: getObject($content_row['content_id']); 
    255255        if ($content->isDisplayableAt($node)) { 
    256             $ui->addContent($content_row['display_area'], $content->getUserUI(), $content_row['display_order']); 
     256            $ui->addContent($content_row['display_area'], $content, $content_row['display_order']); 
    257257        } 
    258258        // Check for content requirements to show the "Show all contents" link 
     
    279279            $content = Content :: getObject($content_row['content_id']); 
    280280            if ($content->isDisplayableAt($node)) { 
    281                 $ui->addContent('main_area_middle', $content->getUserUI()); 
     281                $ui->addContent('main_area_middle', $content); 
    282282            } 
    283283        } 
  • trunk/wifidog-auth/wifidog/resend_validation.php

    r1031 r1127  
    5656require_once('classes/User.php'); 
    5757require_once('classes/MainUI.php'); 
    58  
     58$smarty = SmartyWifidog::getObject(); 
    5959/** 
    6060 * Process recovering username 
     
    123123         * Render output 
    124124         */ 
    125         $ui = new MainUI(); 
     125        $ui = MainUI::getObject(); 
    126126        $ui->addContent('left_area_middle', $html); 
    127127        $ui->addContent('main_area_middle', $html_body); 
     
    193193 * Render output 
    194194 */ 
    195 $ui = new MainUI(); 
     195$ui = MainUI::getObject(); 
    196196$ui->addContent('left_area_middle', $html); 
    197197$ui->addContent('main_area_middle', $html_body); 
  • trunk/wifidog-auth/wifidog/signup.php

    r1031 r1127  
    5858require_once('classes/MainUI.php'); 
    5959require_once('classes/Mail.php'); 
    60  
     60$smarty = SmartyWifidog::getObject(); 
    6161/** 
    6262 * Load custom signup URL if it has been defined in config.php 
     
    233233 
    234234        // If the user is at a REAL hotspot, give him his sign-up minutes right away 
     235                $session = Session::getObject(); 
    235236        $gw_id = $session->get(SESS_GW_ID_VAR); 
    236237        $gw_address = $session->get(SESS_GW_ADDRESS_VAR); 
     
    256257         * Render output 
    257258         */ 
    258         $ui = new MainUI(); 
     259        $ui = MainUI::getObject(); 
    259260 
    260261        $ui->addContent('left_area_middle', $html); 
     
    344345 * Render output 
    345346 */ 
    346 $ui = new MainUI(); 
     347$ui = MainUI::getObject(); 
    347348$ui->addContent('left_area_middle', $html); 
    348349$ui->addContent('main_area_middle', $html_body); 
  • trunk/wifidog-auth/wifidog/validate.php

    r1031 r1127  
    5353require_once('classes/Node.php'); 
    5454require_once('classes/MainUI.php'); 
    55  
     55$smarty = SmartyWifidog::getObject(); 
    5656try { 
    5757    if (!isset($_REQUEST["token"])) 
     
    7676    // Try to current physical node:  if possible it will regenerate the session accordingly with the connection token. 
    7777    $current_user_node = Node::getCurrentRealNode(); 
    78     if($current_user_node) 
    79             $gw_id = $session->set(SESS_GW_ID_VAR, $current_user_node->getId()); 
    80  
     78    if($current_user_node) { 
     79        $session = Session::getObject(); 
     80        $gw_id = $session->set(SESS_GW_ID_VAR, $current_user_node->getId()); 
     81    } 
    8182    // Show activation message 
    8283    $smarty->assign('message', _("Your account has been succesfully activated!\n\nYou may now browse to a remote Internet address and take advantage of the free Internet access!\n\nIf you get prompted for a login, enter the username and password you have just created.")); 
     
    8586} 
    8687 
    87 $ui = new MainUI(); 
     88$ui = MainUI::getObject(); 
    8889$ui->addContent('main_area_middle', $smarty->fetch("templates/sites/validate.tpl")); 
    8990$ui->display();