/** * createRectypes - Function that inserts a new rectype into defRecTypes table.and use the rty_ID to insert any * fields into the defRecStructure table * @author Stephen White * @param $commonNames an array valid column names in the defRecTypes table which match the order of data in the $rt param * @param $dtFieldNames an array valid column names in the defRecStructure table * @param $rt astructured array of which can contain the column names and data for one or more rectypes with fields * @param $icon_filename - filename from icon library - for new record type ONLY * @return $ret an array of return values for the various data elements created or errors if they occurred **/ function createRectypes($commonNames, $rt, $isAddDefaultSetOfFields, $convertTitleMask = true, $icon_filename = null) { global $mysqli, $rtyColumnNames; $ret = null; if (count($commonNames)) { $colNames = join(",", $commonNames); $parameters = array(""); $titleMask = null; $query = ""; $querycols = ""; foreach ($commonNames as $colName) { $val = array_shift($rt[0]['common']); if (@$rtyColumnNames[$colName]) { //keep value of text title mask to create canonical one if ($convertTitleMask && $colName == "rty_TitleMask") { $titleMask = $val; } if ($query != "") { $query = $query . ","; $querycols = $querycols . ","; } $querycols = $querycols . $colName; $query = $query . "?"; $parameters = addParam($parameters, $rtyColumnNames[$colName], $val); } } $query = "insert into defRecTypes ({$querycols}) values ({$query})"; $rows = execSQL($mysqli, $query, $parameters, true); if ($rows == "1062") { $ret = "Record type with specified name already exists in the database, please use the existing record type\nThis type may be hidden - turn it on through Database > Manage structure"; } else { if ($rows == 0 || is_string($rows)) { $ret = "SQL error inserting data into table defRecTypes: " . $rows; } else { $rtyID = $mysqli->insert_id; $ret = -$rtyID; if ($isAddDefaultSetOfFields) { //add default set of detail types addDefaultFieldForNewRecordType($rtyID); } //create canonical title mask if ($titleMask) { updateTitleMask($rtyID, $titleMask); } $need_create_icon = true; if ($icon_filename) { $need_create_icon = copy_IconAndThumb_FromLibrary($rtyID, $icon_filename); } //create icon and thumbnail if ($need_create_icon) { getRectypeIconURL($rtyID); getRectypeThumbURL($rtyID); } } } } if ($ret == null) { $ret = "no data supplied for inserting record type"; } return $ret; }
function createRectypes($commonNames, $rt, $isAddDefaultSetOfFields) { global $db, $rtyColumnNames; $ret = null; if (count($commonNames)) { $colNames = join(",", $commonNames); $parameters = array(""); $titleMask = null; $query = ""; foreach ($commonNames as $colName) { $val = array_shift($rt[0]['common']); if ($query != "") { $query = $query . ","; } $query = $query . "?"; $parameters[0] = $parameters[0] . $rtyColumnNames[$colName]; array_push($parameters, $val); //keep value of text title mask to create canonical one if ($colName == "rty_TitleMask") { $titleMask = $val; } } $query = "insert into defRecTypes ({$colNames}) values ({$query})"; $rows = execSQL($db, $query, $parameters, true); if ($rows == "1062") { $ret = "Record type with specified name already exists in the database, please use the existing record type\nThis type may be hidden - turn it on through Database Designer view > Record types"; } else { if ($rows == 0 || is_string($rows)) { $ret = "SQL error inserting data into table defRecTypes: " . $rows; } else { $rtyID = $db->insert_id; $ret = -$rtyID; if ($isAddDefaultSetOfFields) { //add default set of detail types addDefaultFieldForNewRecordType($rtyID); //create canonical title mask updateCanonicalTitleMask($rtyID, $titleMask); } //create icon and thumbnail getRectypeIconURL($rtyID); getRectypeThumbURL($rtyID); } } } if ($ret == null) { $ret = "no data supplied for inserting rectype"; } return $ret; }
if ($mode == 4 && $rt_id > 0) { // verification of icon existense $filename = HEURIST_ICON_DIR . $rt_id . '.png'; if (file_exists($filename)) { print 1; } else { print 0; } exit; } if ($mode != 3 && !$rt_id) { // no ID set, hopefully this should not occur return; } $rt_name = @$_REQUEST['rty_Name']; $image_icon = getRectypeIconURL($rt_id); $image_thumbnail = getRectypeThumbURL($rt_id); $success_msg = null; $failure_msg = null; /* TODO: ??????? require_once(dirname(__FILE__).'/../../../common/php/dbMySqlWrappers.php'); mysql_connection_select(DATABASE); $res = mysql_query('select * from defRecTypes where rty_ID = ' . $rt_id); $rt = mysql_fetch_assoc($res); */ if (@$_REQUEST['libicon']) { //take from library if (copy_IconAndThumb_FromLibrary($rt_id, $_REQUEST['libicon'])) { //error list($success_msg, $failure_msg) = array('', "Library file: {$filename} couldn't be saved to upload path defined for db = " . HEURIST_DBNAME . " (" . HEURIST_ICON_DIR . "). Please ask your system administrator to correct the path and/or permissions for this directory"); } else {
if (!is_admin()) { return; } //TOD change this for just admin and return msg. Is probably only called where user is admin $rt_id = intval($_REQUEST['rty_ID']); $mode = intval($_REQUEST['mode']); //0 - icon, 1 - thumbnail if (!$rt_id) { // no ID set, hopefully this should not occur error_log("uploadRectypeIcon.php called without a record type ID set"); return; } $dim = $mode == 0 ? 16 : 75; // appropriate sizes for icons and thumbnails $image_dir = HEURIST_ICON_DIR . ($mode == 0 ? '' : 'thumb/th_'); $image_url = $mode == 0 ? getRectypeIconURL($rt_id) : getRectypeThumbURL($rt_id); /*****DEBUG****/ //error_log("image directory / image url: ".$image_dir." / ".$image_url); /* ??????? require_once(dirname(__FILE__).'/../../common/php/dbMySqlWrappers.php'); mysql_connection_select(DATABASE); $res = mysql_query('select * from defRecTypes where rty_ID = ' . $rt_id); $rt = mysql_fetch_assoc($res); */ list($success_msg, $failure_msg) = upload_file($rt_id, $dim); ?> <html> <head> <title>Upload reference type icon</title> <link rel="stylesheet" type="text/css" href="<?php