CHG: Featured Collections to support children. New collection types. [q10271]
git-svn-id: http://svn.resourcespace.com/svn/rs/trunk@16171 c08608d7-6e46-0410-86ca-f2a6f1370df5
This commit is contained in:
parent
f396a32d1c
commit
e3263b3a5f
|
@ -204,7 +204,7 @@ div.autocomplete ul li {color: #000;}
|
|||
#InfoBoxCollectionInner h2 {color:black;}
|
||||
#InfoBoxCollectionInner p {color:black;}
|
||||
.ListviewBoxedTitleStyle td {background-color:#fff;}
|
||||
.NewFlag {background-color:#737373;color:#fff;}
|
||||
.NewFlag { background-color: #fff; color: #737373; }
|
||||
|
||||
/* Mouseover effect on list views */
|
||||
.ListviewStyle tr:hover td {background-color: #EEE;}
|
||||
|
|
|
@ -632,7 +632,7 @@ behavior: url('../css/iepngfix.htc');
|
|||
.PDFnav {font-size: 4em; padding:6px;font-weight:bold;}
|
||||
.PDFnav:hover {text-decoration: none;}
|
||||
|
||||
.NewFlag {display:inline;font-size:0.6em;margin-left:5px;padding:1px 3px 1px 3px;}
|
||||
.NewFlag { display: inline; font-size: 0.6em; margin-left: 5px; padding: 1px 3px; font-weight: bolder; }
|
||||
.Breadcrumbs {float:left;margin-top:4px;}
|
||||
.SearchBreadcrumbs {margin-top:15px;}
|
||||
.SearchTitle {padding: 0px;margin-top:-10px;margin-bottom:5px;}
|
||||
|
@ -1351,6 +1351,15 @@ a.FeaturedSimpleLink:hover, a.FeaturedSimpleLink:active {
|
|||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.FeaturedSimpleTileImage img.TileGroupImageBase { position: absolute; top: 10px; height: 100%; box-shadow: 0 0 25px #000; }
|
||||
|
||||
.FeaturedSimpleTile.FullWidth { height: 40px; }
|
||||
.FeaturedSimpleTile.FullWidth .FeaturedSimpleLink { width: 85%; }
|
||||
.FeaturedSimpleTile.FullWidth .FeaturedSimpleTileContents h2 { background-color: unset; }
|
||||
.FeaturedSimpleTile.FullWidth .ListTools .ActionsContainer select { margin: 5px 5px; }
|
||||
.FeaturedCallToActionTile.FullWidth .FeaturedSimpleTileContents { background-color: rgba(0,0,0,0.4); }
|
||||
.FeaturedCallToActionTile.FullWidth .FeaturedSimpleTileContents h2 span { font-size: larger; }
|
||||
|
||||
.MessageUnread {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -1878,6 +1887,9 @@ a.BrowseRefresh{
|
|||
z-index:500;
|
||||
}
|
||||
|
||||
.FullWidth { width: 100%; }
|
||||
.MarginZeroAuto { margin: 0 auto; }
|
||||
|
||||
.JobTable {
|
||||
clear: both;
|
||||
}
|
||||
|
@ -1893,4 +1905,4 @@ a.BrowseRefresh{
|
|||
.TablePagerHolder {
|
||||
float: right;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
1,"Default Collection",1,"2008-01-01 10:00:00",0,,0,1,,1,,,,,,,,
|
||||
1,"Default Collection",1,"2008-01-01 10:00:00",0,0,1,,,,,,,,,,
|
|
@ -1,4 +1,5 @@
|
|||
collection,0,PRIMARY,1,ref,A,239,,,,BTREE,
|
||||
collection,1,theme,1,theme,A,29,,,YES,BTREE,
|
||||
collection,1,public,1,public,A,1,,,,BTREE,
|
||||
collection,1,user,1,user,A,1,,,,BTREE,
|
||||
collection,0,PRIMARY,1,ref,A,35,,,,BTREE,,
|
||||
collection,1,public,1,public,A,2,,,YES,BTREE,,
|
||||
collection,1,user,1,user,A,4,,,YES,BTREE,,
|
||||
collection,1,type,1,type,A,4,,,YES,BTREE,,
|
||||
collection,1,parent,1,parent,A,6,,,YES,BTREE,,
|
||||
|
|
|
@ -3,9 +3,6 @@ name,varchar(100),YES,,,
|
|||
user,int(11),YES,,,
|
||||
created,datetime,YES,,,
|
||||
public,int(11),NO,MUL,0,
|
||||
theme,varchar(100),YES,MUL,,
|
||||
theme2,varchar(100),YES,MUL,,
|
||||
theme3,varchar(100),YES,MUL,,
|
||||
allow_changes,int(11),YES,,0,
|
||||
cant_delete,int(11),NO,,0,
|
||||
keywords,text,NO,,,
|
||||
|
@ -15,4 +12,6 @@ home_page_text,text,YES,,,
|
|||
home_page_image,int(11),YES,,,
|
||||
session_id,int(11),YES,,,
|
||||
description,text,YES,,,
|
||||
type,int(11),YES,,0,
|
||||
type,int(11),YES,,0,
|
||||
parent,int(11),YES,,,
|
||||
thumbnail_selection_method,int(11),YES,,,
|
|
@ -1,127 +0,0 @@
|
|||
<?php
|
||||
// This file is included fom collection_edit.php and collection_set_category.php
|
||||
|
||||
// find current number of themes used
|
||||
$themecount=1;
|
||||
foreach($collection as $key=>$value)
|
||||
{
|
||||
if (substr($key,0,5)=="theme")
|
||||
{
|
||||
if ($value=="")
|
||||
{break 1;}
|
||||
else
|
||||
{
|
||||
if (substr($key,5)=="")
|
||||
{
|
||||
$themecount=1;
|
||||
$orig_themecount=$themecount;
|
||||
}
|
||||
else
|
||||
{
|
||||
$themecount=substr($key,5);
|
||||
$orig_themecount=$themecount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// find number of theme columns
|
||||
foreach($collection as $key=>$value)
|
||||
{
|
||||
if (substr($key,0,5)=="theme")
|
||||
{$themecolumns=substr($key,5);}
|
||||
}
|
||||
if(!hook("overridethemesel"))
|
||||
{
|
||||
if (checkperm("h") && $enable_themes)
|
||||
{ # Only users with the 'h' permission can publish public collections as themes.
|
||||
?>
|
||||
<input type=hidden name="addlevel" id="addlevel" value=""/>
|
||||
<?php
|
||||
if (getval("addlevel","")=="yes")
|
||||
{$themecount++;}
|
||||
$lastselected=false;
|
||||
# Theme category levels
|
||||
for ($i=1;$i<=$themecount;$i++)
|
||||
{
|
||||
if ($theme_category_levels>=$i)
|
||||
{
|
||||
if ($i==1)
|
||||
{$themeindex="";}
|
||||
else
|
||||
{$themeindex=$i;}
|
||||
|
||||
$themearray=array();
|
||||
for($y=0;$y<$i-1;$y++)
|
||||
{
|
||||
if ($y==0)
|
||||
{
|
||||
$themearray[]=$collection["theme"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$themearray[]=$collection["theme".($y+1)];
|
||||
}
|
||||
}
|
||||
$themes=get_theme_headers($themearray);
|
||||
?>
|
||||
<div class="Question">
|
||||
<label for="theme<?php echo $themeindex?>"><?php echo $lang["themecategory"] . " ".$themeindex ?></label>
|
||||
<?php
|
||||
if (count($themes)>0)
|
||||
{?>
|
||||
<select class="stdwidth" name="theme<?php echo $themeindex?>" id="theme<?php echo $themeindex?>" <?php if ($theme_category_levels>=$themeindex) { ?>onchange="if (document.getElementById('theme<?php echo $themeindex?>').value!=='') {document.getElementById('addlevel').value='yes'; return CentralSpacePost(jQuery('#collectionform')[0])} else {document.getElementById('redirect').value='';return CentralSpacePost(jQuery('#collectionform')[0])}"<?php } ?>>
|
||||
<option value=""><?php echo $lang["select"]?></option>
|
||||
<?php
|
||||
$lastselected=false;
|
||||
for ($n=0;$n<count($themes);$n++)
|
||||
{ ?>
|
||||
<option <?php if ($collection["theme".$themeindex]==$themes[$n]) { ?>selected<?php } ?>><?php echo htmlspecialchars($themes[$n]) ?></option>
|
||||
<?php
|
||||
if ($collection["theme".$themeindex]==$themes[$n] && $i==$orig_themecount)
|
||||
{$lastselected=true;} ?>
|
||||
<?php
|
||||
} ?>
|
||||
</select>
|
||||
<?php
|
||||
if (getval("addlevel","")!="yes" && $lastselected)
|
||||
{$themecount++;}?>
|
||||
<div class="clearerleft"> </div>
|
||||
<label><?php echo $lang["newcategoryname"]?></label>
|
||||
<?php
|
||||
} //end conditional selector ?>
|
||||
<input type=text class="medwidth" name="newtheme<?php echo $themeindex?>" id="newtheme<?php echo $themeindex?>" value="" maxlength="100">
|
||||
<?php
|
||||
if ($themecount!=1)
|
||||
{?>
|
||||
<input type=button class="medcomplementwidth" value="<?php echo $lang['save'];?>" style="display:inline;" onclick="document.getElementById('addlevel').value='yes';return CentralSpacePost(jQuery('#collectionform')[0])"/>
|
||||
<?php
|
||||
} ?>
|
||||
<?php
|
||||
if ($themecount==1)
|
||||
{?>
|
||||
<input type=button class="medcomplementwidth" value="<?php echo $lang['add'];?>" style="display:inline;" onclick="if (document.getElementById('newtheme<?php echo $themeindex?>').value==''){alert('<?php echo $lang["collectionsnothemeselected"] ?>');return false;}document.getElementById('addlevel').value='yes';return CentralSpacePost(jQuery('#collectionform')[0])"/>
|
||||
<?php
|
||||
}?>
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// in case a user can edit collections but doesn't have themes enabled, preserve them
|
||||
for ($i=1;$i<=$themecount;$i++)
|
||||
{
|
||||
if ($theme_category_levels>=$i)
|
||||
{
|
||||
if ($i==1)
|
||||
{$themeindex="";}
|
||||
else
|
||||
{$themeindex=$i;} ?>
|
||||
<input type=hidden name="theme<?php echo $themeindex?>" value="<?php echo htmlspecialchars($collection["theme".$themeindex]) ?>">
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -741,17 +741,12 @@ $use_recent_as_home=false;
|
|||
|
||||
# Show images along with theme category headers (image selected is the most popular within the theme category)
|
||||
$theme_images=true;
|
||||
$theme_images_number=1; # How many to auto-select (if none chosen manually)
|
||||
$theme_images_number = 6; # How many to auto-select (if none chosen manually). Smart FCs only display one.
|
||||
$theme_images_align_right=false; # Align theme images to the right on the themes page? (particularly useful when there are multiple theme images)
|
||||
$show_theme_collection_stats=false; # Show count of themes and resources in theme category
|
||||
|
||||
# How many levels of theme category to show.
|
||||
# If this is set to more than one, a dropdown box will appear to allow browsing of theme sub-levels
|
||||
$theme_category_levels=1;
|
||||
|
||||
# Theme direct jump mode
|
||||
# If set, sub category levels DO NOT appear and must be directly linked to using custom home panels or top navigation items (or similar).
|
||||
# $theme_category_levels must be greater than 1.
|
||||
$theme_direct_jump=false;
|
||||
|
||||
#Force Collections lists on the Themes page to be in Descending order.
|
||||
|
@ -1215,7 +1210,6 @@ $save_as=false;
|
|||
|
||||
# Allow resources to be e-mailed / shared (internally and externally)
|
||||
$allow_share=true;
|
||||
$enable_theme_category_sharing=false;
|
||||
|
||||
# Always create a collection when sharing an individual resource via email
|
||||
$share_resource_as_collection=false;
|
||||
|
@ -1267,10 +1261,6 @@ $checkbox_ordered_vertically=true;
|
|||
# When batch uploading, show the 'add resources to collection' selection box
|
||||
$enable_add_collection_on_upload=true;
|
||||
|
||||
# When batch uploading, allow users to set collection public as part of upload process
|
||||
# also allows assignment to themes for users who have appropriate privileges
|
||||
$enable_public_collection_on_upload=false;
|
||||
|
||||
# Batch Uploads, default is "Add to New Collection". Turn off to default to "Do not Add to Collection"
|
||||
$upload_add_to_new_collection=true;
|
||||
# Batch Uploads, enables the "Add to New Collection" option.
|
||||
|
@ -1982,20 +1972,20 @@ $enable_theme_breadcrumbs = true;
|
|||
$show_collection_name = false;
|
||||
|
||||
# Themes simple view - option to show featured collection categories and featured collections (themes) as basic tiles wih no images.
|
||||
# Can be tested or used for custom link by adding querystring parameter simpleview=true to themes.php e.g. pages/themes.php?simpleview=true
|
||||
# Can be tested or used for custom link by adding querystring parameter simpleview=true to collections_featured.php e.g. pages/collections_featured.php?simpleview=true
|
||||
# NOTE: only works with $themes_category_split_pages=true;
|
||||
$themes_simple_view=false;
|
||||
# Option to show images on featured collection and featured collection category tiles if $themes_simple_view is enabled
|
||||
$themes_simple_images=true;
|
||||
|
||||
# Option to show single home slideshow image on featured collection page (themes.php) if $themes_simple_view is enabled
|
||||
# Option to show single home slideshow image on featured collection page (collections_featured.php) if $themes_simple_view is enabled
|
||||
$featured_collection_static_bg = false;
|
||||
|
||||
# Display theme categories as links, and themes on separate pages?
|
||||
$themes_category_split_pages=false;
|
||||
# Display breadcrumb-style theme parent links instead of "Subcategories"
|
||||
$themes_category_split_pages_parents=false;
|
||||
# Include "Themes" root node before theme level crumbs to add context and link to themes.php
|
||||
# Include "Themes" root node before theme level crumbs to add context and link to collections_featured.php
|
||||
$themes_category_split_pages_parents_root_node=true;
|
||||
# Navigate to deeper levels in theme category trees? Set to false to link to matching resources directly.
|
||||
$themes_category_navigate_levels=false;
|
||||
|
@ -2177,9 +2167,7 @@ $staticsync_whitelist_folders = array();
|
|||
# Maximum number of files to process per execution of staticsync.php
|
||||
$staticsync_max_files = 10000;
|
||||
$staticsync_autotheme=true; # Automatically create themes based on the first and second levels of the sync folder structure.
|
||||
# Allow unlimited theme levels to be created based on the folder structure.
|
||||
# Script will output a new $theme_category_levels number which must then be updated in config.php
|
||||
$staticsync_folder_structure=false;
|
||||
|
||||
# Mapping extensions to resource types for sync'd files
|
||||
# Format: staticsync_extension_mapping[resource_type]=array("extension 1","extension 2");
|
||||
$staticsync_extension_mapping_default=1;
|
||||
|
|
|
@ -20,7 +20,6 @@ $home_slideshow_height=1080;
|
|||
|
||||
$themes_simple_view=true;
|
||||
$themes_category_split_pages=true;
|
||||
$theme_category_levels=8;
|
||||
|
||||
$stemming=true;
|
||||
$case_insensitive_username=true;
|
||||
|
|
|
@ -84,30 +84,31 @@ function tile_select($tile_type,$tile_style,$tile,$tile_id,$tile_width,$tile_hei
|
|||
|
||||
function tile_config_themeselector($tile,$tile_id,$tile_width,$tile_height)
|
||||
{
|
||||
global $lang,$pagename,$baseurl_short,$dash_tile_shadows, $theme_category_levels, $theme_direct_jump;
|
||||
global $lang,$pagename,$baseurl_short,$dash_tile_shadows, $theme_direct_jump;
|
||||
|
||||
$url = "{$baseurl_short}pages/collections_featured.php";
|
||||
?>
|
||||
<div class="featuredcollectionselector HomePanel DashTile DashTileDraggable allUsers" tile="<?php echo $tile["ref"]?>" id="<?php echo str_replace("contents_","",$tile_id);?>" >
|
||||
<div id="<?php echo $tile_id?>" class="HomePanelThemes HomePanelDynamicDash HomePanelIN <?php echo ($dash_tile_shadows)? "TileContentShadow":""; ?>" >
|
||||
<span class="theme-icon"></span>
|
||||
<a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/themes.php"><h2><?php echo $lang["themes"]?></h2></a>
|
||||
<a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/collections_featured.php"><h2><?php echo $lang["themes"]?></h2></a>
|
||||
<p>
|
||||
<select id="themeselect" onChange="CentralSpaceLoad(this.value,true);">
|
||||
<option value=""><?php echo $lang["select"] ?></option>
|
||||
<?php
|
||||
$headers=get_theme_headers();
|
||||
for ($n=0;$n<count($headers);$n++)
|
||||
{
|
||||
?>
|
||||
<option value="<?php echo $baseurl_short?>pages/themes.php?theme1=<?php echo urlencode($headers[$n])?>"><?php echo htmlspecialchars(i18n_get_translated(str_replace("*","",$headers[$n]))); ?></option>
|
||||
<?php
|
||||
}
|
||||
foreach(get_featured_collection_categories(0, array()) as $header)
|
||||
{
|
||||
?>
|
||||
<option value="<?php echo generateURL($url, array("parent" => $header["ref"])); ?>"><?php echo htmlspecialchars(i18n_get_translated($header["name"])); ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
if($theme_category_levels == 1 || !$theme_direct_jump)
|
||||
if(!$theme_direct_jump)
|
||||
{
|
||||
?>
|
||||
<a id="themeviewall" onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/themes.php"><?php echo LINK_CARET ?><?php echo $lang["viewall"] ?></a>
|
||||
<a id="themeviewall" onClick="return CentralSpaceLoad(this,true);" href="<?php echo $url; ?>"><?php echo LINK_CARET; ?><?php echo $lang["viewall"]; ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
@ -119,6 +120,7 @@ function tile_config_themeselector($tile,$tile_id,$tile_width,$tile_height)
|
|||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
function tile_config_custom($tile,$tile_id,$tile_width,$tile_height)
|
||||
{
|
||||
global $lang;
|
||||
|
@ -678,20 +680,9 @@ function tile_featured_collection_multi($tile, $tile_id, $tile_width,$tile_heigh
|
|||
$link_parts = explode('?', $tile['link']);
|
||||
parse_str(str_replace('&', '&', $link_parts[1]), $link_parts);
|
||||
|
||||
$resources = array();
|
||||
$featured_collection_categories = array();
|
||||
|
||||
foreach($link_parts as $link_part_key => $link_part_value)
|
||||
{
|
||||
if(false === strpos($link_part_key, 'theme'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$featured_collection_categories[] = $link_part_value;
|
||||
}
|
||||
|
||||
foreach(get_themes($featured_collection_categories, true) as $theme)
|
||||
$parent = (isset($link_parts["parent"]) ? validate_collection_parent(array("parent" => (int) $link_parts["parent"])) : 0);
|
||||
$resources = array();
|
||||
foreach(get_featured_collection_categories($parent, array()) as $theme)
|
||||
{
|
||||
$resources = array_merge(
|
||||
$resources,
|
||||
|
|
|
@ -967,33 +967,6 @@ function CheckDBStruct($path,$verbose=false)
|
|||
}
|
||||
##########
|
||||
|
||||
##########
|
||||
## RS-specific mod:
|
||||
# add theme columns to collection table as needed.
|
||||
global $theme_category_levels;
|
||||
if ($table=="collection")
|
||||
{
|
||||
for ($m=1;$m<=$theme_category_levels;$m++)
|
||||
{
|
||||
if ($m==1){$themeindex="";}else{$themeindex=$m;}
|
||||
# Look for this column in the existing columns.
|
||||
$found=false;
|
||||
|
||||
for ($n=0;$n<count($existing);$n++)
|
||||
{
|
||||
if ("theme".$themeindex==$existing[$n]["Field"]) {$found=true;}
|
||||
}
|
||||
if (!$found)
|
||||
{
|
||||
# Add this column.
|
||||
$sql="alter table $table add column ";
|
||||
$sql.="theme".$themeindex . " VARCHAR(100)";
|
||||
sql_query($sql,false,-1,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##########
|
||||
if (file_exists($path . "/" . $file))
|
||||
{
|
||||
$f=fopen($path . "/" . $file,"r");
|
||||
|
@ -1018,6 +991,7 @@ function CheckDBStruct($path,$verbose=false)
|
|||
// - If target column is of type text, update
|
||||
// - If target column is of type varchar and currently int, update (e.g. the 'archive' column in collection_savedsearch moved from a single state to a multiple)
|
||||
// - If target column is of type longtext and currently is text
|
||||
|
||||
if(
|
||||
(count($matchbase) == 3 && count($matchexisting) == 3 && $matchbase[1] == $matchexisting[1] && $matchbase[2] > $matchexisting[2])
|
||||
|| (stripos($basecoltype, "text") !== false && stripos($existingcoltype, "text") === false)
|
||||
|
@ -1130,3 +1104,32 @@ function sql_limit($offset, $rows)
|
|||
|
||||
return $limit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query helper function for the WHERE clause to avoid repetitive checks when value might be NULL or an actual value
|
||||
*
|
||||
* @param string $v Non-null value
|
||||
* @param boolean $cond Condition to use IS NULL or to use the escaped value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function sql_is_null_or_eq_val(string $v, bool $cond)
|
||||
{
|
||||
return ($cond ? "IS NULL" : "= '" . escape_check($v) . "'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query helper function for insert/update statements to avoid repetitive checks when value might be NULL or an actual value.
|
||||
* Helps keeping database level data as expected (ie. uses an actual NULL value when there's no data as opposed to empty strings)
|
||||
*
|
||||
* @param string $v Non-null value
|
||||
* @param boolean $cond Condition to set it to NULL or to use the escaped value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function sql_null_or_val(string $v, bool $cond)
|
||||
{
|
||||
return ($cond ? "NULL" : "'" . escape_check($v) . "'");
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
// current upgrade level of ResourceSpace (used for migration scripts, will set sysvar using this if not already defined)
|
||||
define('SYSTEM_UPGRADE_LEVEL', 12);
|
||||
define('SYSTEM_UPGRADE_LEVEL', 15);
|
||||
|
||||
// PHP VERSION AND MINIMUM SUPPORTED
|
||||
if (!defined('PHP_VERSION_ID'))
|
||||
|
@ -186,6 +186,8 @@ define('HOME_ICON','<i aria-hidden="true" class="fa fa-fw fa-home"></i> ');
|
|||
define('SEARCH_ICON', '<i class="fa fa-search" aria-hidden="true"></i> ');
|
||||
define('ICON_EDIT', '<i class="fa fa-pencil" aria-hidden="true"></i> ');
|
||||
define('ICON_REMOVE', '<i class="fa fa-minus-circle" aria-hidden="true"></i> ');
|
||||
define('ICON_FOLDER', '<i class="fas fa-folder" aria-hidden="true"></i> ');
|
||||
define('ICON_CUBE', '<i class="fas fa-cube" aria-hidden="true"></i> ');
|
||||
|
||||
define ('NODE_TOKEN_PREFIX','@@');
|
||||
define ('NODE_TOKEN_OR','|');
|
||||
|
@ -309,10 +311,22 @@ $corefields = array(
|
|||
)
|
||||
);
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
// COLLECTIONS
|
||||
// ----------------------------------------------
|
||||
define("COLLECTION_TYPE_STANDARD", 0);
|
||||
define("COLLECTION_TYPE_UPLOAD", 1); # for collections used in upload then edit mode
|
||||
define("COLLECTION_TYPE_SELECTION", 2); # selecting resources to be edited in batch for the active user (allowed only one per user)
|
||||
|
||||
define("COLLECTION_TYPE_FEATURED", 3); # featured collections (used for both parents and children featured collections)
|
||||
define("COLLECTION_TYPE_PUBLIC", 4); # public collections
|
||||
$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS = array(
|
||||
"no_image" => 0,
|
||||
"most_popular_image" => 1,
|
||||
"most_popular_images" => 10,
|
||||
"manual" => 100,
|
||||
);
|
||||
$COLLECTION_PUBLIC_TYPES = array(COLLECTION_TYPE_PUBLIC, COLLECTION_TYPE_FEATURED);
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
|
|
|
@ -187,24 +187,28 @@ if ($on_upload || $ref<0)
|
|||
}
|
||||
|
||||
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"];
|
||||
}
|
||||
else{
|
||||
if (strlen($list[$n]["theme"])>0){
|
||||
$accessmode= $lang["theme"];
|
||||
}
|
||||
else{
|
||||
$accessmode= $lang["public"];
|
||||
}
|
||||
{
|
||||
$colusername = $list[$n]['fullname'];
|
||||
|
||||
if(!hook('collectionaccessmode'))
|
||||
{
|
||||
switch($list[$n]["type"])
|
||||
{
|
||||
case COLLECTION_TYPE_PUBLIC:
|
||||
$accessmode = $lang["public"];
|
||||
break;
|
||||
|
||||
case COLLECTION_TYPE_FEATURED:
|
||||
$accessmode = $lang["theme"];
|
||||
break;
|
||||
|
||||
case COLLECTION_TYPE_STANDARD:
|
||||
default:
|
||||
$accessmode = $lang["private"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#remove smart collections as they cannot be uploaded to.
|
||||
|
@ -308,39 +312,7 @@ if ($on_upload || $ref<0)
|
|||
<div name="collectionname" id="collectionname" <?php if ($upload_add_to_new_collection_opt){ ?> style="display:block;"<?php } else { ?> style="display:none;"<?php } ?>>
|
||||
<label for="entercolname"><?php echo $lang["collectionname"]?><?php if ($upload_collection_name_required){?><sup>*</sup><?php } ?></label>
|
||||
<input type=text id="entercolname" name="entercolname" class="stdwidth" value='<?php echo htmlentities(stripslashes(getval("entercolname","")), ENT_QUOTES);?>'>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ($enable_public_collection_on_upload && ($enable_public_collections || checkperm('h')) && !checkperm('b'))
|
||||
{ ?>
|
||||
<label for="public"><?php echo $lang["access"]?></label>
|
||||
<select id="public" name="public" class="shrtwidth" <?php
|
||||
if (checkperm('h')){ // if the user can add to a theme, include the code to toggle the theme selector
|
||||
?>onchange="if(jQuery(this).val()==1){jQuery('#themeselect').fadeIn();resetThemeLevels();} else {jQuery('#themeselect').fadeOut(); clearThemeLevels();}"<?php
|
||||
}
|
||||
?>>
|
||||
<option value="0" selected><?php echo $lang["private"]?></option>
|
||||
<option value="1"><?php echo $lang["public"]?></option>
|
||||
</select>
|
||||
|
||||
|
||||
<?php
|
||||
if (checkperm('h')){
|
||||
// if the user can add to a theme, include the theme selector
|
||||
?>
|
||||
<!-- select theme if collection is public -->
|
||||
<script type="text/javascript" src="<?php echo $baseurl_short ?>lib/js/update_theme_levels.js"></script>
|
||||
<input type="hidden" name="themestring" id="themestring" value="" />
|
||||
<div id='themeselect' class='themeselect' style="display:none">
|
||||
<?php
|
||||
include_once("ajax/themelevel_add.php");
|
||||
?>
|
||||
</div>
|
||||
<!-- end select theme -->
|
||||
<?php
|
||||
} // end if checkperm h
|
||||
} // end if public collections enabled
|
||||
?>
|
||||
</div>
|
||||
</div> <!-- end collectioninfo -->
|
||||
</div> <!-- end question_collectionadd -->
|
||||
<?php
|
||||
|
|
|
@ -194,15 +194,7 @@ $additional_title_pages=array(hook("additional_title_pages_array"));
|
|||
// place page titles
|
||||
else if (in_array($pagename,$general_title_pages)){
|
||||
|
||||
if ($pagename=="themes"){
|
||||
$pagetitle=$lang['themes'];
|
||||
for ($n=0;$n<$theme_category_levels;$n++){
|
||||
if (getval("theme".$n,"")!=""){
|
||||
$pagetitle.=" / ".getval("theme".$n,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isset($lang[$pagename])){
|
||||
if (isset($lang[$pagename])){
|
||||
$pagetitle=$lang[$pagename];
|
||||
}
|
||||
else if (isset($lang['action-'.$pagename])){
|
||||
|
|
|
@ -2741,7 +2741,7 @@ function get_slideshow_files_data()
|
|||
$homeanim_folder_path = dirname(__DIR__) . "/{$homeanim_folder}";
|
||||
|
||||
$query = "SELECT ref, resource_ref, homepage_show, featured_collections_show, login_show FROM slideshow";
|
||||
$slideshow_records = sql_query($query,"slideshow");
|
||||
$slideshow_records = sql_query($query, "slideshow");
|
||||
|
||||
$slideshow_files = array();
|
||||
|
||||
|
@ -4167,4 +4167,4 @@ function trim_filename(string $s)
|
|||
$s .= ".{$extension}";
|
||||
|
||||
return $s;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
|
||||
hook ("preheaderoutput");
|
||||
|
||||
$k=getvalescaped("k","");
|
||||
if(!isset($internal_share_access))
|
||||
{
|
||||
// Set a flag for logged in users if $external_share_view_as_internal is set and logged on user is accessing an external share
|
||||
$internal_share_access = ($k!="" && $external_share_view_as_internal && isset($is_authenticated) && $is_authenticated);
|
||||
$internal_share_access = internal_share_access();
|
||||
}
|
||||
|
||||
$logout=getvalescaped("logout","");
|
||||
|
@ -298,7 +297,7 @@ if (($pagename!="preview" || $preview_header_footer) && $pagename!="preview_all"
|
|||
|
||||
<?php
|
||||
$homepage_url=$baseurl."/pages/".$default_home_page;
|
||||
if ($use_theme_as_home){$homepage_url=$baseurl."/pages/themes.php";}
|
||||
if($use_theme_as_home) { $homepage_url = $baseurl."/pages/collections_featured.php"; }
|
||||
if ($use_recent_as_home){$homepage_url=$baseurl."/pages/search.php?search=".urlencode('!last'.$recent_search_quantity);}
|
||||
if ($pagename=="login" || $pagename=="user_request" || $pagename=="user_password"){$homepage_url=$baseurl."/index.php";}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
<?php if (!hook("replacethemelink")) { ?>
|
||||
<?php if (checkperm("s") && $enable_themes && !$theme_direct_jump && $themes_navlink) { ?>
|
||||
<li class="HeaderLink">
|
||||
<a href="<?php echo $baseurl?>/pages/themes.php" onClick="return CentralSpaceLoad(this,true);">
|
||||
<?php echo FEATURED_COLLECTION_ICON . $lang["themes"]?>
|
||||
<a href="<?php echo $baseurl?>/pages/collections_featured.php" onClick="return CentralSpaceLoad(this,true);">
|
||||
<?php echo FEATURED_COLLECTION_ICON . $lang["themes"]; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
|
|
@ -356,8 +356,7 @@ function is_parent_node($ref)
|
|||
|
||||
|
||||
/**
|
||||
* Determine how many level deep a node is. Useful for knowing how much
|
||||
* indent a node
|
||||
* Determine how many level deep a node is. Useful for knowing how much to indent a node
|
||||
*
|
||||
* @param integer $ref Node ref
|
||||
*
|
||||
|
|
|
@ -1177,7 +1177,7 @@ function render_actions(array $collection_data, $top_actions = true, $two_line =
|
|||
submitted: true,
|
||||
ref: '<?php echo $collection_data["ref"]; ?>',
|
||||
name: <?php echo json_encode($collection_data["name"]); ?>,
|
||||
public: '<?php echo $collection_data["public"]; ?>',
|
||||
public: '<?php echo ($collection_data["type"] == COLLECTION_TYPE_PUBLIC ? 1 : 0); ?>',
|
||||
deleteall: 'on',
|
||||
<?php echo generateAjaxToken("delete_all_in_collection"); ?>
|
||||
};
|
||||
|
@ -1371,14 +1371,24 @@ function render_split_text_question($label, $inputs = array(), $additionaltext="
|
|||
/**
|
||||
* render_dropdown_question - Used to display a question with a dropdown selector
|
||||
*
|
||||
* @param string $label Label of question
|
||||
* @param string $input name of input field
|
||||
* @param array $options Array of options (value and text pairs) (eg. array('pixelwidthmin'=>'From','pixelwidthmin'=>'To')
|
||||
* @param string $label Label of question
|
||||
* @param string $inputname Name of input field
|
||||
* @param array $options Array of options (value and text pairs) (eg. array('pixelwidthmin'=>'From','pixelwidthmin'=>'To')
|
||||
* @param string $current The current selected value
|
||||
* @param string $extra Extra attributes used on the selector element
|
||||
* @param array $ctx Rendering context. Should be used to inject different elements (e.g set the div class, add onchange for select)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function render_dropdown_question($label, $inputname, $options = array(), $current="", $extra="")
|
||||
function render_dropdown_question($label, $inputname, $options = array(), $current="", $extra="", array $ctx = array())
|
||||
{
|
||||
$div_class = array("Question");
|
||||
if(isset($ctx["div_class"]) && is_array($ctx["div_class"]) && !empty($ctx["div_class"]))
|
||||
{
|
||||
$div_class = array_merge($div_class, $ctx["div_class"]);
|
||||
}
|
||||
?>
|
||||
<div class="Question" id = "pixelwidth">
|
||||
<div class="<?php echo implode(" ", $div_class); ?>">
|
||||
<label><?php echo $label; ?></label>
|
||||
<select name="<?php echo $inputname?>" id="<?php echo $inputname?>" <?php echo $extra; ?>>
|
||||
<?php
|
||||
|
@ -1390,10 +1400,10 @@ function render_dropdown_question($label, $inputname, $options = array(), $curre
|
|||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<div class="clearerleft"></div>
|
||||
</div>
|
||||
<div class="clearerleft"> </div>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2288,6 +2298,7 @@ function render_date_range_field($name,$value,$forsearch=true,$autoupdate=false,
|
|||
*
|
||||
* @param array $links List of link "objects" that create the trail
|
||||
* @param string $pre_links Pre-rendered links in HTML form
|
||||
* @param string $class Extra classes for the main container div
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -2324,7 +2335,7 @@ function renderBreadcrumbs(array $links, $pre_links = '', $class = '')
|
|||
}
|
||||
|
||||
if ($anchor)
|
||||
{ ?><a href="<?php echo htmlspecialchars($links[$i]['href']); ?>" onClick="return CentralSpaceLoad(this, true);"><?php } ?><span><?php echo htmlspecialchars(htmlspecialchars_decode($links[$i]['title'])); ?></span><?php if ($anchor) { ?></a><?php }
|
||||
{ ?><a href="<?php echo htmlspecialchars($links[$i]['href']); ?>" onclick="return CentralSpaceLoad(this, true);"><?php } ?><span><?php echo htmlspecialchars(htmlspecialchars_decode($links[$i]['title'])); ?></span><?php if ($anchor) { ?></a><?php }
|
||||
if (isset($links[$i]['help']))
|
||||
{
|
||||
render_help_link($links[$i]['help']);
|
||||
|
@ -2342,29 +2353,35 @@ function renderBreadcrumbs(array $links, $pre_links = '', $class = '')
|
|||
/**
|
||||
* Render a blank tile used for call to actions (e.g: on featured collections, a tile for creating new collections)
|
||||
*
|
||||
* @param string $link URL
|
||||
* @param string $url URL
|
||||
* @param array $ctx Rendering options determined by the outside context
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function renderCallToActionTile($link)
|
||||
function render_new_featured_collection_cta(string $url, array $ctx)
|
||||
{
|
||||
global $themes_simple_view;
|
||||
global $collection_allow_creation;
|
||||
|
||||
if(!$themes_simple_view || checkperm('b'))
|
||||
if('' === $url)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if('' === $link)
|
||||
$html_tile_class = array("FeaturedSimplePanel", "HomePanel", "DashTile", "FeaturedSimpleTile", "FeaturedCallToActionTile");
|
||||
$html_contents_h2_class = array();
|
||||
|
||||
$full_width = (isset($ctx["full_width"]) && $ctx["full_width"]);
|
||||
if($full_width)
|
||||
{
|
||||
return;
|
||||
$html_tile_class[] = "FullWidth";
|
||||
$html_contents_h2_class[] = "MarginZeroAuto";
|
||||
}
|
||||
?>
|
||||
<div id="FeaturedSimpleTile" class="FeaturedSimplePanel HomePanel DashTile FeaturedSimpleTile FeaturedCallToActionTile">
|
||||
<a href="<?php echo $link; ?>" onclick="return ModalLoad(this, true, true);" class="">
|
||||
<div id="FeaturedSimpleTile" class="<?php echo implode(" ", $html_tile_class); ?>">
|
||||
<a href="<?php echo $url; ?>" onclick="return ModalLoad(this, true, true);">
|
||||
<div class="FeaturedSimpleTileContents">
|
||||
<div class="FeaturedSimpleTileText">
|
||||
<h2><span class='fas fa-plus-circle'></span></h2>
|
||||
<h2 class="<?php echo implode(" ", $html_contents_h2_class); ?>"><span class='fas fa-plus-circle'></span></h2>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
|
@ -4100,6 +4117,489 @@ function display_size_option($sizeID, $sizeName, $fordropdown=true)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render the featured collection category selector
|
||||
*
|
||||
* @param integer $parent Parent collection ref
|
||||
* @param array $context Contextual data (e.g depth level to render or the current branch path)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function render_featured_collection_category_selector(int $parent, array $context)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
// If this information is missing, that's an unrecoverable error, the developer should really make sure this information is provided
|
||||
$collection = $context["collection"]; # as returned by get_collection()
|
||||
$depth = (int) $context["depth"];
|
||||
$current_branch_path = $context["current_branch_path"]; # as returned by get_featured_collection_category_branch_by_leaf()
|
||||
|
||||
$featured_collection_categories = get_featured_collection_categories($parent, array());
|
||||
if(empty($featured_collection_categories))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$html_selector_name = "selected_featured_collection_category_{$depth}";
|
||||
$html_question_label_txt = $lang["themecategory"] . ($depth == 0 ? "" : " {$depth}");
|
||||
?>
|
||||
<div class="Question">
|
||||
<label for="<?php echo $html_selector_name; ?>"><?php echo $html_question_label_txt; ?></label>
|
||||
<?php
|
||||
$next_level_parent = null;
|
||||
?>
|
||||
<select id="<?php echo $html_selector_name; ?>" class="stdwidth" name="<?php echo $html_selector_name; ?>"
|
||||
onchange="document.getElementsByName('update_parent')[0].value = 'true'; document.getElementById('redirect').value = ''; CentralSpacePost(jQuery('#collectionform')[0]);">
|
||||
<option value="0"><?php echo $lang["select"]; ?></option>
|
||||
<?php
|
||||
foreach($featured_collection_categories as $fc_category)
|
||||
{
|
||||
// Never show as an option the FC you're editing
|
||||
if($fc_category["ref"] == $collection["ref"])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$html_attr_selected = "";
|
||||
if(isset($current_branch_path[$depth]) && $fc_category["ref"] == $current_branch_path[$depth]["ref"])
|
||||
{
|
||||
$html_attr_selected = "selected";
|
||||
$next_level_parent = $fc_category["ref"];
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo $fc_category["ref"]; ?>" <?php echo $html_attr_selected; ?>><?php echo htmlspecialchars(i18n_get_translated($fc_category["name"])); ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="clearerleft"></div>
|
||||
</div>
|
||||
<?php
|
||||
if(is_null($next_level_parent))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$context["depth"] = ++$depth;
|
||||
return render_featured_collection_category_selector($next_level_parent, $context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render featured collections (as tiles on the collections_featured.php page)
|
||||
*
|
||||
* @param array $ctx Context data to allow caller code to decide rendering requirements
|
||||
* @param array $items List of items to render (featured collection category, actual collection or smart collection)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function render_featured_collections(array $ctx, array $items)
|
||||
{
|
||||
global $baseurl_short, $lang, $k, $themes_simple_images, $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS, $theme_images_number,
|
||||
$themes_simple_view;
|
||||
|
||||
$is_smart_featured_collection = (isset($ctx["smart"]) ? (bool) $ctx["smart"] : false);
|
||||
$general_url_params = (isset($ctx["general_url_params"]) && is_array($ctx["general_url_params"]) ? $ctx["general_url_params"] : array());
|
||||
|
||||
foreach($items as $fc)
|
||||
{
|
||||
$render_ctx = $ctx;
|
||||
$is_featured_collection_category = is_featured_collection_category($fc);
|
||||
$is_featured_collection = (!$is_featured_collection_category && !$is_smart_featured_collection);
|
||||
|
||||
$tool_edit = array(
|
||||
"href" => generateURL("{$baseurl_short}pages/collection_edit.php", array("ref" => $fc["ref"])),
|
||||
"text" => $lang['action-edit'],
|
||||
"modal_load" => true,
|
||||
);
|
||||
|
||||
// Prepare FC images
|
||||
$thumbnail_selection_method = $fc["thumbnail_selection_method"];
|
||||
$show_images = ($themes_simple_view && in_array($thumbnail_selection_method, $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS) && $thumbnail_selection_method != $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["no_image"]);
|
||||
unset($fc_resources);
|
||||
if($themes_simple_images && $show_images)
|
||||
{
|
||||
$fc_resources = get_featured_collection_resources(
|
||||
$fc,
|
||||
array(
|
||||
"smart" => $is_smart_featured_collection,
|
||||
"limit" => ($thumbnail_selection_method == $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_images"] ? $theme_images_number : 1),
|
||||
));
|
||||
$fc_images = generate_featured_collection_image_urls($fc_resources, "pre");
|
||||
|
||||
if(!empty($fc_images))
|
||||
{
|
||||
$render_ctx["images"] = $fc_images;
|
||||
}
|
||||
}
|
||||
|
||||
// Featured collection default tools
|
||||
if($is_featured_collection && checkPermission_dashmanage())
|
||||
{
|
||||
$render_ctx["tools"][] = array(
|
||||
"href" => generateURL(
|
||||
"{$baseurl_short}pages/dash_tile.php",
|
||||
array(
|
||||
'create' => 'true',
|
||||
'tltype' => 'srch',
|
||||
'title' => "{$fc['name']}",
|
||||
'freetext' => 'true',
|
||||
'tile_audience' => 'false',
|
||||
'all_users' => 1,
|
||||
'promoted_resource' => 'true',
|
||||
'link' => "{$baseurl_short}pages/search.php?search=!collection{$fc['ref']}",
|
||||
)
|
||||
),
|
||||
"text" => $lang['add_to_dash']);
|
||||
}
|
||||
|
||||
if($is_featured_collection && collection_readable($fc['ref']))
|
||||
{
|
||||
$render_ctx["tools"][] = array(
|
||||
"text" => $lang['action-select'],
|
||||
"custom_onclick" => "return ChangeCollection({$fc['ref']}, '');");
|
||||
}
|
||||
|
||||
if($is_featured_collection && collection_writeable($fc['ref']))
|
||||
{
|
||||
$render_ctx["tools"][] = $tool_edit;
|
||||
}
|
||||
|
||||
|
||||
if($is_featured_collection_category && !$is_smart_featured_collection)
|
||||
{
|
||||
global $enable_theme_category_edit;
|
||||
|
||||
$fc_category_url = generateURL("{$baseurl_short}pages/collections_featured.php", $general_url_params, array("parent" => $fc["ref"]));
|
||||
|
||||
$render_ctx["href"] = $fc_category_url;
|
||||
$render_ctx["icon"] = ICON_FOLDER;
|
||||
$render_ctx["tools"] = array();
|
||||
|
||||
if(checkPermission_dashmanage())
|
||||
{
|
||||
$render_ctx["tools"][] = array(
|
||||
"href" => generateURL(
|
||||
"{$baseurl_short}pages/dash_tile.php",
|
||||
array(
|
||||
'create' => 'true',
|
||||
'tltype' => 'fcthm',
|
||||
'tlstyle' => 'thmbs',
|
||||
'title' => "{$fc['name']}",
|
||||
'freetext' => 'true',
|
||||
'tile_audience' => 'false',
|
||||
'promoted_resource' => 'true',
|
||||
'link' => $fc_category_url
|
||||
)
|
||||
),
|
||||
"text" => $lang["add_to_dash"]);
|
||||
}
|
||||
|
||||
if(checkperm("h") && allow_featured_collection_share($fc))
|
||||
{
|
||||
$render_ctx["tools"][] = array(
|
||||
"href" => generateURL("{$baseurl_short}pages/collection_share.php", array("ref" => $fc["ref"])),
|
||||
"text" => $lang["share"]);
|
||||
}
|
||||
|
||||
if($enable_theme_category_edit && checkperm("t"))
|
||||
{
|
||||
$render_ctx["tools"][] = $tool_edit;
|
||||
}
|
||||
}
|
||||
|
||||
if($is_smart_featured_collection)
|
||||
{
|
||||
$search = NODE_TOKEN_PREFIX . $fc["ref"];
|
||||
$render_ctx["href"] = generateURL("{$baseurl_short}pages/search.php", array("search" => $search, "resetrestypes" => "true"));
|
||||
|
||||
$node_is_parent = (isset($fc["node_is_parent"]) ? $fc["node_is_parent"] : true);
|
||||
if($node_is_parent)
|
||||
{
|
||||
$render_ctx["href"] = generateURL(
|
||||
"{$baseurl_short}pages/collections_featured.php",
|
||||
array(
|
||||
"smart_rtf" => $fc["resource_type_field"],
|
||||
"smart_fc_parent" => $fc["parent"],
|
||||
));
|
||||
}
|
||||
$render_ctx["icon"] = ICON_FOLDER;
|
||||
$render_ctx["tools"] = array();
|
||||
}
|
||||
|
||||
// Don't show the tools for external shares
|
||||
if((trim($k) != ""))
|
||||
{
|
||||
$render_ctx["tools"] = array();
|
||||
}
|
||||
|
||||
render_featured_collection($render_ctx, $fc);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render a featured collection (as tiles on the collections_featured.php page)
|
||||
*
|
||||
* @param array $ctx Context data to allow caller code to decide rendering requirements
|
||||
* @param array $fc Featured collection data structure
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function render_featured_collection(array $ctx, array $fc)
|
||||
{
|
||||
if(empty($fc))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
global $baseurl_short, $lang, $k, $flag_new_themes, $flag_new_themes_age;
|
||||
|
||||
$is_smart_featured_collection = (isset($ctx["smart"]) ? (bool) $ctx["smart"] : false);
|
||||
$full_width = (isset($ctx["full_width"]) && $ctx["full_width"]);
|
||||
$general_url_params = (isset($ctx["general_url_params"]) && is_array($ctx["general_url_params"]) ? $ctx["general_url_params"] : array());
|
||||
|
||||
|
||||
$html_container_class = array("FeaturedSimplePanel", "HomePanel", "DashTile", "FeaturedSimpleTile");
|
||||
$html_container_style = array();
|
||||
|
||||
|
||||
// Set main featured collection URL (e.g for collections it's the !collection[ID], for categories it's for collection_featured.php)
|
||||
$html_fc_a_href = generateURL("{$baseurl_short}pages/search.php", $general_url_params, array("search" => "!collection{$fc["ref"]}"));
|
||||
$html_fc_a_href = (isset($ctx["href"]) && trim($ctx["href"]) !== "" ? $ctx["href"] : $html_fc_a_href);
|
||||
|
||||
|
||||
$html_contents_class = array("FeaturedSimpleTileContents");
|
||||
$html_contents_icon = (isset($ctx["icon"]) && trim($ctx["icon"]) != "" ? $ctx["icon"] : ICON_CUBE);
|
||||
$html_contents_h2 = $html_contents_icon . i18n_get_collection_name($fc);
|
||||
$html_contents_h2_style = array();
|
||||
if($full_width)
|
||||
{
|
||||
$html_container_class[] = "FullWidth";
|
||||
$html_contents_h2_style[] = "max-width: unset;";
|
||||
|
||||
$action_selection_id = "themes_action_selection{$fc["ref"]}_bottom_{$fc["ref"]}";
|
||||
}
|
||||
if(!$is_smart_featured_collection && $flag_new_themes && (time() - strtotime($fc["created"])) < (60 * 60 * 24 * $flag_new_themes_age))
|
||||
{
|
||||
$html_contents_h2 .= " <div class=\"NewFlag\">{$lang['newflag']}</div>";
|
||||
}
|
||||
|
||||
|
||||
$theme_images = (isset($ctx["images"]) ? $ctx["images"] : array());
|
||||
if(!empty($theme_images))
|
||||
{
|
||||
$html_container_class[] = "FeaturedSimpleTileImage";
|
||||
$html_contents_class[] = "TileContentShadow";
|
||||
|
||||
if(count($theme_images) == 1)
|
||||
{
|
||||
$theme_image_path = $theme_images[0];
|
||||
$html_container_style[] = "background: url({$theme_image_path});";
|
||||
$html_container_style[] = "background-size: cover;";
|
||||
$theme_images = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tools = (isset($ctx["tools"]) && is_array($ctx["tools"]) && !$full_width ? $ctx["tools"] : array());
|
||||
$html_actions_style = array();
|
||||
if(count($tools) > 3)
|
||||
{
|
||||
$html_actions_style[] = "height: 43px;";
|
||||
}
|
||||
|
||||
|
||||
// DEVELOPER NOTE: anything past this point should be set. All logic is handled above
|
||||
?>
|
||||
<div id="FeaturedSimpleTile_<?php echo md5($fc['ref']); ?>" class="<?php echo implode(" ", $html_container_class); ?>" style="<?php echo implode(" ", $html_container_style); ?>">
|
||||
<a href="<?php echo $html_fc_a_href; ?>" onclick="return CentralSpaceLoad(this, true);" id="featured_tile_<?php echo $fc["ref"]; ?>" class="FeaturedSimpleLink">
|
||||
<div id="FeaturedSimpleTileContents_<?php echo $fc["ref"]; ?>" class="<?php echo implode(" ", $html_contents_class); ?>">
|
||||
<?php
|
||||
foreach($theme_images as $i => $theme_image)
|
||||
{
|
||||
$gap = 200 / count($theme_images);
|
||||
$space = $i * $gap;
|
||||
$style = array(
|
||||
"left: {$space}px;",
|
||||
"transform: rotate(" . (20 - ($i * 12)) . "deg);"
|
||||
);
|
||||
?>
|
||||
<img src="<?php echo $theme_image; ?>" class="TileGroupImageBase" style="<?php echo implode(" ", $style); ?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<h2 style="<?php echo implode(" ", $html_contents_h2_style); ?>"><?php echo $html_contents_h2; ?></h2>
|
||||
</div>
|
||||
</a>
|
||||
<?php
|
||||
if(!empty($tools))
|
||||
{
|
||||
?>
|
||||
<div id="FeaturedSimpleTileActions_<?php echo md5($fc['ref']); ?>" class="FeaturedSimpleTileActions DisplayNone" style="<?php echo implode(" ", $html_actions_style); ?>">
|
||||
<?php
|
||||
foreach($tools as $tool)
|
||||
{
|
||||
if(empty($tool))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$href = (isset($tool["href"]) && trim($tool["href"]) != "" ? $tool["href"] : "#");
|
||||
$text = $tool["text"]; // if this is missing, code is wrong somewhere else
|
||||
|
||||
$tool_onclick = (isset($tool["modal_load"]) && $tool["modal_load"] ? 'return ModalLoad(this, true);' : 'return CentralSpaceLoad(this, true);');
|
||||
if(isset($tool["custom_onclick"]) && trim($tool["custom_onclick"]) != "")
|
||||
{
|
||||
$tool_onclick = $tool["custom_onclick"];
|
||||
}
|
||||
?>
|
||||
<div class="tool">
|
||||
<a href="<?php echo $href; ?>" onclick="<?php echo $tool_onclick; ?>">
|
||||
<span><?php echo LINK_CARET; ?><?php echo htmlspecialchars($text); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div><!-- End of FeaturedSimpleTileActions_<?php echo md5($fc['ref']); ?> -->
|
||||
<?php
|
||||
}
|
||||
else if($full_width && !$is_smart_featured_collection)
|
||||
{
|
||||
?>
|
||||
<div class="ListTools">
|
||||
<div class="ActionsContainer">
|
||||
<select id="<?php echo $action_selection_id; ?>" onchange="action_onchange_<?php echo $action_selection_id; ?>(this.value);">
|
||||
<option><?php echo $lang["actions-select"]; ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<script>
|
||||
jQuery('#<?php echo $action_selection_id; ?>').bind({
|
||||
mouseenter: function(e)
|
||||
{
|
||||
LoadActions('themes', '<?php echo $action_selection_id; ?>', 'collection', '<?php echo $fc["ref"]; ?>');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</div><!-- End of ListTools -->
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div><!-- End of FeaturedSimpleTile_<?php echo $fc["ref"]; ?>-->
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renders an option in the Permission Manager (admin_group_permissions.php page)
|
||||
*
|
||||
* @param string $permission Permission identifier
|
||||
* @param string $description User friendly description of the permission
|
||||
* @param boolean $reverse Reverse the permission
|
||||
* @param boolean $reload Autosave changes done on this permission
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function DrawOption($permission,$description,$reverse=false,$reload=false)
|
||||
{
|
||||
global $permissions,$permissions_done;
|
||||
$checked=(in_array($permission,$permissions));
|
||||
if ($reverse) {$checked=!$checked;}
|
||||
?>
|
||||
<input type="hidden" name="permission_<?php echo base64_encode($permission)?>" value="<?php echo ($reverse)?"reverse":"normal" ?>">
|
||||
<tr>
|
||||
<td><?php if ($reverse) {?><i><?php } ?><?php echo $permission?><?php if ($reverse) {?></i><?php } ?></td>
|
||||
<td><?php echo $description?></td>
|
||||
<td><input type="checkbox" name="checked_<?php echo base64_encode($permission) ?>" <?php
|
||||
if ($checked) { ?> checked <?php } ?><?php if ($reload) { ?> onChange="CentralSpacePost(this.form,false);" <?php } ?>></td>
|
||||
</tr>
|
||||
<?php
|
||||
$permissions_done[]=$permission;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render featured collections options in the Permission Manager (admin_group_permissions.php page)
|
||||
*
|
||||
* This function will generate and render the following permissions that target featured collection categories
|
||||
* # j[numeric ID of new collection] - valid for FC categories at root level. These are normal permissions.
|
||||
* # -j[numeric ID of new collection] - valid for the rest of FC sub-categories. These permissions are reversed, {@see DrawOption()}!
|
||||
*
|
||||
* @param array $ctx Context data to allow caller code to start from different tree levels. Supports the following
|
||||
* properties: parent and depth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function render_featured_collections_category_permissions(array $ctx)
|
||||
{
|
||||
global $lang;
|
||||
|
||||
$permissions = (isset($ctx["permissions"]) && is_array($ctx["permissions"]) ? $ctx["permissions"] : array());
|
||||
$parent = (isset($ctx["parent"]) ? validate_collection_parent(array("parent" => $ctx["parent"])) : 0);
|
||||
$path_depth = (isset($ctx["depth"]) ? $ctx["depth"] : 0);
|
||||
$branch_path = (isset($ctx["branch_path"]) && is_array($ctx["branch_path"]) ? $ctx["branch_path"] : array());
|
||||
|
||||
$current_depth = $path_depth;
|
||||
$current_branch_path = $branch_path;
|
||||
$reverse_permission = ($parent > 0);
|
||||
|
||||
foreach(get_featured_collection_categories($parent, array("access_control" => false)) as $fc)
|
||||
{
|
||||
$branch_path = $current_branch_path;
|
||||
$branch_path[] = array(
|
||||
"ref" => $fc["ref"],
|
||||
"name" => $fc["name"],
|
||||
"parent" => validate_collection_parent($fc),
|
||||
);
|
||||
|
||||
$fc_perm_id = (!$reverse_permission ? "" : "-") . "j{$fc["ref"]}";
|
||||
$description = sprintf("%s%s '%s'",
|
||||
($path_depth == 0 ? "" : str_pad("", $path_depth * 7, "—") . " "),
|
||||
(!$reverse_permission ? $lang["can_see_theme_category"] : $lang["can_see_theme_sub_category"]),
|
||||
i18n_get_translated($fc["name"])
|
||||
);
|
||||
DrawOption($fc_perm_id, $description, $reverse_permission, true);
|
||||
|
||||
// Root categories (ie that don't have a parent) get rendered as normal permissions. Sub-categories, get rendered
|
||||
// as reverse permissions
|
||||
debug(sprintf("render_featured_collections_category_permissions: Check if allowed to render sub-categories for FC category '%s'", $fc['ref']));
|
||||
$render_subcategories = array_reduce($branch_path, function($carry, $item) use ($permissions)
|
||||
{
|
||||
$root_node = is_null($item["parent"]);
|
||||
$perm_id = ($root_node ? "" : "-") . "j{$item["ref"]}";
|
||||
$allow_render = ($root_node ? in_array($perm_id, $permissions) : !in_array($perm_id, $permissions));
|
||||
debug(sprintf("render_featured_collections_category_permissions: For perm ID '%s': carry = %s; root_node = %s; allow_render = %s", $perm_id, json_encode($carry), json_encode($root_node), json_encode($allow_render)));
|
||||
|
||||
// FALSE if at least one featured collection category parent is forbidden
|
||||
return (!is_bool($carry) ? $allow_render : $carry && $allow_render);
|
||||
}, null);
|
||||
debug("render_featured_collections_category_permissions: render_subcategories = " . json_encode($render_subcategories));
|
||||
debug("render_featured_collections_category_permissions: ");
|
||||
|
||||
if($render_subcategories)
|
||||
{
|
||||
render_featured_collections_category_permissions(
|
||||
array(
|
||||
"permissions" => $permissions,
|
||||
"parent" => $fc["ref"],
|
||||
"depth" => ++$path_depth,
|
||||
"branch_path" => $branch_path,
|
||||
));
|
||||
|
||||
// Step back to initial depth level
|
||||
$path_depth = $current_depth;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* show_upgrade_in_progress message
|
||||
*
|
||||
|
@ -4350,5 +4850,3 @@ function render_array_in_table_cells($array)
|
|||
echo "</table>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3695,42 +3695,52 @@ function get_custom_access($resource,$usergroup,$return_default=true)
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Determine the featured collections and public collections a resource is associated with.
|
||||
*
|
||||
* @param integer $ref Resource ref
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_themes_by_resource($ref)
|
||||
{
|
||||
global $theme_category_levels;
|
||||
{
|
||||
global $lang;
|
||||
|
||||
$themestring="";
|
||||
for($n=1;$n<=$theme_category_levels;$n++){
|
||||
if ($n==1){$themeindex="";}else{$themeindex=$n;}
|
||||
$themestring.=",c.theme".$themeindex;
|
||||
}
|
||||
$sql = sprintf(
|
||||
"SELECT c.ref, c.`name`, c.`type`, u.fullname
|
||||
FROM collection_resource AS cr
|
||||
JOIN collection AS c ON cr.collection = c.ref AND cr.resource = '%s' AND c.`type` IN (%s)
|
||||
LEFT OUTER JOIN user AS u ON c.user = u.ref
|
||||
%s # access control filter (ok if empty - it means we don't want permission checks or there's nothing to filter out)",
|
||||
escape_check($ref),
|
||||
COLLECTION_TYPE_FEATURED . ", " . COLLECTION_TYPE_PUBLIC,
|
||||
trim(featured_collections_permissions_filter_sql("WHERE", "c.ref"))
|
||||
);
|
||||
|
||||
$themes=sql_query("select c.ref $themestring ,c.name,u.fullname from collection_resource cr join collection c on cr.collection=c.ref and cr.resource='$ref' and c.public=1 left outer join user u on c.user=u.ref order by length(theme) desc");
|
||||
# Combine the theme categories into one string so multiple category levels display correctly.
|
||||
$return=array();
|
||||
$results = sql_query($sql);
|
||||
$branch_path_fct = function($carry, $item) { return sprintf("%s / %s", $carry, i18n_get_translated($item["name"])); };
|
||||
|
||||
for ($n=0;$n<count($themes);$n++)
|
||||
{
|
||||
if (checkperm("j*") || checkperm("j" . $themes[$n]["theme"]))
|
||||
{
|
||||
$theme="";
|
||||
for ($x=1;$x<=$theme_category_levels;$x++){
|
||||
if ($x==1){$themeindex="";}else{$themeindex=$x;}
|
||||
if ($themes[$n]["theme".$themeindex]==""){break;}
|
||||
if ($themeindex!=""){$theme.=" / ";}
|
||||
foreach($results as $i => $col)
|
||||
{
|
||||
$path = sprintf("%s: %s", $lang["public"], i18n_get_translated($col["name"]));
|
||||
|
||||
if ($themes[$n]["theme".$themeindex]!="") {
|
||||
$theme.=$themes[$n]["theme".$themeindex];
|
||||
}
|
||||
}
|
||||
$themes[$n]["theme"]=$theme;
|
||||
$return[]=$themes[$n];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
if($col["type"] == COLLECTION_TYPE_FEATURED)
|
||||
{
|
||||
$branch_path = get_featured_collection_category_branch_by_leaf($col["ref"], array());
|
||||
$branch_path_str = array_reduce($branch_path, $branch_path_fct, "");
|
||||
$path = mb_substr($branch_path_str, 2, mb_strlen($branch_path_str));
|
||||
}
|
||||
|
||||
$results[$i]["path"] = trim($path);
|
||||
}
|
||||
|
||||
// Order by resulting path
|
||||
usort($results, function($a, $b) { return strnatcasecmp($a["path"], $b["path"]); });
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
function update_resource_type($ref,$type)
|
||||
{
|
||||
|
|
|
@ -1514,49 +1514,13 @@ function do_search(
|
|||
$score="h.score";
|
||||
}
|
||||
|
||||
# Can only search for resources that belong to themes
|
||||
if (checkperm("J"))
|
||||
# Can only search for resources that belong to featured collections
|
||||
if(checkperm("J"))
|
||||
{
|
||||
global $theme_category_levels;
|
||||
$collection_join = " JOIN collection_resource jcr ON jcr.resource=r.ref JOIN collection jc ON jcr.collection=jc.ref ";
|
||||
$themes=sql_query("select * from collection where public=1");
|
||||
$allowed_themes=array();
|
||||
for ($n=0;$n<count($themes);$n++)
|
||||
{
|
||||
if (checkperm("j*"))
|
||||
{
|
||||
// Access to all themes
|
||||
$allowed_themes[]=$themes[$n]["ref"];
|
||||
}
|
||||
else if (checkperm("j" . $themes[$n]["theme"]))
|
||||
{
|
||||
$theme_path=$themes[$n]["theme"];
|
||||
for ($x=2;$x<$theme_category_levels +1;$x++)
|
||||
{
|
||||
if ($themes[$n]["theme".$x]==NULL){break;}
|
||||
if (checkperm("j-" . $theme_path . "|" . $themes[$n]["theme".$x]))
|
||||
{
|
||||
// Access to this branch is blocked for this usergroup
|
||||
continue 2;
|
||||
}
|
||||
$theme_path.= "|" . $themes[$n]["theme".$x];
|
||||
}
|
||||
|
||||
$allowed_themes[]=$themes[$n]["ref"];
|
||||
}
|
||||
}
|
||||
$collection_join = " JOIN collection_resource AS jcr ON jcr.resource = r.ref JOIN collection AS jc ON jcr.collection = jc.ref";
|
||||
$collection_join .= featured_collections_permissions_filter_sql("AND", "jc.ref");
|
||||
|
||||
if(!empty($allowed_themes))
|
||||
{
|
||||
$collection_join .= "AND jc.ref IN (" . implode(', ',$allowed_themes) . ") ";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can only see public collections but not allowed to see any public collections
|
||||
$collection_join .= "AND 1=0 ";
|
||||
}
|
||||
|
||||
$sql_join= $collection_join . $sql_join;
|
||||
$sql_join = $collection_join . $sql_join;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1170,20 +1170,20 @@ function search_special($search,$sql_join,$fetchrows,$sql_prefix,$sql_suffix,$or
|
|||
if (strpos($flags,"T")!==false) # Include themes
|
||||
{
|
||||
if ($collection_filter!="(") {$collection_filter.=" OR ";}
|
||||
$collection_filter.=" (c.public=1 AND (length(c.theme)>0))";
|
||||
$collection_filter .= sprintf(" c.`type` = %s", COLLECTION_TYPE_FEATURED);
|
||||
}
|
||||
|
||||
if (strpos($flags,"P")!==false) # Include public collections
|
||||
{
|
||||
if ($collection_filter!="(") {$collection_filter.=" OR ";}
|
||||
$collection_filter.=" (c.public=1 AND (length(c.theme)=0 OR c.theme IS null))";
|
||||
$collection_filter .= sprintf(" c.`type` = %s", COLLECTION_TYPE_PUBLIC);
|
||||
}
|
||||
|
||||
if (strpos($flags,"U")!==false) # Include the user's own collections
|
||||
{
|
||||
if ($collection_filter!="(") {$collection_filter.=" OR ";}
|
||||
global $userref;
|
||||
$collection_filter.=" (c.public=0 AND c.user='$userref')";
|
||||
$collection_filter .= sprintf(" (c.`type` = %s AND c.user = '%s')", COLLECTION_TYPE_STANDARD, escape_check($userref));
|
||||
}
|
||||
$collection_filter.=")";
|
||||
|
||||
|
|
|
@ -133,27 +133,6 @@ if ($search_titles_searchcrumbs && $use_refine_searchstring)
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($collectiondata["theme"]) && strlen($collectiondata["theme"])>0)
|
||||
{
|
||||
$colaccessmode = $lang["themes"];
|
||||
$is_theme=true;
|
||||
$theme_link="<a onClick='return CentralSpaceLoad(this,true);' href='" . $baseurl . "/pages/themes.php'>".$lang['themes']."</a>" . " " . LINK_CARET . "<a onClick='return CentralSpaceLoad(this,true);' href='".$baseurl . "/pages/themes.php?theme1=" . urlencode(htmlspecialchars($collectiondata["theme"])) . "'>" . htmlspecialchars(str_replace("*","",i18n_get_translated($collectiondata["theme"]))) . "</a>";
|
||||
|
||||
global $theme_category_levels;
|
||||
for($x=2;$x<=$theme_category_levels;$x++)
|
||||
{
|
||||
if(isset($collectiondata['theme' . $x]) && strlen($collectiondata['theme' . $x]) > 0)
|
||||
{
|
||||
$theme_link_url = $baseurl . "/pages/themes.php?lastlevelchange=" . $x . "&theme1=" . urlencode(htmlspecialchars($collectiondata["theme"]));
|
||||
for($l=2;$l<=$x;$l++)
|
||||
{
|
||||
$theme_link_url .= "&theme" . $l . "=" . urlencode(htmlspecialchars($collectiondata['theme' . $l]));
|
||||
}
|
||||
$theme_link .=" " . LINK_CARET . "<a onClick='return CentralSpaceLoad(this, true);' href='" . $theme_link_url . "'>" . htmlspecialchars(str_replace("*","",i18n_get_translated($collectiondata['theme' . $x]))) . "</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($search_titles)
|
||||
{
|
||||
$parameters_string = '&order_by=' . urlencode($order_by) . '&sort=' . urlencode($sort) . '&offset=' . urlencode($offset) . '&archive=' . urlencode($archive) . '&sort=' . urlencode($sort) . '&k=' . urlencode($k);
|
||||
|
@ -167,24 +146,23 @@ if ($search_titles)
|
|||
# Work out the correct access mode to display
|
||||
if (!hook('collectionaccessmode'))
|
||||
{
|
||||
if ($collectiondata["public"]==0)
|
||||
switch($collectiondata["type"])
|
||||
{
|
||||
$colaccessmode = $lang["private"];
|
||||
$display_user_and_access = true;
|
||||
if ($colusername!="")
|
||||
{
|
||||
$colaccessmode="/".$colaccessmode;
|
||||
}
|
||||
}
|
||||
else if (strlen($collectiondata["theme"])==0)
|
||||
{
|
||||
$colaccessmode = $lang["public"];
|
||||
$display_user_and_access = true;
|
||||
case COLLECTION_TYPE_PUBLIC:
|
||||
$display_user_and_access = true;
|
||||
$colaccessmode = $lang["public"];
|
||||
break;
|
||||
|
||||
if ($colusername!="")
|
||||
{
|
||||
$colaccessmode="/".$colaccessmode;
|
||||
}
|
||||
case COLLECTION_TYPE_STANDARD:
|
||||
default:
|
||||
$display_user_and_access = true;
|
||||
$colaccessmode = $lang["private"];
|
||||
break;
|
||||
}
|
||||
|
||||
if($colusername != "")
|
||||
{
|
||||
$colaccessmode = "/" . $colaccessmode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ if($basic_simple_search)
|
|||
if(!isset($internal_share_access))
|
||||
{
|
||||
// Set a flag for logged in users if $external_share_view_as_internal is set and logged on user is accessing an external share
|
||||
$internal_share_access = (isset($k) && $k!="" && $external_share_view_as_internal && isset($is_authenticated) && $is_authenticated);
|
||||
$internal_share_access = internal_share_access();
|
||||
}
|
||||
|
||||
# Load the basic search fields, so we know which to strip from the search string
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
// ---------- start of n-level theme permissions ----------
|
||||
|
||||
# returns array of key=>value
|
||||
# key = theme path, pipe delimited ("|"), e.g. Cars|German|VW
|
||||
# value = boolean - TRUE(1) if permission to view or FALSE if denied
|
||||
# --- set via permission manager j*, (include all), j<top level include> and j-<exclude below top level> directives
|
||||
#
|
||||
function getThemePathPerms()
|
||||
{
|
||||
global $theme_category_levels, $permissions, $current_user_collection_blacklisted_no_perms;
|
||||
$stack = array();
|
||||
$sql_theme_columns_name = "";
|
||||
for ($i=2; $i<=$theme_category_levels; $i++) $sql_theme_columns_name .= ",theme{$i}"; // build up list of columns depending on how many theme levels specified in setup
|
||||
$collections=sql_query("select distinct ref, theme theme1${sql_theme_columns_name} from collection where length(theme)>0 order by theme1${sql_theme_columns_name}"); // *** order by is IMPORTANT ***
|
||||
foreach ($collections as $collection)
|
||||
{
|
||||
$pathString = "";
|
||||
$ref = 0;
|
||||
$perm = true; // by default grant permission
|
||||
foreach ($collection as $item)
|
||||
{
|
||||
if ($ref == 0) // the first field return in query is the ref, so grab it and continue
|
||||
{
|
||||
$ref = $item;
|
||||
continue;
|
||||
}
|
||||
if (empty($item)) break; // the current field is blank so quit field iteration
|
||||
if ($pathString != "") $pathString .= "|"; // only add separator if not first field
|
||||
$pathString .= $item;
|
||||
if (
|
||||
(substr_count ($pathString,"|") == 0 && !array_search ("j${pathString}", $permissions)) // for top level we just need to make sure that "jMyTheme" does not exist
|
||||
||
|
||||
(array_search ("j-${pathString}", $permissions)) // look for minus path to indicate that we do not have permission from here and below
|
||||
)
|
||||
{
|
||||
$perm = false; // *** IMPORTANT *** for this and all other sub-levels permission will not be granted - cool!
|
||||
}
|
||||
$stack[$pathString] = $perm; // add to return stack
|
||||
} // end field iteration
|
||||
} // end row iteration
|
||||
return $stack;
|
||||
}
|
||||
|
||||
// ---------- end of n-level theme permissions ----------
|
||||
|
||||
?>
|
|
@ -1689,7 +1689,7 @@ function check_access_key($resources,$key)
|
|||
|
||||
|
||||
/**
|
||||
* Check access key for a collection
|
||||
* Check access key for a collection. For a featured collection category, the check will be done on all sub featured collections.
|
||||
*
|
||||
* @param integer $collection Collection ID
|
||||
* @param string $key Access key
|
||||
|
@ -1704,7 +1704,6 @@ function check_access_key_collection($collection, $key)
|
|||
}
|
||||
|
||||
hook("external_share_view_as_internal_override");
|
||||
|
||||
global $external_share_view_as_internal;
|
||||
if($external_share_view_as_internal && isset($_COOKIE["user"]) && validate_user("session='" . escape_check($_COOKIE["user"]) . "'", false))
|
||||
{
|
||||
|
@ -1712,28 +1711,46 @@ function check_access_key_collection($collection, $key)
|
|||
return false;
|
||||
}
|
||||
|
||||
$resources = get_collection_resources($collection);
|
||||
|
||||
if(!is_array($resources) || 0 == count($resources))
|
||||
$collection = get_collection($collection);
|
||||
if($collection === false)
|
||||
{
|
||||
// No resources; treat as failure
|
||||
return false;
|
||||
}
|
||||
|
||||
# hook to retrieve alternative list of resources for access key check
|
||||
$resources_alt = hook("GetResourcesToCheck","",array($collection));
|
||||
$resources = ($resources_alt !== false ) ? $resources_alt : $resources;
|
||||
$collection_resources = get_collection_resources($collection["ref"]);
|
||||
$collection["has_resources"] = (is_array($collection_resources) && !empty($collection_resources) ? 1 : 0);
|
||||
$is_featured_collection_category = is_featured_collection_category($collection);
|
||||
|
||||
// only check access key when there are resources to check
|
||||
if (count($resources) > 0)
|
||||
if(!$is_featured_collection_category && !$collection["has_resources"])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// From this point all collections should have resources. For FC categories, its sub FCs will have resources because
|
||||
// get_featured_collection_categ_sub_fcs() does the check internally
|
||||
$collections = (!$is_featured_collection_category ? array($collection["ref"]) : get_featured_collection_categ_sub_fcs($collection, array("access_control" => false)));
|
||||
|
||||
$sql = "UPDATE external_access_keys SET lastused = NOW() WHERE collection = '%s' AND access_key = '{$key}'";
|
||||
|
||||
foreach($collections as $collection_ref)
|
||||
{
|
||||
$resources_alt = hook("GetResourcesToCheck","",array($collection));
|
||||
$resources = ($resources_alt !== false ? $resources_alt : get_collection_resources($collection_ref));
|
||||
|
||||
if(!check_access_key($resources, $key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
sql_query(sprintf($sql, escape_check($collection_ref)));
|
||||
}
|
||||
|
||||
if($is_featured_collection_category)
|
||||
{
|
||||
// Update the last used for the dummy record we have for the featured collection category (ie. no resources since
|
||||
// a category contains only collections)
|
||||
sql_query(sprintf($sql, escape_check($collection["ref"])));
|
||||
}
|
||||
// Set the 'last used' date for this key
|
||||
sql_query("UPDATE external_access_keys SET lastused = now() WHERE collection = '{$collection}' AND access_key = '{$key}'");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2357,3 +2374,15 @@ function checkperm_user_edit($user)
|
|||
// Return true if the target user we are checking is in one of the valid groups
|
||||
return (in_array($editusergroup, $validgroups));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if this is an internal share access request
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function internal_share_access()
|
||||
{
|
||||
global $k, $external_share_view_as_internal, $is_authenticated;
|
||||
return ($k != "" && $external_share_view_as_internal && isset($is_authenticated) && $is_authenticated);
|
||||
}
|
||||
|
|
53
index.php
53
index.php
|
@ -19,39 +19,40 @@ if('' == $k || (!check_access_key_collection(getvalescaped('c', ''), $k) && !che
|
|||
if (!hook("replacetopurl"))
|
||||
{
|
||||
$topurl="pages/" . $default_home_page . "?login=true";
|
||||
if ($use_theme_as_home) {$topurl="pages/themes.php";}
|
||||
if($use_theme_as_home) { $topurl = "pages/collections_featured.php"; }
|
||||
if ($use_recent_as_home) {$topurl="pages/search.php?search=" . urlencode("!last".$recent_search_quantity);}
|
||||
} /* end hook replacetopurl */
|
||||
|
||||
|
||||
if (getval("c","")!="")
|
||||
$c = trim(getval("c", ""));
|
||||
if($c != "")
|
||||
{
|
||||
# quick redirect to a collection (from e-mails, keep the URL nice and short)
|
||||
$c=getvalescaped("c","");
|
||||
$collection = get_collection($c);
|
||||
if($collection === false)
|
||||
{
|
||||
exit($lang["error-collectionnotfound"]);
|
||||
}
|
||||
|
||||
// Now redirect to the terms page with appropriate parameters
|
||||
$topurl="pages/search.php?search=" . urlencode("!collection" . $c) . "&k=" . $k;
|
||||
$topurl = "pages/search.php?search=" . urlencode("!collection" . $c) . "&k=" . $k;
|
||||
|
||||
if ($k!="")
|
||||
{
|
||||
# External access user... set top URL to first resource
|
||||
$r=get_collection_resources($c);
|
||||
if (is_array($r) && count($r)>0)
|
||||
{
|
||||
# Fetch collection data
|
||||
$cinfo=get_collection($c);if ($cinfo===false) {exit("Collection not found.");}
|
||||
|
||||
if ($feedback_resource_select && $cinfo["request_feedback"])
|
||||
{
|
||||
$topurl="pages/collection_feedback.php?collection=" . $c . "&k=" . $k;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Now redirect to the terms page with appropriate parameters
|
||||
$topurl="pages/search.php?search=" . urlencode("!collection" . $c) . "&k=" . $k;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(trim($k) != "")
|
||||
{
|
||||
$collection_resources = get_collection_resources($c);
|
||||
|
||||
if($collection["type"] == COLLECTION_TYPE_FEATURED)
|
||||
{
|
||||
$collection["has_resources"] = (is_array($collection_resources) && !empty($collection_resources) ? 1 : 0);
|
||||
}
|
||||
|
||||
if(is_featured_collection_category($collection))
|
||||
{
|
||||
$topurl = "pages/collections_featured.php?parent={$c}&k={$k}";
|
||||
}
|
||||
else if(is_array($collection_resources) && count($collection_resources) > 0 && $feedback_resource_select && $collection["request_feedback"])
|
||||
{
|
||||
$topurl = "pages/collection_feedback.php?collection={$c}&k={$k}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getval("r","")!="")
|
||||
|
|
|
@ -455,6 +455,11 @@ $lang["emailthemecollectionmessageexternal"]="has e-mailed you collections of re
|
|||
$lang["emailthememessage"]="has e-mailed you a selection of featured collections from $applicationname which have been added to your 'My collections' page.";
|
||||
$lang["clicklinkviewthemes"]="Click the link below to view the featured collections.";
|
||||
$lang["clicklinkviewcollections"]="Click the links below to view the collections.";
|
||||
$lang["background_image"] = "Background image";
|
||||
$lang["background_most_popular_image"] = "Most popular image";
|
||||
$lang["background_most_popular_images"] = "Most popular %n images";
|
||||
$lang["background_manual_selection"] = "Choose images (collection commenting)";
|
||||
$lang["share_fc_warning"] = "Please note that when sharing a featured collection category only featured collections that contain resources will be externally shared.";
|
||||
|
||||
# Lightbox
|
||||
$lang["lightbox-image"] = "Image";
|
||||
|
|
|
@ -709,4 +709,4 @@ function remove_multiple_resources_from_collection(resource_list, collection, cs
|
|||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ function ToggleBrowseBar(forcestate, noresize)
|
|||
|
||||
function renderBrowseItem(node, parent)
|
||||
{
|
||||
console.debug("Calling renderBrowseItem(node = %o, parent = %o)", node, parent);
|
||||
var parentid = parent.attr('data-browse-id');
|
||||
var newlevel = parent.attr("data-browse-level");
|
||||
newlevel++;
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
|
||||
|
||||
function updateThemeLevels(changedlevel){
|
||||
// used to compute theme string and update dynamic theme levels on edit.php page
|
||||
//
|
||||
// how many instances are currently being displayed?
|
||||
var levelcount = 0;
|
||||
var o = document.getElementById("themelevellist").getElementsByTagName("div");
|
||||
for(var i=0;i < o.length;i++){
|
||||
if(o[i].className == "themelevelinstance")
|
||||
levelcount ++;
|
||||
}
|
||||
// first, if they've changed a value, we want to clear out all values higher than that, since they will need to reselect
|
||||
for (var k=changedlevel+1; k < levelcount; k++){
|
||||
var thisfield = "newtheme" + k;
|
||||
var thissel = "theme" + k;
|
||||
document.getElementById(thisfield).value = '';
|
||||
document.getElementById(thissel).selectedIndex = 0;
|
||||
}
|
||||
|
||||
// ok, now piece together the string of theme titles to send to the server
|
||||
var themestring = '';
|
||||
var sep = '';
|
||||
for (i=0; i < levelcount+1; i++){
|
||||
thisfield = "newtheme" + i;
|
||||
thissel = "theme" + i;
|
||||
if (i > 0){
|
||||
sep = '||';
|
||||
}
|
||||
|
||||
if (document.getElementById(thisfield) == null || (document.getElementById(thisfield).value == '' && document.getElementById(thissel)[document.getElementById(thissel).selectedIndex].value == '')){
|
||||
break;
|
||||
} else {
|
||||
thisselValue = document.getElementById(thissel)[document.getElementById(thissel).selectedIndex].value;
|
||||
if (document.getElementById(thisfield).value == '' ){
|
||||
themestring = themestring + sep + thisselValue;
|
||||
} else {
|
||||
themestring = themestring + sep + document.getElementById(thisfield).value;
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById('themestring').value = themestring;
|
||||
//alert(document.getElementById('themestring').value);
|
||||
//document.getElementById('submitform').submit();
|
||||
jQuery('#themeselect').load('ajax/themelevel_add.php?themestring='+encodeURIComponent(themestring),{async:true});
|
||||
}
|
||||
|
||||
function resetThemeLevels(){
|
||||
jQuery('#themeselect').load('ajax/themelevel_add.php',{async:true});
|
||||
}
|
||||
|
||||
function clearThemeLevels(){
|
||||
document.getElementById('themestring').value='';
|
||||
}
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
include "../../include/db.php";
|
||||
|
||||
include "../../include/authenticate.php";
|
||||
|
||||
if (!checkperm("a"))
|
||||
|
@ -56,24 +54,7 @@ if (getval("save","")!="" && enforcePostRequest(false))
|
|||
$group=get_usergroup($ref);
|
||||
if(isset($group['inherit']) && is_array($group['inherit']) && in_array("permissions",$group['inherit'])){exit($lang["error-permissiondenied"]);}
|
||||
$permissions=trim_array(explode(",",$group["permissions"]));
|
||||
$permissions_done=array();
|
||||
|
||||
function DrawOption($permission,$description,$reverse=false,$reload=false)
|
||||
{
|
||||
global $permissions,$permissions_done;
|
||||
$checked=(in_array($permission,$permissions));
|
||||
if ($reverse) {$checked=!$checked;}
|
||||
?>
|
||||
<input type="hidden" name="permission_<?php echo base64_encode($permission)?>" value="<?php echo ($reverse)?"reverse":"normal" ?>">
|
||||
<tr>
|
||||
<td><?php if ($reverse) {?><i><?php } ?><?php echo $permission?><?php if ($reverse) {?></i><?php } ?></td>
|
||||
<td><?php echo $description?></td>
|
||||
<td><input type="checkbox" name="checked_<?php echo base64_encode($permission) ?>" <?php
|
||||
if ($checked) { ?> checked <?php } ?><?php if ($reload) { ?> onChange="CentralSpacePost(this.form,false);" <?php } ?>></td>
|
||||
</tr>
|
||||
<?php
|
||||
$permissions_done[]=$permission;
|
||||
}
|
||||
$permissions_done=array();
|
||||
?>
|
||||
<div class="BasicsBox">
|
||||
<?php
|
||||
|
@ -287,40 +268,14 @@ else
|
|||
}
|
||||
DrawOption("dtu",$lang["manage_own_dash"],true,false);
|
||||
|
||||
# ------------ Access to theme categories
|
||||
|
||||
# ------------ Access to featured collection categories
|
||||
DrawOption("j*", $lang["can_see_all_theme_categories"], false, true);
|
||||
if (!in_array("j*",$permissions)) // by default is checked
|
||||
{
|
||||
include_once "../../include/theme_permission_functions.php";
|
||||
$theme_paths = getThemePathPerms();
|
||||
foreach ($theme_paths as $path=>$bPerm)
|
||||
{
|
||||
$level = substr_count ($path,"|");
|
||||
if ($level == 0)
|
||||
{
|
||||
DrawOption("j${path}", "${lang['can_see_theme_category']} '${path}'", false, true); // always show the top level theme
|
||||
}
|
||||
else
|
||||
{
|
||||
$parent = substr ($path, 0, strrpos($path,"|"));
|
||||
$skip =(!isset($theme_paths[$parent]) || !$theme_paths[$parent]); // check if parent theme permission has been set
|
||||
$permission = "j-" . $path;
|
||||
if ($skip)
|
||||
{
|
||||
$permissions_done[] = $permission; // stop any hidden perms appearing in the "custom permissions" if not showing (because parent is not set)
|
||||
}
|
||||
else
|
||||
{
|
||||
$nicename = substr ($path, strrpos ($path,"|") + 1);
|
||||
DrawOption($permission, str_pad("", $level*7, "—") . " " . $lang["can_see_theme_sub_category"] . " '" . i18n_get_translated($nicename) . "'", true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!in_array("j*", $permissions))
|
||||
{
|
||||
render_featured_collections_category_permissions(array("permissions" => $permissions));
|
||||
}
|
||||
DrawOption("J", $lang["display_only_resources_within_accessible_themes"]);
|
||||
|
||||
# ---------- end of theme categories
|
||||
# ---------- end of featured collection categories
|
||||
|
||||
|
||||
# ---------- End of Dash Tiles
|
||||
|
|
|
@ -222,15 +222,6 @@ $page_def[] = config_add_html('<h3 class="CollapsibleSectionHead collapsed">' .
|
|||
$page_def[] = config_add_boolean_select('enable_themes', $lang['systemconfig_enable_themes'], $yes_no_options, 420, '', true);
|
||||
$page_def[] = config_add_boolean_select('themes_simple_view', $lang['systemconfig_themes_simple_view'], $yes_no_options, 420, '', true);
|
||||
$page_def[] = config_add_boolean_select('themes_category_split_pages', $lang['systemconfig_themes_category_split_pages'], $yes_no_options, 420, '', true);
|
||||
$page_def[] = config_add_single_select(
|
||||
'theme_category_levels',
|
||||
$lang['systemconfig_theme_category_levels'],
|
||||
range(1, 8),
|
||||
false,
|
||||
420,
|
||||
'',
|
||||
true
|
||||
);
|
||||
$page_def[] = config_add_html('</div>');
|
||||
|
||||
// Workflow section
|
||||
|
|
|
@ -8,7 +8,7 @@ $id = getvalescaped('id', '');
|
|||
|
||||
// Use id to work out search string for link and path to data requested e.g. to get field id for node expansion
|
||||
$target_search = array();
|
||||
$ftcolcats = array();
|
||||
$fc_parent = 0;
|
||||
$parent_nodes = array();
|
||||
$browse_field = 0;
|
||||
|
||||
|
@ -38,7 +38,7 @@ for($n=0;$n<$bcount;$n++)
|
|||
case "FC":
|
||||
if($browseid != "")
|
||||
{
|
||||
$ftcolcats[] = base64_decode($browseid);
|
||||
$fc_parent = $browseid;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -271,73 +271,63 @@ switch ($returntype)
|
|||
}
|
||||
break;
|
||||
|
||||
// Featured collection
|
||||
case "FC":
|
||||
// Featured collection
|
||||
|
||||
$ftcol_subcats = get_theme_headers($ftcolcats);
|
||||
$tgtparams = array();
|
||||
$morelevels = count($ftcolcats) < $theme_category_levels-1;
|
||||
for ($x=0;$x<count($ftcolcats);$x++)
|
||||
$fc_parent = validate_collection_parent(array("parent" => $fc_parent));
|
||||
|
||||
// Add 'create new' option
|
||||
if($collection_allow_creation && checkperm("h"))
|
||||
{
|
||||
$fclevel = ($x==0) ? "" : $x+1;
|
||||
$tgtparams["theme" . $fclevel] = $ftcolcats[$x];
|
||||
$item = array(
|
||||
"id" => "{$id}-FC:new",
|
||||
"name" => htmlspecialchars($lang["create"]),
|
||||
"class" => "New",
|
||||
"expandable" => "false",
|
||||
"link" => generateURL(
|
||||
"{$baseurl_short}pages/collections_featured.php",
|
||||
array(
|
||||
"new" => "true",
|
||||
"cta" => "true",
|
||||
"parent" => $fc_parent,
|
||||
)
|
||||
),
|
||||
"modal" => true,
|
||||
);
|
||||
|
||||
$return_items[$n] = $item;
|
||||
$n++;
|
||||
}
|
||||
|
||||
if($collection_allow_creation && checkperm("h") && $morelevels)
|
||||
// If we're getting the root, look only for categories, otherwise you will get other public collections as they're all public collections
|
||||
$featured_collections = ($fc_parent == 0 ? get_featured_collection_categories($fc_parent, array()) : get_featured_collections($fc_parent, array()));
|
||||
usort($featured_collections, "order_featured_collections_by_hasresources");
|
||||
foreach($featured_collections as $fc)
|
||||
{
|
||||
// Add 'create new' option
|
||||
$return_items[$n] = array();
|
||||
$return_items[$n]["id"] = $id . "-FC:new";
|
||||
$return_items[$n]["name"] = $lang["create"];
|
||||
$return_items[$n]["class"] = "New";
|
||||
$return_items[$n]["expandable"] = "false";
|
||||
$newtgtparams = $tgtparams;
|
||||
$newtgtparams["new"] = "true";
|
||||
|
||||
$tgturl = generateURL($baseurl_short . "pages/themes.php", $newtgtparams);
|
||||
$return_items[$n]["link"] = $tgturl;
|
||||
$return_items[$n]["modal"] = true;
|
||||
$n++;
|
||||
}
|
||||
|
||||
foreach($ftcol_subcats as $subcat)
|
||||
{
|
||||
// Create link based on parent
|
||||
$return_items[$n] = array();
|
||||
$return_items[$n]["id"] = $id . "-FC:" . base64_encode($subcat);
|
||||
$return_items[$n]["name"] = htmlspecialchars(i18n_get_translated($subcat));
|
||||
$return_items[$n]["class"] = "Featured";
|
||||
$return_items[$n]["expandable"] = "true";
|
||||
$tgturl = generateURL($baseurl_short . "pages/themes.php", $tgtparams, array("theme" . ($x+1) => $subcat));
|
||||
$return_items[$n]["link"] = $tgturl;
|
||||
$return_items[$n]["modal"] = false;
|
||||
$n++;
|
||||
}
|
||||
|
||||
if(count($ftcolcats) > 0)
|
||||
{
|
||||
$fcols = get_themes($ftcolcats);
|
||||
foreach($fcols as $fcol)
|
||||
$is_featured_collection_category = is_featured_collection_category($fc);
|
||||
$id_part = ($is_featured_collection_category ? "FC" : "C");
|
||||
$link = generateURL("{$baseurl_short}pages/search.php", array("search" => "!collection{$fc["ref"]}"));
|
||||
if($is_featured_collection_category)
|
||||
{
|
||||
// Create link based on parent
|
||||
$return_items[$n] = array();
|
||||
$return_items[$n]["id"] = $id . "-C:" . $fcol["ref"];
|
||||
$return_items[$n]["name"] = htmlspecialchars(i18n_get_translated($fcol["name"]));
|
||||
$return_items[$n]["class"] = "Col";
|
||||
$return_items[$n]["expandable"] = "false";
|
||||
$tgtparams = array();
|
||||
$tgtparams["search"] = "!collection" . $fcol["ref"];
|
||||
$tgturl = generateURL($baseurl_short . "pages/search.php", $tgtparams);
|
||||
$return_items[$n]["link"] = $tgturl;
|
||||
$return_items[$n]["modal"] = false;
|
||||
$return_items[$n]["drop"] = true;
|
||||
$n++;
|
||||
$link = generateURL("{$baseurl_short}pages/collections_featured.php", array("parent" => $fc["ref"]));
|
||||
}
|
||||
}
|
||||
|
||||
$return_data["success"] = TRUE;
|
||||
$item = array(
|
||||
"id" => "{$id}-{$id_part}:{$fc["ref"]}",
|
||||
"name" => htmlspecialchars(i18n_get_translated($fc["name"])),
|
||||
"class" => ($is_featured_collection_category ? "Featured" : "Col"),
|
||||
"expandable" => ($is_featured_collection_category ? "true" : "false"), # lib/js/browsebar_js.php requires this to be a string.
|
||||
"link" => $link,
|
||||
"modal" => false,
|
||||
"drop" => !$is_featured_collection_category,
|
||||
);
|
||||
|
||||
$return_items[$n] = $item;
|
||||
$n++;
|
||||
}
|
||||
|
||||
$return_data["success"] = true;
|
||||
$return_data["items"] = $return_items;
|
||||
break;
|
||||
break;
|
||||
|
||||
case "C":
|
||||
// My collections
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
<?php
|
||||
if (file_exists('../include/collections_functions.php')){
|
||||
$relpath = '..';
|
||||
} else {
|
||||
$relpath = '../..';
|
||||
}
|
||||
|
||||
include_once "$relpath/include/db.php";
|
||||
|
||||
include_once "$relpath/include/authenticate.php";
|
||||
|
||||
$max_theme_levels = get_max_theme_levels(); // max number of theme columns currently in table
|
||||
|
||||
|
||||
function getThemeList($parents=array()){
|
||||
if (count($parents) == 0){
|
||||
// just retrieve all the top level themes
|
||||
$sql = "select distinct theme as value from collection where theme is not null and theme <> '' order by theme";
|
||||
} else {
|
||||
// we were passed an array of parents, so we need to narrow our search
|
||||
for ($i = 1; $i < count($parents)+1; $i++){
|
||||
if ($i == 1){
|
||||
$searchfield = 'theme';
|
||||
} else {
|
||||
$searchfield = "theme$i";
|
||||
}
|
||||
|
||||
$whereclause = "$searchfield = '" . escape_check($parents[$i-1]) . "' ";
|
||||
}
|
||||
$sql = "select distinct theme$i as value from collection where $whereclause and theme$i is not null and theme$i <> '' order by theme$i";
|
||||
//echo $sql;
|
||||
}
|
||||
$result = sql_array($sql);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$themestring = getval('themestring','');
|
||||
if ($themestring <> ''){
|
||||
$themearr = explode("||", $themestring);
|
||||
} else {
|
||||
$themearr = array();
|
||||
}
|
||||
?>
|
||||
<!-- Beginning of theme level list -->
|
||||
<div id="themelevellist" class="themelevellist">
|
||||
<?php
|
||||
$i = 0;
|
||||
$parents = array();
|
||||
|
||||
do {
|
||||
|
||||
if (isset($themearr[$i])){
|
||||
$thisval = $themearr[$i];
|
||||
} else {
|
||||
$thisval = '';
|
||||
}
|
||||
|
||||
if ($i==0){$themeindex="";}else{$themeindex=$i+1;}
|
||||
|
||||
?>
|
||||
<div class='themelevelinstance' id="themelevel<?php echo $i ?>">
|
||||
<div class="Question">
|
||||
<label for="theme<?php echo $i ?>"><?php echo $lang["themecategory"] . " ".$themeindex ?></label>
|
||||
<select class="stdwidth" name="theme<?php echo $i ?>" id="theme<?php echo $i ?>" onchange="updateThemeLevels(<?php echo $i ?>);"><option value=""><?php echo $lang["select"]?></option>
|
||||
<?php
|
||||
if ($thisval == ''){
|
||||
$printedval = true;
|
||||
} else {
|
||||
$printedval = false;
|
||||
}
|
||||
|
||||
foreach (getThemeList($parents) as $theoption){
|
||||
if ($theoption == $thisval){
|
||||
echo "<option selected>" . htmlspecialchars($theoption) . "</option>";
|
||||
$printedval = true;
|
||||
} else {
|
||||
echo "<option>" . htmlspecialchars($theoption) . "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
if (!$printedval) {
|
||||
// we never found the currently selected value, so we'll add it at the bottom.
|
||||
echo "<option selected>" . htmlspecialchars($thisval) . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="clearerleft"> </div>
|
||||
<label><?php echo $lang["newcategoryname"]?></label>
|
||||
<input type=text class="medwidth" name="newtheme<?php echo $i ?>" id="newtheme<?php echo $i ?>" value="">
|
||||
<input type=button class="medcomplementwidth" value="<?php echo $lang["save"]?>" onclick="updateThemeLevels(<?php echo $i ?>);"/>
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$parents[] = $thisval;
|
||||
if ($thisval == '' && $i > 0) {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
} while ( $i <= count($themearr) && $i < $theme_category_levels);
|
||||
|
||||
|
||||
?>
|
||||
</div>
|
||||
<!-- end of themelevellist -->
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
include "../include/db.php";
|
||||
|
||||
include "../include/authenticate.php";
|
||||
|
||||
if (getval("save","")!="" && enforcePostRequest(false))
|
||||
|
@ -9,7 +8,7 @@ if (getval("save","")!="" && enforcePostRequest(false))
|
|||
rs_setcookie("language", getval("language", ""), 1000, $baseurl_short);
|
||||
rs_setcookie("language", getval("language", ""), 1000, $baseurl_short . "pages/");
|
||||
log_activity($lang["languageselection"],LOG_CODE_EDITED,getval("language", ""));
|
||||
redirect(getval("uri",$baseurl_short."pages/" . ($use_theme_as_home?'themes.php':($use_recent_as_home?"search.php?search=!last1000":$default_home_page))));
|
||||
redirect(getval("uri",$baseurl_short."pages/" . ($use_theme_as_home?'collections_featured.php':($use_recent_as_home?"search.php?search=!last1000":$default_home_page))));
|
||||
}
|
||||
include "../include/header.php";
|
||||
?>
|
||||
|
|
|
@ -19,9 +19,8 @@ $multi_edit=allow_multi_edit($ref);
|
|||
if (!collection_writeable($ref))
|
||||
{exit($lang["no_access_to_collection"]);}
|
||||
|
||||
|
||||
# Fetch collection data
|
||||
$collection=get_collection($ref);
|
||||
|
||||
if ($collection===false)
|
||||
{
|
||||
$error=$lang['error-collectionnotfound'];
|
||||
|
@ -29,10 +28,14 @@ if ($collection===false)
|
|||
exit();
|
||||
}
|
||||
|
||||
if($collection["type"] != COLLECTION_TYPE_STANDARD)
|
||||
if(!in_array($collection["type"], array(COLLECTION_TYPE_STANDARD, COLLECTION_TYPE_PUBLIC, COLLECTION_TYPE_FEATURED)))
|
||||
{
|
||||
exit(error_alert($lang["error-permissiondenied"], true, 401));
|
||||
}
|
||||
else if($collection["type"] == COLLECTION_TYPE_FEATURED && !featured_collection_check_access_control((int) $collection["ref"]))
|
||||
{
|
||||
exit(error_alert($lang["error-permissiondenied"], true, 403));
|
||||
}
|
||||
|
||||
$resources=do_search("!collection".$ref);
|
||||
$colcount=count($resources);
|
||||
|
@ -48,33 +51,33 @@ if ($copy!="")
|
|||
if (getval("submitted","")!="" && enforcePostRequest(false))
|
||||
{
|
||||
# Save collection data
|
||||
$coldata["name"] = getval("name","");
|
||||
$coldata["allow_changes"] = getval("allow_changes","") != "" ? 1 : 0;
|
||||
//$public = getvalescaped('public', 0, true);
|
||||
$coldata["public"] = getval('public', 0, true);
|
||||
$coldata["keywords"] = getval("keywords","");
|
||||
$coldata["description"] = getval("description","");
|
||||
hook('saveadditionalfields');
|
||||
$coldata["name"] = getval("name","");
|
||||
$coldata["allow_changes"] = getval("allow_changes","") != "" ? 1 : 0;
|
||||
$coldata["public"] = getval('public', 0, true);
|
||||
$coldata["keywords"] = getval("keywords","");
|
||||
$coldata["description"] = getval("description","");
|
||||
|
||||
for($n=1;$n<=$theme_category_levels;$n++)
|
||||
if($collection["public"] == 1 && getval("update_parent", "") == "true")
|
||||
{
|
||||
if ($n==1)
|
||||
// Prepare coldata for save_collection() for posted featured collections (if any changes have been made)
|
||||
$current_branch_path = get_featured_collection_category_branch_by_leaf((int) $ref, array());
|
||||
$featured_collections_changes = process_posted_featured_collection_categories(0, $current_branch_path);
|
||||
if(!empty($featured_collections_changes))
|
||||
{
|
||||
$themeindex = "";
|
||||
$coldata["featured_collections_changes"] = $featured_collections_changes;
|
||||
}
|
||||
else
|
||||
{
|
||||
$themeindex = $n;
|
||||
}
|
||||
$themename = getval("theme$themeindex","");
|
||||
$coldata["theme" . $themeindex] = $themename;
|
||||
|
||||
if (getval("newtheme$themeindex","")!="")
|
||||
{
|
||||
$coldata["theme". $themeindex] = trim(getval("newtheme$themeindex",""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// User selected a background image
|
||||
if($enable_themes && $themes_simple_images && $collection["public"] == 1 && checkperm("h"))
|
||||
{
|
||||
$thumbnail_selection_method = getval("thumbnail_selection_method", $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["no_image"], true);
|
||||
if(in_array($thumbnail_selection_method, $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS))
|
||||
{
|
||||
$coldata["featured_collections_changes"]["thumbnail_selection_method"] = $thumbnail_selection_method;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkperm("h"))
|
||||
{
|
||||
$coldata["home_page_publish"] = (getval("home_page_publish","") != "") ? "1" : "0";
|
||||
|
@ -84,28 +87,29 @@ if (getval("submitted","")!="" && enforcePostRequest(false))
|
|||
$coldata["home_page_image"] = getval("home_page_image","");
|
||||
}
|
||||
}
|
||||
|
||||
hook('saveadditionalfields'); # keep it close to save_collection(). Plugins should access any $coldata at this point
|
||||
save_collection($ref, $coldata);
|
||||
if (getval("redirect","")!="")
|
||||
{
|
||||
if (getval("addlevel","")=="yes"){
|
||||
redirect ($baseurl_short."pages/collection_edit.php?ref=".$ref."&addlevel=yes");
|
||||
}
|
||||
else if ((getval("theme","")!="") || (getval("newtheme","")!=""))
|
||||
{
|
||||
redirect ($baseurl_short."pages/themes.php?manage=true");
|
||||
}
|
||||
else
|
||||
{
|
||||
redirect($baseurl_short . 'pages/collection_manage.php?offset=' . $offset . '&col_order_by=' . $col_order_by . '&sort=' . $sort . '&find=' . urlencode($find) . '&reload=true');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# No redirect, we stay on this page. Reload the collection info.
|
||||
$collection=get_collection($ref);
|
||||
|
||||
if(getval("redirect", "") != "")
|
||||
{
|
||||
redirect(generateURL(
|
||||
"{$baseurl_short}pages/collection_manage.php",
|
||||
array(
|
||||
"offset" => $offset,
|
||||
"col_order_by" => $col_order_by,
|
||||
"sort" => $sort,
|
||||
"find" => $find,
|
||||
"reload" => "true",
|
||||
)));
|
||||
}
|
||||
else
|
||||
{
|
||||
# No redirect, we stay on this page. Reload the collection info.
|
||||
$collection = get_collection($ref);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
include "../include/header.php";
|
||||
?>
|
||||
<div class="BasicsBox">
|
||||
|
@ -116,6 +120,7 @@ include "../include/header.php";
|
|||
<input type="hidden" name="redirect" id="redirect" value="yes" >
|
||||
<input type=hidden name=ref value="<?php echo htmlspecialchars($ref) ?>">
|
||||
<input type=hidden name="submitted" value="true">
|
||||
<input type=hidden name="update_parent" value="false">
|
||||
<div class="Question">
|
||||
<label for="name"><?php echo $lang["name"]?></label>
|
||||
<input type=text class="stdwidth" name="name" id="name" value="<?php echo htmlspecialchars($collection["name"]) ?>" maxlength="100" <?php if ($collection["cant_delete"]==1) { ?>readonly=true<?php } ?>>
|
||||
|
@ -181,9 +186,14 @@ include "../include/header.php";
|
|||
} ?>
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ($collection["public"]==0 || (($collection['public']==1 && !$themes_in_my_collections && $collection['theme']=='') || ($collection['public']==1 && $themes_in_my_collections) ))
|
||||
<?php
|
||||
if(
|
||||
$collection["public"] == 0
|
||||
|| (
|
||||
($collection['type'] == COLLECTION_TYPE_PUBLIC && !$themes_in_my_collections)
|
||||
|| ($collection['type'] == COLLECTION_TYPE_FEATURED && $themes_in_my_collections)
|
||||
)
|
||||
)
|
||||
{
|
||||
if (!hook("replaceuserselect"))
|
||||
{?>
|
||||
|
@ -207,10 +217,38 @@ include "../include/header.php";
|
|||
} /* end hook replaceuserselect */
|
||||
}
|
||||
|
||||
if ($collection['public']==1)
|
||||
{
|
||||
include __DIR__ . '/../include/collection_theme_select.php';
|
||||
}
|
||||
if($enable_themes && $collection['public'] == 1 && checkperm("h"))
|
||||
{
|
||||
render_featured_collection_category_selector(
|
||||
0,
|
||||
array(
|
||||
"collection" => $collection,
|
||||
"depth" => 0,
|
||||
"current_branch_path" => get_featured_collection_category_branch_by_leaf((int) $collection["ref"], array()),
|
||||
));
|
||||
|
||||
if($themes_simple_images && $collection["type"] == COLLECTION_TYPE_FEATURED)
|
||||
{
|
||||
$configurable_options = array(
|
||||
$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["no_image"] => $lang["select"],
|
||||
$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"] => $lang["background_most_popular_image"],
|
||||
$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_images"] => str_replace("%n", $theme_images_number, $lang["background_most_popular_images"]),
|
||||
);
|
||||
|
||||
if($collection_commenting)
|
||||
{
|
||||
$configurable_options[$FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["manual"]] = $lang["background_manual_selection"];
|
||||
}
|
||||
|
||||
render_dropdown_question(
|
||||
$lang["background_image"],
|
||||
"thumbnail_selection_method",
|
||||
$configurable_options,
|
||||
$collection["thumbnail_selection_method"],
|
||||
'class="stdwidth"'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (checkperm("h") && $collection['public']==1 && !$home_dash)
|
||||
{
|
||||
|
@ -282,13 +320,10 @@ include "../include/header.php";
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
if(getval("reload","") == "true" && getval("ajax","") != "")
|
||||
{
|
||||
refresh_collection_frame();
|
||||
}
|
||||
|
||||
include "../include/footer.php";
|
||||
?>
|
||||
include "../include/footer.php";
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
include "../include/db.php";
|
||||
include "../include/authenticate.php"; #if (!checkperm("s")) {exit ("Permission denied.");}
|
||||
include "../include/authenticate.php";
|
||||
|
||||
|
||||
$collection_url = getvalescaped("collection","");
|
||||
|
@ -10,98 +10,113 @@ $order_by = getvalescaped("order_by","");
|
|||
$sort = getvalescaped("sort","");
|
||||
$search = getvalescaped("search","");
|
||||
$starsearch = getvalescaped('starsearch', '', true);
|
||||
$themeshare = getvalescaped("catshare","false");
|
||||
$themecount = 0;
|
||||
if(getvalescaped("subthemes","false")!="false"){$subthemes=true;}else{$subthemes=false;}
|
||||
$linksuffix = "?";
|
||||
$ref = getvalescaped("ref","");
|
||||
$refArray[] = $ref;
|
||||
$ref = getvalescaped("ref", 0, true);
|
||||
|
||||
$collection = get_collection($ref);
|
||||
if($collection === false)
|
||||
{
|
||||
exit(error_alert($lang["error-collectionnotfound"], true, 403));
|
||||
}
|
||||
|
||||
# Check access
|
||||
if (!$themeshare && !collection_readable($ref)) {exit($lang["no_access_to_collection"]);}
|
||||
if($collection["type"] == COLLECTION_TYPE_FEATURED)
|
||||
{
|
||||
$collection_resources = get_collection_resources($collection["ref"]);
|
||||
$collection["has_resources"] = (is_array($collection_resources) && !empty($collection_resources) ? 1 : 0);
|
||||
}
|
||||
|
||||
// Check access controls
|
||||
if(!collection_readable($ref))
|
||||
{
|
||||
exit($lang["no_access_to_collection"]);
|
||||
}
|
||||
else if($collection["type"] == COLLECTION_TYPE_FEATURED && !featured_collection_check_access_control((int) $collection["ref"]))
|
||||
{
|
||||
exit(error_alert($lang["error-permissiondenied"], true, 403));
|
||||
}
|
||||
if(!$allow_share || checkperm("b"))
|
||||
{
|
||||
exit(error_alert($lang["error-permissiondenied"], true, 403));
|
||||
}
|
||||
|
||||
if ($themeshare!="false")
|
||||
{
|
||||
$themeshare=true;
|
||||
# came here from theme category share page
|
||||
$themes=array("");
|
||||
reset($_POST);reset($_GET);
|
||||
foreach (array_merge($_GET, $_POST) as $key=>$value)
|
||||
{
|
||||
// only set necessary vars
|
||||
if (substr($key,0,5)=="theme" && $value!=""){
|
||||
$themes[$themecount]=rawurldecode($value);
|
||||
$themecount++;
|
||||
}
|
||||
}
|
||||
for ($x=0;$x<count($themes);$x++){
|
||||
if ($x!=0){ $linksuffix.="&"; }
|
||||
$linksuffix.="theme" . ($x+1);
|
||||
$linksuffix.="=". urlencode($themes[$x]);
|
||||
$themename=$themes[$x];
|
||||
}
|
||||
$collectionstoshare=get_themes($themes,$subthemes);
|
||||
foreach($collectionstoshare as $collection)
|
||||
{
|
||||
if ($ref!=""){$ref.=", ";}
|
||||
$ref.=$collection["ref"];
|
||||
}
|
||||
$ref=explode(", ",$ref);$ref=array_unique($ref);$ref=implode(",",$ref);
|
||||
$refArray = explode(',',$ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
$themeshare=false;
|
||||
$themename="";
|
||||
# Fetch collection data
|
||||
if (!is_numeric($ref)) ## multiple collections may be referenced
|
||||
{
|
||||
$refArray = explode(',',$ref);
|
||||
$collection=get_collection($refArray[0]);if ($collection===false) {exit("Collection not found.");}
|
||||
}
|
||||
else {
|
||||
$collection=get_collection($ref);if ($collection===false) {exit("Collection not found.");}
|
||||
}
|
||||
}
|
||||
|
||||
#Check if sharing allowed
|
||||
if (!$allow_share) {
|
||||
$show_error=true;
|
||||
$error=$lang["error-permissiondenied"];
|
||||
$themeshare = false;
|
||||
$themename = "";
|
||||
$subthemes = (getval("subthemes", "false") != "false");
|
||||
if(is_featured_collection_category($collection))
|
||||
{
|
||||
$themeshare = true;
|
||||
$themename = i18n_get_translated($collection["name"]);
|
||||
|
||||
// Check this is not an empty FC category
|
||||
if(empty(get_featured_collection_resources($collection, array("limit" => 1))))
|
||||
{
|
||||
exit(error_alert($lang["cannotshareemptythemecategory"], true, 403));
|
||||
}
|
||||
|
||||
|
||||
$user_select_internal=checkperm("noex") || intval($user_dl_limit) > 0;
|
||||
|
||||
#Check if any resources are not in the active state
|
||||
foreach ($refArray as $colref){
|
||||
if (!$collection_allow_not_approved_share && !is_collection_approved(trim($colref)))
|
||||
{
|
||||
$show_error=true;
|
||||
// Further checks at collection-resource level. Recurse through category's sub FCs
|
||||
if($subthemes)
|
||||
{
|
||||
$sub_fcs = get_featured_collection_categ_sub_fcs($collection);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sub_fcs = get_featured_collections($collection["ref"], array());
|
||||
$sub_fcs = array_filter($sub_fcs, function($fc) { return !is_featured_collection_category($fc, array()); });
|
||||
$sub_fcs = array_values(array_column($sub_fcs, "ref"));
|
||||
}
|
||||
$collection["sub_fcs"] = $sub_fcs;
|
||||
$sub_fcs_resources_states = array();
|
||||
$sub_fcs_resources_minaccess = array();
|
||||
foreach($collection["sub_fcs"] as $sub_fc)
|
||||
{
|
||||
// Check all featured collections contain only active resources
|
||||
$collectionstates = is_collection_approved($sub_fc);
|
||||
if(!$collection_allow_not_approved_share && $collectionstates === false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(is_array($collectionstates))
|
||||
{
|
||||
$sub_fcs_resources_states = array_unique(array_merge($sub_fcs_resources_states, $collectionstates));
|
||||
}
|
||||
|
||||
// Check minimum access is restricted or lower and sharing of restricted resources is not allowed
|
||||
$sub_fcs_resources_minaccess[] = collection_min_access($sub_fc);
|
||||
}
|
||||
$collectionstates = (!empty($sub_fcs_resources_states) ? $sub_fcs_resources_states : $collectionstates);
|
||||
|
||||
if(!empty($sub_fcs_resources_minaccess))
|
||||
{
|
||||
$minaccess = max(array_unique($sub_fcs_resources_minaccess));
|
||||
}
|
||||
}
|
||||
|
||||
$collectionstates = (isset($collectionstates) ? $collectionstates : is_collection_approved($ref));
|
||||
if(!$collection_allow_not_approved_share && $collectionstates == false)
|
||||
{
|
||||
$show_error=true;
|
||||
$error=$lang["notapprovedsharecollection"];
|
||||
}
|
||||
}
|
||||
|
||||
# Get min access to this collection
|
||||
foreach ($refArray as $colref){
|
||||
$minaccess=collection_min_access(trim($colref));
|
||||
}
|
||||
}
|
||||
|
||||
# Minimum access is restricted or lower and sharing of restricted resources is not allowed. The user cannot share this collection.
|
||||
$minaccess = (isset($minaccess) ? $minaccess : collection_min_access($ref));
|
||||
if(!$restricted_share && $minaccess >= RESOURCE_ACCESS_RESTRICTED)
|
||||
{
|
||||
$show_error = true;
|
||||
$error = $lang["restrictedsharecollection"];
|
||||
}
|
||||
|
||||
if ($minaccess>=1 && !$restricted_share) # Minimum access is restricted or lower and sharing of restricted resources is not allowed. The user cannot share this collection.
|
||||
{
|
||||
$show_error=true;
|
||||
$error=$lang["restrictedsharecollection"];
|
||||
}
|
||||
|
||||
if (isset($show_error)){?>
|
||||
<script type="text/javascript">
|
||||
alert('<?php echo $error;?>');
|
||||
history.go(-1);
|
||||
</script><?php
|
||||
exit();}
|
||||
|
||||
|
||||
$internal_share_only = checkperm("noex") || (isset($user_dl_limit) && intval($user_dl_limit) > 0);
|
||||
|
||||
// Legacy way of working when sharing a FC category. It relies on a list of collections
|
||||
$ref = ($themeshare ? join(",", array_merge(array($collection["ref"]), $collection["sub_fcs"])) : $ref);
|
||||
|
||||
$errors="";
|
||||
if (getval("save","")!="" && enforcePostRequest(getval("ajax", false)))
|
||||
{
|
||||
|
@ -122,8 +137,8 @@ if (getval("save","")!="" && enforcePostRequest(getval("ajax", false)))
|
|||
if (!$use_user_email){$from_name=$applicationname;} else {$from_name=$userfullname;} // make sure from_name matches email
|
||||
|
||||
if (getval("ccme",false)){ $cc=$useremail;} else {$cc="";}
|
||||
$errors=email_collection($ref,i18n_get_collection_name($collection),$userfullname,$users,$message,$feedback,$access,$expires,$user_email,$from_name,$cc,$themeshare,$themename,$linksuffix,$list_recipients,$add_internal_access,$group, $sharepwd);
|
||||
|
||||
$errors = email_collection($ref,i18n_get_collection_name($collection),$userfullname,$users,$message,$feedback,$access,$expires,$user_email,$from_name,$cc,$themeshare,$themename, "",$list_recipients,$add_internal_access,$group, $sharepwd);
|
||||
if ($errors=="")
|
||||
{
|
||||
# Log this
|
||||
|
@ -151,7 +166,7 @@ include "../include/header.php";
|
|||
<?php
|
||||
|
||||
$link_array = array(
|
||||
"ref" => $ref,
|
||||
"ref" => $collection["ref"],
|
||||
"search" => $search,
|
||||
"offset" => $offset,
|
||||
"order_by" => $order_by,
|
||||
|
@ -176,9 +191,9 @@ else
|
|||
render_help_link("user/sharing-resources");?>
|
||||
</p>
|
||||
|
||||
<form name="collectionform" method=post id="collectionform" action="<?php echo $baseurl_short?>pages/collection_email.php<?php echo $linksuffix ?>&catshare=<?php if($themeshare==true){echo "true";}else{echo "false";}?>">
|
||||
<form name="collectionform" method=post id="collectionform" action="<?php echo $baseurl_short?>pages/collection_email.php?catshare=<?php if($themeshare==true){echo "true";}else{echo "false";}?>">
|
||||
<input type=hidden name=redirect id=redirect value=yes>
|
||||
<input type=hidden name=ref id="ref" value="<?php echo htmlspecialchars(trim($refArray[0])) ?>">
|
||||
<input type=hidden name=ref id="ref" value="<?php echo htmlspecialchars($collection["ref"]); ?>">
|
||||
<?php
|
||||
generateFormToken("collectionform");
|
||||
|
||||
|
@ -200,16 +215,16 @@ if ($email_multi_collections && !$themeshare) { ?>
|
|||
</script>
|
||||
<?php }
|
||||
|
||||
|
||||
if ($themeshare)
|
||||
{?>
|
||||
<div class="Question">
|
||||
<label for="subthemes"><?php echo $lang["share_theme_category_subcategories"]?></label>
|
||||
<input type="checkbox" id="subthemes" name="subthemes" value="true" <?php if ($subthemes){echo "checked";} ?>>
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
if($themeshare)
|
||||
{
|
||||
?>
|
||||
<div class="Question">
|
||||
<label for="subthemes"><?php echo $lang["share_theme_category_subcategories"]; ?></label>
|
||||
<input type="checkbox" id="subthemes" name="subthemes" value="true" <?php echo ($subthemes ? "checked" : ""); ?>>
|
||||
<div class="clearerleft"></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{?>
|
||||
<div class="Question">
|
||||
|
@ -280,7 +295,7 @@ else
|
|||
<div class="Question">
|
||||
|
||||
<label for="users">
|
||||
<?php echo ($user_select_internal)?$lang["emailtousers_internal"]:$lang["emailtousers"]; ?>
|
||||
<?php echo ($internal_share_only)?$lang["emailtousers_internal"]:$lang["emailtousers"]; ?>
|
||||
</label><?php $userstring=getval("users","");include "../include/user_select.php"; ?>
|
||||
<div class="clearerleft"> </div>
|
||||
<?php if ($errors!="") { ?><div class="FormError">!! <?php echo $errors?> !!</div><?php } ?>
|
||||
|
@ -305,10 +320,10 @@ if($allow_edit)
|
|||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
if(!$user_select_internal)
|
||||
if(!$internal_share_only)
|
||||
{
|
||||
render_share_options(true, $ref, true);
|
||||
} // End of section checking $user_select_internal
|
||||
} // End of section checking $internal_share_only
|
||||
|
||||
hook("collectionemailafterexternal");
|
||||
?>
|
||||
|
|
|
@ -14,7 +14,7 @@ $revsort = ($sort=="ASC") ? "DESC" : "ASC";
|
|||
# pager
|
||||
$per_page=getvalescaped("per_page_list",$default_perpage_list,true);rs_setcookie('per_page_list', $per_page);
|
||||
|
||||
$collection_valid_order_bys=array("fullname","name","ref","count","public");
|
||||
$collection_valid_order_bys=array("fullname","name","ref","count","type");
|
||||
$modified_collection_valid_order_bys=hook("modifycollectionvalidorderbys");
|
||||
if ($modified_collection_valid_order_bys){$collection_valid_order_bys=$modified_collection_valid_order_bys;}
|
||||
if (!in_array($col_order_by,$collection_valid_order_bys)) {$col_order_by="created";} # Check the value is one of the valid values (SQL injection filter)
|
||||
|
@ -26,20 +26,27 @@ if('' != $name && $collection_allow_creation && enforcePostRequest(false))
|
|||
{
|
||||
// Create new collection
|
||||
$new = create_collection($userref, $name);
|
||||
$redirect_url = "pages/collection_edit.php?ref={$new}&reload=true";
|
||||
|
||||
// This is used to create collections directly from featured collections page when in simpleview mode
|
||||
if($themes_simple_view && filter_var(getvalescaped('call_to_action_tile', false), FILTER_VALIDATE_BOOLEAN))
|
||||
// This is used to create featured collections directly from the featured collections page
|
||||
if($enable_themes && getval("call_to_action_tile", "") === "true" && checkperm("h"))
|
||||
{
|
||||
$coldata = array("name" => $name);
|
||||
$parent = (int) getval("parent", 0, true);
|
||||
$coldata = array(
|
||||
"name" => $name,
|
||||
"featured_collections_changes" => array("update_parent" => $parent, "force_featured_collection_type" => true),
|
||||
);
|
||||
$redirect_params = ($parent == 0 ? array() : array("parent" => $parent));
|
||||
$redirect_url = generateURL("{$baseurl_short}pages/collections_featured.php", $redirect_params);
|
||||
|
||||
save_collection($new,$coldata);
|
||||
}
|
||||
|
||||
set_user_collection($userref, $new);
|
||||
|
||||
// Log this
|
||||
daily_stat('New collection', $userref);
|
||||
|
||||
redirect("pages/collection_edit.php?ref={$new}&reload=true");
|
||||
redirect($redirect_url);
|
||||
}
|
||||
|
||||
$delete=getvalescaped("delete","");
|
||||
|
@ -303,7 +310,7 @@ $url=$baseurl_short."pages/collection_manage.php?paging=true&col_order_by=".urle
|
|||
|
||||
<td class="count"><?php if ($col_order_by=="count") {?><span class="Selected"><?php } ?><a href="<?php echo $baseurl_short?>pages/collection_manage.php?offset=0&col_order_by=count&sort=<?php echo urlencode($revsort)?>&find=<?php echo urlencode($find)?>" onClick="return CentralSpaceLoad(this);"><?php echo $lang["itemstitle"]?></a><?php if ($col_order_by=="count") {?><div class="<?php echo urlencode($sort)?>"> </div><?php } ?></td>
|
||||
|
||||
<?php if (!$hide_access_column){ ?><td class="access"><?php if ($col_order_by=="public") {?><span class="Selected"><?php } ?><a href="<?php echo $baseurl_short?>pages/collection_manage.php?offset=0&col_order_by=public&sort=<?php echo urlencode($revsort)?>&find=<?php echo urlencode($find)?>" onClick="return CentralSpaceLoad(this);"><?php echo $lang["access"]?></a><?php if ($col_order_by=="public") {?><div class="<?php echo urlencode($sort)?>"> </div><?php } ?></td><?php }?>
|
||||
<?php if (!$hide_access_column){ ?><td class="access"><?php if ($col_order_by=="type") {?><span class="Selected"><?php } ?><a href="<?php echo $baseurl_short?>pages/collection_manage.php?offset=0&col_order_by=type&sort=<?php echo urlencode($revsort)?>&find=<?php echo urlencode($find)?>" onClick="return CentralSpaceLoad(this);"><?php echo $lang["access"]?></a><?php if ($col_order_by=="type") {?><div class="<?php echo urlencode($sort)?>"> </div><?php } ?></td><?php }?>
|
||||
|
||||
<td class="collectionin"><?php echo $lang["showcollectionindropdown"] ?></td>
|
||||
|
||||
|
@ -319,26 +326,30 @@ for ($n=$offset;(($n<count($collections)) && ($n<($offset+$per_page)));$n++)
|
|||
$count_result = $collections[$n]["count"];
|
||||
?><tr <?php hook("collectionlistrowstyle");?>>
|
||||
<td class="name"><div class="ListTitle">
|
||||
<a <?php if ($collections[$n]["public"]==1 && (strlen($collections[$n]["theme"])>0)) { ?>style="font-style:italic;"<?php } ?> href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode("!collection" . $collections[$n]["ref"])?>" onClick="return CentralSpaceLoad(this);"><?php echo strip_tags_and_attributes(highlightkeywords(htmlspecialchars_decode(i18n_get_collection_name($collections[$n])), $find)); ?></a></div></td>
|
||||
<a <?php if($collections[$n]["type"] == COLLECTION_TYPE_FEATURED) { ?>style="font-style:italic;"<?php } ?> href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode("!collection" . $collections[$n]["ref"])?>" onClick="return CentralSpaceLoad(this);"><?php echo strip_tags_and_attributes(highlightkeywords(htmlspecialchars_decode(i18n_get_collection_name($collections[$n])), $find)); ?></a></div></td>
|
||||
<td class="fullname"><?php echo strip_tags_and_attributes(highlightkeywords($colusername, $find)); ?></td>
|
||||
<td class="ref"><?php echo strip_tags_and_attributes(highlightkeywords($collection_prefix . $collections[$n]["ref"], $find)); ?></td>
|
||||
<td class="created"><?php echo nicedate($collections[$n]["created"],true) ?></td>
|
||||
<td class="count"><?php echo $collections[$n]["count"] ?></td>
|
||||
<?php if (! $hide_access_column){ ?> <td class="access"><?php
|
||||
# Work out the correct access mode to display
|
||||
if (!hook('collectionaccessmode')) {
|
||||
if ($collections[$n]["public"]==0){
|
||||
echo $lang["private"];
|
||||
}
|
||||
else{
|
||||
if (strlen($collections[$n]["theme"])>0){
|
||||
echo $lang["theme"];
|
||||
}
|
||||
else{
|
||||
echo $lang["public"];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!hook('collectionaccessmode'))
|
||||
{
|
||||
switch($collections[$n]["type"])
|
||||
{
|
||||
case COLLECTION_TYPE_PUBLIC:
|
||||
echo $lang["public"];
|
||||
break;
|
||||
|
||||
case COLLECTION_TYPE_FEATURED:
|
||||
echo $lang["theme"];
|
||||
break;
|
||||
|
||||
case COLLECTION_TYPE_STANDARD:
|
||||
default:
|
||||
echo $lang["private"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
?></td><?php
|
||||
}?>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ $revsort = ($sort=="ASC") ? "DESC" : "ASC";
|
|||
# pager
|
||||
$per_page=getvalescaped("per_page_list",$default_perpage_list,true);rs_setcookie('per_page_list', $per_page);
|
||||
|
||||
$collection_valid_order_bys=array("fullname","name","ref","count","public","created");
|
||||
$collection_valid_order_bys=array("fullname","name","ref","count","type","created");
|
||||
$modified_collection_valid_order_bys=hook("modifycollectionvalidorderbys");
|
||||
if ($modified_collection_valid_order_bys){$collection_valid_order_bys=$modified_collection_valid_order_bys;}
|
||||
if (!in_array($col_order_by,$collection_valid_order_bys)) {$col_order_by="created";} # Check the value is one of the valid values (SQL injection filter)
|
||||
|
@ -174,7 +174,7 @@ echo "<br />";
|
|||
|
||||
<td class="count"><?php if ($col_order_by=="count") {?><span class="Selected"><?php } ?><a href="<?php echo $baseurl_short?>pages/collection_public.php?offset=0&col_order_by=count&sort=<?php echo urlencode($revsort)?>&find=<?php echo urlencode($find)?>" onClick="return CentralSpaceLoad(this);"><?php echo $lang["itemstitle"]?></a><?php if ($col_order_by=="count") {?><div class="<?php echo urlencode($sort)?>"> </div><?php } ?></td>
|
||||
|
||||
<?php if (!$hide_access_column_public){ ?><td class="access"><?php if ($col_order_by=="public") {?><span class="Selected"><?php } ?><a href="<?php echo $baseurl_short?>pages/collection_public.php?offset=0&col_order_by=public&sort=<?php echo urlencode($revsort)?>&find=<?php echo urlencode($find)?>" onClick="return CentralSpaceLoad(this);"><?php echo $lang["access"]?></a><?php if ($col_order_by=="public") {?><div class="<?php echo urlencode($sort)?>"> </div><?php } ?></td><?php } ?>
|
||||
<?php if (!$hide_access_column_public){ ?><td class="access"><?php if ($col_order_by=="type") {?><span class="Selected"><?php } ?><a href="<?php echo $baseurl_short?>pages/collection_public.php?offset=0&col_order_by=type&sort=<?php echo urlencode($revsort)?>&find=<?php echo urlencode($find)?>" onClick="return CentralSpaceLoad(this);"><?php echo $lang["access"]?></a><?php if ($col_order_by=="public") {?><div class="<?php echo urlencode($sort)?>"> </div><?php } ?></td><?php } ?>
|
||||
<?php hook("beforecollectiontoolscolumnheader");?>
|
||||
|
||||
<td class="tools"><div class="ListTools"><?php echo $lang['actions']?></div></td>
|
||||
|
@ -200,9 +200,24 @@ for ($n=$offset;(($n<count($collections)) && ($n<($offset+$per_page)));$n++)
|
|||
<td class="created"><?php echo nicedate($collections[$n]["created"],true)?></td>
|
||||
<td class="count"><?php echo $collections[$n]["count"]?></td>
|
||||
<?php
|
||||
if (!$hide_access_column_public)
|
||||
{ ?>
|
||||
<td class="access"><?php echo ($collections[$n]["public"]==0)?$lang["private"]:$lang["public"]?></td>
|
||||
if(!$hide_access_column_public)
|
||||
{
|
||||
switch($collections[$n]["type"])
|
||||
{
|
||||
case COLLECTION_TYPE_PUBLIC:
|
||||
$access_str = $lang["public"];
|
||||
break;
|
||||
|
||||
case COLLECTION_TYPE_FEATURED:
|
||||
$access_str = $lang["theme"];
|
||||
break;
|
||||
|
||||
default:
|
||||
$access_str = $lang["private"];
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<td class="access"><?php echo htmlspecialchars($access_str); ?></td>
|
||||
<?php
|
||||
}
|
||||
hook("beforecollectiontoolscolumn");
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
<?php
|
||||
include "../include/db.php";
|
||||
|
||||
include "../include/authenticate.php";
|
||||
if(checkperm("b") || !checkperm("h") || !$enable_themes) {exit ("Permission denied.");} // Must have collections functionality and permission to publish featured collections
|
||||
|
||||
$ref=getvalescaped("ref","",true);
|
||||
$copycollectionremoveall=getvalescaped("copycollectionremoveall","");
|
||||
$offset=getval("offset",0);
|
||||
$find=getvalescaped("find","");
|
||||
$col_order_by=getvalescaped("col_order_by","name");
|
||||
$sort=getval("sort","ASC");
|
||||
|
||||
# Does this user have edit access to collections? Variable will be found in functions below.
|
||||
$multi_edit=allow_multi_edit($ref);
|
||||
|
||||
# Check access
|
||||
if (!collection_writeable($ref))
|
||||
{exit($lang["no_access_to_collection"]);}
|
||||
|
||||
|
||||
# Fetch collection data
|
||||
$collection=get_collection($ref);
|
||||
if ($collection===false)
|
||||
{
|
||||
$error=$lang['error-collectionnotfound'];
|
||||
error_alert($error);
|
||||
exit();
|
||||
}
|
||||
|
||||
if (getval("submitted","")!="" && enforcePostRequest(false))
|
||||
{
|
||||
$categories = array();
|
||||
for($n=0;$n<$theme_category_levels;$n++)
|
||||
{
|
||||
if ($n==0){$themeindex = "";} else {$themeindex = $n+1;}
|
||||
$categories[$n]=getvalescaped("theme$themeindex","");
|
||||
if (getval("newtheme$themeindex","") != "")
|
||||
{
|
||||
$categories[$n]=trim(getvalescaped("newtheme$themeindex",""));
|
||||
}
|
||||
}
|
||||
collection_set_themes($ref, $categories);
|
||||
if (getval("redirect","")!="")
|
||||
{
|
||||
if (getval("addlevel","")=="yes"){
|
||||
redirect ($baseurl_short."pages/collection_set_category.php?ref=".$ref."&addlevel=yes");
|
||||
}
|
||||
else
|
||||
{
|
||||
redirect($baseurl_short . 'pages/search.php?search=!collection' . $ref);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# No redirect, we stay on this page. Reload the collection info.
|
||||
$collection=get_collection($ref);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
include "../include/header.php";
|
||||
?>
|
||||
<div class="BasicsBox">
|
||||
<h1><?php echo $lang["collection_set_theme_category_title"];render_help_link("user/themes-public-collections");?></h1>
|
||||
<p><?php echo text("introtext")?></p>
|
||||
<form method=post id="collectionform" action="<?php echo $baseurl_short?>pages/collection_set_category.php">
|
||||
<?php generateFormToken("collectionform"); ?>
|
||||
<input type=hidden name=ref value="<?php echo htmlspecialchars($ref) ?>">
|
||||
<input type="hidden" name="redirect" id="redirect" value="yes" >
|
||||
<input type=hidden name="submitted" value="true">
|
||||
<div class="Question">
|
||||
<label for="name"><?php echo $lang["collection"]?></label>
|
||||
<div class="Fixed"><?php echo htmlspecialchars(i18n_get_collection_name($collection, $index="name")); ?></div >
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
include __DIR__ . '/../include/collection_theme_select.php';
|
||||
?>
|
||||
|
||||
<div class="QuestionSubmit">
|
||||
<label for="buttons"> </label>
|
||||
<input name="save" type="submit" value=" <?php echo $lang["save"]?> " />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
include "../include/footer.php";
|
||||
?>
|
|
@ -1,9 +1,7 @@
|
|||
<?php
|
||||
include "../include/db.php";
|
||||
|
||||
include "../include/authenticate.php";
|
||||
|
||||
// Fetch vars
|
||||
|
||||
$collection_url = getvalescaped('collection', '', true);
|
||||
$col_order_by = getvalescaped('col_order_by', '', true);
|
||||
|
@ -18,28 +16,38 @@ $starsearch = getvalescaped('starsearch', '', true);
|
|||
$user_group = getvalescaped('usergroup', '', true);
|
||||
$backurl = getvalescaped('backurl', '');
|
||||
|
||||
$collection=get_collection($ref);
|
||||
$collection = get_collection($ref);
|
||||
|
||||
# if bypass sharing page option is on, redirect to e-mail
|
||||
if ($bypass_share_screen && $collection["type"] != COLLECTION_TYPE_SELECTION)
|
||||
if($collection["type"] == COLLECTION_TYPE_FEATURED)
|
||||
{
|
||||
$collection_resources = get_collection_resources($collection["ref"]);
|
||||
$collection["has_resources"] = (is_array($collection_resources) && !empty($collection_resources) ? 1 : 0);
|
||||
}
|
||||
if($bypass_share_screen && $collection["type"] != COLLECTION_TYPE_SELECTION)
|
||||
{
|
||||
redirect('pages/collection_email.php?ref='.$ref ) ;
|
||||
}
|
||||
|
||||
# Check access
|
||||
if (!collection_readable($ref)) {exit($lang["no_access_to_collection"]);}
|
||||
|
||||
#Check if sharing allowed
|
||||
if (checkperm("b") || !$allow_share) {
|
||||
$show_error=true;
|
||||
$error=$lang["error-permissiondenied"];
|
||||
}
|
||||
// Check access controls
|
||||
if(!collection_readable($ref))
|
||||
{
|
||||
exit($lang["no_access_to_collection"]);
|
||||
}
|
||||
else if($collection["type"] == COLLECTION_TYPE_FEATURED && !featured_collection_check_access_control((int) $collection["ref"]))
|
||||
{
|
||||
exit(error_alert($lang["error-permissiondenied"], true, 403));
|
||||
}
|
||||
if(!$allow_share || checkperm("b"))
|
||||
{
|
||||
$show_error = true;
|
||||
$error = $lang["error-permissiondenied"];
|
||||
}
|
||||
|
||||
$internal_share_only = checkperm("noex") || (isset($user_dl_limit) && intval($user_dl_limit) > 0);
|
||||
|
||||
# Check if editing existing external share
|
||||
$editaccess=getvalescaped("editaccess","");
|
||||
($editaccess=="")?$editing=false:$editing=true;
|
||||
$editaccess = trim(getvalescaped("editaccess", ""));
|
||||
$editing = ($editaccess != "");
|
||||
|
||||
$editexternalurl = (getval("editexternalurl","")!="");
|
||||
$deleteaccess = (getval("deleteaccess", "") != "");
|
||||
|
@ -65,14 +73,67 @@ if($collection["type"] == COLLECTION_TYPE_SELECTION)
|
|||
$collection = get_collection($ref);
|
||||
}
|
||||
}
|
||||
// Special collection being shared. Ensure certain features are enabled/disabled
|
||||
else if(is_featured_collection_category($collection))
|
||||
{
|
||||
// Check this is not an empty FC category
|
||||
$fc_resources = get_featured_collection_resources($collection, array("limit" => 1));
|
||||
if(empty($fc_resources))
|
||||
{
|
||||
$show_error = true;
|
||||
$error = $lang["cannotshareemptythemecategory"];
|
||||
}
|
||||
|
||||
// Further checks at collection-resource level. Recurse through category's sub FCs
|
||||
$collection["sub_fcs"] = get_featured_collection_categ_sub_fcs($collection);
|
||||
$sub_fcs_resources_states = array();
|
||||
$sub_fcs_resources_minaccess = array();
|
||||
foreach($collection["sub_fcs"] as $sub_fc)
|
||||
{
|
||||
// Check all featured collections contain only active resources
|
||||
$collectionstates = is_collection_approved($sub_fc);
|
||||
if(!$collection_allow_not_approved_share && $collectionstates === false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(is_array($collectionstates))
|
||||
{
|
||||
$sub_fcs_resources_states = array_unique(array_merge($sub_fcs_resources_states, $collectionstates));
|
||||
}
|
||||
|
||||
// Check minimum access is restricted or lower and sharing of restricted resources is not allowed
|
||||
$sub_fcs_resources_minaccess[] = collection_min_access($sub_fc);
|
||||
}
|
||||
$collectionstates = (!empty($sub_fcs_resources_states) ? $sub_fcs_resources_states : $collectionstates);
|
||||
|
||||
if(!empty($sub_fcs_resources_minaccess))
|
||||
{
|
||||
$minaccess = max(array_unique($sub_fcs_resources_minaccess));
|
||||
}
|
||||
|
||||
// To keep it in line with the legacy theme_category_share.php page, disable these features (home_dash, hide_internal_sharing_url)
|
||||
$home_dash = false;
|
||||
$hide_internal_sharing_url = true;
|
||||
|
||||
// Beyond this point mark accordingly any validations that have been enforced specifically for Featured Collections
|
||||
// (categories or otherwise) type in a different way than for a normal collection
|
||||
// IMPORTANT: make sure there's code above this point (within this block) dealing with these validations.
|
||||
$collection_allow_empty_share = true;
|
||||
}
|
||||
|
||||
// Sharing an empty collection?
|
||||
if (!$collection_allow_empty_share && count(get_collection_resources($ref))==0)
|
||||
{
|
||||
$show_error=true;
|
||||
$error=$lang["cannotshareemptycollection"];
|
||||
}
|
||||
|
||||
#Check if any resources are not active
|
||||
$collectionstates=is_collection_approved($ref);
|
||||
$collectionstates = (isset($collectionstates) ? $collectionstates : is_collection_approved($ref));
|
||||
if (!$collection_allow_not_approved_share && $collectionstates==false) {
|
||||
$show_error=true;
|
||||
$error=$lang["notapprovedsharecollection"];
|
||||
}
|
||||
|
||||
if(is_array($collectionstates) && (count($collectionstates)>1 || !in_array(0,$collectionstates)))
|
||||
{
|
||||
$warningtext=$lang["collection_share_status_warning"];
|
||||
|
@ -82,35 +143,28 @@ if(is_array($collectionstates) && (count($collectionstates)>1 || !in_array(0,$co
|
|||
}
|
||||
}
|
||||
|
||||
# Get min access to this collection
|
||||
$minaccess=collection_min_access($ref);
|
||||
|
||||
if (($minaccess>=1 && !$restricted_share)) # Minimum access is restricted or lower and sharing of restricted resources is not allowed. The user cannot share this collection.
|
||||
{
|
||||
$show_error=true;
|
||||
$error=$lang["restrictedsharecollection"];
|
||||
}
|
||||
|
||||
if (!$collection_allow_empty_share && count(get_collection_resources($ref))==0) # Sharing an empty collection?
|
||||
# Minimum access is restricted or lower and sharing of restricted resources is not allowed. The user cannot share this collection.
|
||||
$minaccess = (isset($minaccess) ? $minaccess : collection_min_access($ref));
|
||||
if(!$restricted_share && $minaccess >= RESOURCE_ACCESS_RESTRICTED)
|
||||
{
|
||||
$show_error=true;
|
||||
$error=$lang["cannotshareemptycollection"];
|
||||
$show_error = true;
|
||||
$error = $lang["restrictedsharecollection"];
|
||||
}
|
||||
|
||||
# Should those that have been granted open access to an otherwise restricted resource be able to share the resource? - as part of a collection
|
||||
if(!$allow_custom_access_share && isset($customgroupaccess) && isset($customuseraccess) && ($customgroupaccess || $customuseraccess))
|
||||
{
|
||||
$show_error=true;
|
||||
$error=$lang["customaccesspreventshare"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# Process deletion of access keys
|
||||
if ($deleteaccess && !isset($show_error) && enforcePostRequest(getval("ajax", false)))
|
||||
{
|
||||
delete_collection_access_key($ref,getvalescaped("deleteaccess",""));
|
||||
}
|
||||
|
||||
if($deleteaccess && !isset($show_error) && enforcePostRequest(getval("ajax", false)))
|
||||
{
|
||||
delete_collection_access_key($ref,getvalescaped("deleteaccess",""));
|
||||
}
|
||||
|
||||
include "../include/header.php";
|
||||
?>
|
||||
|
@ -123,7 +177,6 @@ include "../include/header.php";
|
|||
</script><?php
|
||||
exit();}
|
||||
?>
|
||||
|
||||
<div class="BasicsBox">
|
||||
<form method=post id="collectionform" action="<?php echo $baseurl_short?>pages/collection_share.php?ref=<?php echo urlencode($ref)?>">
|
||||
<input type="hidden" name="ref" id="ref" value="<?php echo htmlspecialchars($ref) ?>">
|
||||
|
@ -168,8 +221,13 @@ include "../include/header.php";
|
|||
if(isset($warningtext))
|
||||
{
|
||||
echo "<div class='PageInformal'>" . $warningtext . "</div>";
|
||||
}?>
|
||||
|
||||
}
|
||||
|
||||
if($collection["type"] == COLLECTION_TYPE_FEATURED && is_featured_collection_category($collection))
|
||||
{
|
||||
echo "<p>" . htmlspecialchars($lang["share_fc_warning"]) . "</p>";
|
||||
}
|
||||
?>
|
||||
<div class="VerticalNav">
|
||||
<ul>
|
||||
<?php
|
||||
|
@ -244,20 +302,20 @@ include "../include/header.php";
|
|||
</div>
|
||||
<?php
|
||||
}
|
||||
else if('' == getvalescaped('editaccess', ''))
|
||||
else if($editaccess == "")
|
||||
{
|
||||
// Access has been selected. Generate a new URL.
|
||||
$generated_access_key = '';
|
||||
|
||||
if(empty($allowed_external_share_groups) || (!empty($allowed_external_share_groups) && in_array($user_group, $allowed_external_share_groups)))
|
||||
{
|
||||
$generated_access_key = generate_collection_access_key($ref, 0, 'URL', $access, $expires, $user_group, $sharepwd);
|
||||
$generated_access_key = generate_collection_access_key($collection, 0, 'URL', $access, $expires, $user_group, $sharepwd);
|
||||
}
|
||||
else if (!empty($allowed_external_share_groups) && !in_array($usergroup, $allowed_external_share_groups))
|
||||
{
|
||||
// Not allowed to select usergroup but this usergroup can not be used, default to the first entry in allowed_external_share_groups
|
||||
$generated_access_key = generate_collection_access_key($ref, 0, 'URL', $access, $expires, $allowed_external_share_groups[0], $sharepwd);
|
||||
}
|
||||
{
|
||||
// Not allowed to select usergroup but this usergroup can not be used, default to the first entry in allowed_external_share_groups
|
||||
$generated_access_key = generate_collection_access_key($collection, 0, 'URL', $access, $expires, $allowed_external_share_groups[0], $sharepwd);
|
||||
}
|
||||
|
||||
if('' != $generated_access_key)
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ if('!collection' === substr($search, 0, 11) && "!collection{$collection}" == $se
|
|||
$change_col_url="search=" . urlencode($search). "&order_by=" . urlencode($order_by) . "&sort=" . urlencode($sort) . "&restypes=" . urlencode($restypes) . "&archive=" .urlencode($archive) . "&daylimit=" . urlencode($daylimit) . "&offset=" . urlencode($offset) . "&resources_count=" . urlencode($resources_count);
|
||||
|
||||
// Set a flag for logged in users if $external_share_view_as_internal is set and logged on user is accessing an external share
|
||||
$internal_share_access = ($k!="" && $external_share_view_as_internal && isset($is_authenticated) && $is_authenticated);
|
||||
$internal_share_access = internal_share_access();
|
||||
|
||||
// copied from collection_manage to support compact style collection adds (without redirecting to collection_manage)
|
||||
$addcollection=getvalescaped("addcollection","");
|
||||
|
|
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
include_once "../include/db.php";
|
||||
|
||||
$k = trim(getval("k", ""));
|
||||
$parent = (int) getval("parent", 0, true);
|
||||
if($k == "" || !check_access_key_collection($parent, $k))
|
||||
{
|
||||
include "../include/authenticate.php";
|
||||
}
|
||||
|
||||
if(!$enable_themes)
|
||||
{
|
||||
http_response_code(403);
|
||||
exit($lang["error-permissiondenied"]);
|
||||
}
|
||||
|
||||
// Access control
|
||||
if($parent > 0 && !featured_collection_check_access_control($parent))
|
||||
{
|
||||
exit(error_alert($lang["error-permissiondenied"], true, 403));
|
||||
}
|
||||
|
||||
$smart_rtf = (int) getval("smart_rtf", 0, true);
|
||||
$smart_fc_parent = getval("smart_fc_parent", 0, true);
|
||||
$smart_fc_parent = ($smart_fc_parent > 0 ? $smart_fc_parent : null);
|
||||
|
||||
$general_url_params = ($k == "" ? array() : array("k" => $k));
|
||||
|
||||
if(getval("new", "") == "true" && getval("cta", "") == "true")
|
||||
{
|
||||
new_featured_collection_form($parent);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
include "../include/header.php";
|
||||
?>
|
||||
<div class="BasicsBox FeaturedSimpleLinks">
|
||||
<?php
|
||||
if($enable_theme_breadcrumbs && $parent > 0)
|
||||
{
|
||||
$links_trail = array(
|
||||
array(
|
||||
"title" => $lang["themes"],
|
||||
"href" => generateURL("{$baseurl_short}pages/collections_featured.php", $general_url_params)
|
||||
)
|
||||
);
|
||||
|
||||
$branch_trail = array_map(function($branch) use ($baseurl_short, $general_url_params)
|
||||
{
|
||||
return array(
|
||||
"title" => i18n_get_translated($branch["name"]),
|
||||
"href" => generateURL("{$baseurl_short}pages/collections_featured.php", $general_url_params, array("parent" => $branch["ref"]))
|
||||
);
|
||||
}, get_featured_collection_category_branch_by_leaf($parent, array()));
|
||||
|
||||
renderBreadcrumbs(array_merge($links_trail, $branch_trail), "", "BreadcrumbsBoxTheme");
|
||||
}
|
||||
|
||||
// Default rendering options (should apply to both FCs and smart FCs)
|
||||
$full_width = !$themes_simple_view;
|
||||
$rendering_options = array(
|
||||
"full_width" => $full_width,
|
||||
"general_url_params" => $general_url_params,
|
||||
);
|
||||
|
||||
|
||||
$featured_collections = array();
|
||||
if($smart_rtf == 0)
|
||||
{
|
||||
// If we're getting the root, look only for categories, otherwise you will get other public collections as they're all public collections
|
||||
$featured_collections = ($parent == 0 ? get_featured_collection_categories($parent, array()) : get_featured_collections($parent, array()));
|
||||
}
|
||||
usort($featured_collections, "order_featured_collections_by_hasresources");
|
||||
render_featured_collections($rendering_options, $featured_collections);
|
||||
|
||||
|
||||
$smart_fcs_list = array();
|
||||
if($parent == 0 && $smart_rtf == 0)
|
||||
{
|
||||
// Root level - this is made up of all the fields that have a Smart theme name set.
|
||||
$smart_fc_headers = array_filter(get_smart_theme_headers(), function(array $v) { return metadata_field_view_access($v["ref"]); });
|
||||
$smart_fcs_list = array_map(function(array $v) use ($FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS)
|
||||
{
|
||||
return array(
|
||||
"ref" => $v["ref"],
|
||||
"name" => $v["smart_theme_name"],
|
||||
"type" => COLLECTION_TYPE_FEATURED,
|
||||
"parent" => null,
|
||||
"thumbnail_selection_method" => $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"],
|
||||
"has_resources" => 0,
|
||||
"resource_type_field" => $v["ref"]);
|
||||
},
|
||||
$smart_fc_headers);
|
||||
}
|
||||
else if($parent == 0 && $smart_rtf > 0 && metadata_field_view_access($smart_rtf))
|
||||
{
|
||||
// Smart fields. If a category tree, then a parent could be passed once user requests a lower level than root of the tree
|
||||
$resource_type_field = get_resource_type_field($smart_rtf);
|
||||
if($resource_type_field !== false)
|
||||
{
|
||||
$smart_fc_nodes = get_smart_themes_nodes($smart_rtf, (FIELD_TYPE_CATEGORY_TREE == $resource_type_field["type"]), $smart_fc_parent);
|
||||
$smart_fcs_list = array_map(function(array $v) use ($smart_rtf, $smart_fc_parent, $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS)
|
||||
{
|
||||
return array(
|
||||
"ref" => $v["ref"],
|
||||
"name" => $v["name"],
|
||||
"type" => COLLECTION_TYPE_FEATURED,
|
||||
"parent" => $v["ref"], # parent here is the node ID. When transformed to a FC this parent will be used for going to the next level down the branch
|
||||
"thumbnail_selection_method" => $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"],
|
||||
"has_resources" => 0,
|
||||
"resource_type_field" => $smart_rtf,
|
||||
"node_is_parent" => $v["is_parent"]);
|
||||
},
|
||||
$smart_fc_nodes);
|
||||
}
|
||||
}
|
||||
$rendering_options["smart"] = (count($smart_fcs_list) > 0);
|
||||
render_featured_collections($rendering_options, $smart_fcs_list);
|
||||
unset($rendering_options["smart"]);
|
||||
|
||||
|
||||
if($k == "" && $smart_rtf == 0 && $collection_allow_creation && checkperm("h"))
|
||||
{
|
||||
render_new_featured_collection_cta(
|
||||
generateURL(
|
||||
"{$baseurl_short}pages/collections_featured.php",
|
||||
array(
|
||||
"new" => "true",
|
||||
"cta" => "true",
|
||||
"parent" => $parent,
|
||||
)
|
||||
),
|
||||
$rendering_options);
|
||||
}
|
||||
?>
|
||||
</div> <!-- End of BasicsBox FeaturedSimpleLinks -->
|
||||
<script>
|
||||
jQuery(document).ready(function ()
|
||||
{
|
||||
jQuery('.FeaturedSimpleTile').hover(
|
||||
function(e)
|
||||
{
|
||||
tileid = jQuery(this).attr('id').substring(19);
|
||||
jQuery('#FeaturedSimpleTileActions_' + tileid).stop(true, true).slideDown();
|
||||
},
|
||||
function(e)
|
||||
{
|
||||
tileid=jQuery(this).attr('id').substring(19);
|
||||
jQuery('#FeaturedSimpleTileActions_' + tileid).stop(true, true).slideUp();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
if($themes_show_background_image && !$full_width)
|
||||
{
|
||||
$slideshow_files = get_slideshow_files_data();
|
||||
|
||||
if(!$featured_collection_static_bg && ($parent > 0 || ($smart_rtf > 0 && count($smart_fcs_list) > 0)))
|
||||
{
|
||||
// Overwrite background_image_url with theme specific ones
|
||||
$get_fc_imgs_ctx = array("limit" => 1);
|
||||
|
||||
if($parent > 0)
|
||||
{
|
||||
$collection_data = get_collection($parent);
|
||||
$collection_resources = get_collection_resources($parent);
|
||||
$collection_data["has_resources"] = (is_array($collection_resources) && !empty($collection_resources) ? 1 : 0);
|
||||
|
||||
// get_featured_collection_resources() is expecting a featured collection structure. $collection_data being a
|
||||
// collection structure is a superset containing the required information (ref, parent, has_resources) for the function to work
|
||||
$bg_fc_images = get_featured_collection_resources($collection_data, $get_fc_imgs_ctx);
|
||||
$bg_fc_images = generate_featured_collection_image_urls($bg_fc_images, "scr");
|
||||
}
|
||||
else if((count($smart_fcs_list) > 0))
|
||||
{
|
||||
$get_fc_imgs_ctx["smart"] = true;
|
||||
foreach($smart_fcs_list as $smart_fc)
|
||||
{
|
||||
$smart_fc_images = get_featured_collection_resources($smart_fc, $get_fc_imgs_ctx);
|
||||
$smart_fc_images = generate_featured_collection_image_urls($smart_fc_images, "scr");
|
||||
|
||||
if(!empty($smart_fc_images))
|
||||
{
|
||||
$bg_fc_images = $smart_fc_images;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($bg_fc_images) && is_array($bg_fc_images) && !empty($bg_fc_images))
|
||||
{
|
||||
$background_image_url = $bg_fc_images[0]; # get_fc_imgs_ctx is limiting to 1 so we know we have this
|
||||
|
||||
// Reset slideshow files as we want to use the featured collection image
|
||||
$slideshow_files = array();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
var SlideshowImages = new Array();
|
||||
var SlideshowCurrent = -1;
|
||||
var big_slideshow_timer = <?php echo $slideshow_photo_delay; ?>;
|
||||
<?php
|
||||
foreach($slideshow_files as $slideshow_file_info)
|
||||
{
|
||||
if((bool) $slideshow_file_info['featured_collections_show'] === false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$image_download_url = "{$baseurl_short}pages/download.php?slideshow={$slideshow_file_info['ref']}";
|
||||
$image_resource = isset($slideshow_file_info['link']) ? $slideshow_file_info['link'] : '';
|
||||
?>
|
||||
RegisterSlideshowImage('<?php echo $image_download_url; ?>', '<?php echo $image_resource; ?>');
|
||||
<?php
|
||||
}
|
||||
|
||||
if(!$featured_collection_static_bg && isset($background_image_url) && trim($background_image_url) != '')
|
||||
{
|
||||
?>
|
||||
RegisterSlideshowImage('<?php echo $background_image_url; ?>', '', true);
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
jQuery(document).ready(function()
|
||||
{
|
||||
ClearTimers();
|
||||
ActivateSlideshow();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
include "../include/footer.php";
|
|
@ -614,19 +614,9 @@ if('' != $tile_type && $tile_type !== "conf")
|
|||
$link_parts = explode('?', $link);
|
||||
parse_str(str_replace('&', '&', $link_parts[1]), $link_parts);
|
||||
|
||||
$featured_collection_categories = array();
|
||||
$parent = (isset($link_parts["parent"]) ? validate_collection_parent(array("parent" => (int) $link_parts["parent"])) : 0);
|
||||
|
||||
foreach($link_parts as $link_part_key => $link_part_value)
|
||||
{
|
||||
if(false === strpos($link_part_key, 'theme'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$featured_collection_categories[] = $link_part_value;
|
||||
}
|
||||
|
||||
foreach(get_themes($featured_collection_categories, true) as $theme)
|
||||
foreach(get_featured_collection_categories($parent, array()) as $theme)
|
||||
{
|
||||
$resources = array_merge(
|
||||
$resources,
|
||||
|
|
|
@ -44,7 +44,7 @@ include "../include/header.php";
|
|||
<?php if (getval("k","")=="") { ?>
|
||||
<p><a href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset) ?>&order_by=<?php echo urlencode($order_by) ?>&sort=<?php echo urlencode($sort) ?>&archive=<?php echo urlencode($archive) ?>&restypes=<?php echo urlencode($restypes); ?>" onclick="return CentralSpaceLoad(this,true);"><?php echo LINK_CARET ?><?php echo $lang["continuetoresults"]?></a></p>
|
||||
|
||||
<p><a href="<?php echo ($use_theme_as_home?$baseurl_short.'pages/themes.php':$default_home_page)?>" onclick="return CentralSpaceLoad(this,true);"><?php echo LINK_CARET ?><?php echo $lang["continuetohome"]?></a></p>
|
||||
<p><a href="<?php echo ($use_theme_as_home?$baseurl_short.'pages/collections_featured.php':$default_home_page)?>" onclick="return CentralSpaceLoad(this,true);"><?php echo LINK_CARET ?><?php echo $lang["continuetohome"]?></a></p>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ if(!($direct_download_noauth && $direct))
|
|||
|
||||
|
||||
// Set a flag for logged in users if $external_share_view_as_internal is set and logged on user is accessing an external share
|
||||
$internal_share_access = ('' != $k && $external_share_view_as_internal && isset($is_authenticated) && $is_authenticated);
|
||||
$internal_share_access = internal_share_access();
|
||||
|
||||
$ref = getvalescaped('ref', '', true);
|
||||
$size = getvalescaped('size', '');
|
||||
|
|
|
@ -46,8 +46,6 @@ $uploadparams["collection_add"] = $collection_add;
|
|||
$uploadparams["local"] = $local;
|
||||
$uploadparams["metadatatemplate"] = getval("metadatatemplate","");
|
||||
$uploadparams["no_exif"] = $no_exif;
|
||||
$uploadparams["themestring"] = getval("themestring","");
|
||||
$uploadparams["public"] = getval("public","");
|
||||
$uploadparams["autorotate"] = $autorotate;
|
||||
$uploadparams["entercolname"] = getvalescaped("entercolname","");
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ if (!hook("replaceslideshow"))
|
|||
$title="themeselector";
|
||||
$all_users=1;
|
||||
$url="pages/ajax/dash_tile.php?tltype=conf&tlstyle=thmsl";
|
||||
$link="pages/themes.php";
|
||||
$link="pages/collections_featured.php";
|
||||
$reload_interval=0;
|
||||
$resource_count=0;
|
||||
$default_order_by=0;
|
||||
|
@ -269,24 +269,25 @@ if (!hook("replaceslideshow"))
|
|||
}
|
||||
}
|
||||
else
|
||||
{ ?>
|
||||
{
|
||||
$url = "{$baseurl_short}pages/collections_featured.php";
|
||||
?>
|
||||
<div class="HomePanel">
|
||||
<div class="HomePanelIN HomePanelThemes <?php if (count($home_collections)>0) { ?> HomePanelMatchPromotedHeight<?php } ?>">
|
||||
<a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/themes.php">
|
||||
<a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/collections_featured.php">
|
||||
<h2 style="padding: 0px 15px 0 44px;margin-top: 26px;margin-left: 15px;"><?php echo $lang["themes"]?></h2></a>
|
||||
<p style="text-shadow: none;">
|
||||
<select id="themeselect" onChange="CentralSpaceLoad(this.value,true);">
|
||||
<option value=""><?php echo $lang["select"] ?></option>
|
||||
<?php
|
||||
$headers=get_theme_headers();
|
||||
for ($n=0;$n<count($headers);$n++)
|
||||
foreach(get_featured_collection_categories(0, array()) as $header)
|
||||
{
|
||||
?>
|
||||
<option value="<?php echo $baseurl_short?>pages/themes.php?header=<?php echo urlencode($headers[$n])?>"><?php echo i18n_get_translated(str_replace("*","",$headers[$n]))?></option>
|
||||
<option value="<?php echo generateURL($url, array("parent" => $header["ref"])); ?>"><?php echo htmlspecialchars(i18n_get_translated($header["name"])); ?></option>
|
||||
<?php
|
||||
} ?>
|
||||
</select>
|
||||
<a id="themeviewall" onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/themes.php"><?php echo LINK_CARET ?><?php echo $lang["viewall"] ?></a>
|
||||
<a id="themeviewall" onClick="return CentralSpaceLoad(this,true);" href="<?php echo $url; ?>"><?php echo LINK_CARET ?><?php echo $lang["viewall"] ?></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ $revsort = ($sort=="ASC") ? "DESC" : "ASC";
|
|||
# pager
|
||||
$per_page=getvalescaped("per_page_list",$default_perpage_list,true);rs_setcookie('per_page_list', $per_page);
|
||||
|
||||
$collection_valid_order_bys=array("fullname","name","ref","count","public");
|
||||
$collection_valid_order_bys=array("fullname","name","ref","count");
|
||||
$modified_collection_valid_order_bys=hook("modifycollectionvalidorderbys");
|
||||
if ($modified_collection_valid_order_bys){$collection_valid_order_bys=$modified_collection_valid_order_bys;}
|
||||
if (!in_array($col_order_by,$collection_valid_order_bys)) {$col_order_by="created";} # Check the value is one of the valid values (SQL injection filter)
|
||||
|
@ -144,7 +144,7 @@ for ($n=$offset;(($n<count($collections)) && ($n<($offset+$per_page)));$n++)
|
|||
|
||||
?><tr <?php hook("collectionlistrowstyle");?>>
|
||||
<td><div class="ListTitle">
|
||||
<a <?php if ($collections[$n]["public"]==1 && (strlen($collections[$n]["theme"])>0)) { ?>style="font-style:italic;"<?php } ?> href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode("!collection" . $collections[$n]["ref"])?>" onClick="return CentralSpaceLoad(this);"><?php echo highlightkeywords(i18n_get_collection_name($collections[$n]),$find)?></a></div></td>
|
||||
<a <?php if ($collections[$n]["type"] == COLLECTION_TYPE_FEATURED) { ?>style="font-style:italic;"<?php } ?> href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode("!collection" . $collections[$n]["ref"])?>" onClick="return CentralSpaceLoad(this);"><?php echo highlightkeywords(i18n_get_collection_name($collections[$n]),$find)?></a></div></td>
|
||||
<td><?php echo highlightkeywords($collection_prefix . $collections[$n]["ref"],$find)?></td>
|
||||
<td><?php echo nicedate($collections[$n]["created"],true)?></td>
|
||||
<td><?php echo $collections[$n]["count"]?></td>
|
||||
|
|
|
@ -35,28 +35,27 @@ for ($n=0;$n<count($collections);$n++)
|
|||
{
|
||||
?><tr <?php hook("collectionlistrowstyle");?>>
|
||||
<td><div class="ListTitle">
|
||||
<a onClick="return CentralSpaceLoad(this,true);" <?php if ($collections[$n]["public"]==1 && (strlen($collections[$n]["theme"])>0)) { ?>style="font-style:italic;"<?php } ?> href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode("!collection" . $collections[$n]["ref"])?>"><?php echo i18n_get_collection_name($collections[$n])?></a></div></td>
|
||||
<a onClick="return CentralSpaceLoad(this,true);" <?php if($collections[$n]["type"] == COLLECTION_TYPE_FEATURED) { ?>style="font-style:italic;"<?php } ?> href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode("!collection" . $collections[$n]["ref"])?>"><?php echo i18n_get_collection_name($collections[$n])?></a></div></td>
|
||||
<td><?php echo htmlspecialchars($collections[$n]["fullname"])?></td>
|
||||
<td><?php echo $collection_prefix . $collections[$n]["ref"]?></td>
|
||||
<td><?php echo nicedate($collections[$n]["created"],true)?></td>
|
||||
<td><?php echo $collections[$n]["count"]?></td>
|
||||
<?php if (! $hide_access_column){ ?> <td><?php
|
||||
# Work out the correct access mode to display
|
||||
if ($collections[$n]["public"]==0)
|
||||
{
|
||||
echo $lang["private"];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen($collections[$n]["theme"])>0)
|
||||
{
|
||||
echo $lang["theme"];
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $lang["public"];
|
||||
}
|
||||
}
|
||||
switch($collections[$n]["type"])
|
||||
{
|
||||
case COLLECTION_TYPE_PUBLIC:
|
||||
echo $lang["public"];
|
||||
break;
|
||||
|
||||
case COLLECTION_TYPE_FEATURED:
|
||||
echo $lang["theme"];
|
||||
break;
|
||||
|
||||
case COLLECTION_TYPE_STANDARD:
|
||||
default:
|
||||
echo $lang["private"];
|
||||
break;
|
||||
}
|
||||
?></td><?php
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -15,7 +15,7 @@ $resetlockedfields = getvalescaped("resetlockedfields","") != "";
|
|||
if (($k=="") || (!check_access_key_collection(str_replace("!collection","",$s[0]),$k))) {include "../include/authenticate.php";}
|
||||
|
||||
// Set a flag for logged in users if $external_share_view_as_internal is set and logged on user is accessing an external share
|
||||
$internal_share_access = ($k!="" && $external_share_view_as_internal && isset($is_authenticated) && $is_authenticated);
|
||||
$internal_share_access = internal_share_access();
|
||||
|
||||
if ($k=="" || $internal_share_access)
|
||||
{
|
||||
|
@ -878,19 +878,44 @@ if (isset($result_title_height))
|
|||
|
||||
hook('searchresultsheader');
|
||||
|
||||
#if (is_array($result)||(isset($collections)&&(count($collections)>0)))
|
||||
|
||||
if((isset($collectiondata) && array_key_exists("name",$collectiondata)) && $enable_themes && $enable_theme_breadcrumbs && !$search_titles && isset($theme_link) && $k=="")
|
||||
if(
|
||||
$enable_themes && $enable_theme_breadcrumbs
|
||||
&& isset($collectiondata) && $collectiondata !== false
|
||||
&& !$search_titles
|
||||
&& !is_null(validate_collection_parent($collectiondata)) && $collectiondata["parent"] > 0
|
||||
)
|
||||
{
|
||||
// Show the themes breadcrumbs if they exist, but not if we are using the search_titles
|
||||
renderBreadcrumbs(
|
||||
$general_url_params = ($k == "" ? array() : array("k" => $k));
|
||||
$links_trail = array(
|
||||
array(
|
||||
"title" => $lang["themes"],
|
||||
"href" => generateURL("{$baseurl_short}pages/collections_featured.php", $general_url_params)
|
||||
)
|
||||
);
|
||||
|
||||
// We ask for the branch up from the parent as we want to generate a different link for the actual collection.
|
||||
// If we were use the $collectiondata["ref"] then the generated link for the collection would've pointed at
|
||||
// collections_featured.php which we don't want
|
||||
$branch_trail = array_map(function($branch) use ($baseurl_short, $general_url_params)
|
||||
{
|
||||
return array(
|
||||
"title" => i18n_get_translated($branch["name"]),
|
||||
"href" => generateURL("{$baseurl_short}pages/collections_featured.php", $general_url_params, array("parent" => $branch["ref"]))
|
||||
);
|
||||
}, get_featured_collection_category_branch_by_leaf($collectiondata["parent"], array()));
|
||||
|
||||
renderBreadcrumbs(
|
||||
array_merge(
|
||||
$links_trail,
|
||||
$branch_trail,
|
||||
array(
|
||||
'title' => i18n_get_collection_name($collectiondata),
|
||||
'href' => generateURL("{$baseurl_short}pages/search.php", array('search' => "!collection{$collection}"))
|
||||
array(
|
||||
'title' => i18n_get_collection_name($collectiondata),
|
||||
'href' => generateURL("{$baseurl_short}pages/search.php", $general_url_params, array('search' => "!collection{$collectiondata["ref"]}"))
|
||||
)
|
||||
)
|
||||
),
|
||||
$theme_link);
|
||||
"");
|
||||
}
|
||||
|
||||
if ($search_titles)
|
||||
|
|
|
@ -61,7 +61,7 @@ renderBreadcrumbs($links_trail);
|
|||
if($enable_themes)
|
||||
{ ?>
|
||||
<li>
|
||||
<a href="<?php echo $baseurl."/pages/dash_tile.php?create=true&tltype=conf&tlstyle=thmsl&title=themeselector&tile_audience=true&link=pages/themes.php&url=pages/ajax/dash_tile.php%3Ftltype=conf%26tlstyle=thmsl";?>">
|
||||
<a href="<?php echo $baseurl."/pages/dash_tile.php?create=true&tltype=conf&tlstyle=thmsl&title=themeselector&tile_audience=true&link=pages/collections_featured.php&url=pages/ajax/dash_tile.php%3Ftltype=conf%26tlstyle=thmsl";?>">
|
||||
<?php echo $lang["createdashtilethemeselector"];?>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -1,295 +0,0 @@
|
|||
<?php
|
||||
include "../include/db.php";
|
||||
|
||||
include "../include/authenticate.php";
|
||||
|
||||
|
||||
$themes=array();
|
||||
$themecount=0;
|
||||
reset($_POST);reset($_GET);foreach (array_merge($_GET, $_POST) as $key=>$value) {
|
||||
// only set necessary vars
|
||||
if (substr($key,0,5)=="theme" && $value!=""){
|
||||
$themes[$themecount]=rawurldecode($value);
|
||||
$themecount++;
|
||||
}
|
||||
}
|
||||
|
||||
$header=getvalescaped("header","");
|
||||
$smart_theme=getvalescaped("smart_theme","");
|
||||
$showexisting=getvalescaped("showexisting","");
|
||||
$subthemes=getvalescaped("subthemes",false);
|
||||
|
||||
$linksuffix="?";
|
||||
for ($x=0;$x<count($themes);$x++){
|
||||
if ($x!=0){ $linksuffix.="&"; }
|
||||
$linksuffix.="theme" . ($x+1);
|
||||
$linksuffix.="=". urlencode($themes[$x]);
|
||||
$themename=$themes[$x];
|
||||
}
|
||||
|
||||
$linksuffixprev=explode("&",$linksuffix);
|
||||
array_pop($linksuffixprev); // remove last level
|
||||
$linksuffixprev=implode('&',$linksuffixprev);
|
||||
|
||||
$internal_share_only=checkperm("noex");
|
||||
|
||||
# Process deletion of access keys
|
||||
if (getval("deleteaccess","")!="" && enforcePostRequest(false))
|
||||
{
|
||||
$ref=getvalescaped("ref","",true);
|
||||
delete_collection_access_key($ref,getvalescaped("deleteaccess",""));
|
||||
}
|
||||
|
||||
include "../include/header.php";
|
||||
|
||||
?>
|
||||
|
||||
<div class="BasicsBox">
|
||||
<form method=post id="themeform" action="<?php echo $baseurl_short?>pages/theme_category_share.php<?php echo $linksuffix ?>" onsubmit="return CentralSpacePost(this,true)">
|
||||
<?php generateFormToken("themeform"); ?>
|
||||
<input type="hidden" name="generateurl" id="generateurl" value="">
|
||||
<p><a href='<?php echo $baseurl_short?>pages/themes.php<?php echo $linksuffixprev?>' onclick="return CentralSpaceLoad(this,true);"><?php echo LINK_CARET_BACK ?><?php echo $lang['backtothemes']?></a></p>
|
||||
<?php if(!isset($themename)){exit($lang["error-theme-missing"]);}?>
|
||||
<h1><?php echo $lang["share_theme_category"] . " - " . $themename;render_help_link("user/sharing-resources");?></h1>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
// Get collections under the theme
|
||||
$collectionstoshare=get_themes($themes,$subthemes);
|
||||
|
||||
if (count($collectionstoshare)<1) # There are no collections in this theme
|
||||
{
|
||||
$show_error=true;
|
||||
$error=$lang["cannotshareemptythemecategory"];
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($collectionstoshare as $collection)
|
||||
{
|
||||
$ref=$collection["ref"];
|
||||
|
||||
# Get min access to this collection
|
||||
$minaccess=collection_min_access($ref);
|
||||
|
||||
if ($minaccess>=1 && !$restricted_share) # Minimum access is restricted or lower and sharing of restricted resources is not allowed. The user cannot share this collection.
|
||||
{
|
||||
$show_error=true;
|
||||
$error = str_replace("%collectionname%", i18n_get_collection_name($collection), $lang["collection-name"]) . "\n" . $lang["restrictedsharecollection"];
|
||||
}
|
||||
|
||||
if (count(get_collection_resources($ref))==0) # Sharing an empty collection?
|
||||
{
|
||||
$show_error=true;
|
||||
$error = str_replace("%collectionname%", i18n_get_collection_name($collection), $lang["collection-name"]) . "\n" . $lang["cannotshareemptycollection"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$access=getvalescaped("access","");
|
||||
$expires=getvalescaped("expires","");
|
||||
|
||||
if (!$internal_share_only && getvalescaped("generateurl","")=="")
|
||||
{ ?>
|
||||
|
||||
<div class="VerticalNav">
|
||||
|
||||
<li><a id="emaillink" onClick="var _href=jQuery('#emaillink').attr('href');var subthemes=document.getElementById('subthemes').checked;jQuery('#emaillink').attr('href',_href + '&subthemes=' + subthemes);return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short . "pages/collection_email.php" . $linksuffix . "&catshare=true\">" . $lang["email_theme_category"];?></a></li>
|
||||
<li><a id="urllink" onClick="var _href=jQuery('#urllink').attr('href');var subthemes=document.getElementById('subthemes').checked;jQuery('#urllink').attr('href',_href + '&subthemes=' + subthemes);return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short . "pages/theme_category_share.php" . $linksuffix . "&generateurl=true&subthemes=" . $subthemes . "\">" . $lang["generateurls"];?></a></li>
|
||||
</div>
|
||||
<?php }
|
||||
elseif($internal_share_only)
|
||||
{
|
||||
if (!($hide_internal_sharing_url))
|
||||
{
|
||||
?>
|
||||
<p><?php echo $lang["generateurlinternal"]?></p>
|
||||
|
||||
<p><input class="URLDisplay" type="text" value="<?php echo $baseurl?>/pages/themes.php<?php echo $linksuffix?>">
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($access=="")
|
||||
{
|
||||
if (!($hide_internal_sharing_url))
|
||||
{
|
||||
?>
|
||||
<p><?php echo $lang["generateurlinternal"]?></p>
|
||||
|
||||
<p><input class="URLDisplay" type="text" value="<?php echo $baseurl?>/pages/themes.php<?php echo $linksuffix?>">
|
||||
<?php
|
||||
}
|
||||
if(!$internal_share_only)
|
||||
{
|
||||
?>
|
||||
<p><?php echo $lang["selectgenerateurlexternalthemecat"] ?></p>
|
||||
<div class="Question" id="question_access">
|
||||
<label for="archive"><?php echo $lang["access"]?></label>
|
||||
<select class="stdwidth" name="access" id="access">
|
||||
<?php
|
||||
# List available access levels. The highest level must be the minimum user access level.
|
||||
for ($n=$minaccess;$n<=1;$n++) { ?>
|
||||
<option value="<?php echo $n?>"><?php echo $lang["access" . $n]?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
for ($x=0;$x<$themecount;$x++)
|
||||
{ ?>
|
||||
<input type="hidden" name="theme<?php echo $x+1 ?>" id="theme<?php echo $x+1 ?>" value="<?php echo i18n_get_translated($themes[$x]) ?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="Question">
|
||||
<label><?php echo $lang["expires"]?></label>
|
||||
<select name="expires" class="stdwidth">
|
||||
<option value=""><?php echo $lang["never"]?></option>
|
||||
<?php
|
||||
for ($n=1;$n<=150;$n++)
|
||||
{
|
||||
$date = time()+(60*60*24*$n);
|
||||
$d = date("D",$date);
|
||||
$option_class = '';
|
||||
if (($d == "Sun") || ($d == "Sat"))
|
||||
{
|
||||
$option_class = 'optionWeekend';
|
||||
} ?>
|
||||
<option class="<?php echo $option_class ?>" value="<?php echo date("Y-m-d",$date)?>"><?php echo nicedate(date("Y-m-d",$date),false,true)?></option>
|
||||
<?php
|
||||
} ?>
|
||||
</select>
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
<div class="Question">
|
||||
<label for="subthemes"><?php echo $lang["share_theme_category_subcategories"]?></label>
|
||||
<input type="checkbox" id="subthemes" name="subthemes" value="true" <?php if ($subthemes){echo "checked";} ?>>
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
|
||||
<div class="QuestionSubmit" style="padding-top:0;margin-top:0;">
|
||||
<label for="buttons"> </label>
|
||||
<input onclick="jQuery('#generateurl').val(true);" type="submit" value=" <?php echo $lang["generateexternalurls"]?> " />
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $access!="" && getvalescaped("generateurl","")!="" )
|
||||
{
|
||||
# Access has been selected. Generate a URL.
|
||||
?>
|
||||
<p><?php echo $lang["generatethemeurlsexternal"]?></p>
|
||||
<p>
|
||||
<textarea class="URLDisplay" cols="100" rows="<?php echo count($collectionstoshare)*4+1; ?>" ><?php
|
||||
$unapproved_collection=false;
|
||||
|
||||
foreach($collectionstoshare as $collection)
|
||||
{
|
||||
$ref=$collection["ref"];
|
||||
|
||||
#Check if any resources are not approved
|
||||
if (!is_collection_approved($ref) && !$collection_allow_not_approved_share)
|
||||
{
|
||||
echo "\r\n" . str_replace("%collectionname%", i18n_get_collection_name($collection), $lang["collection-name"]) . "\r\n" . $lang["notapprovedsharecollection"] . "\r\n";
|
||||
$unapproved_collection=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "\r\n" . str_replace("%collectionname%", i18n_get_collection_name($collection), $lang["collection-name"]) . "\r\n" . $baseurl?>/?c=<?php echo urlencode($ref)?>&k=<?php echo
|
||||
generate_collection_access_key($ref,0,"URL",$access,$expires) . "\r\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</textarea>
|
||||
<?php if ($unapproved_collection){?><script>alert('<?php echo $lang['notapprovedsharetheme']?>');</script><?php } ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
//Display existing shares for collections in theme
|
||||
|
||||
if ($access=="" && !$internal_share_only)
|
||||
{
|
||||
foreach($collectionstoshare as $collection)
|
||||
{
|
||||
$ref=$collection["ref"];
|
||||
$keys=get_collection_external_access($ref);
|
||||
?>
|
||||
<p> </p>
|
||||
<h2><?php echo str_replace("%collectionname%", i18n_get_collection_name($collection), $lang["externalusersharing-name"]);?></h2>
|
||||
<div class="Question">
|
||||
<?php
|
||||
if (count($keys)==0)
|
||||
{
|
||||
?>
|
||||
<p><?php echo $lang["noexternalsharing"] ?></p>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<div class="Listview">
|
||||
<table border="0" cellspacing="0" cellpadding="0" class="ListviewStyle">
|
||||
<tr class="ListviewTitleStyle">
|
||||
<td><?php echo $lang["accesskey"];?></td>
|
||||
<td><?php echo $lang["sharedby"];?></td>
|
||||
<!--<td><?php echo $lang["sharedwith"];?></td>-->
|
||||
<td><?php echo $lang["lastupdated"];?></td>
|
||||
<td><?php echo $lang["lastused"];?></td>
|
||||
<td><?php echo $lang["expires"];?></td>
|
||||
<td><?php echo $lang["access"];?></td>
|
||||
<td><div class="ListTools"><?php echo $lang["tools"]?></div></td>
|
||||
</tr>
|
||||
<?php
|
||||
for ($n=0;$n<count($keys);$n++)
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td><div class="ListTitle"><a target="_blank" href="<?php echo $baseurl . "?c=" . urlencode($ref) . "&k=" . $keys[$n]["access_key"]?>"><?php echo $keys[$n]["access_key"]?></a></div></td>
|
||||
<td><?php echo resolve_users($keys[$n]["users"])?></td>
|
||||
<!--<td><?php echo $keys[$n]["emails"]?></td>-->
|
||||
<td><?php echo nicedate($keys[$n]["maxdate"],true); ?></td>
|
||||
<td><?php echo nicedate($keys[$n]["lastused"],true); ?></td>
|
||||
<td><?php echo ($keys[$n]["expires"]=="")?$lang["never"]:nicedate($keys[$n]["expires"],false)?></td>
|
||||
<td><?php echo ($keys[$n]["access"]==-1)?"":$lang["access" . $keys[$n]["access"]]; ?></td>
|
||||
<td><div class="ListTools">
|
||||
<a href="#" onClick="if (confirm('<?php echo $lang["confirmdeleteaccess"]?>')) {document.getElementById('deleteaccess').value='<?php echo $keys[$n]["access_key"] ?>';document.getElementById('ref').value='<?php echo htmlspecialchars($ref) ?>';document.getElementById('themeform').submit(); }"><?php echo LINK_CARET ?><?php echo $lang["action-delete"]?></a>
|
||||
</div></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?></div>
|
||||
<?php }
|
||||
}?>
|
||||
|
||||
<input type="hidden" id="deleteaccess" name="deleteaccess" value=""/>
|
||||
<input type="hidden" id="ref" name="ref" value=""/>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
if (isset($show_error)){?>
|
||||
<script type="text/javascript">
|
||||
alert(<?php echo json_encode($error);?>);
|
||||
CentralSpaceLoad('<?php echo $baseurl_short?>pages/themes.php<?php echo $linksuffixprev?>');
|
||||
</script><?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
include "../include/footer.php";
|
||||
?>
|
|
@ -1,120 +0,0 @@
|
|||
<?php
|
||||
include "../include/db.php";
|
||||
|
||||
include "../include/authenticate.php";
|
||||
if (!$enable_theme_category_edit){ die ('$enable_theme_category_edit=false');}
|
||||
|
||||
|
||||
|
||||
$themes=array();
|
||||
$themecount=0;
|
||||
reset($_POST);reset($_GET);foreach (array_merge($_GET, $_POST) as $key=>$value) {
|
||||
// only set necessary vars
|
||||
if (substr($key,0,5)=="theme" && $value!=""){
|
||||
$themes[$themecount]=rawurldecode($value);
|
||||
$themecount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Work out theme name and level, also construct back link
|
||||
$link="themes.php?";
|
||||
$lastlevelchange=getvalescaped("lastlevelchange",1,true);
|
||||
if(!is_numeric($lastlevelchange)) {$lastlevelchange = 1;}
|
||||
$link.="lastlevelchange=" . $lastlevelchange . "&";
|
||||
for ($x=0;$x<$themecount;$x++)
|
||||
{
|
||||
if (!$x==0){$link.="&";}
|
||||
if ($x==0)
|
||||
{
|
||||
$collection_column="theme";
|
||||
if ($x<$themecount-1)
|
||||
{$link.= "theme=" . urlencode($themes[$x]);}
|
||||
elseif ($x==$themecount-1 && getval("rename","")!="" && !($themes_category_split_pages)) #add new name of theme to back link
|
||||
{
|
||||
$link.= "theme=" . getvalescaped("rename","");
|
||||
}
|
||||
$themename=$themes[$x];
|
||||
}
|
||||
else
|
||||
{
|
||||
$collection_column="theme" . ($x+1);
|
||||
if ($x<$themecount-1 || getval("rename","")=="") #add current theme to back link only if not renaming it
|
||||
{$link.= "theme" . ($x+1) . "=" . urlencode($themes[$x]);}
|
||||
elseif ($x==$themecount-1 && getval("rename","")!="" && !($themes_category_split_pages)) #add new name of theme to back link
|
||||
{
|
||||
$link.= "theme" . ($x+1) . "=" . getvalescaped("rename","");
|
||||
}
|
||||
$themename=$themes[$x];
|
||||
}
|
||||
}
|
||||
|
||||
if (getval("rename","")!="" && enforcePostRequest(false))
|
||||
{
|
||||
# Save theme category
|
||||
save_themename();
|
||||
}
|
||||
|
||||
hook("beforethemeeditheader");
|
||||
|
||||
include "../include/header.php";
|
||||
|
||||
if (!checkperm("t")) {
|
||||
echo "You do not have permission to edit theme categories. " ;
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$modal=(getval("modal","")=="true");
|
||||
if(!$modal)
|
||||
{?>
|
||||
<p><a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl . "/pages/" . $link?>"><?php echo LINK_CARET_BACK ?><?php echo $lang["backtothemes"]?></a></p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div class="BasicsBox">
|
||||
<h1><?php echo $lang["edit_theme_category"];render_help_link("collections-public-and-themes"); ?></h1>
|
||||
<p><?php echo text("introtext")?></p>
|
||||
<form method=post id="themeform" action="<?php echo $baseurl_short?>pages/theme_edit.php">
|
||||
<input type="hidden" name="collection_column" id="collection_column" value="<?php echo $collection_column?>">
|
||||
<input type="hidden" name="link" id="link" value="<?php echo $link?>">
|
||||
<input type="hidden" name="lastlevelchange" id="lastlevelchange" value="<?php echo htmlspecialchars($lastlevelchange)?>">
|
||||
<?php
|
||||
generateFormToken("themeform");
|
||||
|
||||
for ($x=0;$x<$themecount;$x++)
|
||||
{
|
||||
if ($x==0)
|
||||
{?>
|
||||
<input type="hidden" name="theme" id="theme" value="<?php echo $themes[$x]?>">
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{ ?>
|
||||
<input type="hidden" name="theme<?php echo $x+1 ?>" id="theme<?php echo $x+1 ?>" value="<?php echo $themes[$x] ?>">
|
||||
<?php }
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="Question">
|
||||
<label for="rename"><?php echo $lang["name"]?></label><input type=text class="stdwidth" name="rename" id="rename" value="<?php echo $themename?>" maxlength="100" />
|
||||
<div class="clearerleft"> </div>
|
||||
</div>
|
||||
|
||||
<?php hook("morethemeeditoptions");?>
|
||||
|
||||
<div class="QuestionSubmit">
|
||||
<label for="buttons"> </label>
|
||||
<input name="save" type="submit" value=" <?php echo $lang["save"]?> " />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
include "../include/footer.php";
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
1177
pages/themes.php
1177
pages/themes.php
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,8 @@ if('cli' != php_sapi_name())
|
|||
|
||||
$newline = PHP_EOL;
|
||||
|
||||
sql_query("DELETE FROM collection WHERE public<>1 AND user NOT IN (SELECT ref FROM user)");
|
||||
$public_types = join(", ", $COLLECTION_PUBLIC_TYPES);
|
||||
sql_query("DELETE FROM collection WHERE `type` NOT IN ({$public_types}) AND user NOT IN (SELECT ref FROM user)");
|
||||
echo number_format(sql_affected_rows()) . " orphaned collections deleted." . $newline;
|
||||
|
||||
sql_query("DELETE FROM collection_keyword WHERE collection NOT IN (SELECT ref FROM collection) OR keyword NOT IN (SELECT ref FROM keyword)");
|
||||
|
|
|
@ -192,15 +192,15 @@ function touch_category_tree_level($path_parts)
|
|||
function ProcessFolder($folder)
|
||||
{
|
||||
global $lang, $syncdir, $nogo, $staticsync_max_files, $count, $done, $lastsync, $ffmpeg_preview_extension,
|
||||
$staticsync_autotheme, $staticsync_folder_structure, $staticsync_extension_mapping_default,
|
||||
$staticsync_autotheme, $staticsync_extension_mapping_default, $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS,
|
||||
$staticsync_extension_mapping, $staticsync_mapped_category_tree, $staticsync_title_includes_path,
|
||||
$staticsync_ingest, $staticsync_mapfolders, $staticsync_alternatives_suffix, $theme_category_levels,
|
||||
$staticsync_ingest, $staticsync_mapfolders, $staticsync_alternatives_suffix,
|
||||
$staticsync_defaultstate, $additional_archive_states, $staticsync_extension_mapping_append_values,
|
||||
$staticsync_deleted_state, $staticsync_alternative_file_text, $staticsync_filepath_to_field,
|
||||
$resource_deletion_state, $alternativefiles, $staticsync_revive_state, $enable_thumbnail_creation_on_upload,
|
||||
$FIXED_LIST_FIELD_TYPES, $staticsync_extension_mapping_append_values_fields, $view_title_field, $filename_field,
|
||||
$staticsync_whitelist_folders,$staticsync_ingest_force,$errors, $category_tree_add_parents,
|
||||
$staticsync_alt_suffixes, $staticsync_alt_suffix_array, $staticsync_file_minimum_age;
|
||||
$staticsync_alt_suffixes, $staticsync_alt_suffix_array, $staticsync_file_minimum_age, $userref;
|
||||
|
||||
$collection = 0;
|
||||
$treeprocessed=false;
|
||||
|
@ -340,50 +340,118 @@ function ProcessFolder($folder)
|
|||
}
|
||||
}
|
||||
$count++;
|
||||
|
||||
echo "Processing file: $fullpath" . PHP_EOL;
|
||||
|
||||
if ($collection == 0 && $staticsync_autotheme)
|
||||
{
|
||||
# Make a new collection for this folder.
|
||||
$e = explode("/", $shortpath);
|
||||
$theme = ucwords($e[0]);
|
||||
$themesql = "theme='" . ucwords(escape_check($e[0])) . "'";
|
||||
$themecolumns = "theme";
|
||||
$themevalues = "'" . ucwords(escape_check($e[0])) . "'";
|
||||
|
||||
if ($staticsync_folder_structure)
|
||||
$fallback_fc_categ_name = ucwords($e[0]);
|
||||
$name = (count($e) == 1) ? '' : $e[count($e)-2];
|
||||
echo "Collection '{$name}'" . PHP_EOL;
|
||||
|
||||
// The real featured collection will always be the last directory in the path
|
||||
$proposed_fc_categories = array_diff($e, array_slice($e, -2));
|
||||
echo "Proposed Featured Collection Categories: " . join(" / ", $proposed_fc_categories) . PHP_EOL;
|
||||
|
||||
// Build the tree first, if needed
|
||||
$proposed_branch_path = array();
|
||||
for($b = 0; $b < count($proposed_fc_categories); $b++)
|
||||
{
|
||||
for ($x=0;$x<count($e)-2;$x++)
|
||||
$parent = ($b == 0 ? 0 : $proposed_branch_path[($b - 1)]);
|
||||
$fc_categ_name = ucwords($proposed_fc_categories[$b]);
|
||||
|
||||
$fc_categ_ref_sql = sprintf(
|
||||
"SELECT DISTINCT ref AS `value`
|
||||
FROM collection AS c
|
||||
LEFT JOIN collection_resource AS cr ON c.ref = cr.collection
|
||||
WHERE `type` = %s
|
||||
AND parent %s
|
||||
AND `name` = '%s'
|
||||
GROUP BY c.ref
|
||||
HAVING count(DISTINCT cr.resource) = 0",
|
||||
COLLECTION_TYPE_FEATURED,
|
||||
sql_is_null_or_eq_val($parent, $parent == 0),
|
||||
escape_check($fc_categ_name)
|
||||
);
|
||||
$fc_categ_ref = sql_value($fc_categ_ref_sql, 0);
|
||||
|
||||
if($fc_categ_ref == 0)
|
||||
{
|
||||
if ($x != 0)
|
||||
echo "Creating new Featured Collection category named '{$fc_categ_name}'" . PHP_EOL;
|
||||
$fc_categ_ref = create_collection($userref, $fc_categ_name);
|
||||
echo "Created '{$fc_categ_name}' with ref #{$fc_categ_ref}" . PHP_EOL;
|
||||
|
||||
$updated_fc_category = save_collection(
|
||||
$fc_categ_ref,
|
||||
array(
|
||||
"featured_collections_changes" => array(
|
||||
"update_parent" => $parent,
|
||||
"force_featured_collection_type" => true,
|
||||
"thumbnail_selection_method" => $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"],
|
||||
)
|
||||
));
|
||||
if($updated_fc_category === false)
|
||||
{
|
||||
$themeindex = $x+1;
|
||||
if ($themeindex >$theme_category_levels)
|
||||
{
|
||||
$theme_category_levels = $themeindex;
|
||||
if ($x == count($e)-2)
|
||||
{
|
||||
echo PHP_EOL . PHP_EOL .
|
||||
"UPDATE THEME_CATEGORY_LEVELS TO $themeindex IN CONFIG!!!!" .
|
||||
PHP_EOL . PHP_EOL;
|
||||
}
|
||||
}
|
||||
$th_name = ucwords(escape_check($e[$x]));
|
||||
$themesql .= " AND theme{$themeindex} = '$th_name'";
|
||||
$themevalues .= ",'$th_name'";
|
||||
$themecolumns .= ",theme{$themeindex}";
|
||||
echo "Unable to update '{$fc_categ_name}' with ref #{$fc_categ_ref} to a Featured Collection Category" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$proposed_branch_path[] = $fc_categ_ref;
|
||||
}
|
||||
|
||||
$name = (count($e) == 1) ? '' : $e[count($e)-2];
|
||||
echo "Collection $name, theme=$theme" . PHP_EOL;
|
||||
$escaped_name = escape_check($name);
|
||||
$collection = sql_value("SELECT ref value FROM collection WHERE name='$escaped_name' AND $themesql", 0);
|
||||
if ($collection == 0)
|
||||
$collection_parent = array_pop($proposed_branch_path);
|
||||
if(is_null($collection_parent))
|
||||
{
|
||||
sql_query("INSERT INTO collection (name,created,public,$themecolumns,allow_changes)
|
||||
VALUES ('$escaped_name', NOW(), 1, $themevalues, 0)");
|
||||
$collection = sql_insert_id();
|
||||
// We don't have enough folders to create categories so the first one will do (legacy logic)
|
||||
$collection_parent = create_collection($userref, $fallback_fc_categ_name);
|
||||
save_collection(
|
||||
$collection_parent,
|
||||
array(
|
||||
"featured_collections_changes" => array(
|
||||
"update_parent" => 0,
|
||||
"force_featured_collection_type" => true,
|
||||
"thumbnail_selection_method" => $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"],
|
||||
)
|
||||
));
|
||||
}
|
||||
echo "Collection parent should be ref #{$collection_parent}" . PHP_EOL;
|
||||
|
||||
$collection = sql_value(
|
||||
sprintf(
|
||||
"SELECT DISTINCT ref AS `value`
|
||||
FROM collection AS c
|
||||
LEFT JOIN collection_resource AS cr ON c.ref = cr.collection
|
||||
WHERE `type` = %s
|
||||
AND parent %s
|
||||
AND `name` = '%s'
|
||||
GROUP BY c.ref
|
||||
HAVING count(DISTINCT cr.resource) > 0",
|
||||
COLLECTION_TYPE_FEATURED,
|
||||
sql_is_null_or_eq_val($collection_parent, $collection_parent == 0),
|
||||
escape_check($name)
|
||||
),
|
||||
0);
|
||||
|
||||
if($collection == 0)
|
||||
{
|
||||
$collection = create_collection($userref, $name);
|
||||
echo "Created '{$name}' with ref #{$collection}" . PHP_EOL;
|
||||
|
||||
$updated_fc_category = save_collection(
|
||||
$collection,
|
||||
array(
|
||||
"featured_collections_changes" => array(
|
||||
"update_parent" => $collection_parent,
|
||||
"force_featured_collection_type" => true,
|
||||
"thumbnail_selection_method" => $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"],
|
||||
)
|
||||
));
|
||||
if($updated_fc_category === false)
|
||||
{
|
||||
echo "Unable to update '{$name}' with ref #{$collection} to be a Featured Collection under parent ref #{$collection_parent}" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -613,14 +681,23 @@ function ProcessFolder($folder)
|
|||
# Add to collection
|
||||
if ($staticsync_autotheme)
|
||||
{
|
||||
$test = '';
|
||||
$test = sql_query("SELECT * FROM collection_resource WHERE collection='$collection' AND resource='$r'");
|
||||
if (count($test) == 0)
|
||||
// Featured collection categories cannot contain resources. At this stage we need to distinguish
|
||||
// between categories and collections by checking for children collections.
|
||||
if(!is_featured_collection_category_by_children($collection))
|
||||
{
|
||||
sql_query("INSERT INTO collection_resource (collection, resource, date_added)
|
||||
VALUES ('$collection', '$r', NOW())");
|
||||
$test = sql_query("SELECT * FROM collection_resource WHERE collection='$collection' AND resource='$r'");
|
||||
if(count($test) == 0)
|
||||
{
|
||||
sql_query("INSERT INTO collection_resource (collection, resource, date_added) VALUES ('$collection', '$r', NOW())");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Error: Unable to add resource to a featured collection category!" . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
$done[$shortpath]["ref"]=$r;
|
||||
$done[$shortpath]["processed"]=true;
|
||||
$done[$shortpath]["modified"]=date('Y-m-d H:i:s',time());
|
||||
|
@ -950,7 +1027,10 @@ if (!$staticsync_ingest)
|
|||
# ***for modified syncdir directories:
|
||||
$syncdonemodified = hook("modifysyncdonerf");
|
||||
if (!empty($syncdonemodified)) { $resources_to_archive = $syncdonemodified; }
|
||||
|
||||
|
||||
// Get all the featured collections (including categories) that hold these resources
|
||||
$fc_branches = get_featured_collections_by_resources(array_column($resources_to_archive, "ref"));
|
||||
|
||||
foreach ($resources_to_archive as $rf)
|
||||
{
|
||||
$fp = $syncdir . '/' . $rf["file_path"];
|
||||
|
@ -994,10 +1074,30 @@ if (!$staticsync_ingest)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Remove any themes that are now empty as a result of deleted files.
|
||||
sql_query("DELETE FROM collection WHERE theme IS NOT NULL AND LENGTH(theme) > 0 AND
|
||||
(SELECT count(*) FROM collection_resource cr WHERE cr.collection=collection.ref) = 0;");
|
||||
foreach($fc_branches as $fc_branch)
|
||||
{
|
||||
// Reverse the branch path to start from the leaf node. This way, when you reach the category you won't have any
|
||||
// children nodes (ie a normal FC) left (if it will be the case) and we'll be able to delete the FC category.
|
||||
$reversed_branch_path = array_reverse($fc_branch);
|
||||
foreach($reversed_branch_path as $fc)
|
||||
{
|
||||
if(!can_delete_featured_collection($fc["ref"]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(delete_collection($fc["ref"]) === false)
|
||||
{
|
||||
echo "Unable to delete featured collection #{$fc["ref"]}" . PHP_EOL;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "Deleted featured collection #{$fc["ref"]}" . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count($errors) > 0)
|
||||
|
|
|
@ -96,11 +96,6 @@ if($collection_add == "new" && (!$upload_then_edit || ($queue_index == 0 && $chu
|
|||
{
|
||||
collection_set_public($collection_add);
|
||||
}
|
||||
if (strlen(getval("themestring",'')) > 0)
|
||||
{
|
||||
$themearr = explode('||',getval("themestring",''));
|
||||
collection_set_themes($collection_add,$themearr);
|
||||
}
|
||||
}
|
||||
if ($upload_then_edit && $replace == "" && $replace_resource == "")
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ if(getval("save", "") != "" && enforcePostRequest(false))
|
|||
redirect($baseurl_short."pages/done.php?text=password_changed¬loggedin=true");
|
||||
exit();
|
||||
}
|
||||
redirect($baseurl_short."pages/" . ($use_theme_as_home?'themes.php':$default_home_page));
|
||||
redirect($baseurl_short."pages/" . ($use_theme_as_home?'collections_featured.php':$default_home_page));
|
||||
exit();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -15,7 +15,7 @@ include_once "../include/image_processing.php";
|
|||
|
||||
|
||||
// Set a flag for logged in users if $external_share_view_as_internal is set and logged on user is accessing an external share
|
||||
$internal_share_access = ($k!="" && $external_share_view_as_internal && isset($is_authenticated) && $is_authenticated);
|
||||
$internal_share_access = internal_share_access();
|
||||
|
||||
# Update hit count
|
||||
update_hitcount($ref);
|
||||
|
@ -2083,12 +2083,21 @@ if (count($result)>0)
|
|||
<div class="Title"><?php echo $lang["collectionsthemes"]?></div>
|
||||
|
||||
<?php
|
||||
# loop and display the results
|
||||
for ($n=0;$n<count($result);$n++)
|
||||
{
|
||||
$url = generateURL("{$baseurl}/pages/search.php", array("search" => "!collection{$result[$n]["ref"]}"));
|
||||
|
||||
$path = $result[$n]["path"];
|
||||
if(!$collection_public_hide_owner)
|
||||
{
|
||||
$col_name = i18n_get_translated($result[$n]["name"]);
|
||||
// legacy thing: we add the fullname right before the collection name in the path.
|
||||
$path = str_replace($col_name, htmlspecialchars($result[$n]["fullname"]) . " / {$col_name}", $path);
|
||||
}
|
||||
$path = sprintf("%s %s", LINK_CARET, htmlspecialchars($path));
|
||||
?>
|
||||
<a href="<?php echo $baseurl?>/pages/search.php?search=!collection<?php echo $result[$n]["ref"]?>" onClick="return CentralSpaceLoad(this,true);"><?php echo LINK_CARET ?><?php echo (strlen($result[$n]["theme"])>0)?htmlspecialchars(str_replace("*","",i18n_get_translated($result[$n]["theme"])) . " / "):$lang["public"] . " : "; ?><?php if (!$collection_public_hide_owner) {echo htmlspecialchars($result[$n]["fullname"] . " / ");} ?><?php echo i18n_get_collection_name($result[$n]); ?></a><br />
|
||||
<?php
|
||||
<a href="<?php echo $url; ?>" onclick="return CentralSpaceLoad(this, true);"><?php echo $path; ?></a><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ for ($n=$offset;(($n<count($collections)) && ($n<($offset+$per_page)));$n++)
|
|||
echo "</tr>";
|
||||
}
|
||||
|
||||
if ($collections[$n]["public"]==1)
|
||||
if(in_array($collections[$n]["type"], $COLLECTION_PUBLIC_TYPES))
|
||||
{
|
||||
if (strlen($collections[$n]["theme"])>0)
|
||||
if ($collections[$n]["type"] == COLLECTION_TYPE_FEATURED)
|
||||
{
|
||||
echo "<tr>";
|
||||
echo "<td>" . $lang["theme"] . "</td>";
|
||||
|
|
|
@ -266,6 +266,10 @@ function HookResourceconnectAllGetResourcesToCheck($collection)
|
|||
access key check only relevant for local resources therefore retrieve local resources only
|
||||
*/
|
||||
global $userrequestmode;
|
||||
if(is_array($collection) && isset($collection["ref"]))
|
||||
{
|
||||
$collection = $collection["ref"];
|
||||
}
|
||||
# retrieve only local resources from collection for access key validation
|
||||
$resources = sql_array('SELECT resource AS value FROM collection_resource WHERE collection = ' . escape_check($collection) . ';');
|
||||
|
||||
|
|
|
@ -1,27 +1,19 @@
|
|||
<?php
|
||||
|
||||
|
||||
if (php_sapi_name()!=="cli") {exit("This utility is command line only.");}
|
||||
// Test to ensure that J permission blocks access to resources that are outside public collections that the user has access to.
|
||||
|
||||
$saved_userref = $userref;
|
||||
$userref = 999;
|
||||
$savedpermissions = $userpermissions;
|
||||
// create 5 new resources
|
||||
|
||||
|
||||
// Create 5 new resources
|
||||
$resourcea=create_resource(1,0);
|
||||
$resourceb=create_resource(1,0);
|
||||
$resourcec=create_resource(1,0);
|
||||
$resourced=create_resource(1,0);
|
||||
$resourcee=create_resource(1,0);
|
||||
|
||||
debug("BANG Resource A: " . $resourcea);
|
||||
debug("BANG Resource B: " . $resourceb);
|
||||
debug("BANG Resource C: " . $resourcec);
|
||||
debug("BANG Resource D: " . $resourced);
|
||||
debug("BANG Resource E: " . $resourcee);
|
||||
|
||||
// Add text to free text to fields
|
||||
update_field($resourcea,'title','test_000985_A');
|
||||
update_field($resourceb,'title','test_000985_B');
|
||||
|
@ -37,11 +29,27 @@ add_resource_nodes($resourcec,array($dummynode));
|
|||
add_resource_nodes($resourced,array($dummynode));
|
||||
add_resource_nodes($resourcee,array($dummynode));
|
||||
|
||||
// Create the Featured collections tree
|
||||
$fc_cat_mountains = create_collection(1, "Mountains");
|
||||
save_collection($fc_cat_mountains, array("featured_collections_changes" => array("update_parent" => 0, "force_featured_collection_type" => true)));
|
||||
$fc_cat_cuillin = create_collection(1, "Cuillin");
|
||||
save_collection($fc_cat_cuillin, array("featured_collections_changes" => array("update_parent" => $fc_cat_mountains,"force_featured_collection_type" => true)));
|
||||
$fc_cat_seasons = create_collection(1, "Seasons");
|
||||
save_collection( $fc_cat_seasons,array("featured_collections_changes" => array("update_parent" => 0,"force_featured_collection_type" => true)));
|
||||
$fc_cat_winter = create_collection(1, "Winter");
|
||||
save_collection( $fc_cat_winter,array("featured_collections_changes" => array("update_parent" => $fc_cat_seasons,"force_featured_collection_type" => true)));
|
||||
$fc_cat_spring = create_collection(1, "Spring");
|
||||
save_collection( $fc_cat_spring,array("featured_collections_changes" => array("update_parent" => $fc_cat_seasons,"force_featured_collection_type" => true)));
|
||||
|
||||
// Create public collections
|
||||
$mountains = create_collection(1,'Mountains',0,0,0,true,array('Mountains'));
|
||||
$cuillin = create_collection(1,'Cuillin',0,0,0,true,array('Mountains','Cuillin'));
|
||||
$winter = create_collection(1,'Winter',0,0,0,true,array('Seasons','Winter'));
|
||||
$spring = create_collection(1,'Spring',0,0,0,true,array('Seasons','Spring'));
|
||||
$mountains = create_collection(1,'Mountains',0,0,0,true/*,array('Mountains')*/);
|
||||
save_collection($mountains, array("featured_collections_changes" => array("update_parent" => $fc_cat_mountains,"force_featured_collection_type" => true)));
|
||||
$cuillin = create_collection(1,'Cuillin',0,0,0,true/*,array('Mountains','Cuillin')*/);
|
||||
save_collection($cuillin, array("featured_collections_changes" => array("update_parent" => $fc_cat_cuillin,"force_featured_collection_type" => true)));
|
||||
$winter = create_collection(1,'Winter',0,0,0,true/*,array('Seasons','Winter')*/);
|
||||
save_collection($winter, array("featured_collections_changes" => array("update_parent" => $fc_cat_winter,"force_featured_collection_type" => true)));
|
||||
$spring = create_collection(1,'Spring',0,0,0,true/*,array('Seasons','Spring')*/);
|
||||
save_collection($spring, array("featured_collections_changes" => array("update_parent" => $fc_cat_spring,"force_featured_collection_type" => true)));
|
||||
|
||||
// Add resources to public collections
|
||||
// Resource A in Mountains
|
||||
|
@ -93,7 +101,7 @@ if (!is_array($results)
|
|||
// SUBTEST C
|
||||
// ----- Access to Mountains themes and no access to resources not in themes -----
|
||||
// Resource a,b should be shown
|
||||
$userpermissions = array('s','jMountains','J');
|
||||
$userpermissions = array('s', "j{$fc_cat_mountains}",'J');
|
||||
$results = do_search('test000985');
|
||||
|
||||
if (!is_array($results)
|
||||
|
@ -111,7 +119,7 @@ if (!is_array($results)
|
|||
// SUBTEST D
|
||||
// ----- Access to Mountains but not Cuillin subtheme and no access to resources not in themes -----
|
||||
// Resource a should be shown
|
||||
$userpermissions = array('s','jMountains','j-Mountains|Cuillin','J');
|
||||
$userpermissions = array('s', "j{$fc_cat_mountains}", "-j{$fc_cat_cuillin}"/*,'jMountains','j-Mountains|Cuillin'*/,'J');
|
||||
$results = do_search('test000985');
|
||||
|
||||
if (!is_array($results)
|
||||
|
|
|
@ -1,34 +1,31 @@
|
|||
<?php
|
||||
|
||||
include_once(__DIR__ . '/../../include/db.php');
|
||||
if (php_sapi_name()!=="cli") {exit("This utility is command line only.");}
|
||||
|
||||
// create new collections
|
||||
$levels = array("Top level");
|
||||
// Create the Featured collections tree
|
||||
$fc_cat_1 = create_collection($userref, "FC 1");
|
||||
save_collection($fc_cat_1, array("featured_collections_changes" => array("update_parent" => 0, "force_featured_collection_type" => true)));
|
||||
$fc_cat_1_1 = create_collection($userref, "FC 1 / 1");
|
||||
save_collection($fc_cat_1_1, array("featured_collections_changes" => array("update_parent" => 0, "force_featured_collection_type" => true)));
|
||||
|
||||
$levelacollection = create_collection(1,"TEST COLLECTION 1",0,0,0,true,$levels);
|
||||
$getthemes=get_themes($levels);
|
||||
// Check FC tree has been created
|
||||
$lvl_1 = get_featured_collection_categories(0, array("access_control" => false));
|
||||
$lvl_2 = get_featured_collection_categories($fc_cat_1, array("access_control" => false));
|
||||
$fc_tree = array_merge($lvl_1, $lvl_2);
|
||||
$fc_tree = array_column($fc_tree, "ref");
|
||||
if(!empty(array_diff(array($fc_cat_1, $fc_cat_1_1), $fc_tree)))
|
||||
{
|
||||
echo "Create Featured Collection Categories - ";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(count($getthemes) != 1 || !in_array($levelacollection,array_column($getthemes,"ref")))
|
||||
{return false;}
|
||||
$public_col = create_collection($userref, "Test 1400 - Public collection", 0, 0, 0, true);
|
||||
$find_public_col = search_public_collections("Test 1400", "name", "ASC", true, false);
|
||||
$found_public_col = array_column($find_public_col, "ref");
|
||||
if(empty($found_public_col))
|
||||
{
|
||||
echo "Create Public Collection - ";
|
||||
return false;
|
||||
}
|
||||
|
||||
$levels[] = "level 2";
|
||||
$levelbcollection = create_collection(1,"TEST COLLECTION 2",0,0,0,true,$levels);
|
||||
$getthemes=get_themes($levels);
|
||||
if(count($getthemes) != 1 || !in_array($levelbcollection,array_column($getthemes,"ref")))
|
||||
{return false;}
|
||||
|
||||
$levels[] = "level 3";
|
||||
$levelccollection = create_collection(1,"TEST COLLECTION 3",0,0,0,true,$levels);
|
||||
$getthemes=get_themes(array("Top level","level 2"),true);
|
||||
if(count($getthemes) != 2 || !in_array($levelbcollection,array_column($getthemes,"ref")) || !in_array($levelccollection,array_column($getthemes,"ref")) )
|
||||
{return false;}
|
||||
|
||||
$theme_category_levels=4;
|
||||
$levels[] = "level 4";
|
||||
$leveldcollection = create_collection(1,"TEST COLLECTION 4",0,0,0,true,$levels);
|
||||
$getthemes=get_themes(array("Top level","level 2"),true);
|
||||
if(count($getthemes) != 3 || !in_array($levelbcollection,array_column($getthemes,"ref")) || !in_array($levelccollection,array_column($getthemes,"ref")) || !in_array($leveldcollection,array_column($getthemes,"ref")) )
|
||||
{return false;}
|
||||
|
||||
return true;
|
||||
return true;
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
set_sysvar(SYSVAR_UPGRADE_PROGRESS_SCRIPT, "Starting migrating themes to collections using parent structure...");
|
||||
$featured_collections = sql_query("SELECT * FROM collection WHERE public = 1 AND length(theme) > 0");
|
||||
foreach($featured_collections as $collection)
|
||||
{
|
||||
// Ensure the full tree structure exists first to support this.
|
||||
$parent = null;
|
||||
for($level = 1; $level <= $theme_category_levels; $level++)
|
||||
{
|
||||
$col = "theme" . ($level == 1 ? "" : $level);
|
||||
|
||||
if(trim($collection[$col]) == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$parent_sql_val = sql_is_null_or_eq_val((string) $parent, is_null($parent));
|
||||
$new_fc_name = escape_check($collection[$col]);
|
||||
|
||||
logScript("Processing collection #{$collection["ref"]} - column {$col} = '{$collection[$col]}' and parent {$parent_sql_val}");
|
||||
|
||||
$fc_ref = sql_value(
|
||||
sprintf("SELECT ref AS `value` FROM collection WHERE `name` = '%s' AND public = 1 AND `type` = '%s' AND parent %s",
|
||||
$new_fc_name, // name
|
||||
COLLECTION_TYPE_FEATURED, // type
|
||||
$parent_sql_val // parent
|
||||
), null);
|
||||
|
||||
if(is_null($fc_ref))
|
||||
{
|
||||
$sql = sprintf("INSERT INTO collection(name, public, type, parent, thumbnail_selection_method) VALUES ('%s', 1, '%s', %s, %s)",
|
||||
$new_fc_name,
|
||||
COLLECTION_TYPE_FEATURED,
|
||||
sql_null_or_val((string) $parent, is_null($parent)),
|
||||
(!$collection_commenting ? $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"] : $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["manual"])
|
||||
);
|
||||
logScript($sql);
|
||||
sql_query($sql);
|
||||
$fc_ref = sql_insert_id();
|
||||
logScript("Created new FC #{$fc_ref}");
|
||||
}
|
||||
|
||||
// Set the parent to this collection as we descend down the tree
|
||||
$parent = $fc_ref;
|
||||
}
|
||||
|
||||
// The necessary parts of the tree now exist to support this collection. Drop it into the tree.
|
||||
logScript("Update collection parent for the actual collection: {$collection["ref"]} with parent '$parent'");
|
||||
sql_query(sprintf("UPDATE collection SET `type` = '%s', parent = %s, thumbnail_selection_method = '%s' WHERE ref = '%s'",
|
||||
COLLECTION_TYPE_FEATURED,
|
||||
sql_null_or_val((string) $parent, is_null($parent)),
|
||||
(!$collection_commenting ? $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["most_popular_image"] : $FEATURED_COLLECTION_BG_IMG_SELECTION_OPTIONS["manual"]),
|
||||
$collection["ref"]
|
||||
));
|
||||
}
|
||||
|
||||
set_sysvar(SYSVAR_UPGRADE_PROGRESS_SCRIPT, "Successfully migrated themes to collections using the parent structure");
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
include_once __DIR__ . "/../../include/db.php";
|
||||
|
||||
set_sysvar(SYSVAR_UPGRADE_PROGRESS_SCRIPT, "Started migrating featured collections permissions from the old format to the new one (e.g j[ID], -j[ID]) ...");
|
||||
|
||||
$all_ugs = sql_query("SELECT ref, `name`, permissions FROM usergroup");
|
||||
foreach($all_ugs as $ug)
|
||||
{
|
||||
logScript("Analysing user group #{$ug["ref"]} '{$ug["name"]}'");
|
||||
logScript("Original (old format) permissions: {$ug["permissions"]}");
|
||||
$permissions = trim_array(explode(",", $ug["permissions"]));
|
||||
|
||||
$old_format_perms = array();
|
||||
foreach($permissions as $perm)
|
||||
{
|
||||
$matches = array();
|
||||
if(preg_match("/^(j\-?){1}(.+[^*])$/", $perm, $matches) === 1)
|
||||
{
|
||||
/* Examples of a match (root category and a sub-category):
|
||||
Array
|
||||
(
|
||||
[0] => jFC1 --> actual permission (full regex match)
|
||||
[1] => j --> permission type (j for root levels, "j-" for sub-categories which are also reverse permissions)
|
||||
[2] => FC1 --> the featured collection category branch path (separated by pipes "|" and using the category name)
|
||||
)
|
||||
Array
|
||||
(
|
||||
[0] => j-FC1|FC1/1.1|FC1/1.1/1.1.1
|
||||
[1] => j-
|
||||
[2] => FC1|FC1/1.1|FC1/1.1/1.1.1
|
||||
)
|
||||
*/
|
||||
$old_format_perms[] = $matches;
|
||||
}
|
||||
}
|
||||
|
||||
$update_permissions = false;
|
||||
foreach($old_format_perms as $j_perm)
|
||||
{
|
||||
$find_fc_by_name = explode("|", $j_perm[2]);
|
||||
$find_fc_by_name = trim(end($find_fc_by_name));
|
||||
|
||||
if($find_fc_by_name == "")
|
||||
{
|
||||
logScript("Unable to determine the leaf node name for Featured Collection Category '{$j_perm[2]}'");
|
||||
continue;
|
||||
}
|
||||
|
||||
$found_fc_categ_refs = sql_array(
|
||||
sprintf(
|
||||
"SELECT DISTINCT c.ref AS `value`
|
||||
FROM collection AS c
|
||||
LEFT JOIN collection AS cc ON c.ref = cc.parent
|
||||
WHERE c.public = 1
|
||||
AND c.`type`= %s
|
||||
AND c.`name` = '%s'
|
||||
GROUP BY c.ref
|
||||
HAVING count(DISTINCT cc.ref) > 0",
|
||||
COLLECTION_TYPE_FEATURED,
|
||||
escape_check($find_fc_by_name)
|
||||
)
|
||||
);
|
||||
|
||||
$fc_categ_ref = null;
|
||||
foreach($found_fc_categ_refs as $found_fc_categ_ref)
|
||||
{
|
||||
// Ensure there were no issues finding the correct featured collection by double checking that the branch paths match
|
||||
$found_branch_path = get_featured_collection_category_branch_by_leaf($found_fc_categ_ref, array());
|
||||
$branch_path_str = array_reduce($found_branch_path, function($carry, $item) { return "{$carry}|{$item["name"]}"; }, "");
|
||||
$branch_path_str = mb_substr($branch_path_str, 1, mb_strlen($branch_path_str));
|
||||
if($j_perm[2] != $branch_path_str)
|
||||
{
|
||||
logScript("Found a featured collection category but computed branch path is different! For the old permission this is '{$j_perm[2]}' and for the new one it is '{$branch_path_str}'. ResourceSpace might have found a similar named collection incorrectly! Skipping...");
|
||||
continue;
|
||||
}
|
||||
|
||||
$fc_categ_ref = $found_fc_categ_ref;
|
||||
}
|
||||
|
||||
if(is_null($fc_categ_ref))
|
||||
{
|
||||
logScript("Unable to find Featured Collection Category named '{$j_perm}'");
|
||||
continue;
|
||||
}
|
||||
|
||||
// add the new permission format
|
||||
$new_fc_perm = ($j_perm[1] == "j" ? "" : "-") . "j{$fc_categ_ref}";
|
||||
$permissions[] = $new_fc_perm;
|
||||
|
||||
// remove the old permission format
|
||||
$permissions = array_diff($permissions, array("{$j_perm[0]}"));
|
||||
|
||||
$update_permissions = true;
|
||||
}
|
||||
|
||||
if($update_permissions)
|
||||
{
|
||||
$permissions_str = join(",", $permissions);
|
||||
logScript("New format permissions: " . $permissions_str);
|
||||
sql_query(
|
||||
sprintf("UPDATE usergroup SET permissions = '%s' WHERE ref = '%s'",
|
||||
escape_check($permissions_str),
|
||||
escape_check($ug["ref"])));
|
||||
}
|
||||
}
|
||||
|
||||
set_sysvar(SYSVAR_UPGRADE_PROGRESS_SCRIPT, "Successfully migrated featured collections permissions to the new format!");
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
set_sysvar(SYSVAR_UPGRADE_PROGRESS_SCRIPT, "Starting migrating public collections to use the new collection type - COLLECTION_TYPE_PUBLIC...");
|
||||
|
||||
$public_collections = sql_array(sprintf("SELECT ref AS `value` FROM collection WHERE `type` = %s AND public = 1 AND (theme IS NULL OR length(trim(theme)) = 0)", COLLECTION_TYPE_STANDARD));
|
||||
if(!empty($public_collections))
|
||||
{
|
||||
sql_query(
|
||||
sprintf(
|
||||
"UPDATE collection SET `type` = %s WHERE ref IN ('%s')",
|
||||
COLLECTION_TYPE_PUBLIC,
|
||||
join("', '", $public_collections)));
|
||||
}
|
||||
|
||||
set_sysvar(SYSVAR_UPGRADE_PROGRESS_SCRIPT, "Successfully migrated public collections to use the new 'COLLECTION_TYPE_PUBLIC' type");
|
Loading…
Reference in New Issue