0) {
// a simple id was passed
$id = intval($_REQUEST['subtarget']);
} else {
// an object was passed
$subtarget = json_decode($_REQUEST['subtarget'], TRUE);
// fileid
$id = intval($subtarget['id']);
// the NEW connection of the file (to an object)
$connectedobjectid = intval($subtarget['connectedobjectid']);
}
// loading basic info for the file
$file = new File($id);
$data = $file->getData();
// get the access rights of the current user for the given file
$content_vars['access'] = Tools::checkAccessrights(
array(
"type" => "file",
"id" => $id,
"currentaccountid" => $_SESSION['account_id'],
"setupaccountid" => $data['setupaccountid']
)
);
// read account data of current user
$accountdata = Account::getAccountData(array("accountid" => $_SESSION['account_id']));
// by default, do not show the form
$showform = false;
$errormessage = t("You have to be signed in.");
if ($_SESSION['account_id'] > 0) {
if ($_SESSION['account_id'] == $data['setupaccountid']) {
// user is the file owner
$showform = true;
} elseif (account_services_check('admin')) {
// user is an admin
$showform = true;
}
}
if ($data['deleted']){
if ($showform === true) {
// owner and admins have access
} else {
// user has no access
$showform = false;
$errormessage = t("File could not be loaded.");
}
}
// check, if file is private and user is not owner > then redirect to start page
if ($data['isprivate'] && $_SESSION['account_id'] != $data['setupaccountid']){
if ($showform === true) {
// owner and admins have access
} else {
// user has no access
$showform = false;
$errormessage = t("File cannot be displayed.");
}
}
// check, if file is not owned by shotbox author, redirect to home
if ($data['fileownershipid'] != 3 && !empty($_REQUEST['name']) && $_SESSION['account_id'] != $data['setupaccountid']){
$showform = false;
$errormessage = t("File cannot be displayed.");
}
?>
getFileURL('300-crop');
$vars['latitudestart'] = $data['latitudestart'];
$vars['longitudestart'] = $data['longitudestart'];
// echo file_get_contents($file->getFileURL(2).'&hit=view&userid='.$_SESSION['account_id']);
// the image
// get width/height for tag
$calculatedwidthheight = $file->getFileWidthHeight('low');
$vars['the_image'] = sprintf(
'
',
$file->getFileURL(2),
shorten($data["description"], 30, ' '),
shorten($data["description"], 50, ' '),
$calculatedwidthheight['width'],
$calculatedwidthheight['height']
);
// categories
$categories = array();
$cat_array_edit = array();
foreach ($data['categories'] as $key => $value) {
array_push($categories, array($key, $value));
array_push($cat_array_edit, $key);
}
$vars['categories_file'] = $cat_array_edit;
/*
if (!empty($data["ownername"])){
$vars['img_author'] = GenerateURL::buildURL('author', array($data["ownername"]));
} else {
$vars['img_author'] = '';
}
*/
$vars['author_line'] = $data["ownername"];
$vars['author_line_edit'] = (empty($data["ownername"])) ? $accountdata['accountfileownername'] : $data["ownername"];
if ($vars['author_line_edit'] == "" && $accountdata['accountfileownername'] != "") {
$vars['author_line_edit'] = $accountdata['accountfileownername'];
}
// uploadername
if ($_SESSION['account_id'] == $data['setupaccountid'] || in_array($_SESSION['account_id'], $GLOBALS['admins'])){
$query = sprintf("SELECT accountname FROM account WHERE accountid = %u", $data['setupaccountid']);
$vars['uploadername'] = queryOne($query);
} else {
$vars['uploadername'] = false;
}
// get available languages
if ($_SESSION['account_id'] > 0){
$query = sprintf('SELECT languageid, "name", isocode FROM language WHERE NOT deleted ORDER BY languageid', $_SESSION['lng']);
$vars['languages'] = query($query);
}
// additional functionality > sort cat's by alphabet (first main) > the output was not sorted.
// leave, could not be solved by sql query! => by frank
function subval_sort($a, $subkey) {
foreach($a as $k=>$v) {
$b[$k] = strtolower($v[$subkey]);
}
asort($b);
foreach($b as $key=>$val) {
$c[] = $a[$key];
}
return $c;
}
// is user is logged in, we get all pricing and license models
if ($_SESSION['account_id'] > 0){
// get licenses
include CROOT."/midware/License.class.php";
$vars['licenses'] = License::getLicenseNameKey($vars['setupaccountid']);
// get pricemodels
include CROOT."/midware/Pricemodel.class.php";
$vars['pricemodels'] = Pricemodel::getPricemodelNameKey($vars['setupaccountid']);
// get ownerships
$query = "SELECT id, longtext FROM fileownership WHERE NOT id = 2 ORDER BY sort;";
$vars['ownerships'] = query($query);
// get categories
require_once CROOT."/midware/Filecategory.class.php";
$unsorted = Filecategory::getCategories();
$vars['cattree'] = subval_sort($unsorted, 'text');
$vars['inputlanguage'] = $$data['inputlanguage'];
}
if (isset($connectedobjectid) && is_numeric($connectedobjectid)) {
// a new default object was passed to the edit tool (which has not been saved yet)
$linkedobjectid = $connectedobjectid;
} elseif (is_numeric($data['objectid'])) {
$linkedobjectid = $data['objectid'];
}
if (is_numeric($linkedobjectid) && $linkedobjectid != 999999999) {
require_once CROOT."/midware/GenerateURL.class.php";
require_once CROOT."/midware/Factory.class.php";
$structure = Factory::getObjectByID($linkedobjectid);
$objectdata = $structure->getDisplayData();
$objectvalues = $objectdata['data'];
if (!empty($objectvalues['name']['value'][$_SESSION['account_language']])) {
$objectname = $content_vars['values']['name']['value'][$_SESSION['account_language']];
} else if (!empty($objectvalues['name']['value']['en'])) {
$objectname = $objectvalues['name']['value']['en'];
} else {
$objectname = current($objectvalues['name']['value']);
}
if (strlen($objectname) >= 24) {
// name too long, shorten it for link
$objectlinkname = substr($objectname, 0, 24) . '..';
}
// copy lat/lng for frame.html => to copy current object as current object
// this is necessary to enable that the map is loaded when a specific object window has been loaded already and user is then opening map mode
$latlngarray = explode(" ", $objectdata['data']['pinpoint']['value']);
$_REQUEST['currentobject_lat'] = $latlngarray[1];
$_REQUEST['currentobject_lng'] = $latlngarray[0];
}
?>