Code updates
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 6 Apr 2009 07:03:56 +0000 (07:03 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 6 Apr 2009 07:03:56 +0000 (07:03 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13527 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/sent_subfolders/functions.php
plugins/sent_subfolders/index.php
plugins/sent_subfolders/setup.php

index 3df9b3182397bc0eef5d3557c6dec8efe56f6197..32699de512fb774c06faf34eb18cef679f4c206a 100644 (file)
  * @subpackage sent_subfolders
  */
 
+define('SMPREF_SENT_SUBFOLDERS_DISABLED',  0);
+define('SMPREF_SENT_SUBFOLDERS_YEARLY',    1);
+define('SMPREF_SENT_SUBFOLDERS_QUARTERLY', 2);
+define('SMPREF_SENT_SUBFOLDERS_MONTHLY',   3);
+define('SMOPT_GRP_SENT_SUBFOLDERS','SENT_SUBFOLDERS');
+
 function sent_subfolders_check_handleAsSent_do($mailbox) {
-    global $handleAsSent_result, $sent_subfolders_base,
-           $use_sent_subfolders;
+
+    global $handleAsSent_result;
+
+    // don't need to bother if it's already special
+    if ($handleAsSent_result) return;
 
     sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
 
+    $use_sent_subfolders = getPref($data_dir, $username,
+                                   'use_sent_subfolders', SMPREF_OFF);
+    $sent_subfolders_base = getPref($data_dir, $username,
+                                    'sent_subfolders_base', SMPREF_NONE);
+
     /* Only check the folder string if we have been passed a mailbox. */
     if ($use_sent_subfolders && !empty($mailbox)) {
         /* Chop up the folder strings as needed. */
@@ -25,36 +39,18 @@ function sent_subfolders_check_handleAsSent_do($mailbox) {
         $mbox_str = substr($mailbox, 0, strlen($base_str));
 
         /* Perform the comparison. */
-        $handleAsSent_result =
-            ( $handleAsSent_result
-            || ($base_str == $mbox_str)
-            || ($sent_subfolders_base == $mailbox)
-            );
+        $handleAsSent_result = ( ($base_str == $mbox_str)
+                              || ($sent_subfolders_base == $mailbox) );
     }
 }
 
-/**
- * Loads sent_subfolders settings
- */
-function sent_subfolders_load_prefs_do() {
-    global $use_sent_subfolders, $data_dir, $username,
-           $sent_subfolders_setting, $sent_subfolders_base;
-
-    $use_sent_subfolders = getPref
-    ($data_dir, $username, 'use_sent_subfolders', SMPREF_OFF);
-
-    $sent_subfolders_setting = getPref
-    ($data_dir, $username, 'sent_subfolders_setting', SMPREF_SENT_SUBFOLDERS_DISABLED);
-
-    $sent_subfolders_base = getPref
-    ($data_dir, $username, 'sent_subfolders_base', SMPREF_NONE);
-}
-
 /**
  * Adds sent_subfolders options in folder preferences
  */
 function sent_subfolders_optpage_loadhook_folders_do() {
-    global $username, $optpage_data, $imapServerAddress, $imapPort, $show_contain_subfolders_option;
+
+    global $username, $optpage_data, $imapServerAddress, $imapPort,
+           $show_contain_subfolders_option;
 
     /* Get some imap data we need later. */
     $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
@@ -65,6 +61,10 @@ function sent_subfolders_optpage_loadhook_folders_do() {
     $optgrp = _("Sent Subfolders Options");
     $optvals = array();
 
+    global $sent_subfolders_setting;
+    $sent_subfolders_setting = getPref($data_dir, $username,
+                                       'sent_subfolders_setting',
+                                       SMPREF_SENT_SUBFOLDERS_DISABLED);
     $optvals[] = array(
         'name'    => 'sent_subfolders_setting',
         'caption' => _("Use Sent Subfolders"),
@@ -80,6 +80,9 @@ function sent_subfolders_optpage_loadhook_folders_do() {
     $filtered_folders=array_filter($boxes, "filter_folders");
     $sent_subfolders_base_values = array('whatever'=>$filtered_folders);
 
+    global $sent_subfolders_base;
+    $sent_subfolders_base = getPref($data_dir, $username,
+                                    'sent_subfolders_base', SMPREF_NONE);
     $optvals[] = array(
         'name'    => 'sent_subfolders_base',
         'caption' => _("Base Sent Folder"),
@@ -119,7 +122,7 @@ function filter_folders($fldr) {
  * Saves sent_subfolder_options
  */
 function save_option_sent_subfolders_setting($option) {
-    global $data_dir, $username, $use_sent_subfolders;
+    global $data_dir, $username;
 
     /* Set use_sent_subfolders as either on or off. */
     if ($option->new_value == SMPREF_SENT_SUBFOLDERS_DISABLED) {
@@ -140,13 +143,20 @@ function save_option_sent_subfolders_setting($option) {
  * creates required imap folders
  */
 function sent_subfolders_update_sentfolder_do() {
-    global $sent_folder, $username;
-    global $sent_subfolders_base, $sent_subfolders_setting;
-    global $data_dir, $imapServerAddress, $imapPort;
-    global $use_sent_subfolders, $move_to_sent;
+    global $sent_folder, $username,
+           $data_dir, $imapServerAddress, $imapPort,
+           $move_to_sent;
 
     sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
 
+    $use_sent_subfolders = getPref($data_dir, $username,
+                                   'use_sent_subfolders', SMPREF_OFF);
+    $sent_subfolders_setting = getPref($data_dir, $username,
+                                       'sent_subfolders_setting',
+                                       SMPREF_SENT_SUBFOLDERS_DISABLED);
+    $sent_subfolders_base = getPref($data_dir, $username,
+                                    'sent_subfolders_base', SMPREF_NONE);
+
     if ($use_sent_subfolders || $move_to_sent) {
         $year = date('Y');
         $month = date('m');
@@ -283,8 +293,9 @@ function sent_subfolders_special_mailbox_do($mb) {
 
     sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
 
-    $use_sent_subfolders = getPref
-        ($data_dir, $username, 'use_sent_subfolders', SMPREF_OFF);
+    $use_sent_subfolders = getPref($data_dir, $username, 'use_sent_subfolders', SMPREF_OFF);
+
+//FIXME: why "na" as the default?  Shouldn't this be SMPREF_NONE as it is elsewhere in this file?
     $sent_subfolders_base = getPref($data_dir, $username, 'sent_subfolders_base', 'na');
 
     /**
index 20b5148cb1da010b11b2f461b1dfd07f43907802..30186f786841f6ac1d4c009682bfb501d02169cf 100644 (file)
@@ -16,4 +16,3 @@
 
 header('Location: ../index.php');
 
-?>
\ No newline at end of file
index efe2db11154fd56e799a09a5672e32531687012a..a3e7a6d173638ac106108894dc28d22b68661927 100644 (file)
  * @subpackage sent_subfolders
  */
 
-/**
- */
-define('SMPREF_SENT_SUBFOLDERS_DISABLED',  0);
-define('SMPREF_SENT_SUBFOLDERS_YEARLY',    1);
-define('SMPREF_SENT_SUBFOLDERS_QUARTERLY', 2);
-define('SMPREF_SENT_SUBFOLDERS_MONTHLY',   3);
-define('SMOPT_GRP_SENT_SUBFOLDERS','SENT_SUBFOLDERS');
-
 /**
  * Adds plugin to SquirrelMail's hooks
  */
@@ -28,33 +20,22 @@ function squirrelmail_plugin_init_sent_subfolders() {
     global $squirrelmail_plugin_hooks;
 
     /* The hooks to make the sent subfolders display correctly. */
-    $squirrelmail_plugin_hooks
-    ['check_handleAsSent_result']['sent_subfolders'] =
-        'sent_subfolders_check_handleAsSent';
+    $squirrelmail_plugin_hooks['check_handleAsSent_result']['sent_subfolders']
+        = 'sent_subfolders_check_handleAsSent';
 
     /* The hooks to automatically update sent subfolders. */
-    $squirrelmail_plugin_hooks
-    ['left_main_before']['sent_subfolders'] =
-        'sent_subfolders_update_sentfolder';
-
-    $squirrelmail_plugin_hooks
-    ['compose_send']['sent_subfolders'] =
-        'sent_subfolders_update_sentfolder';
-
-    /* The hook to load the sent subfolders prefs. */
-    $squirrelmail_plugin_hooks
-    ['loading_prefs']['sent_subfolders'] =
-        'sent_subfolders_load_prefs';
+    $squirrelmail_plugin_hooks['left_main_before']['sent_subfolders']
+        = 'sent_subfolders_update_sentfolder';
+    $squirrelmail_plugin_hooks['compose_send']['sent_subfolders']
+        = 'sent_subfolders_update_sentfolder';
 
     /* The hooks to handle sent subfolders options. */
-    $squirrelmail_plugin_hooks
-    ['optpage_loadhook_folder']['sent_subfolders'] =
-        'sent_subfolders_optpage_loadhook_folders';
+    $squirrelmail_plugin_hooks['optpage_loadhook_folder']['sent_subfolders']
+        = 'sent_subfolders_optpage_loadhook_folders';
 
     /* mark base sent folder as special mailbox */
-    $squirrelmail_plugin_hooks
-    ['special_mailbox']['sent_subfolders'] =
-        'sent_subfolders_special_mailbox';
+    $squirrelmail_plugin_hooks['special_mailbox']['sent_subfolders']
+        = 'sent_subfolders_special_mailbox';
 }
 
 function sent_subfolders_check_handleAsSent($mailbox) {
@@ -62,14 +43,6 @@ function sent_subfolders_check_handleAsSent($mailbox) {
     sent_subfolders_check_handleAsSent_do($mailbox);
 }
 
-/**
- * Loads sent_subfolders settings
- */
-function sent_subfolders_load_prefs() {
-    include_once(SM_PATH . 'plugins/sent_subfolders/functions.php');
-    sent_subfolders_load_prefs_do();
-}
-
 /**
  * Adds sent_subfolders options in folder preferences
  */