diff --git a/panels.install b/panels.install index 1d82544..b09cc1c 100644 --- a/panels.install +++ b/panels.install @@ -492,3 +492,24 @@ function panels_update_7303() { db_create_table($table_name, $schema[$table_name]); } } + +/** + * Renames style permissions. + */ +function panels_update_7304() { + $permissions = array( + 'change pane settings in place editing', + 'administer pane styles in place editing', + 'administer region styles in place editing', + 'add panes in place editing', + 'remove panes in place editing', + ); + foreach (array_keys(user_roles(TRUE, 'use panels in place editing')) as $rid) { + user_role_grant_permissions($rid, $permissions); + } + $msg = array( + t('Please note, the permissions for the Panels In-Place Editor have been made more granular, please review them ASAP.'), + l(t('User Permissions'), 'admin/people/permissions'), + ); + return implode("\n", $msg); +} diff --git a/panels.module b/panels.module index 16917b5..82cfc6c 100644 --- a/panels.module +++ b/panels.module @@ -294,14 +294,6 @@ function panels_permission() { 'title' => t("Configure access settings on Panel panes"), 'description' => t("Access rules (often also called visibility rules) can be configured on a per-pane basis. This permission allows users to configure those settings."), ), - 'use panels in place editing' => array( - 'title' => t("Use the Panels In-Place Editor"), - 'description' => t("Allows a user to utilize Panels' In-Place Editor."), - ), - 'change layouts in place editing' => array( - 'title' => t("Change layouts with the Panels In-Place Editor"), - 'description' => t("Allows a user to change layouts with the IPE."), - ), 'administer advanced pane settings' => array( 'title' => t("Configure advanced settings on Panel panes"), 'description' => t(""), @@ -322,10 +314,6 @@ function panels_permission() { 'title' => t('Use panel locks'), 'description' => t('Allows a user to lock and unlock panes in a panel display.'), ), - 'use ipe with page manager' => array( - 'title' => t("Use the Panels In-Place Editor with Page Manager"), - 'description' => t('Allows users with access to the In-Place editor to administer page manager pages. This permission is only needed for users without "use page manager" access.'), - ), ); } diff --git a/panels_ipe/panels_ipe.module b/panels_ipe/panels_ipe.module index a11fc3a..026ebd7 100644 --- a/panels_ipe/panels_ipe.module +++ b/panels_ipe/panels_ipe.module @@ -83,20 +83,22 @@ function template_preprocess_panels_ipe_pane_wrapper(&$vars) { $vars['links'] = array(); if (ctools_content_editable($content_type, $subtype, $pane->configuration)) { - $vars['links']['edit'] = array( - 'title' => isset($content_type['edit text']) ? '' . $content_type['edit text'] . '' : '' . t('Settings') . '', - 'href' => $renderer->get_url('edit-pane', $pane->pid), - 'html' => TRUE, - 'attributes' => array( - 'class' => array('ctools-use-modal', 'panels-ipe-hide-bar'), - 'title' => isset($content_type['edit text']) ? $content_type['edit text'] : t('Settings'), - // 'id' => "pane-edit-panel-pane-$pane->pid", - ), - ); + if (user_access('change pane settings in place editing')) { + $vars['links']['edit'] = array( + 'title' => isset($content_type['edit text']) ? '' . $content_type['edit text'] . '' : '' . t('Settings') . '', + 'href' => $renderer->get_url('edit-pane', $pane->pid), + 'html' => TRUE, + 'attributes' => array( + 'class' => array('ctools-use-modal', 'panels-ipe-hide-bar'), + 'title' => isset($content_type['edit text']) ? $content_type['edit text'] : t('Settings'), + // 'id' => "pane-edit-panel-pane-$pane->pid", + ), + ); + } } // Add option to configure style in IPE - if (user_access('administer panels styles')) { + if (user_access('administer panels styles') || user_access('administer pane styles in place editing')) { $vars['links']['style'] = array( 'title' => '' . t('Style') . '', 'href' => $renderer->get_url('style-type', 'pane', $pane->pid), @@ -110,16 +112,18 @@ function template_preprocess_panels_ipe_pane_wrapper(&$vars) { // Deleting is managed entirely in the js; this is just an attachment point // for it - $vars['links']['delete'] = array( - 'title' => '' . t('Delete') . '', - 'href' => '#', - 'html' => TRUE, - 'attributes' => array( - 'class' => 'pane-delete', - 'id' => "pane-delete-panel-pane-$pane->pid", - 'title' => t('Delete'), - ), - ); + if (user_access('remove panes in place editing')) { + $vars['links']['delete'] = array( + 'title' => '' . t('Delete') . '', + 'href' => '#', + 'html' => TRUE, + 'attributes' => array( + 'class' => 'pane-delete', + 'id' => "pane-delete-panel-pane-$pane->pid", + 'title' => t('Delete'), + ), + ); + } $context = array( 'pane' => $pane, @@ -164,11 +168,11 @@ function template_preprocess_panels_ipe_add_pane_button(&$vars) { $region_id = $vars['region_id']; $display = $vars['display']; $renderer = $vars['renderer']; - $vars['links'] = ''; + $vars['region_links'] = ''; // Add option to configure style in IPE - if (user_access('administer panels styles')) { - $vars['links']['style'] = array( + if (user_access('administer panels styles') || user_access('administer region styles in place editing')) { + $vars['region_links']['style'] = array( 'title' => '' . t('Region style') . '', 'href' => $renderer->get_url('style-type', 'region', $region_id), 'html' => TRUE, @@ -180,7 +184,7 @@ function template_preprocess_panels_ipe_add_pane_button(&$vars) { } // Add option to add items in the IPE - $vars['links']['add-pane'] = array( + $vars['region_links']['add-pane'] = array( 'title' => '' . t('Add new pane') . '', 'href' => $renderer->get_url('select-content', $region_id), 'attributes' => array( @@ -195,8 +199,7 @@ function template_preprocess_panels_ipe_add_pane_button(&$vars) { 'display' => $display, 'renderer' => $renderer, ); - drupal_alter('panels_ipe_region_links', $vars['links'], $context); - + drupal_alter('panels_ipe_region_links', $vars['region_links'], $context); } function theme_panels_ipe_add_pane_button($vars) { @@ -268,3 +271,44 @@ function theme_panels_ipe_toolbar($vars) { return $output; } + + +/** + * Implements hook_permission(). + */ +function panels_ipe_permission() { + return array( + 'use panels in place editing' => array( + 'title' => t("Use the Panels In-Place Editor (IPE)"), + 'description' => t("Allows a user to utilize the Panels' In-Place Editor."), + ), + 'change layouts in place editing' => array( + 'title' => t("Change layouts with the Panels In-Place Editor"), + 'description' => t("Allows a user to change layouts with the IPE."), + ), + 'change pane settings in place editing' => array( + 'title' => t("Change pane settings with the Panels In-Place Editor"), + 'description' => t("Allows a user to change pane settings with the IPE."), + ), + 'administer pane styles in place editing' => array( + 'title' => t("Administer pane styles with the Panels In-Place Editor"), + 'description' => t("Allows a user to change the Panels' pane styles with the IPE."), + ), + 'administer region styles in place editing' => array( + 'title' => t("Administer region styles with the Panels In-Place Editor"), + 'description' => t("Allows a user to change the Panels' region styles with the IPE."), + ), + 'add panes in place editing' => array( + 'title' => t("Add panes with the Panels In-Place Editor"), + 'description' => t("Allows a user to add panes with the IPE."), + ), + 'remove panes in place editing' => array( + 'title' => t("Remove panes with the Panels In-Place Editor"), + 'description' => t("Allows a user to remove panes with the IPE."), + ), + 'use ipe with page manager' => array( + 'title' => t("Use the Panels In-Place Editor with Page Manager"), + 'description' => t('Allows users with access to the In-Place Editor to administer page manager pages. This permission is only needed for users without the "use page manager" permission.'), + ), + ); +} diff --git a/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php b/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php index c959a6d..036f666 100644 --- a/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php +++ b/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php @@ -177,8 +177,13 @@ class panels_renderer_ipe extends panels_renderer_editor { // Generate this region's 'empty' placeholder pane from the IPE plugin. $empty_ph = theme('panels_ipe_placeholder_pane', array('region_id' => $region_id, 'region_title' => $this->plugins['layout']['regions'][$region_id])); + $add_button = ''; + if (user_access('add panes in place editing')) { + $add_button = theme('panels_ipe_add_pane_button', array('region_id' => $region_id, 'display' => $this->display, 'renderer' => $this)); + } + // Wrap the placeholder in some guaranteed markup. - $control = '
' . $empty_ph . theme('panels_ipe_add_pane_button', array('region_id' => $region_id, 'display' => $this->display, 'renderer' => $this)) . "
"; + $control = '
' . $empty_ph . $add_button . "
"; $output = parent::render_region($region_id, $panes); $output = theme('panels_ipe_region_wrapper', array('output' => $output, 'region_id' => $region_id, 'display' => $this->display, 'controls' => $control, 'renderer' => $this));