diff --git a/lib/eduGAIN_entity.php b/lib/eduGAIN_entity.php index a2d6677beeb591fa0fcc4f6e6d88bdd8bd3fc947..ba09626cbc9c4057fcb92898bfebaf3d0724d8eb 100644 --- a/lib/eduGAIN_entity.php +++ b/lib/eduGAIN_entity.php @@ -305,7 +305,9 @@ class eduGAIN_entity extends eduGAIN { $obj['org'] = $org; $obj['contacts'] = $this->getEntityContacts($entity_row_id); $obj['coco_status'] = $this->getEntityCoCo($entity_row_id); - $obj['eccs_status'] = $this->getEntityECCS($entity_row_id); + $eccs = $this->getEntityECCS($entity_row_id); + $obj['eccs_status'] = $eccs['eccs_status']; + $obj['eccs_status_date'] = $eccs['eccs_status_date']; $obj['sirtfi_status'] = $this->getEntitySIRTFI($entity_row_id); $obj['validator_warnings'] = $this->getEntityWarnings($entity_row_id); return($obj); @@ -692,11 +694,10 @@ class eduGAIN_entity extends eduGAIN { private function getEntityECCS($entity_row_id) { if (!is_numeric($entity_row_id)) exit; - $q = "SELECT eccs_status FROM entity_details WHERE entity_id = $entity_row_id"; + $q = "SELECT eccs_status, eccs_status_date FROM entity_details WHERE entity_id = $entity_row_id"; $result = $this->databaseQuery($q); $obj = $result->fetch_assoc(); - $out = $obj['eccs_status']; - return($out); + return($obj); } private function getEntityWarnings($entity_row_id) { diff --git a/lib/eduGAIN_entityDetails.php b/lib/eduGAIN_entityDetails.php index fe6fca7edd40cae5daaf822752574633f28f2f9c..b5381efa1d119347f520cb2802385ff8a434839c 100644 --- a/lib/eduGAIN_entityDetails.php +++ b/lib/eduGAIN_entityDetails.php @@ -289,7 +289,7 @@ class eduGAIN_entityDetails extends eduGAIN_entity { public function printEntity($row_id, $e_id='NOTSET') { $out = ''; $this->entity = $this->showEntityDetails($row_id, $e_id); - $out .= "<script>var entityid='" . urlencode($this->entity['entityid']) . "'; var eccs_status=" . $this->entity['eccs_status'] . ";</script>"; + $out .= "<script>var entityid='" . urlencode($this->entity['entityid']) . "'; var eccs_status=" . $this->entity['eccs_status'] . "; var eccs_date='" . $this->entity['eccs_status_date'] . "';</script>"; $out .= "<table class='entity_details'>\n"; $out .= "<tr><td class='details_header' colspan=2>Entity information</td></tr>\n"; $out .= "<tr><th>Entity ID:</th><td>" . $this->entity['entityid'] . "</td></tr>"; diff --git a/scripts/ECCSinterface.php b/scripts/ECCSinterface.php index a955f5cbdbbae21bccfabb2c97ef3e96cd5b9186..f06e4b69c6f23825b2fc86a270b6323dece63d7d 100644 --- a/scripts/ECCSinterface.php +++ b/scripts/ECCSinterface.php @@ -1,13 +1,17 @@ <?php +/* + * ECCS update should probably be done by the ECCS process itself, + * therefore this is most likely a temporary solution + */ require "../lib/config.php"; require(eduGAIN_config."eccs_update.php"); - class ECCSinterface { public function __construct() { $mysqli = new mysqli(DB_HOST, USER, PASSWORD, DB_DATABASE); - if ($mysqli->connect_error) + if ($mysqli->connect_error) { die("Not connected"); + } $mysqli->set_charset('utf8'); $this->mysqli = $mysqli; } @@ -22,18 +26,19 @@ class ECCSinterface { } public function load_eccs() { - $j = file_get_contents(ECCS_URL.'/api/eccsresults?format=simple'); - $e = json_decode($j); - $Colors = [ - 'OK' => 1, - 'DISABLED' => 2, - 'ERROR' => 3, - 'UNKNOWN' => 4, - ]; - foreach ($e as $r) { - $this->ECCS[$r->entityID] = $Colors[$r->status]; - } + $j = file_get_contents(ECCS_URL.'/api/eccsresults?format=simple'); + $e = json_decode($j); + $Colors = [ + 'OK' => 1, + 'DISABLED' => 2, + 'ERROR' => 3, + 'UNKNOWN' => 4, + ]; + foreach ($e as $r) { + $this->ECCS[$r->entityID] = $Colors[$r->status]; + } } + public $ECCS; } @@ -41,12 +46,14 @@ $e = new ECCSinterface(); $e->load_eccs(); $date = gmdate("Y-m-d", time()); -$q = "DELETE FROM eccs_stat"; -$e->databaseQuery($q); - foreach ($e->ECCS as $e_id => $s) { - $q = "INSERT into eccs_stat (entityid,status,update_date) VALUES ('$e_id',$s, '$date') ON DUPLICATE KEY UPDATE status=$s, update_date='$date'"; - $e->databaseQuery($q); -// print "$q\n"; + + $q = "INSERT INTO eccs_stat (entityid,status,update_date) VALUES ('$e_id',$s, '$date') ON DUPLICATE KEY UPDATE status=$s, update_date='$date'"; + $e->databaseQuery($q); + $e->databaseQuery("LOCK TABLE entity_details WRITE, entity_warn_tmp WRITE"); + $e->databaseQuery("LOCK TABLE entity_details WRITE"); + $q = "UPDATE entity_details JOIN entity_warn_tmp ON entity_details.entity_id=entity_warn_tmp.entity_id set entity_details.validator_status=entity_warn_tmp.warn"; + $e->databaseQuery($q); + $e->databaseQuery("UNLOCK TABLES"); } ?> diff --git a/scripts/update_eccs.sh b/scripts/update_eccs.sh index e4e98e92496b812faf5946dbcae989590e6d19d1..35fdd38dea6bf3fbb6ea20c49c2dbb3687cdf62e 100755 --- a/scripts/update_eccs.sh +++ b/scripts/update_eccs.sh @@ -1,5 +1,12 @@ #!/bin/bash # this is a temporary solution for ECCS status updates +# the paths might needed to be changed +# +# The script should be started soon after the ECCS run starts +# it will then test /opt/eccs-deployment/debug/eccs_status for +# existence of the 'end ECCS' line as a signal that the ECCS +# run is done. +# Changes introduced by ECCS will only be seen after the next aggregation run if [ ! -f /opt/eccs-deployment/debug/eccs_status ] ; then exit diff --git a/templates/js/entities.js b/templates/js/entities.js index 2c477e73749e1a907c1c3875f7f53ee2edc2d030..276eb9acee30dfbc1d2d0054b5d00332b0d71ad5 100644 --- a/templates/js/entities.js +++ b/templates/js/entities.js @@ -1,5 +1,4 @@ <script tyle="text/javascript"> - var xx; var yy; var link; @@ -57,14 +56,14 @@ $(function(){ win.focus(); }) - function show_eccs(e_id, eccs_date) { - var win = window.open(eccs_url+"?idp="+e_id+"&date="+eccs_date,'_blank'); + function show_eccs(e_id, date) { + var win = window.open(eccs_url+"?idp="+e_id+"&date="+date,'_blank'); win.focus(); } $("#show_eccs").click(function(event) { event.preventDefault(); - show_eccs(entityid); + show_eccs(entityid, eccs_date); }); function show_coco(c_id) { @@ -279,7 +278,6 @@ $("#entity_cat").change(function(event) { $("#entity_cat_uri").html(id); $("#entity_cat_legend").css("visibility","visible"); } -//alert("ecs="+entity_cat_support[id]+"; ec="+entity_cat[id]); if(entity_cat_support[id] > 0 && entity_cat[id] > 0) { $("#category_type_selection").show(); } else { @@ -301,7 +299,6 @@ $("#entity_cat").change(function(event) { $("input[name=search_type]").bind("change",function(event) { var type = $('input[name=search_type]:checked').val(); -//alert(type); var txt; var hlp; if(type == 'entityid') { @@ -352,5 +349,4 @@ $("input[name=new_entities]").on("click",function(event) { $( "#datepicker" ).val(""); } ); - </script>