Show
Ignore:
Timestamp:
09/03/06 18:54:01 (6 years ago)
Author:
max-horvath
Message:

"2006-09-03 Max Horvath <max.horvath@…>

  • The term SPLASH_ONLY_USER displayed to people visiting the portal has been replaced by the more meaningful term \"anonymous user\" (fixes #106)
  • When creating a new node and choosing an existing node_id there will be shown an error message (fixes #223)
  • If one or more nodes aren't monitored they now will be announced on the front page (instead of just showing the number of monitored online nodes) (fixes #100)
  • Display more meaningful error messages if required user permissions are missing (fixes #242)
  • Refactored Network->getAdminUI() to match look and feel of Node->getAdminUI (fixes #140)
  • Show descriptive status of node (fixes #241)"
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/Statistics.php

    r1088 r1089  
    4747 */ 
    4848require_once('include/common.php'); 
     49require_once('classes/MainUI.php'); 
    4950 
    5051/** 
     
    378379     * 
    379380     * @return string HTML markup 
     381     * 
     382     * @access private 
    380383     */ 
    381384    private function getSelectedNodesUI() 
    382385    { 
     386        // Define globals 
    383387        global $db; 
     388 
     389        // Init values 
    384390        $html = ''; 
     391 
    385392        $name = "statistics_selected_nodes[]"; 
    386         $user = User :: getCurrentUser(); 
    387         if ($user->isSuperAdmin()) 
    388         { 
    389             $sql_join = ''; 
    390         } 
    391         else 
    392         { 
    393             $user_id = $db->escapeString($user->getId()); 
    394             $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='$user_id') "; 
    395         } 
    396         $sql = "SELECT nodes.node_id, nodes.name from nodes $sql_join WHERE 1=1 ORDER BY lower(node_id)"; 
    397         $node_rows = null; 
    398         $db->execSql($sql, $node_rows, false); 
    399         $html .= "<select multiple size = 6 name='$name'>\n"; 
    400  
    401         /*count($this->report_selected_nodes)==0?$selected=' SELECTED ':$selected=''; 
    402                     $html.= "<option value='' $selected>"._("Statistics for all nodes")."</option>\n"; 
    403         */ 
    404         if ($node_rows != null) 
    405         { 
    406             foreach ($node_rows as $node_row) 
    407             { 
    408                 $html .= "<option "; 
    409                 if (array_key_exists($node_row['node_id'], $this->report_selected_nodes)) 
    410                 { 
    411                     $html .= " SELECTED "; 
     393        $user = User::getCurrentUser(); 
     394 
     395        try { 
     396            if (!isset($user)) { 
     397                throw new Exception(_('Access denied!')); 
     398            } else if ((!$user->isSuperAdmin() && !$user->isOwner()) || $user->isNobody()) { 
     399                throw new Exception(_('Access denied!')); 
     400            } 
     401 
     402            if ($user->isSuperAdmin()) { 
     403                $sql_join = ''; 
     404            } else { 
     405                $user_id = $db->escapeString($user->getId()); 
     406                $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='$user_id') "; 
     407            } 
     408 
     409            $sql = "SELECT nodes.node_id, nodes.name from nodes $sql_join WHERE 1=1 ORDER BY lower(node_id)"; 
     410            $node_rows = null; 
     411            $db->execSql($sql, $node_rows, false); 
     412            $html .= "<select multiple size = 6 name='$name'>\n"; 
     413 
     414            if ($node_rows != null) { 
     415                foreach ($node_rows as $node_row) { 
     416                    $html .= "<option "; 
     417 
     418                    if (array_key_exists($node_row['node_id'], $this->report_selected_nodes)) { 
     419                        $html .= " SELECTED "; 
     420                    } 
     421 
     422                    $nom = $node_row['node_id'].": ".$node_row['name']; 
     423                    $nom = htmlspecialchars($nom, ENT_QUOTES, 'UTF-8'); 
     424                    $primary_key = htmlentities($node_row['node_id'], ENT_QUOTES, 'UTF-8'); 
     425                    $html .= "value='$primary_key'>$nom</option>\n"; 
    412426                } 
    413  
    414                 $nom = $node_row['node_id'].": ".$node_row['name']; 
    415                 $nom = htmlspecialchars($nom, ENT_QUOTES, 'UTF-8'); 
    416                 $primary_key = htmlentities($node_row['node_id'], ENT_QUOTES, 'UTF-8'); 
    417                 $html .= "value='$primary_key'>$nom</option>\n"; 
    418             } 
    419         } 
    420         $html .= "</select>\n"; 
     427            } 
     428 
     429            $html .= "</select>\n"; 
     430        } catch (Exception $e) { 
     431            $ui = new MainUI(); 
     432            $ui->setToolSection('ADMIN'); 
     433            $ui->displayError($e->getMessage(), false); 
     434            exit; 
     435        } 
     436 
    421437        return $html; 
    422438    }