Changeset 1089 for trunk/wifidog-auth/wifidog/classes/Network.php
- Timestamp:
- 09/03/06 18:54:01 (6 years ago)
- Files:
-
- 1 modified
-
trunk/wifidog-auth/wifidog/classes/Network.php (modified) (57 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 }
