X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=application%2Fcontrollers%2Fregister.php;h=242d860231ad2a681c6d41a8464685c65763fdaf;hb=d557c8eaf9a4a4f041672b7e5adb0fae9c7184a9;hp=847eefe3caf5d05da9f00d308ac7c90d7c334951;hpb=8fd1bf7b6562424a96b42bf9ad50ce851acd7cab;p=www-register-wizard.git diff --git a/application/controllers/register.php b/application/controllers/register.php index 847eefe..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; } @@ -385,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']; } @@ -421,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) @@ -475,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); @@ -598,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); @@ -668,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']; @@ -711,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; }