예제 #1
0
/**
* updateRecTitles : updates the constructed record titles following modification of data values (details)
*
* @param mixed $data
*/
function updateRecTitles($recIDs)
{
    if (!is_array($recIDs)) {
        if (is_numeric($recIDs)) {
            $recIDs = array($recIDs);
        } else {
            return false;
        }
    }
    $res = mysql_query("select rec_ID, rec_Title, rec_RecTypeID from Records" . " where ! rec_FlagTemporary and rec_ID in (" . join(",", $recIDs) . ") order by rand()");
    $recs = array();
    while ($row = mysql_fetch_assoc($res)) {
        $recs[$row['rec_ID']] = $row;
    }
    $masks = mysql__select_assoc('defRecTypes', 'rty_ID', 'rty_TitleMask', '1');
    foreach ($recIDs as $recID) {
        $rtyID = $recs[$recID]['rec_RecTypeID'];
        $new_title = fill_title_mask($masks[$rtyID], $recID, $rtyID);
        mysql_query("update Records set rec_Title = '" . addslashes($new_title) . "'where rec_ID = {$recID}");
    }
}
/**
 * determine the inverse of a relationship term
 * @global    array llokup of term inverses by trmID to inverseTrmID
 * @param     int $relTermID reltionship trmID
 * @return    int inverse trmID
 * @todo      modify to retrun -1 in case not inverse defined
 */
function reltype_inverse($relTermID)
{
    //saw Enum change - find inverse as an id instead of a string
    global $inverses;
    if (!$relTermID) {
        return;
    }
    if (!$inverses) {
        $inverses = mysql__select_assoc("defTerms A left join defTerms B on B.trm_ID=A.trm_InverseTermID", "A.trm_ID", "B.trm_ID", "A.trm_Label is not null and B.trm_Label is not null");
    }
    $inverse = @$inverses[$relTermID];
    if (!$inverse) {
        $inverse = array_search($relTermID, $inverses);
    }
    //do an inverse search and return key.
    if (!$inverse) {
        $inverse = 'Inverse of ' . $relTermID;
    }
    //FIXME: This should be -1 indicating no inverse found.
    return $inverse;
}
/**
* util to find like records
*
* @author      Tom Murtagh
* @author      Stephen White   <*****@*****.**>
* @copyright   (C) 2005-2013 University of Sydney
* @link        http://Sydney.edu.au/Heurist
* @version     3.1.0
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @package     Heurist academic knowledge management system
* @subpackage  Records/Util
*/
function findFuzzyMatches($fields, $rec_types, $rec_id = NULL, $fuzziness = NULL)
{
    if (!$fuzziness) {
        $fuzziness = 0.5;
    }
    // Get some data about the matching data for the given record type
    $types = mysql__select_assoc('defRecStructure left join defDetailTypes on rst_DetailTypeID=dty_ID', 'dty_ID', 'dty_Type', 'rst_RecTypeID=' . $rec_types[0] . ' and rst_RecordMatchOrder or rst_DetailTypeID=' . DT_NAME);
    $fuzzyFields = array();
    $strictFields = array();
    foreach ($fields as $key => $vals) {
        if (!preg_match('/^t:(\\d+)/', $key, $matches)) {
            continue;
        }
        $rdt_id = $matches[1];
        if (!@$types[$rdt_id]) {
            continue;
        }
        if (!$vals) {
            continue;
        }
        switch ($types[$rdt_id]) {
            case "blocktext":
            case "freetext":
            case "urlinclude":
                foreach ($vals as $val) {
                    if (trim($val)) {
                        array_push($fuzzyFields, array($rdt_id, trim($val)));
                    }
                }
                break;
            case "integer":
            case "float":
            case "date":
            case "year":
            case "file":
            case "enum":
            case "boolean":
            case "urlinclude":
            case "relationtype":
            case "resource":
                foreach ($vals as $val) {
                    if (trim($val)) {
                        array_push($strictFields, array($rdt_id, trim($val)));
                    }
                }
                break;
            case "separator":
                // this should never happen since separators are not saved as details, skip if it does
            // this should never happen since separators are not saved as details, skip if it does
            case "relmarker":
                // saw seems like relmarkers are external to the record and should not be part of matching
            // saw seems like relmarkers are external to the record and should not be part of matching
            case "fieldsetmarker":
            case "calculated":
            default:
                continue;
        }
    }
    if (count($fuzzyFields) == 0 && count($strictFields) == 0) {
        return;
    }
    $groups = get_group_ids();
    if (!is_array($groups)) {
        $groups = array();
    }
    if (is_logged_in()) {
        array_push($groups, get_user_id());
        array_push($groups, 0);
    }
    $groupPred = count($groups) > 0 ? "rec_OwnerUGrpID in (" . join(",", $groups) . ") or " : "";
    $tables = "records";
    $predicates = "rec_RecTypeID={$rec_types['0']} and ! rec_FlagTemporary and ({$groupPred} not rec_NonOwnerVisibility='hidden')" . ($rec_id ? " and rec_ID != {$rec_id}" : "");
    $N = 0;
    foreach ($fuzzyFields as $field) {
        list($rdt_id, $val) = $field;
        $threshold = intval((strlen($val) + 1) * $fuzziness);
        ++$N;
        $tables .= ", recDetails bd{$N}";
        $predicates .= " and (bd{$N}.dtl_RecID=rec_ID and bd{$N}.dtl_DetailTypeID={$rdt_id} and limited_levenshtein(bd{$N}.dtl_Value, '" . addslashes($val) . "', {$threshold}) is not null)";
    }
    foreach ($strictFields as $field) {
        list($rdt_id, $val) = $field;
        ++$N;
        $tables .= ", recDetails bd{$N}";
        $predicates .= " and (bd{$N}.dtl_RecID=rec_ID and bd{$N}.dtl_DetailTypeID={$rdt_id} and bd{$N}.dtl_Value = '" . addslashes($val) . "')";
    }
    $matches = array();
    $res = mysql_query("select rec_ID as id, rec_Title as title, rec_Hash as hhash from {$tables} where {$predicates} order by rec_Title limit 100");
    /*****DEBUG****/
    //error_log("approx-matching: select rec_ID as id, rec_Title as title, rec_Hash as hhash from $tables where $predicates order by rec_Title limit 100");
    while ($bib = mysql_fetch_assoc($res)) {
        array_push($matches, $bib);
    }
    return $matches;
}
예제 #4
0
function doTagInsertion($bkm_ID)
{
    global $usrID;
    //translate bmkID to record IT
    $res = mysql_query("select bkm_recID from usrBookmarks where bkm_ID={$bkm_ID}");
    $rec_id = mysql_fetch_row($res);
    $rec_id = $rec_id[0] ? $rec_id[0] : null;
    if (!$rec_id) {
        return "";
    }
    $tags = mysql__select_array("usrRecTagLinks, usrTags", "tag_Text", "rtl_RecID={$rec_id} and tag_ID=rtl_TagID and tag_UGrpID={$usrID} order by rtl_Order, rtl_ID");
    $tagString = join(",", $tags);
    // if the tags to insert is the same as the existing tags (in order) Nothing to do
    if (mb_strtolower(trim($_POST["tagString"]), 'UTF-8') == mb_strtolower(trim($tagString), 'UTF-8')) {
        return;
    }
    // create array of tags to be linked
    $tags = array_filter(array_map("trim", explode(",", str_replace("\\", "/", $_POST["tagString"]))));
    // replace backslashes with forwardslashes
    //create a map of this user's personal tags to tagIDs
    $kwd_map = mysql__select_assoc("usrTags", "trim(lower(tag_Text))", "tag_ID", "tag_UGrpID={$usrID} and tag_Text in (\"" . join("\",\"", array_map("mysql_real_escape_string", $tags)) . "\")");
    $tag_ids = array();
    foreach ($tags as $tag) {
        $tag = preg_replace('/\\s+/', ' ', trim($tag));
        $tag = mb_strtolower($tag, 'UTF-8');
        if (@$kwd_map[$tag]) {
            // tag exist get it's id
            $tag_id = $kwd_map[$tag];
        } else {
            // no existing tag so add it and get it's id
            $query = "insert into usrTags (tag_Text, tag_UGrpID) values (\"" . mysql_real_escape_string($tag) . "\", {$usrID})";
            mysql_query($query);
            $tag_id = mysql_insert_id();
        }
        array_push($tag_ids, $tag_id);
    }
    // Delete all personal tags for this bookmark's record
    mysql_query("delete usrRecTagLinks from usrRecTagLinks, usrTags where rtl_RecID = {$rec_id} and tag_ID=rtl_TagID and tag_UGrpID = {$usrID}");
    if (count($tag_ids) > 0) {
        $query = "";
        for ($i = 0; $i < count($tag_ids); ++$i) {
            if ($query) {
                $query .= ", ";
            }
            $query .= "({$rec_id}, " . ($i + 1) . ", " . $tag_ids[$i] . ")";
        }
        $query = "insert into usrRecTagLinks (rtl_RecID, rtl_Order, rtl_TagID) values " . $query;
        mysql_query($query);
    }
    // return new tag string
    $tags = mysql__select_array("usrRecTagLinks, usrTags", "tag_Text", "rtl_RecID = {$rec_id} and tag_ID=rtl_TagID and tag_UGrpID={$usrID} order by rtl_Order, rtl_ID");
    return join(",", $tags);
}
/**
 * creates an xForms select lookup list using the rectitles and heurist record ids
 *
 * given a list of recType IDs this function create a select list of Record Titles (alphabetical order)
 * with HEURIST record ids as the lookup value.
 * @param        array [$rtIDs] array of record Type identifiers for which a resource pointer is constrained to.
 * @return       string formatted as a XForm select lookup item list
 * @todo         need to accept a filter for reducing the recordset, currently you get all records of every type in the input list
 */
