Example #1
0
 /**
  * Delete this Object form the it's storage mechanism
  *
  * @param string &$errmsg Returns an explanation of the error on failure
  *
  * @return bool true on success, false on failure or access denied
  *
  * @access public
  */
 public function delete(&$errmsg)
 {
     // Init values
     $retval = false;
     Security::requirePermission(Permission::P('NETWORK_PERM_DELETE_NETWORK'), $this);
     if ($this->isDefaultNetwork() === true) {
         $errmsg = _('Cannot delete default network, create another one and select it before you remove this one.');
     } else {
         $db = AbstractDb::getObject();
         $id = $db->escapeString($this->getId());
         if (!$db->execSqlUpdate("DELETE FROM networks WHERE network_id='{$id}'", false)) {
             $errmsg = _('Could not delete network!');
         } else {
             parent::_delete($errmsg);
             $retval = true;
         }
     }
     return $retval;
 }
Example #2
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;
     }
 }
Example #3
0
 /**
  * Detect if the addition of element with id $object_id as either parent or child would cause the graph to have a cycle
  * @param HotspotGraphElement $start_element The element to start cycle detection with
  * @param string $object_id The object_id of the element to add to the graph from $start_elelemtn
  * @param boolean $child if the element to add to the graph is a child of the start_element or a parent
  * @return boolean (true if cycle detected)
  */
 protected static function detectCycle($start_element, $object_id, $child = true)
 {
     // If the element is a child, we check for its presence in the parents and vice versa
     if ($child) {
         $function = 'getParents';
     } else {
         $function = 'getChildren';
     }
     $db = AbstractDb::getObject();
     $start_object_id = $db->escapeString($start_element->getHgeId());
     return HotspotGraph::isCycle($start_object_id, $function, $object_id);
 }
Example #4
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 = Network::getDefaultNetwork();
     //pretty_print_r($_REQUEST);
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODEGROUP_CONFIG'), Network::getDefaultNetwork());
     $permArray[] = array(Permission::P('NODEGROUP_PERM_EDIT_ANY_NODEGROUP_CONFIG'), $this);
     $permArray[] = array(Permission::P('NODEGROUP_PERM_EDIT_NODEGROUP_CONFIG'), $this);
     Security::requireAnyPermission($permArray);
     // Check if user is a admin
     $_userIsAdmin = User::getCurrentUser()->DEPRECATEDisSuperAdmin();
     // Information about the node
     $ng_id = $this->getId();
     // Content processing
     parent::processContentAdminUI();
     // Name
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODEGROUP_CONFIG'), Network::getDefaultNetwork());
     $permArray[] = array(Permission::P('NODEGROUP_PERM_EDIT_NODEGROUP_CONFIG'), $this);
     if (Security::hasAnyPermission($permArray)) {
         $name = "node_group_" . $ng_id . "_name";
         $this->setName($_REQUEST[$name]);
     }
     // Creation date
     $name = "node_group_" . $ng_id . "_creation_date";
     $this->setCreationDate(DateTimeWD::processSelectDateTimeUI($name, DateTimeWD::INTERFACE_DATETIME_FIELD)->getIso8601FormattedString());
     // Description
     $name = "node_" . $ng_id . "_description";
     $this->setDescription($_REQUEST[$name]);
     parent::processGraphAdminUI($errMsg);
     if (!empty($errMsg)) {
         echo $errMsg;
         $errMsg = null;
     }
     // End Node group configuration section
     // Access rights
     Stakeholder::processAssignStakeholdersUI($this, $errMsg);
     if (!empty($errMsg)) {
         echo $errMsg;
     }
 }