X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=application%2Fcontrollers%2Fregister.php;h=242d860231ad2a681c6d41a8464685c65763fdaf;hb=d557c8eaf9a4a4f041672b7e5adb0fae9c7184a9;hp=a6d33504e405ea843a2cd7370f010c3f1b6faef5;hpb=ae761c2688942da8399bb9c19df89c1a1ef95d2d;p=www-register-wizard.git
diff --git a/application/controllers/register.php b/application/controllers/register.php
index a6d3350..242d860 100644
--- a/application/controllers/register.php
+++ b/application/controllers/register.php
@@ -11,7 +11,7 @@ include 'plc_header.php';
// Common functions
require_once 'plc_functions.php';
-require_once 'plc_sorts.php';
+//require_once 'plc_sorts.php';
include 'plc_objects.php';
@@ -55,7 +55,7 @@ class Register extends Controller {
$data = array();
if ($this->validation->run() == TRUE)
{
- if ($this->validation->model != "none-selected" )
+ if ($this->validation->model != "none-selected" )
{
/* b/c the submit is valid, it doesn't matter if pcu_register is set */
$this->pcu_id = $this->add_pcu($data);
@@ -117,11 +117,12 @@ class Register extends Controller {
global $api, $plc;
// get sites depending on role and sites associated.
if( $person->isAdmin() ) {
- $site_info= $api->GetSites( NULL, array( "name", "site_id", "login_base" ) );
+ $site_info= $api->GetSites(array('peer_id' => NULL,'-SORT'=>'name'),
+ array( "name", "site_id", "login_base" ) );
} else {
$site_info= $api->GetSites( $person->getSites(), array( "name", "site_id", "login_base" ) );
}
- sort_sites( $site_info );
+ //sort_sites( $site_info );
return $site_info;
}
@@ -323,6 +324,7 @@ class Register extends Controller {
function add_node(&$data)
{
global $api, $plc;
+ print "Adding Node\n
";
$hostname = trim($_REQUEST['hostname']);
$model= trim($_REQUEST['model']);
$method = trim($_REQUEST['method']);
@@ -384,8 +386,8 @@ class Register extends Controller {
}
}
- $nodenetwork_id= $api->AddNodeNetwork( $node_id, $optional_vals);
- if( $nodenetwork_id <= 0 ) {
+ $interface_id= $api->AddInterface( $node_id, $optional_vals);
+ if( $interface_id <= 0 ) {
$data['error'] = $api->error();
print $data['error'];
}
@@ -420,7 +422,12 @@ class Register extends Controller {
{
global $api, $plc;
$plc_node_list = $api->GetNodes(array('site_id' => intval($site_id) ));
- return PlcObject::constructList('Node', $plc_node_list);
+ $ret = array();
+ foreach ($plc_node_list as $plc_node)
+ {
+ $ret[] = new Node($plc_node, True);
+ }
+ return $ret;
}
function getsite($site_id)
@@ -474,14 +481,20 @@ class Register extends Controller {
print $this->validation->error_string . "
";
}
-
$data['node'] = $this->getnode($data['node_id']);
- $api_pcus = $api->GetPCUs($data['node']->pcu_ids);
- $pcu = $api_pcus[0];
+ if ( sizeof($data['node']->pcu_ids) == 0)
+ {
+ $data['pcu_assigned'] = False;
+ $data['pcu_port'] = -1;
+ } else {
+ $data['pcu_assigned'] = True;
+ $api_pcus = $api->GetPCUs($data['node']->pcu_ids);
+ $pcu = $api_pcus[0];
+ # NOTE: find index of node id, then pull out that index of
+ $index = array_search($data['node_id'], $pcu['node_ids']);
+ $data['pcu_port'] = $pcu['ports'][$index];
+ }
- # NOTE: find index of node id, then pull out that index of
- $index = array_search($data['node_id'], $pcu['node_ids']);
- $data['pcu_port'] = $pcu['ports'][$index];
$data['stage'] = 4.5;
#$data = $this->get_stage4_data($person, $data);
$this->load->view('header', $data);
@@ -597,7 +610,7 @@ class Register extends Controller {
$api_node_list = $api->GetNodes($node_id);
if ( count($api_node_list) > 0 )
{
- $node_obj = new Node($api_node_list[0]);
+ $node_obj = new Node($api_node_list[0], True);
} else {
print "broken!!!";
exit (1);
@@ -667,7 +680,7 @@ class Register extends Controller {
if ( count($optional_vals) > 0 )
{
print_r($optional_vals);
- $ret = $api->UpdateNodeNetwork( $node_obj->nodenetwork_id, $optional_vals);
+ $ret = $api->UpdateInterface( $node_obj->interface_id, $optional_vals);
if( $ret <= 0 ) {
$data['error'] = $api->error();
print $data['error'];
@@ -689,6 +702,7 @@ class Register extends Controller {
}
$data['node'] = $this->getnode($data['node_id']);
$data['site'] = $this->getsite($data['site_id']);
+ /*print "SITENAME: " . $data['site']['login_base'] . "
";*/
return $data;
}
@@ -709,7 +723,7 @@ class Register extends Controller {
$plc_node_list = $api->GetNodes(array('node_id' => intval($node_id) ));
if ( count($plc_node_list) > 0 )
{
- return new Node($plc_node_list[0]);
+ return new Node($plc_node_list[0], True);
} else {
return NULL;
}