diff options
author | thomascube <thomas@roundcube.net> | 2009-08-27 07:07:10 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2009-08-27 07:07:10 +0000 |
commit | 85c812acec58c46d97442c736d62ea16633a96d9 (patch) | |
tree | aaceeffb10fcfd3e34ef810ecd4fa63b4387fc66 | |
parent | 4b20e2871897ad4a0e9bbb7a7b1b83cbcfa01efb (diff) |
Added archive plugin
-rw-r--r-- | plugins/archive/archive.js | 36 | ||||
-rw-r--r-- | plugins/archive/archive.php | 114 | ||||
-rw-r--r-- | plugins/archive/archive_act.png | bin | 0 -> 3663 bytes | |||
-rw-r--r-- | plugins/archive/archive_pas.png | bin | 0 -> 977 bytes | |||
-rw-r--r-- | plugins/archive/foldericon.png | bin | 0 -> 3312 bytes | |||
-rw-r--r-- | plugins/archive/localization/de_CH.inc | 8 | ||||
-rw-r--r-- | plugins/archive/localization/de_DE.inc | 8 | ||||
-rw-r--r-- | plugins/archive/localization/en_US.inc | 8 | ||||
-rw-r--r-- | plugins/archive/localization/fr_FR.inc | 9 |
9 files changed, 183 insertions, 0 deletions
diff --git a/plugins/archive/archive.js b/plugins/archive/archive.js new file mode 100644 index 000000000..d771fb66b --- /dev/null +++ b/plugins/archive/archive.js @@ -0,0 +1,36 @@ +/* + * Archive plugin script + * @version 1.2 + */ + +function rcmail_archive(prop) +{ + if (!rcmail.env.uid && (!rcmail.message_list || !rcmail.message_list.get_selection().length)) + return; + + var uids = rcmail.env.uid ? rcmail.env.uid : rcmail.message_list.get_selection().join(','); + + rcmail.set_busy(true, 'loading'); + rcmail.http_post('plugin.archive', '_uid='+uids+'&_mbox='+urlencode(rcmail.env.mailbox), true); +} + +// callback for app-onload event +if (window.rcmail) { + rcmail.addEventListener('init', function(evt) { + + // register command (directly enable in message view mode) + rcmail.register_command('plugin.archive', rcmail_archive, (rcmail.env.uid && rcmail.env.mailbox != rcmail.env.archive_folder)); + + // add event-listener to message list + if (rcmail.message_list) + rcmail.message_list.addEventListener('select', function(list){ + rcmail.enable_command('plugin.archive', (list.get_selection().length > 0 && rcmail.env.mailbox != rcmail.env.archive_folder)); + }); + + // set css style for archive folder + var li; + if (rcmail.env.archive_folder && (li = rcmail.get_folder_li(rcmail.env.archive_folder))) + $(li).css('background-image', 'url(plugins/archive/foldericon.png)'); + }) +} + diff --git a/plugins/archive/archive.php b/plugins/archive/archive.php new file mode 100644 index 000000000..2bd1adc7a --- /dev/null +++ b/plugins/archive/archive.php @@ -0,0 +1,114 @@ +<?php + +/** + * Archive + * + * Plugin that adds a new button to the mailbox toolbar + * to move messages to a (user selectable) archive folder. + * + * @version 1.4 + * @author Andre Rodier, Thomas Bruederli + */ +class archive extends rcube_plugin +{ + public $task = 'mail|settings'; + + function init() + { + $this->register_action('plugin.archive', array($this, 'request_action')); + + # There is no "Archived flags" + # $GLOBALS['IMAP_FLAGS']['ARCHIVED'] = 'Archive'; + + $rcmail = rcmail::get_instance(); + if ($rcmail->task == 'mail' && ($rcmail->action == '' || $rcmail->action == 'show') && ($archive_folder = $rcmail->config->get('archive_mbox'))) { + $this->include_script('archive.js'); + $this->add_texts('localization', true); + $this->add_button( + array( + 'command' => 'plugin.archive', + 'imagepas' => 'archive_pas.png', + 'imageact' => 'archive_act.png', + 'title' => 'buttontitle', + 'domain' => $this->ID, + ), + 'toolbar'); + + // register hook to localize the archive folder + $this->add_hook('render_mailboxlist', array($this, 'render_mailboxlist')); + + // set env variable for client + $rcmail->output->set_env('archive_folder', $archive_folder); + + // add archive folder to the list of defailt mailboxes + if (($default_folders = $rcmail->config->get('default_imap_folders')) && !in_array($archive_folder, $default_folders)) { + $default_folders[] = $archive_folder; + $rcmail->config->set('default_imap_folders', $default_folders); + } + + } + else if ($rcmail->task == 'settings') { + $dont_override = $rcmail->config->get('dont_override', array()); + if (!in_array('archive_mbox', $dont_override)) { + $this->add_hook('user_preferences', array($this, 'prefs_table')); + $this->add_hook('save_preferences', array($this, 'save_prefs')); + } + } + } + + function render_mailboxlist($p) + { + $rcmail = rcmail::get_instance(); + $archive_folder = $rcmail->config->get('archive_mbox'); + + // set localized name for the configured arcive folder + if ($archive_folder && $p['list'][$archive_folder]) + $p['list'][$archive_folder]['name'] = $this->gettext('archivefolder'); + + return $p; + } + + function request_action() + { + $this->add_texts('localization'); + + $uids = get_input_value('_uid', RCUBE_INPUT_POST); + $mbox = get_input_value('_mbox', RCUBE_INPUT_POST); + + $rcmail = rcmail::get_instance(); + + # There is no "Archive flags", but I left this line in case it may be useful + # $rcmail->imap->set_flag($uids, 'ARCHIVE'); + + if (($archive_mbox = $rcmail->config->get('archive_mbox')) && $mbox != $archive_mbox) { + $rcmail->output->command('move_messages', $archive_mbox); + $rcmail->output->command('display_message', $this->gettext('archived'), 'confirmation'); + } + + $rcmail->output->send(); + } + + function prefs_table($args) + { + if ($args['section'] == 'folders') { + $this->add_texts('localization'); + + $rcmail = rcmail::get_instance(); + $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true, 'maxlength' => 30)); + + $args['blocks']['main']['options']['archive_mbox'] = array( + 'title' => $this->gettext('archivefolder'), + 'content' => $select->show($rcmail->config->get('archive_mbox'), array('name' => "_archive_mbox")) + ); + } + + return $args; + } + + function save_prefs($args) + { + $args['prefs']['archive_mbox'] = get_input_value('_archive_mbox', RCUBE_INPUT_POST); + return $args; + } + +} diff --git a/plugins/archive/archive_act.png b/plugins/archive/archive_act.png Binary files differnew file mode 100644 index 000000000..2a1735868 --- /dev/null +++ b/plugins/archive/archive_act.png diff --git a/plugins/archive/archive_pas.png b/plugins/archive/archive_pas.png Binary files differnew file mode 100644 index 000000000..8de208583 --- /dev/null +++ b/plugins/archive/archive_pas.png diff --git a/plugins/archive/foldericon.png b/plugins/archive/foldericon.png Binary files differnew file mode 100644 index 000000000..ec0853c44 --- /dev/null +++ b/plugins/archive/foldericon.png diff --git a/plugins/archive/localization/de_CH.inc b/plugins/archive/localization/de_CH.inc new file mode 100644 index 000000000..2ed0f5ac8 --- /dev/null +++ b/plugins/archive/localization/de_CH.inc @@ -0,0 +1,8 @@ +<?php + +$labels = array(); +$labels['buttontitle'] = 'Nachricht archivieren'; +$labels['archived'] = 'Nachricht erfolgreich archiviert'; +$labels['archivefolder'] = 'Archiv'; + +?> diff --git a/plugins/archive/localization/de_DE.inc b/plugins/archive/localization/de_DE.inc new file mode 100644 index 000000000..2ed0f5ac8 --- /dev/null +++ b/plugins/archive/localization/de_DE.inc @@ -0,0 +1,8 @@ +<?php + +$labels = array(); +$labels['buttontitle'] = 'Nachricht archivieren'; +$labels['archived'] = 'Nachricht erfolgreich archiviert'; +$labels['archivefolder'] = 'Archiv'; + +?> diff --git a/plugins/archive/localization/en_US.inc b/plugins/archive/localization/en_US.inc new file mode 100644 index 000000000..fce31a0b5 --- /dev/null +++ b/plugins/archive/localization/en_US.inc @@ -0,0 +1,8 @@ +<?php + +$labels = array(); +$labels['buttontitle'] = 'Archive this message'; +$labels['archived'] = 'Successfully archived'; +$labels['archivefolder'] = 'Archive'; + +?> diff --git a/plugins/archive/localization/fr_FR.inc b/plugins/archive/localization/fr_FR.inc new file mode 100644 index 000000000..422d45d87 --- /dev/null +++ b/plugins/archive/localization/fr_FR.inc @@ -0,0 +1,9 @@ +<?php + +$labels = array(); +$labels['buttontitle'] = 'Archiver ce message'; +$labels['archived'] = 'Message archivé avec success'; +$labels['archivefolder'] = 'Archive'; + +?> + |