Skip to content

Commit

Permalink
Add option (disabled_actions) to disable UI elements/actions (#1489638)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Aug 4, 2014
1 parent 04638fb commit d01f9fc
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 68 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================

- Add option (disabled_actions) to disable UI elements/actions (#1489638)
- Support password encryption using openssl extension (#1489989)
- Create/rename groups in UI dialogs (#1489951)
- Added 'contact_search_name' option to define autocompletion entry format
Expand Down
3 changes: 3 additions & 0 deletions config/defaults.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@
// don't allow these settings to be overriden by the user
$config['dont_override'] = array();

// List of disabled UI elements/actions
$config['disabled_actions'] = array();

// define which settings should be listed under the 'advanced' block
// which is hidden by default
$config['advanced_prefs'] = array();
Expand Down
8 changes: 8 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@
'message' => "Referer check failed"), true, true);
}
}

// check access to disabled actions
$disabled_actions = (array) $RCMAIL->config->get('disabled_actions');
if (in_array($RCMAIL->task . '.' . ($RCMAIL->action ?: 'index'), $disabled_actions)) {
rcube::raise_error(array(
'code' => 403, 'type' => 'php',
'message' => "Action disabled"), true, true);
}
}

// we're ready, user is authenticated and the request is safe
Expand Down
30 changes: 27 additions & 3 deletions program/include/rcmail_output_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,8 @@ protected function include_php($file)
*/
public function button($attrib)
{
static $s_button_count = 100;
static $s_button_count = 100;
static $disabled_actions = null;

// these commands can be called directly via url
$a_static_commands = array('compose', 'list', 'preferences', 'folders', 'identities');
Expand All @@ -1148,18 +1149,36 @@ public function button($attrib)
return '';
}


// try to find out the button type
if ($attrib['type']) {
$attrib['type'] = strtolower($attrib['type']);
if ($pos = strpos($attrib['type'], '-menuitem')) {
$attrib['type'] = substr($attrib['type'], 0, -9);
$menuitem = true;
}
}
else {
$attrib['type'] = ($attrib['image'] || $attrib['imagepas'] || $attrib['imageact']) ? 'image' : 'link';
}

$command = $attrib['command'];

if ($attrib['task'])
$command = $attrib['task'] . '.' . $command;
if ($attrib['task']) {
$element = $command = $attrib['task'] . '.' . $command;
}
else {
$element = ($this->env['task'] ? $this->env['task'] . '.' : '') . $command;
}

if ($disabled_actions === null) {
$disabled_actions = (array) $this->config->get('disabled_actions');
}

// remove buttons for disabled actions
if (in_array($element, $disabled_actions)) {
return '';
}

if (!$attrib['image']) {
$attrib['image'] = $attrib['imagepas'] ? $attrib['imagepas'] : $attrib['imageact'];
Expand Down Expand Up @@ -1292,6 +1311,11 @@ public function button($attrib)
$out = html::tag($attrib['wrapper'], null, $out);
}

if ($menuitem) {
$class = $attrib['menuitem-class'] ? ' class="' . $attrib['menuitem-class'] . '"' : '';
$out = '<li role="menuitem"' . $class . '>' . $out . '</li>';
}

return $out;
}

Expand Down
1 change: 1 addition & 0 deletions program/steps/mail/func.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,7 @@ function rcmail_message_import_form($attrib = array())
));

$content = html::tag('input', array('type' => 'hidden', 'name' => '_unlock', 'value' => ''))
. html::tag('input', array('type' => 'hidden', 'name' => '_framed', 'value' => '1'))
. html::div(null, $fileinput->show())
. html::div('hint', $RCMAIL->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))));

Expand Down
30 changes: 15 additions & 15 deletions skins/classic/includes/messagetoolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,39 @@

<div id="forwardmenu" class="popupmenu">
<ul>
<li role="menuitem"><roundcube:button command="forward-inline" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" /></li>
<li role="menuitem"><roundcube:button command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" /></li>
<roundcube:button type="link-menuitem" command="forward-inline" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" />
<roundcube:button type="link-menuitem" command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" />
<roundcube:container name="forwardmenu" id="forwardmenu" />
</ul>
</div>

<div id="replyallmenu" class="popupmenu">
<ul>
<li role="menuitem"><roundcube:button command="reply-all" label="replyall" prop="sub" classAct="replyalllink active" class="replyalllink" /></li>
<li role="menuitem"><roundcube:button command="reply-list" label="replylist" prop="sub" classAct="replylistlink active" class="replylistlink" /></li>
<roundcube:button type="link-menuitem" command="reply-all" label="replyall" prop="sub" classAct="replyalllink active" class="replyalllink" />
<roundcube:button type="link-menuitem" command="reply-list" label="replylist" prop="sub" classAct="replylistlink active" class="replylistlink" />
<roundcube:container name="replyallmenu" id="replyallmenu" />
</ul>
</div>

