drupal_set_error("Cannot renew slice that far in the future, max is $WEEKS weeks from now");
plc_redirect(l_slice($slice_id));
}
- plc_debug('slice_id',$slice_id);
- plc_debug('expires',$expires);
if ($api->UpdateSlice ($slice_id, array('expires'=>$expires)) == 1)
drupal_set_message("Slice renewed");
else
margin: 10px;
}
/* site registration */
-div.site-pending {
+div.site-pending, div.sites-pending {
background-color: #eadbc8;
padding: 5px;
margin: 10px;
padding: 5px;
margin: 10px;
}
+div.person-register {
+ background-color: #e3d1cb;
+ padding: 5px;
+ margin: 10px;
+}
/****************************************/
/* slice creation page */
// will trash this eventually
//require_once 'plc_functions_trash.php';
+# note: this needs to be consistent with the value in Monitor/monitor/wrapper/plc.py
+global $PENDING_CONSORTIUM_ID;
+$PENDING_CONSORTIUM_ID = 0;
+# this one does not matter that much, just picking one
+global $APPROVED_CONSORTIUM_ID;
+$APPROVED_CONSORTIUM_ID = 999999;
+
// utility
function my_is_int ($x) {
return (is_numeric($x) ? intval($x) == $x : false);
function l_person_register() { return "/db/persons/register.php"; }
function l_site_register() { return "/db/sites/register.php"; }
function l_sites_pending() { return "/db/sites/join_request.php"; }
+function l_site_review_pending($site_id){ return "/db/sites/join_request.php?review=t&site_id=$site_id"; }
//////////////////////////////////////////////////////////// nav tabs
require_once 'plc_drupal.php';
-$PENDING_CONSORTIUM_ID = 0;
-$APPROVED_CONSORTIUM_ID = 999999;
-
if (!function_exists('drupal_page_header')) {
$title = drupal_get_title();
$head = drupal_get_html_head();
require_once 'plc_functions.php';
require_once 'details.php';
require_once 'nifty.php';
+require_once 'table.php';
+require_once 'nifty.php';
include 'site_form.php';
////////////////////////////////////////
function render_all_join_requests($api) {
- $sites = $api->GetSites( array("enabled" => False, "peer_id" => NULL, "ext_consortium_id" => $PENDING_CONSORTIUM_ID));
- if (!empty($sites)) {
- print("<table width=100%>");
- print("<tr><th>Site Name</th><th>site_id</th><th>Submitted</th></tr>");
- foreach($sites as $site) {
- printf("<tr><td><a href=/db/sites/join_request.php?review=t&site_id=%d> %s </a> </td>", $site['site_id'], $site['name']);
- printf("<td><a href=/db/sites/join_request.php?review=t&site_id=%d> %d </a> </td>", $site['site_id'], $site['site_id']);
- printf("<td> %s </td> </tr>", date("d F Y, G:i",$site['date_created']));
- }
- print("</table>");
- } else {
+ global $PENDING_CONSORTIUM_ID;
+ $filter = array("peer_id" => NULL, "ext_consortium_id" => $PENDING_CONSORTIUM_ID);
+ $columns=array('site_id','name','enabled','date_created');
+ $sites = $api->GetSites( $filter, $columns);
+ if (empty($sites)) {
print("<p> No open join requests </p>");
+ return;
}
+ $headers = array();
+ $headers['id']='int';
+ $headers['Site Name']='string';
+ # trying the sortEnglishDateTime stuff - not too lucky so far
+ # http://www.frequency-decoder.com/demo/table-sort-revisited/custom-sort-functions/
+ $headers['submitted']='sortEnglishDateTime';
+ $headers['enabled']='string';
+
+ $nifty=new PlekitNifty ('pending','sites-pending','medium');
+ $nifty->start();
+ $table=new PlekitTable ('pending',$headers,2,
+ array('pagesize_area'=>FALSE,'pagesize'=>10000));
+ $table->start();
+ foreach($sites as $site) {
+ $site_id=$site['site_id'];
+ $link = $site['enabled'] ? l_site($site_id) : l_site_review_pending($site_id);
+ $table->row_start();
+ $table->cell(href($link,$site['site_id']));
+ $table->cell(href($link,$site['name']));
+ $table->cell(date("dS F Y",$site['date_created']) . " at " . date("G:i",$site['date_created']));
+ $table->cell( $site['enabled'] ? plc_warning_html('yes') : 'no');
+ $table->row_end();
+ }
+ $table->end();
+ $nifty->end();
}
function render_join_request_review($api, $site_id) {
}
$addresses = $api->GetAddresses ($site['address_ids']);
if (empty ($addresses)) {
- print("<p class='plc-warning'> No address found for site_id=$site_id</p> ");
- return ;
+ drupal_set_message("Site $site_id has no address - never mind");
+ $address=array('line1'=>'');
+ $address_id=0;
+ } else {
+ $address = $addresses[0];
+ $address_id=$address['address_id'];
}
- $address = $addresses[0];
- $address_id=$address['address_id'];
# just in case there is no person attached yet
if (empty ($site['person_ids'])) {
$persons=array();
<input type="hidden" name="site_id" value="$site_id">
EOF;
+ // don't render the tech part if that was the same as the pi
$site_form = build_site_form(FALSE);
$input = array ('site' => $site, 'address'=> $address, 'pi' => $pi, 'tech' => $tech);
case 'Update': {
$api->begin();
$api->UpdateSite($site_id,$site);
- $api->UpdateAddress($address_id,$address);
+ if ($address_id) $api->UpdateAddress($address_id,$address);
$api->UpdatePerson($pi_id,$pi);
- $api->UpdatePerson($tech_id,$tech);
+ if ($tech_id != $pi_id) $api->UpdatePerson($tech_id,$tech);
$api->commit();
$api_error=$api->error();
if (!empty($api_error)) {
// the PI's email address, which makes the whole thing *a lot* simpler
// enable the site, enable the PI, and VerifyPerson the thec if different from the PI
$site['enabled'] = True;
+ global $APPROVED_CONSORTIUM_ID;
$site['ext_consortium_id'] = $APPROVED_CONSORTIUM_ID;
$api->UpdateSite ($site_id,$site);
$api_error=$api->error();
$error .= $api->error();
$messages [] = "Could not enable site";
} else {
- $messages[] = "Site " . $site['name'] . " enabled";
+ $messages[] = l_site_t ($site_id,"Site '" . $site['name'] . "' enabled");
}
- if (empty ($error)) {
+ if (empty ($error) && $address_id) {
// Update Address
$api->UpdateAddress($address_id,$address);
$api_error=$api->error();
$tech=$input['tech'];
$address=$input['address'];
+# allow address to be left out
+function non_empty_address ($address) {
+ return !empty($address['line1']);
+}
+
if (! $empty_form ) {
// Look for missing/blank entries
$error = form_check_required ($site_form, $input);
// creating the site
$site['enabled']=FALSE;
+ global $PENDING_CONSORTIUM_ID;
+ $site['ext_consortium_id']=$PENDING_CONSORTIUM_ID;
$site_id=$adm->AddSite($site);
$api_error .= $adm->error();
if (empty($api_error)) {
- $verboses [] = "Site created as disabled";
+ $verboses [] = "Site created as disabled, with ext_consortium_id=".$PENDING_CONSORTIUM_ID;
} else {
$error .= $api_error;
}
$messages [] = "Please send a message to " . PLC_MAIL_SUPPORT_ADDRESS . " if this request is not instructed within a few days.";
// creating address
- $adm->AddSiteAddress($site_id,$address);
- $api_error = $adm->error();
- if (empty($api_error)) {
- $verboses [] = "Address created";
- } else {
- $error .= $api_error;
+ if (non_empty_address($address)) {
+ $adm->AddSiteAddress($site_id,$address);
+ $api_error = $adm->error();
+ if (empty($api_error)) {
+ $verboses [] = "Address created";
+ } else {
+ $error .= $api_error;
+ }
}
// creating PI
$max_slices= $site['max_slices'];
$enabled = $site['enabled'];
+$ext_consortium_id = $site ['ext_consortium_id'];
// get peer
$peer_id= $site['peer_id'];
// show gray background on foreign objects : start a <div> with proper class
$peers->block_start ($peer_id);
-if ( $local_peer && ( ! $enabled ) ) {
- if ($site['ext_consortium_id'] == $PENDING_CONSORTIUM_ID) {
- plc_warning ("This site is not enabled - Please visit " .
- href (l_sites_pending(),"this page") .
- " to review pending applications.");
- } else {
- plc_warning ("This site is disabled.");
- }
+// sanity checks
+if ( $local_peer ) {
+ // pending site
+ global $PENDING_CONSORTIUM_ID;
+ if ( $ext_consortium_id == $PENDING_CONSORTIUM_ID) {
+ if ( ! $enabled )
+ plc_warning ("This site is under pending registration - Please visit " .
+ href (l_sites_pending(),"this page") .
+ " to review pending applications.");
+ else
+ plc_warning ("This site is pending but is also enabled - something is wrong. You should fix the issue with plcsh");
+ } else {
+ if ( ! $enabled)
+ plc_warning ("This site is disabled.");
+ }
}
$can_update=(plc_is_admin () && $local_peer) || ( plc_in_site($site_id) && plc_is_pi());
$form = array();
$form['site:name'] = array('title' => 'Site name', 'required' => TRUE,
'maxlength' => 40, 'size' => 20,
- 'comment' => '<strong>Site Information</strong>:');
+ 'comment' => '<strong>Site Information</strong>');
$form['site:login_base'] = array('title' => 'Login base', 'required' => TRUE,
'maxlength' => 16, 'size' => 10);
$form['site:abbreviated_name'] = array('title' => 'Abbreviated name', 'required' => TRUE,
'maxlength' => 20, 'size' => 12);
$form['site:url'] = array('title' => 'URL', 'required' => TRUE,
'maxlength' => 30, 'size' => 30);
- $form['site:latitude'] = array('title' => 'Latitude', 'required' => FALSE,
+ $form['site:latitude'] = array('title' => 'Latitude', 'required' => TRUE,
'maxlength' => 10, 'size' => 10, 'type' => 'double');
- $form['site:longitude'] = array('title' => 'Longitude', 'required' => FALSE,
+ $form['site:longitude'] = array('title' => 'Longitude', 'required' => TRUE,
'maxlength' => 10, 'size' => 10, 'type' => 'double');
- $form['address:line1'] = array('title' => 'Address', 'required' => TRUE,
- 'maxlength' => 40, 'size' => 30,
- 'comment' => '<strong>Postal address</strong>:');
- $form['address:line2'] = array('title' => 'Address (2)', 'required' => FALSE,
- 'maxlength' => 40, 'size' => 30);
- $form['address:line3'] = array('title' => 'Address (3)', 'required' => FALSE,
- 'maxlength' => 40, 'size' => 30);
- $form['address:city'] = array('title' => 'City', 'required' => TRUE,
- 'maxlength' => 20, 'size' => 20);
- $form['address:postalcode'] = array('title' => 'Postal Code', 'required' => TRUE,
- 'maxlength' => 10, 'size' => 10);
-# would have liked it *not* required but it is mandatory in the DB - sigh
- $form['address:state'] = array('title' => 'State', 'required' => TRUE,
- 'maxlength' => 20, 'size' => 20);
- $form['address:country'] = array('title' => 'Country', 'required' => TRUE,
- 'maxlength' => 20, 'size' => 20);
-
$form['pi:first_name'] = array('title' => 'PI First Name', 'required' => TRUE,
'maxlength' => 20, 'size' => 20,
- 'comment' => '<strong>Principal Investigator Information</strong>:');
+ 'comment' => '<strong>Principal Investigator Information</strong>');
$form['pi:last_name'] = array('title' => 'PI Last Name', 'required' => TRUE,
'maxlength' => 20, 'size' => 20);
$form['pi:title'] = array('title' => 'PI Title', 'required' => FALSE,
$form['tech:first_name'] = array('title' => 'Tech First Name', 'required' => TRUE,
'maxlength' => 20, 'size' => 20,
- 'comment' => '<strong>Technical Contact Information</strong>:' . $fill_from_pi_button);
+ 'comment' => '<strong>Technical Contact Information</strong>' . $fill_from_pi_button);
$form['tech:last_name'] = array('title' => 'Tech Last Name', 'required' => TRUE,
'maxlength' => 20, 'size' => 20);
$form['tech:title'] = array('title' => 'Tech Title', 'required' => FALSE,
$form['tech:user-role'] = array('type' => 'boolean', 'title' => 'Need user role', 'default' => TRUE);
}
+ $form['address:line1'] = array('title' => 'Address', 'required' => FALSE,
+ 'maxlength' => 40, 'size' => 30,
+ 'comment' => '<strong>Postal address</strong> (can be left blank)');
+ $form['address:line2'] = array('title' => 'Address (2)', 'required' => FALSE,
+ 'maxlength' => 40, 'size' => 30);
+ $form['address:line3'] = array('title' => 'Address (3)', 'required' => FALSE,
+ 'maxlength' => 40, 'size' => 30);
+ $form['address:city'] = array('title' => 'City', 'required' => FALSE,
+ 'maxlength' => 20, 'size' => 20);
+ $form['address:postalcode'] = array('title' => 'Postal Code', 'required' => FALSE,
+ 'maxlength' => 10, 'size' => 10);
+# would have liked it *not* required but it is mandatory in the DB - sigh
+ $form['address:state'] = array('title' => 'State', 'required' => FALSE,
+ 'maxlength' => 20, 'size' => 20);
+ $form['address:country'] = array('title' => 'Country', 'required' => FALSE,
+ 'maxlength' => 20, 'size' => 20);
+
return $form;
}
// check that site is enabled
if ( ! $site['enabled'])
$messages [] = "Not enabled";
+ global $PENDING_CONSORTIUM_ID;
+ if ( $site['ext_consortium_id'] == $PENDING_CONSORTIUM_ID )
+ $messages [] = "Pending registration";
// check that site has at least a PI and a tech
global $api;
$site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" );
$site_filter = array_merge ($site_filter, array ("enabled" => TRUE));
} else {
- $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" , "is_public",
- "enabled", "person_ids", "max_slices", "slice_ids", "node_ids");
+ $site_columns = array("site_id", "name", "abbreviated_name", "login_base" , "peer_id" ,
+ "is_public", "enabled", "ext_consortium_id",
+ "person_ids", "max_slices", "slice_ids", "node_ids");
}
if (plc_is_admin())