Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions packages/ezwt_extension/ezextension/ezwt/design/standard/templates/parts/website_toolbar.tpl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
{def $current_node = fetch( 'content', 'node', hash( 'node_id', $current_node_id ) )
$content_object = $current_node.object
$can_edit_languages = $content_object.can_edit_languages
$content_object = $current_node.object }

{if fetch( 'websitetoolbar', 'can_use', hash( 'class_id', $content_object.content_class.id ) )}

{def $can_edit_languages = $content_object.can_edit_languages
$can_manage_location = fetch( 'content', 'access', hash( 'access', 'manage_locations', 'contentobject', $current_node ) )
$can_create_languages = $content_object.can_create_languages
$is_container = $content_object.content_class.is_container
$odf_display_classes = ezini( 'WebsiteToolbarSettings', 'ODFDisplayClasses', 'websitetoolbar.ini' )
$odf_hide_container_classes = ezini( 'WebsiteToolbarSettings', 'HideODFContainerClasses', 'websitetoolbar.ini' )
$website_toolbar_access = fetch( 'user', 'has_access_to', hash( 'module', 'websitetoolbar', 'function', 'use' ) )
$odf_import_access = fetch( 'user', 'has_access_to', hash( 'module', 'ezodf', 'function', 'import' ) )
$odf_export_access = fetch( 'user', 'has_access_to', hash( 'module', 'ezodf', 'function', 'export' ) )
$content_object_language_code = ''
$policies = fetch( 'user', 'user_role', hash( 'user_id', $current_user.contentobject_id ) )
$available_for_current_class = false()
$custom_templates = ezini( 'CustomTemplateSettings', 'CustomTemplateList', 'websitetoolbar.ini' )
$include_in_view = ezini( 'CustomTemplateSettings', 'IncludeInView', 'websitetoolbar.ini' )
$node_hint = ': '|append( $current_node.name|wash(), ' [', $content_object.content_class.name|wash(), ']' ) }

{foreach $policies as $policy}
{if and( eq( $policy.moduleName, 'websitetoolbar' ),
eq( $policy.functionName, 'use' ),
is_array( $policy.limitation ) )}
{if $policy.limitation[0].values_as_array|contains( $content_object.content_class.id )}
{set $available_for_current_class = true()}
{/if}
{elseif or( and( eq( $policy.moduleName, '*' ),
eq( $policy.functionName, '*' ),
eq( $policy.limitation, '*' ) ),
and( eq( $policy.moduleName, 'websitetoolbar' ),
eq( $policy.functionName, '*' ),
eq( $policy.limitation, '*' ) ),
and( eq( $policy.moduleName, 'websitetoolbar' ),
eq( $policy.functionName, 'use' ),
eq( $policy.limitation, '*' ) ) )}
{set $available_for_current_class = true()}
{/if}
{/foreach}

{if and( $website_toolbar_access, $available_for_current_class )}

<!-- eZ website toolbar: START -->

<div id="ezwt">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{if fetch( 'websitetoolbar', 'can_use', hash( 'class_id', $object.content_class.id ) )}

{def $custom_templates = ezini( 'CustomTemplateSettings', 'CustomTemplateList', 'websitetoolbar.ini' )
$include_in_view = ezini( 'CustomTemplateSettings', 'IncludeInView', 'websitetoolbar.ini' )}

Expand Down Expand Up @@ -70,4 +72,6 @@

{include uri='design:parts/websitetoolbar/floating_toolbar.tpl'}

<!-- eZ website toolbar: END -->
<!-- eZ website toolbar: END -->

{/if}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{if fetch( 'websitetoolbar', 'can_use', hash( 'class_id', $object.content_class.id ) )}

{def $custom_templates = ezini( 'CustomTemplateSettings', 'CustomTemplateList', 'websitetoolbar.ini' )
$include_in_view = ezini( 'CustomTemplateSettings', 'IncludeInView', 'websitetoolbar.ini' )}

Expand Down Expand Up @@ -65,4 +67,6 @@

{include uri='design:parts/websitetoolbar/floating_toolbar.tpl'}

<!-- eZ website toolbar: END -->
<!-- eZ website toolbar: END -->

{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* fetch function implementation file for eZ Websitetoolbar
*
* @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
* @license http://ez.no/licenses/gnu_gpl GNU GPLv2
*
*/

class ezwtFunctionCollection
{
/**
* Fetch if current user can use website toolbar
* Used by fetch( 'websitetoolbar', 'can_use', hash( 'class_id', $class_id ) ) template function
*
* @param int $classID ID of content class
* @return bool
*/
function canUse( $classID )
{
$currentUser = eZUser::currentUser();
$userHasAccess = $currentUser->hasAccessTo( 'websitetoolbar', 'use' );

if ( $userHasAccess['accessWord'] == 'no' )
return array( 'result' => false );

$contentClass = eZContentClass::fetch( (int) $classID );
if ( !$contentClass instanceof eZContentClass )
return array( 'result' => false );

$availableForCurrentClass = false;
$userFunctions = new eZUserFunctionCollection();
$policies = $userFunctions->fetchUserRole( $currentUser->attribute( 'contentobject_id' ) );

foreach ( $policies['result'] as $policy )
{
if ( $policy['moduleName'] == 'websitetoolbar' && $policy['functionName'] == 'use' && is_array( $policy['limitation'] ) )
{
if ( in_array( (int) $classID, $policy['limitation'][0]->allValues() ) )
$availableForCurrentClass = true;
}
else if ( ( $policy['moduleName'] == '*' && $policy['functionName'] == '*' && $policy['limitation'] == '*' ) ||
( $policy['moduleName'] == 'websitetoolbar' && $policy['functionName'] == '*' && $policy['limitation'] == '*' ) ||
( $policy['moduleName'] == 'websitetoolbar' && $policy['functionName'] == 'use' && $policy['limitation'] == '*' ) )
{
$availableForCurrentClass = true;
}
}

return array( 'result' => $availableForCurrentClass );
}
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* fetch function definition file for eZ Websitetoolbar
*
* @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
* @license http://ez.no/licenses/gnu_gpl GNU GPLv2
*
*/

$FunctionList = array();

$FunctionList['can_use'] = array( 'name' => 'can_use',
'call_method' => array( 'class' => 'ezwtFunctionCollection', 'method' => 'canUse' ),
'parameter_type' => 'standard',
'parameters' => array( array( 'name' => 'class_id',
'type' => 'integer',
'required' => true ) ) );

?>