/** * Retrieves the admin interface of this object * * @return string The HTML fragment for this interface * * @access public * * @todo Most of this code will be moved to Hotspot class when the * abtraction will be completed */ public function getAdminUI() { $permArray = null; $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $this->getNetwork()); $permArray[] = array(Permission::P('NODE_PERM_EDIT_CONFIG'), $this); $permArray[] = array(Permission::P('NODE_PERM_EDIT_GATEWAY_ID'), $this); $permArray[] = array(Permission::P('NODE_PERM_EDIT_DEPLOYMENT_DATE'), $this); Security::requireAnyPermission($permArray); require_once 'classes/InterfaceElements.php'; require_once 'classes/Stakeholder.php'; // Init values $html = ''; // Get information about the network $network = $this->getNetwork(); $node_id = $this->getId(); /* * Check for a warning message */ if ($this->_warningMessage != "") { $html .= "<div class='errormsg'>" . $this->_warningMessage . "</div>\n"; } /* * Begin with admin interface */ $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n"; $html .= "<legend>" . _("Edit a node") . "</legend>\n"; $html .= "<ul class='admin_element_list'>\n"; /* * Display stats */ $permArray = null; $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network); $permArray[] = array(Permission::P('NODE_PERM_ALLOW_GENERATING_PUBLIC_STATS'), $this); if (Security::hasAnyPermission($permArray)) { $_title = _("Statistics"); $_data = InterfaceElements::generateInputCheckbox("allows_public_stats", "", _("Allow public access to some node statistics."), $this->getAllowsPublicStats(), "allows_public_stats"); $_data .= InterfaceElements::generateInputSubmit("node_" . $this->id . "_get_stats", _("Get access statistics"), "node_get_stats_submit"); $html .= InterfaceElements::generateAdminSectionContainer("node_get_stats", $_title, $_data); } /* * Information about the node */ $_html_node_information = array(); // Gateway ID $_title = _("Gateway ID"); $permArray = null; $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network); $permArray[] = array(Permission::P('NODE_PERM_EDIT_GATEWAY_ID'), $this); if (Security::hasAnyPermission($permArray)) { $_data = InterfaceElements::generateInputText("node_" . $node_id . "_gw_id", $this->getGatewayId(), "gw_id_input"); } else { $_data = htmlspecialchars($this->getGatewayId(), ENT_QUOTES); $_data .= InterfaceElements::generateInputHidden("node_" . $node_id . "_gw_id", $this->getGatewayId()); } $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("gateway_id", $_title, $_data); //Node content $html .= parent::getContentAdminUI(); // Name $permArray = null; $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network); $permArray[] = array(Permission::P('NODE_PERM_EDIT_NAME'), $this); if (Security::hasAnyPermission($permArray)) { $_title = _("Name"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_name", $this->getName(), "node_name_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_name", $_title, $_data); } else { $_title = _("Name"); $_data = $this->getName(); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_name", $_title, $_data); } // Creation date $_title = _("Creation date"); $permArray = null; $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network); $permArray[] = array(Permission::P('NODE_PERM_EDIT_DEPLOYMENT_DATE'), $this); if (Security::hasAnyPermission($permArray)) { $_data = DateTimeWD::getSelectDateTimeUI(new DateTimeWD($this->getCreationDate()), "node_" . $node_id . "_creation_date", DateTimeWD::INTERFACE_DATETIME_FIELD, "node_creation_date_input"); } else { $_data = htmlspecialchars($this->getCreationDate(), ENT_QUOTES); $_data .= InterfaceElements::generateInputHidden("node_" . $node_id . "_creation_date", $this->getCreationDate()); } $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_creation_date", $_title, $_data); // Description $_title = _("Description"); $name = "node_" . $node_id . "_description"; $_data = "<textarea name='{$name}' cols=80 rows=5 id='node_description_textarea'>\n" . $this->getDescription() . "\n</textarea>\n"; $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_description", $_title, $_data); // Civic number $_title = _("Civic number"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_civic_number", $this->getCivicNumber(), "node_civic_number_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_civic_number", $_title, $_data); // Street name $_title = _("Street name"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_street_name", $this->getStreetName(), "node_street_name_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_street_name", $_title, $_data); // City $_title = _("City"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_city", $this->getCity(), "node_city_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_city", $_title, $_data); // Province $_title = _("Province / State"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_province", $this->getProvince(), "node_province_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_province", $_title, $_data); // Postal Code $_title = _("Postal code"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_postal_code", $this->getPostalCode(), "node_postal_code_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_postal_code", $_title, $_data); // Country $_title = _("Country"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_country", $this->getCountry(), "node_country_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_country", $_title, $_data); // Public phone # $_title = _("Public phone number"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_public_phone", $this->getTelephone(), "node_public_phone_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_public_phone", $_title, $_data); // Public mail $_title = _("Public email"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_public_email", $this->getEmail(), "node_public_email_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_public_email", $_title, $_data); // Homepage URL $_title = _("Homepage URL"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_homepage_url", $this->getWebSiteURL(), "node_homepage_url_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_homepage_url", $_title, $_data); // Mass transit info $_title = _("Mass transit info"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_mass_transit_info", $this->getTransitInfo(), "node_mass_transit_info_input"); $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_mass_transit_info", $_title, $_data); // Build section $html .= InterfaceElements::generateAdminSectionContainer("node_information", _("Information about the node"), implode(null, $_html_node_information)); /* * Node GIS data */ $_html_node_gis_data = array(); $gis_point = $this->getGisLocation(); // Latitude $_title = _("Latitude"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_gis_latitude", $gis_point->getLatitude(), "node_" . $node_id . "_gis_latitude"); $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_gis_latitude", $_title, $_data); // Latitude $_title = _("Longitude"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_gis_longitude", $gis_point->getLongitude(), "node_" . $node_id . "_gis_longitude"); $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_gis_longitude", $_title, $_data); // Call the geocoding service, if Google Maps is enabled then use Google Maps to let the user choose a more precise location if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED === true) { $_data = InterfaceElements::generateInputSubmit("geocode_only", _("Geocode the address or postal code above"), "geocode_only_submit"); $_data .= InterfaceElements::generateInputButton("google_maps_geocode", _("Check using Google Maps"), "google_maps_geocode_button", "submit", array("onclick" => "window.open('hotspot_location_map.php?node_id={$this->getId()}', 'hotspot_location', 'toolbar = 0, scrollbars = 1, resizable = 1, location = 0, statusbar = 0, menubar = 0, width = 600, height = 600');")); $_data .= "<div class='admin_section_hint' id='node_gis_geocode_hint'>" . "(" . _("Use a geocoding service, then use Google Maps to pinpoint the exact location.") . ")" . "</div>\n"; } else { $_data = InterfaceElements::generateInputSubmit("geocode_only", _("Geocode the address or postal code above"), "geocode_only_submit"); $_data .= "<div class='admin_section_hint' id='node_gis_geocode_hint'>" . "(" . _("Use a geocoding service") . ")" . "</div>\n"; } $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_gis_geocode", "", $_data); // Map URL $_title = _("Map URL"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_map_url", $this->getMapURL(), "node_map_url_input"); $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_map_url", $_title, $_data); $_title = _("Show node on map"); $help = _("Should this node be visible on the map when deployed?"); $_data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_show_on_map", "", _("Yes"), $this->showOnMap(), "node_show_on_map_input"); $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_show_on_map", $_title, $_data, $help); // Build section $html .= InterfaceElements::generateAdminSectionContainer("node_gis_data", _("GIS data"), implode(null, $_html_node_gis_data)); /* * Node configuration section */ $_html_node_config = array(); // Deployment status $_title = _("Node deployment status"); $_data = $this->getSelectDeploymentStatus("node_" . $node_id . "_deployment_status"); $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_deployment_status", $_title, $_data); // Network selection $_title = _("Node Network"); $_data = Network::getSelectUI("node_" . $node_id . "_network_id", array('preSelectedObject' => $this->getNetwork())); $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_network", $_title, $_data); // is_splash_only_node if ($network->getSplashOnlyNodesAllowed()) { $_title = _("Is this node splash-only (no login)?"); $_data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_is_splash_only_node", "", _("Yes"), $this->isConfiguredSplashOnly(), "node_is_splash_only_node_radio"); $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_is_splash_only_node", $_title, $_data); } // custom_portal_redirect_url if ($network->getCustomPortalRedirectAllowed()) { $_title = _("URL to show instead of the portal"); $_data = InterfaceElements::generateInputText("node_" . $node_id . "_custom_portal_redirect_url", $this->getCustomPortalRedirectUrl(), "node_custom_portal_redirect_url_input"); $_data .= _("If this is not empty, the portal will be disabled and this URL will be shown instead"); $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_custom_portal_redirect_url", $_title, $_data); } // 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? this will overide the custom portal URL"); $data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_allow_original_URL_redirect", "", _("Yes"), $this->getPortalOriginalUrlAllowed(), "node_allow_original_URL_redirect_radio"); $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_allow_original_URL_redirect", $title, $data, $help); // Build section $html .= InterfaceElements::generateAdminSectionContainer("node_config", _("Node configuration"), implode(null, $_html_node_config)); /* * Access rights */ if (User::getCurrentUser()->DEPRECATEDisSuperAdmin()) { require_once 'classes/Stakeholder.php'; $html_access_rights = Stakeholder::getAssignStakeholdersUI($this); $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights); } //Node hierarchy $html .= parent::getGraphAdminUI($network); $html .= "</ul>\n"; $html .= "</fieldset>"; return $html; }