Esempio n. 1
0
 public function processAdminUI()
 {
     $network = Network::processSelectUI('Statistics');
     if ($network) {
         $this->report_selected_networks[$network->getId()] = $network;
     } else {
         $networks = Security::getObjectsWithPermission(Permission::P('NETWORK_PERM_VIEW_STATISTICS'));
         foreach ($networks as $network) {
             $this->report_selected_networks[$network->getId()] = $network;
         }
     }
     $this->processDateRangeUI();
     $this->processSelectedNodesUI();
     $this->processDistinguishUsersByUI();
     $this->processSelectedUsersUI();
     $this->processSelectedReportsUI();
 }
Esempio n. 2
0
 /** Get the selected user, IF one was selected and is valid
  * @param $user_prefix A identifier provided by the programmer to recognise it's generated form
  * @param &$errMsg An error message will be appended to this is the username is not empty, but the user doesn't exist.
  * @return the User object, or null if the user is invalid or none was selected
  */
 static function processSelectUserUI($user_prefix, &$errMsg)
 {
     $object = null;
     try {
         $network = Network::processSelectUI($user_prefix);
         $name = "select_user_{$user_prefix}_username";
         if (!empty($_REQUEST[$name])) {
             $username = $_REQUEST[$name];
             return self::getUserByUsernameOrEmailAndOrigin($username, $network, $errMsg);
         } else {
             return null;
         }
     } catch (Exception $e) {
         return null;
     }
 }
Esempio n. 3
0
 /**
  * Process admin interface of this object.
  *
  * @return void
  *
  * @access public
  */
 public function processAdminUI()
 {
     require_once 'classes/Stakeholder.php';
     $user = User::getCurrentUser();
     // Get information about the network
     $network = $this->getNetwork();
     //pretty_print_r($_REQUEST);
     $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);
     // Check if user is a admin
     $_userIsAdmin = User::getCurrentUser()->DEPRECATEDisSuperAdmin();
     // Information about the node
     $node_id = $this->getId();
     // 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)) {
         $name = "node_" . $node_id . "_gw_id";
         $this->setGatewayId($_REQUEST[$name]);
     }
     // Content processing
     parent::processContentAdminUI();
     // 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)) {
         $name = "node_" . $node_id . "_name";
         $this->setName($_REQUEST[$name]);
     }
     // 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)) {
         $name = "node_" . $node_id . "_creation_date";
         $this->setCreationDate(DateTimeWD::processSelectDateTimeUI($name, DateTimeWD::INTERFACE_DATETIME_FIELD)->getIso8601FormattedString());
     }
     // Homepage URL
     $name = "node_" . $node_id . "_homepage_url";
     $this->setWebSiteUrl($_REQUEST[$name]);
     // Description
     $name = "node_" . $node_id . "_description";
     $this->setDescription($_REQUEST[$name]);
     // Map URL
     $name = "node_" . $node_id . "_map_url";
     $this->setMapUrl($_REQUEST[$name]);
     // Civic number
     $name = "node_" . $node_id . "_civic_number";
     $this->setCivicNumber($_REQUEST[$name]);
     // Street name
     $name = "node_" . $node_id . "_street_name";
     $this->setStreetName($_REQUEST[$name]);
     // City
     $name = "node_" . $node_id . "_city";
     $this->setCity($_REQUEST[$name]);
     // Province
     $name = "node_" . $node_id . "_province";
     $this->setProvince($_REQUEST[$name]);
     // Postal Code
     $name = "node_" . $node_id . "_postal_code";
     $this->setPostalCode($_REQUEST[$name]);
     // Country
     $name = "node_" . $node_id . "_country";
     $this->setCountry($_REQUEST[$name]);
     // Public phone #
     $name = "node_" . $node_id . "_public_phone";
     $this->setTelephone($_REQUEST[$name]);
     // Public mail
     $name = "node_" . $node_id . "_public_email";
     $this->setEmail($_REQUEST[$name]);
     // Mass transit info
     $name = "node_" . $node_id . "_mass_transit_info";
     $this->setTransitInfo($_REQUEST[$name]);
     // GIS data
     // Get a geocoder for a given country
     if (!empty($_REQUEST['geocode_only'])) {
         if ($geocoder = AbstractGeocoder::getGeocoder($this->getCountry()) != null) {
             $geocoder = AbstractGeocoder::getGeocoder($this->getCountry());
         } else {
             $geocoder = AbstractGeocoder::getGeocoder('Earth');
         }
         if ($geocoder != null) {
             $geocoder->setCivicNumber($this->getCivicNumber());
             $geocoder->setStreetName($this->getStreetName());
             $geocoder->setCity($this->getCity());
             $geocoder->setProvince($this->getProvince());
             $geocoder->setPostalCode($this->getPostalCode());
             if ($geocoder->validateAddress() == true) {
                 if (($point = $geocoder->getGisLocation()) !== null) {
                     $this->setGisLocation($point);
                 } else {
                     $this->_warningMessage = _("It appears that the Geocoder could not be reached or could not geocode the given address.");
                 }
             } else {
                 $this->_warningMessage = _("You must enter a valid address.");
             }
         } else {
             $this->_warningMessage = _("Unable to create geocoder.  Are you sure you set the country?");
         }
     } else {
         // Use what has been set by the user.
         $gis_lat_name = "node_" . $node_id . "_gis_latitude";
         $gis_long_name = "node_" . $node_id . "_gis_longitude";
         $this->setGisLocation(new GisPoint($_REQUEST[$gis_lat_name], $_REQUEST[$gis_long_name], 0.0));
     }
     $name = "node_" . $node_id . "_show_on_map";
     $this->setShowOnMap(empty($_REQUEST[$name]) ? false : true);
     // Statistics
     $name = "node_{$this->id}_get_stats";
     if (!empty($_REQUEST[$name])) {
         header("Location: stats.php?" . urlencode("selected_nodes[]") . "=" . urlencode($this->getId()));
     }
     $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)) {
         if (isset($_REQUEST['allows_public_stats'])) {
             $this->setAllowsPublicStats($_REQUEST['allows_public_stats'] == 'on');
         } else {
             $this->setAllowsPublicStats(false);
         }
     }
     // Node configuration section
     $network = $this->getNetwork();
     // Deployment status
     $name = "node_" . $node_id . "_deployment_status";
     $this->setDeploymentStatus(self::processSelectDeploymentStatus($name));
     // Network selection
     $name = "node_" . $node_id . "_network_id";
     $new_network = Network::processSelectUI($name);
     if ($new_network != $this->getNetwork()) {
         Security::requirePermission(Permission::P('NETWORK_PERM_ADD_NODE'), $new_network);
         $this->setNetwork($new_network);
     }
     //  is_splash_only_node
     if ($network->getSplashOnlyNodesAllowed()) {
         $name = "node_" . $node_id . "_is_splash_only_node";
         $this->setIsConfiguredSplashOnly(empty($_REQUEST[$name]) ? false : true);
     }
     // custom_portal_redirect_url
     if ($network->getCustomPortalRedirectAllowed()) {
         $name = "node_" . $node_id . "_custom_portal_redirect_url";
         $this->setCustomPortalRedirectUrl($_REQUEST[$name]);
     }
     // allow_original_URL_redirect
     if ($network->getPortalOriginalUrlAllowed()) {
         $name = "node_" . $node_id . "_allow_original_URL_redirect";
         $this->setPortalOriginalUrlAllowed(empty($_REQUEST[$name]) ? false : true);
     }
     // End Node configuration section
     parent::processGraphAdminUI($errMsg, $network);
     if (!empty($errMsg)) {
         echo $errMsg;
         $errMsg = null;
     }
     // Access rights
     Stakeholder::processAssignStakeholdersUI($this, $errMsg);
     if (!empty($errMsg)) {
         echo $errMsg;
     }
 }