<div id="messagemenu" class="popupmenu">
<ul class="toolbarmenu">
<li role="menuitem"><roundcube:button class="printlink" command="print" label="printmessage" classAct="printlink active" /></li>
<li role="menuitem"><roundcube:button class="downloadlink" command="download" label="emlsave" classAct="downloadlink active" /></li>
<li role="menuitem"><roundcube:button class="editlink" command="edit" prop="new" label="editasnew" classAct="editlink active" /></li>
<li role="menuitem"><roundcube:button class="movelink" command="move" label="moveto" classAct="movelink active" innerclass="folder-selector-link" /></li>
<li role="menuitem"><roundcube:button class="copylink" command="copy" label="copyto" classAct="copylink active" innerclass="folder-selector-link" /></li>
<li role="menuitem" class="separator_below"><roundcube:button class="sourcelink" command="viewsource" label="viewsource" classAct="sourcelink active" /></li>
<li role="menuitem"><roundcube:button class="openlink" command="open" label="openinextwin" target="_blank" classAct="openlink active" /></li>
<roundcube:button type="link-menuitem" class="printlink" command="print" label="printmessage" classAct="printlink active" />
<roundcube:button type="link-menuitem" class="downloadlink" command="download" label="emlsave" classAct="downloadlink active" />
<roundcube:button type="link-menuitem" class="editlink" command="edit" prop="new" label="editasnew" classAct="editlink active" />
<roundcube:button type="link-menuitem" class="movelink" command="move" label="moveto" classAct="movelink active" innerclass="folder-selector-link" />
<roundcube:button type="link-menuitem" class="copylink" command="copy" label="copyto" classAct="copylink active" innerclass="folder-selector-link" />
<roundcube:button type="link-menuitem" class="sourcelink" command="viewsource" label="viewsource" classAct="sourcelink active" menuitem-class="separator_below" />
<roundcube:button type="link-menuitem" class="openlink" command="open" label="openinextwin" target="_blank" classAct="openlink active" />
<roundcube:container name="messagemenu" id="messagemenu" />
</ul>
</div>

<div id="markmessagemenu" class="popupmenu">
<ul class="toolbarmenu">
<li><roundcube:button command="mark" prop="read" label="markread" classAct="readlink active" class="readlink" /></li>
<li><roundcube:button command="mark" prop="unread" label="markunread" classAct="unreadlink active" class="unreadlink" /></li>
<li><roundcube:button command="mark" prop="flagged" label="markflagged" classAct="flaggedlink active" class="flaggedlink" /></li>
<li><roundcube:button command="mark" prop="unflagged" label="markunflagged" classAct="unflaggedlink active" class="unflaggedlink" /></li>
<roundcube:button type="link-menuitem" command="mark" prop="read" label="markread" classAct="readlink active" class="readlink" />
<roundcube:button type="link-menuitem" command="mark" prop="unread" label="markunread" classAct="unreadlink active" class="unreadlink" />
<roundcube:button type="link-menuitem" command="mark" prop="flagged" label="markflagged" classAct="flaggedlink active" class="flaggedlink" />
<roundcube:button type="link-menuitem" command="mark" prop="unflagged" label="markunflagged" classAct="unflaggedlink active" class="unflaggedlink" />
<roundcube:container name="markmenu" id="markmessagemenu" />
</ul>
</div>
4 changes: 2 additions & 2 deletions skins/classic/templates/compose.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@
<li><label class="comment"><roundcube:label name="insertresponse" /></label></li>
<roundcube:object name="responseslist" id="responseslist" tagname="ul" itemclass="active" />
<li><label class="comment"><roundcube:label name="manageresponses" /></label></li>
<li><roundcube:button command="save-response" type="link" label="newresponse" classAct="active" unselectable="on" /></li>
<li><roundcube:button command="responses" type="link" label="editresponses" classAct="active" /></li>
<roundcube:button command="save-response" type="link-menuitem" label="newresponse" classAct="active" unselectable="on" />
<roundcube:button command="responses" type="link-menuitem" label="editresponses" classAct="active" />
</ul>
</div>

Expand Down
4 changes: 2 additions & 2 deletions skins/classic/templates/messagepreview.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

