" maxlength="100" class="shrtwidth" /></div>
			 <div class="Inline"><input name="Submit" type="submit" value="&nbsp;&nbsp;<?php 
echo $lang["searchbutton"];
?>
&nbsp;&nbsp;" /></div>
			 <div class="Inline"><input name="Clear" type="button" onclick="document.getElementById('find').value='';submit();" value="&nbsp;&nbsp;<?php 
echo $lang["clearbutton"];
?>
&nbsp;&nbsp;" /></div>
			</div>
			<div class="clearerleft"> </div>
		</div>
	</form>
</div>
<?php 
$collections = get_user_collections($userref, $find, $col_order_by, $sort);
$results = count($collections);
$totalpages = ceil($results / $per_page);
$curpage = floor($offset / $per_page) + 1;
$jumpcount = 1;
# Create an a-z index
$atoz = "<div class=\"InpageNavLeftBlock\">";
if ($find == "") {
    $atoz .= "<span class='Selected'>";
}
$atoz .= "<a href=\"" . $baseurl_short . "pages/collection_manage.php?col_order_by=name&find=\" onClick=\"return CentralSpaceLoad(this);\">" . $lang["viewall"] . "</a>";
if ($find == "") {
    $atoz .= "</span>";
}
$atoz .= "&nbsp;&nbsp;&nbsp;&nbsp;";
for ($n = ord("A"); $n <= ord("Z"); $n++) {
 function get_user_collections($user, $find = "", $order_by = "name", $sort = "ASC", $fetchrows = -1, $auto_create = true)
 {
     global $usergroup;
     # Returns a list of user collections.
     $sql = "";
     $keysql = "";
     $extrasql = "";
     if ($find == "!shared") {
         # only return shared collections
         $sql = " where (public='1' or c.ref in (select distinct collection from user_collection where user<>'{$user}' union select distinct collection from external_access_keys))";
     } elseif (strlen($find) == 1 && !is_numeric($find)) {
         # A-Z search
         $sql = " where c.name like '{$find}%'";
     } elseif (strlen($find) > 1 || is_numeric($find)) {
         $keywords = split_keywords($find);
         $keyrefs = array();
         $keysql = "";
         for ($n = 0; $n < count($keywords); $n++) {
             $keyref = resolve_keyword($keywords[$n], false);
             if ($keyref !== false) {
                 $keyrefs[] = $keyref;
             }
             $keysql .= " join collection_keyword k" . $n . " on k" . $n . ".collection=ref and (k" . $n . ".keyword='{$keyref}')";
             //$keysql="or keyword in (" . join (",",$keyrefs) . ")";
         }
         //$sql.="and (c.name rlike '$search' or u.username rlike '$search' or u.fullname rlike '$search' $spcr )";
     }
     # Include themes in my collecions?
     # Only filter out themes if $themes_in_my_collections is set to false in config.php
     global $themes_in_my_collections;
     if (!$themes_in_my_collections) {
         if ($sql == "") {
             $sql = " where ";
         } else {
             $sql .= " and ";
         }
         $sql .= " (length(c.theme)=0 or c.theme is null) ";
     }
     global $anonymous_login, $username, $anonymous_user_session_collection;
     if (isset($anonymous_login) && $username == $anonymous_login && $anonymous_user_session_collection) {
         // Anonymous user - only get the user's own collections that are for this session - although we can still join to get collections that have been specifically shared with the anonymous user
         if ($sql == "") {
             $extrasql = " where ";
         } else {
             $extrasql .= " and ";
         }
         $rs_session = get_rs_session_id(true);
         $extrasql .= " (c.session_id='" . $rs_session . "')";
     }
     $order_sort = "";
     if ($order_by != "name") {
         $order_sort = " order by {$order_by} {$sort}";
     }
     $return = "select * from (select c.*,u.username,u.fullname,count(r.resource) count from user u join collection c on u.ref=c.user and c.user='******' left outer join collection_resource r on c.ref=r.collection {$sql} {$extrasql} group by c.ref\n\tunion\n\tselect c.*,u.username,u.fullname,count(r.resource) count from user_collection uc join collection c on uc.collection=c.ref and uc.user='******' and c.user<>'{$user}' left outer join collection_resource r on c.ref=r.collection left join user u on c.user=u.ref {$sql} group by c.ref\n\tunion\n\tselect c.*,u.username,u.fullname,count(r.resource) count from usergroup_collection gc join collection c on gc.collection=c.ref and gc.usergroup='{$usergroup}' and c.user<>'{$user}' left outer join collection_resource r on c.ref=r.collection left join user u on c.user=u.ref {$sql} group by c.ref) clist {$keysql} group by ref {$order_sort}";
     $return = sql_query($return);
     if ($order_by == "name") {
         if ($sort == "ASC") {
             usort($return, 'collections_comparator');
         } else {
             if ($sort == "DESC") {
                 usort($return, 'collections_comparator_desc');
             }
         }
     }
     // To keep My Collection creation consistent: Check that user has at least one collection of his/her own  (not if collection result is empty, which may include shares),
     $hasown = false;
     for ($n = 0; $n < count($return); $n++) {
         if ($return[$n]['user'] == $user) {
             $hasown = true;
         }
     }
     if (!$hasown && $auto_create && $find == "") {
         # No collections of one's own? The user must have at least one My Collection
         global $usercollection;
         $name = get_mycollection_name($user);
         $usercollection = create_collection($user, $name, 0, 1);
         // make not deletable
         set_user_collection($user, $usercollection);
         # Recurse to send the updated collection list.
         return get_user_collections($user, $find, $order_by, $sort, $fetchrows, false);
     }
     return $return;
 }
                        ?>
selected <?php 
                    }
                    ?>
