function getEntityPreviousStatus($idp, $fedsDisabledList)
 {
     $query = new QueryBuilder();
     $query->setSql('SELECT * FROM EntityDescriptors WHERE entityID = ? ORDER BY lastCheck');
     $query->addQueryParam($idp['entityID'], 's');
     $result = $this->dbManager->executeStatement(true, $query);
     $previousStatus = NULL;
     $ignoreEntity = false;
     // If I found the input IdP on the EntityDescriptors table
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             // If the IdP was disabled before, but now its registrationAuthority is accepted, then enables the IdP
             if (!in_array($row['registrationAuthority'], $fedsDisabledList) && $row['ignoreReason'] == 'Federation excluded from check') {
                 $query = new QueryBuilder();
                 $query->setSql("UPDATE EntityDescriptors SET ignoreEntity = 0, ignoreReason = NULL WHERE entityID = ?");
                 $query->addQueryParam($row['entityID'], 's');
                 $this->dbManager->executeStatement(false, $query);
                 $previousStatus = NULL;
                 $ignoreEntity = false;
             } else {
                 if (in_array($row['registrationAuthority'], $fedsDisabledList) && $row['ignoreReason'] != 'Federation excluded from check') {
                     $query = new QueryBuilder();
                     $query->setSql("UPDATE EntityDescriptors SET ignoreEntity = 1, ignoreReason = 'Federation excluded from check' WHERE entityID = ?");
                     $query->addQueryParam($row['entityID'], 's');
                     $this->dbManager->executeStatement(false, $query);
                     $previousStatus = NULL;
                     $ignoreEntity = true;
                 } else {
                     $previousStatus = $row['currentResult'];
                     $ignoreEntity = $row['ignoreEntity'];
                 }
             }
         }
         return array($ignoreEntity, $previousStatus);
     } else {
         $query = new QueryBuilder();
         $query->setSql("INSERT INTO EntityDescriptors (entityID, registrationAuthority, displayName, technicalContacts, supportContacts, serviceLocation, ignoreEntity, ignoreReason) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
         $query->addQueryParam($idp['entityID'], 's');
         $query->addQueryParam($idp['registrationAuthority'], 's');
         $query->addQueryParam($idp['displayName'], 's');
         $query->addQueryParam($idp['technicalContacts'], 's');
         $query->addQueryParam($idp['supportContacts'], 's');
         $query->addQueryParam($idp['SingleSignOnService'], 's');
         if (in_array($idp['registrationAuthority'], $fedsDisabledList)) {
             $query->addQueryParam('1', 's');
             $query->addQueryParam('Federation excluded from check', 's');
             $previousStatus = NULL;
             $ignoreEntity = true;
         } else {
             $query->addQueryParam('0', 's');
             $query->addQueryParam(NULL, 's');
             $previousStatus = NULL;
             $ignoreEntity = false;
         }
         $result = $this->dbManager->executeStatement(false, $query);
         return array($ignoreEntity, $previousStatus);
     }
 }
 private function getFederationStatistics()
 {
     $query = new QueryBuilder();
     $sql = "SELECT * FROM FederationStats";
     $query->setSql($sql);
     $result = $this->dbManager->executeStatement(true, $query);
     $entities = array();
     while ($row = $result->fetch_assoc()) {
         $entity = array('checkDate' => $row['checkDate'], 'registrationAuthority' => $row['registrationAuthority'], 'currentResult' => $row['currentResult'] ? substr($row['currentResult'], 4) : 'disabled', 'css_class' => $this->computeCssClass($row['currentResult']), 'numIdPs' => $row['numIdPs']);
         array_push($entities, $entity);
     }
     return array('results' => $entities);
 }