person; $_roles= $_person['role_ids']; //print_r( $_person ); // if not a PI or admin then redirect to slice index if( !in_array( '10', $_roles ) && !in_array( '20', $_roles ) ) header( "index.php" ); if( !$_POST['name'] ) { // get default site base $site_info= $api->GetSites( array( $_person['site_ids'][0] ), array( "login_base" ) ); $base= $site_info[0]['login_base'] ."_"; } // add it if( $_POST['add'] ) { // get post vars $url= $_POST['url']; $instantiation= $_POST['instantiation']; $name= $_POST['name']; $description= $_POST['description']; // validate input if( $name == $base ) $error['name']= "You must enter a name for your slice."; else { $slice_name= $name; // make sure slice name doesnt exist $slice_info= $api->GetSlices( array( $slice_name ), array( "slice_id" ) ); if( !empty( $slice_info ) ) { $error['name']= "Slice name already in use. Please choose another."; $name= ""; } } if( $url == "http://" || "" ) $error['url']= "You must enter a URL for your slice's info."; if( $description == "" ) $error['description']= "Your must enter a description for you slice."; // if no errors then add if( !$error ) { $fields= array( "url" => $url, "instantiation" => $instantiation, "name" => $slice_name, "description" => $description ); echo "added:
"; print_r( $fields ); echo "\n"; // add it! $slice_new_id= $api->AddSlice( $fields ); if( $slice_new_id ) { plc_redirect( "index.php?id=$slice_new_id" ); exit(); } else { $error['api']= $api->error(); } } } // Print header require_once 'plc_drupal.php'; drupal_set_title('Slices'); include 'plc_header.php'; if( !$url ) $url= "http://"; // check for errors and set error styles if( $error['name'] ) $name_error= " class='plc-warning'"; if( $error['url'] ) $url_error= " class='plc-warning'"; if( $error['description'] ) $desc_error= " class='plc-warning'"; // add javaScript code echo "\n"; // start form echo "\n"; // Print footer include 'plc_footer.php'; ?>