function createRecordLookup($rtIDs)
{
    $emptyLookup = "<item>\n" . "<label>\"no records found for rectypes '{$rtIDs}'\"</label>\n" . "<value>0</value>\n" . "</item>\n";
    $recs = mysql__select_assoc("Records", "rec_ID", "rec_Title", "rec_RecTypeID in ({$rtIDs}) order by rec_Title");
    if (!count($recs)) {
        return $emptyLookup;
    }
    $ret = "";
    foreach ($recs as $recID => $recTitle) {
        if ($recTitle && $recTitle != "") {
            $ret = $ret . "<item>\n" . "<label>\"{$recTitle}\"</label>\n" . "<value>{$recID}</value>\n" . "</item>\n";
        }
    }
    return $ret;
}
 */
require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php';
require_once dirname(__FILE__) . '/../../common/php/dbMySqlWrappers.php';
if (isForAdminOnly("to rebuild titles")) {
    return;
}
set_time_limit(0);
mysql_connection_overwrite(DATABASE);
require_once dirname(__FILE__) . '/../../common/php/utilsTitleMask.php';
//?db='.HEURIST_DBNAME);
$res = mysql_query('select rec_ID, rec_Title, rec_RecTypeID from Records where !rec_FlagTemporary order by rand()');
$recs = array();
while ($row = mysql_fetch_assoc($res)) {
    $recs[$row['rec_ID']] = $row;
}
$masks = mysql__select_assoc('defRecTypes', 'rty_ID', 'rty_TitleMask', '1');
$updates = array();
$blank_count = 0;
$repair_count = 0;
$processed_count = 0;
ob_start();
?>

