person; $_roles= $_person['role_ids']; // if no id: add, else: display(update) if( !$_GET['id'] ) { if( $_POST['submitted'] ) { // get person's site id $site_id= $_person['site_ids'][0]; // build dict $fields= array( 'protocol'=>$_POST['protocol'], 'hostname'=>$_POST['hostname'], 'model'=>$_POST['model'], 'username'=>$_POST['username'], 'password'=>$_POST['password'], 'notes'=>$_POST['notes'], 'ip'=>$_POST['ip'] ); $pcu_id= $api->AddPCU( $site_id, $fields ); if( $pcu_id != 0 ) { // xxx is l_pcu defined & effective ? plc_redirect( l_pcu($pcu_id)); exit(); } else { $error= $api->error(); } } if( !empty( $error ) ) echo '
' . $error . '.
'; echo "

Add a PCU

\n
\n

\n \n \n \n \n \n \n \n
Protocol:
Hostname:
IP Address:
Model:
Username:
Password:
Notes:
\n

\n"; } else { // get PCU info $pcu_id= intval( $_GET['id'] ); $pcu_info= $api->GetPCUs( array( intval( $pcu_id ) ) ); // if remove is set remove the node from the pcu if( $_GET['remove'] ) { $rem_id= $_GET['remove']; $api->DeleteNodeFromPCU( intval( $rem_id ), $pcu_id ); plc_redirect (l_pcu ($pcu_id)); } //if submitted, update node info if( $_POST['submitted'] ) { $protocol= $_POST['protocol']; $username= $_POST['username']; $hostname= $_POST['hostname']; $ipaddress= $_POST['ip']; $model= $_POST['model']; $password= $_POST['password']; $notes= $_POST['notes']; $api->UpdatePCU( $pcu_id, array( "protocol"=>$protocol, "hostname"=>$hostname, "model"=>$model, "password"=>$password, "notes"=>$notes, "ip"=>$ipaddress ) ); plc_redirect (l_pcu($pcu_id)); } if( in_array( 10, $_roles) ) { $is_admin= true; } else { $is_admin = false; } if( in_array( 10, $_roles ) || ( in_array( 20, $_roles ) && in_array( $pcu_info[0]['site_id'], $_person['site_ids'] ) ) || ( in_array( 40, $_roles ) && in_array( $pcu_info[0]['site_id'], $_person['site_ids'] ) ) ) $pcu_controller= true; // get PCU node info $node_info= $api->GetNodes( $pcu_info[0]['node_ids'], array( "hostname", "node_id", "boot_state" ) ); echo "\n

PCU: ". $pcu_info[0]['hostname'] ."

\n

\n \n \n \n \n \n \n \n
Protocol: "; if( $pcu_controller ) echo ""; echo "
Hostname: "; if( $pcu_controller ) echo ""; echo "
IP Address: "; if( $pcu_controller ) echo ""; if( $pcu_controller ) echo "
Model: "; // NOTE: in general, this value should not be edited, so only allow admins. if( $pcu_controller && $is_admin ) echo ""; echo "
Username: "; if( $pcu_controller ) echo ""; echo "
Password: "; if( $pcu_controller ) echo ""; echo "
Notes: "; if( $pcu_controller ) echo ""; echo "
\n"; if( $pcu_controller ) echo "

\n"; if( !empty( $node_info ) ) { echo "

\n\n"; // if user can control PCU add table cells if( $pcu_controller ) echo "\n"; echo "\n"; // for port numbers $count= 0; foreach( $node_info as $node ) { echo ""; if( $pcu_controller ) echo "\n"; echo "\n"; $count++; } echo "
Nodes
HostnameState
". $pcu_info[0]['ports'][$count] ."". $node['hostname'] ."". $node['boot_state'] ."remove

\n"; } else { echo "

No nodes on PCU."; } echo "

Back to Site\n"; } // Print footer include 'plc_footer.php'; ?>