From 53e923d90ca4efd96b4be9e3b23d931a2284f9ab Mon Sep 17 00:00:00 2001 From: Jeanette Sperhac Date: Wed, 19 Apr 2017 13:45:19 -0400 Subject: [PATCH] Modify xdmod source for php7 compatibility. --- classes/Glossary.php | 77 ------------------- .../OpenXdmod/DataWarehouseInitializer.php | 2 +- .../Shredded/{Resource.php => Resources.php} | 3 +- db/data/moddb.sql | 2 +- db/migrations/6.6.0-6.7.0/moddb.sql | 5 ++ db/schema/moddb.sql | 16 ---- html/controllers/ui_data/repogen_sites.php | 34 -------- html/controllers/user_profile.php | 30 -------- .../user_profile/fetch_profile.php | 20 ----- .../user_profile/list_fields_of_science.php | 27 ------- .../user_profile/update_profile.php | 49 ------------ libraries/network.php | 25 ------ libraries/utilities.php | 22 ------ .../lib/TestHarness/XdmodTestHelper.php | 2 +- 14 files changed, 9 insertions(+), 305 deletions(-) delete mode 100644 classes/Glossary.php rename classes/OpenXdmod/Ingestor/Shredded/{Resource.php => Resources.php} (89%) create mode 100644 db/migrations/6.6.0-6.7.0/moddb.sql delete mode 100644 html/controllers/ui_data/repogen_sites.php delete mode 100644 html/controllers/user_profile.php delete mode 100644 html/controllers/user_profile/fetch_profile.php delete mode 100644 html/controllers/user_profile/list_fields_of_science.php delete mode 100644 html/controllers/user_profile/update_profile.php delete mode 100644 libraries/network.php diff --git a/classes/Glossary.php b/classes/Glossary.php deleted file mode 100644 index 5f39dc4556..0000000000 --- a/classes/Glossary.php +++ /dev/null @@ -1,77 +0,0 @@ - - - function presentTerm(e, term, definition) { - ... - }//presentTerm - - function hideTerm() { - ... - }//hideTerm - - - - */ - - - public static function processText($string) { - - // Pad the string left and right with a space so the regular expression (see $pattern) can match appropriately. - $string = ' '.$string.' '; - - $res = DataWarehouse::connect()->query('SELECT term, definition FROM moddb.Glossary'); - - $active_terms = array(); - - foreach ($res as $term) { - - $t = $term['term']; - $base_term = ucwords($t); - $definition = mysql_escape_string($term['definition']); - - $term_collection = array($t); - - // ---------------------------------- - - // Grab all the aliases for the term (should any exist), so they can be tagged as well. - - $aliasResults = DataWarehouse::connect()->query("SELECT alias FROM moddb.GlossaryAliases WHERE term = '$t'"); - - foreach ($aliasResults as $alias) { - $term_collection[] = $alias['alias']; - } - - // ---------------------------------- - - foreach ($term_collection as $term) { - - // The pattern accounts for 'common' pluralization (using 's') and possession (apostrophe s) - // Todo: Still have to account for a closing parenthesis immediately to the right of the term (e.g. "application kernels)" ) - - $pattern = "/\s(($term)('{0,1}s)?)\s/i"; - - $string = preg_replace($pattern, " \\1 ", $string); - - }//foreach - - }//foreach - - return $string; - - }//processText - - }//Glossary - -?> \ No newline at end of file diff --git a/classes/OpenXdmod/DataWarehouseInitializer.php b/classes/OpenXdmod/DataWarehouseInitializer.php index 2c30fa1165..ded7d4b722 100644 --- a/classes/OpenXdmod/DataWarehouseInitializer.php +++ b/classes/OpenXdmod/DataWarehouseInitializer.php @@ -53,7 +53,7 @@ class DataWarehouseInitializer * @var array */ protected $shreddedJobIngestors = array( - 'Resource', + 'Resources', 'PI', 'PIResource', 'UserPIResource', diff --git a/classes/OpenXdmod/Ingestor/Shredded/Resource.php b/classes/OpenXdmod/Ingestor/Shredded/Resources.php similarity index 89% rename from classes/OpenXdmod/Ingestor/Shredded/Resource.php rename to classes/OpenXdmod/Ingestor/Shredded/Resources.php index d9be7b4ea3..aa36b64f38 100644 --- a/classes/OpenXdmod/Ingestor/Shredded/Resource.php +++ b/classes/OpenXdmod/Ingestor/Shredded/Resources.php @@ -4,7 +4,7 @@ use PDODBSynchronizingIngestor; -class Resource extends PDODBSynchronizingIngestor +class Resources extends PDODBSynchronizingIngestor { public function __construct($dest_db, $src_db) { @@ -20,4 +20,3 @@ public function __construct($dest_db, $src_db) ); } } - diff --git a/db/data/moddb.sql b/db/data/moddb.sql index b1fc9f8c88..69d959f697 100644 --- a/db/data/moddb.sql +++ b/db/data/moddb.sql @@ -37,4 +37,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -INSERT INTO `schema_version_history` VALUES ('moddb', '6.6.0', NOW(), 'created', 'N/A'); +INSERT INTO `schema_version_history` VALUES ('moddb', '6.7.0', NOW(), 'created', 'N/A'); diff --git a/db/migrations/6.6.0-6.7.0/moddb.sql b/db/migrations/6.6.0-6.7.0/moddb.sql new file mode 100644 index 0000000000..e0bd568786 --- /dev/null +++ b/db/migrations/6.6.0-6.7.0/moddb.sql @@ -0,0 +1,5 @@ +DROP TABLE IF EXISTS `Glossary`; + +DROP TABLE IF EXISTS `GlossaryAliases`; + +INSERT INTO `schema_version_history` VALUES ('moddb', '6.7.0', NOW(), 'upgraded', 'N/A'); diff --git a/db/schema/moddb.sql b/db/schema/moddb.sql index 5743db6aaa..7ff251fa3a 100644 --- a/db/schema/moddb.sql +++ b/db/schema/moddb.sql @@ -73,22 +73,6 @@ CREATE TABLE `ExceptionEmailAddresses` ( `email_address` varchar(200) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `Glossary`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `Glossary` ( - `term` text, - `definition` text -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; -DROP TABLE IF EXISTS `GlossaryAliases`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `GlossaryAliases` ( - `term` text, - `alias` text -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -/*!40101 SET character_set_client = @saved_cs_client */; DROP TABLE IF EXISTS `RESTx509`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; diff --git a/html/controllers/ui_data/repogen_sites.php b/html/controllers/ui_data/repogen_sites.php deleted file mode 100644 index 589f11915a..0000000000 --- a/html/controllers/ui_data/repogen_sites.php +++ /dev/null @@ -1,34 +0,0 @@ - $resource, 'leaf' => true, 'checked' => true, 'iconCls' => 'site_child'); - - } - - $p[] = array('text' => $abbrev, 'checked' => true, 'iconCls' => 'site_parent', 'children' => $e, 'expanded' => false); - - } - - echo json_encode($p); - -?> \ No newline at end of file diff --git a/html/controllers/user_profile.php b/html/controllers/user_profile.php deleted file mode 100644 index b740cde380..0000000000 --- a/html/controllers/user_profile.php +++ /dev/null @@ -1,30 +0,0 @@ -registerOperation('list_fields_of_science'); - $controller->registerOperation('fetch_profile'); - $controller->registerOperation('update_profile'); - - $controller->invoke('GET'); - -?> \ No newline at end of file diff --git a/html/controllers/user_profile/fetch_profile.php b/html/controllers/user_profile/fetch_profile.php deleted file mode 100644 index 8d72845ee7..0000000000 --- a/html/controllers/user_profile/fetch_profile.php +++ /dev/null @@ -1,20 +0,0 @@ -fetch_profile - - $user_to_fetch = \xd_security\getLoggedInUser(); - - $returnData['first_name'] = $user_to_fetch->getFirstName(); - $returnData['last_name'] = $user_to_fetch->getLastName(); - $returnData['email_address'] = $user_to_fetch->getEmailAddress(); - - $returnData['token'] = $user_to_fetch->getToken(); - $returnData['token_expiration'] = $user_to_fetch->getTokenExpiration(); - - $returnData['field_of_science'] = $user_to_fetch->getFieldOfScience(); - - $returnData['status'] = "success"; - - xd_controller\returnJSON($returnData); - -?> \ No newline at end of file diff --git a/html/controllers/user_profile/list_fields_of_science.php b/html/controllers/user_profile/list_fields_of_science.php deleted file mode 100644 index cf74b91568..0000000000 --- a/html/controllers/user_profile/list_fields_of_science.php +++ /dev/null @@ -1,27 +0,0 @@ -list_fields_of_science - - $db_host = xd_utilities\getConfiguration('datawarehouse', 'host'); - $db_database = xd_utilities\getConfiguration('datawarehouse', 'database'); - $db_user = xd_utilities\getConfiguration('datawarehouse', 'user'); - $db_pass = xd_utilities\getConfiguration('datawarehouse', 'pass'); - - mysql_connect($db_host, $db_user, $db_pass); - - $res = mysql_query("SELECT id, description FROM $db_database.fieldofscience ORDER BY description"); - - $fields = array(); - - while(list($fos_id, $fos_label) = mysql_fetch_array($res)) { - $fields[] = array('field_id' => $fos_id, 'field_label' => $fos_label); - } - - // ----------------------------- - - $returnData['status'] = 'success'; - $returnData['fields_of_science'] = $fields; - - xd_controller\returnJSON($returnData); - -?> diff --git a/html/controllers/user_profile/update_profile.php b/html/controllers/user_profile/update_profile.php deleted file mode 100644 index ebe153cf15..0000000000 --- a/html/controllers/user_profile/update_profile.php +++ /dev/null @@ -1,49 +0,0 @@ -update_profile - - $user_to_update = \xd_security\getLoggedInUser(); - - // ----------------------------- - - $params = array( - 'first_name' => RESTRICTION_FIRST_NAME, - 'last_name' => RESTRICTION_LAST_NAME, - 'email_address' => RESTRICTION_EMAIL, - 'password' => RESTRICTION_PASSWORD, - 'field_of_science' => RESTRICTION_FIELD_OF_SCIENCE - ); - - $qualifyingParams = xd_security\secureCheck($params, 'POST', false); - - if ($qualifyingParams == 0) { - $returnData['status'] = 'need_update_information'; - xd_controller\returnJSON($returnData); - }; - - if (isset($_POST['first_name'])) $user_to_update->setFirstName($_POST['first_name']); - if (isset($_POST['last_name'])) $user_to_update->setLastName($_POST['last_name']); - if (isset($_POST['email_address'])) $user_to_update->setEmailAddress($_POST['email_address']); - - if (isset($_POST['password'])) $user_to_update->setPassword($_POST['password']); - if (isset($_POST['field_of_science'])) $user_to_update->setFieldOfScience($_POST['field_of_science']); - - // ----------------------------- - - try { - - $user_to_update->saveUser(); - - } - catch(Exception $e) { - - $returnData['status'] = $e->getMessage(); - xd_controller\returnJSON($returnData); - - } - - $returnData['status'] = "success"; - - xd_controller\returnJSON($returnData); - -?> \ No newline at end of file diff --git a/libraries/network.php b/libraries/network.php deleted file mode 100644 index b46dfd2c39..0000000000 --- a/libraries/network.php +++ /dev/null @@ -1,25 +0,0 @@ -"; - - $resolved_net = ip2long($ip) & $ip_mask; - - //print decbin($resolved_net)."
"; - - return ($resolved_net == $reference_net); - - }//addressBelongsToNetwork - -?> \ No newline at end of file diff --git a/libraries/utilities.php b/libraries/utilities.php index 1a13e1e1b8..27e0c7b7e6 100644 --- a/libraries/utilities.php +++ b/libraries/utilities.php @@ -184,28 +184,6 @@ function quote($entity) return "'$entity'"; } -/** - * Resolve a token? - */ -function tokenResolver($input) -{ - $user = \xd_security\getLoggedInUser(); - - $mappings = array( - "username" => $user->getUsername() - ); - - $output = $input; - - foreach ($mappings as $find => $replace) { - $output = str_replace("<$find>", $replace, $output); - } - - $output = mysql_escape_string($output); - - return $output; -} - /** * Remove an element from an array. */ diff --git a/open_xdmod/modules/xdmod/integration_tests/lib/TestHarness/XdmodTestHelper.php b/open_xdmod/modules/xdmod/integration_tests/lib/TestHarness/XdmodTestHelper.php index 2ea53c0b61..1059a5dd9a 100644 --- a/open_xdmod/modules/xdmod/integration_tests/lib/TestHarness/XdmodTestHelper.php +++ b/open_xdmod/modules/xdmod/integration_tests/lib/TestHarness/XdmodTestHelper.php @@ -47,7 +47,7 @@ public function __construct($config = array()) private function processResponseHeader($curl, $headerline) { - $tokens = split(':', $headerline); + $tokens = explode(':', $headerline); if (count($tokens) == 2) { $this->responseHeaders[$tokens[0]] = $tokens[1]; }