function mia_results($results){
    global $date_fields,$dont_pull;
    $getfields = sql_query("SELECT ref,title FROM resource_type_field");
    $fieldnames = array();
    for($g=0; $g<count($getfields); $g++){
       $fieldnames[$getfields[$g]['ref']]=$getfields[$g]['title'];
    }
    for($i = 0; $i < count($results); $i++) {
        $ref = $results[$i]['ref'];
        if(isset($results[$i]['ref'])){
            $query=sql_query("SELECT * FROM resource_data WHERE resource = $ref AND value != '' AND value!='NULL' AND value != ','");
            for($q=0; $q<count($query); $q++){
                if($query[$q]['value'] != "," && $query[$q]['value'] !="" && array_key_exists($query[$q]['resource_type_field'],$fieldnames)){
                    if(substr($query[$q]['value'],0,1)==","){
                        $results[$i][$fieldnames[$query[$q]['resource_type_field']]]=substr($query[$q]['value'],1);
                    }else{
                        $results[$i][$fieldnames[$query[$q]['resource_type_field']]]=$query[$q]['value'];
                    }
                }
            }

            $access = get_resource_access($results[$i]);
            $filepath = get_resource_path($results[$i]['ref'], TRUE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
            $original_link = get_resource_path($results[$i]['ref'], FALSE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
            if(file_exists($filepath)) {
                $results[$i]['original_link'] = $original_link;
            } else {
                $results[$i]['original_link'] = 'No original link available.';
            }
            // Get the size of the original file:
           /* $original_size = get_original_imagesize($results[$i]['ref'], $filepath, $results[$i]['file_extension']);
            $original_size = formatfilesize($original_size[0]);
            $original_size = str_replace('&nbsp;', ' ', $original_size);
            $results[$i]['original_size'] = $original_size;*/
            foreach($results[$i] as $k => $v){
                if($v == "" || $v ==","){
                    unset($results[$i][$k]);
                }
                if($k == "created_by"){
                    $user = get_user($v);
                    $results[$i][$k]=$user["fullname"];
                }
                if(in_array($k,$date_fields)){
                    $unix = strtotime($v);
                    $datetime = date('y-m-d',$unix);
                    $results[$i][$k] = $datetime;
                }
                if($k == "resource_type" && is_numeric($v)){
                   $results[$i][$k]=get_resource_type_name($v);
                }
                //need to convert type to string here
                if(in_array($k,$dont_pull)){
                   unset($results[$i][$k]);
                }
            }
       }
//  var_dump($results);exit();
  return $results;
  }
}
    echo $collection;
    ?>
">

<?php 
    if ($feedback_resource_select) {
        ?>
<h2><?php 
        echo $lang["selectedresources"];
        ?>
:</h2><?php 
        # Show thumbnails and allow the user to select resources.
        $result = do_search("!collection" . $collection);
        for ($n = 0; $n < count($result); $n++) {
            $ref = $result[$n]["ref"];
            $access = get_resource_access($ref);
            $use_watermark = check_use_watermark($ref);
            $title = $ref . " : " . htmlspecialchars(tidy_trim(i18n_get_translated($result[$n]["field" . $view_title_field]), 60));
            if (isset($collection_feedback_display_field)) {
                $displaytitle = htmlspecialchars(get_data_by_field($ref, $collection_feedback_display_field));
            } else {
                $displaytitle = $title;
            }
            ?>
	
		<!--Resource Panel-->
		<div class="ResourcePanelShell" id="ResourceShell<?php 
            echo $ref;
            ?>
">
		<div class="ResourcePanel">
<div class="ResourcePanelShellSmall" <?php 
if ($display_user_rating_stars && $k == "") {
    ?>
 <?php 
}
?>
id="ResourceShell<?php 
echo $ref;
?>
">
	<div class="ResourcePanelSmall">	
		<?php 
if (!hook("renderimagesmallthumb")) {
    ?>
		<?php 
    $access = get_resource_access($result[$n]);
    $use_watermark = check_use_watermark();
    # Work out the preview image path
    $col_url = get_resource_path($ref, false, "col", false, $result[$n]["preview_extension"], -1, 1, $use_watermark, $result[$n]["file_modified"]);
    if (isset($result[$n]["col_url"])) {
        $col_url = $result[$n]["col_url"];
    }
    # If col_url set in data, use instead, e.g. by manipulation of data via process_search_results hook
    ?>
		<table border="0" class="ResourceAlignSmall">
		<?php 
    hook("resourcetop");
    ?>
		<tr><td>
		<a href="<?php 
    echo $url;
function collection_min_access($collection)
{
    # Returns the minimum access (the least permissive) that the current user has to the resources in $collection.
    $minaccess = 0;
    if (is_array($collection)) {
        $result = $collection;
    } else {
        $result = do_search("!collection" . $collection, "", "relevance", 0, -1, "desc", false, "", false, "");
    }
    for ($n = 0; $n < count($result); $n++) {
        $ref = $result[$n]["ref"];
        # Load access level
        $access = get_resource_access($result[$n]);
        if ($access > $minaccess) {
            $minaccess = $access;
        }
    }
    return $minaccess;
}
function resource_download_allowed($resource,$size,$resource_type)
	{

	# For the given resource and size, can the curent user download it?
	# resource type and access may already be available in the case of search, so pass them along to get_resource_access to avoid extra queries
	# $resource can be a resource-specific search result array.
	$access=get_resource_access($resource);

	if (checkperm('X' . $resource_type . "_" . $size) || checkperm('T' . $resource_type . "_" . $size))
		{
		# Block access to this resource type / size?
		# Only if no specific user access override (i.e. they have successfully requested this size).
		global $userref;
		$usercustomaccess = get_custom_access_user($resource,$userref);
		if ($usercustomaccess === false || !($usercustomaccess==='0')) {return false;}
		}

	# Full access
	if ($access==0)
		{
		return true;
		}

	# Special case for purchased downloads.
	global $userref;
	if (isset($userref))
		{
		$complete=sql_value("select cr.purchase_complete value from collection_resource cr join collection c on cr.collection=c.ref where c.user='******' and cr.resource='$resource' and cr.purchase_size='" . escape_check($size) . "'",0);
		if ($complete==1) {return true;}
		}

	# Restricted
	if ($access==1)
		{
		if ($size=="")
			{
			# Original file - access depends on the 'restricted_full_download' config setting.
			global $restricted_full_download;
			return $restricted_full_download;
			}
		else
			{
			# Return the restricted access setting for this resource type.
			return (sql_value("select allow_restricted value from preview_size where id='" . escape_check($size) . "'",0)==1);
			}
		}
		
	# Confidential
	if ($access==2)
		{
		return false;
		}
	
	}
Exemple #6
0
		
		<div class="clearerleft"> </div>
		</div>
		<?php 
}
if ($edit_upload_options_at_top) {
    include '../include/edit_upload_options.php';
}
$use = $ref;
# Resource aliasing.
# 'Copy from' or 'Metadata template' been supplied? Load data from this resource instead.
$originalref = $use;
if (getval("copyfrom", "") != "") {
    # Copy from function
    $copyfrom = getvalescaped("copyfrom", "");
    $copyfrom_access = get_resource_access($copyfrom);
    # Check access level
    if ($copyfrom_access != 2) {
        $use = $copyfrom;
        $original_fields = get_resource_field_data($ref, $multiple, true, -1, "", $tabs_on_edit);
    }
}
if (getval("metadatatemplate", "") != "") {
    $use = getvalescaped("metadatatemplate", "");
    $original_fields = get_resource_field_data($ref, $multiple, true, -1, "", $tabs_on_edit);
}
# Load resource data
$fields = get_resource_field_data($use, $multiple, !hook("customgetresourceperms"), $originalref, "", $tabs_on_edit);
# if this is a metadata template, set the metadata template title field at the top
if (isset($metadata_template_resource_type) && isset($metadata_template_title_field) && $resource["resource_type"] == $metadata_template_resource_type) {
    # recreate fields array, first with metadata template field
function can_share_resource($ref, $access = "")
{
    global $allow_share, $restricted_share, $customgroupaccess, $customuseraccess, $allow_custom_access_share;
    if ($access == "" || !isset($customgroupaccess)) {
        $access = get_resource_access($ref);
    }
    if (!$allow_share || $access == 2 || $access == 1 && !$restricted_share) {
        return false;
    }
    // return false asap
    if ($restricted_share) {
        return true;
    }
    // If sharing of restricted resources is permitted we should allow sharing whether access is open or restricted
    // User is not permitted to share if open access has been specifically granted for an otherwise restrcited resource to the user/group.
    if (!$allow_custom_access_share && ($customgroupaccess || $customuseraccess)) {
        return false;
    }
    // Must have open access and sharing is permitted
    return true;
}
Exemple #8
0
<?php 
        if (isset($home_slideshow_width)) {
            echo "style=\"";
            $slide_width = $home_slideshow_width + 2;
            echo "width:" . (string) $slide_width . "px; ";
            echo "\" ";
        }
        ?>
>
	
	<a id="slideshowlink" target="main"
	<?php 
        $linkurl = "#";
        if (file_exists("../" . $homeanim_folder . "/1.txt")) {
            $linkres = file_get_contents("../" . $homeanim_folder . "/1.txt");
            $linkaccess = get_resource_access($linkres);
            if ($linkaccess !== "" && ($linkaccess == 0 || $linkaccess == 1)) {
                $linkurl = $baseurl . "/pages/view.php?ref=" . $linkres;
            }
            echo "href=\"" . $linkurl . "\" ";
        }
        ?>
	\>
	
	<div class="HomePicturePanelIN" id='photoholder' style="
	<?php 
        if (isset($home_slideshow_height)) {
            echo "height:" . (string) $home_slideshow_height . "px; ";
        }
        ?>
		
#Begin loop through resources, collecting Keywords too.
$i=0;
$j=0;


for ($n=0;$n<count($result);$n++){
	$ref=$result[$n]["ref"];
	$preview_extension=$result[$n]["preview_extension"];
	$resourcetitle="";
    $i++;
	$currentx=$pdf->GetX();
	$currenty=$pdf->GetY();
	if ($ref!==false){
		# Find image
		# Load access level
		$access=get_resource_access($result[$n]); // feed get_resource_access the resource array rather than the ref, since access is included.
		$use_watermark=check_use_watermark();
		$imgpath = get_resource_path($ref,true,$imgsize,false,$preview_extension,-1,1,$use_watermark);
		if (!file_exists($imgpath) && $preview_extension=="jpg" && $imgsize=='hpr'){$imgpath = get_resource_path($ref,true,'',false,$preview_extension,-1,1,$use_watermark);}
		if (!file_exists($imgpath) && $imgsize!='pre'){$imgpath = get_resource_path($ref,true,'pre',false,$preview_extension,-1,1,$use_watermark);}
		if (!file_exists($imgpath)){
			$imgpath="../../gfx/".get_nopreview_icon($result[$n]['resource_type'],$result[$n]['file_extension'],false,true); 
			$preview_extension=explode(".",$imgpath);
			if(count($preview_extension)>1){
				$preview_extension=trim(strtolower($preview_extension[count($preview_extension)-1]));
			} 
		}	
		if (file_exists($imgpath)){
			# cells are used for measurement purposes only
			# Two ways to size image, either by height or by width.
			$thumbsize=getimagesize($imgpath);			
Exemple #10
0
function HookMagictouchViewReplacerenderinnerresourcepreview()
{
    global $baseurl, $plugins, $lang, $search, $offset, $archive, $order_by, $sort, $plugins, $download_multisize, $k, $access, $ref, $resource, $watermark;
    global $magictouch_account_id;
    if ($magictouch_account_id == "") {
        return false;
    }
    // This hooks runs outside of the renderinnerresourcepreview hook,
    // and if MTFAIL is defined, annotate will know not to include a Zoom link.
    // annotate plugin compatibility
    global $plugins;
    if (in_array("annotate", $plugins)) {
        global $annotate_ext_exclude;
        global $annotate_rt_exclude;
        if (in_array($resource['file_extension'], $annotate_ext_exclude)) {
            return false;
        }
        if (in_array($resource['resource_type'], $annotate_rt_exclude)) {
            return false;
        }
        if (getval("annotate", "") != "") {
            return false;
        }
    }
    // exclusions
    global $magictouch_rt_exclude;
    global $magictouch_ext_exclude;
    if (in_array($resource['resource_type'], $magictouch_rt_exclude)) {
        define("MTFAIL", true);
        return false;
    }
    if (in_array($resource['file_extension'], $magictouch_ext_exclude)) {
        define("MTFAIL", true);
        return false;
    }
    $download_multisize = true;
    if ($resource["has_image"] != 1) {
        define("MTFAIL", true);
        return false;
    }
    // watermark check
    $access = get_resource_access($ref);
    $use_watermark = check_use_watermark($ref);
    // paths
    $imageurl = get_resource_path($ref, false, "pre", false, $resource["preview_extension"], -1, 1, $use_watermark);
    global $magictouch_view_page_sizes;
    foreach ($magictouch_view_page_sizes as $mtpreviewsize) {
        $largeurl = get_resource_path($ref, false, $mtpreviewsize, false, "jpg", -1, 1, $use_watermark);
        $largeurl_path = get_resource_path($ref, true, $mtpreviewsize, false, "jpg", -1, 1, $use_watermark);
        if (file_exists($largeurl_path)) {
            break;
        }
    }
    if (!file_exists($largeurl_path)) {
        define("MTFAIL", true);
        return false;
        # Requires an original large JPEG file.
    }
    ?>

<div style="float:left;">
<div class="Picture">
<a href="<?php 
    echo $largeurl;
    ?>
" class="MagicTouch"><img src="<?php 
    echo $imageurl;
    ?>
" GALLERYIMG="no" id="previewimage" /></a>
</div><br />
    
<?php 
    // annotate plugin compatibility
    if (in_array("annotate", $plugins) && $k == "") {
        ?>
<a style="display:inline;clear:left;float:left;" href="<?php 
        echo $baseurl;
        ?>
/pages/view.php?ref=<?php 
        echo $ref;
        ?>
&search=<?php 
        echo urlencode($search);
        ?>
&offset=<?php 
        echo $offset;
        ?>
&order_by=<?php 
        echo $order_by;
        ?>
&sort=<?php 
        echo $sort;
        ?>
&archive=<?php 
        echo $archive;
        ?>
&k=<?php 
        echo $k;
        ?>
&annotate=true" onClick="return CentralSpaceLoad(this);">&gt;&nbsp;<?php 
        echo $lang['annotations'];
        ?>
</a><br /><br /><?php 
    }
    ?>
<script type="text/javascript">if(typeof MagicTouch=="object") {MagicTouch.refresh();} else {console.log("MagicTouch not loaded");}</script>
</div>
<?php 
    return true;
}
        $use_watermark = check_use_watermark();
        $filepath = get_resource_path($results[$n]['ref'], true, getval('previewsize', ''), false, 'jpg', -1, 1, $use_watermark, '', -1);
        $previewpath = get_resource_path($results[$n]['ref'], false, getval("previewsize", ""), false, "jpg", -1, 1, $use_watermark, "", -1);
        if (file_exists($filepath)) {
            $results[$n]['preview'] = $previewpath;
        } else {
            $previewpath = explode('filestore/', $previewpath);
            $previewpath = $previewpath[0] . "gfx/";
            $file = $previewpath . get_nopreview_icon($results[$n]["resource_type"], $results[$n]["file_extension"], false, true);
            $results[$n]['preview'] = $file;
        }
    }
}
if ($original) {
    for ($i = 0; $i < count($results); $i++) {
        $access = get_resource_access($results[$i]);
        $filepath = get_resource_path($results[$i]['ref'], TRUE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
        $original_link = get_resource_path($results[$i]['ref'], FALSE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
        if (file_exists($filepath)) {
            $results[$i]['original_link'] = $original_link;
        } else {
            $results[$i]['original_link'] = 'No original link available.';
        }
        // Get the size of the original file:
        $original_size = get_original_imagesize($results[$i]['ref'], $filepath, $results[$i]['file_extension']);
        $original_size = formatfilesize($original_size[0]);
        $original_size = str_replace('&nbsp;', ' ', $original_size);
        $results[$i]['original_size'] = $original_size;
    }
}
// flv file and thumb if available
 $pdf->SetAuthor($userfullname);
 if ($is_collection) {
     $pdf->SetTitle(i18n_get_collection_name($collectiondata) . ' ' . $date);
 } else {
     $pdf->SetTitle(i18n_get_translated($resourcedata['field' . $view_title_field]) . ' ' . $date);
 }
 $pdf->SetSubject($lang['annotations']);
 $pdf->setPrintHeader(false);
 $pdf->setPrintFooter(false);
 $pdf->setMargins(0.5, 0.5, 0.5);
 // add a page
 for ($n = 0; $n < count($resources); $n++) {
     $pdf->AddPage();
     $resourcedata = $resources[$n];
     $ref = $resources[$n]['ref'];
     $access = get_resource_access($resources[$n]['ref']);
     // feed get_resource_access the resource array rather than the ref, since access is included.
     $use_watermark = check_use_watermark();
     $imgpath = get_resource_path($ref, true, "hpr", false, "jpg", -1, 1, $use_watermark);
     if (!file_exists($imgpath)) {
         $imgpath = get_resource_path($ref, true, "lpr", false, "jpg", -1, 1, $use_watermark);
     }
     if (!file_exists($imgpath)) {
         $imgpath = get_resource_path($ref, true, "scr", false, "jpg", -1, 1, $use_watermark);
     }
     if (!file_exists($imgpath)) {
         $imgpath = get_resource_path($ref, true, "", false, "jpg", -1, 1, $use_watermark);
     }
     if (!file_exists($imgpath)) {
         $imgpath = get_resource_path($ref, true, "pre", false, "jpg", -1, 1, $use_watermark);
     }
    $restypes = "";
}
$default_sort = "DESC";
if (substr($order_by, 0, 5) == "field") {
    $default_sort = "ASC";
}
$sort = getval("sort", $default_sort);
$archive = getvalescaped("archive", 0, true);
$errors = array();
# The results of the save operation (e.g. required field messages)
$editaccess = get_edit_access($ref);
if (!$propose_changes_always_allow) {
    # Check user has permission.
    $proposeallowed = sql_value("select r.ref value from resource r left join collection_resource cr on r.ref='{$ref}' and cr.resource=r.ref left join user_collection uc on uc.user='******' and uc.collection=cr.collection left join collection c on c.ref=uc.collection where c.propose_changes=1", "");
    if ($proposeallowed == "" && $propose_changes_allow_open) {
        $proposeallowed = get_resource_access($ref) == 0 ? $ref : "";
    }
}
if (!$propose_changes_always_allow && $proposeallowed == "" && !$editaccess) {
    # The user is not allowed to edit this resource or the resource doesn't exist.
    $error = $lang['error-permissiondenied'];
    error_alert($error);
    exit;
}
if ($editaccess) {
    $userproposals = sql_query("select pc.user, u.username from propose_changes_data pc left join user u on u.ref=pc.user where resource='{$ref}' group by pc.user order by u.username asc");
    $view_user = getvalescaped("proposeuser", count($userproposals) == 0 ? $userref : $userproposals[0]["user"]);
    $proposed_changes = get_proposed_changes($ref, $view_user);
} else {
    $proposed_changes = get_proposed_changes($ref, $userref);
}