$record = array(); $record["replacedBy"] = $rec_id; } else { $record = getBaseProperties($rec_id, $bkm_ID); /*****DEBUG****/ //error_log("base Properties".print_r($record,true)); if (@$record["workgroupID"] && $record["workgroupID"] != get_user_id() && $record[@"visibility"] == "hidden" && !$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist']["user_access"][$record["workgroupID"]]) { // record is hidden and user is not the owner or a member of owning workgroup $record = array(); $record["denied"] = true; } else { $record["bdValuesByType"] = getAllRecordDetails($rec_id); $record["reminders"] = getAllReminders($rec_id); $record["comments"] = getAllComments($rec_id); $record["workgroupTags"] = getAllworkgroupTags($rec_id); $record["relatedRecords"] = getAllRelatedRecords($rec_id); $record["rtConstraints"] = getRectypeConstraints($record['rectypeID']); $record["retrieved"] = date('Y-m-d H:i:s'); // the current time according to the server } } } if (!defined("JSON_RESPONSE")) { if ($isPopup) { ?> if (! window.HEURIST) window.HEURIST = {}; if (! window.HEURIST.edit) window.HEURIST.edit = {}; window.HEURIST.edit.record = <?php echo json_format($record); ?> ;
function saveRelationship($recID, $relTermID, $trgRecID, $interpRecID, $title, $notes, $start_date, $end_date) { $relval = mysql_fetch_assoc(mysql_query("select trm_Label from defTerms where trm_ID = {$relTermID}")); $relval = $relval['trm_Label']; $srcTitle = mysql_fetch_assoc(mysql_query("select rec_Title from Records where rec_ID = {$recID}")); $srcTitle = $srcTitle['rec_Title']; $trgTitle = mysql_fetch_assoc(mysql_query("select rec_Title from Records where rec_ID = {$trgRecID}")); $trgTitle = $trgTitle['rec_Title']; mysql__insert("Records", array("rec_Title" => "{$title} ({$srcTitle} {$relval} {$trgTitle})", "rec_Added" => date('Y-m-d H:i:s'), "rec_Modified" => date('Y-m-d H:i:s'), "rec_RecTypeID" => RT_RELATION, 'rec_OwnerUGrpID' => intval(@$_REQUEST['rec_owner']) ? intval($_REQUEST['rec_owner']) : (@$userDefaultOwnerGroupID ? $userDefaultOwnerGroupID : (defined('HEURIST_NEWREC_OWNER_ID') ? HEURIST_NEWREC_OWNER_ID : get_user_id())), "rec_AddedByUGrpID" => get_user_id())); if (mysql_error()) { return array("error" => slash(mysql_error())); } $relnRecID = mysql_insert_id(); $res = null; if ($relnRecID > 0 && defined('DT_NAME') && defined('DT_RELATION_TYPE') && defined('DT_TARGET_RESOURCE') && defined('DT_PRIMARY_RESOURCE')) { $query = "insert into recDetails (dtl_RecID, dtl_DetailTypeID, dtl_Value) values "; $query .= "({$relnRecID}, " . DT_NAME . ", '" . mysql_real_escape_string($title) . "')"; $query .= ", ({$relnRecID}, " . DT_PRIMARY_RESOURCE . ", {$recID})"; $query .= ", ({$relnRecID}, " . DT_TARGET_RESOURCE . ", {$trgRecID})"; $query .= ", ({$relnRecID}, " . DT_RELATION_TYPE . ", {$relTermID})"; if ($interpRecID && defined('DT_INTERPRETATION_REFERENCE')) { $query .= ", ({$relnRecID}, " . DT_INTERPRETATION_REFERENCE . ", {$interpRecID})"; } if ($notes && defined('DT_SHORT_SUMMARY')) { $query .= ", ({$relnRecID}, " . DT_SHORT_SUMMARY . ", '" . mysql_real_escape_string($notes) . "')"; } if ($start_date && defined('DT_START_DATE')) { $query .= ", ({$relnRecID}, " . DT_START_DATE . ", '" . mysql_real_escape_string($start_date) . "')"; } if ($end_date && defined('DT_END_DATE')) { $query .= ", ({$relnRecID}, " . DT_END_DATE . ", '" . mysql_real_escape_string($end_date) . "')"; } $res = mysql_query($query); } if (mysql_error()) { return array("error" => slash(mysql_error())); } else { // $related = getAllRelatedRecords($recID, $relnRecID); $related = getAllRelatedRecords($recID); return array("relationship" => $related, "relnRecID" => $relnRecID); } }