]> git.donarmstrong.com Git - roundcube.git/blobdiff - plugins/archive/archive.php
Imported Upstream version 0.7
[roundcube.git] / plugins / archive / archive.php
index 9df7f8b99e9cb66f3ddd7701b0e999c1a4565ca6..a56806263c2fa2ed9af494a363015ff0d659d879 100644 (file)
@@ -6,7 +6,7 @@
  * Plugin that adds a new button to the mailbox toolbar
  * to move messages to a (user selectable) archive folder.
  *
- * @version 1.4
+ * @version @package_version@
  * @author Andre Rodier, Thomas Bruederli
  */
 class archive extends rcube_plugin
@@ -15,20 +15,23 @@ class archive extends rcube_plugin
 
   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'))) {
+
+    // There is no "Archived flags"
+    // $GLOBALS['IMAP_FLAGS']['ARCHIVED'] = 'Archive';
+    if ($rcmail->task == 'mail' && ($rcmail->action == '' || $rcmail->action == 'show')
+      && ($archive_folder = $rcmail->config->get('archive_mbox'))) {
+      $skin_path = $this->local_skin_path();
+      
       $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',
+            'imagepas' => $skin_path.'/archive_pas.png',
+            'imageact' => $skin_path.'/archive_act.png',
+            'width' => 32,
+            'height' => 32,
             'title' => 'buttontitle',
             'domain' => $this->ID,
         ),
@@ -39,19 +42,19 @@ class archive extends rcube_plugin
 
       // set env variable for client
       $rcmail->output->set_env('archive_folder', $archive_folder);
+      $rcmail->output->set_env('archive_folder_icon', $this->url($skin_path.'/foldericon.png'));
 
       // add archive folder to the list of default 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'));
+        $this->add_hook('preferences_list', array($this, 'prefs_table'));
+        $this->add_hook('preferences_save', array($this, 'save_prefs'));
       }
     }
   }
@@ -77,41 +80,29 @@ class archive extends rcube_plugin
     foreach ($list as $idx => $item) {
       if ($item['id'] == $folder) {
         $list[$idx]['name'] = $new_name;
-       return true;
+        return true;
       } else if (!empty($item['folders']))
         if ($this->_mod_folder_name($list[$idx]['folders'], $folder, $new_name))
-         return true;
+        return true;
     }
     return false;
   }
 
-  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)
   {
+    global $CURR_SECTION;
+
     if ($args['section'] == 'folders') {
       $this->add_texts('localization');
-      
+
       $rcmail = rcmail::get_instance();
-      $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true, 'maxlength' => 30));
+
+      // load folders list when needed
+      if ($CURR_SECTION)
+        $select = rcmail_mailbox_select(array('noselection' => '---', 'realnames' => true,
+          'maxlength' => 30, 'exceptions' => array('INBOX'), 'folder_filter' => 'mail', 'folder_rights' => 'w'));
+      else
+        $select = new html_select();
 
       $args['blocks']['main']['options']['archive_mbox'] = array(
           'title' => $this->gettext('archivefolder'),