Changeset 1089
- Timestamp:
- 09/03/06 18:54:01 (5 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 9 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/admin/generic_object_admin.php (modified) (1 diff)
-
wifidog/classes/Content.php (modified) (11 diffs)
-
wifidog/classes/Network.php (modified) (57 diffs)
-
wifidog/classes/Node.php (modified) (13 diffs)
-
wifidog/classes/Server.php (modified) (3 diffs)
-
wifidog/classes/Statistics.php (modified) (2 diffs)
-
wifidog/node_list.php (modified) (2 diffs)
-
wifidog/templates/sites/index.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1088 r1089 1 2006-09-03 Max Horváth <max.horvath@maxspot.de> 2 * The term SPLASH_ONLY_USER displayed to people visiting the portal has been 3 replaced by the more meaningful term "anonymous user" (fixes #106) 4 * When creating a new node and choosing an existing node_id there will be 5 shown an error message (fixes #223) 6 * If one or more nodes aren't monitored they now will be announced on the 7 front page (instead of just showing the number of monitored online nodes) 8 (fixes #100) 9 * Display more meaningful error messages if required user permissions are 10 missing (fixes #242) 11 * Refactored Network->getAdminUI() to match look and feel of 12 Node->getAdminUI (fixes #140) 13 * Show descriptive status of node (fixes #241) 14 1 15 2006-09-02 Max Horváth <max.horvath@maxspot.de> 2 16 * Installation script checks for PHP session extension (fixes #139) -
trunk/wifidog-auth/wifidog/admin/generic_object_admin.php
r1070 r1089 68 68 require_once('classes/InterfaceElements.php'); 69 69 70 // Check user permissions 71 try { 72 $user = User::getCurrentUser(); 73 74 if (!isset($user)) { 75 throw new Exception(_('Access denied!')); 76 } else if ((!$user->isSuperAdmin() && !$user->isOwner()) || $user->isNobody()) { 77 throw new Exception(_('Access denied!')); 78 } 79 } catch (Exception $e) { 80 $ui = new MainUI(); 81 $ui->setToolSection('ADMIN'); 82 $ui->displayError($e->getMessage(), false); 83 exit; 84 } 85 70 86 // Init values 71 87 $html = ""; -
trunk/wifidog-auth/wifidog/classes/Content.php
r1086 r1089 51 51 require_once ('classes/Cache.php'); 52 52 require_once ('classes/HyperLink.php'); 53 require_once ('classes/MainUI.php'); 54 53 55 /** 54 56 * Defines any type of content … … 104 106 */ 105 107 private $is_logging_enabled; 106 108 107 109 /** Log as part of this other content */ 108 110 private $log_as_content; … … 712 714 * @access public 713 715 */ 714 public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $show_persistant_content = true, $order = "creation_timestamp", $type_interface = "select") { 715 // Define globals 716 global $db; 716 public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $show_persistant_content = true, $order = "creation_timestamp", $type_interface = "select") 717 { 718 // Define globals 719 global $db; 717 720 718 721 // Init values … … 721 724 $contentRows = null; 722 725 723 if (!User :: getCurrentUser()) { 724 throw new Exception(_('Access denied!')); 726 try { 727 if (!User :: getCurrentUser()) { 728 throw new Exception(_('Access denied!')); 729 } 730 } catch (Exception $e) { 731 $ui = new MainUI(); 732 $ui->setToolSection('ADMIN'); 733 $ui->displayError($e->getMessage(), false); 734 exit; 725 735 } 726 736 727 737 if ($type_interface != "table") { 728 $html .= "<fieldset class='admin_container Content'>\n"; 729 if(!empty($title)){ 730 $html .= "<legend>$title</legend>\n"; 731 } 738 $html .= "<fieldset class='admin_container Content'>\n"; 739 740 if (!empty($title)) { 741 $html .= "<legend>$title</legend>\n"; 742 } 743 732 744 $html .= _("Add existing content").": "; 733 745 } … … 752 764 753 765 foreach ($contentRows as $contentRow) { 754 $content = Content ::getObject($contentRow['content_id']);755 756 if (User :: getCurrentUser()->isSuperAdmin() || $content->isOwner(User ::getCurrentUser())) {766 $content = Content::getObject($contentRow['content_id']); 767 768 if (User::getCurrentUser()->isSuperAdmin() || $content->isOwner(User::getCurrentUser())) { 757 769 if ($type_interface != "table") { 758 770 $tab[$i][0] = $content->getId(); … … 1088 1100 1089 1101 1090 /** Allow logging as part of another content (usually the parent for metadata). 1102 /** Allow logging as part of another content (usually the parent for metadata). 1091 1103 * Redirects clickthrough logging to the parent's content id, and does not log 1092 1104 * display */ … … 1180 1192 $this->titleShouldDisplay() ? $checked = 'CHECKED' : $checked = ''; 1181 1193 $html_title_is_displayed .= "<input type='checkbox' name='$name' $checked>\n"; 1182 1194 1183 1195 /* title */ 1184 1196 $html .= "<li class='admin_element_item_container admin_section_edit_title'>\n"; 1185 $html .= "<div class='admin_element_data'>\n"; 1197 $html .= "<div class='admin_element_data'>\n"; 1186 1198 if (empty ($this->content_row['title'])) { 1187 $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:")); 1199 $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:")); 1188 1200 $html .= "</div>\n"; 1189 1201 } else { 1190 $html .= $html_title_is_displayed; 1202 $html .= $html_title_is_displayed; 1191 1203 $title = self :: getObject($this->content_row['title']); 1192 1204 $html .= $title->getAdminUI(null, _("Title:")); … … 1199 1211 $html .= "</li>\n"; 1200 1212 } 1201 1213 1202 1214 if ($this->is_trivial_content == false) { 1203 1215 /* description */ … … 1252 1264 $html .= "</li>\n"; 1253 1265 } 1254 1266 1255 1267 //End content medatada 1256 1268 if ($this->is_trivial_content == false || $this->isPersistent()) { 1257 1269 $html .= "</fieldset>\n"; 1258 1270 } 1259 if ($this->is_trivial_content == false || $this->isPersistent()) { 1271 if ($this->is_trivial_content == false || $this->isPersistent()) { 1260 1272 $html .= "<fieldset class='admin_element_group'>\n"; 1261 1273 $html .= "<legend>".sprintf(_("%s access control"),get_class($this))."</legend>\n"; … … 1330 1342 {//Content medatada 1331 1343 1332 1344 1333 1345 if ($this->is_trivial_content == false || $this->isPersistent()) { 1334 1346 /* title_is_displayed */ … … 1515 1527 return $retval; 1516 1528 } 1517 1529 1518 1530 /** Set if the content group is persistent 1519 1531 * @param $is_locative_content true or false -
trunk/wifidog-auth/wifidog/classes/Network.php
r1085 r1089 1 1 <?php 2 3 2 4 3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ … … 48 47 * Load required classes 49 48 */ 50 require_once ('classes/GenericObject.php'); 51 require_once ('classes/Content.php'); 52 require_once ('classes/User.php'); 53 require_once ('classes/Node.php'); 54 require_once ('classes/GisPoint.php'); 55 require_once ('classes/Cache.php'); 56 require_once ('classes/ThemePack.php'); 49 require_once('classes/GenericObject.php'); 50 require_once('classes/Content.php'); 51 require_once('classes/User.php'); 52 require_once('classes/Node.php'); 53 require_once('classes/GisPoint.php'); 54 require_once('classes/Cache.php'); 55 require_once('classes/ThemePack.php'); 56 require_once('classes/InterfaceElements.php'); 57 require_once('classes/MainUI.php'); 57 58 58 59 /** … … 67 68 * @copyright 2006 Max Horvath, maxspot GmbH 68 69 */ 69 class Network implements GenericObject { 70 private $id; /**< The network id */ 70 class Network implements GenericObject 71 { 72 /** 73 * The network Id 74 * 75 * @var string 76 * 77 * @access private 78 */ 79 private $id; 80 71 81 private $mRow; 72 82 73 /** Get an instance of the object 74 * @see GenericObject 75 * @param $id The object id 76 * @return the Content object, or null if there was an error (an exception is also thrown) 77 */ 78 static public function getObject($id) { 83 /** 84 * Get an instance of the object 85 * 86 * @param string $id The object id 87 * 88 * @return mixed The Content object, or null if there was an error 89 * (an exception is also thrown) 90 * 91 * @see GenericObject 92 * @static 93 * @access public 94 */ 95 public static function getObject($id) 96 { 79 97 return new self($id); 80 98 } 81 99 82 /** Get all the Networks configured on this server 83 * @return an array of Network objects. The default network is returned 84 * first 85 */ 86 static function getAllNetworks() { 100 /** 101 * Get all the Networks configured on this server 102 * 103 * @return array An array of Network objects. The default network is 104 * returned first 105 * 106 * @static 107 * @access public 108 */ 109 public static function getAllNetworks() 110 { 87 111 $retval = array (); 88 112 global $db; … … 99 123 } 100 124 101 /** Get the default network 102 * @return a Network object, NEVER returns null. 103 */ 104 static function getDefaultNetwork($real_network_only = false) { 125 /** 126 * Get the default network 127 * 128 * @param bool $real_network_only Return a real network only? 129 * 130 * @return object A Network object, NEVER returns null. 131 * 132 * @static 133 * @access public 134 */ 135 public static function getDefaultNetwork($real_network_only = false) 136 { 105 137 $retval = null; 106 138 global $db; … … 115 147 } 116 148 117 /** Get the current network for which the portal is displayed or to which a user is physically connected. 118 * @param $real_network_only NOT IMPLEMENTED YET true or false. If true, 119 * the real physical network where the user is connected is returned, and 120 * the node set by setCurrentNode is ignored. 121 * @return a Network object, NEVER returns null. 122 */ 123 static function getCurrentNetwork($real_network_only = false) { 149 /** 150 * Get the current network for which the portal is displayed or to which a 151 * user is physically connected. 152 * 153 * @param bool $real_network_only NOT IMPLEMENTED YET true or false. If 154 * true, the real physical network where the 155 * user is connected is returned, and 156 * the node set by setCurrentNode is ignored. 157 * 158 * @return objetc A Network object, NEVER returns null. 159 * 160 * @static 161 * @access public 162 */ 163 public static function getCurrentNetwork($real_network_only = false) 164 { 124 165 $retval = null; 125 166 $current_node = Node :: getCurrentNode(); 167 126 168 if ($current_node != null) { 127 169 $retval = $current_node->getNetwork(); 128 } 129 else { 170 } else { 130 171 $retval = Network :: getDefaultNetwork(); 131 172 } 173 132 174 return $retval; 133 175 } 134 176 135 /** Create a new Content object in the database 177 /** 178 * Create a new Content object in the database 179 * 180 * @param string $network_id The network id of the new network. If absent, 181 * will be assigned a guid. 182 * 183 * @return mixed The newly created object, or null if there was an error 184 * 136 185 * @see GenericObject 137 * @ param $network_id The network id of the new network. If absent, will be138 * assigned a guid.139 * @return the newly created object, or null if there was an error140 */141 static function createNewObject($network_id = null){186 * @static 187 * @access public 188 */ 189 public static function createNewObject($network_id = null) 190 { 142 191 global $db; 143 192 if (empty ($network_id)) { … … 174 223 * @access public 175 224 */ 176 public static function getSelectNetworkUI($user_prefix, $pre_selected_network = null, $additional_where = null) { 225 public static function getSelectNetworkUI($user_prefix, $pre_selected_network = null, $additional_where = null) 226 { 177 227 $html = ''; 178 228 $name = $user_prefix; … … 180 230 if ($pre_selected_network) { 181 231 $selected_id = $pre_selected_network->getId(); 182 } 183 else { 232 } else { 184 233 $selected_id = null; 185 234 } 235 186 236 global $db; 187 237 $additional_where = $db->escapeString($additional_where); … … 204 254 $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, false); 205 255 206 } 207 else { 256 } else { 208 257 foreach ($network_rows as $network_row) //iterates only once... 209 258 { … … 228 277 * @access public 229 278 */ 230 public static function processSelectNetworkUI($user_prefix) { 279 public static function processSelectNetworkUI($user_prefix) 280 { 231 281 $name = "{$user_prefix}"; 232 if (!empty ($_REQUEST[$name])) 282 283 if (!empty ($_REQUEST[$name])) { 233 284 return new self($_REQUEST[$name]); 234 else285 } else { 235 286 throw new exception(sprintf(_("Unable to retrieve the selected network, the %s REQUEST parameter does not exist"), $name)); 236 } 237 238 /** Get an interface to create a new network. 239 * @return html markup 240 */ 241 public static function getCreateNewObjectUI() { 287 } 288 } 289 290 /** 291 * Get an interface to create a new network. 292 * 293 * @return string HTML markup 294 * 295 * @static 296 * @access public 297 */ 298 public static function getCreateNewObjectUI() 299 { 300 // Init values 242 301 $html = ''; 302 243 303 $html .= _("Create a new network with ID")." \n"; 244 304 $name = "new_network_id"; 245 305 $html .= "<input type='text' size='10' name='{$name}'>\n"; 306 246 307 return $html; 247 248 } 249 250 /** Process the new object interface. 251 * Will return the new object if the user has the credentials and the form was fully filled. 252 * @return the Network object or null if no new Network was created. 253 */ 254 static function processCreateNewObjectUI() { 308 } 309 310 /** 311 * Process the new object interface. 312 * 313 * Will return the new object if the user has the credentials and the form 314 * was fully filled. 315 * 316 * @return mixed The Network object or null if no new Network was created. 317 * 318 * @static 319 * @access public 320 */ 321 public static function processCreateNewObjectUI() 322 { 323 // Init values 255 324 $retval = null; 256 325 $name = "new_network_id"; 257 if (!empty ($_REQUEST[$name])) { 326 327 if (!empty($_REQUEST[$name])) { 258 328 $network_id = $_REQUEST[$name]; 329 259 330 if ($network_id) { 260 if (!User :: getCurrentUser()->isSuperAdmin()) { 261 throw new Exception(_("Access denied")); 331 try { 332 if (!User::getCurrentUser()->isSuperAdmin()) { 333 throw new Exception(_("Access denied")); 334 } 335 } catch (Exception $e) { 336 $ui = new MainUI(); 337 $ui->setToolSection('ADMIN'); 338 $ui->displayError($e->getMessage(), false); 339 exit; 262 340 } 263 $retval = self :: createNewObject($network_id); 264 } 265 } 341 342 $retval = self::createNewObject($network_id); 343 } 344 } 345 266 346 return $retval; 267 347 } 268 348 269 private function __construct($p_network_id) { 349 /** 350 * Constructor 351 * 352 * @param string $p_network_id 353 * 354 * @return void 355 * 356 * @access private 357 */ 358 private function __construct($p_network_id) 359 { 360 // Define globals 270 361 global $db; 271 362 … … 281 372 } 282 373 283 /** Retreives the id of the object 284 * @return The id */ 285 public function getId() { 374 /** 375 * Retreives the id of the object 376 * 377 * @return string The id 378 * 379 * @access public 380 */ 381 public function getId() 382 { 286 383 return $this->id; 287 384 } 288 385 289 /** Retreives the network name 290 * @return The id */ 291 public function getTechSupportEmail() { 386 /** 387 * Retreives the network name 388 * 389 * @return string The id 390 * 391 * @access public 392 */ 393 public function getTechSupportEmail() 394 { 292 395 return $this->mRow['tech_support_email']; 293 396 } 294 397 295 /** Set the network's tech support and information email address 296 * @param $value The new value 297 * @return true on success, false on failure */ 298 function setTechSupportEmail($value) { 398 /** 399 * Set the network's tech support and information email address 400 * 401 * @param string $value The new value 402 * 403 * @return bool True on success, false on failure 404 * 405 * @access public 406 */ 407 public function setTechSupportEmail($value) 408 { 409 // Init values 299 410 $retval = true; 411 300 412 if ($value != $this->getName()) { 301 413 global $db; … … 304 416 $this->refresh(); 305 417 } 418 306 419 return $retval; 307 420 } … … 309 422 /** 310 423 * Retrieves the network name 311 * @return A string 312 */ 313 public function getName() { 424 * 425 * @return string A string 426 * 427 * @access public 428 */ 429 public function getName() 430 { 314 431 return $this->mRow['name']; 315 432 } 316 433 317 /** Set the network's name 318 * @param $value The new value 319 * @return true on success, false on failure 320 */ 321 function setName($value) { 434 /** 435 * Set the network's name 436 * 437 * @param string $value The new value 438 * 439 * @return bool True on success, false on failure 440 * 441 * @access public 442 */ 443 public function setName($value) 444 { 445 // Init values 322 446 $retval = true; 447 323 448 if ($value != $this->getName()) { 324 449 global $db; … … 327 452 $this->refresh(); 328 453 } 454 329 455 return $retval; 330 456 } … … 332 458 /** 333 459 * Retrieves the network's theme pack 334 * @return ThemePack or null 335 */ 336 public function getThemePack() { 460 * 461 * @return mixed ThemePack or null 462 * 463 * @access public 464 */ 465 public function getThemePack() 466 { 337 467 if (!empty ($this->mRow['theme_pack'])) { 338 468 return ThemePack::getObject($this->mRow['theme_pack']); 339 } 340 else { 469 } else { 341 470 return null; 342 471 } 343 472 } 344 473 345 /** Set the network's name 346 * @param $value The new ThemePack, or null 347 * @return true on success, false on failure 348 */ 349 function setThemePack($value) { 474 /** 475 * Set the network's name 476 * 477 * @param string $value The new ThemePack, or null 478 * 479 * @return bool True on success, false on failure 480 * 481 * @access public 482 */ 483 public function setThemePack($value) 484 { 485 // Init values 350 486 $retval = true; 487 351 488 if ($value != $this->getThemePack()) { 352 489 global $db; … … 355 492 $this->refresh(); 356 493 } 494 357 495 return $retval; 358 496 } 497 359 498 /** 360 499 * Retrieves the network's creation date 361 500 * 362 501 * @return string Network's creation date 363 */ 364 public function getCreationDate() { 502 * 503 * @access public 504 */ 505 public function getCreationDate() 506 { 365 507 return $this->mRow['creation_date']; 366 508 } … … 375 517 * @access public 376 518 */ 377 public function setCreationDate($value) { 519 public function setCreationDate($value) 520 { 378 521 // Define globals 379 522 global $db; … … 391 534 } 392 535 393 /** Retreives the network's homepage url 394 * @return The id */ 395 public function getHomepageURL() { 536 /** 537 * Retreives the network's homepage url 538 * 539 * @return string The id 540 * 541 * @access public 542 */ 543 public function getHomepageURL() 544 { 396 545 return $this->mRow['homepage_url']; 397 546 } 398 547 399 /** Set the network's homepage url 400 * @param $value The new value 401 * @return true on success, false on failure */ 402 function setHomepageURL($value) { 548 /** 549 * Set the network's homepage url 550 * 551 * @param string $value The new value 552 * 553 * @return bool True on success, false on failure 554 * 555 * @access public 556 */ 557 public function setHomepageURL($value) 558 { 559 // Init values 403 560 $retval = true; 561 404 562 if ($value != $this->getName()) { 405 563 global $db; … … 408 566 $this->refresh(); 409 567 } 568 410 569 return $retval; 411 570 } … … 418 577 * @access public 419 578 */ 420 public function getAuthenticatorClassName() { 579 public function getAuthenticatorClassName() 580 { 421 581 return $this->mRow['network_authenticator_class']; 422 582 } … … 434 594 * @access public 435 595 */ 436 public function setAuthenticatorClassName($value) { 596 public function setAuthenticatorClassName($value) 597 { 437 598 // Define globals 438 599 global $db; … … 457 618 * @access public 458 619 */ 459 public function getAuthenticatorConstructorParams() { 620 public function getAuthenticatorConstructorParams() 621 { 460 622 return $this->mRow['network_authenticator_params']; 461 623 } … … 472 634 * @access public 473 635 */ 474 public function setAuthenticatorConstructorParams($value) { 636 public function setAuthenticatorConstructorParams($value) 637 { 475 638 // Define globals 476 639 global $db; … … 495 658 * @access public 496 659 */ 497 public function getAuthenticator() { 660 public function getAuthenticator() 661 { 498 662 require_once ('classes/Authenticator.php'); 499 663 … … 516 680 * @access public 517 681 */ 518 public static function getAvailableAuthenticators() { 682 public static function getAvailableAuthenticators() 683 { 519 684 // Init values 520 685 $_authenticators = array (); … … 589 754 * @access public 590 755 */ 591 public static function getSelectAuthenticator($user_prefix, $pre_selected_authenticator = null) { 592 // Define globals 593 global $db; 756 public static function getSelectAuthenticator($user_prefix, $pre_selected_authenticator = null) 757 { 758 // Define globals 759 global $db; 594 760 595 761 // Init values … … 617 783 * Is the network the default network? 618 784 * 619 * @return true or false 620 */ 621 public function isDefaultNetwork() { 785 * @return bool True or false 786 * 787 * @access public 788 */ 789 public function isDefaultNetwork() 790 { 622 791 ($this->mRow['is_default_network'] == 't') ? $retval = true : $retval = false; 623 792 return $retval; 624 793 } 625 794 626 /** Set as the default network. The can only be one default network, so this method will unset is_default_network for all other network 627 * @return true on success, false on failure */ 628 function setAsDefaultNetwork() { 795 /** 796 * Set as the default network. 797 * 798 * The can only be one default network, so this method will unset 799 * is_default_network for all other network 800 * 801 * @return bool True on success, false on failure 802 * 803 * @access public 804 */ 805 public function setAsDefaultNetwork() 806 { 807 // Init values 629 808 $retval = true; 809 630 810 if (!$this->isDefaultNetwork()) { 631 811 global $db; … … 635 815 $this->refresh(); 636 816 } 817 637 818 return $retval; 638 819 } 639 820 640 /** Retreives the network's validation grace period 641 * @return An integer (seconds) */ 642 public function getValidationGraceTime() { 821 /** 822 * Retreives the network's validation grace period 823 * 824 * @return int Network's validation grace period in seconds 825 * 826 * @access public 827 */ 828 public function getValidationGraceTime() 829 { 643 830 return $this->mRow['validation_grace_time_seconds']; 644 831 } 645 832 646 /** Set the network's validation grace period in seconds. A new user is granted Internet access for this period check his email and validate his account. 647 * @param $value The new value 648 * @return true on success, false on failure */ 649 function setValidationGraceTime($value) { 833 /** 834 * Set the network's validation grace period in seconds. 835 * 836 * A new user is granted Internet access for this period check his email 837 * and validate his account. 838 * 839 * @param int $value The new value 840 * 841 * @return bool True on success, false on failure 842 * 843 * @access public 844 */ 845 public function setValidationGraceTime($value) 846 { 847 // Init values 650 848 $retval = true; 849 651 850 if ($value != $this->getValidationGraceTime()) { 652 851 global $db; … … 655 854 $this->refresh(); 656 855 } 856 657 857 return $retval; 658 858 } 659 859 660 /** Retreives the FROM adress of the validation email 661 * @return A string */ 662 public function getValidationEmailFromAddress() { 860 /** 861 * Retreives the FROM adress of the validation email 862 * 863 * @return string A string 864 * 865 * @access public 866 */ 867 public function getValidationEmailFromAddress() 868 { 663 869 return $this->mRow['validation_email_from_address']; 664 870 } 665 871 666 /** Set the FROM adress of the validation email 667 * @param $value The new value 668 * @return true on success, false on failure */ 669 function setValidationEmailFromAddress($value) { 872 /** 873 * Set the FROM adress of the validation email 874 * 875 * @param string $value The new value 876 * 877 * @return bool True on success, false on failure 878 * 879 * @access public 880 */ 881 public function setValidationEmailFromAddress($value) 882 { 883 // Init values 670 884 $retval = true; 885 671 886 if ($value != $this->getValidationEmailFromAddress()) { 672 887 global $db; … … 675 890 $this->refresh(); 676 891 } 892 677 893 return $retval; 678 894 } 679 895 680 /** Can an account be connected more than once at the same time? 681 * @return true or false */ 682 public function getMultipleLoginAllowed() { 896 /** 897 * Can an account be connected more than once at the same time? 898 * 899 * @return bool True or false 900 * 901 * @access public 902 */ 903 public function getMultipleLoginAllowed() 904 { 683 905 return ($this->mRow['allow_multiple_login'] == 't') ? true : false; 684 906 } 685 907 686 /** Set if a account be connected more than once at the same time? 687 * @param $value The new value, true or false 688 * @return true on success, false on failure */ 689 function setMultipleLoginAllowed($value) { 908 /** 909 * Set if a account be connected more than once at the same time 910 * 911 * @param bool $value The new value, true or false 912 * 913 * @return bool true on success, false on failure 914 * 915 * @access public 916 */ 917 public function setMultipleLoginAllowed($value) 918 { 919 // Init values 690 920 $retval = true; 921 691 922 if ($value != $this->getMultipleLoginAllowed()) { 692 923 global $db; … … 695 926 $this->refresh(); 696 927 } 928 697 929 return $retval; 698 930 } 699 931 700 /** Are nodes allowed to be set as splash-only (no login)? 701 * @return true or false */ 702 public function getSplashOnlyNodesAllowed() { 932 /** 933 * Are nodes allowed to be set as splash-only (no login)? 934 * 935 * @return bool True or false 936 * 937 * @access public 938 */ 939 public function getSplashOnlyNodesAllowed() 940 { 703 941 return (($this->mRow['allow_splash_only_nodes'] == 't') ? true : false); 704 942 } 705 943 706 /** Set if nodes are allowed to be set as splash-only (no login) 707 * @param $value The new value, true or false 708 * @return true on success, false on failure */ 709 function setSplashOnlyNodesAllowed($value) { 944 /** 945 * Set if nodes are allowed to be set as splash-only (no login) 946 * 947 * @param bool $value The new value, true or false 948 * 949 * @return bool True on success, false on failure 950 * 951 * @access public 952 */ 953 public function setSplashOnlyNodesAllowed($value) 954 { 955 // Init values 710 956 $retval = true; 957 711 958 if ($value != $this->getSplashOnlyNodesAllowed()) { 712 959 global $db; … … 715 962 $this->refresh(); 716 963 } 964 717 965 return $retval; 718 966 } … … 725 973 * @access public 726 974 */ 727 public function getGisLocation() { 975 public function getGisLocation() 976 { 728 977 return new GisPoint($this->mRow['gmaps_initial_latitude'], $this->mRow['gmaps_initial_longitude'], $this->mRow['gmaps_initial_zoom_level']); 729 978 } … … 738 987 * @access public 739 988 */ 740 public function setGisLocation($pt) { 989 public function setGisLocation($pt) 990 { 741 991 // Define globals 742 992 global $db; … … 765 1015 * @access public 766 1016 */ 767 public function getGisMapType() { 1017 public function getGisMapType() 1018 { 768 1019 return $this->mRow['gmaps_map_type']; 769 1020 } … … 778 1029 * @access public 779 1030 */ 780 public function setGisMapType($value) { 1031 public function setGisMapType($value) 1032 { 781 1033 // Define globals 782 1034 global $db; … … 807 1059 * @access public 808 1060 */ 809 public static function getSelectGisMapType($user_prefix, $pre_selected_map_type = "G_NORMAL_MAP") { 810 // Define globals 811 global $db; 1061 public static function getSelectGisMapType($user_prefix, $pre_selected_map_type = "G_NORMAL_MAP") 1062 { 1063 // Define globals 1064 global $db; 812 1065 813 1066 // Init values … … 828 1081 } 829 1082 830 /** Get's the splash-only user. This is the user that people logged-in at a splash-only hotspot will show up as. This user always has multiple-login capabilities. 831 * @param $username The username of the user 832 * @param $account_origin The account origin 833 * @return a User object 834 */ 835 public function getSplashOnlyUser() { 1083 /** 1084 * Get's the splash-only user. 1085 * 1086 * This is the user that people logged-in at a splash-only hotspot will 1087 * show up as. This user always has multiple-login capabilities. 1088 * 1089 * @param string $username The username of the user 1090 * @param string $account_origin The account origin 1091 * 1092 * @return object A User object 1093 * 1094 * @access public 1095 */ 1096 public function getSplashOnlyUser() 1097 { 836 1098 $username = 'SPLASH_ONLY_USER'; 837 1099 … … 851 1113 * @access public 852 1114 */ 853 public function getNumUsers() { 1115 public function getNumUsers() 1116 { 854 1117 // Define globals 855 1118 global $db; … … 900 1163 * @access public 901 1164 */ 902 public function getNumValidUsers() { 1165 public function getNumValidUsers() 1166 { 903 1167 // Define globals 904 1168 global $db; … … 950 1214 * @access public 951 1215 */ 952 public function getNumOnlineUsers() { 1216 public function getNumOnlineUsers() 1217 { 953 1218 // Define globals 954 1219 global $db; … … 999 1264 * @access public 1000 1265 */ 1001 public function getNumNodes() { 1266 public function getNumNodes() 1267 { 1002 1268 // Define globals 1003 1269 global $db; … … 1048 1314 * @access public 1049 1315 */ 1050 public function getNumDeployedNodes() { 1316 public function getNumDeployedNodes() 1317 { 1051 1318 // Define globals 1052 1319 global $db; … … 1093 1360 * Find out how many deployed nodes are online in this networks's database 1094 1361 * 1362 * @param bool $nonMonitoredOnly Return number of non-monitored nodes only 1363 * 1095 1364 * @return int Number of deployed nodes which are online 1096 1365 * 1097 1366 * @access public 1098 1367 */ 1099 public function getNumOnlineNodes() { 1368 public function getNumOnlineNodes($nonMonitoredOnly = false) 1369 { 1100 1370 // Define globals 1101 1371 global $db; … … 1108 1378 1109 1379 // Create new cache objects (valid for 5 minutes) 1110 $_cache = new Cache('network_'.$this->id.'_num_online_nodes', $this->id, 300); 1380 if ($nonMonitoredOnly) { 1381 $_cache = new Cache('network_'.$this->id.'_num_online_nodes_non_monitored', $this->id, 300); 1382 } else { 1383 $_cache = new Cache('network_'.$this->id.'_num_online_nodes', $this->id, 300); 1384 } 1111 1385 1112 1386 // Check if caching has been enabled. … … 1124 1398 // Get number of online nodes 1125 1399 $_network_id = $db->escapeString($this->id); 1126 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((NOW()-last_heartbeat_timestamp) < interval '5 minutes')", $_row, false); 1400 1401 if ($nonMonitoredOnly) { 1402 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND node_deployment_status = 'NON_WIFIDOG_NODE' AND ((NOW()-last_heartbeat_timestamp) >= interval '5 minutes')", $_row, false); 1403 } else { 1404 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((NOW()-last_heartbeat_timestamp) < interval '5 minutes')", $_row, false); 1405 } 1127 1406 1128 1407 // String has been found … … 1139 1418 } 1140 1419 1141 /** Are nodes allowed to redirect users to an arbitrary web page instead of the portal? 1142 * @return true or false */ 1143 public function getCustomPortalRedirectAllowed() { 1420 /** 1421 * Are nodes allowed to redirect users to an arbitrary web page instead of 1422 * the portal? 1423 * 1424 * @return bool True or false 1425 * 1426 * @access public 1427 */ 1428 public function getCustomPortalRedirectAllowed() 1429 { 1144 1430 return (($this->mRow['allow_custom_portal_redirect'] == 't') ? true : false); 1145 1431 } 1146 1432 1147 /** Set if nodes are allowed to redirect users to an arbitrary web page instead of the portal? 1148 * @param $value The new value, true or false 1149 * @return true on success, false on failure */ 1150 function setCustomPortalRedirectAllowed($value) { 1433 /** 1434 * Set if nodes are allowed to redirect users to an arbitrary web page 1435 * instead of the portal? 1436 * 1437 * @param bool $value The new value, true or false 1438 * 1439 * @return bool True on success, false on failure 1440 * 1441 * @access public 1442 */ 1443 public function setCustomPortalRedirectAllowed($value) 1444 { 1445 // Init values 1151 1446 $retval = true; 1447 1152 1448 if ($value != $this->getCustomPortalRedirectAllowed()) { 1153 1449 global $db; … … 1156 1452 $this->refresh(); 1157 1453 } 1454 1158 1455 return $retval; 1159 1456 } … … 1161 1458 /** 1162 1459 * Does the user have admin access to this network? 1163 * @return boolean true our false 1164 */ 1165 function hasAdminAccess(User $user) { 1460 * 1461 * @return bool true our false 1462 * 1463 * @access public 1464 */ 1465 public function hasAdminAccess(User $user) 1466 { 1166 1467 // Define globals 1167 1468 global $db; … … 1203 1504 // Define globals 1204 1505 global $db; 1205 1506 1206 1507 // Init values 1207 1508 $content_rows = null; 1208 1509 $retval = array (); 1209 1510 1210 1511 // Get all network, but exclude user subscribed content if asked 1211 1512 if ($exclude_subscribed_content == true && $subscriber) { … … 1214 1515 $sql = "SELECT content_id FROM network_has_content WHERE network_id='$this->id' ORDER BY subscribe_timestamp DESC"; 1215 1516 } 1216 1517 1217 1518 $db->execSql($sql, $content_rows, false); 1218 1519 1219 1520 if ($content_rows != null) { 1220 1521 foreach ($content_rows as $content_row) { … … 1222 1523 } 1223 1524 } 1224 1525 1225 1526 return $retval; 1226 1527 } 1227 1528 */ 1529 1228 1530 /** 1229 1531 * Retreives the admin interface of this object … … 1233 1535 * @access public 1234 1536 */ 1235 public function getAdminUI() { 1537 public function getAdminUI() 1538 { 1539 // Init values 1236 1540 $html = ''; 1541 1542 /* 1543 * Begin with admin interface 1544 */ 1237 1545 $html .= "<fieldset class='admin_container ".get_class($this)."'>\n"; 1238 1546 $html .= "<legend>"._("Network management")."</legend>\n"; 1239 1547 $html .= "<ul class='admin_element_list'>\n"; 1240 1548 1241 // Content management 1549 /* 1550 * Content management 1551 */ 1242 1552 $title = _("Network content"); 1243 1553 $name = "network_".$this->id."_content"; 1244 $data = Content :: getLinkedContentUI($name, "network_has_content", "network_id", $this->id, $display_page = "portal"); 1245 $html .= InterfaceElements :: generateAdminSectionContainer("network_content", $title, $data); 1554 $data = Content::getLinkedContentUI($name, "network_has_content", "network_id", $this->id, $display_page = "portal"); 1555 $html .= InterfaceElements::generateAdminSectionContainer("network_content", $title, $data); 1556 1557 /* 1558 * Network information 1559 */ 1560 $html_network_information = array(); 1246 1561 1247 1562 // network_id 1248 $html .= "<li class='admin_element_item_container'>\n"; 1249 $html .= "<div class='admin_element_label'>"._("Network ID")." : </div>\n"; 1250 $html .= "<div class='admin_element_data'>\n"; 1251 $value = htmlspecialchars($this->getId(), ENT_QUOTES); 1252 $html .= $value; 1253 $html .= "</div>\n"; 1254 $html .= "</li>\n"; 1563 $title = _("Network ID"); 1564 $data = htmlspecialchars($this->getId(), ENT_QUOTES); 1565 $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_id", $title, $data); 1255 1566 1256 1567 // name 1257 $html .= "<li class='admin_element_item_container'>\n"; 1258 $html .= "<div class='admin_element_label'>"._("Network name")." : </div>\n"; 1259 $html .= "<div class='admin_element_data'>\n"; 1260 $name = "network_".$this->getId()."_name"; 1261 $value = htmlspecialchars($this->getName(), ENT_QUOTES); 1262 $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 1263 $html .= "</div>\n"; 1264 $html .= "</li>\n"; 1568 $title = _("Network name"); 1569 $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_name", $this->getName(), "network_name_input"); 1570 $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_name", $title, $data); 1265 1571 1266 1572 // creation_date 1267 $name = "network_".$this->getId()."_creation_date"; 1268 $value = htmlspecialchars($this->getCreationDate(), ENT_QUOTES); 1269 1270 $html .= "<li class='admin_element_item_container'>\n"; 1271 $html .= "<div class='admin_element_label'>"._("Network creation date").":</div>\n"; 1272 $html .= "<div class='admin_element_data'>\n"; 1273 $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 1274 $html .= "</div>\n"; 1275 $html .= "</li>\n"; 1276 1573 $title = _("Network creation date"); 1574 $data = DateTime::getSelectDateTimeUI(new DateTime($this->getCreationDate()), "network_" . $this->getId() . "_creation_date", DateTime::INTERFACE_DATETIME_FIELD, "network_creation_date_input"); 1575 $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_creation_date", $title, $data); 1576 1277 1577 // homepage_url 1278 $html .= "<li class='admin_element_item_container'>\n"; 1279 $html .= "<div class='admin_element_label'>"._("Network's web site")." : </div>\n"; 1280 $html .= "<div class='admin_element_data'>\n"; 1281 $name = "network_".$this->getId()."_homepage_url"; 1282 $value = htmlspecialchars($this->getHomepageURL(), ENT_QUOTES); 1283 $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 1284 $html .= "</div>\n"; 1285 $html .= "</li>\n"; 1578 $title = _("Network's web site"); 1579 $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_homepage_url", $this->getHomepageURL(), "network_homepage_url_input"); 1580 $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_homepage_url", $title, $data); 1286 1581 1287 1582 // tech_support_email 1288 $html .= "<li class='admin_element_item_container'>\n"; 1289 $html .= "<div class='admin_element_label'>"._("Technical support email")." : </div>\n"; 1290 $html .= "<div class='admin_element_data'>\n"; 1291 $name = "network_".$this->getId()."_tech_support_email"; 1292 $value = htmlspecialchars($this->getTechSupportEmail(), ENT_QUOTES); 1293 $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 1294 $html .= "</div>\n"; 1295 $html .= "</li>\n"; 1583 $title = _("Technical support email"); 1584 $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_tech_support_email", $this->getTechSupportEmail(), "network_tech_support_email_input"); 1585 $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_tech_support_email", $title, $data); 1586 1587 // Build section 1588 $html .= InterfaceElements::generateAdminSectionContainer("network_information", _("Information about the network"), implode(null, $html_network_information)); 1589 1590 /* 1591 * Network authentication 1592 */ 1593 $html_network_authentication = array(); 1296 1594 1297 1595 // network_authenticator_class 1298 $html .= "<li class='admin_element_item_container'>\n"; 1299 $html .= "<div class='admin_element_label'>"._("Network authenticator class. The subclass of Authenticator to be used for user authentication (ex: AuthenticatorRadius)")." : </div>\n"; 1300 $html .= "<div class='admin_element_data'>\n"; 1301 $name = "network_".$this->getId()."_network_authenticator_class"; 1596 $title = _("Network authenticator class"); 1597 $help = _("The subclass of Authenticator to be used for user authentication. Example: AuthenticatorRadius"); 1598 $name = "network_" . $this->getId() . "_network_authenticator_class"; 1302 1599 $value = htmlspecialchars($this->getAuthenticatorClassName(), ENT_QUOTES); 1303 $html .= $this->getSelectAuthenticator($name, $value); 1304 $html .= "</div>\n"; 1305 $html .= "</li>\n"; 1600 $data = $this->getSelectAuthenticator($name, $value); 1601 $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_class", $title, $data, $help); 1306 1602 1307 1603 // network_authenticator_params 1308 $html .= "<li class='admin_element_item_container'>\n"; 1309 $html .= "<div class='admin_element_label'>"._("The explicit parameters to be passed to the authenticator (ex: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5')")." : </div>\n"; 1310 $html .= "<div class='admin_element_data'>\n"; 1311 $name = "network_".$this->getId()."_network_authenticator_params"; 1312 $value = htmlspecialchars($this->getAuthenticatorConstructorParams(), ENT_QUOTES); 1313 $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 1314 $html .= "</div>\n"; 1315 $html .= "</li>\n"; 1604 $title = _("Authenticator parameters"); 1605 $help = _("The explicit parameters to be passed to the authenticator. Example: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5'"); 1606 $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_network_authenticator_params", $this->getAuthenticatorConstructorParams(), "network_network_authenticator_params_input"); 1607 $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_params", $title, $data, $help); 1608 1609 // Build section 1610 $html .= InterfaceElements::generateAdminSectionContainer("network_authentication", _("Network Authentication"), implode(null, $html_network_authentication)); 1611 1612 /* 1613 * Network properties 1614 */ 1615 $html_network_properties = array(); 1316 1616 1317 1617 // is_default_network 1318 $html .= "<li class='admin_element_item_container'>\n"; 1319 $html .= "<div class='admin_element_label'>"._("Is this network the default network?")." : </div>\n"; 1320 $html .= "<div class='admin_element_data'>\n"; 1321 $name = "network_".$this->getId()."_is_default_network"; 1322 $this->isDefaultNetwork() ? $checked = 'CHECKED' : $checked = ''; 1323 $html .= "<input type='checkbox' name='$name' $checked>\n"; 1324 $html .= "</div>\n"; 1325 $html .= "</li>\n"; 1618 $title = _("Is this network the default network?"); 1619 $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_is_default_network", "", _("Yes"), $this->isDefaultNetwork(), "network_is_default_network_radio"); 1620 $html_network_properties[] = InterfaceElements::generateAdminSectionContainer("network_is_default_network", $title, $data); 1621 1622 // theme_pack 1623 $title = _("Selected theme pack for this network"); 1624 $data = ThemePack::getSelectUI("network_" . $this->getId() . "_theme_pack", $this->getThemePack()); 1625 $html_network_properties[] = InterfaceElements::generateAdminSectionContainer("network_theme_pack", $title, $data); 1626 1627 // Build section 1628 $html .= InterfaceElements::generateAdminSectionContainer("network_properties", _("Network properties"), implode(null, $html_network_properties)); 1629 1630 /* 1631 * Network's node properties 1632 */ 1633 $html_network_node_properties = array(); 1634 1635 // allow_splash_only_nodes 1636 $title = _("Splash-only nodes"); 1637 $help = _("Are nodes allowed to be set as splash-only (no login)?"); 1638 $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_splash_only_nodes", "", _("Yes"), $this->getSplashOnlyNodesAllowed(), "network_allow_splash_only_nodes_radio"); 1639 $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_splash_only_nodes", $title, $data, $help); 1640 1641 // allow_custom_portal_redirect 1642 $title = _("Portal page redirection"); 1643 $help = _("Are nodes allowed to redirect users to an arbitrary web page instead of the portal?"); 1644 $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_custom_portal_redirect", "", _("Yes"), $this->getCustomPortalRedirectAllowed(), "network_allow_custom_portal_redirect_radio"); 1645 $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_custom_portal_redirect", $title, $data, $help); 1646 1647 // Build section 1648 $html .= InterfaceElements::generateAdminSectionContainer("network_node_properties", _("Network's node properties"), implode(null, $html_network_node_properties)); 1649 1650 /* 1651 * Network's user verification 1652 */ 1653 $html_network_user_verification = array(); 1326 1654 1327 1655 // validation_grace_time 1328 $html .= "<li class='admin_element_item_container'>\n"; 1329 $html .= "<div class='admin_element_label'>"._("The length of the validation grace period in seconds. A new user is granted Internet access for this period check his email and validate his account.")." : </div>\n"; 1330 $html .= "<div class='admin_element_data'>\n"; 1331 $name = "network_".$this->getId()."_validation_grace_time"; 1332 $value = htmlspecialchars($this->getValidationGraceTime(), ENT_QUOTES); 1333 $html .= "<input type='text' size ='5' value='$value' name='$name'>\n"; 1334 $html .= "</div>\n"; 1335 $html .= "</li>\n"; 1656 $title = _("Validation grace period"); 1657 $help = _("The length of the validation grace period in seconds. A new user is granted Internet access for this period check his email and validate his account."); 1658 $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_grace_time", $this->getValidationGraceTime(), "network_validation_grace_time_input"); 1659 $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_grace_time", $title, $data, $help); 1336 1660 1337 1661 // validation_email_from_address 1338 $html .= "<li class='admin_element_item_container'>\n"; 1339 $html .= "<div class='admin_element_label'>"._("This will be the from adress of the validation email")." : </div>\n"; 1340 $html .= "<div class='admin_element_data'>\n"; 1341 $name = "network_".$this->getId()."_validation_email_from_address"; 1342 $value = htmlspecialchars($this->getValidationEmailFromAddress(), ENT_QUOTES); 1343 $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 1344 $html .= "</div>\n"; 1345 $html .= "</li>\n"; 1346 1347 // theme_pack 1348 $html .= "<li class='admin_element_item_container'>\n"; 1349 $html .= "<div class='admin_element_label'>"._("Selected theme pack for this network")." : </div>\n"; 1350 $html .= "<div class='admin_element_data'>\n"; 1351 $name = "network_".$this->getId()."_theme_pack"; 1352 $html .= ThemePack :: getSelectUI($name, $this->getThemePack()); 1353 $html .= "</div>\n"; 1354 $html .= "</li>\n"; 1662 $title = _("This will be the from adress of the validation email"); 1663 $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_email_from_address", $this->getValidationEmailFromAddress(), "network_validation_email_from_address_input"); 1664 $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_email_from_address", $title, $data); 1355 1665 1356 1666 // allow_multiple_login 1357 $html .= "<li class='admin_element_item_container'>\n"; 1358 $html .= "<div class='admin_element_label'>"._("Can an account be connected more than once at the same time?")." : </div>\n"; 1359 $html .= "<div class='admin_element_data'>\n"; 1360 $name = "network_".$this->getId()."_allow_multiple_login"; 1361 $this->getMultipleLoginAllowed() ? $checked = 'CHECKED' : $checked = ''; 1362 $html .= "<input type='checkbox' name='$name' $checked>\n"; 1363 $html .= "</div>\n"; 1364 $html .= "</li>\n"; 1365 1366 // allow_splash_only_nodes 1367 $html .= "<li class='admin_element_item_container'>\n"; 1368 $html .= "<div class='admin_element_label'>"._("Are nodes allowed to be set as splash-only (no login)?")." : </div>\n"; 1369 $html .= "<div class='admin_element_data'>\n"; 1370 $name = "network_".$this->getId()."_allow_splash_only_nodes"; 1371 $this->getSplashOnlyNodesAllowed() ? $checked = 'CHECKED' : $checked = ''; 1372 $html .= "<input type='checkbox' name='$name' $checked>\n"; 1373 $html .= "</div>\n"; 1374 $html .= "</li>\n"; 1375 1376 // allow_custom_portal_redirect 1377 $html .= "<li class='admin_element_item_container'>\n"; 1378 $html .= "<div class='admin_element_label'>"._("Are nodes allowed to redirect users to an arbitrary web page instead of the portal?")." : </div>\n"; 1379 $html .= "<div class='admin_element_data'>\n"; 1380 $name = "network_".$this->getId()."_allow_custom_portal_redirect"; 1381 $this->getCustomPortalRedirectAllowed() ? $checked = 'CHECKED' : $checked = ''; 1382 $html .= "<input type='checkbox' name='$name' $checked>\n"; 1383 $html .= "</div>\n"; 1384 $html .= "</li>\n"; 1667 $title = _("Multiple connections"); 1668 $help = _("Can an account be connected more than once at the same time?"); 1669 $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_multiple_login", "", _("Yes"), $this->getMultipleLoginAllowed(), "network_allow_multiple_login_radio"); 1670 $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_allow_multiple_login", $title, $data, $help); 1671 1672 // Build section 1673 $html .= InterfaceElements::generateAdminSectionContainer("network_user_verification", _("Network's user verification"), implode(null, $html_network_user_verification)); 1674 1675 /* 1676 * Access management 1677 */ 1678 $html_access_rights = array(); 1385 1679 1386 1680 // network_stakeholders 1387 $html .= "<li class='admin_element_item_container'>\n"; 1388 $html .= "<div class='admin_element_label'>"._("Network stakeholders")." : </div>\n"; 1389 $html .= "<div class='admin_element_data'>\n"; 1390 //$name = "network_".$this->getId()."_allow_custom_portal_redirect"; 1391 //$this->getCustomPortalRedirectAllowed()? $checked='CHECKED': $checked=''; 1392 //$html .= "<input type='checkbox' name='$name' $checked>\n"; 1393 $html .= "WRITEME!"; 1394 $html .= "</div>\n"; 1395 $html .= "</li>\n"; 1396 1397 // Build HTML form fields names & values 1681 $title = _("Network stakeholders"); 1682 $data = "WRITEME!"; 1683 $html_access_rights[] = InterfaceElements::generateAdminSectionContainer("network_stakeholders", $title, $data); 1684 1685 // Build section 1686 $html .= InterfaceElements::generateAdminSectionContainer("network_access_rights", _("Access rights"), implode(null, $html_access_rights)); 1687 1688 /* 1689 * Network GIS data 1690 */ 1398 1691 if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) { 1692 $html_network_gis_data = array(); 1693 1399 1694 $gis_point = $this->getGisLocation(); 1400 $gis_lat_name = "network_" .$this->getId()."_gis_latitude";1695 $gis_lat_name = "network_" . $this->getId() . "_gis_latitude"; 1401 1696 $gis_lat_value = htmlspecialchars($gis_point->getLatitude(), ENT_QUOTES); 1402 $gis_long_name = "network_" .$this->getId()."_gis_longitude";1697 $gis_long_name = "network_" . $this->getId() . "_gis_longitude"; 1403 1698 $gis_long_value = htmlspecialchars($gis_point->getLongitude(), ENT_QUOTES); 1404 $gis_alt_name = "network_" .$this->getId()."_gis_altitude";1699 $gis_alt_name = "network_" . $this->getId() . "_gis_altitude"; 1405 1700 $gis_alt_value = htmlspecialchars($gis_point->getAltitude(), ENT_QUOTES); 1406 1701 1407 $html .= "<li class='admin_element_item_container'>\n"; 1408 $html .= "<div class='admin_element_label'>"._("Center latitude for your the area of your wireless network")." : </div>\n"; 1409 $html .= "<div class='admin_element_data'>\n"; 1410 $html .= "<input type='text' size ='15' value='$gis_lat_value' id='$gis_lat_name' name='$gis_lat_name'>\n"; 1411 $html .= "</div>\n"; 1412 $html .= "</li>\n"; 1413 1414 $html .= "<li class='admin_element_item_container'>\n"; 1415 $html .= "<div class='admin_element_label'>"._("Center longitude for your the area of your wireless network")." : </div>\n"; 1416 $html .= "<div class='admin_element_data'>\n"; 1417 $html .= "<input type='text' size ='15' value='$gis_long_value' id='$gis_long_name' name='$gis_long_name'>\n"; 1418 $html .= "</div>\n"; 1419 $html .= "</li>\n"; 1420 1421 $html .= "<li class='admin_element_item_container'>\n"; 1422 $html .= "<div class='admin_element_label'>"._("Zoomlevel of the Google Map for your the area of your wireless network")." : </div>\n"; 1423 $html .= "<div class='admin_element_data'>\n"; 1424 $html .= "<input type='text' size ='15' value='$gis_alt_value' id='$gis_alt_name' name='$gis_alt_name'>\n"; 1425 $html .= "</div>\n"; 1426 $html .= "</li>\n"; 1427 1428 $html .= "<li class='admin_element_item_container'>\n"; 1429 $html .= "<div class='admin_element_label'>"._("Default Google Map type for your the area of your wireless network")." : </div>\n"; 1430 $html .= "<div class='admin_element_data'>\n"; 1431 $html .= $this->getSelectGisMapType("network_".$this->getId()."_gmaps_map_type", $this->getGisMapType()); 1432 $html .= "</div>\n"; 1433 $html .= "</li>\n"; 1434 } 1435 1436 // Create new nodes 1437 $html .= "<li class='admin_element_item_container'>\n"; 1438 $html .= "<div class='admin_element_label'>"._("New node ID")." : </div>\n"; 1439 1440 $html .= "<div class='admin_element_data'>\n"; 1441 1442 $html .= Node :: getCreateNewObjectUI($this); 1443 $html .= "</div>\n"; 1444 $html .= "<div class='admin_element_tools'>\n"; 1445 $name = "network_{$this->getId()}_create_node"; 1446 $html .= "<input type='submit' name='{$name}' value='"._("Create a new node")."'>\n"; 1447 $html .= "</div>\n"; 1448 $html .= "</li>\n"; 1702 $title = _("Latitude"); 1703 $help = _("Center latitude for your the area of your wireless network"); 1704 $data = InterfaceElements::generateInputText($gis_lat_name, $gis_lat_value, "network_gis_latitude_input"); 1705 $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_latitude", $title, $data, $help); 1706 1707 $title = _("Longitude"); 1708 $help = _("Center longitude for your the area of your wireless network"); 1709 $data = InterfaceElements::generateInputText($gis_long_name, $gis_long_value, "network_gis_longitude_input"); 1710 $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_longitude", $title, $data, $help); 1711 1712 $title = _("Zoomlevel"); 1713 $help = _("Zoomlevel of the Google Map for your the area of your wireless network"); 1714 $data = InterfaceElements::generateInputText($gis_alt_name, $gis_alt_value, "network_gis_altitude_input"); 1715 $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_altitude", $title, $data, $help); 1716 1717 $title = _("Map type"); 1718 $help = _("Default Google Map type for your the area of your wireless network"); 1719 $data = $this->getSelectGisMapType("network_" . $this->getId() . "_gmaps_map_type", $this->getGisMapType()); 1720 $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gmaps_map_type", $title, $data, $help); 1721 1722 // Build section 1723 $html .= InterfaceElements::generateAdminSectionContainer("network_gis_data", _("GIS data"), implode(null, $html_network_gis_data)); 1724 } 1449 1725 1450 1726 $html .= "</ul>\n"; 1451 $html .= "</fieldset>\n"; 1727 $html .= "</fieldset>"; 1728 1452 1729 return $html; 1453 1730 } 1454 1731 1455 /** Process admin interface of this object. 1456 */ 1457 public function processAdminUI() { 1458 //pretty_print_r($_REQUEST); 1459 $user = User :: getCurrentUser(); 1460 if (!$this->hasAdminAccess($user)) { 1461 throw new Exception(_('Access denied!')); 1462 } 1463 1732 /** 1733 * Process admin interface of this object. 1734 * 1735 * @return void 1736 * 1737 * @access public 1738 */ 1739 public function processAdminUI() 1740 { 1741 $user = User::getCurrentUser(); 1742 1743 try { 1744 if (!$this->hasAdminAccess($user)) { 1745 throw new Exception(_('Access denied!')); 1746 } 1747 } catch (Exception $e) { 1748 $ui = new MainUI(); 1749 $ui->setToolSection('ADMIN'); 1750 $ui->displayError($e->getMessage(), false); 1751 exit; 1752 } 1753 1464 1754 // Content management 1465 1755 $name = "network_".$this->id."_content"; … … 1469 1759 $name = "network_".$this->getId()."_name"; 1470 1760 $this->setName($_REQUEST[$name]); 1471 1761 1472 1762 // creation_date 1473 1763 $name = "network_".$this->getId()."_creation_date"; … … 1544 1834 } 1545 1835 1546 /** Add network-wide content to this network */ 1547 public function addContent(Content $content) { 1548 global $db; 1836 /** 1837 * Add network-wide content to this network 1838 * 1839 * @param object Content object 1840 * 1841 * @return void 1842 * 1843 * @access public 1844 */ 1845 public function addContent(Content $content) 1846 { 1847 // Define globals 1848 global $db; 1849 1549 1850 $content_id = $db->escapeString($content->getId()); 1550 1851 $sql = "INSERT INTO network_has_content (network_id, content_id) VALUES ('$this->id','$content_id')"; … … 1552 1853 } 1553 1854 1554 /** Remove network-wide content from this network */ 1555 public function removeContent(Content $content) { 1556 global $db; 1855 /** 1856 * Remove network-wide content from this network 1857 * 1858 * @param object Content object 1859 * 1860 * @return void 1861 * 1862 * @access public 1863 */ 1864 public function removeContent(Content $content) 1865 { 1866 // Define globals 1867 global $db; 1868 1557 1869 $content_id = $db->escapeString($content->getId()); 1558 1870 $sql = "DELETE FROM network_has_content WHERE network_id='$this->id' AND content_id='$content_id'"; … … 1560 1872 } 1561 1873 1562 /** Delete this Object form the it's storage mechanism 1563 * @param &$errmsg Returns an explanation of the error on failure 1564 * @return true on success, false on failure or access denied */ 1565 public function delete(& $errmsg) { 1874 /** 1875 * Delete this Object form the it's storage mechanism 1876 * 1877 * @param string &$errmsg Returns an explanation of the error on failure 1878 * 1879 * @return bool true on success, false on failure or access denied 1880 * 1881 * @access public 1882 */ 1883 public function delete(& $errmsg) 1884 { 1885 // Init values 1566 1886 $retval = false; 1887 1567 1888 $user = User :: getCurrentUser(); 1568 1889 if (!$user->isSuperAdmin()) { 1569 1890 $errmsg = _('Access denied (must have super admin access)'); 1570 } 1571 else { 1572 if ($this->isDefaultNetwork() === true) 1891 } else { 1892 if ($this->isDefaultNetwork() === true) { 1573 1893 $errmsg = _('Cannot delete default network, create another one and select it before remove this one.'); 1574 else {1894 } else { 1575 1895 global $db; 1576 1896 $id = $db->escapeString($this->getId()); 1577 1897 if (!$db->execSqlUpdate("DELETE FROM networks WHERE network_id='{$id}'", false)) { 1578 1898 $errmsg = _('Could not delete network!'); 1579 } 1580 else { 1899 } else { 1581 1900 $retval = true; 1582 1901 } 1583 1902 } 1584 1903 } 1904 1585 1905 return $retval; 1586 1906 } 1587 /** Reloads the object from the database. Should normally be called after a set operation */ 1588 protected function refresh() { 1907 /** 1908 * Reloads the object from the database. 1909 * 1910 * Should normally be called after a set operation 1911 * 1912 * @return void 1913 * 1914 * @access protected 1915 */ 1916 protected function refresh() 1917 { 1589 1918 $this->__construct($this->id); 1590 1919 } 1591 1920 1592 public static function assignSmartyValues($smarty, $net = null) { 1593 if (!$net) 1594 $net = Network :: getCurrentNetwork(); 1595 1921 /** 1922 * Assigns values about network to be processed by the Smarty engine. 1923 * 1924 * @param object $smarty Smarty object 1925 * @param object $net Network object 1926 * 1927 * @return void 1928 * 1929 * @static 1930 * @access public 1931 */ 1932 public static function assignSmartyValues($smarty, $net = null) 1933 { 1934 if (!$net) { 1935 $net = Network::getCurrentNetwork(); 1936 } 1937 1938 // Set network details 1596 1939 $smarty->assign('networkName', $net ? $net->getName() : ''); 1597 1940 $smarty->assign('networkHomepageURL', $net ? $net->getHomepageURL() : ''); 1941 1598 1942 // Set networks usage information 1599 1943 $smarty->assign('networkNumValidUsers', $net ? $net->getNumValidUsers() : 0); … … 1603 1947 $smarty->assign('networkNumDeployedNodes', $net ? $net->getNumDeployedNodes() : 0); 1604 1948 $smarty->assign('networkNumOnlineNodes', $net ? $net->getNumOnlineNodes() : 0); 1949 $smarty->assign('networkNumNonMonitoredNodes', $net ? $net->getNumOnlineNodes(true) : 0); 1605 1950 } 1606 1951 } -
trunk/wifidog-auth/wifidog/classes/Node.php
r1088 r1089 51 51 require_once('classes/DateTime.php'); 52 52 require_once('classes/InterfaceElements.php'); 53 require_once('classes/MainUI.php'); 53 54 54 55 /** … … 68 69 private $id; 69 70 private static $current_node_id = null; 71 72 /** 73 * List of deployment statuses 74 * 75 * @var array 76 * @access private 77 */ 78 private $_deploymentStatuses = array(); 70 79 71 80 /** … … 187 196 } 188 197 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 { 198 /** 199 * Create a new Node in the database 200 * 201 * @param string $node_id The Id to be given to the new node. If not 202 * present, guid will be assigned. 203 * @param object $network Network object. The node's network. If not 204 * present, the current Network will be assigned 205 * 206 * @return mixed The newly created Node object, or null if there was 207 * an error 208 * 209 * @static 210 * @access public 211 */ 212 public static function createNewObject($node_id = null, $network = null) 213 { 214 // Define globals 215 global $db; 216 217 if (empty ($node_id)) { 202 218 $node_id = get_guid(); 203 219 } 220 204 221 $node_id = $db->escapeString($node_id); 205 222 206 if (empty ($network)) 207 {208 $network = Network :: getCurrentNetwork();209 } 223 if (empty ($network)) { 224 $network = Network::getCurrentNetwork(); 225 } 226 210 227 $network_id = $db->escapeString($network->getId()); 211 228 212 229 $node_deployment_status = $db->escapeString("IN_PLANNING"); 213 230 $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; 231 232 try { 233 if (Node::nodeExists($node_id)) { 234 throw new Exception(_('This node already exists.')); 235 } 236 237 $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')"; 238 239 if (!$db->execSqlUpdate($sql, false)) { 240 throw new Exception(_('Unable to insert new node into database!')); 241 } 242 243 $object = new self($node_id); 244 245 return $object; 246 } catch (Exception $e) { 247 $ui = new MainUI(); 248 $ui->setToolSection('ADMIN'); 249 $ui->displayError($e->getMessage(), false); 250 exit; 251 } 225 252 } 226 253 … … 235 262 $html = ''; 236 263 $name = "{$user_prefix}"; 264 265 $_deploymentStatuses = array( 266 "DEPLOYED" => _("Deployed"), 267 "IN_PLANNING" => _("In planning"), 268 "IN_TESTING" => _("In testing"), 269 "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 270 "PERMANENTLY_CLOSED" => _("Permanently closed"), 271 "TEMPORARILY_CLOSED" => _("Temporarily closed") 272 ); 273 237 274 $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)"; 238 275 $node_rows = null; 239 276 $db->execSql($sql, $node_rows, false); 240 if ($node_rows != null) 241 {277 278 if ($node_rows != null) { 242 279 Utils :: natsort2d($node_rows, "node_id"); 243 280 if ($type_interface != "table") { … … 267 304 { 268 305 $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"; 306 $_deployStatusNode = $node_row['node_deployment_status']; 307 $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"; 270 308 } 271 309 $html .= "\t\t\t</tbody>\n\t\t</table>\n"; … … 317 355 } 318 356 319 /** Process the new object interface. 320 * Will return the new object if the user has the credentials and the form was fully filled. 357 /** 358 * Process the new object interface. 359 * 360 * Will return the new object if the user has the credentials and the form was fully filled. 321 361 * @return the node object or null if no new node was created. 322 362 */ 323 static function processCreateNewObjectUI() 324 { 363 public static function processCreateNewObjectUI() 364 { 365 // Init values 325 366 $retval = null; 326 367 $name = "new_node_id"; 327 if (!empty ($_REQUEST[$name])) 328 {368 369 if (!empty ($_REQUEST[$name])) { 329 370 $node_id = $_REQUEST[$name]; 330 371 $name = "new_node_network_id"; 331 if (!empty ($_REQUEST[$name])) 332 { 333 $network = Network :: getObject($_REQUEST[$name]); 372 373 if (!empty ($_REQUEST[$name])) { 374 $network = Network::getObject($_REQUEST[$name]); 375 } else { 376 $network = Network::processSelectNetworkUI('new_node'); 334 377 } 335 else 336 { 337 $network = Network :: processSelectNetworkUI('new_node'); 378 379 if ($node_id && $network) { 380 try { 381 if (!$network->hasAdminAccess(User :: getCurrentUser())) { 382 throw new Exception(_("Access denied")); 383 } 384 } catch (Exception $e) { 385 $ui = new MainUI(); 386 $ui->setToolSection('ADMIN'); 387 $ui->displayError($e->getMessage(), false); 388 exit; 389 } 390 391 $retval = self::createNewObject($node_id, $network); 338 392 } 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 } 393 } 394 348 395 return $retval; 349 396 } … … 377 424 378 425 foreach ($status_list as $status) { 379 $tab[] = array($status['node_deployment_status'], $status['node_deployment_status']); 426 $_statusvalue = $status['node_deployment_status']; 427 $tab[] = array($_statusvalue, $this->_deploymentStatuses["$_statusvalue"]); 380 428 } 381 429 … … 385 433 } 386 434 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 435 /** 436 * Get the selected deployment status 437 * 438 * @param string $user_prefix An identifier provided by the programmer to 439 * recognise it's generated form 440 * 441 * @return string The deployment status 442 * 443 * @access public 390 444 */ 391 445 public function processSelectDeploymentStatus($user_prefix) … … 410 464 throw new Exception(sprintf(_("The node %s could not be found in the database!"), $node_id_str)); 411 465 } 466 467 $this->_deploymentStatuses = array( 468 "DEPLOYED" => _("Deployed"), 469 "IN_PLANNING" => _("In planning"), 470 "IN_TESTING" => _("In testing"), 471 "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 472 "PERMANENTLY_CLOSED" => _("Permanently closed"), 473 "TEMPORARILY_CLOSED" => _("Temporarily closed") 474 ); 475 412 476 $this->mRow = $row; 413 477 $this->id = $row['node_id']; … … 744 808 * Retrieves the admin interface of this object 745 809 * 746 * @return The HTML fragment for this interface810 * @return string The HTML fragment for this interface 747 811 * 748 812 * @access public … … 756 820 $html = ''; 757 821 758 if (!User::getCurrentUser()) { 759 throw new Exception(_('Access denied!')); 760 } 822 try { 823 if (!User::getCurrentUser()) { 824 throw new Exception(_('Access denied!')); 825 } 826 } catch (Exception $e) { 827 $ui = new MainUI(); 828 $ui->setToolSection('ADMIN'); 829 $ui->displayError($e->getMessage(), false); 830 exit; 831 } 761 832 762 833 // Get information about the network … … 996 1067 } 997 1068 998 /** Process admin interface of this object. 999 */ 1069 /** 1070 * Process admin interface of this object. 1071 * 1072 * @return void 1073 * 1074 * @access public 1075 */ 1000 1076 public function processAdminUI() 1001 1077 { 1002 $user = User :: getCurrentUser(); 1003 1004 if (!$this->isOwner($user) && !$user->isSuperAdmin()) 1005 { 1006 throw new Exception(_('Access denied!')); 1007 } 1078 $user = User::getCurrentUser(); 1079 1080 try { 1081 if (!$this->isOwner($user) && !$user->isSuperAdmin()) { 1082 throw new Exception(_('Access denied!')); 1083 } 1084 } catch (Exception $e) { 1085 $ui = new MainUI(); 1086 $ui->setToolSection('ADMIN'); 1087 $ui->displayError($e->getMessage(), false); 1088 exit; 1089 } 1008 1090 1009 1091 // Check if user is a admin … … 1288 1370 } 1289 1371 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 (); 1372 /** 1373 * The list of users online at this node 1374 * 1375 * @return array An array of User object, or an empty array 1376 * 1377 * @access public 1378 */ 1379 public function getOnlineUsers() 1380 { 1381 // Define globals 1382 global $db; 1383 1384 // Init values 1385 $retval = array(); 1296 1386 $users = null; 1387 $anonUsers = 0; 1388 1297 1389 $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']); 1390 1391 if ($users != null) { 1392 foreach ($users as $user_row) { 1393 if ($this->isConfiguredSplashOnly()) { 1394 if (User::getObject($user_row['user_id']) == "SPLASH_ONLY_USER") { 1395 $anonUsers++; 1396 } else { 1397 $retval[] = User::getObject($user_row['user_id']); 1398 } 1399 } else { 1400 $retval[] = User::getObject($user_row['user_id']); 1401 } 1303 1402 } 1304 } 1403 1404 if ($this->isConfiguredSplashOnly() && $anonUsers == 1) { 1405 $retval[] = "One anonymous user"; 1406 } else if ($this->isConfiguredSplashOnly() && $anonUsers > 1) { 1407 $retval[] = sprintf("%d anonymous users", $anonUsers); 1408 } 1409 } 1410 1305 1411 return $retval; 1306 1412 } 1307 1413 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; 1414 /** 1415 * Find out how many users are online this specific Node 1416 * 1417 * @return int Number of online users 1418 * 1419 * @access public 1420 */ 1421 public function getNumOnlineUsers() 1422 { 1423 // Define globals 1424 global $db; 1425 1426 // Init values 1314 1427 $retval = array (); 1315 1428 $row = null; 1316 if(!$this->isConfiguredSplashOnly()) 1429 1430 if (!$this->isConfiguredSplashOnly()) { 1317 1431 $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 else1432 } else { 1319 1433 $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); 1434 } 1435 1320 1436 return $row['count']; 1321 1437 } -
trunk/wifidog-auth/wifidog/classes/Server.php
r1085 r1089 403 403 404 404 if ($_serverId) { 405 if (!User::getCurrentUser()->isSuperAdmin()) { 406 throw new Exception(_("Access denied")); 407 } 405 try { 406 if (!User::getCurrentUser()->isSuperAdmin()) { 407 throw new Exception(_("Access denied")); 408 } 409 } catch (Exception $e) { 410 require_once('classes/MainUI.php'); 411 412 $ui = new MainUI(); 413 $ui->setToolSection('ADMIN'); 414 $ui->displayError($e->getMessage(), false); 415 exit; 416 } 408 417 409 418 $_retVal = self::createNewObject($_serverId); … … 780 789 { 781 790 require_once('classes/User.php'); 782 if (!User::getCurrentUser()->isSuperAdmin()) { 783 throw new Exception(_('Access denied!')); 784 } 791 792 try { 793 if (!User::getCurrentUser()->isSuperAdmin()) { 794 throw new Exception(_('Access denied!')); 795 } 796 } catch (Exception $e) { 797 $ui = new MainUI(); 798 $ui->setToolSection('ADMIN'); 799 $ui->displayError($e->getMessage(), false); 800 exit; 801 } 785 802 786 803 // creation_date … … 877 894 * End: 878 895 */ 879 -
trunk/wifidog-auth/wifidog/classes/Statistics.php
r1088 r1089 47 47 */ 48 48 require_once('include/common.php'); 49 require_once('classes/MainUI.php'); 49 50 50 51 /** … … 378 379 * 379 380 * @return string HTML markup 381 * 382 * @access private 380 383 */ 381 384 private function getSelectedNodesUI() 382 385 { 386 // Define globals 383 387 global $db; 388 389 // Init values 384 390 $html = ''; 391 385 392 $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"; 412 426 } 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 421 437 return $html; 422 438 } -
trunk/wifidog-auth/wifidog/node_list.php
r1088 r1089 107 107 throw new Exception(_("No nodes could not be found in the database")); 108 108 109 $deploymentStatuses = array( 110 "DEPLOYED" => _("Deployed"), 111 "IN_PLANNING" => _("In planning"), 112 "IN_TESTING" => _("In testing"), 113 "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 114 "PERMANENTLY_CLOSED" => _("Permanently closed"), 115 "TEMPORARILY_CLOSED" => _("Temporarily closed") 116 ); 117 109 118 $nodes_list = array (); 110 119 foreach ($nodes_results as $node_row) … … 113 122 $node_row['duration'] = $db->GetDurationArrayFromIntervalStr($node_row['since_last_heartbeat']); 114 123 $node_row['num_online_users'] = $node->getNumOnlineUsers(); 124 $nodeDeploymentStatus = $node_row['node_deployment_status']; 125 $node_row['node_deployment_status'] = $deploymentStatuses["$nodeDeploymentStatus"]; 115 126 $nodes_list[] = $node_row; 116 127 } -
trunk/wifidog-auth/wifidog/templates/sites/index.tpl
r1088 r1089 93 93 {"%d hotspots are currently operationnal."|_|sprintf:$networkNumOnlineNodes} 94 94 {/if} 95 96 {if $networkNumNonMonitoredNodes > 0} 97 {if $networkNumNonMonitoredNodes == 1} 98 {"Because of one hotspot not being monitored we don't know if it is currently operationnal."|_} 99 {else} 100 {"Because of %d hotspots not being monitored we don't know if they are currently operationnal."|_|sprintf:$networkNumNonMonitoredNodes} 101 {/if} 102 {/if} 95 103 </p> 96 104
