add fix to use the updated plc_object.php with conditional call to
[www-register-wizard.git] / application / controllers / register.php
index f7f330d..0334251 100644 (file)
@@ -36,6 +36,7 @@ class Register extends Controller {
                
                $this->validation->set_error_delimiters('<span class="error">', '</span>');
 
+               $rules['model']         = "trim|required";
                $rules['hostname']  = "trim|required";
                $rules['ip']            = "trim|required|valid_ip";
                $rules['username']  = "trim";
@@ -43,6 +44,7 @@ class Register extends Controller {
                $rules['notes']         = "trim";
                $this->validation->set_rules($rules);
 
+               $fields['model']  = "Model";
                $fields['hostname']  = "Hostname";
                $fields['ip']           = "IP Address";
                $fields['username']  = "Username";
@@ -53,8 +55,11 @@ class Register extends Controller {
                $data = array();
                if ($this->validation->run() == TRUE)
                {
-                       /* b/c the submit is valid, it doesn't matter if pcu_register is set */
-                       $this->pcu_id = $this->add_pcu($data);
+                       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);
+                       }
                }
                $data = $this->get_stage1_data($person, $data);
                $data['stage'] = 1;
@@ -416,7 +421,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)
@@ -593,7 +603,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);
@@ -706,7 +716,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;
                }