><?php 
                    echo $lang["batchdonotaddcollection"];
                    ?>
</option><?php 
                }
                ?>
		
		<?php 
                if ($upload_force_mycollection) {
                    $list = get_user_collections($userref, "My Collection");
                } else {
                    $list = get_user_collections($userref);
                }
                $currentfound = false;
                // make sure it's possible to set the collection with collection_add (compact style "upload to this collection"
                if ($collection_add != "" && getval("resetform", "") == "" && (!isset($save_errors) || !$save_errors)) {
                    # Switch to the selected collection (existing or newly created) and refresh the frame.
                    set_user_collection($userref, $collection_add);
                    refresh_collection_frame($collection_add);
                }
                for ($n = 0; $n < count($list); $n++) {
                    if ($collection_dropdown_user_access_mode) {
                        $colusername = $list[$n]['fullname'];
                        # Work out the correct access mode to display
                        if (!hook('collectionaccessmode')) {
                            if ($list[$n]["public"] == 0) {
                                $accessmode = $lang["private"];
 /**
  * Get the collections associated with a user.
  *
  * @param string $subtype Optionally, the subtype of result we want to limit to
  * @param int $limit The number of results to return
  * @param int $offset Any indexing offset
  * @return unknown
  */
 public function getCollections($subtype = "", $limit = 10, $offset = 0)
 {
     return get_user_collections($this->getGUID(), $subtype, $limit, $offset);
 }
function get_user_collections($user,$find="",$order_by="name",$sort="ASC",$fetchrows=-1,$auto_create=true)
	{
	# Returns a list of user collections.
	$sql="";
	$keysql="";
	if (strlen($find)==1 && !is_numeric($find))
		{
		# A-Z search
		$sql=" where c.name like '$find%'";
		}
	elseif (strlen($find)>1 || is_numeric($find))
		{  
		$keywords=split_keywords($find);
		$keyrefs=array();
		$keysql="";
		for ($n=0;$n<count($keywords);$n++)
			{
			$keyref=resolve_keyword($keywords[$n],false);
			if ($keyref!==false) {$keyrefs[]=$keyref;}

			$keysql.=" join collection_keyword k" . $n . " on k" . $n . ".collection=ref and (k" . $n . ".keyword='$keyref')";	
			//$keysql="or keyword in (" . join (",",$keyrefs) . ")";
			}

 
		//$sql.="and (c.name rlike '$search' or u.username rlike '$search' or u.fullname rlike '$search' $spcr )";
		}
    
    # Include themes in my collecions? 
    # Only filter out themes if $themes_in_my_collections is set to false in config.php
   	global $themes_in_my_collections;
   	if (!$themes_in_my_collections)
   		{
		if ($sql==""){$sql=" where ";} else {$sql.=" and ";}	
   		$sql.=" (length(c.theme)=0 or c.theme is null) ";
   		}
   
	$order_sort="";
	if ($order_by!="name"){$order_sort=" order by $order_by $sort";}
   
	$return="select * from (select c.*,u.username,u.fullname,count(r.resource) count from user u join collection c on u.ref=c.user and c.user='******' left outer join collection_resource r on c.ref=r.collection $sql group by c.ref
	union
	select c.*,u.username,u.fullname,count(r.resource) count from user_collection uc join collection c on uc.collection=c.ref and uc.user='******' and c.user<>'$user' left outer join collection_resource r on c.ref=r.collection left join user u on c.user=u.ref $sql group by c.ref) clist $keysql $order_sort";

	$return=sql_query($return);
	
	if ($order_by=="name"){
		if ($sort=="ASC"){usort($return, 'collections_comparator');}
		else if ($sort=="DESC"){usort($return,'collections_comparator_desc');}
	}
	
	// To keep My Collection creation consistent: Check that user has at least one collection of his/her own  (not if collection result is empty, which may include shares), 
	$hasown=false;
	for ($n=0;$n<count($return);$n++){
		if ($return[$n]['user']==$user){
			$hasown=true;
		}
	}
	if ($find!=""){$hasown=true;} // if doing a search in collections, assume My Collection already exists (to avoid creating new collections due to an empty search result).

	if (!$hasown && $auto_create)
		{
		# No collections of one's own? The user must have at least one My Collection
		global $usercollection;
		$name=get_mycollection_name($user);
		$usercollection=create_collection ($user,$name,0,1); // make not deletable
		set_user_collection($user,$usercollection);
		
		# Recurse to send the updated collection list.
		return get_user_collections($user,$find,$order_by,$sort,$fetchrows,false);
		}

	return $return;
	}
include "../include/header.php";
?>
<div class="BasicsBox">
<p><a href="<?php 
echo $baseurl_short;
?>
pages/collection_manage.php" onClick="return CentralSpaceLoad(this,true);">&lt;&nbsp;<?php 
echo $lang["managecollectionslink"];
?>
</a></p>	
<h1><?php 
echo $lang["shared_collections"];
?>
</h1>
<?php 
$collections = get_user_collections($userref, "!shared");
$results = count($collections);
$totalpages = ceil($results / $per_page);
$curpage = floor($offset / $per_page) + 1;
$jumpcount = 1;
$url = $baseurl_short . "pages/view_shares.php?coluser="******"TopInpageNav"><?php 
pager(false);
?>
</div><?php 
for ($n = $offset; $n < count($collections) && $n < $offset + $per_page; $n++) {
    ?>
	<div class="RecordBox">
	<div class="RecordPanel">
		<div class="RecordHeader">
Example #7
0
$search_includes_themes_now=$search_includes_themes;
$search_includes_public_collections_now=$search_includes_themes;
$search_includes_user_collections_now=$search_includes_themes;
if ($restypes!="") {
$restypes_x=explode(",",$restypes);
$search_includes_themes_now=in_array("themes",$restypes_x);
$search_includes_public_collections_now=in_array("pubcol",$restypes_x);
$search_includes_user_collections_now=in_array("mycol",$restypes_x);
} 

if (( ($search_includes_themes_now || $search_includes_public_collections_now || $search_includes_user_collections_now)) && $search!="" && substr($search,0,1)!="!" && $offset==0)
    {
    $collections=search_public_collections($search,"theme","ASC",!$search_includes_themes_now,!$search_includes_public_collections_now,true);
    if ($search_includes_user_collections_now){
		$collections=array_merge(get_user_collections($userref,$search,"name",$revsort),$collections);
		$condensedcollectionsresults=array();
		$colresultsdupecheck=array();
		foreach($collections as $collection){
			if (!in_array($collection['ref'],$colresultsdupecheck)){
				$condensedcollectionsresults[]=$collection;
				$colresultsdupecheck[]=$collection['ref'];
			}
		}
		$collections=$condensedcollectionsresults;
	}
}
    
# Special case: numeric searches (resource ID) and one result: redirect immediately to the resource view.
if ((($config_search_for_number && is_numeric($search)) || $searchresourceid > 0) && is_array($result) && count($result)==1)
	{
    $resource = $get_file_thumbnail_link;
    $file = sql_query("SELECT * FROM resource WHERE ref='{$resource}'");
    $preview_extension = $file[0]['file_extension'];
    if ($preview_extension == 'pdf') {
        $preview_extension = $file[0]['preview_extension'];
    }
    $thumbnail_link = get_resource_path($resource, FALSE, 'col', FALSE, $preview_extension, -1, 1, FALSE);
    $file_headers = get_headers($thumbnail_link);
    $resourcedata = get_resource_data($resource);
    $no_preview_icon = "gfx/" . get_nopreview_icon($resourcedata["resource_type"], $resourcedata["file_extension"], false);
    $data = array('thumbnail_link' => $thumbnail_link, 'no_preview_icon' => $no_preview_icon, 'file_header' => $file_headers[0]);
    printJson($data);
}
// get all collections
if ($get && $get_all_collections) {
    $all_collections = get_user_collections($user_id);
    printJson($all_collections);
}
// get all files within a specific collection
if ($get_files_in_collection && $collection_id) {
    $fetchFiles = "SELECT * \n            FROM resource \n            WHERE \n              ref IN (SELECT resource FROM collection_resource WHERE collection='{$collection_id}')";
    $fetchCollection = "SELECT ref, name FROM collection WHERE ref='{$collection_id}'";
    $fileData = sql_query($fetchFiles);
    $collectionData = sql_query($fetchCollection);
    foreach ($fileData as $k => $file) {
        // Get the size of the original file
        $filepath = get_resource_path($file['ref'], TRUE, '', FALSE, $file['file_extension'], -1, 1, FALSE, '', -1);
        $original_size = get_original_imagesize($file['ref'], $filepath, $file['file_extension']);
        $original_size = formatfilesize($original_size[0]);
        $original_size = str_replace('&nbsp;', ' ', $original_size);
        $fileData[$k]['original_size'] = $original_size;