Esempio n. 1
0
 /**
  * Retreives the admin interface of this object
  *
  * @return string The HTML fragment for this interface
  */
 public function getAdminUI()
 {
     Security::requirePermission(Permission::P('NETWORK_PERM_EDIT_NETWORK_CONFIG'), $this);
     require_once 'classes/InterfaceElements.php';
     // Init values
     $html = '';
     /*
      * Verify if an error message was registered before outputting the form
      */
     if (isset($this->errorMsg)) {
         $html .= "<div class='errormsg'>" . $this->errorMsg . "</div>";
     }
     /*
      * Begin with admin interface
      */
     $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
     $html .= "<legend>" . _("Network management") . "</legend>\n";
     $html .= "<ul class='admin_element_list'>\n";
     /*
      * Content management
      */
     $html .= parent::getContentAdminUI();
     /*
      * Network information
      */
     $html_network_information = array();
     // network_id
     $title = _("Network ID");
     $data = htmlspecialchars($this->getId(), ENT_QUOTES);
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_id", $title, $data);
     // name
     $title = _("Network name");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_name", $this->getName(), "network_name_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_name", $title, $data);
     // creation_date
     $title = _("Network creation date");
     $data = DateTimeWD::getSelectDateTimeUI(new DateTimeWD($this->getCreationDate()), "network_" . $this->getId() . "_creation_date", DateTimeWD::INTERFACE_DATETIME_FIELD, "network_creation_date_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_creation_date", $title, $data);
     // homepage_url
     $title = _("Network's web site");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_homepage_url", $this->getWebSiteURL(), "network_homepage_url_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_homepage_url", $title, $data);
     // tech_support_email
     $title = _("Technical support email");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_tech_support_email", $this->getTechSupportEmail(), "network_tech_support_email_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_tech_support_email", $title, $data);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_information", _("Information about the network"), implode(null, $html_network_information));
     /*
      * Network authentication
      */
     $html_network_authentication = array();
     //  network_authenticator_class
     $title = _("Network authenticator class");
     $help = _("The subclass of Authenticator to be used for user authentication. Example: AuthenticatorRadius");
     $name = "network_" . $this->getId() . "_network_authenticator_class";
     $value = htmlspecialchars($this->getAuthenticatorClassName(), ENT_QUOTES);
     $data = $this->getSelectAuthenticator($name, $value);
     $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_class", $title, $data, $help);
     //  network_authenticator_params
     $title = _("Authenticator parameters");
     $help = _("The explicit parameters to be passed to the authenticator. You MUST read the constructor documentation of your desired authenticator class (in wifidog/classes/Authenticators/) BEFORE you start playing with this.  Example: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5'");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_network_authenticator_params", $this->getAuthenticatorConstructorParams(), "network_network_authenticator_params_input");
     $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_params", $title, $data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_authentication", _("Network Authentication"), implode(null, $html_network_authentication));
     /*
      * Network properties
      */
     $html_network_properties = array();
     //  theme_pack
     $title = _("Selected theme pack for this network");
     $data = ThemePack::getSelectUI("network_" . $this->getId() . "_theme_pack", $this->getThemePack());
     $html_network_properties[] = InterfaceElements::generateAdminSectionContainer("network_theme_pack", $title, $data);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_properties", _("Network properties"), implode(null, $html_network_properties));
     /*
      * Network's node properties
      */
     $html_network_node_properties = array();
     //  allow_splash_only_nodes
     $title = _("Splash-only nodes");
     $help = _("Are nodes allowed to be set as splash-only (no login)?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_splash_only_nodes", "", _("Yes"), $this->getSplashOnlyNodesAllowed(), "network_allow_splash_only_nodes_radio");
     $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_splash_only_nodes", $title, $data, $help);
     //  allow_custom_portal_redirect
     $title = _("Portal page redirection");
     $help = _("Are nodes allowed to redirect users to an arbitrary web page instead of the portal?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_custom_portal_redirect", "", _("Yes"), $this->getCustomPortalRedirectAllowed(), "network_allow_custom_portal_redirect_radio");
     $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_custom_portal_redirect", $title, $data, $help);
     //  allow_original_URL_redirect
     $title = _("Original URL redirection");
     $help = _("Are nodes allowed to redirect users to the web page they originally requested instead of the portal?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_original_URL_redirect", "", _("Yes"), $this->getPortalOriginalUrlAllowed(), "network_allow_original_URL_redirect_radio");
     $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_original_URL_redirect", $title, $data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_node_properties", _("Network's node properties"), implode(null, $html_network_node_properties));
     /*
      * Network's user verification
      */
     $html_network_user_verification = array();
     //  validation_grace_time
     $title = _("Validation grace period");
     $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.");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_grace_time", $this->getValidationGraceTime(), "network_validation_grace_time_input");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_grace_time", $title, $data, $help);
     //  validation_email_from_address
     $title = _("This will be the from address of the validation email");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_email_from_address", $this->getValidationEmailFromAddress(), "network_validation_email_from_address_input");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_email_from_address", $title, $data);
     //  allow_multiple_login
     $title = _("Multiple connections");
     $help = _("Can an account be connected more than once at the same time?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_multiple_login", "", _("Yes"), $this->getMultipleLoginAllowed(), "network_allow_multiple_login_radio");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_allow_multiple_login", $title, $data, $help);
     //  network_authenticator_params
     $title = _("Case sensitivity");
     $help = _("Are usernames case sensitive?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_usernames_case_sensitive", "", _("Yes"), $this->getUsernamesCaseSensitive(), "network_usernames_case_sensitive");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_usernames_case_sensitive", $title, $data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_user_verification", _("Network's user verification"), implode(null, $html_network_user_verification));
     /*
      * Dynamic abuse control
      */
     $html_dynamic_abuse_control = array();
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_DYNAMIC_ABUSE_CONTROL'), $this);
     if (Security::hasAnyPermission($permArray)) {
         //  connection_limit_window
         $title = _("Abuse control window");
         $help = _("The length of the window during which the user must not have exceeded the limits below.  Any valid postgresql interval expression is acceptable, typically '1 month' '1 week'.  A user who exceeds the limits will be denied access until his usage falls below the limits.");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_window", $this->getConnectionLimitWindow(), "network_connection_limit_window_input");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_window", $title, $data, $help);
         //  connection_limit_network_max_total_bytes
         $title = _("Network max total bytes transfered");
         $help = _("Maximum data transfer during the abuse control window");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_network_max_total_bytes", $this->getConnectionLimitNetworkMaxTotalBytes(), "network_connection_limit_network_max_total_bytes");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_network_max_total_bytes", $title, $data, $help);
         //  connection_limit_network_max_usage_duration
         $title = _("Network max connection duration");
         $help = _("Maximum connection duration during the abuse control window.  Any valid postgresql interval expression is acceptable, such as hh:mm:ss");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_network_max_usage_duration", $this->getConnectionLimitNetworkMaxDuration(), "network_connection_limit_network_max_usage_duration");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_network_max_usage_duration", $title, $data, $help);
         //  connection_limit_node_max_total_bytes
         $title = _("Node max total bytes transfered");
         $help = _("Maximum data transfer during the abuse control window");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_node_max_total_bytes", $this->getConnectionLimitNodeMaxTotalBytes(), "network_connection_limit_node_max_total_bytes");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_node_max_total_bytes", $title, $data, $help);
         //  connection_limit_node_max_usage_duration
         $title = _("Node max connection duration");
         $help = _("Maximum connection duration during the abuse control window.  Any valid postgresql interval expression is acceptable, such as hh:mm:ss");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_node_max_usage_duration", $this->getConnectionLimitNodeMaxDuration(), "network_connection_limit_node_max_usage_duration");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_node_max_usage_duration", $title, $data, $help);
     } else {
         $html_dynamic_abuse_control[] = _("You do not have access to edit these options");
     }
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_user_verification", _("Dynamic abuse control"), implode(null, $html_dynamic_abuse_control));
     /*
      * Access management
      */
     $html_access_rights = array();
     /*
      * Access rights
      */
     if (true) {
         require_once 'classes/Stakeholder.php';
         $html_access_rights = Stakeholder::getAssignStakeholdersUI($this);
         $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights);
     }
     /*
      * Network GIS data
      */
     if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) {
         $html_network_gis_data = array();
         $gis_point = $this->getGisLocation();
         $gis_lat_name = "network_" . $this->getId() . "_gis_latitude";
         $gis_lat_value = htmlspecialchars($gis_point->getLatitude(), ENT_QUOTES);
         $gis_long_name = "network_" . $this->getId() . "_gis_longitude";
         $gis_long_value = htmlspecialchars($gis_point->getLongitude(), ENT_QUOTES);
         $gis_alt_name = "network_" . $this->getId() . "_gis_altitude";
         $gis_alt_value = htmlspecialchars($gis_point->getAltitude(), ENT_QUOTES);
         $html_network_gis_data[] = '<p>' . _("Note that to be valid, all 3 values must be present.") . "</p>\n";
         $title = _("Latitude");
         $help = _("Center latitude for the area covered by your wireless network");
         $data = InterfaceElements::generateInputText($gis_lat_name, $gis_lat_value, "network_gis_latitude_input");
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_latitude", $title, $data, $help);
         $title = _("Longitude");
         $help = _("Center longitude for the area covered by your wireless network");
         $data = InterfaceElements::generateInputText($gis_long_name, $gis_long_value, "network_gis_longitude_input");
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_longitude", $title, $data, $help);
         $title = _("Zoomlevel");
         $help = _("Zoomlevel of the Google Map.  12 is a typical value.");
         $data = InterfaceElements::generateInputText($gis_alt_name, $gis_alt_value, "network_gis_altitude_input");
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_altitude", $title, $data, $help);
         $title = _("Map type");
         $help = _("Default Google Map type for your the area of your wireless network");
         $data = $this->getSelectGisMapType("network_" . $this->getId() . "_gmaps_map_type", $this->getGisMapType());
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gmaps_map_type", $title, $data, $help);
         // Build section
         $html .= InterfaceElements::generateAdminSectionContainer("network_gis_data", _("GIS data"), implode(null, $html_network_gis_data));
     }
     // Profile templates
     $title = _("Network profile templates");
     $name = "network_" . $this->_id . "_profile_templates";
     $data = ProfileTemplate::getLinkedProfileTemplateUI($name, "network_has_profile_templates", "network_id", $this->_id);
     $html .= InterfaceElements::generateAdminSectionContainer("network_profile_templates", $title, $data);
     // objects hierarchy
     $html .= parent::getGraphAdminUI($this);
     $html .= "</ul>\n";
     $html .= "</fieldset>";
     return $html;
 }