Esempio n. 1
0
 /**
  * Retrieves the interface to assign stakeholders to objects
  *
  * @return string The HTML fragment for this interface
  *
  * @param $targetObject The Object on which the permssion applies (Network, Server, etc.)
  */
 public static function getAssignStakeholdersUI($targetObject)
 {
     require_once 'classes/Role.php';
     if (User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         $listData = "";
         $db = AbstractDb::getObject();
         $object_class = get_class($targetObject);
         $table = strtolower($object_class) . '_stakeholders';
         $object_id = $db->escapeString($targetObject->getId());
         $sql = "SELECT * FROM {$table} JOIN roles USING (role_id) WHERE object_id = '{$object_id}';";
         $stakeholder_rows = null;
         $db->execSql($sql, $stakeholder_rows, false);
         if ($stakeholder_rows) {
             foreach ($stakeholder_rows as $stakeholder_row) {
                 $user = User::getObject($stakeholder_row['user_id']);
                 $role = Role::getObject($stakeholder_row['role_id']);
                 $roleStr = htmlspecialchars($role->getLabelStr());
                 $name = $object_id . "_stakeholder_" . $stakeholder_row['user_id'] . "_" . $stakeholder_row['role_id'] . "_remove";
                 $listDataContents = InterfaceElements::generateAdminSection("", $user->getListUI() . ' ' . $roleStr, InterfaceElements::generateInputSubmit($name, _("Remove stakeholder")));
                 $listData .= "<li class='admin_element_item_container node_owner_list'>" . $listDataContents . "</li>\n";
             }
         }
         $listData .= "<li class='admin_element_item_container'>";
         $listData .= Role::getSelectUI($object_id . "_new_stakeholder_role", array('stakeholderTypeId' => $object_class));
         $listData .= User::getSelectUserUI($object_id . "_new_stakeholder", $object_id . "_new_stakeholder_submit", _("Add stakeholder"));
         $listData .= "<br class='clearbr' /></li>\n";
         $html = "<ul id='node_owner_ul' class='admin_element_list'>\n" . $listData . "</ul>\n";
     }
     return $html;
 }
Esempio n. 2
0
 /**
  * Get an interface to add a user to a list
  *
  * @param string $user_prefix      A identifier provided by the programmer
  *                                 to recognise it's generated HTML form
  * @param string $add_button_name  Name of optional "add" button
  * @param string $add_button_value Value of optional "add" button
  *
  * @return string HTML markup
  */
 public static function getSelectUserUI($user_prefix, $add_button_name = null, $add_button_value = null)
 {
     $db = AbstractDb::getObject();
     $networkSelector = Network::getSelectUI($user_prefix);
     // Check if we need to add an "add" button
     if ($add_button_name && $add_button_value) {
         $userSelector = _("Username") . ": " . InterfaceElements::generateInputText("select_user_" . $user_prefix . "_username", "", "", "input_text", array("onkeypress" => "if ((event.which ? event.which : event.keyCode) == 13) {form.{$add_button_name}.click() }"));
         $userSelector .= InterfaceElements::generateInputSubmit($add_button_name, $add_button_value);
     } else {
         $userSelector = _("Search for Username or Email Address") . ": " . InterfaceElements::generateInputText("select_user_" . $user_prefix . "_username");
     }
     $html = "<div class='user_select_user_ui_container'>" . $networkSelector . "<br>" . $userSelector . "</div>\n";
     return $html;
 }
Esempio n. 3
0
 /**
  * Get a flexible interface to view the children and parents of a given element
  * One can add parents and children to the hierarchy 
  *
  * @param string $user_prefix            A identifier provided by the
  *                                       programmer to recognise it's
  *                                       generated HTML form
  * @param string $graph_element          Hotspot_Graph_Element
  * @return string HTML markup
  */
 public static function getGraphAdminUI($user_prefix, $graph_element)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $object_id = $db->escapeString($graph_element->getHgeId());
     // Get the parents
     if (!$graph_element->isRoot()) {
         $_title = _("Parents :");
         $parent_rows = HotspotGraph::getParents($object_id);
         $listData = "";
         if ($parent_rows) {
             foreach ($parent_rows as $parent_row) {
                 $classname = $parent_row['element_type'];
                 $element = HotspotGraphElement::getObject($parent_row['element_id'], $classname);
                 $parentStr = htmlspecialchars($parent_row['name']) . " (" . htmlspecialchars($parent_row['element_type']) . ")  ";
                 $name = $object_id . "_parent_" . $parent_row['next_element_id'] . "_remove";
                 $listDataContents = InterfaceElements::generateAdminSection("", $parentStr, InterfaceElements::generateInputSubmit($name, _("Remove from")));
                 $listData .= "<li class='admin_element_item_container node_owner_list'>" . $listDataContents . "</li>\n";
             }
         }
         $listData .= "<li class='admin_element_item_container'>";
         $listData .= HotspotGraphElement::getSelectGraphElementUI($object_id . "_parent_add_element", array('additionalWhere' => " AND element_type in ('Network', 'NodeGroup') AND hotspot_graph_element_id != '{$db->escapeString($graph_element->getHgeId())}'"));
         $listData .= InterfaceElements::generateInputSubmit($object_id . "_parent_add", _("Add"));
         $listData .= "<br class='clearbr' /></li>\n";
         $_data = "<ul id='node_owner_ul' class='admin_element_list'>\n" . $listData . "</ul>\n";
         $html .= InterfaceElements::generateAdminSectionContainer("element_parent", $_title, $_data);
     }
     // Get the children
     if (!$graph_element->isLeaf()) {
         $_title = _("Children :");
         $children_rows = HotspotGraph::getChildren($object_id);
         $listData = "";
         if ($children_rows) {
             foreach ($children_rows as $child_row) {
                 $classname = $child_row['element_type'];
                 $element = HotspotGraphElement::getObject($child_row['element_id'], $classname);
                 $childStr = htmlspecialchars($child_row['name']) . " (" . htmlspecialchars($child_row['element_type']) . ")  ";
                 $name = $object_id . "_child_" . $child_row['next_element_id'] . "_remove";
                 $listDataContents = InterfaceElements::generateAdminSection("", $childStr, InterfaceElements::generateInputSubmit($name, _("Remove from")));
                 $listData .= "<li class='admin_element_item_container node_owner_list'>" . $listDataContents . "</li>\n";
             }
         }
         $listData .= "<li class='admin_element_item_container'>";
         $listData .= HotspotGraphElement::getSelectGraphElementUI($object_id . "_child_add_element", array('additionalWhere' => " AND element_type in ('Node', 'NodeGroup') AND hotspot_graph_element_id != '{$db->escapeString($graph_element->getHgeId())}'"));
         $listData .= InterfaceElements::generateInputSubmit($object_id . "_child_add", _("Add"));
         $listData .= "<br class='clearbr' /></li>\n";
         $_data = "<ul id='node_owner_ul' class='admin_element_list'>\n" . $listData . "</ul>\n";
         $html .= InterfaceElements::generateAdminSectionContainer("element_children", $_title, $_data);
     }
     return $html;
 }
Esempio n. 4
0
 /**
  * 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;
 }