Changeset 40

Show
Ignore:
Timestamp:
09/07/06 14:00:00 (2 years ago)
Author:
drazzib
Message:

Mise a jour par rapport a la derniere version SVN de wifidog.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wifidog/wifidog-auth/wifidog/classes/Mail.php

    r39 r40  
    3838 * @author     Francois Proulx <francois.proulx@gmail.com> 
    3939 * @copyright  2005-2006 Francois Proulx, Technologies Coeus inc. 
    40  * @version    Subversion $Id: Mail.php 1088 2006-09-03 03:35:06Z max-horvath
     40 * @version    Subversion $Id: Mail.php 1090 2006-09-06 13:01:54Z benoitg
    4141 * @link       http://www.wifidog.org/ 
    4242 */ 
     
    4545 * Load required classes 
    4646 */ 
    47 require_once('include/class.phpmailer.php'); 
    48 require_once('include/class.smtp.php'); 
     47require_once('lib/PHPMailer/class.phpmailer.php'); 
     48require_once('lib/SMTP/class.smtp.php'); 
    4949 
    5050/** 
     
    136136     * 
    137137     * @return string Encoded MIME header 
    138      * 
    139      * @access private 
     138 
    140139     * 
    141140     * @see http://www.php.net/manual/en/function.mb-send-mail.php 
  • wifidog/wifidog-auth/wifidog/classes/Node.php

    r39 r40  
    3838 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
    3939 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc. 
    40  * @version    Subversion $Id: Node.php 1083 2006-08-28 19:32:54Z benoitg $ 
     40 * @version    Subversion $Id: Node.php 1092 2006-09-07 08:38:25Z benoitg $ 
    4141 * @link       http://www.wifidog.org/ 
    4242 */ 
     
    5050require_once('classes/Utils.php'); 
    5151require_once('classes/DateTime.php'); 
    52 require_once('classes/InterfaceElements.php'); 
    5352 
    5453/** 
     
    6867        private $id; 
    6968        private static $current_node_id = null; 
     69 
     70        /** 
     71         * List of deployment statuses 
     72         * 
     73         * @var array 
     74         * @access private 
     75         */ 
     76        private $_deploymentStatuses = array(); 
    7077 
    7178        /** 
     
    187194        } 
    188195 
    189         /** Create a new Node in the database 
    190          * @param $node_id The id to be given to the new node.  If not present, a 
    191          * guid will be assigned. 
    192          * @param $network Network object.  The node's network.  If not present, 
    193          * the current Network will be assigned 
    194          * 
    195          * @return the newly created Node object, or null if there was an error 
    196          */ 
    197         static function createNewObject($node_id = null, $network = null) 
    198         { 
    199                 global $db; 
    200                 if (empty ($node_id)) 
    201                 { 
     196        /** 
     197         * Create a new Node in the database 
     198         * 
     199         * @param string $node_id The Id to be given to the new node.  If not 
     200         *                        present, guid will be assigned. 
     201         * @param object $network Network object.  The node's network.  If not 
     202         *                        present, the current Network will be assigned 
     203         * 
     204         * @return mixed The newly created Node object, or null if there was 
     205         *               an error 
     206         * 
     207         * @static 
     208         * @access public 
     209         */ 
     210        public static function createNewObject($node_id = null, $network = null) 
     211        { 
     212            // Define globals 
     213                global $db; 
     214 
     215                if (empty ($node_id)) { 
    202216                        $node_id = get_guid(); 
    203217                } 
     218 
    204219                $node_id = $db->escapeString($node_id); 
    205220 
    206                 if (empty ($network)) 
    207                 { 
    208                        $network = Network :: getCurrentNetwork(); 
    209                 } 
     221                if (empty ($network)) { 
     222                       $network = Network::getCurrentNetwork(); 
     223                } 
     224 
    210225                $network_id = $db->escapeString($network->getId()); 
    211226 
    212227                $node_deployment_status = $db->escapeString("IN_PLANNING"); 
    213228                $node_name = _("New node"); 
    214                 if (Node :: nodeExists($node_id)) 
    215                         throw new Exception(_('This node already exists.')); 
    216  
    217                 $sql = "INSERT INTO nodes (node_id, network_id, creation_date, node_deployment_status, name) VALUES ('$node_id', '$network_id', NOW(),'$node_deployment_status', '$node_name')"; 
    218  
    219                 if (!$db->execSqlUpdate($sql, false)) 
    220                 { 
    221                         throw new Exception(_('Unable to insert new node into database!')); 
    222                 } 
    223                 $object = new self($node_id); 
    224                 return $object; 
     229 
     230            if (Node::nodeExists($node_id)) { 
     231                throw new Exception(_('This node already exists.')); 
     232            } 
     233 
     234            $sql = "INSERT INTO nodes (node_id, network_id, creation_date, node_deployment_status, name) VALUES ('$node_id', '$network_id', NOW(),'$node_deployment_status', '$node_name')"; 
     235 
     236            if (!$db->execSqlUpdate($sql, false)) { 
     237                throw new Exception(_('Unable to insert new node into database!')); 
     238            } 
     239 
     240            $object = new self($node_id); 
     241 
     242            return $object; 
    225243        } 
    226244 
     
    235253                $html = ''; 
    236254                $name = "{$user_prefix}"; 
     255 
     256        $_deploymentStatuses = array( 
     257            "DEPLOYED" => _("Deployed"), 
     258            "IN_PLANNING" => _("In planning"), 
     259            "IN_TESTING" => _("In testing"), 
     260            "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 
     261            "PERMANENTLY_CLOSED" => _("Permanently closed"), 
     262            "TEMPORARILY_CLOSED" => _("Temporarily closed") 
     263            ); 
     264 
    237265                $sql = "SELECT node_id, name, node_deployment_status, is_splash_only_node from nodes WHERE 1=1 $sql_additional_where ORDER BY lower(node_id)"; 
    238266                $node_rows = null; 
    239267                $db->execSql($sql, $node_rows, false); 
    240                 if ($node_rows != null) 
    241                
     268 
     269                if ($node_rows != null)
    242270                        Utils :: natsort2d($node_rows, "node_id"); 
    243271                        if ($type_interface != "table") { 
     
    267295                                { 
    268296                                        $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$node_row['node_id']}&object_class=Node&action=edit"; 
    269                                         $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$node_row['name']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>{$node_row['node_id']}</td>\n\t\t\t\t\t<td>{$node_row['node_deployment_status']}</td>\n\t\t\t\t</tr>\n"; 
     297                                        $_deployStatusNode = $node_row['node_deployment_status']; 
     298                                        $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$node_row['name']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>{$node_row['node_id']}</td>\n\t\t\t\t\t<td>{$_deploymentStatuses[$_deployStatusNode]}</td>\n\t\t\t\t</tr>\n"; 
    270299                                } 
    271300                                $html .= "\t\t\t</tbody>\n\t\t</table>\n"; 
     
    317346        } 
    318347 
    319         /** Process the new object interface. 
    320          *  Will return the new object if the user has the credentials and the form was fully filled. 
     348        /** 
     349         * Process the new object interface. 
     350         * 
     351         * Will return the new object if the user has the credentials and the form was fully filled. 
    321352         * @return the node object or null if no new node was created. 
    322353         */ 
    323         static function processCreateNewObjectUI() 
    324         { 
     354        public static function processCreateNewObjectUI() 
     355        { 
     356            // Init values 
    325357                $retval = null; 
    326358                $name = "new_node_id"; 
    327                 if (!empty ($_REQUEST[$name])) 
    328                
     359 
     360                if (!empty ($_REQUEST[$name]))
    329361                        $node_id = $_REQUEST[$name]; 
    330362                        $name = "new_node_network_id"; 
    331                         if (!empty ($_REQUEST[$name])) 
    332                         { 
    333                                 $network = Network :: getObject($_REQUEST[$name]); 
    334                         } 
    335                         else 
    336                         { 
    337                                 $network = Network :: processSelectNetworkUI('new_node'); 
    338                         } 
    339                         if ($node_id && $network) 
    340                         { 
    341                                 if (!$network->hasAdminAccess(User :: getCurrentUser())) 
    342                                 { 
    343                                         throw new Exception(_("Access denied")); 
    344                                 } 
    345                                 $retval = self :: createNewObject($node_id, $network); 
    346                         } 
    347                 } 
     363 
     364                        if (!empty ($_REQUEST[$name])) { 
     365                                $network = Network::getObject($_REQUEST[$name]); 
     366                        } else { 
     367                                $network = Network::processSelectNetworkUI('new_node'); 
     368                        } 
     369 
     370                        if ($node_id && $network) { 
     371                            try { 
     372                                if (!$network->hasAdminAccess(User :: getCurrentUser())) { 
     373                                        throw new Exception(_("Access denied")); 
     374                                } 
     375                } catch (Exception $e) { 
     376                    $ui = new MainUI(); 
     377                    $ui->setToolSection('ADMIN'); 
     378                    $ui->displayError($e->getMessage(), false); 
     379                    exit; 
     380                } 
     381 
     382                                $retval = self::createNewObject($node_id, $network); 
     383                        } 
     384                } 
     385 
    348386                return $retval; 
    349387        } 
     
    356394     * 
    357395     * @return string HTML markup 
    358      * 
    359      * @access public 
    360396     */ 
    361397        public function getSelectDeploymentStatus($user_prefix) 
     
    377413 
    378414                foreach ($status_list as $status) { 
    379                         $tab[] = array($status['node_deployment_status'], $status['node_deployment_status']); 
     415                    $_statusvalue = $status['node_deployment_status']; 
     416                        $tab[] = array($_statusvalue, $this->_deploymentStatuses["$_statusvalue"]); 
    380417                } 
    381418 
     
    385422        } 
    386423 
    387         /** Get the selected deployment status 
    388          * @param $user_prefix A identifier provided by the programmer to recognise it's generated form 
    389          * @return the deployment status 
     424        /** 
     425         * Get the selected deployment status 
     426         * 
     427         * @param string $user_prefix An identifier provided by the programmer to 
     428         *                            recognise it's generated form 
     429         * 
     430         * @return string The deployment status 
     431         * 
     432         * @access public 
    390433         */ 
    391434        public function processSelectDeploymentStatus($user_prefix) 
     
    410453                        throw new Exception(sprintf(_("The node %s could not be found in the database!"), $node_id_str)); 
    411454                } 
     455 
     456        $this->_deploymentStatuses = array( 
     457            "DEPLOYED" => _("Deployed"), 
     458            "IN_PLANNING" => _("In planning"), 
     459            "IN_TESTING" => _("In testing"), 
     460            "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 
     461            "PERMANENTLY_CLOSED" => _("Permanently closed"), 
     462            "TEMPORARILY_CLOSED" => _("Temporarily closed") 
     463            ); 
     464 
    412465                $this->mRow = $row; 
    413466                $this->id = $row['node_id']; 
     
    744797         * Retrieves the admin interface of this object 
    745798         * 
    746          * @return The HTML fragment for this interface 
     799         * @return string The HTML fragment for this interface 
    747800         * 
    748801         * @access public 
     
    753806        public function getAdminUI() 
    754807        { 
     808            require_once('classes/InterfaceElements.php'); 
    755809            // Init values 
    756810                $html = ''; 
    757  
    758                 if (!User::getCurrentUser()) { 
    759                         throw new Exception(_('Access denied!')); 
    760                 } 
     811                if (!User::getCurrentUser()) { 
     812                        throw new Exception(_('Access denied!')); 
     813                } 
    761814 
    762815                // Get information about the network 
     
    815868        $_data = Content::getLinkedContentUI("node_" . $hashed_node_id . "_content", "node_has_content", "node_id", $this->id, "portal"); 
    816869        $html .= InterfaceElements::generateAdminSectionContainer("node_content", $_title, $_data); 
    817   
     870 
    818871                // Name 
    819872                $_title = _("Name"); 
     
    944997                // custom_portal_redirect_url 
    945998                if ($network->getCustomPortalRedirectAllowed()) { 
    946                 $_title = _("URL to show instead of the portal (if this is not empty, the portal will be disabled and this URL will be shown instead)"); 
     999                $_title = _("URL to show instead of the portal"); 
    9471000                $_data = InterfaceElements::generateInputText("node_" . $hashed_node_id . "_custom_portal_redirect_url", $this->getCustomPortalRedirectUrl(), "node_custom_portal_redirect_url_input"); 
    948                 $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_custom_portal_redirect_url", $_title, $_data); 
     1001                $_data .= _("If this is not empty, the portal will be disabled and this URL will be shown instead"); 
     1002                 $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_custom_portal_redirect_url", $_title, $_data); 
    9491003                } 
    9501004 
     
    9961050        } 
    9971051 
    998         /** Process admin interface of this object. 
    999         */ 
     1052        /** 
     1053         * Process admin interface of this object. 
     1054         * 
     1055         * @return void 
     1056         * 
     1057         * @access public 
     1058         */ 
    10001059        public function processAdminUI() 
    10011060        { 
    1002                 $user = User :: getCurrentUser(); 
    1003  
    1004                 if (!$this->isOwner($user) && !$user->isSuperAdmin()) 
    1005                 { 
    1006                         throw new Exception(_('Access denied!')); 
    1007                 } 
     1061                $user = User::getCurrentUser(); 
     1062 
     1063                if (!$this->isOwner($user) && !$user->isSuperAdmin()) { 
     1064                        throw new Exception(_('Access denied!')); 
     1065                } 
     1066 
    10081067 
    10091068                // Check if user is a admin 
     
    12881347        } 
    12891348 
    1290         /** The list of users online at this node 
    1291          * @return An array of User object, or en empty array */ 
    1292         function getOnlineUsers() 
    1293         { 
    1294                 global $db; 
    1295                 $retval = array (); 
     1349        /** 
     1350         * The list of users online at this node 
     1351         * 
     1352         * @return array An array of User object, or an empty array 
     1353         * 
     1354         * @access public 
     1355         */ 
     1356        public function getOnlineUsers() 
     1357        { 
     1358            // Define globals 
     1359                global $db; 
     1360 
     1361                // Init values 
     1362                $retval = array(); 
    12961363                $users = null; 
     1364                $anonUsers = 0; 
     1365 
    12971366                $db->execSql("SELECT users.user_id FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $users, false); 
    1298                 if ($users != null) 
    1299                
    1300                         foreach ($users as $user_row) 
    1301                         { 
    1302                                $retval[] = User :: getObject($user_row['user_id']); 
    1303                        
    1304                 } 
     1367 
     1368                if ($users != null)
     1369                        foreach ($users as $user_row) { 
     1370                                   $retval[] = User::getObject($user_row['user_id']); 
     1371                        } 
     1372               
     1373 
    13051374                return $retval; 
    13061375        } 
    13071376 
    1308         /** Find out how many users are online this specific Node 
    1309          * @return Number of online users 
    1310          */ 
    1311         function getNumOnlineUsers() 
    1312         { 
    1313                 global $db; 
     1377        /** 
     1378         * Find out how many users are online this specific Node 
     1379         * 
     1380         * @return int Number of online users 
     1381         * 
     1382         * @access public 
     1383         */ 
     1384        public function getNumOnlineUsers() 
     1385        { 
     1386            // Define globals 
     1387                global $db; 
     1388 
     1389                // Init values 
    13141390                $retval = array (); 
    13151391                $row = null; 
    1316                 if(!$this->isConfiguredSplashOnly()) 
     1392 
     1393                if (!$this->isConfiguredSplashOnly()) { 
    13171394                        $db->execSqlUniqueRes("SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $row, false); 
    1318                 else 
     1395                } else { 
    13191396                        $db->execSqlUniqueRes("SELECT COUNT(DISTINCT connections.user_mac) as count FROM connections WHERE connections.token_status='".TOKEN_INUSE."' AND connections.node_id='{$this->id}'", $row, false); 
     1397                } 
     1398 
    13201399                return $row['count']; 
    13211400        } 
     
    14651544        private static function nodeExists($id) 
    14661545        { 
    1467                // Define globals 
     1546            // Define globals 
    14681547                global $db; 
    14691548 
     
    14901569 
    14911570// BEGIN :DRAZZIB: Ajout fonction specifique pour le ping 
    1492        public function ping($node_heartbeat_ip, $user_agent) 
    1493        
    1494                $this->mDb->execSqlUpdate("UPDATE nodes SET last_heartbeat_ip='{$node_heartbeat_ip}', last_heartbeat_timestamp=NOW(), last_heartbeat_user_agent='{$user_agent}' WHERE node_id='{$this->getId()}'"); 
    1495        
     1571    public function ping($node_heartbeat_ip, $user_agent) 
     1572   
     1573        $this->mDb->execSqlUpdate("UPDATE nodes SET last_heartbeat_ip='{$node_heartbeat_ip}', last_heartbeat_timestamp=NOW(), last_heartbeat_user_agent='{$user_agent}' WHERE node_id='{$this->getId()}'"); 
     1574   
    14961575// END :DRAZZIB: 
    14971576 
  • wifidog/wifidog-auth/wifidog/classes/Statistics.php

    r39 r40  
    3939 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
    4040 * @copyright  2004-2006 Benoit Grégoire, Technologies Coeus inc. 
    41  * @version    Subversion $Id: Statistics.php 1078 2006-07-20 16:19:19Z benoitg $ 
     41 * @version    Subversion $Id: Statistics.php 1091 2006-09-06 14:58:06Z benoitg $ 
    4242 * @link       http://www.wifidog.org/ 
    4343 */ 
     
    304304                $id = $db->escapeString($id); 
    305305                $first ? $sql .= "" : $sql .= " OR "; 
    306                                 // :DRAZZIB: Utilisation de la table des connections. 
     306                // :DRAZZIB: Utilisation de la table connections 
    307307                $sql .= "connections.$column = '$id'"; 
    308308                $first = false; 
     
    379379     * 
    380380     * @return string HTML markup 
     381     * 
     382     * @access private 
    381383     */ 
    382384    private function getSelectedNodesUI() 
    383385    { 
     386        // Define globals 
    384387        global $db; 
     388 
     389        // Init values 
    385390        $html = ''; 
     391 
    386392        $name = "statistics_selected_nodes[]"; 
    387         $user = User :: getCurrentUser(); 
    388         if ($user->isSuperAdmin()) 
    389         { 
    390             $sql_join = ''; 
    391         } 
    392         else 
    393         { 
    394             $user_id = $db->escapeString($user->getId()); 
    395             $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='$user_id') "; 
    396         } 
    397         $sql = "SELECT nodes.node_id, nodes.name from nodes $sql_join WHERE 1=1 ORDER BY lower(node_id)"; 
    398         $node_rows = null; 
    399         $db->execSql($sql, $node_rows, false); 
    400         $html .= "<select multiple size = 6 name='$name'>\n"; 
    401  
    402         /*count($this->report_selected_nodes)==0?$selected=' SELECTED ':$selected=''; 
    403                     $html.= "<option value='' $selected>"._("Statistics for all nodes")."</option>\n"; 
    404         */ 
    405         if ($node_rows != null) 
    406         { 
    407             foreach ($node_rows as $node_row) 
    408             { 
    409                 $html .= "<option "; 
    410                 if (array_key_exists($node_row['node_id'], $this->report_selected_nodes)) 
    411                 { 
    412                     $html .= " SELECTED "; 
     393        $user = User::getCurrentUser(); 
     394 
     395            if (!isset($user)) { 
     396                throw new Exception(_('Access denied!')); 
     397            } else if ((!$user->isSuperAdmin() && !$user->isOwner()) || $user->isNobody()) { 
     398                throw new Exception(_('Access denied!')); 
     399            } 
     400 
     401            if ($user->isSuperAdmin()) { 
     402                $sql_join = ''; 
     403            } else { 
     404                $user_id = $db->escapeString($user->getId()); 
     405                $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='$user_id') "; 
     406            } 
     407 
     408            $sql = "SELECT nodes.node_id, nodes.name from nodes $sql_join WHERE 1=1 ORDER BY lower(node_id)"; 
     409            $node_rows = null; 
     410            $db->execSql($sql, $node_rows, false); 
     411            $html .= "<select multiple size = 6 name='$name'>\n"; 
     412 
     413            if ($node_rows != null) { 
     414                foreach ($node_rows as $node_row) { 
     415                    $html .= "<option "; 
     416 
     417                    if (array_key_exists($node_row['node_id'], $this->report_selected_nodes)) { 
     418                        $html .= " SELECTED "; 
     419                    } 
     420 
     421                    $nom = $node_row['node_id'].": ".$node_row['name']; 
     422                    $nom = htmlspecialchars($nom, ENT_QUOTES, 'UTF-8'); 
     423                    $primary_key = htmlentities($node_row['node_id'], ENT_QUOTES, 'UTF-8'); 
     424                    $html .= "value='$primary_key'>$nom</option>\n"; 
    413425                } 
    414  
    415                 $nom = $node_row['node_id'].": ".$node_row['name']; 
    416                 $nom = htmlspecialchars($nom, ENT_QUOTES, 'UTF-8'); 
    417                 $primary_key = htmlentities($node_row['node_id'], ENT_QUOTES, 'UTF-8'); 
    418                 $html .= "value='$primary_key'>$nom</option>\n"; 
    419             } 
    420         } 
    421         $html .= "</select>\n"; 
     426            } 
     427 
     428            $html .= "</select>\n"; 
     429 
     430 
    422431        return $html; 
    423432    } 
     
    544553                $username = $db->escapeString($_REQUEST['stats_selected_users']); 
    545554                $row = null; 
    546                                 // :DRAZZIB: Suppression du debug 
    547555                $db->execSqlUniqueRes("SELECT user_id FROM users WHERE username='$username'", $row, false); 
    548556                if ($row) 
     
    601609            $html .= "<div class='admin_element_tools'><input type='checkbox' name='$key' $checked /></div>\n"; 
    602610            $html .= "<div class='admin_element_label'>$name</div>\n"; 
    603              
     611 
    604612                $html .= "</li>\n"; 
    605613                } 
  • wifidog/wifidog-auth/wifidog/classes/User.php

    r33 r40  
    11<?php 
     2 
    23 
    34/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     
    3839 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
    3940 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc. 
    40  * @version    Subversion $Id: User.php 1070 2006-06-08 21:24:39Z benoitg $ 
     41 * @version    Subversion $Id: User.php 1093 2006-09-07 08:45:11Z benoitg $ 
    4142 * @link       http://www.wifidog.org/ 
    4243 */ 
     
    4546 * Load required classes 
    4647 */ 
    47 require_once('classes/Network.php'); 
    48 require_once('classes/Mail.php'); 
    49 require_once('classes/InterfaceElements.php'); 
     48require_once ('classes/Network.php'); 
     49require_once ('classes/Mail.php'); 
     50require_once ('classes/InterfaceElements.php'); 
    5051 
    5152/** 
     
    5657 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc. 
    5758 */ 
    58 class User implements GenericObject 
    59 
     59class User implements GenericObject { 
    6060    private $mRow; 
    6161    private $id; 
     
    6565     * @return a User object, or null if there was an error 
    6666     */ 
    67     public static function getObject($id) 
    68     { 
     67    public static function getObject($id) { 
    6968        $object = null; 
    7069        $object = new self($id); 
     
    7271    } 
    7372 
    74     static function createNewObject() 
    75     { 
     73    static function createNewObject() { 
    7674        echo "<h1>Use User::createUser() instead</h1>"; 
    7775    } 
     
    7977    * @return html markup 
    8078    */ 
    81     public static function getCreateNewObjectUI() 
    82     { 
     79    public static function getCreateNewObjectUI() { 
    8380        return null; 
    8481    } 
     
    9087     * @return the node object or null if no new node was created. 
    9188     */ 
    92     static function processCreateNewObjectUI() 
    93     { 
     89    static function processCreateNewObjectUI() { 
    9490        return self :: createNewObject(); 
    9591    } 
     
    9894     * 
    9995     * @return mixed A User object, or null if there was an error 
    100      * 
    101      * @static 
    102      * @access public 
    103      */ 
    104     public static function getCurrentUser() 
    105     { 
    106         require_once('classes/Session.php'); 
     96     
     97     */ 
     98    public static function getCurrentUser() { 
     99        require_once ('classes/Session.php'); 
    107100        $session = new Session(); 
    108101        $user = null; 
    109         try 
    110         { 
     102        try { 
    111103            $user = self :: getObject($session->get(SESS_USER_ID_VAR)); 
    112104            //$user = new User($session->get(SESS_USER_ID_VAR)); 
    113         } 
    114         catch (Exception $e) 
    115         { 
     105        } catch (Exception $e) { 
    116106            /**If any problem occurs, the user should be considered logged out*/ 
    117107            $session->set(SESS_USER_ID_VAR, null); 
     
    128118     * 
    129119     * @return bool True if everything went well setting the session 
    130      * 
    131      * @static 
    132      * @access public 
    133      */ 
    134     public static function setCurrentUser(User $user) 
    135     { 
    136         try 
    137         { 
     120     
     121     */ 
     122    public static function setCurrentUser(User $user) { 
     123        try { 
    138124            $session = new Session(); 
    139125            $session->set(SESS_USER_ID_VAR, $user->getId()); 
    140126            $session->set(SESS_PASSWORD_HASH_VAR, $user->getPasswordHash()); 
    141127            return true; 
    142         } 
    143         catch (Exception $e) 
    144         { 
     128        } catch (Exception $e) { 
    145129            return false; 
    146130        } 
     
    151135     * 
    152136     * @return string Hostname of server 
    153      * 
    154      * @static 
    155      * @access public 
    156      */ 
    157     public static function getCurrentServer() 
    158     { 
     137     
     138     */ 
     139    public static function getCurrentServer() { 
    159140        return $_SERVER['SERVER_NAME']; 
    160141    } 
     
    165146     * @return a User object, or null if there was an error 
    166147     */ 
    167     public static function getUserByUsernameAndOrigin($username, Network $account_origin) 
    168     { 
     148    public static function getUserByUsernameAndOrigin($username, Network $account_origin) { 
    169149        global $db; 
    170150        $object = null; 
     
    184164     * @return a User object, or null if there was an error 
    185165     */ 
    186     public static function getUserByEmailAndOrigin($email, Network $account_origin) 
    187     { 
     166    public static function getUserByEmailAndOrigin($email, Network $account_origin) { 
    188167        global $db; 
    189168        $object = null; 
     
    201180     * @return The 32 character hash. 
    202181     */ 
    203     public static function passwordHash($password) 
    204     { 
     182    public static function passwordHash($password) { 
    205183        /** 
    206184         * utf8_decode is used for backward compatibility with old passwords 
     
    215193     * @return the newly created User object, or null if there was an error 
    216194     */ 
    217     static function createUser($id, $username, Network $account_origin, $email, $password) 
    218     { 
     195    static function createUser($id, $username, Network $account_origin, $email, $password) { 
    219196        global $db; 
    220197 
     
    235212    } 
    236213 
    237 /*    public static function purgeUnvalidatedUsers($days_since_creation) 
    238    
    239         global $db; 
    240         $days_since_creation = $db->escapeString($days_since_creation); 
    241  
    242         //$db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW())"); 
    243     }*/ 
     214    /*    public static function purgeUnvalidatedUsers($days_since_creation) 
     215       
     216            global $db; 
     217            $days_since_creation = $db->escapeString($days_since_creation); 
     218     
     219            //$db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW())"); 
     220        }*/ 
    244221 
    245222    /** @param $object_id The id of the user */ 
    246     function __construct($object_id) 
    247     { 
     223    function __construct($object_id) { 
    248224        global $db; 
    249225        $this->mDb = & $db; 
     
    251227        $sql = "SELECT * FROM users WHERE user_id='{$object_id_str}'"; 
    252228        $db->execSqlUniqueRes($sql, $row, false); 
    253         if ($row == null) 
    254         { 
     229        if ($row == null) { 
    255230            throw new Exception(sprintf(_("User id: %s could not be found in the database"), $object_id_str)); 
    256231        } 
     
    259234    } //End class 
    260235 
    261     function getId() 
    262     { 
     236    function getId() { 
    263237        return $this->id; 
    264238    } 
     
    267241     * @return Network object (never returns null) 
    268242     */ 
    269     public function getNetwork() 
    270     { 
     243    public function getNetwork() { 
    271244        return Network :: getObject($this->mRow['account_origin']); 
    272245    } 
    273246 
    274247    /** Get a user display suitable for a user list.  Will include link to the user profile. */ 
    275     function getListUI() 
    276     { 
     248    function getListUI() { 
    277249        /*    $roles = array (); 
    278  
    279     if ($current_node->isOwner($online_user)) { 
     250         
     251        if ($current_node->isOwner($online_user)) { 
    280252        $roles[] = _("owner"); 
    281    
    282  
    283     if ($current_node->isTechnicalOfficer($online_user)) { 
     253       
     254         
     255        if ($current_node->isTechnicalOfficer($online_user)) { 
    284256        $roles[] = _("technical officer"); 
    285    
    286  
    287     if ($roles) { 
     257       
     258         
     259        if ($roles) { 
    288260        $rolenames = join($roles, ","); 
    289     }*/ 
     261        }*/ 
    290262        $html = ''; 
    291         $html .= $this->getUserName(); 
     263        if ($this->isSplashOnlyUser()) { 
     264            $html .= _("Guest"); 
     265        } 
     266        else { 
     267                $html .= $this->getUserName(); 
     268        } 
    292269        return $html; 
    293270    } 
    294271 
    295     function getUsername() 
    296     { 
     272    function getUsername() { 
    297273        return $this->mRow['username']; 
    298274    } 
    299      
    300     /** Set the user's username 
    301     * @param $value The new value 
    302     * @return true on success, false on failure 
    303     * @throws exception if the user tries to set a duplicate username 
    304     */ 
     275 
     276    /** Set the user's username 
     277    * @param $value The new value 
     278    * @return true on success, false on failure 
     279    * @throws exception if the user tries to set a duplicate username 
     280    */ 
    305281    function setUsername($value) { 
    306282        $retval = true; 
     
    308284            global $db; 
    309285            $value = $db->escapeString($value); 
    310             $retval = @$db->execSqlUpdate("UPDATE users SET username = '{$value}' WHERE user_id='{$this->id}'", false); 
    311             if(!$retval) 
    312             { 
    313                 throw new exception (sprintf(_("Sorry, the username %s is not available"), $value)); 
     286            $retval = @ $db->execSqlUpdate("UPDATE users SET username = '{$value}' WHERE user_id='{$this->id}'", false); 
     287            if (!$retval) { 
     288                throw new exception(sprintf(_("Sorry, the username %s is not available"), $value)); 
    314289            } 
    315290            $this->refresh(); 
     
    318293    } 
    319294 
    320     public function getEmail() 
    321     { 
     295    public function getEmail() { 
    322296        return $this->mRow['email']; 
    323297    } 
    324298 
    325     public function setEmail($email) 
    326     { 
    327       $email_str = $this->mDb->escapeString($email); 
    328       if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET email='{$email_str}' WHERE user_id='{$this->id}'"))) 
    329         { 
    330           throw new Exception(_("Could not update email address.")); 
    331         } 
    332       $this->mRow['email'] = $email; // unescaped 
    333     } 
    334  
    335     function setIsInvisible($value) 
    336     { 
    337       $retval = true; 
    338       if ($value != $this->isAdvertised()) 
    339         { 
    340           global $db; 
    341           $value ? $value = 'TRUE' : $value = 'FALSE'; 
    342           $retval = $db->execSqlUpdate("UPDATE users SET is_invisible = {$value} WHERE user_id = '{$this->getId()}'", false); 
    343           $this->refresh(); 
    344         } 
    345       return $retval; 
    346     } 
    347  
    348     public function isInvisible() 
    349     { 
    350       return (($this->mRow['is_invisible'] == 't') ? true : false); 
     299    public function setEmail($email) { 
     300        $email_str = $this->mDb->escapeString($email); 
     301        if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET email='{$email_str}' WHERE user_id='{$this->id}'"))) { 
     302            throw new Exception(_("Could not update email address.")); 
     303        } 
     304        $this->mRow['email'] = $email; // unescaped 
     305    } 
     306 
     307    function setIsInvisible($value) { 
     308        $retval = true; 
     309        if ($value != $this->isAdvertised()) { 
     310            global $db; 
     311            $value ? $value = 'TRUE' : $value = 'FALSE'; 
     312            $retval = $db->execSqlUpdate("UPDATE users SET is_invisible = {$value} WHERE user_id = '{$this->getId()}'", false); 
     313            $this->refresh(); 
     314        } 
     315        return $retval; 
     316    } 
     317 
     318    public function isInvisible() { 
     319        return (($this->mRow['is_invisible'] == 't') ? true : false); 
    351320    } 
    352321 
    353322    /**What locale (language) does the user prefer? */ 
    354     public function getPreferedLocale() 
    355     { 
    356       global $session; 
    357       $locale = $this->mRow['prefered_locale']; 
    358       if (empty($locale) && !empty($session)) 
    359         $locale = $session->get(SESS_LANGUAGE_VAR); 
    360       if (empty($locale)) 
    361         $locale = DEFAULT_LANG; 
    362       return $locale; 
    363     } 
    364  
    365     public function setPreferedLocale($locale) 
    366     { 
    367       $locale_str = $this->mDb->escapeString($locale); 
    368       if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET prefered_locale='{$locale_str}' WHERE user_id='{$this->id}'"))) 
    369         { 
    370           throw new Exception(_("Could not update username locale.")); 
    371         } 
    372       $this->mRow['prefered_locale'] = $locale; 
     323    public function getPreferedLocale() { 
     324        global $session; 
     325        $locale = $this->mRow['prefered_locale']; 
     326