Make the non-wifidog node appear on the map.

Bug #721928 reported by Alexis Cornellier
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
AuthPuppy
Fix Committed
Undecided
Unassigned

Bug Description

Make the non-wifidog node appear on the maps colored neutral (transparent, grey).

Revision history for this message
gbastien (gbastien02) wrote :

There is already a non-wifidog node status in AuthPuppy. So the feature already exists.

description: updated
summary: - add non-authpuppy node
+ Make the non-wifidog node appear on the map.
Revision history for this message
Robin Jones (robin-networkfusion) wrote :

I am making good progress on this bug, but I cant find where the query getDeployedNodes is executed in the following function:

  protected function getNodeList($onlyDeployed = true) {
      $nodetbl = Doctrine::getTable('Node');

      $method = 'getActiveNodes';
      if ($onlyDeployed) {
        $method = "getDeployedNodes";
      }

      $this->nodes = $nodetbl->$method();
      return $this->nodes;
  }

I want to change 'getActiveNodes' to show Deployed Nodes and Unmanaged nodes, 'getDeployedNodes' to only show Deployed Nodes and add a third type of 'getAllNodes' which returns all nodes including those in planning etc...

could someone tell me which file the queries are located?

Revision history for this message
gbastien (gbastien02) wrote :

These functions are part of the core and are in the NodeTable class, in file lib/model/doctrine/NodeTable.class.php

To avoid in the future having to change the core for this kind of request (nodes by status, etc), maybe we should replace those functions by getNodesByStatus(array $statuses) and those named functions could be in the plugin and call that other one?

Revision history for this message
Robin Jones (robin-networkfusion) wrote :

so would you do something similar to this:

    public function getNodesByStatus($statuses) {
       # Loop through the statuses returning the query results when finished
      foreach ( $statuses as $status )
      {
        $q = $this->createQuery('n')
        ->where('n.deployment_status = ?', $status);

        $resultarray += $q->execute();
      }
      unset($status);
      return $resultarray
    }

    protected function getNodeList($onlyDeployed = true) {
      $nodetbl = Doctrine::getTable('Node');
        if ($onlyDeployed) {
          $statuses = array("DEPLOYED");
        }
        else {
          $statuses = array("DEPLOYED", "NON_WIFIDOG_NODE");
        }
        $this->nodes = $nodetbl->getNodesByStatus($statuses);
        return $this->nodes;
    }

Revision history for this message
Robin Jones (robin-networkfusion) wrote :

ok, i changed the code to this:

//kept for backwards compatibility, but modified to work as it should!
public function getActiveNodes() {
      # Return all nodes for now
      $q = $this->createQuery('n')
   ->where('n.deployment_status = ?', "DEPLOYED")
   ->orWhere('n.deployment_status = ?', "NON_WIFIDOG_NODE");

      return $q->execute();
    }

 public function getNodesByStatuses($statuses) {
      # Return all nodes for now
      $q = $this->createQuery('n')
   ->where('n.deployment_status = ?', $statuses[0]);
   $count = count($statuses);
      for ($i = 1; $i < $count; $i++) {
     $q->orWhere('n.deployment_status = ?', $statuses[$i]);
   }

      return $q->execute();
    }

getNodesByStatuses can be called as follows:

$params = array("DEPLOYED","NON_WIFIDOG_NODE");
$this->nodes = $nodetbl->getNodesByStatuses($params);

this seems to work nicely...

Revision history for this message
Robin Jones (robin-networkfusion) wrote :

OK, I have partly patched this bug (attached)

the following code needs to be changed in NodeTable.class:

public function getActiveNodes() {
      # Return all nodes for now
      $q = $this->createQuery('n')
   ->where('n.deployment_status = ?', "DEPLOYED")
   ->orWhere('n.deployment_status = ?', "NON_WIFIDOG_NODE");
      return $q->execute();
    }

for this patch to be complete, actions.class needs to call the nodelist in the correct way, but I couldn't get it to work as I couldn't seem to call the parameter isDeployed when constructing the class (it is commented as a TODO in the patch).

As a dirty work arround (for those of you who are desperate) you could comment out the following line in apNodeListAbstract.class.php

$method = "getDeployedNodes";

Geneviève, if you could guide me in the right direction...

Revision history for this message
Robin Jones (robin-networkfusion) wrote :

Oops... forgot to include an important piece of logic...

Here is the updated one!

Revision history for this message
gbastien (gbastien02) wrote :

Hi Robin,

Good idea to add this as a configuration option for the plugin. I don't know what would be the best approach to show them

1- if the option is checked then we should considered non-wifidog nodes as 'deployed' so no need to initialise the value of 'onlyDeployed' in actions.class.php, the deployed node query will return the non-wifidog nodes.

or

2- if the option is checked, construct the class with new $class(array('onlyDeployed' => false)) and the active nodes query would return deployed and non-wifidog nodes.

Revision history for this message
gbastien (gbastien02) wrote :

Will only work on versions of the core > 0.1.1-stable

Changed in authpuppy:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.