* @version $Revision: 1.2 $ */ /** * The hostname of the database server. */ define("G_DATABASE_HOST", "localhost", 1); //define("G_DATABASE_HOST", "192.168.100.8", 1); /** * The username to use when connecting to the database server. */ define("G_DATABASE_USER", "scientific-confe", 1); /** * The password to use when connecting to the database server. */ define("G_DATABASE_PASSWORD", "zZp49FmJqw9EVgyw", 1); /** * The name of the physical database on the server. */ define("G_DATABASE_CATALOG", "solanaceae.scientific-conference.net", 1); /** * Open a connection to the database. * * @return long an identifier for the MySQL database connection */ function OpenDatabase() { $conn = mysql_pconnect(G_DATABASE_HOST, G_DATABASE_USER, G_DATABASE_PASSWORD); mysql_select_db(G_DATABASE_CATALOG, $conn); return $conn; } ?> * @version $Revision: 1.8 $ */ include_once("../classes/config.php"); //include_once("../classes/db_fcns.php"); /** * Resolves the author/address linkage map from IDs to names. * * @param dictionary $map a dictionary of (authorid,addressid) tuples * @return dictionary a dictionary of (authorname,address) tuples * @since 1.6 */ function ResolveLinkageMap($map) { $result = array(); foreach ($map as $authorid => $addressid) { $auname = GetAuthorNameForID($authorid); $address = GetAddressForID($addressid); $result[$auname] = $address; } user_error(dv__dump_array($result)); return $result; } function GetAuthorNameForID($authorID,$type='inline') { if (($authorID == '') || ($authorID == 'Unknown')) { return "Unknown"; } $result = ""; $sql = "SELECT * FROM tblabstractauthor WHERE AuthorID=#id#"; $sql = str_replace("#id", $authorID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAuthorNameForID($authorID): $sql: " . mysql_error()); return ""; } if (0 == mysql_num_rows($rst)) { $result = ""; } else { for ($i=0; $iAuthorID; $result[0]["Surname"] = $row->Surname; $result[0]["GivenName"] = $row->GivenName; $result[0]["EmailAddress"] = $row->EmailAddress; } else { $result = $row->GivenName . " " . $row->Surname; } } } mysql_free_result($rst); mysql_close($dbh); return $result; } function GetAddressForID($addressID,$type="inline") { $result = ""; $sql = "SELECT * FROM tblabstractaddress WHERE AddressID=#id#"; $sql = str_replace("#id#", $addressID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAddressForID($addressID): $sql: " . mysql_error()); return ""; } if (0 == mysql_num_rows($rst)) { $result = ""; } else { $row = mysql_fetch_object($rst); $result = FormatAddress($row,$type); } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Resolve a section ID back to a section name. * * @param long $sectionID The section ID to lookup. * @return integer the name of the section on success, or an empty string on error. * @since 1.6 */ function GetSectionNameForID($sectionID) { $result = ""; $sql = "SELECT SectionName FROM tblsections WHERE SectionID=#i#"; $sql = str_replace("#i#", $sectionID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetSectionNameForID($sectionID): $sql: " . mysql_error()); return ""; } if (0 == mysql_num_rows($rst)) { $result = ""; } else { $row = mysql_fetch_array($rst); $result = $row[0]; } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Save the special (step 5) information for an abstract. * * @param long $abstractID the abstract ID to update * @param string $conflicts the "potential conflicts" data * @param string $specialAV the "special AV needs" data * @param boolean $willingJudge is the submitter willing to judge * @param boolean $willingSecLead is the submitter willing to lead a section * @param boolean $wantsAward does the submitter want to be considered for awards * @since 1.6 */ function SaveSpecialsForAbstract($abstractID, $conflicts, $specialAV, $willingJudge, $willingSecLead, $wantsAward, $needsstandard, $needsslide, $needsoh, $linksymposiam, $symposiumid) { $sql = "UPDATE tblabstracts SET Conflicts='#c#', SpecialAV='#a#'," . "WillingSecChair=#s#, WillingJudge=#j#, ConsiderAward=#k#, StandardAV=#av#, SlideNeeded=#sl#, OverheadNeeded=#oh#, LinkSymposium=#ls#, SymposiumLinked=#sid# WHERE AbstractID=#i#"; $sql = str_replace("#c#", $conflicts, $sql); $sql = str_replace("#a#", $specialAV, $sql); $sql = str_replace("#s#", $willingSecLead, $sql); $sql = str_replace("#j#", $willingJudge, $sql); $sql = str_replace("#i#", $abstractID, $sql); $sql = str_replace("#k#", $wantsAward, $sql); $sql = str_replace("#av#", $needsstandard, $sql); $sql = str_replace("#sl#", $needsslide, $sql); $sql = str_replace("#oh#", $needsoh, $sql); $sql = str_replace("#ls#", $linksymposiam, $sql); $sql = str_replace("#sid#", $symposiumid, $sql); $dbh = OpenDatabase(); mysql_query($sql, $dbh); mysql_close($dbh); } function SaveFundingReqAbstract($abstractID, $position, $advisor, $visa, $funds, $reasons, $nationality, $ethnicity, $gender) { $sql = "UPDATE tblabstracts SET AbsAwPosition='$position', AbsAwAdvisor='$advisor'," . "AbsAwVisa='$visa', AbsAwFunds='$funds', AbsAwEssay='$reasons', AbsAwNationality='$nationality', AbsAwEthnic='$ethnicity', AbsAwGender='$gender' WHERE AbstractID='$abstractID'"; $dbh = OpenDatabase(); mysql_query($sql, $dbh); mysql_close($dbh); } /** * Check if a section requires a submission password and if the correct * password was supplied. * * @param long $sectionID the section ID to check * @param string $password the password supplied by the user, if any * @return 1 if the submission is authorized, 0 otherwise. * @since 1.6 */ function CheckSectionPassword($sectionID, $password) { $result = 0; $sql = "SELECT SubmissionPassword FROM tblsections WHERE SectionID=#i#"; $sql = str_replace("#i#", $sectionID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("CheckSectionPassword($sectionID, $password): $sql: " . mysql_error()); return 0; } if (0 == mysql_num_rows($rst)) { $result = 0; } else { $row = mysql_fetch_object($rst); if (0 == strlen($row->SubmissionPassword)) { $result = 1; } else { if ($row->SubmissionPassword == $password) { $result = 1; } } } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Retrieve the name of the section associated with a given abstract. * * @param long $abstractID the abstract ID to look up * @return string the name of the section associated with the abstract. */ function GetSectionNameForAbstract($abstractID) { $sectionID = GetSectionIDForAbstract($abstractID); $result = ""; $sql = "SELECT SectionName FROM tblsections WHERE SectionID=#id#"; $sql = str_replace("#id#", $sectionID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetSectionNameForAbstract($abstractID): $sql: " . mysql_error()); return ""; } if (0 == mysql_num_rows($rst)) { $result = ""; } else { $row = mysql_fetch_array($rst); $result = $row[0]; } mysql_free_result($rst); mysql_close($dbh); return $result; } function GetSectionIDForAbstract($abstractID) { $result = -1; $sql = "SELECT SectionID FROM tblabstracts WHERE AbstractID=#id#"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetSectionIDForAbstract($abstractID): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { $result = ""; user_error("GetSectionIDForAbstract($abstractID): " . mysql_error()); } else { $row = mysql_fetch_array($rst); $result = $row[0]; } mysql_free_result($rst); mysql_close($dbh); return $result; } function GetTitleForAbstract($abstractID) { $result = -1; $sql = "SELECT AbstractTitle FROM tblabstracts WHERE AbstractID=#id#"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractTitleForAbstract($abstractID): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { $result = ""; user_error("GetAbstractTitleForAbstract($abstractID): " . mysql_error()); } else { $row = mysql_fetch_array($rst); $result = $row[0]; } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Get a compact summary of all the data associated with an abstract * in one data structure. * * @param long $abstractID the abstract to retrieve * @return hash a hash containing the data for the specified abstract * @since 1.3 */ function GetAbstractSummary($abstractID,$addtype="inline") { $result = array(); $dbh = OpenDatabase(); // Fetch the abstract title and text $sql = "SELECT * FROM tblabstracts WHERE AbstractID=#aid#"; $sql = str_replace("#aid#", $abstractID, $sql); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractSummary($abstractID): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $result["type"] = $row->AbstractType; $result["title"] = $row->AbstractTitle; $result["abstract"] = $row->Abstract; $result["section"] = GetSectionNameForAbstract($abstractID); $result["conflicts"] = $row->Conflicts; $result["avneeds"] = $row->SpecialAV; $result["wschair"] = $row->WillingSecChair; $result["wjudge"] = $row->WillingJudge; $result["caward"] = $row->ConsiderAward; $result["number"] = $row->AbstractNo; $result["standardav"]= $row->StandardAV; $result["slide"] = $row->SlideNeeded; $result["overhead"] = $row->OverheadNeeded; $result["linksymposium"]=$row->LinkSymposium; $result["symposiumid"]=$row->SymposiumLinked; $result["creatorid"]=$row->CreatorID; mysql_free_result($rst); } else { $result["type"] = "unknown"; $result["title"] = "unknown"; $result["abstract"] = "unknown"; $result["section"] = "unknown"; $result["conflicts"] = "unknown"; $result["avneeds"] = "unknown"; $result["wschair"] = "unknown"; $result["wjudge"] = "unknown"; $result["caward"] = "unknown"; $result["number"] = "unknown"; $result["standardav"]= "unknown"; $result["slide"] = "unknown"; $result["overhead"] = "unknown"; $result["linksymposium"]="unknown"; $result["symposiumid"]="unknown"; $result["creatorid"]="unknown"; } mysql_close($dbh); // Get the author and keyword data for the abstract $result["authors"] = GetAuthorDataForAbstract($abstractID,$addtype); $result["keywords"] = GetKeywordsForAbstract($abstractID); $result["weblinks"] = GetLinksForAbstract($abstractID); $result["uploads"] = GetUploadsForAbstract($abstractID); // Return the whole schmear return $result; } /** * Get the author information associated with an abstract. * * @param long $abstractID the abstract ID to look up. * @return an dictionary of [first:last:email =>address] tuples. * @since 1.4 */ function GetAuthorDataForAbstract($abstractID,$addtype="inline") { $dbh = OpenDatabase(); $result = array(); $sql = "SELECT DISTINCT AuthorID from tbllinkabstractauthor WHERE AbstractID=#aid#"; $sql = str_replace("#aid#", $abstractID, $sql); $authorList = mysql_query($sql, $dbh); if (!$authorList) { user_error("GetAuthorDataForAbstract($abstractID): \$authorList: " . mysql_error()); } for ($i=0; $i < mysql_num_rows($authorList); $i++) { $arr = mysql_fetch_array($authorList); $authorID = $arr[0]; $rstAuthorData = mysql_query("SELECT * FROM tblabstractauthor WHERE AuthorID=$authorID", $dbh); if (!$rstAuthorData) { user_error("GetAuthorDataForAbstract($abstractID): \$rstAuthorData($authorID): " . mysql_error()); } $authorData = mysql_fetch_object($rstAuthorData); $rstlinkaddr = mysql_query("SELECT * FROM tbllinkauthoraddress WHERE AuthorID=$authorID AND AbstractID=$abstractID", $dbh); if (!$rstlinkaddr) { user_error("GetAuthorDataForAbstract($abstractID): \$rstlinkaddr($authorID): " . mysql_error()); } $linkage = mysql_fetch_object($rstlinkaddr); if ($linkage) { $rstAddress = mysql_query("SELECT * FROM tblabstractaddress WHERE AddressID=" . $linkage->AddressID, $dbh); if (!$rstAddress) { user_error("GetAuthorDataForAbstract($abstractID): \$rstAddress($authorID): " . mysql_error()); } $address = mysql_fetch_object($rstAddress); } $key = $authorData->GivenName . ":". $authorData->Surname . ":" . $authorData->EmailAddress. ":" . $authorData->AuthorID; $val = FormatAddress($address,$addtype); $result[$key] = $val; mysql_free_result($rstAuthorData); mysql_free_result($rstlinkaddr); mysql_free_result($rstAddress); } mysql_free_result($authorList); mysql_close($dbh); return $result; } /** * Get a list of the keywords associated with an abstract. * * @param long $abstractID the abstract ID to look up. * @return array an array of keywords * @since 1.4 */ function GetKeywordsForAbstract($abstractID) { $keywords = array(); $dbh = OpenDatabase(); $sql = "SELECT DISTINCT Keyword FROM tblkeywords tblkeywords, " . "tbllinkabstractkeywords tbllinkabstractkeywords ". "WHERE tblkeywords.KeywordID = tbllinkabstractkeywords.KeywordID " . "AND tbllinkabstractkeywords.AbstractID = #aid#"; $sql = str_replace("#aid#", $abstractID, $sql); $rst = mysql_query($sql,$dbh); if (!$rst) { user_error("GetKeywordsForAbstract($abstractID): " . mysql_error()); user_error("SQL was: $sql"); } if (0 != mysql_num_rows($rst)) { for ($i=0; $i,,,')); SaveKeywordLinkage($abstractID, $kid); } } /** * Link a keyword to an abstract ID. * * @param long $abstractID the abstract ID to link to * @param long $keywordID the keyword ID to link */ function SaveKeywordLinkage($abstractID, $keywordID) { $kwlid = -1; $sql = "SELECT AbstractID,KeywordID FROM tbllinkabstractkeywords WHERE KeywordID='#kwd#' AND AbstractID='#abid#'"; $sql = str_replace("#kwd#", $keywordID, $sql); $sql = str_replace("#abid#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("SaveKeywordLinkage($keywordID,$abstractID): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { // The keyword wasn't found, add it $sql = "INSERT INTO tbllinkabstractkeywords(AbstractID,KeywordID)" . "VALUES(#abid#, #kwid#)"; $sql = str_replace("#abid#", $abstractID, $sql); $sql = str_replace("#kwid#", $keywordID, $sql); $dbh = OpenDatabase(); $r = mysql_query($sql, $dbh); if (!$r) { user_error("SaveKeywordLinkage($abstractID,$keywordID): " . mysql_error()); } } mysql_free_result($rst); mysql_close($dbh); } /** * Get the ID number of a keyword, or create a new one and return its ID. * * @param string $keyword the keyword to add * @return long the ID number of the keyword in the database * @since 1.3 */ function MaybeAddKeyword($keyword) { $kwid = -1; $sql = "SELECT KeywordID FROM tblkeywords WHERE Keyword='#kwd#'"; $sql = str_replace("#kwd#", $keyword, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("MaybeAddKeyword($keyword): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { // The keyword wasn't found, add it $rawkeyword = strip_tags($keyword); $sql = "INSERT INTO tblkeywords(Keyword,RawKeyword) VALUES('$keyword','$rawkeyword')"; $sql = str_replace("#kwd#", $keyword, $sql); mysql_query($sql, $dbh); // Get the keyword ID back from the database $sql = "SELECT LAST_INSERT_ID() AS KeywordID"; $rst = mysql_query($sql, $dbh); $row = mysql_fetch_object($rst); $kwid = $row->KeywordID; } else { // Get the keyword ID from the database $row = mysql_fetch_object($rst); $kwid = $row->KeywordID; } mysql_free_result($rst); mysql_close($dbh); assert($kwid <> -1); return $kwid; } function GetPossibleKeywords($keyword,$searchtype='like',$score=3) { $keyword = ltrim(rtrim($keyword)); $rawkeyword = strip_tags($keyword); if ($keyword != '') { if ($searchtype == 'fulltext') { $sql = "SELECT * , MATCH (Keyword)AGAINST ('$keyword') as score FROM tblkeywords WHERE MATCH (Keyword) AGAINST ('$keyword') HAVING score > $score ORDER BY score"; } else if ($searchtype == 'equals') { $sql = "SELECT * FROM tblkeywords WHERE (Keyword = '$keyword') OR (RawKeyword = '$rawkeyword') ORDER BY RawKeyword, Keyword"; } else { $sql = "SELECT * FROM tblkeywords WHERE (Keyword LIKE '%$keyword%') OR (RawKeyword LIKE '%$rawkeyword%') ORDER BY RawKeyword, Keyword"; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetPossibleKeywords($keyword): " . mysql_error()); } $keywordarray = array(); for ($i=0; $iKeywordID; $keywordarray[$i]['Keyword'] = $row->Keyword; } mysql_free_result($rst); mysql_close($dbh); } return $keywordarray; } function GetKeywordForKeywordID($KeywordID,$type='inline') { if (($KeywordID == '') || ($KeywordID == 'Unknown')) { return "Unknown"; } $result = ""; $sql = "SELECT * FROM tblkeywords WHERE KeywordID=#id#"; $sql = str_replace("#id", $KeywordID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetKeywordForKeywordID($authorID): $sql: " . mysql_error()); return ""; } if (0 == mysql_num_rows($rst)) { $result = ""; } else { for ($i=0; $iKeywordID; $result[0]["Keyword"] = $row->Keyword; } else { $result = $row->Keyword . " " . $row->Keyword; } } } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Creates a new abstract record and returns its abstract ID. * * @return long the ID of the newly created abstract. * @since 1.1 */ function CreateAbstractRecord($type) { $abid = -1; $sql = "INSERT INTO tblabstracts(AbstractType, DateCreated, SectionID, CreatorID, TypeNode) "; $sql .= "VALUES('#t#', NOW(), '#s#', '#i#', '#n#')"; $sql = str_replace("#i#", $_SESSION["botany_userid"], $sql); $sql = str_replace("#s#", $_SESSION["botany_submittalSection"], $sql); $sql = str_replace("#t#", $_SESSION["botany_submittalType"], $sql); $sql = str_replace("#n#", $_SESSION["botany_TypeNode"], $sql); $dbh = OpenDatabase(); $r = mysql_query($sql, $dbh); if (!$r) { user_error("CreateAbstractRecord(): " . mysql_error()); } $sql = "SELECT LAST_INSERT_ID() AS NewEntry"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("CreateAbstractRecord(\$rst2): " . mysql_error()); } $row = mysql_fetch_array($rst); $abid = $row[0]; mysql_free_result($rst); mysql_close($dbh); assert($abid > 0); return $abid; } function SetAbstractSection($abstractID, $abstractSection, $abstractType, $presentingAUID, $typenode) { $sql = "UPDATE tblabstracts SET AbstractType='#type#', " . "SectionID='#section#' , FirstAuthorID='#presAUID', TypeNode='#typenode#' WHERE AbstractID=#aid#"; $sql = str_replace("#aid#", $abstractID, $sql); $sql = str_replace("#type#", $abstractType, $sql); $sql = str_replace("#section#", $abstractSection, $sql); $sql = str_replace("#presAUID", $presentingAUID, $sql); $sql = str_replace("#typenode#", $typenode, $sql); $dbh = OpenDatabase(); $result = mysql_query($sql, $dbh); if (!$result) { user_error("SetAbstractSection($abstractID): " . mysql_error()); } mysql_close($dbh); return 0; } /** * Sets the linkage between an author and her/his address. * * @param long $abstractID the abstract ID * @param long $authorid the author ID to link * @param long $addressid the adress ID to link * @since 1.1 */ function SetAddressLinkage($abstractid, $authorid, $addressid) { $aulid = -1; $whereabstract = ""; if ($abstractid != "") { $whereabstract = " AND AbstractID = '#ab#' "; } else { $abstractid = 0; } $sql = "SELECT AuthorID,AddressID,AbstractID FROM tbllinkauthoraddress WHERE AuthorID='#au#' $whereabstract"; $sql = str_replace("#ab#", $abstractid, $sql); $sql = str_replace("#au#", $authorid, $sql); $sql = str_replace("#ad#", $addressid, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("SetAddressLinkage($abstractid,$authorid,$addressid): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { $sql = "INSERT INTO tbllinkauthoraddress(AuthorID,AddressID,AbstractID) " . "VALUES(#au#, #ad#, #ab#)"; $sql = str_replace("#au#", $authorid, $sql); $sql = str_replace("#ad#", $addressid, $sql); $sql = str_replace("#ab#", $abstractid, $sql); $dbh = OpenDatabase(); $r = mysql_query($sql, $dbh); if (!$r) { user_error("SetAddressLinkage($abstractid,$authorid,$addressid): " . mysql_error()); } //echo "linkage: ", $authorid, ": ", $addressid, "
"; mysql_free_result($rst); mysql_close($dbh); if ($abstractid > 0){ SetAuthorLinkage($abstractid, $authorid); } } else { $sql = "UPDATE tbllinkauthoraddress SET AddressID = #ad# WHERE AuthorID='#au#' AND AbstractID = '#ab#'"; $sql = str_replace("#au#", $authorid, $sql); $sql = str_replace("#ad#", $addressid, $sql); $sql = str_replace("#ab#", $abstractid, $sql); $dbh = OpenDatabase(); $r = mysql_query($sql, $dbh); if (!$r) { user_error("SetAddressLinkage($abstractid,$authorid,$addressid): " . mysql_error()); } //echo "linkage: ", $authorid, ": ", $addressid, "
"; mysql_free_result($rst); mysql_close($dbh); } } /** * Sets the linkage between an abstract and an author. * * @param long $abstractid the abstract ID to link * @param long $authorid the author ID to link * @since 1.1 */ function SetAuthorLinkage($abstractid, $authorid, $sortorder=0) { $aulid = -1; $sql = "SELECT AbstractID, AuthorID FROM tbllinkabstractauthor WHERE AbstractID='#ab#' AND AuthorID='#au#'"; $sql = str_replace("#ab#", $abstractid, $sql); $sql = str_replace("#au#", $authorid, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("SetAuthorLinkage($abstractid,$authorid): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { // The keyword wasn't found, add it $sql = "INSERT INTO tbllinkabstractauthor(AbstractID, AuthorID, SortOrder) " . "VALUES(#ab#, #au#, #so#)"; $sql = str_replace("#ab#", $abstractid, $sql); $sql = str_replace("#au#", $authorid, $sql); $sql = str_replace("#so#", $sortorder, $sql); $dbh = OpenDatabase(); $r = mysql_query($sql, $dbh); if (!$r) { user_error("SetAuthorLinkage($abstractid,$authorid): " . mysql_error()); } } mysql_free_result($rst); mysql_close($dbh); } /** * Adds an author to the database. Does NOT link the author to anything. * * @param string $lastName the author's last name * @param string $givenName the author's given name(s) or initials * @param string $email the author's email address, if known * @return long the author ID of the newly created author */ function AddAuthor($lastName, $givenName, $email) { $auid = -1; $lastName = addslashes($lastName); $givenName = addslashes($givenName); if (strlen($email)) { $auid = LookupAuthorByEmail($email); if ($auid > 0) { return $auid; } } if (($lastName != '') && ($givenName != '')) { $sql = "INSERT INTO tblabstractauthor(Surname,GivenName,EmailAddress) " . "VALUES('#ln#', '#fn#', LOWER('#em#'))"; $sql = str_replace("#ln#", $lastName, $sql); $sql = str_replace("#fn#", $givenName, $sql); $sql = str_replace("#em#", $email, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("AddAuthor($lastName, $givenName, $email): " . mysql_error()); } //echo "author: ", $email, "
"; $rst = mysql_query("SELECT LAST_INSERT_ID() AS NewAuthorID", $dbh); if (!$rst) { user_error("AddAuthor(\$rst2): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $auid = $row->NewAuthorID; } mysql_free_result($rst); mysql_close($dbh); assert($auid > 0); return $auid; } } /** * Look up an author by e-mail address, and return his/her author ID. * * @param string $email the e-mail address to look up * @return long the author's ID, or 0 if the specified email was not found. */ function LookupAuthorByEmail($email) { $auid = 0; if ($email == '') { return "Unknown"; } $sql = "SELECT MAX(AuthorID) AS AUID FROM tblabstractauthor WHERE " . "LOWER(EmailAddress)=LOWER('#em#')"; $sql = str_replace("#em#", $email, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("LookupAuthorByEmail($email): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $auid = $row->AUID; } mysql_free_result($rst); mysql_close($dbh); return $auid; } function LookupAuthorByName($lastname,$givenname) { $result = array(); if ($givenname != '') { $sql = "SELECT * FROM tblabstractauthor WHERE Surname LIKE '$lastname%' AND GivenName LIKE '".$givenname."%' ORDER BY Surname, GivenName"; } else { $sql = "SELECT * FROM tblabstractauthor WHERE Surname LIKE '$lastname%' ORDER BY Surname, GivenName"; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("LookupAuthorByName($email): " . mysql_error()); } for ($i=0; $iAuthorID; $result[$i]["Surname"] = $row->Surname; $result[$i]["GivenName"] = $row->GivenName; $result[$i]["EmailAddress"] = $row->EmailAddress; } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Look to see if there's an exact match for an address in the database. * * We don't do this because we expect a lot of matches, user error being * what it is, but even a few successful matches makes it worth the overhead * of doing the check. * * @param string $address the address to look up * @return long the address ID for the given address, or 0 if it was not found. */ function LookupAddress($address) { $auid = 0; $address = addslashes($address); $sql = "SELECT MAX(AddressID) AS MaxAddr FROM tblabstractaddress WHERE " . "AddressID='#a#'"; $sql = str_replace("#a#", $address, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("LookupAddress($address): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $auid = $row->MaxAddr; } if ($auid == 0) { $addressvals = array(); $addressvals = explode("|",$address); $sql = "SELECT MAX(AddressID)AS MaxAddr FROM tblabstractaddress WHERE Institution = '$addressvals[0]' AND Department = '$addressvals[1]' AND AddressData = '$addressvals[2]' AND Address2 = '$addressvals[3]' AND City = '$addressvals[4]' AND State = '$addressvals[5]' AND Zip = '$addressvals[6]' AND Zip4 = '$addressvals[7]' AND Country = '$addressvals[8]'"; //$sql = str_replace("#a#", $addressvals, $sql); if ($addressvals[6]=='99501') { $a = $a; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $auid = $row->MaxAddr; } } mysql_free_result($rst); mysql_close($dbh); return $auid; } /** * Add an address to the database. * * @param string $address the address to add * @return long the address ID of the newly added address. */ function AddAddress($address) { $slashedaddress = addslashes($address); $auid = LookupAddress($address); if ($auid > 0) { return $auid; } $addressvals = array(); $addressvals = explode("|",$slashedaddress); $sql = "INSERT INTO tblabstractaddress(Institution,Department,AddressData,Address2,City,State,Zip,Zip4,Country) VALUES('$addressvals[0]','$addressvals[1]','$addressvals[2]','$addressvals[3]','$addressvals[4]','$addressvals[5]','$addressvals[6]','$addressvals[7]','$addressvals[8]')"; //$sql = str_replace("#a#", $addressvals, $sql); $dbh = OpenDatabase(); $r = mysql_query($sql, $dbh); if (!$r) { user_error("AddAddress($address): " . mysql_error()); } //echo "zip: ", $addressvals[6], "
"; $sql = "SELECT LAST_INSERT_ID() AS MaxAddr"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("AddAddress(\$rst2): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $auid = $row->MaxAddr; } mysql_free_result($rst); mysql_close($dbh); return $auid; } /** * Get a list of the sections for a conference. * * @param long $conferenceID the conference ID of the conference to query * @param long $selectSymposia 0 to select normal sections, 1 to select symposia, 2 to select special sections * @return array a list of secid:secname tuples, as colon-delimited strings */ function GetClassesForConference($conferenceID, $selectSymposia=0) { $sql = "SELECT SectionID, SectionName FROM tblsections " . "WHERE ConferenceID=#cid# AND IsSymposia=#sym# AND IsSpecialSection=#spec# " . "ORDER BY SortOrder ASC, SectionName ASC"; $sql = str_replace("#cid#", $conferenceID, $sql); switch ($selectSymposia) { case 0: $sql = str_replace("#sym#", 0, $sql); $sql = str_replace("#spec#", 0, $sql); break; case 1: $sql = str_replace("#sym#", 1, $sql); $sql = str_replace("#spec#", 0, $sql); break; case 2: $sql = str_replace("#sym#", 0, $sql); $sql = str_replace("#spec#", 1, $sql); break; case 3: $sql = str_replace("#sym#", 2, $sql); $sql = str_replace("#spec#", 0, $sql); break; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetClassesForConference($conferenceID, $selectSymposia): " . mysql_error()); } $result = array(); if (0 == mysql_num_rows($rst)) { mysql_free_result($rst); mysql_close($dbh); return $result; } while ($row = mysql_fetch_object($rst)) { $secid = $row->SectionID; $secname = $row->SectionName; array_push($result, "$secid:$secname"); } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Map the associatedAuthors session array to a dictionary of authors. * * @return dictionary a map of (auid => auname) tuples. */ function GetAssociatedAuthors() { $aumap = array(); $dbh = OpenDatabase(); foreach ($_SESSION["associatedAuthors"] as $auid) { $sql = "SELECT * FROM tblabstractauthor WHERE AuthorID=" . $auid; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAssociatedAuthors($auid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $x = $row->Surname . ", " . $row->GivenName; $aumap[$auid] = $x; } mysql_free_result($rst); } mysql_close($dbh); return $aumap; } /** * Map the associatedAddresses session array to a dictionary of authors. * * @return dictionary a map of (adid => adname) tuples. */ function GetAssociatedAddresses() { $admap = array(); $dbh = OpenDatabase(); foreach ($_SESSION["associatedAddresses"] as $adid) { $sql = "SELECT * FROM tblabstractaddress WHERE AddressID=" . $adid; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAssociatedAddresses($adid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $admap[$adid] = FormatAddress($row,"inline"); } mysql_free_result($rst); } mysql_close($dbh); return $admap; } /** * Count the number of words in a string. * * @param $text the string to count * @return integer the number of words in the string * @since 1.6 */ function CountWords($text) { $words_to_count = strip_tags($text); $words_to_count = str_replace('\"','',$words_to_count); $words_to_count = str_replace("\'","",$words_to_count); $words_to_count = str_replace("\\","",$words_to_count); $words_to_count = str_replace(".","",$words_to_count); $pattern = "/[^(\w|\d|\'|\"|\.|\!|\?|;|,|\\|\/|\-\-|=|:|\&|@)]+/"; $words_to_count = preg_replace ($pattern, " ", $words_to_count); $words_to_count = trim($words_to_count); $total_words = count(explode(" ",$words_to_count)); //$total_words = str_word_count($words_to_count); return $total_words; } /** * Get a list of all keywords. * * @param long $abstractID the abstract ID to look up. * @return array an array of keywords * @since 1.4 */ function GetAllKeywords() { $allkeywords = array(); $dbh = OpenDatabase(); $sql = "SELECT DISTINCT * FROM tblkeywords"; $rst = mysql_query($sql,$dbh); if (!$rst) { user_error("GetAllKeywords(): " . mysql_error()); user_error("SQL was: $sql"); } if (0 != mysql_num_rows($rst)) { for ($i=0; $iKeywordID; $resultarray[$i]['Keyword'] = $row->Keyword; $resultarray[$i]['KeywordSort'] = strtolower(strip_tags($row->Keyword)); } $resultarray = abs_array_natsort($resultarray,'KeywordID','KeywordSort'); $z = $z; for ($i=0; $iSurname; $result["GivenName"] = $row->GivenName; $result["EmailAddress"] = $row->EmailAddress; } mysql_free_result($rst); mysql_close($dbh); return $result; } function GetPossibleAddresses() { $admap = array(); $dbh = OpenDatabase(); foreach ($_SESSION["associatedAuthors"] as $auid) { $sql = "SELECT AddressID FROM tbllinkauthoraddress WHERE AuthorID=" . $auid; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetPossibleAddresses($auid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $admap[$auid] = $row->AddressID; } mysql_free_result($rst); } foreach ($_SESSION["PostalCodes"] as $auid) { $sql = "SELECT AddressID FROM tblabstractaddress WHERE Zip=\"" . $auid."\""; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetPossibleAddresses($auid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { for ($i=0; $iAddressID; } } mysql_free_result($rst); } $admap = array_unique($admap); $addata = array(); $addata = AddIDArray2AddAllArray($admap); mysql_close($dbh); return $addata; } function FormatAddress($row,$type,$element=null) { $address = ""; if ($type == "inline") { if (!isset($element)) { If ($row->Institution != "") $address = $row->Institution.", "; If ($row->Department != "") $address .= $row->Department.", "; If ($row->AddressData != "") $address .= $row->AddressData.", "; If ($row->Address2 != "") $address .= $row->Address2.", "; If ($row->City != "") $address .= $row->City.", "; If ($row->State != "") $address .= $row->State.", "; If ($row->Zip != "") $address .= $row->Zip; //If ($row->Zip4 != 0) $address .= "-".$row->Zip4; If ($row->Country != "") $address .= ", ".$row->Country; } else { If ($row->Institution != "") $address = $row->Institution.""; } } elseif ($type == "array") { $address = array(); if (!isset($element)) { If ($row->Institution != "") $address['Institution'] = $row->Institution.", "; $address['MappingID'] = $row->MappingID; $address['AuthorID'] = $row->AuthorID; $address['AbstractID'] = $row->AbstractID; $address['AddressID'] = $row->AddressID; $address['Institution'] = $row->Institution; $address['Department'] = $row->Department; $address['AddressData'] = $row->AddressData; $address['Address2'] = $row->Address2; $address['City'] = $row->City; $address['State'] = $row->State; $address['Zip'] = $row->Zip; //$address['Zip4'] = $row->Zip4; $address['Country'] = $row->Country; } else { If ($row->Institution != "") $address['Institution'] = $row->Institution.""; } }else { //in rows if (!isset($element)) { If ($row->Institution != "") $address = $row->Institution."
"; If ($row->Department != "") $address .= $row->Department."
"; If ($row->AddressData != "") $address .= $row->AddressData; If ($row->Address2 != "") $address .= "
".$row->Address2; $address .= "
"; If ($row->City != "") $address .= $row->City.", "; If ($row->State != "") $address .= $row->State; If ($row->Zip != 0) $address .= " ".$row->Zip; //If ($row->Zip4 != 0) $address .= "-".$row->Zip4; If ($row->Country != "") $address .= " ".$row->Country; } else { If ($row->Institution != "") $address = $row->Institution."
"; } } return $address; } function SetInitialValue($sessionvar,$default) { if ($sessionvar != $default) { $sessionvar = $sessionvar; }else{ $sessionvar = $default; } return $sessionvar; } function AddIDArray2AddAllArray ($admap) { $addata = array(); $dbh = OpenDatabase(); foreach ($admap as $adid) { $sql = "SELECT * FROM tblabstractaddress WHERE AddressID=" . $adid; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetPossibleAddresses($adid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $addata[$adid]['AddressID'] = $row->AddressID; $addata[$adid]['Institution'] = $row->Institution; $addata[$adid]['Department'] = $row->Department; $addata[$adid]['Address1'] = $row->AddressData; $addata[$adid]['Address2'] = $row->Address2; $addata[$adid]['City'] = $row->City; $addata[$adid]['State'] = $row->State; $addata[$adid]['Zip'] = $row->Zip; $addata[$adid]['Zip4'] = $row->Zip4; $addata[$adid]['Country'] = $row->Country; } mysql_free_result($rst); } mysql_close($dbh); return $addata; } /** * Get a list of the weblinks associated with an abstract. * * @param long $abstractID the abstract ID to look up. * @return array an array of web links * @since 1.4 */ function GetLinksForAbstract($abstractID) { $weblinks = array(); $dbh = OpenDatabase(); $sql = "SELECT * FROM tblweblinks WHERE AbstractID = #aid#"; $sql = str_replace("#aid#", $abstractID, $sql); $rst = mysql_query($sql,$dbh); if (!$rst) { user_error("GetLinksForAbstract($abstractID): " . mysql_error()); user_error("SQL was: $sql"); } if (0 != mysql_num_rows($rst)) { for ($i=0; $iWebLinkID; $weblinks[$i]["AbstractID"] = $row->AbstractID; $weblinks[$i]["WebLinkURL"] = $row->WebLinkURL; $weblinks[$i]["WebLinkDesc"] = $row->WebLinkDesc; } mysql_free_result($rst); } mysql_close($dbh); return $weblinks; } function GetUploadsForAbstract($abstractID) { $uploads = array(); $dbh = OpenDatabase(); $sql = "SELECT * FROM blobs WHERE AbstractID = #aid#"; $sql = str_replace("#aid#", $abstractID, $sql); $rst = mysql_query($sql,$dbh); if (!$rst) { user_error("GetUpoadsForAbstract($abstractID): " . mysql_error()); user_error("SQL was: $sql"); } if (0 != mysql_num_rows($rst)) { for ($i=0; $iid; $uploads[$i]["file_name"] = $row->file_name; $uploads[$i]["DATA"] = $row->DATA; $uploads[$i]["file_size"] = $row->file_size; $uploads[$i]["mimetype"] = $row->mimetype; $uploads[$i]["extension"] = $row->extension; $uploads[$i]["CHECKSUM"] = $row->CHECKSUM; $uploads[$i]["AbstractID"] = $row->AbstractID; $uploads[$i]["BlobTitle"] = $row->BlobTitle; $uploads[$i]["BlobDesc"] = $row->BlobDesc; $uploads[$i]["Requirements"] = $row->Requirements; } mysql_free_result($rst); } mysql_close($dbh); return $uploads; } function AddWebLink($abstractID,$weblink) { $wlid = LookupWebLink($weblink[2]); if ($wlid > 0) { $sql = "UPDATE tblweblinks SET AbstractID=$abstractID,WebLinkURL='$weblink[1]',WebLinkDesc='$weblink[0]' WHERE WebLinkID=$wlid"; } else { //$weblinkvals = explode("|||",$weblink); $sql = "INSERT INTO tblweblinks(AbstractID,WebLinkURL,WebLinkDesc) VALUES('$abstractID','$weblink[1]','$weblink[0]')"; $sql = str_replace("#a#", '$abstractID', $sql); $sql = str_replace("#d#", '$weblink[0]', $sql); $sql = str_replace("#u#", '$weblink[1]', $sql); } $dbh = OpenDatabase(); $r = mysql_query($sql, $dbh); if (!$r) { user_error("AddWebLink($weblink): " . mysql_error()); } $sql = "SELECT LAST_INSERT_ID() AS MaxAddr"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("AddWebLink(\$rst2): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $wlid = $row->MaxAddr; } mysql_free_result($rst); mysql_close($dbh); return $wlid; } function LookupWebLink($weblinkid) { $wlid = 0; $sql = "SELECT MAX(WebLinkID) AS MaxAddr FROM tblweblinks WHERE " . "WebLinkID='#a#'"; $sql = str_replace("#a#", $weblinkid, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("LookupWebLink($weblinkid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $wlid = $row->MaxAddr; } mysql_free_result($rst); mysql_close($dbh); return $wlid; } function GetLinkData($weblinkid) { $wlarray = array(); $sql = "SELECT * FROM tblweblinks WHERE " . "WebLinkID='#a#'"; $sql = str_replace("#a#", $weblinkid, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("LookupWebLink($weblinkid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $wlarray['WebLinkID'] = $row->WebLinkID; $wlarray['WebLinkDesc'] = $row->WebLinkDesc; $wlarray['WebLinkURL'] = $row->WebLinkURL; $wlarray['AbstractID'] = $row->AbstractID; } mysql_free_result($rst); mysql_close($dbh); return $wlarray; } /** * @return Returns the array sorted as required * @param $aryData Array containing data to sort * @param $strIndex Name of column to use as an index * @param $strSortBy Column to sort the array by * @param $strSortType String containing either asc or desc [default to asc] * @desc Naturally sorts an array using by the column $strSortBy */ function abs_array_natsort($aryData, $strIndex, $strSortBy, $strSortType=false) { // if the parameters are invalid if (!is_array($aryData) || !$strIndex || !$strSortBy) // return the array return $aryData; // create our temporary arrays $arySort = $aryResult = array(); // loop through the array foreach ($aryData as $aryRow) // set up the value in the array $arySort[$aryRow[$strIndex]] = $aryRow[$strSortBy]; // apply the natural sort natsort($arySort); // if the sort type is descending if ($strSortType=="desc") // reverse the array arsort($arySort); // loop through the sorted and original data foreach ($arySort as $arySortKey => $arySorted) foreach ($aryData as $aryOriginal) // if the key matches if ($aryOriginal[$strIndex]==$arySortKey) // add it to the output array array_push($aryResult, $aryOriginal); // return the return return $aryResult; } function GetAuthorAddresses($auid) { $admap = array(); $dbh = OpenDatabase(); $sql = "SELECT * FROM tbllinkauthoraddress WHERE AuthorID=" . $auid . " GROUP BY AddressID"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAuthorAddresses($auid): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { for ($i=0; $iAddressID; $admap[$i]['AbstractID'] = $row->AbstractID; $admap[$i]['AuthorID'] = $row->AuthorID; } } mysql_free_result($rst); mysql_close($dbh); return $admap; } function AuthorUpDown($aid,$auid,$order) { $sql = "UPDATE tbllinkabstractauthor SET SortOrder=".$order." WHERE AuthorID = '$auid' AND AbstractID = '$aid'"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $autharray = array(); if (!$rst) { user_error("AuthorUpDown($aid,$auid,$direction): " . mysql_error()); return false; } else { return true; } mysql_free_result($rst); mysql_close($dbh); } // This function will Unlink an author from an abstract, and then run Delete Orphan Author function UnlinkAuthor($aid, $auid) { //DeleteOrphanAuthor($auid, $aid); // delete abstract/author link $sql = "DELETE FROM tbllinkabstractauthor WHERE AbstractID = $aid AND AuthorID = $auid"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("RemoveAuthor($aid,$auid): " . mysql_error()); } mysql_free_result($rst); //delete abstract/author/address link $sql = "DELETE FROM tbllinkauthoraddress WHERE AbstractID = $aid AND AuthorID = $auid"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("RemoveAuthor($aid,$auid): " . mysql_error()); } mysql_free_result($rst); mysql_close($dbh); } // This function will test to see if an author is orphaned, and if so delete it, then runs Delete Orphan Address function DeleteOrphanAuthor($auid, $notaid = null) { $sql = "SELECT * FROM tbllinkabstractauthor WHERE AuthorID = $auid"; If ($notaid) { $sql .= " AND AbstractID != $notaid"; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteOrphanAuthor($auid): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { //since it is orphaned, find the addresses this author is linked to $sql = "SELECT * FROM tbllinkauthoraddress WHERE AuthorID = $auid"; If ($notaid) { $sql .= " AND AbstractID != $notaid"; } $rst2 = mysql_query($sql, $dbh); if (!$rst2) { user_error("DeleteOrphanAuthor($auid): " . mysql_error()); } for ($i=0; $iAddressID); $sql = "DELETE FROM tbllinkauthoraddress WHERE MappingID = $row->MappingID"; $rst3 = mysql_query($sql, $dbh); if (!$rst3) { user_error("DeleteOrphanAuthor($auid): " . mysql_error()); } mysql_free_result($rst3); } mysql_free_result($rst2); //Now actually delete the author $sql = "DELETE FROM tblabstractauthor WHERE AuthorID = $auid"; $rst4 = mysql_query($sql, $dbh); if (!$rst4) { user_error("DeleteOrphanAuthor($auid): " . mysql_error()); } mysql_free_result($rst4); } mysql_free_result($rst); mysql_close($dbh); } function DeleteOrphanAddress($adid) { $sql = "SELECT * FROM tbllinkauthoraddress WHERE AddressID = $adid"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteOrphanAddress($adid): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { //since there are no author/address links, the address must be orphaned; delete it. $sql = "DELETE tblabstractaddress WHERE AddressID = $adid"; $rst2 = mysql_query($sql, $dbh); if (!$rst2) { user_error("DeleteOrphanAddress($adid): " . mysql_error()); } } mysql_free_result($rst); mysql_close($dbh); } // This function will Unlink an author from an abstract, and then run Delete Orphan Author function UnlinkKeyword($aid, $kid) { // delete abstract/Keyword link $sql = "DELETE FROM tbllinkabstractkeywords WHERE MappingID = $kid"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("UnlinkKeyword($aid,$auid): " . mysql_error()); } //mysql_free_result($rst); mysql_close($dbh); } function KeywordUpDown($aid,$kid,$direction="up") { $sql = "SELECT * FROM tbllinkabstractkeywords WHERE AbstractID = $aid ORDER BY MappingID"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $keywordarray = array(); if (!$rst) { user_error("KeywordUpDown($aid,$kid,$direction): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { for ($i=0; $iMappingID; $keywordarray[$i]['AbstractID'] = $row->AbstractID; $keywordarray[$i]['KeywordID'] = $row->KeywordID; if ($keywordarray[$i]['KeywordID'] == $kid) { $lineno = $i; } } mysql_free_result($rst); } if (($direction == "up") & ($lineno != 0)) { $swappedID = $keywordarray[$lineno-1]['KeywordID']; $sql = "UPDATE tbllinkabstractkeywords SET KeywordID=".$kid." WHERE MappingID=".$keywordarray[$lineno-1]['MappingID'].""; //$dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("AuthorUpDown($aid,$kid,$direction): " . mysql_error()); } } else if (($direction != "up") & ($linenoWebLinkID; $weblinkarray[$i]['AbstractID'] = $row->AbstractID; $weblinkarray[$i]['WebLinkURL'] = $row->WebLinkURL; $weblinkarray[$i]['WebLinkDesc'] = $row-> WebLinkDesc; if ($weblinkarray[$i]['WebLinkID'] == $wlid) { $lineno = $i; } } mysql_free_result($rst); } if (($direction == "up") & ($lineno != 0)) { $swappedID = $weblinkarray[$lineno-1]['AbstractID']; $swappedURL = $weblinkarray[$lineno-1]['WebLinkURL']; $swappedDesc = $weblinkarray[$lineno-1]['WebLinkDesc']; $sql = "UPDATE tblweblinks SET AbstractID=".$weblinkarray[$lineno]['AbstractID'].", WebLinkURL=\"".$weblinkarray[$lineno]['WebLinkURL']."\", WebLinkDesc=\"".$weblinkarray[$lineno]['WebLinkDesc']."\" WHERE WebLinkID=".$weblinkarray[$lineno-1]['WebLinkID'].""; //$dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("AuthorUpDown($aid,$wlid,$direction): " . mysql_error()); } } else if (($direction != "up") & ($lineno\n"; if ($pickone != '') { $select .= "\n"; } foreach ($array as $idx => $row) { if ($row[$index] == $default) { $selected = "selected"; } else { $selected = ""; } $select .= "\n"; } $select .= "\n"; return $select; } function RadioList($array,$selname,$default='',$pickone='',$index='ConfigID',$value='ConfigVal',$style='',$multiple='') { //this function doesn't work yet! $select = "\n"; return $select; } function CheckboxList($array,$selname,$cols='4',$index='ConfigID',$value='ConfigVal',$style='') { //this function doesn't work yet! $select = ""; $select .= ""; $count = 0; foreach ($array as $idx => $row) { if (fmod($count,$cols) == 0) { $select .= ""; } $select .= "
".$row[$value]."\n"; $count = $count+1; } $select .= "
"; return $select; } function GetLocationList() { $sql = "SELECT * FROM tblbuilding, tbllocation WHERE tbllocation.BuildingID = tblbuilding.BuildingID"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $locationarray = array(); for ($i=0; $iLocationID; $locationarray[$i]['BuildingID'] = $row->BuildingID; $locationarray[$i]['BuildingName'] = $row->BuildingName; $locationarray[$i]['LocationName'] = $row->LocationName; } mysql_free_result($rst); return $locationarray; } function GetSummaryAbstractID ($sectionID) { $sql = "SELECT SummaryAbstractID FROM tblsections WHERE SectionID = $sectionID"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $row = mysql_fetch_object($rst); $summaryabstractID = $row->SummaryAbstractID; mysql_free_result($rst); return $summaryabstractID; } function GetPresentationArray ($PresentationCode='',$element='',$parent=0) { $dbh = OpenDatabase(); $row = array(); $presentationarray = array(); if ($PresentationCode) { $sql = "SELECT * FROM tblpresentations WHERE PresentationCode = \"$PresentationCode\""; } else { $sql = "SELECT * FROM tblpresentations WHERE PresParent = $parent ORDER BY PresGroup, PresentationOrder"; } $rst = mysql_query($sql, $dbh); if (!$PresentationCode) { for ($i=0; $iPresentationID; $presentationarray[$i]['PresentationCode'] = $row->PresentationCode; $presentationarray[$i]['PresentationName'] = $row->PresentationName; $presentationarray[$i]['PresentationEnabled'] = $row->PresentationEnabled; $presentationarray[$i]['PresentationOrder'] = $row->PresentationOrder; $presentationarray[$i]['ShowSections'] = $row->ShowSections; $presentationarray[$i]['RequirePassword'] = $row->RequirePassword; $presentationarray[$i]['SubmissionInstructions'] = $row->SubmissionInstructions; $presentationarray[$i]['AdminOnly'] = $row->AdminOnly; $presentationarray[$i]['OptionsInstructions'] = $row->OptionsInstructions; $presentationarray[$i]['PresGroup'] = $row->PresGroup; } return $presentationarray; } else { $row = mysql_fetch_object($rst); if ($element == '') { $presentationarray['PresentationID'] = $row->PresentationID; $presentationarray['PresentationCode'] = $row->PresentationCode; $presentationarray['PresentationName'] = $row->PresentationName; $presentationarray['PresentationEnabled'] = $row->PresentationEnabled; $presentationarray['PresentationOrder'] = $row->PresentationOrder; $presentationarray['ShowSections'] = $row->ShowSections; $presentationarray['RequirePasswords'] = $row->RequirePasswords; $presentationarray['SubmissionsInstructions'] = $row->SubmissionsInstructions; $presentationarray['AdminOnly'] = $row->AdminOnly; $presentationarray['OptionsInstructions'] = $row->OptionsInstructions; $presentationarray['PresGroup'] = $row->PresGroup; } else { return $row->$element; } } mysql_free_result($rst); mysql_close($dbh); } function GetSectionsofType($type) { $dbh = OpenDatabase(); $sql = "SELECT tblsections.SectionID, tblsections.SectionName, tblpresentations.PresentationCode FROM tblsections tblsections, tblpresentations tblpresentations, tbllinksectionpresentation tbllinksectionpresentation WHERE tbllinksectionpresentation.SectionID = tblsections.SectionID AND tbllinksectionpresentation.PresentationID = tblpresentations.PresentationID AND tblpresentations.PresentationCode = \"$type\" ORDER BY tblsections.SortOrder"; $sectionarray = array(); $rst = mysql_query($sql, $dbh); for ($i=0; $iSectionID; $sectionarray[$i]['SectionName'] = $row->SectionName; $sectionarray[$i]['PresentationCode'] = $row->PresentationCode; } return $sectionarray; mysql_free_result($rst); mysql_close($dbh); } function IsPsuedoAbstract($abstracttype){ if (($abstracttype != "Custom") && (strcmp($abstracttype,'discussion')!=0)) { $dbh = OpenDatabase(); $sql = "SELECT * FROM tblconfig WHERE ConfigVar = 'SessionEvent' AND ConfigVal = '$abstracttype'"; $sectionarray = array(); $rst = mysql_query($sql, $dbh); if (mysql_num_rows($rst)>0) { return true; } else { return false; } mysql_free_result($rst); mysql_close($dbh); } } function AbstractConfirmBlock() { $confirmblock = ""; if ((isset($_SESSION["botany_submittalType"])) OR (isset($_SESSION["botany_submittalSection"]))){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; if (isset($_SESSION["botany_submittalType"])){ $nodetree = GetPresentationNodeTree($_SESSION["PresentationID"]); $prestype = ""; foreach ($nodetree as $node) { if (strlen($prestype)>0) { $prestype = ":".$prestype; } $prestype = GetPresentationArray($node,'PresentationName').$prestype; } $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["botany_submittalSection"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Your Submission

Presentation Type:

".$prestype."

Section:

".GetSectionNameForID($_SESSION["botany_submittalSection"])."
"; $confirmblock .="
"; } if (isset($_SESSION["authorarray"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $i = 0; foreach ($_SESSION['authorarray'] as $authrow) { $i=$i+1; $presenter = ""; if ($authrow['AuthorID'] == $_SESSION['presenting']) { $presenter = "(Presenter)"; } else { $presenter = ""; } $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Authors

$presenterAuthor #$i:$authrow[LastName], $authrow[GivenName]".GetAddressForID($authrow['AddressID'])."
"; $confirmblock .="
"; } if ((isset($_SESSION["abstractTitle"])) OR (isset($_SESSION["abstractText"]))){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; if (isset($_SESSION["abstractTitle"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["abstractText"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Abstract Details

Title:

".$_SESSION["abstractTitle"]."

Abstract:

".$_SESSION["abstractText"]."
"; $confirmblock .="
"; } if (isset($_SESSION["keywordList"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $kwlist = $_SESSION["keywordList"]; foreach ($kwlist as $keywnum => $keyword) { $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Keywords

Keyword #".($keywnum+1).":

".$keyword."
"; $confirmblock .="
"; } if (isset($_SESSION["weblinks"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; foreach ($_SESSION["weblinks"] as $wlid) { $confirmblock .=""; } $confirmblock .=""; $confirmblock .="

Related Web Links

".$wlid['0']."
(".$wlid['1'].")
"; $confirmblock .="
"; } if ((isset($_SESSION["radStandardAV"])) OR (isset($_SESSION["checkedslide"])) OR (isset($_SESSION["checkedoverhead"])) OR (isset($_SESSION["txtSpecialAV"]))){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; if (isset($_SESSION["radStandardAV"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["checkedslide"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["checkedoverhead"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["txtSpecialAV"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Audio Visual Needs

Standard AV Package:

".($_SESSION["radStandardAV"] == 'yes' ? "Yes" : "No")."

35mm Slide Projector:

".($_SESSION["checkedslide"] == 'on' ? "Yes" : "No")."

Overhead Projector:

".($_SESSION["checkedoverhead"] == 'on' ? "Yes" : "No")."

Special AV Needs:

".$_SESSION["txtSpecialAV"]."
"; $confirmblock .="
"; } if ((isset($_SESSION["txtConflicts"])) OR (isset($_SESSION["radSymposiaLink"])) OR (isset($_SESSION["symposiumid"]))){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; if (isset($_SESSION["txtConflicts"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["radSymposiaLink"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Scheduling Issues

Potential Conflicts:

".$_SESSION["txtConflicts"]."

Linked to Symposia:

".($_SESSION["radSymposiaLink"] == 'yes' ? "Yes" : "No").":"; if ($_SESSION["symposiumid"] > 0 ) { $confirmblock .=GetSectionNameForID($_SESSION["symposiumid"]); } $confirmblock .= "
"; $confirmblock .="
"; } if ((isset($_SESSION["radChairSection"])) OR (isset($_SESSION["radJudge"])) OR (isset($_SESSION["radAward"]))){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; if (isset($_SESSION["radChairSection"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["radJudge"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["radAward"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Conference Roles

Willing to Chair Sessions:

".($_SESSION["radChairSection"] == 'yes' ? "Yes" : "No")."

Willing to Judge Papers:

".($_SESSION["radJudge"] == 'yes' ? "Yes" : "No")."

Consider for Awards:

".($_SESSION["radAward"] == 'yes' ? "Yes" : "No")."
"; $confirmblock .="
"; } if ((isset($_SESSION["AbsAwPosition"])) OR (isset($_SESSION["AbsAwAdvisor"])) OR (isset($_SESSION["AbsAwVisa"])) OR (isset($_SESSION["AbsAwFunds"]))OR (isset($_SESSION["AbsAwEssay"]))OR (isset($_SESSION["AbsAwNationality"]))OR (isset($_SESSION["AbsAwEthnicity"]))OR (isset($_SESSION["AbsAwGender"]))){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; if (isset($_SESSION["AbsAwPosition"])){ $confirmblock .=""; $confirmblock .=""; $posarray = GetConfigVarByID($_SESSION["AbsAwPosition"]); $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["AbsAwAdvisor"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["AbsAwVisa"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["AbsAwFunds"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["AbsAwEssay"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["AbsAwNationality"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["AbsAwEthnicity"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } if (isset($_SESSION["AbsAwGender"])){ $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; $confirmblock .=""; } $confirmblock .="

Financial Awards Request

Position:

$posarray[ConfigVal]

Advisor/Supervisor

$_SESSION[AbsAwAdvisor]

Visa Applied for:

".($_SESSION["AbsAwVisa"] == 'on' ? "Yes" : "No")."

Additional Funds Requested

$_SESSION[AbsAwFunds]

Reasons for Award

$_SESSION[AbsAwEssay]

Nationality

$_SESSION[AbsAwNationality]

Ethnicity

$_SESSION[AbsAwEthnicity]

Gender

$_SESSION[AbsAwGender]
"; $confirmblock .="
"; } $confirmblock .=""; return $confirmblock; } function isuppercase($content) { if (($content !="") AND ($content != null)) { $content = strip_tags($content); $upperstring =""; $upperstring = strtoupper($content); if ($content == $upperstring) { return true; } else { return false; } } } function GetPresentationNodeTree($presid,$nodetree=array()) { if (sizeof($nodetree) == 0) { $nodetree[(sizeof($nodetree)+1)] = GetPresCodeFromPresID($presid); } $sql = "SELECT PresParent from tblpresentations WHERE PresentationID = '$presid'"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetPresentationNodeTree($presid,$nodetree): " . mysql_error()); } if (mysql_num_rows($rst) > 0) { $row = mysql_fetch_object($rst); if ($row->PresParent != 0) { $nodetree[(sizeof($nodetree)+1)] = GetPresCodeFromPresID($row->PresParent); GetPresentationNodeTree($row->PresParent, $nodetree); } } return $nodetree; mysql_free_result($rst); mysql_close($dbh); } function GetPresCodeFromPresID($presid) { $sql = "SELECT PresentationCode from tblpresentations WHERE PresentationID = '$presid'"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (mysql_num_rows($rst) > 0) { $row = mysql_fetch_object($rst); return $row->PresentationCode; } mysql_free_result($rst); mysql_close($dbh); } function GetPresIDFromCode($prescode) { $sql = "SELECT PresentationID from tblpresentations WHERE PresentationCode = '$prescode'"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (mysql_num_rows($rst) > 0) { $row = mysql_fetch_object($rst); return $row->PresentationID; } mysql_free_result($rst); mysql_close($dbh); } function Result2Array ($result) { $i = 0; $array = array(); while ($ary = mysql_fetch_assoc($result)) { $i = $i +1; while (list($key,$val) = each($ary)) { $$key = $val; $array[$i][$key] = $val; } } return $array; } function adminabstract ($aid,$embargo,$absstatus) { if ($embargo == 1){ $embargo = 'checked'; } else { $embargo = ''; } $statuslist = array(); $statuslist = GetConfigVar('AbsStatus'); $result = "
"; $result .= "
"; $result .= "Delete |"; $result .= "Embargo |"; $result .= "Status: ".SelectList($statuslist,"absstatus[$aid]",$absstatus,'Pick One'); $result .= " "; $result .= "
"; $result .= "
"; return $result; } function DeleteAbstractAll($aid) { //$sql = str_replace("#i#", $societyID, $sql); $dbh = OpenDatabase(); $sql = "DELETE FROM tblweblinks WHERE AbstractID = '$aid'"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteAbstractAll($aid, 'WebLinks'): $sql: " . mysql_error()); return ""; } $sql = "DELETE FROM tbllinkauthoraddress WHERE AbstractID = '$aid'"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteAbstractAll($aid, 'AuthorAddress'): $sql: " . mysql_error()); return ""; } $sql = "DELETE FROM tbllinkabstractkeywords WHERE AbstractID = '$aid'"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteAbstractAll($aid, 'Keywords'): $sql: " . mysql_error()); return ""; } $sql = "DELETE FROM tbllinkabstractauthor WHERE AbstractID = '$aid'"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteAbstractAll($aid, 'AbstractAuthor'): $sql: " . mysql_error()); return ""; } $sql = "DELETE FROM blobs WHERE AbstractID = '$aid'"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteAbstractAll($aid, 'Blobs'): $sql: " . mysql_error()); return ""; } $sql = "DELETE FROM tblabstracts WHERE AbstractID = '$aid'"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteAbstractAll($aid, 'Abstracts'): $sql: " . mysql_error()); return ""; } mysql_free_result($rst); mysql_close($dbh); } ?> * @version $Revision: 1.3 $$ */ include_once("../classes/config.php"); //include_once("../classes/db_fcns.php"); function S_GetAuthorsAsString($abstractID) { $result = ""; $temp = array(); $firstID = S_GetFirstAuthorID($abstractID); $sql = "Select DISTINCT tblabstractauthor.AuthorID,tblabstractauthor.Surname,tblabstractauthor.GivenName,"; $sql .= "tblabstractauthor.EmailAddress,tblabstractaddress.AddressData, tblabstractaddress.AddressID From "; $sql .= "tbllinkauthoraddress tbllinkauthoraddress, tblabstractauthor tblabstractauthor,"; $sql .= "tblabstractaddress tblabstractaddress,tbllinkabstractauthor tbllinkabstractauthor "; $sql .= "Where (tbllinkabstractauthor.AuthorID = tblabstractauthor.AuthorID AND "; $sql .= "tblabstractauthor.AuthorID = tbllinkauthoraddress.AuthorID AND "; $sql .= "tbllinkauthoraddress.AddressID = tblabstractaddress.AddressID AND "; $sql .= "tbllinkauthoraddress.AbstractID = #id# AND "; $sql .= "tbllinkabstractauthor.AbstractID=#id#) ORDER BY tbllinkabstractauthor.SortOrder Asc"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("S_GetAuthorsAsString($abstractID): $sql: " . mysql_error()); return ""; } if (0 != mysql_num_rows($rst)) { for ($i=0; $iEmailAddress)) { $tstr .= "EmailAddress . "\">"; } if ($row->AuthorID == $firstID) { $tstr .= ""; } $tstr .= $row->Surname . ", " . $row->GivenName; if ($row->AuthorID == $firstID) { $tstr .= ""; } if (strlen($row->EmailAddress)) { $tstr .= ""; } array_push($temp, $tstr); } $result = join(", ", $temp) . "."; } mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetAuthorsAsUnformattedArray($abstractID) { $result = array(); $sql = "Select tblabstractauthor.*, tbllinkabstractauthor.* From tblabstractauthor tblabstractauthor, tbllinkabstractauthor tbllinkabstractauthor "; $sql .= "Where tbllinkabstractauthor.AuthorID = tblabstractauthor.AuthorID AND "; $sql .= "tbllinkabstractauthor.AbstractID=#id# ORDER BY tbllinkabstractauthor.SortOrder Asc"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("S_GetAuthorsAsUnformattedArray($abstractID): $sql: " . mysql_error()); return ""; } if (0 != mysql_num_rows($rst)) { for ($i=0; $iAuthorID; $result[$i]["Surname"] = $row->Surname; $result[$i]["GivenName"] = $row->GivenName; $result[$i]["EmailAddress"] = $row->EmailAddress; $result[$i]["MappingID"] = $row->MappingID; $result[$i]["SortOrder"] = $row->SortOrder; } } mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetRealFirstAuthorSurname($abstractID) { $result = ""; $temp = array(); $tstr = ""; $sql = "Select DISTINCT tblabstractauthor.AuthorID,tblabstractauthor.Surname,tblabstractauthor.GivenName,"; $sql .= "tblabstractauthor.EmailAddress,tblabstractaddress.AddressData, tblabstractaddress.AddressID, tbllinkabstractauthor.MappingID From "; $sql .= "tbllinkauthoraddress tbllinkauthoraddress, tblabstractauthor tblabstractauthor,"; $sql .= "tblabstractaddress tblabstractaddress,tbllinkabstractauthor tbllinkabstractauthor "; $sql .= "Where (tbllinkabstractauthor.AuthorID = tblabstractauthor.AuthorID AND "; $sql .= "tblabstractauthor.AuthorID = tbllinkauthoraddress.AuthorID AND "; $sql .= "tbllinkauthoraddress.AddressID = tblabstractaddress.AddressID AND "; $sql .= "tbllinkabstractauthor.AbstractID=$abstractID) ORDER BY tbllinkabstractauthor.SortOrder Asc"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("S_GetRealFirstAuthorSurName($abstractID): $sql: " . mysql_error()); return ""; } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $tstr .= $row->Surname; } mysql_free_result($rst); mysql_close($dbh); return $tstr; } function S_GetRealFirstAuthorGivenName($abstractID) { $result = ""; $temp = array(); $tstr = ""; $sql = "Select DISTINCT tblabstractauthor.AuthorID,tblabstractauthor.Surname,tblabstractauthor.GivenName,"; $sql .= "tblabstractauthor.EmailAddress,tblabstractaddress.AddressData, tblabstractaddress.AddressID From "; $sql .= "tbllinkauthoraddress tbllinkauthoraddress, tblabstractauthor tblabstractauthor,"; $sql .= "tblabstractaddress tblabstractaddress,tbllinkabstractauthor tbllinkabstractauthor "; $sql .= "Where (tbllinkabstractauthor.AuthorID = tblabstractauthor.AuthorID AND "; $sql .= "tblabstractauthor.AuthorID = tbllinkauthoraddress.AuthorID AND "; $sql .= "tbllinkauthoraddress.AddressID = tblabstractaddress.AddressID AND "; $sql .= "tbllinkabstractauthor.AbstractID=$abstractID) ORDER BY tbllinkabstractauthor.SortOrder Asc"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("S_GetRealFirstAuthorGivenName($abstractID): $sql: " . mysql_error()); return ""; } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $tstr .= $row->GivenName; } mysql_free_result($rst); mysql_close($dbh); return $tstr; } function S_GetFirstAuthorID($abstractID) { $result = 0; $sql = "SELECT FirstAuthorID FROM tblabstracts WHERE AbstractID=#id#"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractHeader($abstractID): $sql: " . mysql_error()); mysql_close($dbh); return $result; } $row = mysql_fetch_array($rst); $result = $row[0]; mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetAbstractHeader($abstractID) { $result = array(); $sql = "SELECT * FROM tblabstracts WHERE AbstractID=#id#"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractHeader($abstractID): $sql: " . mysql_error()); $result["error"] = mysql_error(); } elseif (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $result["AbstractID"] = $abstractID; $result["AbstractTitle"] = $row->AbstractTitle; $result["Abstract"] = $row->Abstract; $result["DateCreated"] = $row->DateCreated; $result["CreatorID"] = $row->CreatorID; $result["SectionID"] = $row->SectionID; $result["Conflicts"] = $row->Conflicts; $result["SpecialAV"] = $row->SpecialAV; $result["WillingJudge"] = $row->WillingJudge; $result["WillingSecChair"] = $row->WillingSecChair; $result["ConsiderAward"] = $row->ConsiderAward; $result["AbstractType"] = $row->AbstractType; $result["TypeNode"] = $row->TypeNode; $result["FirstAuthorID"] = $row->FirstAuthorID; $result["AbstractNo"] = $row->AbstractNo; $result["AbstractDate"] = s_GetSessionDate($abstractID); $result["AbstractTime"] = $row->AbstractTime; $result["RoomNum"] = s_GetSessionLocation($abstractID); $result["SessionNum"] = s_GetSessionNumber($abstractID); $result["weblinks"] = GetLinksForAbstract($abstractID); $result["SlideNeeded"] = $row->SlideNeeded; $result["OverheadNeeded"] = $row->OverheadNeeded; $result["StandardAV"] = $row->StandardAV; $result["LinkSymposium"] = $row->LinkSymposium; $result["SymposiumLinked"] = $row->SymposiumLinked; $result["embargo"] = $row->embargo; $result["absstatus"] = $row->absstatus; } mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetAbstractAddressList($abstractID,$element=null) { $result = array(); $sql = "Select tbllinkabstractauthor.SortOrder, tblabstractaddress.* From "; $sql .= "tblabstractaddress tblabstractaddress, tbllinkabstractauthor tbllinkabstractauthor, "; $sql .= "tbllinkauthoraddress tbllinkauthoraddress "; $sql .= "Where (tbllinkabstractauthor.AuthorID = tbllinkauthoraddress.AuthorID AND "; $sql .= "tbllinkauthoraddress.AddressID = tblabstractaddress.AddressID AND "; $sql .= "tbllinkabstractauthor.AbstractID = #id# AND tbllinkauthoraddress.AbstractID = #id#) GROUP BY AddressID ORDER BY SortOrder"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractAddressList($abstractID): $sql: " . mysql_error()); $result[0] = mysql_error(); } elseif (0 != mysql_num_rows($rst)) { for ($i=0; $i < mysql_num_rows($rst); $i++) { $row = mysql_fetch_object($rst); $result[$row->SortOrder] = FormatAddress($row,"inline",$element); //$result[$i] = $row->AddressData; } $result2 = array(); $i2 = 0; foreach ($result as $key=>$row2) { $i2 = $i2 + 1; $result2[$i2] = $row2; } } //sort($result); mysql_free_result($rst); mysql_close($dbh); return $result2; } function S_GetAbstractAuthorList($abstractID, $addressList, $firstID) { $result = array(); $sql = "Select DISTINCT tbllinkabstractauthor.*, tblabstractauthor.AuthorID,tblabstractauthor.Surname,tblabstractauthor.GivenName,"; $sql .= "tblabstractauthor.EmailAddress,tblabstractaddress.* From "; $sql .= "tbllinkauthoraddress tbllinkauthoraddress, tblabstractauthor tblabstractauthor,"; $sql .= "tblabstractaddress tblabstractaddress,tbllinkabstractauthor tbllinkabstractauthor "; $sql .= "Where (tbllinkabstractauthor.AuthorID = tblabstractauthor.AuthorID AND "; $sql .= "tblabstractauthor.AuthorID = tbllinkauthoraddress.AuthorID AND "; $sql .= "tbllinkauthoraddress.AbstractID = $abstractID AND "; $sql .= "tbllinkauthoraddress.AddressID = tblabstractaddress.AddressID AND "; $sql .= "tbllinkabstractauthor.AbstractID=#id#) ORDER BY tbllinkabstractauthor.SortOrder Asc"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractAuthorList($abstractID): $sql: " . mysql_error()); return $result; } elseif (0 != mysql_num_rows($rst)) { for ($i=0; $i < mysql_num_rows($rst); $i++) { $row = mysql_fetch_object($rst); $auname = ""; if (strlen($row->EmailAddress)) { $auname .= "EmailAddress . "\">"; } if ($firstID == $row->AuthorID) { $auname .= ""; } $auname .= $row->Surname . ", " . $row->GivenName; if ($firstID == $row->AuthorID) { $auname .= ""; } if (strlen($row->EmailAddress)) { $auname .= ""; } $auname .= " "; $found = false; foreach ($addressList as $idx => $add) { //if ($add == $row->AddressData) if (($add == FormatAddress($row,"inline")) && (!$found)) { $result[$auname] = $idx; $found = true; } } } } mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetAbstractAuthorListText($abstractID, $addressList, $firstID,$element=null) { $result = array(); $sql = "Select DISTINCT tbllinkabstractauthor.*, tblabstractauthor.AuthorID,tblabstractauthor.Surname,tblabstractauthor.GivenName,"; $sql .= "tblabstractauthor.EmailAddress,tblabstractaddress.* From "; $sql .= "tbllinkauthoraddress tbllinkauthoraddress, tblabstractauthor tblabstractauthor,"; $sql .= "tblabstractaddress tblabstractaddress,tbllinkabstractauthor tbllinkabstractauthor "; $sql .= "Where (tbllinkabstractauthor.AuthorID = tblabstractauthor.AuthorID AND "; $sql .= "tblabstractauthor.AuthorID = tbllinkauthoraddress.AuthorID AND "; $sql .= "tbllinkauthoraddress.AbstractID = $abstractID AND "; $sql .= "tbllinkauthoraddress.AddressID = tblabstractaddress.AddressID AND "; $sql .= "tbllinkabstractauthor.AbstractID=#id#) ORDER BY tbllinkabstractauthor.SortOrder Asc"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractAuthorListText($abstractID): $sql: " . mysql_error()); return $result; } elseif (0 != mysql_num_rows($rst)) { for ($i=0; $i < mysql_num_rows($rst); $i++) { $row = mysql_fetch_object($rst); $auname = ""; $auname .= strtoupper($row->Surname) . ", " . strtoupper($row->GivenName); if ($firstID == $row->AuthorID & mysql_num_rows($rst)>1) { $auname .= "*"; } $auname .= " "; foreach ($addressList as $idx => $add) { if (html_entity_decode($add) == FormatAddress($row,"inline",$element)) { $result[$auname] = $idx; } } } } mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetAbstractKeywords($abstractID, $type="array") { $result = array(); $result2 = array(); $sql = "select * from tblkeywords k, tbllinkabstractkeywords lk where "; $sql .= "(lk.KeywordID = k.KeywordID And lk.abstractid=#id#)"; $sql = str_replace("#id#", $abstractID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAbstractKeywords($abstractID): $sql: " . mysql_error()); return $result; } elseif (0 != mysql_num_rows($rst)) { for ($i=0; $i < mysql_num_rows($rst); $i++) { $row = mysql_fetch_array($rst); $result[$i]['KeywordID'] = $row[0]; $result[$i]['Keyword'] = $row[1]; $result[$i]['KeywordSort'] = strtolower(strip_tags($row[1])); $result[$i]['MappingID'] = $row[3]; } $result = array_natsort($result,'0','1'); if ($type=="list") { foreach ($result as $keyid=>$keyword) { $result2[$keyid] = $keyword['Keyword']; } $result = $result2; } } mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetSectionName($SectionID) { if ($SectionID == '') { $SectionID = 0; } $result = 0; $sql = "SELECT SectionName FROM tblsections WHERE SectionID=#id#"; $sql = str_replace("#id#", $SectionID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetSectionName($SectionID): $sql: " . mysql_error()); mysql_close($dbh); return $result; } $row = mysql_fetch_array($rst); $result = $row[0]; if ($result == '') { $result = "Conference Wide"; } mysql_free_result($rst); mysql_close($dbh); return $result; } function S_GetSectionSortOrder($SectionID) { $result = 0; $sql = "SELECT SortOrder FROM tblsections WHERE SectionID='$SectionID'"; //$sql = str_replace("#id#", $SectionID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetSectionSortOrder($SectionID): $sql: " . mysql_error()); mysql_close($dbh); return $result; } $row = mysql_fetch_array($rst); $result = $row[0]; mysql_free_result($rst); mysql_close($dbh); return $result; } function StripKeywordTags($result) { $resultarray = array(); for ($i=0; $iKeywordID; $resultarray[$i]['Keyword'] = $row->Keyword; $resultarray[$i]['KeywordSort'] = ltrim(strtolower(strip_tags($row->Keyword)),": \"\("); $resultarray[$i]['cntKeyword'] = $row->cntKeyword; } $resultarray = array_natsort($resultarray,'KeywordID','KeywordSort'); return $resultarray; } function StripTitleTags($result) { $resultarray = array(); for ($i=0; $iAbstractID; $resultarray[$i]['AbstractTitle'] = $row->AbstractTitle; $resultarray[$i]['AbstractTitleSort'] = ltrim(strtolower(strip_tags($row->AbstractTitle)),": \"\("); $resultarray[$i]['SectionName'] = S_GetSectionName($row->SectionID); $resultarray[$i]['absstatus'] = $row->absstatus; } $resultarray = array_natsort($resultarray,'AbstractID','AbstractTitleSort'); return $resultarray; } /** * @return Returns the array sorted as required * @param $aryData Array containing data to sort * @param $strIndex Name of column to use as an index * @param $strSortBy Column to sort the array by * @param $strSortType String containing either asc or desc [default to asc] * @desc Naturally sorts an array using by the column $strSortBy */ function array_natsort($aryData, $strIndex, $strSortBy, $strSortType=false) { // if the parameters are invalid if (!is_array($aryData) || !$strIndex || !$strSortBy) // return the array return $aryData; // create our temporary arrays $arySort = $aryResult = array(); // loop through the array foreach ($aryData as $aryRow) // set up the value in the array $arySort[$aryRow[$strIndex]] = $aryRow[$strSortBy]; // apply the natural sort natsort($arySort); // if the sort type is descending if ($strSortType=="desc") // reverse the array arsort($arySort); // loop through the sorted and original data foreach ($arySort as $arySortKey => $arySorted) foreach ($aryData as $aryOriginal) // if the key matches if ($aryOriginal[$strIndex]==$arySortKey) // add it to the output array array_push($aryResult, $aryOriginal); // return the return return $aryResult; } function GetAuthorAddress($auid,$aid,$type="inline",$element=null) { if ($auid == '') { return "Unknown"; } $result = ''; if (isset($aid)) { $sql = "SELECT * FROM tblabstractaddress tblabstractaddress, tbllinkauthoraddress tbllinkauthoraddress WHERE tbllinkauthoraddress.AuthorID=$auid AND tbllinkauthoraddress.AbstractID=$aid AND tblabstractaddress.AddressID=tbllinkauthoraddress.AddressID"; } else { $sql = "SELECT * FROM tblabstractaddress tblabstractaddress, tbllinkauthoraddress tbllinkauthoraddress WHERE tbllinkauthoraddress.AuthorID=$auid AND tblabstractaddress.AddressID=tbllinkauthoraddress.AddressID"; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetAuthorAddress($auid,$aid)" . mysql_error()); mysql_close($dbh); return $result; } $row = mysql_fetch_object($rst); mysql_free_result($rst); mysql_close($dbh); return FormatAddress($row,$type,$element); } function Authorized($aid,$section=0,$authid=0,$loginid=0) { $authoredit = GetConfigVar('AuthorEdit'); //echo "id: ", $_SESSION["botany_userid"]; if (!isset($_SESSION["botany_userid"])) { return false; } //echo "admin: ", $_SESSION["admin"]; if ($_SESSION["admin"]==1) { return true; } else if ($authoredit = '0') { return false; } if ($section != 0) { $sql = "SELECT * FROM tblsections WHERE SectionManagerEmail=\"".$_SESSION["botany_email"]."\" AND SectionID=$section"; } else if ($authid != 0) { $sql = "SELECT * FROM tblabstractauthor WHERE AuthorID = \"$authid\" and EmailAddress = \"".$_SESSION["botany_email"]."\""; } else if ($loginid != 0) { $sql = "SELECT * FROM tbllogins WHERE UserID = \"$loginid\" and EmailAddress = \"".$_SESSION["botany_email"]."\""; } else if ($authoredit = '0') { return false; } else { $sql = "SELECT * FROM tbllogins tbllogins, tblabstracts tblabstracts WHERE tbllogins.EmailAddress=\"".$_SESSION["botany_email"]."\" AND tblabstracts.AbstractID=$aid AND tblabstracts.CreatorID=tbllogins.UserID"; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); //echo "rows: ", mysql_num_rows($rst); if (mysql_num_rows($rst)==0) { //user_error("Authorized($aid)" . mysql_error()); mysql_close($dbh); return false; } else { return true; } mysql_free_result($rst); mysql_close($dbh); } function SessionsManaged($email) { $manages = array(); if (isset($email)) { $sql = "SELECT SectionID, SectionName FROM tblsections WHERE SectionManagerEmail='$email'"; } else { $sql = "SELECT SectionID, SectionName FROM tblsections"; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); for ($i=0; $iSectionID; $manages[$i]['SectionName'] = $row->SectionName; } mysql_free_result($rst); mysql_close($dbh); return $manages; } function GetSessionsForSection($section) { $sessions = array(); $presiders = array(); $sql = "SELECT * FROM tblsessions WHERE SectionID=$section"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); for ($i=0; $iSessionID; $sessions[$i]['SessionName'] = $row->SessionName; $sessions[$i]['SectionID'] = $row->SectionID; $sessions[$i]['SessionType'] = $row->SessionType; $sessions[$i]['SessionDate'] = $row->SessionDate; $sessions[$i]['StartTime'] = $row->StartTime; $sessions[$i]['EndTime'] = $row->EndTime; $presiders = explode("|",$row->Presider); $c = 0; foreach ($presiders as $presider){ //$presiderno = "presider".$c; $sessions[$i]['Presider'.$c] = $presiders[$c]; $c++; } //$sessions[$i]['Presider'] = $row->Presider; $sessions[$i]['AVNeeds'] = $row->AVNeeds; $sessions[$i]['Food'] = $row->Food; $sessions[$i]['SessionNo'] = $row->SessionNo; $sessions[$i]['Location'] = $row->Location; $sessions[$i]['NeedOverhead'] = $row->NeedOverhead; $sessions[$i]['NeedProjector'] = $row->NeedProjector; } mysql_free_result($rst); mysql_close($dbh); return $sessions; } function s_GetSessionNumber ($abstractID){ $dbh = OpenDatabase(); $sql = "SELECT tblabstracts.SessionOrder, tblabstracts.SessionNum, tblsessions.SessionNo FROM tblsessions tblsessions, tblabstracts tblabstracts WHERE tblabstracts.SessionNum = tblsessions.SessionID AND tblabstracts.AbstractID=$abstractID"; $rst = mysql_query($sql, $dbh); $row = mysql_fetch_object($rst); mysql_free_result($rst); mysql_close($dbh); if (($row->SessionNo != '') && ($row->SessionOrder != '0')) { $session = "".$row->SessionNo."-".$row->SessionOrder.""; } else { $session = ''; } return $session; } function s_GetSessionDate ($abstractID){ $dbh = OpenDatabase(); $sql = "SELECT tblsessions.SessionDate FROM tblsessions tblsessions, tblabstracts tblabstracts WHERE tblabstracts.SessionNum = tblsessions.SessionID AND tblabstracts.AbstractID=$abstractID"; $rst = mysql_query($sql, $dbh); $row = mysql_fetch_object($rst); mysql_free_result($rst); mysql_close($dbh); return $row->SessionDate; } function s_GetSessionLocation ($abstractID,$element=''){ $dbh = OpenDatabase(); $row = array(); $sql = "SELECT tblsessions.Location, tbllocation.LocationName, tblbuilding.BuildingName FROM tbllocation tbllocation, tblbuilding tblbuilding, tblsessions tblsessions, tblabstracts tblabstracts WHERE tblabstracts.SessionNum = tblsessions.SessionID AND tblbuilding.BuildingID = tbllocation.BuildingID AND tblsessions.Location = tbllocation.LocationID AND tblabstracts.AbstractID=$abstractID"; $rst = mysql_query($sql, $dbh); $row = mysql_fetch_array($rst); mysql_free_result($rst); mysql_close($dbh); //$location = GetConfigVarByID($row->Location); if ($element == '') { //return $location['ConfigVal']; return $row['LocationName']."/".$row['BuildingName']; } else { //return $location[$element]; return $row[$element]; } } function s_GetLocationArray ($LocationID,$element='') { $dbh = OpenDatabase(); $row = array(); $sql = "SELECT tbllocation.*, tblbuilding.* FROM tbllocation tbllocation, tblbuilding tblbuilding WHERE tbllocation.BuildingID = tblbuilding.BuildingID AND LocationID=$LocationID"; $rst = mysql_query($sql, $dbh); $row = mysql_fetch_array($rst); mysql_free_result($rst); mysql_close($dbh); //$location = GetConfigVarByID($row->Location); if ($element == '') { //return $location['ConfigVal']; return $row['LocationName']."/".$row['BuildingName']; } else { //return $location[$element]; return $row[$element]; } } function s_GetBuildings() { $dbh = OpenDatabase(); $result = array(); $sql = "SELECT * FROM tblbuilding ORDER BY BuildingName"; $rst = mysql_query($sql, $dbh); $result = Result2Array($rst); mysql_free_result($rst); mysql_close($dbh); return $result; } function s_GetLocationsForBuilding($buildingid) { $dbh = OpenDatabase(); $result = array(); $sql = "SELECT * FROM tbllocation WHERE BuildingID = '$buildingid' ORDER BY LocationName"; $rst = mysql_query($sql, $dbh); $result = Result2Array($rst); mysql_free_result($rst); mysql_close($dbh); return $result; } function GetSocieties($societyid='') { if ($societyid == '') { $sql = "SELECT * FROM tblsocieties"; } else { $sql = "SELECT * FROM tblsocieties WHERE SocietyID='$societyid'"; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $results = array(); $results = Result2Array($rst); mysql_free_result($rst); mysql_close($dbh); return $results; } function GetSectionsForSociety($society) { $sql = "SELECT tblsections.*, tbllinksocietysection.* FROM tblsections tblsections, tbllinksocietysection tbllinksocietysection WHERE tbllinksocietysection.SocietyID = '$society' AND tblsections.SectionID = tbllinksocietysection.SectionID"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $results = array(); $results = Result2Array($rst); mysql_free_result($rst); mysql_close($dbh); return $results; } function GetSocietiesForSection($section) { $sql = "SELECT tblsocieties.*, tbllinksocietysection.* FROM tblsocieties tblsocieties, tbllinksocietysection tbllinksocietysection WHERE tbllinksocietysection.SectionID = '$section' AND tblsocieties.SocietyID = tbllinksocietysection.SocietyID"; $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $results = array(); $results = Result2Array($rst); mysql_free_result($rst); mysql_close($dbh); return $results; } function array_key_exists_recursive($needle,$haystack) { foreach($haystack as $key=>$val) { if(is_array($val)) { if(array_key_exists_recursive($needle,$val)) return 1; } elseif($val == $needle) return 1; } return 0; } function GetSocietyNameForID($societyID) { $result = ""; $sql = "SELECT SocietyName FROM tblsocieties WHERE SocietyID=#i#"; $sql = str_replace("#i#", $societyID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetSocietyNameForID($societyID): $sql: " . mysql_error()); return ""; } if (0 == mysql_num_rows($rst)) { $result = ""; } else { $row = mysql_fetch_array($rst); $result = $row[0]; } mysql_free_result($rst); mysql_close($dbh); return $result; } function MaybeAddToItinerary($userid, $abstractid) { $itineraryid = GetItineraryID($userid, $abstractid); if (0 == $itineraryid) { $dbh = OpenDatabase(); $sql = "INSERT INTO tblitinerary (UserID, AbstractID) VALUES ('$userid', '$abstractid')"; $rst = mysql_query($sql, $dbh); $sql = "SELECT LAST_INSERT_ID() AS ItineraryID"; $rst = mysql_query($sql, $dbh); $row = mysql_fetch_object($rst); $result = $row->ItineraryID; mysql_free_result($rst); mysql_close($dbh); } else { $result = 0; } return $result; } function DeleteFromItinerary($userid, $abstractid) { $sql = "DELETE FROM tblitinerary WHERE UserID = '$userid' AND AbstractID = '$abstractid'"; //$sql = str_replace("#i#", $societyID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("DeleteFromItinerary($userid, $abstractid): $sql: " . mysql_error()); return ""; } mysql_close($dbh); } function GetItineraryID($userid, $abstractid) { $sql = "SELECT * FROM tblitinerary WHERE UserID = '$userid' AND AbstractID = '$abstractid'"; //$sql = str_replace("#i#", $societyID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetItineraryID($userid, $abstractid): $sql: " . mysql_error()); return ""; } if (0 == mysql_num_rows($rst)) { $result = 0; } else { $row = mysql_fetch_object($rst); $result = $row->ItineraryID; } mysql_free_result($rst); mysql_close($dbh); return $result; } function ItineraryCheckbox($userid, $abstractid) { $itinerary = GetConfigVar('ItineraryLive'); if (($itinerary['ConfigVal']=='1') || ($_SESSION["admin"] == "1")) { $itineraryID = GetItineraryID($userid, $abstractid); if ($_SESSION['botany_email'] != '') { if ($itineraryID > 0 ) { $checkbox = "
On your schedule"; } else { $checkbox = "
Add to your schedule"; } } else { $checkbox = "
Log in to add this item to your schedule"; } } else { $checkbox = ""; } return $checkbox; } function GetTemplate($templateid='') { if ($templateid == '') { $sql = "SELECT * FROM tblemails"; } else { $sql = "SELECT * FROM tblemails WHERE EmailID = \"$templateid\""; } $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); $template = array(); $template = Result2Array($rst); mysql_free_result($rst); return $template; } ?> * @version $Revision: 1.7 $ */ // include_once("../classes/config.php"); //should already be included //include_once("../classes/db_fcns.php"); /** * Get the redirection URL for a specific page tag. * * This is mainly used by login_redir.php to resolve a tag like * next=abstract into a URI. * * @param string $page the page tag to resolve. * @return string the URI for the given tag, or an empty string if the * specified tag was not found. */ function GetRedirectorPage($page) { $result = ""; $sql = "select * from tblredirector where pageKey='#key#'"; $sql = str_replace("#key#", $page, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetRedirectorPage($page): " . mysql_error()); } if (0 != mysql_num_Rows($rst)) { $row = mysql_fetch_object($rst); $result = $row->pageTarget; mysql_free_result($rst); mysql_close($dbh); } return $result; } /** * Validate a username/password pair and set the login session variables. * * @param string $userEmail the e-mail address to validate * @param string $password the password supplied by the user * @return boolean 0 on failure, 1 on success. Also sets session variables * botany_userid, botany_fullname and botany_email. */ function ValidateUserCredentials($userEmail, $password) { $result = 0; if ((strlen($userEmail) == 0) || (strlen($password) ==0)) { return 0; } $sql = "SELECT * FROM tbllogins WHERE EmailAddress='#email#' And Password='#pwd#'"; $sql = str_replace("#email#", $userEmail, $sql); $sql = str_replace("#pwd#", $password, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("ValidateUserCredentials($userEmail,$password): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { $result = 0; } else { $row = mysql_fetch_object($rst); $_SESSION['admin'] = $row->Admin; $result = 1; } mysql_free_result($rst); mysql_close($dbh); return $result; } function GetCredentials($userEmail) { $result = array(); $sql = "SELECT * FROM tbllogins WHERE EmailAddress='#email#'"; $sql = str_replace("#email#", $userEmail, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetCredentials($userEmail): " . mysql_error()); } $row = mysql_fetch_object($rst); array_push($result, $row->UserID); array_push($result, $row->FullName); array_push($result, $row->EmailAddress); array_push($result, $row->Password); array_push($result, $row->InstitutionName); array_push($result, $row->DateAdded); array_push($result, $row->DateLastLogin); mysql_free_result($rst); mysql_close($dbh); return $result; } function GetCredentialsByID($userID) { $result = array(); $sql = "SELECT * FROM tbllogins WHERE UserID='#userid#'"; $sql = str_replace("#userid#", $userID, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("GetCredentials($userEmail): " . mysql_error()); } $row = mysql_fetch_object($rst); array_push($result, $row->UserID); array_push($result, $row->FullName); array_push($result, $row->EmailAddress); array_push($result, $row->Password); array_push($result, $row->InstitutionName); array_push($result, $row->DateAdded); array_push($result, $row->DateLastLogin); mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Updates the DateLastLogin field when a user logs into the site. * * @param string $email the user's e-mail address */ function TouchLoginTime($email) { $sql = "UPDATE tbllogins SET DateLastLogin=NOW() WHERE " . "EmailAddress='#email#'"; $sql = str_replace("#email#", $email, $sql); $dbh = OpenDatabase(); mysql_query($sql, $dbh); mysql_close($dbh); } /** * Checks to see if a given email address is already registered. * * @param string $email the email address supplied by the user. * @return 1 if the specified email is already registered, 0 otherwise. */ function CheckForEmail($email) { $sql = "SELECT * FROM tbllogins WHERE EmailAddress='#email#'"; $sql = str_replace("#email#", $email, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("CheckForEmail($email): " . mysql_error()); } if (0 == mysql_num_rows($rst)) { mysql_free_result($rst); mysql_close($dbh); return 0; } else { mysql_free_result($rst); mysql_close($dbh); return 1; } } /** * Creates a new user account in the database. * * @param string $email the user's email address * @param string $password the user's password * @param string $fullname the user's full name * @return long the ID of the newly inserted user, or -1 on error. */ function CreateUser($email, $password, $fullname) { $result = -1; if (1 == CheckForEmail($email)) { return $result; } $sql = "INSERT INTO tbllogins(EmailAddress, Password, FullName, DateAdded)" . "VALUES('#email#', '#password#', '#fullname#', NOW())"; $sql = str_replace("#email#", $email, $sql); $sql = str_replace("#password#", $password, $sql); $sql = str_replace("#fullname#", $fullname, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("CreateUser($email,$password,$fullname): " . mysql_error()); } mysql_free_result($rst); $sql = "SELECT LAST_INSERT_ID() AS UserID FROM tbllogins"; $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("CreateUser(\$rst2): " . mysql_error()); } if (0 != mysql_num_rows($rst)) { $row = mysql_fetch_object($rst); $result = $row->UserID; } mysql_free_result($rst); mysql_close($dbh); return $result; } /** * Sets the organization fields for a user. * @param long $userid the user's numeric id in the database * @param string $orgname the user's organization name * @param string $orgcity the user's city * @param string $orgstate the user's state * @param string $orgpc the user's zip/postal code * @param string $orgcountry the user's country */ function SetOrgForUser($userid, $orgname) { $sql = "UPDATE tbllogins SET InstitutionName='#orgname#' " . "WHERE UserID=#uid#"; $sql = str_replace("#uid#", $userid, $sql); $sql = str_replace("#orgname#", $orgname, $sql); $dbh = OpenDatabase(); $rst = mysql_query($sql, $dbh); if (!$rst) { user_error("SetOrgForUser($userid): " . mysql_error()); } mysql_free_result($rst); mysql_close($dbh); } function SendRegEmail($useremail) { $sitename = GetConfigVar('SiteName'); $admincontact = GetConfigVar('AdminContact'); $params = GetCredentials($useremail); $mailcontent = "Thank you for registering at the ".$sitename." Abstract Submission Site.\n This email is a confirmation of your login information. Please keep this information handy in the event you need to submit additional abstracts or change your existing information.\n\n **********************************************************************\n\n Email Address (login): ".$params[2]."\n\n Password: ".$params[3]."\n\n Full Name: ".$params[1]."\n\n Institution: ".$params[4]."\n\n Registration Date: ".$params[5].""; mail($params[2],"".$sitename." Registration Confirmation",$mailcontent,"From:".$admincontact."\nbcc:".$admincontact.",robbrandt@yahoo.com"); } ?>