<div id="attachmentmenu" class="popupmenu">
<ul class="toolbarmenu">
<li><roundcube:button command="open-attachment" id="attachmenuopen" type="link" label="open" class="openlink" classAct="openlink active" innerclass="openlink" /></li>
<li><roundcube:button command="download-attachment" id="attachmenudownload" type="link" label="download" class="downloadlink" classAct="downloadlink active" innerclass="downloadlink" /></li>
<roundcube:button command="open-attachment" id="attachmenuopen" type="link-menuitem" label="open" class="openlink" classAct="openlink active" innerclass="openlink" />
<roundcube:button command="download-attachment" id="attachmenudownload" type="link-menuitem" label="download" class="downloadlink" classAct="downloadlink active" innerclass="downloadlink" />
<roundcube:container name="attachmentmenu" id="attachmentmenu" />
</ul>
</div>
Expand Down
30 changes: 15 additions & 15 deletions skins/larry/includes/mailtoolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@
<div id="forwardmenu" class="popupmenu" aria-hidden="true">
<h3 id="aria-label-forwardmenu" class="voice"><roundcube:label name="arialabelforwardingoptions" /></h3>
<ul id="forwardmenu-menu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-forwardmenu">
<li role="menuitem"><roundcube:button command="forward-inline" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" /></li>
<li role="menuitem"><roundcube:button command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" /></li>
<roundcube:button type="link-menuitem" command="forward-inline" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" />
<roundcube:button type="link-menuitem" command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" />
<roundcube:container name="forwardmenu" id="forwardmenu" />
</ul>
</div>

<div id="replyallmenu" class="popupmenu" aria-hidden="true">
<h3 id="aria-label-replyallmenu" class="voice"><roundcube:label name="arialabelreplyalloptions" /></h3>
<ul id="replyallmenu-menu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-replyallmenu">
<li role="menuitem"><roundcube:button command="reply-all" label="replyall" prop="sub" class="replyalllink" classAct="replyalllink active" /></li>
<li role="menuitem"><roundcube:button command="reply-list" label="replylist" prop="sub" class="replylistlink" classAct="replylistlink active" /></li>
<roundcube:button type="link-menuitem" command="reply-all" label="replyall" prop="sub" class="replyalllink" classAct="replyalllink active" />
<roundcube:button type="link-menuitem" command="reply-list" label="replylist" prop="sub" class="replylistlink" classAct="replylistlink active" />
<roundcube:container name="replyallmenu" id="replyallmenu" />
</ul>
</div>

<div id="messagemenu" class="popupmenu" aria-hidden="true">
<h3 id="aria-label-messagemenu" class="voice"><roundcube:label name="arialabelmoremessageactions" /></h3>
<ul id="messagemenu-menu" class="toolbarmenu iconized" role="menu" aria-labelledby="aria-label-messagemenu">
<li role="menuitem"><roundcube:button command="print" label="printmessage" class="icon" classAct="icon active" innerclass="icon print" /></li>
<li role="menuitem"><roundcube:button command="download" label="emlsave" class="icon" classAct="icon active" innerclass="icon download" /></li>
<li role="menuitem"><roundcube:button command="edit" prop="new" label="editasnew" class="icon" classAct="icon active" innerclass="icon edit" /></li>
<li role="menuitem"><roundcube:button command="viewsource" label="viewsource" class="icon" classAct="icon active" innerclass="icon viewsource" /></li>
<li role="menuitem"><roundcube:button command="move" label="moveto" class="icon" classAct="icon active" innerclass="icon move folder-selector-link" /></li>
<li role="menuitem"><roundcube:button command="copy" label="copyto" class="icon" classAct="icon active" innerclass="icon copy folder-selector-link" /></li>
<li role="menuitem"><roundcube:button command="open" label="openinextwin" target="_blank" class="icon" classAct="icon active" innerclass="icon extwin" /></li>
<roundcube:button type="link-menuitem" command="print" label="printmessage" class="icon" classAct="icon active" innerclass="icon print" />
<roundcube:button type="link-menuitem" command="download" label="emlsave" class="icon" classAct="icon active" innerclass="icon download" />
<roundcube:button type="link-menuitem" command="edit" prop="new" label="editasnew" class="icon" classAct="icon active" innerclass="icon edit" />
<roundcube:button type="link-menuitem" command="viewsource" label="viewsource" class="icon" classAct="icon active" innerclass="icon viewsource" />
<roundcube:button type="link-menuitem" command="move" label="moveto" class="icon" classAct="icon active" innerclass="icon move folder-selector-link" />
<roundcube:button type="link-menuitem" command="copy" label="copyto" class="icon" classAct="icon active" innerclass="icon copy folder-selector-link" />
<roundcube:button type="link-menuitem" command="open" label="openinextwin" target="_blank" class="icon" classAct="icon active" innerclass="icon extwin" />
<roundcube:container name="messagemenu" id="messagemenu" />
</ul>
</div>

