[ Index ]
 

Code source de IMP H3 (4.1.5)

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/lib/ -> prefs.php (source)

   1  <?php
   2  
   3  define('IMP_PREF_NO_FOLDER', '**nofolder');
   4  
   5  /**
   6   * $Horde: imp/lib/prefs.php,v 1.3.10.21 2007/03/01 07:42:28 slusarz Exp $
   7   *
   8   * Copyright 1999-2007 Charles J. Hagenbuch <chuck@horde.org>
   9   * Copyright 1999-2007 Jon Parise <jon@horde.org>
  10   *
  11   * See the enclosed file COPYING for license information (GPL).  If you
  12   * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  13   */
  14  
  15  function handle_sentmailselect($updated)
  16  {
  17      global $conf, $prefs, $identity;
  18  
  19      if ($conf['user']['allow_folders'] &&
  20          !$prefs->isLocked('sent_mail_folder')) {
  21          $sent_mail_folder = Util::getFormData('sent_mail');
  22          $sent_mail_new = String::convertCharset(Util::getFormData('sent_mail_new'), NLS::getCharset(), 'UTF7-IMAP');
  23          $sent_mail_default = $prefs->getValue('sent_mail_folder');
  24          if (empty($sent_mail_folder) && !empty($sent_mail_new)) {
  25              $sent_mail_folder = IMP::appendNamespace($sent_mail_new);
  26          } elseif (($sent_mail_folder == '-1') && !empty($sent_mail_default)) {
  27              $sent_mail_folder = IMP::appendNamespace($sent_mail_default);
  28          }
  29          if (!empty($sent_mail_folder)) {
  30              include_once  IMP_BASE . '/lib/Folder.php';
  31              $imp_folder = &IMP_Folder::singleton();
  32              if (!$imp_folder->exists($sent_mail_folder)) {
  33                  $imp_folder->create($sent_mail_folder, $prefs->getValue('subscribe'));
  34              }
  35          }
  36          $identity->setValue('sent_mail_folder', IMP::folderPref($sent_mail_folder, false));
  37          $updated = true;
  38      }
  39  
  40      return $updated;
  41  }
  42  
  43  function handlefolders($updated, $pref, $folder, $new)
  44  {
  45      global $conf, $prefs;
  46  
  47      if ($conf['user']['allow_folders']) {
  48          $folder = Util::getFormData($folder);
  49          if (isset($folder) && !$prefs->isLocked($pref)) {
  50              $new = String::convertCharset(Util::getFormData($new), NLS::getCharset(), 'UTF7-IMAP');
  51              if ($folder == IMP_PREF_NO_FOLDER) {
  52                  $prefs->setValue($pref, '');
  53              } else {
  54                  if (empty($folder) && !empty($new)) {
  55                      $folder = IMP::appendNamespace($new);
  56                      include_once  IMP_BASE . '/lib/Folder.php';
  57                      $imp_folder = &IMP_Folder::singleton();
  58                      if (!$imp_folder->create($folder, $prefs->getValue('subscribe'))) {
  59                          $folder = null;
  60                      }
  61                  }
  62                  if (!empty($folder)) {
  63                      $prefs->setValue($pref, IMP::folderPref($folder, false));
  64                      $updated = true;
  65                  }
  66              }
  67          }
  68      }
  69  
  70      return $updated;
  71  }
  72  
  73  function handle_folderselect($updated)
  74  {
  75      return $updated | handlefolders($updated, 'drafts_folder', 'drafts', 'drafts_new');
  76  }
  77  
  78  function handle_trashselect($updated)
  79  {
  80      return $updated | handlefolders($updated, 'trash_folder', 'trash', 'trash_new');
  81  }
  82  
  83  function handle_sourceselect($updated)
  84  {
  85      global $prefs;
  86  
  87      $search_sources = Util::getFormData('search_sources');
  88      if (!is_null($search_sources)) {
  89          $prefs->setValue('search_sources', $search_sources);
  90          $updated = true;
  91      }
  92  
  93      $search_fields_string = Util::getFormData('search_fields_string');
  94      if (!is_null($search_fields_string)) {
  95          $prefs->setValue('search_fields', $search_fields_string);
  96          $updated = true;
  97      }
  98  
  99      $add_source = Util::getFormData('add_source');
 100      if (!is_null($add_source)) {
 101          $prefs->setValue('add_source', $add_source);
 102          $updated = true;
 103      }
 104  
 105      return $updated;
 106  }
 107  
 108  function handle_initialpageselect($updated)
 109  {
 110      $initial_page = Util::getFormData('initial_page');
 111      $GLOBALS['prefs']->setValue('initial_page', $initial_page);
 112      return true;
 113  }
 114  
 115  function handle_encryptselect($updated)
 116  {
 117      $default_encrypt = Util::getFormData('default_encrypt');
 118      $GLOBALS['prefs']->setValue('default_encrypt', $default_encrypt);
 119      return true;
 120  }
 121  
 122  function handle_spamselect($updated)
 123  {
 124      return $updated | handlefolders($updated, 'spam_folder', 'spam', 'spam_new');
 125  }
 126  
 127  function handle_defaultsearchselect($updated)
 128  {
 129      $default_search = Util::getFormData('default_search');
 130      $GLOBALS['prefs']->setValue('default_search', $default_search);
 131      return true;
 132  }
 133  
 134  function prefs_callback()
 135  {
 136      global $prefs;
 137  
 138      /* Never allow trash and Virtual Trash to be activated at the same time.
 139       * If they collide, and a trash folder is defined, always default to trash
 140       * folder. */
 141      if ($prefs->isDirty('use_vtrash') || $prefs->isDirty('use_trash')) {
 142          if ($prefs->getValue('use_vtrash') && $prefs->getValue('use_trash')) {
 143              if ($prefs->getValue('trash_folder')) {
 144                  $prefs->setValue('use_vtrash', 0);
 145                  $GLOBALS['notification']->push(_("Cannot activate both a Trash folder and Virtual Trash. A Trash folder will be used."), 'horde.error');
 146              } else {
 147                  $prefs->setValue('use_trash', 0);
 148                  $GLOBALS['notification']->push(_("Cannot activate both a Trash folder and Virtual Trash. A Virtual Trash folder will be used."), 'horde.error');
 149              }
 150          }
 151      }
 152  
 153      /* Always check to make sure we have a valid trash folder if delete to
 154       * trash is active. */
 155      if (($prefs->isDirty('use_trash') || $prefs->isDirty('trash_folder')) &&
 156          $prefs->getValue('use_trash') &&
 157          !$prefs->getValue('trash_folder')) {
 158          $prefs->setValue('use_trash', 0);
 159          $GLOBALS['notification']->push(_("Cannot delete to trash unless a Trash folder is defined."), 'horde.error');
 160      }
 161  
 162      if (($prefs->isDirty('use_vtrash') && $prefs->getValue('use_vtrash')) ||
 163          $GLOBALS['prefs']->isDirty('use_vinbox')) {
 164          require_once  IMP_BASE . '/lib/Search.php';
 165          $imp_search = new IMP_Search();
 166          $imp_search->sessionSetup();
 167      }
 168  
 169      if ($GLOBALS['prefs']->isDirty('subscribe')) {
 170          require_once  IMP_BASE . '/lib/IMAP/Tree.php';
 171          $imptree = &IMP_Tree::singleton();
 172          $imptree->init();
 173      }
 174  
 175      /* If a maintenance option has been activated, we need to make sure the
 176       * global Horde 'do_maintenance' pref is also active. */
 177      if (!$GLOBALS['prefs']->isLocked('do_maintenance') &&
 178          !$GLOBALS['prefs']->getValue('do_maintenance')) {
 179          foreach (array('rename_sentmail_monthly', 'delete_sentmail_monthly', 'purge_sentmail', 'delete_attachments_monthly', 'purge_trash') as $val) {
 180              if ($GLOBALS['prefs']->getValue($val)) {
 181                  $GLOBALS['prefs']->setValue('do_maintenance', true);
 182                  break;
 183              }
 184          }
 185      }
 186  }
 187  
 188  require_once  IMP_BASE . '/lib/Maintenance/imp.php';
 189  $maint = new Maintenance_IMP();
 190  foreach (($maint->exportIntervalPrefs()) as $val) {
 191      $$val = &$intervals;
 192  }
 193  
 194  /* Make sure we have an active IMAP stream. */
 195  if (!$GLOBALS['registry']->call('mail/getStream')) {
 196      header('Location: ' . Util::addParameter(Horde::applicationUrl('redirect.php'), 'url', Horde::selfUrl(true)));
 197      exit;
 198  }


Généré le : Thu Nov 29 12:30:07 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics