function addMOProperty($unifiedName, $client) { $mysqli = new mysqli(HOSTNAME, USERNAME, PASSWD, DATABASE); if ($mysqli->connect_errno) { die("error: " . $mysqli->connect_error); } $localTable = "MOSpacePeople"; $parser = new HumanNameParser_Parser($unifiedName); $last = $parser->getLast(); $first = $parser->getFirst(); //@Debug //echo "Checking ".$last.", ".$first."....."; $q = "SELECT * from " . $localTable . " where firstname='" . $mysqli->real_escape_string($first) . "' and lastname='" . $mysqli->real_escape_string($last) . "'"; $fromMU = 0; $isProfessor = 0; if ($result = $mysqli->query($q)) { if ($result->num_rows == 1) { //@Debug //echo "found in local database....."; $fromMU = 1; if ($resAssocArray = $result->fetch_assoc()) { if (isset($resAssocArray['Title'])) { $isProfessor = findIfProfessor($resAssocArray['Title']) == 1 ? 1 : 0; //@Debug //if($isProfessor == 1) echo "is a prof\n"; else echo "NOT a prof\n"; } else { $isProfessor = 0; //@Debu //echo "NOT a prof\n"; } } else { die("fetch result from MOSpacePeople failed"); } } else { $peopleFinderURL = "https://webservices.doit.missouri.edu/peoplefinderWS/peoplefinderws.asmx/PeopleFinderXml?firstName=" . urlencode($first) . "&lastname=" . urlencode($last) . "&department=&phoneno=&email="; $url_parser = new URLParser($peopleFinderURL); $retArr = $url_parser->XMLToArray(); if (intval($retArr['@attributes']['found']) == 1) { //@Debug //echo "found in Peoplefinder..."; $fromMU = 1; $title = array_key_exists("Title", $retArr['Person']) && !empty($retArr['Person']['Title']) ? $retArr['Person']['Title'] : ""; $isProfessor = findIfProfessor($title) == 1 ? 1 : 0; //@Debug //if($isProfessor == 1) echo "is a prof\n"; else echo "NOT a prof\n"; } else { $isProfessor = 0; //@Debug //echo "NOT a prof\n"; } } } else { die("query: " . $q . "\nFailed"); } $q_str = "match (u:Person {name: \"" . $unifiedName . "\"}) set u.fromMU = " . $fromMU . ", u.isProfessor = " . $isProfessor; $query = new Query($client, $q_str); $client->executeCypherQuery($query); }
//@Debu echo "NOT a prof\n"; } } else { die("fetch result from MOSpacePeople failed"); } } else { $peopleFinderURL = "https://webservices.doit.missouri.edu/peoplefinderWS/peoplefinderws.asmx/PeopleFinderXml?firstName=" . urlencode($first) . "&lastname=" . urlencode($last) . "&department=&phoneno=&email="; $url_parser = new URLParser($peopleFinderURL); $retArr = $url_parser->XMLToArray(); if (intval($retArr['@attributes']['found']) == 1) { //@Debug echo "found in Peoplefinder..."; $fromMU = 1; $title = array_key_exists("Title", $retArr['Person']) && !empty($retArr['Person']['Title']) ? $retArr['Person']['Title'] : ""; $isProfessor = findIfProfessor($title) == 1 ? 1 : 0; //@Debug if ($isProfessor == 1) { echo "is a prof\n"; } else { echo "NOT a prof\n"; } } else { $isProfessor = 0; //@Debug echo "NOT a prof\n"; } } } else { die("query: " . $q . "\nFailed"); }