Esempio n. 4
0
 /**
  * Process the login interface
  */
 public static function processLoginUI(&$errmsg = null)
 {
     if (!empty($_REQUEST["login_form_submit"])) {
         if (isset($_REQUEST["user_id"])) {
             $username = User::getObject($_REQUEST["user_id"])->getUsername();
         } else {
             if (isset($_REQUEST["username"])) {
                 $username = $_REQUEST["username"];
             }
         }
         if (isset($_REQUEST["password"])) {
             $password = $_REQUEST["password"];
         }
         // Authenticating the user through the selected auth source.
         $network = Network::processSelectUI('auth_source');
         $user = $network->getAuthenticator()->login($username, $password, $errmsg);
         self::$_loginLastError = $errmsg;
     }
 }
Esempio n. 5
0
 /**
  * Process the new object interface.
  *
  * Will return the new object if the user has the credentials and the form was fully filled.
  * @return the node object or null if no new node was created.
  */
 public static function processCreateNewObjectUI()
 {
     // Init values
     $retval = null;
     $name = "new_node_group_name";
     if (!empty($_REQUEST[$name])) {
         $ng_name = $_REQUEST[$name];
     } else {
         $ng_name = null;
     }
     $name = "new_node_group_network_id";
     if (!empty($_REQUEST[$name])) {
         $network = Network::getObject($_REQUEST[$name]);
     } else {
         $network = Network::processSelectUI('new_node_group');
     }
     if ($network) {
         Security::requirePermission(Permission::P('NETWORK_PERM_ADD_NODEGROUP'), $network);
         $retval = self::createNewObject($ng_name, $network);
     }
     return $retval;
 }
Esempio n. 6
0
 /**
  * Process admin interface of this object
  *
  * @return void
  */
 public function processAdminUI()
 {
     require_once 'classes/User.php';
     Security::requirePermission(Permission::P('SERVER_PERM_EDIT_ANY_VIRTUAL_HOST'), Server::getServer());
     // hostname
     $name = "server_" . $this->getId() . "_hostname";
     $this->setHostname($_REQUEST[$name]);
     //  default_network
     $name = "vhost_" . $this->getId() . "_default_network";
     $this->setDefaultNetwork(Network::processSelectUI($name));
     //  is_default_server
     $name = "vhost_" . $this->getId() . "_is_default_vhost";
     if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == 'on') {
         $server = Server::getServer();
         $server->setDefaultVirtualHost($this);
     }
     //  ssl_available
     $name = "server_" . $this->getId() . "_ssl_available";
     if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == 'on') {
         $this->setSSLAvailable(true);
     } else {
         $this->setSSLAvailable(false);
     }
     // gmaps_api_key
     if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) {
         $name = "server_" . $this->getId() . "_gmaps_api_key";
         $this->setGoogleAPIKey($_REQUEST[$name]);
     }
 }