<div id="markmessagemenu" class="popupmenu" aria-hidden="true">
<h3 id="aria-label-markmessagemenu" class="voice"><roundcube:label name="arialabelmarkmessagesas" /></h3>
<ul id="markmessagemenu-menu" class="toolbarmenu iconized" role="menu" aria-labelledby="aria-label-markmessagemenu">
<li role="menuitem"><roundcube:button command="mark" prop="read" label="markread" classAct="icon active" class="icon" innerclass="icon read" /></li>
<li role="menuitem"><roundcube:button command="mark" prop="unread" label="markunread" classAct="icon active" class="icon" innerclass="icon unread" /></li>
<li role="menuitem"><roundcube:button command="mark" prop="flagged" label="markflagged" classAct="icon active" class="icon" innerclass="icon flagged" /></li>
<li role="menuitem"><roundcube:button command="mark" prop="unflagged" label="markunflagged" classAct="icon active" class="icon" innerclass="icon unflagged" /></li>
<roundcube:button type="link-menuitem" command="mark" prop="read" label="markread" classAct="icon active" class="icon" innerclass="icon read" />
<roundcube:button type="link-menuitem" command="mark" prop="unread" label="markunread" classAct="icon active" class="icon" innerclass="icon unread" />
<roundcube:button type="link-menuitem" command="mark" prop="flagged" label="markflagged" classAct="icon active" class="icon" innerclass="icon flagged" />
<roundcube:button type="link-menuitem" command="mark" prop="unflagged" label="markunflagged" classAct="icon active" class="icon" innerclass="icon unflagged" />
<roundcube:container name="markmenu" id="markmessagemenu" />
</ul>
</div>
16 changes: 8 additions & 8 deletions skins/larry/templates/addressbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ <h2 id="aria-label-toolbar" class="voice"><roundcube:label name="arialabeltoolba
<div id="exportmenu" class="popupmenu" aria-hidden="true">
<h3 id="aria-label-exportmenu" class="voice"><roundcube:label name="arialabelcontactexportoptions" /></h3>
<ul id="exportmenu-menu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-exportmenu">
<li role="menuitem"><roundcube:button command="export" label="exportall" prop="sub" class="exportalllink" classAct="exportalllink active" /></li>
<li role="menuitem"><roundcube:button command="export-selected" label="exportsel" prop="sub" class="exportsellink" classAct="exportsellink active" /></li>
<roundcube:button type="link-menuitem" command="export" label="exportall" prop="sub" class="exportalllink" classAct="exportalllink active" />
<roundcube:button type="link-menuitem" command="export-selected" label="exportsel" prop="sub" class="exportsellink" classAct="exportsellink active" />
</ul>
</div>

Expand Down Expand Up @@ -76,10 +76,10 @@ <h3 class="boxtitle voice"><roundcube:label name="savedsearches" /></h3>
<div id="groupoptions" class="popupmenu" aria-hidden="true">
<h3 id="aria-label-groupoptions" class="voice"><roundcube:label name="arialabelabookgroupoptions" /></h3>
<ul id="groupoptionsmenu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-groupoptions">
<li role="menuitem"><roundcube:button command="group-rename" label="grouprename" classAct="active" /></li>
<li role="menuitem"><roundcube:button command="group-delete" label="groupdelete" classAct="active" /></li>
<li role="menuitem"><roundcube:button command="search-create" label="searchsave" classAct="active" /></li>
<li role="menuitem"><roundcube:button command="search-delete" label="searchdelete" classAct="active" /></li>
<roundcube:button type="link-menuitem" command="group-rename" label="grouprename" classAct="active" />
<roundcube:button type="link-menuitem" command="group-delete" label="groupdelete" classAct="active" />
<roundcube:button type="link-menuitem" command="search-create" label="searchsave" classAct="active" />
<roundcube:button type="link-menuitem" command="search-delete" label="searchdelete" classAct="active" />
<roundcube:container name="groupoptions" id="groupoptionsmenu" />
</ul>
</div>
Expand Down Expand Up @@ -132,8 +132,8 @@ <h3><roundcube:label name="helplistnavigation" /></h3>

<div id="dragcontactmenu" class="popupmenu" aria-hidden="true">
<ul class="toolbarmenu" role="menu">
<li role="menuitem"><roundcube:button command="move" onclick="return rcmail.drag_menu_action('move')" label="move" classAct="active" /></li>
<li role="menuitem"><roundcube:button command="copy" onclick="return rcmail.drag_menu_action('copy')" label="copy" classAct="active" /></li>
<roundcube:button type="link-menuitem" command="move" onclick="return rcmail.drag_menu_action('move')" label="move" classAct="active" />
<roundcube:button type="link-menuitem" command="copy" onclick="return rcmail.drag_menu_action('copy')" label="copy" classAct="active" />
</ul>
</div>

Expand Down
Loading

0 comments on commit d01f9fc

Please sign in to comment.