<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <script type="text/javascript">
            function update_counts(processed, blank, repair, changed) {
                if(changed==null || changed==undefined){
                    changed = 0;
                }
예제 #7
0
 /**
  * Replace detail value for given set of records and detail type and values
  */
 public function detailsReplace()
 {
     if (!(@$this->data['sVal'] && @$this->data['rVal'])) {
         $this->system->addError(HEURIST_INVALID_REQUEST, "Insufficent data passed");
         return false;
     }
     if (!$this->_validateParamsAndCounts()) {
         return false;
     } else {
         if (count(@$this->recIDs) == 0) {
             return $this->result_data;
         }
     }
     $dtyID = $this->data['dtyID'];
     $dtyName = @$this->data['dtyName'] ? "'" . $this->data['dtyName'] . "'" : "id:" . $this->data['dtyID'];
     $mysqli = $this->system->get_mysqli();
     $basetype = mysql__select_value($mysqli, 'select dty_Type from defDetailTypes where dty_ID = ' . $dtyID);
     switch ($basetype) {
         case "freetext":
         case "blocktext":
             $searchClause = "dtl_Value like \"%" . $mysqli->real_escape_string($this->data['sVal']) . "%\"";
             $partialReplace = true;
             break;
         case "enum":
         case "relationtype":
         case "float":
         case "integer":
         case "resource":
         case "date":
             $searchClause = "dtl_Value = \"" . $mysqli->real_escape_string($this->data['sVal']) . "\"";
             $partialReplace = false;
             break;
         default:
             $this->system->addError(HEURIST_INVALID_REQUEST, "{$basetype} fields are not supported by value-replace service");
             return false;
     }
     $undefinedFieldsRecIDs = array();
     //value not found
     $processedRecIDs = array();
     //success
     $sqlErrors = array();
     $now = date('Y-m-d H:i:s');
     $dtl = array('dtl_Modified' => $now);
     $rec_update = array('rec_ID' => 'to-be-filled', 'rec_Modified' => $now);
     $baseTag = "~replace field {$dtyName} {$now}";
     foreach ($this->recIDs as $recID) {
         //get matching detail value for record if there is one
         $valuesToBeReplaced = mysql__select_assoc($mysqli, "recDetails", "dtl_ID", "dtl_Value", "dtl_RecID = {$recID} and dtl_DetailTypeID = {$dtyID} and {$searchClause}");
         if ($mysqli->error != null || $mysqli->error != '') {
             $sqlErrors[$recID] = $mysqli->error;
             continue;
         } else {
             if ($valuesToBeReplaced == null || count($valuesToBeReplaced) == 0) {
                 //not found
                 array_push($undefinedFieldsRecIDs, $recID);
                 continue;
             }
         }
         //update the details
         $recDetailWasUpdated = false;
         foreach ($valuesToBeReplaced as $dtlID => $dtlVal) {
             if ($partialReplace) {
                 // need to replace sVal with rVal
                 $newVal = preg_replace("/" . $this->data['sVal'] . "/", $this->data['rVal'], $dtlVal);
             } else {
                 $newVal = $this->data['rVal'];
             }
             $newVal = $mysqli->real_escape_string($newVal);
             $dtl['dtl_ID'] = $dtlID;
             $dtl['dtl_Value'] = $newVal;
             $ret = mysql__insertupdate($mysqli, 'recDetails', 'dtl', $dtl);
             if (!is_numeric($ret)) {
                 $sqlErrors[$recID] = $ret;
                 continue;
             }
             $recDetailWasUpdated = true;
         }
         if ($recDetailWasUpdated) {
             //only put in processed if a detail was processed,
             // obscure case when record has multiple details we record in error array also
             array_push($processedRecIDs, $recID);
             //update record edit date
             $rec_update['rec_ID'] = $recID;
             $ret = mysql__insertupdate($mysqli, 'Records', 'rec', $rec_update);
             if (!is_numeric($ret)) {
                 $sqlErrors[$recID] = 'Cannot update modify date. ' . $ret;
             }
         }
     }
     //for recors
     //assign special system tags
     $this->_assignTagsAndReport('processed', $processedRecIDs, $baseTag);
     $this->_assignTagsAndReport('undefined', $undefinedFieldsRecIDs, $baseTag);
     $this->_assignTagsAndReport('errors', $sqlErrors, $baseTag);
     return $this->result_data;
 }
예제 #8
0
        </div>
<?php 
print "<form id='startform' name='startform' action='exportFAIMS.php' method='get'>";
print "<input id='rt_selected' name='rt' type='hidden'>";
print "<input name='step' value='1' type='hidden'>";
print "<input name='db' value='" . HEURIST_DBNAME . "' type='hidden'>";
print "<div><div class='lbl_form'>Module name</div><input name='projname' value='" . ($projname ? $projname : HEURIST_DBNAME) . "' size='25'></div>";
// List of record types for export
print "<div id='selectedRectypes' style='width:100%;color:black;'></div>";
$rtStructs = getAllRectypeStructures(false);
$int_rt_dt_type = $rtStructs['typedefs']['dtFieldNamesToIndex']["dty_Type"];
$rt_geoenabled = array();
$rt_invalid_masks = array();
if ($rt_toexport && count($rt_toexport) > 0) {
    //validate title masks
    $rtIDs = mysql__select_assoc("defRecTypes", "rty_ID", "rty_Name", " rty_ID in (" . implode(",", $rt_toexport) . ") order by rty_ID");
    foreach ($rtIDs as $rtID => $rtName) {
        $mask = mysql__select_array("defRecTypes", "rty_TitleMask", "rty_ID={$rtID}");
        $mask = $mask[0];
        $res = titlemask_make($mask, $rtID, 2, null, _ERR_REP_MSG);
        //get human readable
        if (is_array($res)) {
            //invalid mask
            array_push($rt_invalid_masks, $rtName);
        }
        $details = $rtStructs['typedefs'][$rtID]['dtFields'];
        if (!$details) {
            print "<p style='color:red'>No details defined for record type #" . $rtName . ". Edit record type structure.</p>";
            $invalid = true;
        } else {
            //check if rectype is geoenabled
예제 #9
0
function _title_mask__get_rec_types($rt)
{
    static $rct;
    if (!$rct) {
        $cond = $rt ? 'rty_ID=' . $rt : '1';
        $rct = mysql__select_assoc('defRecTypes', 'rty_ID', 'rty_Name', $cond);
        /*****DEBUG****/
        //error_log("rt ".print_r($rct,true));
    }
    return $rct;
}
예제 #10
0
			<span>contains</span>
            </div>
            <div id="ft-enum-container" style="display:none;width: 202px;"></div>
            <div id="ft-input-container" style="display:inline-block; width: 202px;"><input id="field" name="field" onChange="update(this);" onKeyPress="return keypress(event);" style="width: 200px;"></div>
			<span><button type="button" style="visibility:visible; float: right;" onClick="add_to_search('field');" class="button" title="Add to Search">Add</button></span>
		</div>

<!--
		<div class="advanced-search-row">
			<label for="notes">Notes:</label>
			<input id=notes name=notes onChange="update(this);" onKeyPress="return keypress(event);">
		</div>
-->

		<?php 
$groups = mysql__select_assoc(USERS_DATABASE . "." . USER_GROUPS_TABLE . " left join " . USERS_DATABASE . "." . GROUPS_TABLE . " on " . USER_GROUPS_GROUP_ID_FIELD . "=" . GROUPS_ID_FIELD, GROUPS_ID_FIELD, GROUPS_NAME_FIELD, USER_GROUPS_USER_ID_FIELD . "=" . get_user_id() . " and " . GROUPS_TYPE_FIELD . "='workgroup' order by " . GROUPS_NAME_FIELD);
if ($groups && count($groups) > 0) {
    ?>
		<div class="advanced-search-row">
				<label for="user">Owned&nbsp;by:</label>
				<select name="owner" id="owner" onChange="update(this);" style="width:200px;">
					<option value="" selected="selected">(any owner or ownergroup)</option>
					<option value="&quot;<?php 
    echo get_user_username();
    ?>
&quot;"><?php 
    echo get_user_name();
    ?>
</option>
					<?php 
    foreach ($groups as $id => $name) {
예제 #11
0
 function inputOK($postVal, $dtyID, $rtyID)
 {
     if (!@$labelToID) {
         $labelToID = mysql__select_assoc("defTerms", "trm_Label", "trm_ID", "1");
     }
     // if value is term label
     if (!is_numeric($postVal) && array_key_exists($postVal, $labelToID)) {
         $postVal = $labelToID[$postVal];
     }
     return $postVal ? isValidID($postVal, $dtyID, $rtyID) : false;
 }
function handle_notification()
{
    function getInt($strInt)
    {
        return intval(preg_replace("/[\"']/", "", $strInt));
    }
    $bib_ids = array_map("getInt", explode(',', $_REQUEST['bib_ids']));
    if (!count($bib_ids)) {
        return '<div style="color: red; font-weight: bold; padding: 5px;">(you must select at least one bookmark)</div>';
    }
    $bibIDList = join(',', $bib_ids);
    $notification_link = HEURIST_BASE_URL . '?db=' . HEURIST_DBNAME . '&w=all&q=ids:' . $bibIDList;
    $bib_titles = mysql__select_assoc('Records', 'rec_ID', 'rec_Title', 'rec_ID in (' . $bibIDList . ')');
    $title_list = "Id      Title\n" . "------  ---------\n";
    foreach ($bib_titles as $rec_id => $rec_title) {
        $title_list .= str_pad("{$rec_id}", 8) . $rec_title . "\n";
    }
    $msg = '';
    if ($_REQUEST['notify_message'] && $_REQUEST['notify_message'] != '(enter message here)') {
        $msg = '"' . $_REQUEST['notify_message'] . '"' . "\n\n";
    }
    $res = mysql_query('select ' . USERS_EMAIL_FIELD . ' from ' . USERS_DATABASE . '.' . USERS_TABLE . ' where ' . USERS_ID_FIELD . ' = ' . get_user_id());
    $row = mysql_fetch_row($res);
    if ($row) {
        $user_email = $row[0];
    }
    mysql_connection_overwrite(DATABASE);
    $email_subject = 'Email from ' . get_user_name();
    if (count($bib_ids) == 1) {
        $email_subject .= ' (one reference)';
    } else {
        $email_subject .= ' (' . count($bib_ids) . ' references)';
    }
    $email_headers = 'From: ' . get_user_name() . ' <no-reply@' . HEURIST_SERVER_NAME . '>';
    if ($user_email) {
        $email_headers .= "\r\nCc: " . get_user_name() . ' <' . $user_email . '>';
        $email_headers .= "\r\nReply-To: " . get_user_name() . ' <' . $user_email . '>';
    }
    $email_text = get_user_name() . " would like to draw some records to your attention, with the following note:\n\n" . $msg . "Access them and add them (if desired) to your Heurist records at: \n\n" . $notification_link . "\n\n" . "To add records, either click on the unfilled star left of the title\n" . "or select the ones you wish to add and then Selected > Bookmark\n\n" . $title_list;
    if ($_REQUEST['notify_group']) {
        $email_headers = preg_replace('/Cc:[^\\r\\n]*\\r\\n/', '', $email_headers);
        $res = mysql_query('select ' . GROUPS_NAME_FIELD . ' from ' . USERS_DATABASE . '.' . GROUPS_TBALE . ' where ' . GROUPS_ID_FIELD . '=' . intval($_REQUEST['notify_group']));
        $row = mysql_fetch_assoc($res);
        $grpname = $row[GROUPS_NAME_FIELD];
        $res = mysql_query('select ' . USERS_EMAIL_FIELD . '
				from ' . USERS_DATABASE . '.' . USERS_TABLE . ' left join ' . USERS_DATABASE . '.' . USER_GROUPS_TABLE . ' on ' . USER_GROUPS_USER_ID_FIELD . '=' . USERS_ID_FIELD . '
				where ' . USER_GROUPS_GROUP_ID_FIELD . '=' . intval($_REQUEST['notify_group']));
        $count = mysql_num_rows($res);
        while ($row = mysql_fetch_assoc($res)) {
            $email_headers .= "\r\nBcc: " . $row[USERS_EMAIL_FIELD];
        }
        $rv = sendEMail(get_user_name() . ' <' . $user_email . '>', $email_subject, $email_text, $email_headers, true);
        return $rv == "ok" ? 'Notification email sent to group ' . $grpname . ' (' . $count . ' members)' : $rv;
    } else {
        if ($_REQUEST['notify_person']) {
            $res = mysql_query('select ' . USERS_EMAIL_FIELD . ', concat(' . USERS_FIRSTNAME_FIELD . '," ",' . USERS_LASTNAME_FIELD . ') as fullname from ' . USERS_DATABASE . '.' . USERS_TABLE . ' where ' . USERS_ID_FIELD . '=' . $_REQUEST['notify_person']);
            $psn = mysql_fetch_assoc($res);
            $rv = sendEMail($psn[USERS_EMAIL_FIELD], $email_subject, $email_text, $email_headers, true);
            return $rv == "ok" ? 'Notification email sent to ' . addslashes($psn['fullname']) : $rv;
        } else {
            if ($_REQUEST['notify_email']) {
                $rv = sendEMail($_REQUEST['notify_email'], $email_subject, $email_text, $email_headers, true);
                return $rv == "ok" ? 'Notification email sent to ' . addslashes($_REQUEST['notify_email']) : $rv;
            } else {
                return '<div style="color: red; font-weight: bold; padding: 5px;">(you must select a group, person, or enter an email address)</div>';
            }
        }
    }
}
예제 #13
0
    }
    /*
    $bkmk_insert_count = 0;
    if (bookmark_insert(@$_REQUEST['link'][$linkno], @$_REQUEST['title'][$linkno], $kwd, $rec_id)){
    	++$bkmk_insert_count;
    }
    if (@$bkmk_insert_count == 1){
    	$success = 'Added one bookmark';
    }else if (@$bkmk_insert_count > 1){
    	$success = 'Added ' . $bkmk_insert_count . ' bookmarks';
    }
    */
}
// filter the URLs (get rid of the ones already bookmarked)
if (@$urls) {
    $bkmk_urls = mysql__select_assoc('usrBookmarks left join Records on rec_ID = bkm_recID', 'rec_URL', '1', 'bkm_UGrpID=' . get_user_id());
    $ignore = array();
    foreach ($urls as $url => $title) {
        if (@$bkmk_urls[$url]) {
            $ignore[$url] = 1;
        }
    }
}
?>
<html>
<head>
	<title>Import Hyperlinks</title>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="<?php 
echo HEURIST_BASE_URL;
/**
* saw Enum change - find inverse as an id instead of a string
*
* @param mixed $relTermID
* @return mixed
*/
function reltype_inverse($relTermID)
{
    global $inverses;
    if (!$relTermID) {
        return;
    }
    if (!$inverses) {
        //		$inverses = mysql__select_assoc("defTerms A left join defTerms B on B.trm_ID=A.trm_InverseTermID", "A.trm_Label", "B.trm_Label", "A.rdl_rdt_id=200 and A.trm_Label is not null");
        $inverses = mysql__select_assoc("defTerms A left join defTerms B on B.trm_ID=A.trm_InverseTermID", "A.trm_ID", "B.trm_ID", "A.trm_Label is not null and B.trm_Label is not null");
    }
    $inverse = @$inverses[$relTermID];
    if (!$inverse) {
        $inverse = array_search($relTermID, $inverses);
    }
    if (!$inverse) {
        $inverse = 'Inverse of ' . $relTermID;
    }
    return $inverse;
}
    return;
}
if (@$_REQUEST['recTypeIDs']) {
    $recTypeIds = $_REQUEST['recTypeIDs'];
} else {
    print "You must specify a record type (?recTypeIDs=55) or a set of record types (?recTypeIDs=55,174,175) to use this page.";
}
require_once dirname(__FILE__) . '/../../common/php/utilsTitleMask.php';
mysql_connection_overwrite(DATABASE);
$res = mysql_query("select rec_ID, rec_Title, rec_RecTypeID from Records where ! rec_FlagTemporary and rec_RecTypeID in ({$recTypeIds}) order by rand()");
$recs = array();
while ($row = mysql_fetch_assoc($res)) {
    $recs[$row['rec_ID']] = $row;
}
$rt_names = mysql__select_assoc('defRecTypes', 'rty_ID', 'rty_Name', 'rty_ID in (' . $recTypeIds . ')');
$masks = mysql__select_assoc('defRecTypes', 'rty_ID', 'rty_TitleMask', 'rty_ID in (' . $recTypeIds . ')');
$updates = array();
$blank_count = 0;
$repair_count = 0;
$processed_count = 0;
?>

<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>Recalculation of composite record titles</title>
        <link rel="stylesheet" type="text/css" href="../../common/css/global.css">
    </head>

    <body class="popup">
        <p>
예제 #16
0
function insert_tags(&$entry, $tag_map = array())
{
    // automatic tag insertion for the bookmark associated with this entry
    // easy one first: see if there is a workgroup tag to be added, and that we have access to that workgroup
    $wgKwd = $entry->getWorkgroupTag();
    if ($wgKwd) {
        $res = mysql_query("select * from usrTags, " . USERS_DATABASE . ".sysUsrGrpLinks where tag_UGrpID=ugl_GroupID and ugl_UserID=" . get_user_id() . " and tag_ID=" . $wgKwd);
        if (mysql_num_rows($res) != 1) {
            $wgKwd = 0;
        }
        // saw CHECK SPEC: can there be more than 1 , this code ingnores if 0 or more than 1
    }
    if (!$entry->getTags()) {
        return;
    }
    $tag_select_clause = '';
    foreach ($entry->getTags() as $tag) {
        $tag = str_replace('\\', '/', $tag);
        if (array_key_exists(strtolower(trim($tag)), $tag_map)) {
            $tag = $tag_map[strtolower(trim($tag))];
        }
        if ($tag_select_clause) {
            $tag_select_clause .= ',';
        }
        $tag_select_clause .= '"' . mysql_real_escape_string($tag) . '"';
    }
    // create user specific tagText to tagID lookup
    $res = mysql_query('select tag_ID, lower(trim(tag_Text)) from usrTags where tag_Text in (' . $tag_select_clause . ')' . ' and tag_UGrpID= ' . get_user_id());
    $tags = array();
    while ($row = mysql_fetch_row($res)) {
        $tags[$row[1]] = $row[0];
    }
    //now let's add in all the wgTags for this user's workgroups
    $all_wgTags = mysql__select_assoc('usrTags, ' . USERS_DATABASE . '.sysUsrGrpLinks, ' . USERS_DATABASE . '.sysUGrps grp', 'lower(concat(grp.ugr_Name, "\\\\", tag_Text))', 'tag_ID', 'tag_UGrpID=ugl_GroupID and ugl_GroupID=grp.ugr_ID and ugl_UserID=' . get_user_id());
    //saw CHECK SPEC: is it correct to import wgTags with a slash
    foreach ($all_wgTags as $tag => $id) {
        $tags[$tag] = $id;
    }
    $entry_tag_ids = array();
    foreach ($entry->getTags() as $tag) {
        if (preg_match('/^(.*?)\\s*\\\\\\s*(.*)$/', $tag, $matches)) {
            $tag = $matches[1] . '\\' . $matches[2];
            $wg_tag = true;
        } else {
            $wg_tag = false;
        }
        $tag_id = @$tags[strtolower(trim($tag))];
        if ($tag_id) {
            array_push($entry_tag_ids, $tag_id);
        } else {
            if (!$wg_tag) {
                // do not insert new workgroup tags
                mysql_query('insert into usrTags (tag_UGrpID, tag_Text) ' . ' values (' . get_user_id() . ', "' . mysql_real_escape_string($tag) . '")');
                $tag_id = mysql_insert_id();
                array_push($entry_tag_ids, $tag_id);
                $tags[strtolower(trim($tag))] = $tag_id;
            }
        }
    }
    $kwi_insert_stmt = '';
    if ($wgKwd) {
        $kwi_insert_stmt .= '(' . $entry->getBiblioID() . ', ' . $wgKwd . ', 1)';
    }
    foreach ($entry_tag_ids as $tag_id) {
        if ($kwi_insert_stmt) {
            $kwi_insert_stmt .= ',';
        }
        $kwi_insert_stmt .= '(' . $entry->getBiblioID() . ', ' . $tag_id . ', 1)';
        //FIXME getBookmarkID and getBiblioID return empty string
    }
    mysql_query('insert ignore into usrRecTagLinks (rtl_RecID, rtl_TagID, rtl_AddedByImport) values ' . $kwi_insert_stmt);
}
예제 #17
0
function doWgTagInsertion($recordID, $wgTagIDs)
{
    if ($wgTagIDs != "" && !preg_match("/^\\d+(?:,\\d+)*\$/", $wgTagIDs)) {
        return;
    }
    if ($wgTagIDs) {
        mysql_query("delete usrRecTagLinks from usrRecTagLinks, usrTags, " . USERS_DATABASE . ".sysUsrGrpLinks where rtl_RecID={$recordID} and rtl_TagID=tag_ID and tag_UGrpID=ugl_GroupID and ugl_UserID=" . get_user_id() . " and tag_ID not in ({$wgTagIDs})");
        if (mysql_error()) {
            jsonError("database error - " . mysql_error());
        }
    } else {
        mysql_query("delete usrRecTagLinks from usrRecTagLinks, usrTags, " . USERS_DATABASE . ".sysUsrGrpLinks where rtl_RecID={$recordID} and rtl_TagID=tag_ID and tag_UGrpID=ugl_GroupID and ugl_UserID=" . get_user_id());
        if (mysql_error()) {
            jsonError("database error - " . mysql_error());
        }
        return;
    }
    $existingKeywordIDs = mysql__select_assoc("usrRecTagLinks, usrTags, " . USERS_DATABASE . ".sysUsrGrpLinks", "rtl_TagID", "1", "rtl_RecID={$recordID} and rtl_TagID=tag_ID and tag_UGrpID=ugl_GroupID and ugl_UserID=" . get_user_id());
    $newKeywordIDs = array();
    foreach (explode(",", $wgTagIDs) as $kwdID) {
        if (!@$existingKeywordIDs[$kwdID]) {
            array_push($newKeywordIDs, $kwdID);
        }
    }
    if ($newKeywordIDs) {
        mysql_query("insert into usrRecTagLinks (rtl_TagID, rtl_RecID) select tag_ID, {$recordID} from usrTags, " . USERS_DATABASE . ".sysUsrGrpLinks where tag_UGrpID=ugl_GroupID and ugl_UserID=" . get_user_id() . " and tag_ID in (" . join(",", $newKeywordIDs) . ")");
        if (mysql_error()) {
            jsonError("database error - " . mysql_error());
        }
    }
}
예제 #18
0
$isbnDT = defined('DT_ISBN') ? DT_ISBN : 0;
$issnDT = defined('DT_ISSN') ? DT_ISSN : 0;
$titleDT = defined('DT_NAME') ? DT_NAME : 0;
$relTypDT = defined('DT_RELATION_TYPE') ? DT_RELATION_TYPE : 0;
$relSrcDT = defined('DT_PRIMARY_RESOURCE') ? DT_PRIMARY_RESOURCE : 0;
$relTrgDT = defined('DT_TARGET_RESOURCE') ? DT_TARGET_RESOURCE : 0;
/* arrive with a new (un-bookmarked) URL to process */
if (!@$_REQUEST['_submit'] && @$_REQUEST['bkmrk_bkmk_url']) {
    if (!@$rec_id && !@$force_new) {
        /* look up the records table, see if the requested URL is already in the database; if not, add it */
        $res = mysql_query('select * from Records where rec_URL = "' . mysql_real_escape_string($url) . '" ' . 'and (rec_OwnerUGrpID in (0' . (get_user_id() ? ',' . get_user_id() : '') . ')' . ' or not rec_NonOwnerVisibility="hidden")');
        if ($row = mysql_fetch_assoc($res)) {
            // found record
            $rec_id = intval($row['rec_ID']);
            $fav = $_REQUEST["f"];
            $bd = mysql__select_assoc('recDetails', 'concat(dtl_DetailTypeID, ".", dtl_Value)', '1', 'dtl_RecID=' . $rec_id . ' and ((dtl_DetailTypeID = ' . $doiDT . ' and dtl_Value in ("' . join('","', array_map("mysql_real_escape_string", $dois)) . '"))' . ' or  (dtl_DetailTypeID = ' . $webIconDT . ' and dtl_Value = "' . mysql_real_escape_string($fav) . '"))' . ' or  (dtl_DetailTypeID = ' . $issnDT . ' and dtl_Value in ("' . join('","', array_map("mysql_real_escape_string", $issns)) . '"))' . ' or  (dtl_DetailTypeID = ' . $isbnDT . ' and dtl_Value in ("' . join('","', array_map("mysql_real_escape_string", $isbns)) . '")))');
            $inserts = array();
            foreach ($dois as $doi) {
                if (!$bd["{$doiDT}.{$doi}"]) {
                    array_push($inserts, "({$rec_id}, {$doiDT}, '" . mysql_real_escape_string($doi) . "')");
                }
            }
            if ($fav && !$bd["{$webIconDT}.{$fav}"]) {
                array_push($inserts, "({$rec_id}, {$webIconDT}, '" . mysql_real_escape_string($fav) . "')");
            }
            foreach ($isbns as $isbn) {
                if (!$bd["{$isbnDT}.{$isbn}"]) {
                    array_push($inserts, "({$rec_id}, {$isbnDT}, '" . mysql_real_escape_string($isbn) . "')");
                }
            }
            foreach ($issns as $issn) {
예제 #19
0
                <input type="button" value="Close window" onClick="closewin()">
        </div -->
        <div style="margin-bottom:30px">
<?php 
//get list of files
$dim = 120;
//always show icons  ($mode!=1) ?16 :64;
$lib_dir = HEURIST_FILESTORE_DIR . 'term-images/';
$files = array();
foreach ($ids as $id) {
    $filename = $lib_dir . $id . '.png';
    if (file_exists($filename)) {
        array_push($files, $id);
    }
}
if (count($files) > 0) {
    $term_labels = mysql__select_assoc('defTerms', 'trm_ID', 'trm_Label', 'trm_ID in (' . implode(',', $files) . ')');
    foreach ($files as $id) {
        print '<div class="itemlist" style="">';
        print '<a href="#" onclick="onImageSelect(' . $id . ')">';
        // height="'.$dim.'" max-height:'.$dim.';
        print '<img class="itemimage" style="background-image:url(' . HEURIST_BASE_URL . 'hserver/dbaccess/rt_icon.php?db=' . HEURIST_DBNAME . '&ent=term&id=' . $id . ')" ' . 'src="' . HEURIST_BASE_URL . 'common/images/200.gif"/></a>' . '<br><label>' . $term_labels[$id] . '</label></div>';
        //to avoid issues with access   print '<img height="'.$dim.'" src="'.HEURIST_FILESTORE_URL.'term-images/'.$id.'.png"/></a></div>';
    }
} else {
    print 'No terms images defined<script>setTimeout("closewin()", 2000);</script>';
}
?>
          </div>
    </body>
</html>
		</div>
		<div id="page-inner">

			These checks look for ill formed Title Masks for Record Types defined in the <b><?php 
echo HEURIST_DBNAME;
?>
</b> Heurist database.<br/><br/>
			If the Title mask is invalid please edit the Record Type directly.<br/>
		<?php 
if ($check != 2) {
    echo "If the Canonical Title mask is invalid please run 'Synchronise Canocnial Title Mask' command below\n";
} else {
    echo "Canonical Title mask will synchronise to Title Mask and carries the same validity as the Title Mask\n";
}
echo "<br/><hr>\n";
$rtIDs = mysql__select_assoc("defRecTypes", "rty_ID", "rty_Name", "1 order by rty_ID");
if (!$rectypeID) {
    foreach ($rtIDs as $rtID => $rtName) {
        checkRectypeMask($rtID, $rtName, null, null, null, $check);
    }
} else {
    checkRectypeMask($rectypeID, $rtIDs[$rectypeID], $mask, $coMask, $recID, $check);
}
function checkRectypeMask($rtID, $rtName, $mask, $coMask, $recID, $check)
{
    if (!@$mask && @$rtID) {
        $mask = mysql__select_array("defRecTypes", "rty_TitleMask", "rty_ID={$rtID}");
        $mask = $mask[0];
    }
    if (!@$coMask && @$rtID) {
        $coMask = mysql__select_array("defRecTypes", "rty_CanonicalTitleMask", "rty_ID={$rtID}");
예제 #21
0
while ($row = mysql_fetch_assoc($res)) {
    $DTN[$row['dty_ID']] = $row['dty_Name'];
    $DTT[$row['dty_ID']] = $row['dty_Type'];
}
$INV = mysql__select_assoc('defTerms', 'trm_ID', 'trm_InverseTermID', '1');
// lookup detail type enum values
$query = 'SELECT trm_ID, trm_Label, trm_ParentTermID, trm_OntID FROM defTerms';
$res = mysql_query($query);
while ($row = mysql_fetch_assoc($res)) {
    $TL[$row['trm_ID']] = $row;
    $TLV[$row['trm_Label']] = $row;
}
/// group names
mysql_connection_select(USERS_DATABASE) or die(mysql_error());
$WGN = mysql__select_assoc('sysUGrps grp', 'grp.ugr_ID', 'grp.ugr_Name', "ugr_Type ='workgroup'");
$UGN = mysql__select_assoc('sysUGrps grp', 'grp.ugr_ID', 'grp.ugr_Name', "ugr_Type ='user'");
mysql_connection_select(DATABASE) or die(mysql_error());
$GEO_TYPES = array('r' => 'bounds', 'c' => 'circle', 'pl' => 'polygon', 'l' => 'path', 'p' => 'point');
// set parameter defaults
$MAX_DEPTH = @$_REQUEST['depth'] ? intval($_REQUEST['depth']) : 0;
// default to only one level
$REVERSE = @$_REQUEST['rev'] === 'no' ? false : true;
//default to including reverse pointers
$WOOT = @$_REQUEST['woot'] ? intval($_REQUEST['woot']) : 0;
//default to not output text content
$OUTPUT_STUBS = @$_REQUEST['stub'] === '1' ? true : false;
//default to not output stubs
$INCLUDE_FILE_CONTENT = @$_REQUEST['fc'] && $_REQUEST['fc'] == 0 ? false : true;
// default to expand xml file content
$SUPRESS_LOOPBACKS = @$_REQUEST['slb'] && $_REQUEST['slb'] == 0 ? false : true;
// default to supress loopbacks
예제 #22
0
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="../../common/css/global.css">
        <link rel="stylesheet" type="text/css" href="../../common/css/edit.css">
        <link rel="stylesheet" type="text/css" href="../../common/css/admin.css">
    </head>

    <body class="popup">
        <div class="banner"><h2>Modify group / admin status for session</h2></div>
        <div id="page-inner">
            <p>This page is designed for testing purposes. It allows you to exit a group, or relinquish administrator status for a group,
                for the rest of your session, in order to test the behaviour of a database as viewed by another class of user.
                Changes will not be saved to the database. Log out and log back in to restore your normal permissions.</p>

            <table>
            <?php 
mysql_connection_select(USERS_DATABASE);
$grp_ids = array_keys($_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["user_access"]);
$grp_names = mysql__select_assoc(GROUPS_TABLE, GROUPS_ID_FIELD, GROUPS_NAME_FIELD, GROUPS_ID_FIELD . " in (" . join(",", $grp_ids) . ")");
foreach ($grp_ids as $grp_id) {
    print "<tr><td>" . $grp_names[$grp_id] . "</td><td>";
    if ($_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["user_access"][$grp_id] == "admin") {
        print "<a href=?a={$grp_id}>-admin</a>";
    }
    print "</td><td><a href=?g={$grp_id}>exit</td></tr>";
}
?>
        </div>
    </body>
</html>

예제 #23
0
function user_getAllWorkgroups($mysqli)
{
    $result = mysql__select_assoc($mysqli, 'sysUGrps', 'ugr_ID', 'ugr_Name', '(ugr_Type != "user") OR (ugr_ID=2)');
    if ($result == null) {
        $result = array();
    }
    return $result;
}
예제 #24
0
                $user_hyperlinks_import .= $row_count . ' new hyperlinks added.';
            } else {
                $user_hyperlinks_import .= 'No new hyperlinks added.';
            }
        }
        $user_hyperlinks_import .= '</span>&nbsp;';
    }
    $user_hyperlinks_import .= '
  Import ignored hyperlinks from user:
  <select name="import_hyperlinks_user" onchange="form.submit();">
   <option value="">(select a user)</option>
';
    if (defined('HEURIST_USER_GROUP_ID')) {
        $usernames = mysql__select_assoc(USERS_DATABASE . '.sysUGrps usr left join ' . USERS_DATABASE . '.sysUsrGrpLinks on ugl_UserID=usr.ugr_ID', 'usr.ugr_ID', 'usr.ugr_Name', 'ugl_GroupID=' . HEURIST_USER_GROUP_ID . ' and !usr.ugr_IsModelUser order by usr.ugr_Name');
    } else {
        $usernames = mysql__select_assoc(USERS_DATABASE . '.sysUGrps usr', 'usr.ugr_ID', 'usr.ugr_Name', '!usr.ugr_IsModelUser  order by usr.ugr_Name');
    }
    foreach ($usernames as $id => $name) {
        $user_hyperlinks_import .= '   <option value="' . $id . '">' . escChars($name) . '</option>';
    }
    $user_hyperlinks_import .= '</select></p>';
    END;
} else {
    $user_hyperlinks_import = '';
}
mysql_connection_select(DATABASE);
/* Specify the template file containing the web page to be processed and displayed */
$template = file_get_contents('configureProfile.html');
$template = str_replace('{database}', HEURIST_DBNAME, $template);
if (!array_key_exists('body_only', $_REQUEST)) {
    /* Replaces the word {PageHeader} in the web page with the concatenation of the files specified */
예제 #25
0
function showRecordRollback($record, $changes)
{
    print '<div class="record">';
    print '<div class="header">';
    print '<div class="detail-type">';
    print $record["rec_ID"] . ": " . $record["rec_Title"];
    print '</div>';
    print '<div class="current-val">Current values</div>';
    print '<div class="new-val">Will be changed to</div>';
    print '<div class="clearall"></div>';
    print '</div>';
    $reqs = getRectypeStructureFields($record["rec_RecTypeID"]);
    $detail_names = mysql__select_assoc("defDetailTypes", "dty_ID", "dty_Name", 1);
    foreach ($reqs as $dt => $req) {
        if (array_key_exists($dt, $record["details"])) {
            $values = $record["details"][$dt];
            showDetails($dt . ': ' . $req["rst_DisplayName"], $values, $changes);
        }
    }
    foreach ($record["details"] as $dt => $values) {
        if (!array_key_exists($dt, $reqs)) {
            showDetails($dt . ': ' . $detail_names[$dt], $values, $changes);
        }
    }
    foreach ($changes["inserts"] as $insert) {
        if (array_key_exists($insert["ard_DetailTypeID"], $reqs)) {
            $name = $reqs[$insert["ard_DetailTypeID"]]["rst_DisplayName"];
        } else {
            $name = $detail_names[$insert["ard_DetailTypeID"]];
        }
        showDetail($insert["ard_DetailTypeID"] . ': ' . $name, "&nbsp;", '<div class="insert">' . getDetailUpdateString($insert) . '</div>');
    }
    print '</div>';
}
예제 #26
0
    function Biblio($rec_id)
    {
        $this->geometry = array();
        $this->minX = null;
        $this->minY = null;
        $this->maxX = null;
        $this->maxY = null;
        if ($rec_id) {
            $res = mysql_query('select rec_ID, rec_Title, rec_URL, rec_RecTypeID from Records where rec_ID=' . $rec_id);
            $row = mysql_fetch_assoc($res);
            if (!$row) {
                return false;
            }
            $this->rec_id = $row['rec_ID'];
            $this->rec_title = htmlentities($row['rec_Title']);
            $this->rec_URL = htmlentities($row['rec_URL']);
            $this->rec_RecTypeID = $row['rec_RecTypeID'];
            $details = mysql__select_assoc('recDetails', 'dtl_DetailTypeID', 'dtl_Value', 'dtl_RecID=' . $rec_id);
            if (DT_START_DATE && array_key_exists(DT_START_DATE, $details)) {
                $this->start = $details[DT_START_DATE];
            }
            if (DT_END_DATE && array_key_exists(DT_END_DATE, $details)) {
                $this->end = $details[DT_END_DATE];
            }
            $thumb_url = null;
            // 223  Thumbnail
            // 222  Logo image
            // 224  Images
            $res = mysql_query("select recUploadedFiles.*\n\t\t\t\t\t\t\t\t  from recDetails\n\t\t\t\t\t\t\t left join recUploadedFiles on ulf_ID = dtl_UploadedFileID\n\t\t\t\t\t\t\t\t where dtl_RecID = {$rec_id}\n\t\t\t\t\t\t\t\t   and dtl_DetailTypeID in(" . (defined('DT_THUMBNAIL') ? DT_THUMBNAIL : "0") . "," . (defined('DT_LOGO_IMAGE') ? DT_LOGO_IMAGE : "0") . "," . (defined('DT_IMAGES') ? DT_IMAGES : "0") . "," . (defined('DT_FILE_RESOURCE') ? DT_FILE_RESOURCE : "0") . "," . (defined('DT_OTHER_FILE') ? DT_OTHER_FILE : "0") . ")" . " and file_mimetype like 'image%'\n\t\t\t\t\t\t\t  order by " . (defined('DT_THUMBNAIL') ? "dtl_DetailTypeID = " . DT_THUMBNAIL . " desc, " : "") . (defined('DT_LOGO_IMAGE') ? "dtl_DetailTypeID = " . DT_LOGO_IMAGE . " desc, " : "") . (defined('DT_IMAGES') ? "dtl_DetailTypeID = " . DT_IMAGES . " desc, " : "") . "dtl_DetailTypeID limit 1");
            if (mysql_num_rows($res) !== 1) {
                $res = mysql_query("select recUploadedFiles.*\n\t\t\t\t                      from recDetails a, defDetailTypes, Records, recDetails b, recUploadedFiles\n\t\t\t\t                     where a.dtl_RecID = {$rec_id}\n\t\t\t\t                       and a.dtl_DetailTypeID = dty_ID\n\t\t\t\t                       and dty_Type = 'resource'\n\t\t\t\t                       and rec_ID = a.dtl_Value\n\t\t\t\t                       and b.dtl_RecID = rec_ID\n\t\t\t\t                       and ulf_ID = b.dtl_UploadedFileID\n\t\t\t\t                       and file_mimetype like 'image%'\n\t\t\t\t                     limit 1;");
            }
            if (mysql_num_rows($res) == 1) {
                $file = mysql_fetch_assoc($res);
                $thumb_url = "../../common/php/resizeImage.php?ulf_ID=" . $file['ulf_ObfuscatedFileID'];
            }
            $text = DT_EXTENDED_DESCRIPTION && @$details[DT_EXTENDED_DESCRIPTION] ? '' . DT_EXTENDED_DESCRIPTION : (DT_SHORT_SUMMARY && @$details[DT_SHORT_SUMMARY] ? '' . DT_SHORT_SUMMARY : null);
            $this->description = "";
            if ($thumb_url) {
                $this->description .= "<img" . ($text ? " style='float: right;'" : "") . " src='" . $thumb_url . "'/>";
            }
            if ($text) {
                $this->description .= $details[$text];
            }
            $res = mysql_query('SELECT AsWKT(dtl_Geo) geo, dtl_Value, AsWKT(envelope(dtl_Geo)) as rect
			                      FROM recDetails
			                     WHERE NOT IsNULL(dtl_Geo)
			                       AND dtl_RecID = ' . $rec_id);
            if (mysql_num_rows($res) < 1 && (!defined('RT_RELATION') || $this->rec_RecTypeID != RT_RELATION) && DT_START_DATE && $details[DT_START_DATE]) {
                // Special case behaviour!
                // If a record has time data but not spatial data,
                // and it points to record(s) with spatial data, use that.
                // Although this is written in a general fashion it was
                // created for Event records, which may point to Site records
                $res = mysql_query('select AsWKT(g.dtl_Geo) geo, g.dtl_Value, AsWKT(envelope(g.dtl_Geo)) as rect
				                      from recDetails p
				                 left join defDetailTypes on dty_ID = p.dtl_DetailTypeID
				                 left join Records on rec_ID = p.dtl_Value
				                 left join recDetails g on g.dtl_RecID = rec_ID
				                     where p.dtl_RecID = ' . $rec_id . '
				                       and dty_Type = "resource"
				                       and g.dtl_Geo is not null');
            }
            while ($row = mysql_fetch_assoc($res)) {
                $geometry = new Geometry($row['geo'], $row['dtl_Value'], $row['rect']);
                if ($this->minX === null || $geometry->minX < $this->minX) {
                    $this->minX = $geometry->minX;
                }
                if ($this->maxX === null || $geometry->maxX > $this->maxX) {
                    $this->maxX = $geometry->maxX;
                }
                if ($this->minY === null || $geometry->minY < $this->minY) {
                    $this->minY = $geometry->minY;
                }
                if ($this->maxY === null || $geometry->maxY > $this->maxY) {
                    $this->maxY = $geometry->maxY;
                }
                $this->geometry[] = $geometry;
            }
        }
    }
예제 #27
0
 function getReferenceTypes()
 {
     if (HeuristKMLParser::$_referenceTypes) {
         return array_keys($this->_referenceTypes);
     }
     mysql_connection_select(DATABASE);
     // saw TODO check that this is correct seems that it is trying order on non bib types.
     HeuristKMLParser::$_referenceTypes = mysql__select_assoc("defRecTypes ", "rty_Name", "rty_ID", "rty_ShowInLists = 1 order by rty_RecTypeGroupID = 2, rty_Name");
     return array_keys(HeuristKMLParser::$_referenceTypes);
 }
예제 #28
0
 function inputOK($postVal, $dtyID, $rtyID)
 {
     if (!@$labelToID) {
         $labelToID = mysql__select_assoc("defTerms", "trm_Label", "trm_ID", "1");
     }
     /*****DEBUG****/
     //error_log("postvalue = ".print_r($postVal,true));
     // if value is term label
     if (!is_numeric($postVal) && array_key_exists($postVal, $labelToID)) {
         $postVal = $labelToID[$postVal];
     }
     return isValidID($postVal, $dtyID, $rtyID);
 }
if (@$_REQUEST['crosstype']) {
    $crosstype = true;
}
if (@$_REQUEST['personmatch']) {
    $personMatch = true;
    $res = mysql_query("select rec_ID, rec_RecTypeID, rec_Title, dtl_Value from Records left join recDetails on dtl_RecID=rec_ID and dtl_DetailTypeID={$surnameDT} where " . (strlen($recIDs) > 0 ? "rec_ID in ({$recIDs}) and " : "") . "rec_RecTypeID = {$perRT} and not rec_FlagTemporary order by rec_ID desc");
    //Given Name
    while ($row = mysql_fetch_assoc($res)) {
        $recsGivenNames[$row['rec_ID']] = $row['dtl_Value'];
    }
    $res = mysql_query("select rec_ID, rec_RecTypeID, rec_Title, dtl_Value from Records left join recDetails on dtl_RecID=rec_ID and dtl_DetailTypeID={$titleDT} where " . (strlen($recIDs) > 0 ? "rec_ID in ({$recIDs}) and " : "") . "rec_RecTypeID = {$perRT} and not rec_FlagTemporary order by dtl_Value asc");
    //Family Name
} else {
    $res = mysql_query("select rec_ID, rec_RecTypeID, rec_Title, dtl_Value from Records left join recDetails on dtl_RecID=rec_ID and dtl_DetailTypeID={$titleDT} where " . (strlen($recIDs) > 0 ? "rec_ID in ({$recIDs}) and " : "") . "rec_RecTypeID != {$relRT} and not rec_FlagTemporary order by rec_RecTypeID desc");
}
$rectypes = mysql__select_assoc('defRecTypes', 'rty_ID', 'rty_Name', '1');
while ($row = mysql_fetch_assoc($res)) {
    if ($personMatch) {
        if ($row['dtl_Value']) {
            $val = $row['dtl_Value'] . ($recsGivenNames[$row['rec_ID']] ? " " . $recsGivenNames[$row['rec_ID']] : "");
        }
    } else {
        if ($row['rec_Title']) {
            $val = $row['rec_Title'];
        } else {
            $val = $row['dtl_Value'];
        }
    }
    $mval = metaphone(preg_replace('/^(?:a|an|the|la|il|le|die|i|les|un|der|gli|das|zur|una|ein|eine|lo|une)\\s+|^l\'\\b/i', '', $val));
    if ($crosstype || $personMatch) {
        //for crosstype or person matching leave off the type ID
예제 #30
0
        $bib = mysql_fetch_assoc($res);
        $_REQUEST['bkmk_id'] = $bkmk['bkm_ID'];
    }
}
/*****DEBUG****/
//error_log("bookmark is ".print_r($bkmk,true));
/*****DEBUG****/
//error_log("record is ".print_r($bib,true));
$_REQUEST['bkm_ID'] = $_REQUEST['bkmk_id'];
$lexer = new Lexer($template);
$body = new BodyScope($lexer);
$body->global_vars['LINKED_BIBLIO-ID'] = $_REQUEST['recID'];
$body->global_vars['rec_ID'] = $_REQUEST['recID'];
$body->global_vars['bkm_ID'] = $_REQUEST['bkm_ID'];
$my_kwds = mysql__select_array('usrRecTagLinks left join usrTags on rtl_TagID=tag_ID', 'tag_Text', 'rtl_RecID=' . $bib['rec_ID']);
$tags = mysql__select_assoc('usrRecTagLinks left join usrTags on rtl_TagID=tag_ID' . ' left join ' . USERS_DATABASE . '.sysUGrps usr on usr.ugr_ID=tag_UGrpID', 'tag_Text', 'count(tag_ID) as kcount', 'rtl_RecID=' . $_REQUEST['recID'] . ' and rtl_ID is not null' . ' and usr.ugr_Enabled="Y"' . ' group by tag_Text' . ' order by kcount desc, tag_Text');
/*
$res = mysql_query('select concat(ugr_FirstName," ",ugr_LastName) as bkmk_user, tag_Text
					from usrBookmarks
					left join usrRecTagLinks on bkm_RecID=rtl_RecID
					left join usrTags on rtl_TagID=tag_ID
					left join '.USERS_DATABASE.'.sysUGrps usr on bkm_UGrpID=usr.ugr_ID
					where bkm_recID='.$bib['rec_ID'].' and rtl_ID is not null order by bkmk_user, tag_Text');

$user_tags = array();
while ($row = mysql_fetch_assoc($res)) {
	$bkmk_user = $row['bkmk_user'];
	$kwd_name = $row['tag_Text'];

	if ($user_tags[$bkmk_user])
		array_push($user_tags[$bkmk_user], $kwd_name);