Add action to remove a calendar/tasks/notes folders from the list which results in unsubscribing it (#3378)
This commit is contained in:
parent
e5c97c0dd2
commit
624f3b1695
18 changed files with 106 additions and 27 deletions
|
@ -770,8 +770,8 @@ class calendar extends rcube_plugin
|
|||
$success = $this->driver->edit_calendar($cal);
|
||||
$reload = true;
|
||||
break;
|
||||
case "remove":
|
||||
if ($success = $this->driver->remove_calendar($cal))
|
||||
case "delete":
|
||||
if ($success = $this->driver->delete_calendar($cal))
|
||||
$this->rc->output->command('plugin.destroy_source', array('id' => $cal['id']));
|
||||
break;
|
||||
case "subscribe":
|
||||
|
|
|
@ -2775,9 +2775,16 @@ function rcube_calendar_ui(settings)
|
|||
};
|
||||
|
||||
this.calendar_remove = function(calendar)
|
||||
{
|
||||
this.calendar_destroy_source(calendar.id);
|
||||
rcmail.http_post('calendar', { action:'subscribe', c:{ id:calendar.id, active:0, permanent:0, recursive:1 } });
|
||||
return true;
|
||||
};
|
||||
|
||||
this.calendar_delete = function(calendar)
|
||||
{
|
||||
if (confirm(rcmail.gettext(calendar.children ? 'deletecalendarconfirmrecursive' : 'deletecalendarconfirm', 'calendar'))) {
|
||||
rcmail.http_post('calendar', { action:'remove', c:{ id:calendar.id } });
|
||||
rcmail.http_post('calendar', { action:'delete', c:{ id:calendar.id } });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -2803,8 +2810,8 @@ function rcube_calendar_ui(settings)
|
|||
// delete all calendars in the list
|
||||
for (var i=0; i < delete_ids.length; i++) {
|
||||
id = delete_ids[i];
|
||||
calendars_list.remove(id);
|
||||
fc.fullCalendar('removeEventSource', this.calendars[id]);
|
||||
$('#rcmlical' + id).remove();
|
||||
$('#edit-calendar option[value="'+id+'"]').remove();
|
||||
delete this.calendars[id];
|
||||
}
|
||||
|
@ -3349,7 +3356,8 @@ function rcube_calendar_ui(settings)
|
|||
if (node && node.id && me.calendars[node.id]) {
|
||||
me.select_calendar(node.id, true);
|
||||
rcmail.enable_command('calendar-edit', 'calendar-showurl', true);
|
||||
rcmail.enable_command('calendar-remove', !me.calendars[node.id].readonly);
|
||||
rcmail.enable_command('calendar-delete', !me.calendars[node.id].readonly);
|
||||
rcmail.enable_command('calendar-remove', me.calendars[node.id] && me.calendars[node.id].removable);
|
||||
}
|
||||
});
|
||||
calendars_list.addEventListener('insert-item', function(p) {
|
||||
|
@ -3903,6 +3911,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
|
|||
rcmail.register_command('calendar-create', function(){ cal.calendar_edit_dialog(null); }, true);
|
||||
rcmail.register_command('calendar-edit', function(){ cal.calendar_edit_dialog(cal.calendars[cal.selected_calendar]); }, false);
|
||||
rcmail.register_command('calendar-remove', function(){ cal.calendar_remove(cal.calendars[cal.selected_calendar]); }, false);
|
||||
rcmail.register_command('calendar-delete', function(){ cal.calendar_delete(cal.calendars[cal.selected_calendar]); }, false);
|
||||
rcmail.register_command('events-import', function(){ cal.import_events(cal.calendars[cal.selected_calendar]); }, true);
|
||||
rcmail.register_command('calendar-showurl', function(){ cal.showurl(cal.calendars[cal.selected_calendar]); }, false);
|
||||
rcmail.register_command('event-download', function(){ cal.event_download(cal.selected_event); }, true);
|
||||
|
|
|
@ -164,7 +164,7 @@ abstract class calendar_driver
|
|||
* id: Calendar Identifier
|
||||
* @return boolean True on success, Fales on failure
|
||||
*/
|
||||
abstract function remove_calendar($prop);
|
||||
abstract function delete_calendar($prop);
|
||||
|
||||
/**
|
||||
* Search for shared or otherwise not listed calendars the user has access
|
||||
|
|
|
@ -229,9 +229,9 @@ class database_driver extends calendar_driver
|
|||
/**
|
||||
* Delete the given calendar with all its contents
|
||||
*
|
||||
* @see calendar_driver::remove_calendar()
|
||||
* @see calendar_driver::delete_calendar()
|
||||
*/
|
||||
public function remove_calendar($prop)
|
||||
public function delete_calendar($prop)
|
||||
{
|
||||
if (!$this->calendars[$prop['id']])
|
||||
return false;
|
||||
|
|
|
@ -177,6 +177,7 @@ class kolab_driver extends calendar_driver
|
|||
'readonly' => true,
|
||||
'group' => 'other',
|
||||
'class' => 'user',
|
||||
'removable' => true,
|
||||
);
|
||||
}
|
||||
else if ($cal->virtual) {
|
||||
|
@ -209,6 +210,7 @@ class kolab_driver extends calendar_driver
|
|||
'children' => true, // TODO: determine if that folder indeed has child folders
|
||||
'parent' => $parent_id,
|
||||
'caldavurl' => $cal->get_caldav_url(),
|
||||
'removable' => true,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -418,6 +420,16 @@ class kolab_driver extends calendar_driver
|
|||
$ret |= $cal->storage->subscribe(intval($prop['permanent']));
|
||||
if (isset($prop['active']))
|
||||
$ret |= $cal->storage->activate(intval($prop['active']));
|
||||
|
||||
// apply to child folders, too
|
||||
if ($prop['recursive']) {
|
||||
foreach ((array)kolab_storage::list_folders($cal->storage->name, '*', 'event') as $subfolder) {
|
||||
if (isset($prop['permanent']))
|
||||
($prop['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder));
|
||||
if (isset($prop['active']))
|
||||
($prop['active'] ? kolab_storage::folder_activate($subfolder) : kolab_storage::folder_deactivate($subfolder));
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
else {
|
||||
|
@ -435,9 +447,9 @@ class kolab_driver extends calendar_driver
|
|||
/**
|
||||
* Delete the given calendar with all its contents
|
||||
*
|
||||
* @see calendar_driver::remove_calendar()
|
||||
* @see calendar_driver::delete_calendar()
|
||||
*/
|
||||
public function remove_calendar($prop)
|
||||
public function delete_calendar($prop)
|
||||
{
|
||||
if ($prop['id'] && ($cal = $this->get_calendar($prop['id']))) {
|
||||
$folder = $cal->get_realname();
|
||||
|
|
|
@ -49,7 +49,10 @@
|
|||
<div id="calendaroptionsmenu" class="popupmenu">
|
||||
<ul>
|
||||
<li><roundcube:button command="calendar-edit" label="calendar.edit" classAct="active" /></li>
|
||||
<li><roundcube:button command="calendar-delete" label="delete" classAct="active" /></li>
|
||||
<roundcube:if condition="env:calendar_driver == 'kolab'" />
|
||||
<li><roundcube:button command="calendar-remove" label="calendar.remove" classAct="active" /></li>
|
||||
<roundcube:endif />
|
||||
<li><roundcube:button command="calendar-showurl" label="calendar.showurl" classAct="active" /></li>
|
||||
<roundcube:if condition="env:calendar_driver == 'kolab'" />
|
||||
<li class="separator_above"><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
|
||||
|
|
|
@ -69,7 +69,10 @@
|
|||
<h3 id="aria-label-calendaroptions" class="voice"><roundcube:label name="calendar.calendaractions" /></h3>
|
||||
<ul id="calendaroptionsmenu-menu" class="toolbarmenu" role="menu" aria-labelledby="aria-label-calendaroptions">
|
||||
<li role="menuitem"><roundcube:button command="calendar-edit" label="calendar.edit" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="calendar-delete" label="delete" classAct="active" /></li>
|
||||
<roundcube:if condition="env:calendar_driver == 'kolab'" />
|
||||
<li role="menuitem"><roundcube:button command="calendar-remove" label="calendar.remove" classAct="active" /></li>
|
||||
<roundcube:endif />
|
||||
<li role="menuitem"><roundcube:button command="calendar-showurl" label="calendar.showurl" classAct="active" /></li>
|
||||
<roundcube:if condition="env:calendar_driver == 'kolab'" />
|
||||
<li role="menuitem"><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
|
||||
|
|
|
@ -855,6 +855,16 @@ class kolab_notes extends rcube_plugin
|
|||
$success |= $folder->subscribe(intval($list['permanent']));
|
||||
if (isset($list['active']))
|
||||
$success |= $folder->activate(intval($list['active']));
|
||||
|
||||
// apply to child folders, too
|
||||
if ($list['recursive']) {
|
||||
foreach ((array)kolab_storage::list_folders($folder->name, '*', 'node') as $subfolder) {
|
||||
if (isset($list['permanent']))
|
||||
($list['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder));
|
||||
if (isset($list['active']))
|
||||
($list['active'] ? kolab_storage::folder_activate($subfolder) : kolab_storage::folder_deactivate($subfolder));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ $labels['findnotebooks'] = 'Find notebooks...';
|
|||
$labels['listsearchresults'] = 'Additional notebooks';
|
||||
$labels['nrnotebooksfound'] = '$nr notebooks found';
|
||||
$labels['nonotebooksfound'] = 'No notebooks found';
|
||||
$labels['removelist'] = 'Remove';
|
||||
|
||||
$labels['savingdata'] = 'Saving data...';
|
||||
$labels['recordnotfound'] = 'Record not found';
|
||||
|
|
|
@ -59,6 +59,7 @@ function rcube_kolab_notes_ui(settings)
|
|||
}, false);
|
||||
rcmail.register_command('list-create', function(){ list_edit_dialog(null); }, true);
|
||||
rcmail.register_command('list-edit', function(){ list_edit_dialog(me.selected_list); }, false);
|
||||
rcmail.register_command('list-delete', function(){ list_delete(me.selected_list); }, false);
|
||||
rcmail.register_command('list-remove', function(){ list_remove(me.selected_list); }, false);
|
||||
rcmail.register_command('list-sort', list_set_sort, true);
|
||||
rcmail.register_command('save', save_note, true);
|
||||
|
@ -112,7 +113,8 @@ function rcube_kolab_notes_ui(settings)
|
|||
var id = node.id;
|
||||
if (me.notebooks[id] && id != me.selected_list) {
|
||||
warn_unsaved_changes(function(){
|
||||
rcmail.enable_command('createnote', 'list-edit', 'list-remove', me.notebooks[id].editable);
|
||||
rcmail.enable_command('createnote', 'list-edit', 'list-delete', me.notebooks[id].editable);
|
||||
rcmail.enable_command('list-remove', !me.notebooks[id].default);
|
||||
fetch_notes(id); // sets me.selected_list
|
||||
},
|
||||
function(){
|
||||
|
@ -554,16 +556,26 @@ function rcube_kolab_notes_ui(settings)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_delete(id)
|
||||
{
|
||||
var list = me.notebooks[id];
|
||||
if (list && confirm(rcmail.gettext('deletenotebookconfirm', 'kolab_notes'))) {
|
||||
saving_lock = rcmail.set_busy(true, 'kolab_notes.savingdata');
|
||||
rcmail.http_post('list', { _do: 'delete', _list: { id: list.id } });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_remove(id)
|
||||
{
|
||||
var list = me.notebooks[id];
|
||||
if (list && confirm(rcmail.gettext('deletenotebookconfirm', 'kolab_notes'))) {
|
||||
saving_lock = rcmail.set_busy(true, 'kolab_notes.savingdata');
|
||||
rcmail.http_post('list', { _do: 'delete', _list: { id: list.id } });
|
||||
if (me.notebooks[id]) {
|
||||
list_destroy(me.notebooks[id]);
|
||||
rcmail.http_post('list', { _do:'subscribe', _list:{ id:id, permanent:0, recursive:1 } });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,8 @@
|
|||
<h3 id="aria-label-optionsmenu" class="voice"><roundcube:label name="kolab_notes.arialabelnotesoptionsmenu" /></h3>
|
||||
<ul class="toolbarmenu" id="notesoptionsmenu-menu" role="menu" aria-labelledby="aria-label-optionsmenu">
|
||||
<li role="menuitem"><roundcube:button command="list-edit" label="edit" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="list-remove" label="delete" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="list-delete" label="delete" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="list-remove" label="kolab_notes.removelist" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -173,9 +173,9 @@ class tasklist_database_driver extends tasklist_driver
|
|||
*
|
||||
* @param array Hash array with list properties
|
||||
* @return boolean True on success, Fales on failure
|
||||
* @see tasklist_driver::remove_list()
|
||||
* @see tasklist_driver::delete_list()
|
||||
*/
|
||||
public function remove_list($prop)
|
||||
public function delete_list($prop)
|
||||
{
|
||||
$list_id = $prop['id'];
|
||||
|
||||
|
|
|
@ -143,6 +143,7 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
'virtual' => $folder->virtual,
|
||||
'children' => true, // TODO: determine if that folder indeed has child folders
|
||||
'subscribed' => (bool)$folder->is_subscribed(),
|
||||
'removable' => !$folder->default,
|
||||
'group' => $folder->default ? 'default' : $folder->get_namespace(),
|
||||
'class' => trim($folder->get_namespace() . ($folder->default ? ' default' : '')),
|
||||
);
|
||||
|
@ -361,6 +362,16 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
$ret |= $folder->subscribe(intval($prop['permanent']));
|
||||
if (isset($prop['active']))
|
||||
$ret |= $folder->activate(intval($prop['active']));
|
||||
|
||||
// apply to child folders, too
|
||||
if ($prop['recursive']) {
|
||||
foreach ((array)kolab_storage::list_folders($folder->name, '*', 'task') as $subfolder) {
|
||||
if (isset($prop['permanent']))
|
||||
($prop['permanent'] ? kolab_storage::folder_subscribe($subfolder) : kolab_storage::folder_unsubscribe($subfolder));
|
||||
if (isset($prop['active']))
|
||||
($prop['active'] ? kolab_storage::folder_activate($subfolder) : kolab_storage::folder_deactivate($subfolder));
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return false;
|
||||
|
@ -373,7 +384,7 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
* id: list Identifier
|
||||
* @return boolean True on success, Fales on failure
|
||||
*/
|
||||
public function remove_list($prop)
|
||||
public function delete_list($prop)
|
||||
{
|
||||
if ($prop['id'] && ($folder = $this->get_folder($prop['id']))) {
|
||||
if (kolab_storage::folder_delete($folder->name))
|
||||
|
|
|
@ -124,7 +124,7 @@ abstract class tasklist_driver
|
|||
* id: list Identifier
|
||||
* @return boolean True on success, Fales on failure
|
||||
*/
|
||||
abstract function remove_list($prop);
|
||||
abstract function delete_list($prop);
|
||||
|
||||
/**
|
||||
* Search for shared or otherwise not listed tasklists the user has access
|
||||
|
|
|
@ -19,6 +19,7 @@ $labels['findlists'] = 'Find tasklists...';
|
|||
$labels['searchterms'] = 'Search terms';
|
||||
$labels['notasklistsfound'] = 'No tasklists found';
|
||||
$labels['nrtasklistsfound'] = '$nr tasklists found';
|
||||
$labels['removelist'] = 'Remove';
|
||||
|
||||
$labels['newtask'] = 'New Task';
|
||||
$labels['createtask'] = 'Create Task <Enter>';
|
||||
|
|
|
@ -51,9 +51,10 @@
|
|||
<h3 id="aria-label-tasklistoptions" class="voice"><roundcube:label name="tasklist.listactions" /></h3>
|
||||
<ul class="toolbarmenu" id="tasklistoptionsmenu-menu" role="menu" aria-labelledby="aria-label-tasklistoptions">
|
||||
<li role="menuitem"><roundcube:button command="list-edit" label="edit" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="list-remove" label="delete" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="list-delete" label="delete" classAct="active" /></li>
|
||||
<!--<li role="menuitem"><roundcube:button command="list-import" label="tasklist.import" classAct="active" /></li>-->
|
||||
<roundcube:if condition="env:tasklist_driver == 'kolab'" />
|
||||
<li role="menuitem"><roundcube:button command="list-remove" label="tasklist.removelist" classAct="active" /></li>
|
||||
<li role="menuitem"><roundcube:button command="folders" task="settings" type="link" label="managefolders" classAct="active" /></li>
|
||||
<roundcube:endif />
|
||||
</ul>
|
||||
|
|
|
@ -116,6 +116,7 @@ function rcube_tasklist_ui(settings)
|
|||
this.quicksearch = quicksearch;
|
||||
this.reset_search = reset_search;
|
||||
this.expand_collapse = expand_collapse;
|
||||
this.list_delete = list_delete;
|
||||
this.list_remove = list_remove;
|
||||
this.list_edit_dialog = list_edit_dialog;
|
||||
this.unlock_saving = unlock_saving;
|
||||
|
@ -154,7 +155,8 @@ function rcube_tasklist_ui(settings)
|
|||
});
|
||||
tasklists_widget.addEventListener('select', function(node) {
|
||||
var id = $(this).data('id');
|
||||
rcmail.enable_command('list-edit', 'list-remove', 'list-import', me.tasklists[node.id].editable);
|
||||
rcmail.enable_command('list-edit', 'list-delete', 'list-import', me.tasklists[node.id].editable);
|
||||
rcmail.enable_command('list-remove', me.tasklists[node.id] && me.tasklists[node.id].removable);
|
||||
me.selected_list = node.id;
|
||||
});
|
||||
tasklists_widget.addEventListener('subscribe', function(p) {
|
||||
|
@ -2560,17 +2562,29 @@ function rcube_tasklist_ui(settings)
|
|||
/**
|
||||
*
|
||||
*/
|
||||
function list_remove(id)
|
||||
function list_delete(id)
|
||||
{
|
||||
var list = me.tasklists[id];
|
||||
if (list && !list.norename && confirm(rcmail.gettext(list.children ? 'deletelistconfirmrecursive' : 'deletelistconfirm', 'tasklist'))) {
|
||||
saving_lock = rcmail.set_busy(true, 'tasklist.savingdata');
|
||||
rcmail.http_post('tasklist', { action:'remove', l:{ id:list.id } });
|
||||
rcmail.http_post('tasklist', { action:'delete', l:{ id:list.id } });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function list_remove(id)
|
||||
{
|
||||
var list = me.tasklists[id];
|
||||
if (list && list.removable) {
|
||||
destroy_list(list);
|
||||
rcmail.http_post('tasklist', { action:'subscribe', l:{ id:list.id, active:0, permanent:0, recursive:1 } });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback from server to finally remove the given list
|
||||
*/
|
||||
|
@ -2877,6 +2891,7 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
|
|||
|
||||
rcmail.register_command('list-create', function(){ rctasks.list_edit_dialog(null); }, true);
|
||||
rcmail.register_command('list-edit', function(){ rctasks.list_edit_dialog(rctasks.selected_list); }, false);
|
||||
rcmail.register_command('list-delete', function(){ rctasks.list_delete(rctasks.selected_list); }, false);
|
||||
rcmail.register_command('list-remove', function(){ rctasks.list_remove(rctasks.selected_list); }, false);
|
||||
|
||||
rcmail.register_command('search', function(){ rctasks.quicksearch(); }, true);
|
||||
|
|
|
@ -837,8 +837,8 @@ class tasklist extends rcube_plugin
|
|||
$success = $this->driver->subscribe_list($list);
|
||||
break;
|
||||
|
||||
case 'remove':
|
||||
if (($success = $this->driver->remove_list($list)))
|
||||
case 'delete':
|
||||
if (($success = $this->driver->delete_list($list)))
|
||||
$this->rc->output->command('plugin.destroy_tasklist', $list);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue