function compile_collection_actions(array $collection_data, $top_actions)
{
    global $baseurl_short, $lang, $k, $userrequestmode, $zipcommand, $collection_download, $contact_sheet, $manage_collections_contact_sheet_link, $manage_collections_share_link, $allow_share, $manage_collections_remove_link, $userref, $collection_purge, $show_edit_all_link, $result, $edit_all_checkperms, $preview_all, $order_by, $sort, $archive, $contact_sheet_link_on_collection_bar, $show_searchitemsdiskusage, $emptycollection, $remove_resources_link_on_collection_bar, $count_result, $download_usage, $home_dash, $top_nav_upload_type, $pagename, $offset, $col_order_by, $find, $default_sort, $starsearch, $restricted_share;
    $options = array();
    $o = 0;
    if (empty($collection_data)) {
        return $options;
    }
    if (!collection_is_research_request($collection_data['ref']) || !checkperm('r')) {
        if (!$top_actions && checkperm('s') && $pagename === 'collections') {
            // Manage My Collections
            $data_attribute['url'] = $baseurl_short . 'pages/collection_manage.php';
            $options[$o]['value'] = 'manage_collections';
            $options[$o]['label'] = $lang['managemycollections'];
            $options[$o]['data_attr'] = $data_attribute;
            $o++;
            // Collection feedback
            if (isset($collection_data['request_feedback']) && $collection_data['request_feedback']) {
                $data_attribute['url'] = sprintf('%spages/collection_feedback.php?collection=%s&k=%s', $baseurl_short, urlencode($collection_data['ref']), urlencode($k));
                $options[$o]['value'] = 'collection_feedback';
                $options[$o]['label'] = $lang['sendfeedback'];
                $options[$o]['data_attr'] = $data_attribute;
                $o++;
            }
        }
    } else {
        $research = sql_value('SELECT ref value FROM research_request WHERE collection="' . $collection_data['ref'] . '";', 0);
        // Manage research requests
        $data_attribute['url'] = sprintf('%spages/team/team_research.php', $baseurl_short);
        $options[$o]['value'] = 'manage_research_requests';
        $options[$o]['label'] = $lang['manageresearchrequests'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
        // Edit research requests
        $data_attribute['url'] = sprintf('%spages/team/team_research_edit.php?ref=%s', $baseurl_short, urlencode($research));
        $options[$o]['value'] = 'edit_research_requests';
        $options[$o]['label'] = $lang['editresearchrequests'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    }
    // Select collection option - not for collection bar
    if ($pagename != 'collections' && $k == '' && !checkperm('b') && ($pagename == 'themes' || $pagename === 'collection_manage' || $pagename === 'resource_collection_list' || $top_actions)) {
        $options[$o]['value'] = 'select_collection';
        $options[$o]['label'] = $lang['selectcollection'];
        $o++;
    }
    // Edit Collection
    if ($userref == $collection_data['user'] || checkperm('h')) {
        $extra_tag_attributes = sprintf('
                data-url="%spages/collection_edit.php?ref=%s"
            ', $baseurl_short, urlencode($collection_data['ref']));
        $options[$o]['value'] = 'edit_collection';
        $options[$o]['label'] = $lang['action-edit'];
        $options[$o]['data_attr'] = array();
        $options[$o]['extra_tag_attributes'] = $extra_tag_attributes;
        $o++;
    }
    // Upload to collection
    if ((checkperm('c') || checkperm('d')) && $collection_data['savedsearch'] == 0 && ($userref == $collection_data['user'] || $collection_data['allow_changes'] == 1 || checkperm('h'))) {
        $data_attribute['url'] = sprintf('%spages/edit.php?uploader=%s&ref=-%s&collection_add=%s', $baseurl_short, urlencode($top_nav_upload_type), urlencode($userref), urlencode($collection_data['ref']));
        $options[$o]['value'] = 'upload_collection';
        $options[$o]['label'] = $lang['action-upload-to-collection'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    }
    // Home_dash is on, AND NOT Anonymous use, AND (Dash tile user (NOT with a managed dash) || Dash Tile Admin)
    if (!$top_actions && $home_dash && checkPermission_dashcreate()) {
        $data_attribute['url'] = sprintf('
            %spages/dash_tile.php?create=true&tltype=srch&promoted_resource=true&freetext=true&all_users=1&link=/pages/search.php?search=!collection%s&order_by=relevance&sort=DESC
            ', $baseurl_short, $collection_data['ref']);
        $options[$o]['value'] = 'save_collection_to_dash';
        $options[$o]['label'] = $lang['createnewdashtile'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    }
    // Request all
    if ($count_result > 0) {
        # Ability to request a whole collection (only if user has restricted access to any of these resources)
        $min_access = collection_min_access($result);
        if ($min_access != 0) {
            $data_attribute['url'] = sprintf('%spages/collection_request.php?ref=%s&k=%s', $baseurl_short, urlencode($collection_data['ref']), urlencode($k));
            $options[$o]['value'] = 'request_all';
            $options[$o]['label'] = $lang['requestall'];
            $options[$o]['data_attr'] = $data_attribute;
            $o++;
        }
    }
    // Download option
    if ($download_usage && ((isset($zipcommand) || $collection_download) && $count_result > 0)) {
        $data_attribute['url'] = $baseurl_short . "pages/terms.php?k=" . urlencode($k) . "&url=pages/download_usage.php?collection=" . urlencode($collection_data['ref']) . "%26k=" . urlencode($k);
        $options[$o]['value'] = 'download_collection';
        $options[$o]['label'] = $lang['action-download'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    } else {
        if ((isset($zipcommand) || $collection_download) && $count_result > 0) {
            $data_attribute['url'] = $baseurl_short . "pages/terms.php?k=" . urlencode($k) . "&url=pages/collection_download.php?collection=" . urlencode($collection_data['ref']) . "%26k=" . urlencode($k);
            $options[$o]['value'] = 'download_collection';
            $options[$o]['label'] = $lang['action-download'];
            $options[$o]['data_attr'] = $data_attribute;
            $o++;
        } else {
            if (isset($zipcommand) || $collection_download) {
                $data_attribute['url'] = $baseurl_short . "pages/terms.php?k=" . urlencode($k) . "&url=pages/collection_download.php?collection=" . urlencode($collection_data['ref']) . "%26k=" . urlencode($k);
                $options[$o]['value'] = 'download_collection';
                $options[$o]['label'] = $lang['action-download'];
                $options[$o]['data_attr'] = $data_attribute;
                $o++;
            }
        }
    }
    // Contact Sheet
    if ($k == "" && $contact_sheet == true && ($manage_collections_contact_sheet_link || $contact_sheet_link_on_collection_bar)) {
        $data_attribute = array('url' => sprintf('%spages/contactsheet_settings.php?ref=%s', $baseurl_short, urlencode($collection_data['ref'])));
        $options[$o]['value'] = 'contact_sheet';
        $options[$o]['label'] = $lang['contactsheet'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    }
    // Share
    if ($k == "" && $manage_collections_share_link && $allow_share && (checkperm('v') || checkperm('g') || collection_min_access($collection_data['ref']) <= 1 && $restricted_share)) {
        $extra_tag_attributes = sprintf('
                data-url="%spages/collection_share.php?ref=%s"
            ', $baseurl_short, urlencode($collection_data['ref']));
        $options[$o]['value'] = 'share_collection';
        $options[$o]['label'] = $lang['share'];
        $options[$o]['data_attr'] = array();
        $options[$o]['extra_tag_attributes'] = $extra_tag_attributes;
        $o++;
    }
    // Remove
    if ($k == "" && $manage_collections_remove_link && $userref != $collection_data['user']) {
        $options[$o]['value'] = 'remove_collection';
        $options[$o]['label'] = $lang['action-remove'];
        $o++;
    }
    // Delete
    if ($k == "" && ($userref == $collection_data['user'] || checkperm('h')) && $collection_data['cant_delete'] == 0) {
        $options[$o]['value'] = 'delete_collection';
        $options[$o]['label'] = $lang['action-delete'];
        $o++;
    }
    // Collection Purge
    if ($k == "" && $collection_purge && isset($collections) && checkperm('e0') && $collection_data['cant_delete'] == 0) {
        $options[$o]['value'] = 'purge_collection';
        $options[$o]['label'] = $lang['purgeanddelete'];
        $o++;
    }
    // Collection log
    if ($k == "" && $userref == $collection_data['user'] || checkperm('h')) {
        $extra_tag_attributes = sprintf('
                data-url="%spages/collection_log.php?ref=%s"
            ', $baseurl_short, urlencode($collection_data['ref']));
        $options[$o]['value'] = 'collection_log';
        $options[$o]['label'] = $lang['action-log'];
        $options[$o]['data_attr'] = array();
        $options[$o]['extra_tag_attributes'] = $extra_tag_attributes;
        $o++;
    }
    // View all
    if ($k == "" && (isset($collection_data["c"]) && $collection_data["c"] > 0) || count($result) > 0) {
        $data_attribute['url'] = $baseurl_short . 'pages/search.php?search=!collection' . urlencode($collection_data['ref']) . "&k=" . urlencode($k);
        $options[$o]['value'] = 'view_all_resources_in_collection';
        $options[$o]['label'] = $lang['view_all_resources'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    }
    // Edit all
    # If this collection is (fully) editable, then display an edit all link
    if ($k == "" && $show_edit_all_link && count($result) > 0) {
        if (!$edit_all_checkperms || allow_multi_edit($collection_data['ref'])) {
            $extra_tag_attributes = sprintf('
                    data-url="%spages/edit.php?collection=%s"
                ', $baseurl_short, urlencode($collection_data['ref']));
            $options[$o]['value'] = 'edit_all_in_collection';
            $options[$o]['label'] = $lang['edit_all_resources'];
            $options[$o]['data_attr'] = array();
            $options[$o]['extra_tag_attributes'] = $extra_tag_attributes;
            $o++;
        }
    }
    // Delete all
    // Note: functionality moved from edit collection page
    if ($k == "" && !$top_actions && (count($result) != 0 || $count_result != 0) && !(isset($allow_resource_deletion) && !$allow_resource_deletion) && collection_writeable($collection_data['ref']) && allow_multi_edit($collection_data['ref']) && !checkperm('D')) {
        $options[$o]['value'] = 'delete_all_in_collection';
        $options[$o]['label'] = $lang['deleteallresourcesfromcollection'];
        $o++;
    }
    // Preview all
    if (count($result) != 0 && $k == '' && $preview_all) {
        $extra_tag_attributes = sprintf('
                data-url="%spages/preview_all.php?ref=%s"
            ', $baseurl_short, urlencode($collection_data['ref']));
        $options[$o]['value'] = 'preview_all';
        $options[$o]['label'] = $lang['preview_all'];
        $options[$o]['data_attr'] = array();
        $options[$o]['extra_tag_attributes'] = $extra_tag_attributes;
        $o++;
    }
    // Remove all
    if ($k == '' && isset($emptycollection) && $remove_resources_link_on_collection_bar && collection_writeable($collection_data['ref'])) {
        $data_attribute['url'] = sprintf('%spages/collections.php?emptycollection=%s&removeall=true&submitted=removeall&ajax=true', $baseurl_short, urlencode($collection_data['ref']));
        $options[$o]['value'] = 'empty_collection';
        $options[$o]['label'] = $lang['emptycollection'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    }
    // Edit Previews
    if ($k == '' && $count_result > 0 && ($userref == $collection_data['user'] || $collection_data['allow_changes'] == 1 || checkperm('h')) && allow_multi_edit($collection_data['ref'])) {
        $main_pages = array('search', 'collection_manage', 'collection_public', 'themes');
        $back_to_page = in_array($pagename, $main_pages) ? htmlspecialchars($pagename) : '';
        $data_attribute['url'] = sprintf('%spages/collection_edit_previews.php?ref=%s&offset=%s&order_by=%s&col_order_by=<%s&sort=%s&find=%s&backto=%s', $baseurl_short, urlencode($collection_data['ref']), urlencode($offset), urlencode($order_by), urlencode($col_order_by), urlencode($sort), urlencode($find), $back_to_page);
        $options[$o]['value'] = 'edit_previews';
        $options[$o]['label'] = $lang['editcollectionresources'];
        $options[$o]['data_attr'] = $data_attribute;
        $o++;
    }
    // Show disk usage
    if ($k == '' && !$top_actions && $show_searchitemsdiskusage) {
        $extra_tag_attributes = sprintf('
                data-url="%spages/search_disk_usage.php?search=!collection%s&k=%s"
            ', $baseurl_short, urlencode($collection_data['ref']), urlencode($k));
        $options[$o]['value'] = 'search_items_disk_usage';
        $options[$o]['label'] = $lang['collection_disk_usage'];
        $options[$o]['data_attr'] = array();
        $options[$o]['extra_tag_attributes'] = $extra_tag_attributes;
        $o++;
    }
    // CSV export of collection metadata
    if (!$top_actions && $k == '') {
        if (empty($order_by)) {
            $order_by = $default_sort;
        }
        $options[$o]['value'] = 'csv_export_results_metadata';
        $options[$o]['label'] = $lang['csvExportResultsMetadata'];
        $options[$o]['data_attr']['url'] = sprintf('%spages/csv_export_results_metadata.php?search=!collection%s&restype=%s&order_by=%s&archive=0&sort=%s&starsearch=%s', $baseurl_short, urlencode($collection_data['ref']), isset($_COOKIE['restypes']) ? urlencode($_COOKIE['restypes']) : '', urlencode($order_by), urlencode($sort), urlencode($starsearch));
        $o++;
    }
    // Add extra collection actions and manipulate existing actions through plugins
    $modified_options = hook('render_actions_add_collection_option', '', array($top_actions, $options));
    if (is_array($modified_options) && !empty($modified_options)) {
        $options = $modified_options;
    }
    return $options;
}
// 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"];
			}
		
		}
	
Beispiel #3
0
function HookLegacy_actionsAllAftertogglethumbs()
{
    global $baseurl_short, $lang, $usercollection, $contact_sheet, $allow_share, $cinfo, $userref, $preview_all, $feedback, $k, $result, $collection_download, $count_result, $disable_collection_toggle;
    ?>
    <ul style="float: right;">
    <?php 
    if (!collection_is_research_request($usercollection) || !checkperm('r')) {
        hook('beforecollectionminlinks');
        if (checkperm('s')) {
            if ($contact_sheet == true) {
                ?>
                <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
                echo $baseurl_short;
                ?>
pages/contactsheet_settings.php?ref=<?php 
                echo urlencode($usercollection);
                ?>
">&nbsp;<?php 
                echo $lang['contactsheet'];
                ?>
</a></li>
                <?php 
            }
            if ($allow_share) {
                ?>
                <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
                echo $baseurl_short;
                ?>
pages/collection_share.php?ref=<?php 
                echo urlencode($usercollection);
                ?>
"><?php 
                echo $lang['share'];
                ?>
</a></li>
                <?php 
            }
            if ($userref == $cinfo['user'] || checkperm('h')) {
                ?>
                <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
                echo $baseurl_short;
                ?>
pages/collection_edit.php?ref=<?php 
                echo urlencode($usercollection);
                ?>
">&nbsp;<?php 
                echo $allow_share ? $lang['action-edit'] : $lang['editcollection'];
                ?>
</a></li>
                <?php 
            }
            if ($preview_all) {
                ?>
                <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
                echo $baseurl_short;
                ?>
pages/preview_all.php?ref=<?php 
                echo urlencode($usercollection);
                ?>
"><?php 
                echo $lang['preview_all'];
                ?>
</a></li>
                <?php 
            }
            hook('collectiontool2min');
            if ($feedback) {
                ?>
                <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
                echo $baseurl_short;
                ?>
pages/collection_feedback.php?collection=<?php 
                echo urlencode($usercollection);
                ?>
&k=<?php 
                echo urlencode($k);
                ?>
">&nbsp;<?php 
                echo $lang['sendfeedback'];
                ?>
</a></li>
                <?php 
            }
        }
    } else {
        if (!hook('replacecollectionsresearchlinks')) {
            $research = sql_value("SELECT ref value FROM research_request WHERE collection = '" . $usercollection . "'", 0);
            ?>
            <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
            echo $baseurl_short;
            ?>
pages/team/team_research.php"><?php 
            echo $lang['manageresearchrequests'];
            ?>
</a></li>
            <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
            echo $baseurl_short;
            ?>
pages/team/team_research_edit.php?ref=<?php 
            echo urlencode($research);
            ?>
"><?php 
            echo $lang['editresearchrequests'];
            ?>
</a></li>
            <?php 
        }
        /* end hook replacecollectionsresearchlinks */
    }
    # If this collection is (fully) editable, then display an extra edit all link
    if (count($result) > 0 && checkperm('e' . $result[0]['archive']) && allow_multi_edit($result)) {
        ?>
        <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
        echo $baseurl_short;
        ?>
pages/search.php?search=<?php 
        echo urlencode('!collection' . $usercollection);
        ?>
"><?php 
        echo $lang['viewall'];
        ?>
</a></li>
        <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
        echo $baseurl_short;
        ?>
pages/edit.php?collection=<?php 
        echo $usercollection;
        ?>
"><?php 
        echo $lang['action-editall'];
        ?>
</a></li>
        <?php 
    } else {
        ?>
        <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
        echo $baseurl_short;
        ?>
pages/search.php?search=<?php 
        echo urlencode('!collection' . $usercollection);
        ?>
"><?php 
        echo $lang['viewall'];
        ?>
</a></li>
        <?php 
    }
    echo isset($emptycollection) && $remove_resources_link_on_collection_bar && collection_writeable($usercollection) ? '<li><a href="' . $baseurl_short . 'pages/collections.php?emptycollection=' . urlencode($usercollection) . '&removeall=true&submitted=removeall&ajax=true" onclick="if(!confirm(\'' . $lang['emptycollectionareyousure'] . '\')){return false;}return CollectionDivLoad(this);">' . $lang['emptycollection'] . '</a></li>' : '';
    if ((isset($zipcommand) || $collection_download) && $count_result > 0) {
        ?>
        <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
        echo $baseurl_short;
        ?>
pages/terms.php?k=<?php 
        echo $k;
        ?>
&url=<?php 
        echo urlencode("pages/collection_download.php?collection=" . $usercollection . "&k=" . $k);
        ?>
"><?php 
        echo $lang['action-download'];
        ?>
</a></li>
        <?php 
    }
    if ($count_result > 0 && $k == '' && checkperm('q')) {
        # Ability to request a whole collection (only if user has restricted access to any of these resources)
        $min_access = collection_min_access($result);
        if ($min_access != 0) {
            ?>
            <li><a onclick="return CentralSpaceLoad(this, true);" href="<?php 
            echo $baseurl_short;
            ?>
pages/collection_request.php?ref=<?php 
            echo urlencode($usercollection);
            ?>
"><?php 
            echo $lang['action-request'];
            ?>
</a></li>
            <?php 
        }
    }
    hook('collectiontoolmin');
    ?>
    </ul>
    <?php 
}
	elseif ($k!="")
		{
		# Anonymous access, slightly different display
		$tempcol=$cinfo;
		?>
	<div id="CollectionMinTitle" class="ExternalShare"><h2><?php echo i18n_get_collection_name($tempcol)?></h2></div>
	<div id="CollectionMinRightNav" class="ExternalShare">
		<?php if(!hook("replaceanoncollectiontools")){ ?>
		<?php if ((isset($zipcommand) || $collection_download) && $count_result>0) { ?>
		<li><a onclick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/terms.php?k=<?php echo urlencode($k) ?>&url=<?php echo urlencode("pages/collection_download.php?collection=" .  $usercollection . "&k=" . $k)?>"><?php echo $lang["action-download"]?></a></li>
		<?php } ?>
		<?php if ($feedback) {?><li><a onclick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/collection_feedback.php?collection=<?php echo urlencode($usercollection) ?>&k=<?php echo urlencode($k) ?>"><?php echo $lang["sendfeedback"]?></a></li><?php } ?>
		<?php if ($count_result>0)
			{ 
			# Ability to request a whole collection (only if user has restricted access to any of these resources)
			$min_access=collection_min_access($result);
			if ($min_access!=0)
				{
				?>
				<li><a onclick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/collection_request.php?ref=<?php echo urlencode($usercollection) ?>&k=<?php echo urlencode($k) ?>"><?php echo 	$lang["requestall"]?></a></li>
				<?php
				}
			}
		?>
	  <?php if (!$disable_collection_toggle) { ?>
		<li><a id="toggleThumbsLink" href="#" onClick="ToggleThumbs();return false;"><?php echo $lang["showthumbnails"]?></a></li>
	  <?php } ?>
	  <?php } # end hook("replaceanoncollectiontools") ?>
	</div>
	<?php 
		}
#Check if sharing allowed
if (!$allow_share) {
    $show_error = true;
    $error = $lang["error-permissiondenied"];
}
$user_select_internal = checkperm("noex");
#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;
        $error = $lang["notapprovedsharecollection"];
    }
}
# Get min access to this collection
foreach ($refArray as $colref) {
    $minaccess = collection_min_access(trim($colref));
}
if ($minaccess >= 1 && !$restricted_share) {
    $show_error = true;
    $error = $lang["restrictedsharecollection"];
}
if (isset($show_error)) {
    ?>
    <script type="text/javascript">
    alert('<?php 
    echo $error;
    ?>
');
        history.go(-1);
    </script><?php 
    exit;