- $success = $api->AddNodeToPCU( $node_id, $data['pcu_id'], 1);
- if( !isset($success) || $success <= 0 ) {
- $data['error'] = $api->error();
- print $data['error'];
+ $pcus = $api->GetPCUs(array('pcu_id' => $data['pcu_id']));
+ if ( count($pcus) > 0 )
+ {
+ $pcu = $pcus[0];
+ # if $node_id in $pcu['node_ids']
+ if ( ! in_array( $node_id , $pcu['node_ids'] ) )
+ {
+ $success = $api->AddNodeToPCU( $node_id, $data['pcu_id'], 1);
+ if( !isset($success) || $success <= 0 ) {
+ $data['error'] = $api->error();
+ print $data['error'];
+ }
+
+ }