Move prefs callbacks into Horde_Registry_Application
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 11 Aug 2009 20:49:54 +0000 (14:49 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 11 Aug 2009 20:52:55 +0000 (14:52 -0600)
32 files changed:
ansel/lib/Api.php
ansel/lib/Application.php
chora/lib/Api.php
chora/lib/Application.php
crumb/lib/Api.php [deleted file]
crumb/lib/Application.php
fima/lib/Api.php [deleted file]
fima/lib/Application.php
folks/lib/Api.php
folks/lib/Application.php
gollem/lib/Api.php
gollem/lib/Application.php
imp/lib/Api.php
imp/lib/Application.php
ingo/lib/Api.php
ingo/lib/Application.php
jeta/lib/Api.php [deleted file]
jeta/lib/Application.php
kastalia/lib/Api.php [deleted file]
kastalia/lib/Application.php
kronolith/lib/Api.php
kronolith/lib/Application.php
nag/lib/Api.php
nag/lib/Application.php
news/lib/Api.php
news/lib/Application.php
skeleton/lib/Api.php
skeleton/lib/Application.php
skoli/lib/Api.php [deleted file]
skoli/lib/Application.php
turba/lib/Api.php
turba/lib/Application.php

index 4715ca0..51fa728 100644 (file)
@@ -29,42 +29,6 @@ class Ansel_Api extends Horde_Registry_Api
     }
 
     /**
-     * TODO
-     */
-    public function prefsHandle($item, $updated)
-    {
-        switch ($item) {
-        case 'default_category_select':
-            $default_category = Horde_Util::getFormData('default_category_select');
-            if (!is_null($default_category)) {
-                $GLOBALS['prefs']->setValue('default_category', $default_category);
-                return true;
-            }
-            break;
-
-        case 'default_gallerystyle_select':
-            $default_style = Horde_Util::getFormData('default_gallerystyle_select');
-            if (!is_null($default_style)) {
-                $GLOBALS['prefs']->setValue('default_gallerystyle', $default_style);
-                return true;
-            }
-            break;
-        }
-
-        return $updated;
-    }
-
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Ansel::getMenu();
-    }
-
-    /**
      * Browse through Ansel's gallery tree.
      *
      * @param string $path       The level of the tree to browse.
index e99e070..9b521a5 100644 (file)
 class Ansel_Application extends Horde_Registry_Application
 {
     public $version = 'H4 (2.0-git)';
+
+    /**
+     * Special preferences handling on update.
+     *
+     * @param string $item      The preference name.
+     * @param boolean $updated  Set to true if preference was updated.
+     *
+     * @return boolean  True if preference was updated.
+     */
+    public function prefsHandle($item, $updated)
+    {
+        switch ($item) {
+        case 'default_category_select':
+            $default_category = Horde_Util::getFormData('default_category_select');
+            if (!is_null($default_category)) {
+                $GLOBALS['prefs']->setValue('default_category', $default_category);
+                return true;
+            }
+            break;
+
+        case 'default_gallerystyle_select':
+            $default_style = Horde_Util::getFormData('default_gallerystyle_select');
+            if (!is_null($default_style)) {
+                $GLOBALS['prefs']->setValue('default_gallerystyle', $default_style);
+                return true;
+            }
+            break;
+        }
+
+        return $updated;
+    }
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Ansel::getMenu();
+    }
+
 }
index b8662d6..25a764f 100644 (file)
@@ -31,14 +31,4 @@ class Chora_Api extends Horde_Registry_Api
         return $perms;
     }
 
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Chora::getMenu();
-    }
-
 }
index c8ea976..8eee943 100644 (file)
@@ -15,4 +15,15 @@ class Chora_Application extends Horde_Registry_Application
      * @var string
      */
     public $version = 'H4 (3.0-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Chora::getMenu();
+    }
+
 }
diff --git a/crumb/lib/Api.php b/crumb/lib/Api.php
deleted file mode 100644 (file)
index 0a95673..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-class Crumb_Api extends Horde_Registry_Api
-{
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Crumb::getMenu();
-    }
-
-}
index 5399734..0904046 100644 (file)
@@ -2,4 +2,15 @@
 class Crumb_Application extends Horde_Registry_Application
 {
     public $version = 'H4 (0.1-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Crumb::getMenu();
+    }
+
 }
diff --git a/fima/lib/Api.php b/fima/lib/Api.php
deleted file mode 100644 (file)
index b1d758e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-class Fima_Api extends Horde_Regsitry_Api
-{
-    /**
-     * TODO
-     */
-    public function prefsHandle($item, $updated)
-    {
-        switch ($item) {
-        case 'ledgerselect':
-            $active_ledger = Horde_Util::getFormData('active_ledger');
-            if (!is_null($active_ledger)) {
-                $ledgers = Fima::listLedgers();
-                if (is_array($ledgers) &&
-                    array_key_exists($active_ledger, $ledgers)) {
-                    $GLOBALS['prefs']->setValue('active_ledger', $active_ledger);
-                    return true;
-                }
-            }
-            break;
-
-        case 'closedperiodselect':
-            $period = Horde_Util::getFormData('closedperiod');
-            if ((int)$period['year'] > 0 && (int)$period['month'] > 0) {
-                $period = mktime(0, 0, 0, $period['month'] + 1, 0, $period['year']);
-            } else {
-                $period = 0;
-            }
-            $GLOBALS['prefs']->setValue('closed_period', $period);
-            return true;
-        }
-
-        return $updated;
-    }
-
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Fima::getMenu();
-    }
-
-}
index b50e46e..a3b8266 100644 (file)
@@ -2,4 +2,52 @@
 class Fima_Application extends Horde_Regsitry_Application
 {
     public $version = '1.0.1';
+
+    /**
+     * Special preferences handling on update.
+     *
+     * @param string $item      The preference name.
+     * @param boolean $updated  Set to true if preference was updated.
+     *
+     * @return boolean  True if preference was updated.
+     */
+    public function prefsHandle($item, $updated)
+    {
+        switch ($item) {
+        case 'ledgerselect':
+            $active_ledger = Horde_Util::getFormData('active_ledger');
+            if (!is_null($active_ledger)) {
+                $ledgers = Fima::listLedgers();
+                if (is_array($ledgers) &&
+                    array_key_exists($active_ledger, $ledgers)) {
+                    $GLOBALS['prefs']->setValue('active_ledger', $active_ledger);
+                    return true;
+                }
+            }
+            break;
+
+        case 'closedperiodselect':
+            $period = Horde_Util::getFormData('closedperiod');
+            if ((int)$period['year'] > 0 && (int)$period['month'] > 0) {
+                $period = mktime(0, 0, 0, $period['month'] + 1, 0, $period['year']);
+            } else {
+                $period = 0;
+            }
+            $GLOBALS['prefs']->setValue('closed_period', $period);
+            return true;
+        }
+
+        return $updated;
+    }
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Fima::getMenu();
+    }
+
 }
index 83a7d39..92460c7 100644 (file)
@@ -31,16 +31,6 @@ class Folks_Api extends Horde_Registry_Api
     }
 
     /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Folks::getMenu();
-    }
-
-    /**
      * Returns profile image URL.
      *
      * @param string  $user      User uid
index f65e949..7de69c3 100644 (file)
 class Folks_Application extends Horde_Registry_Application
 {
     public $version = 'H4 (0.1-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Folks::getMenu();
+    }
+
 }
index 0e8eb95..d1e1849 100644 (file)
@@ -38,34 +38,6 @@ class Gollem_Api extends Horde_Registry_Api
     }
 
     /**
-     * TODO
-     */
-    public function prefsHandle($item, $updated)
-    {
-        switch ($item) {
-        case 'columnselect':
-            $columns = Horde_Util::getFormData('columns');
-            if (!empty($columns)) {
-                $GLOBALS['prefs']->setValue('columns', $columns);
-                return true;
-            }
-            break;
-        }
-
-        return $updated;
-    }
-
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Gollem::getMenu();
-    }
-
-    /**
      * Browses through the VFS tree.
      *
      * Each VFS backend is listed as a directory at the top level.  No modify
index 95211c2..1fd3fd5 100644 (file)
@@ -18,4 +18,38 @@ class Gollem_Application extends Horde_Registry_Application
      * @var string
      */
     public $version = 'H4 (2.0-git)';
+
+    /**
+     * Special preferences handling on update.
+     *
+     * @param string $item      The preference name.
+     * @param boolean $updated  Set to true if preference was updated.
+     *
+     * @return boolean  True if preference was updated.
+     */
+    public function prefsHandle($item, $updated)
+    {
+        switch ($item) {
+        case 'columnselect':
+            $columns = Horde_Util::getFormData('columns');
+            if (!empty($columns)) {
+                $GLOBALS['prefs']->setValue('columns', $columns);
+                return true;
+            }
+            break;
+        }
+
+        return $updated;
+    }
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Gollem::getMenu();
+    }
+
 }
index eacc1b1..ffa9bf6 100644 (file)
@@ -134,331 +134,6 @@ class IMP_Api extends Horde_Registry_Api
         }
     }
 
-    /**
-     * Code to run when viewing prefs for this application.
-     *
-     * @param string $group  The prefGroup name.
-     */
-    public function prefsInit($group)
-    {
-        /* Add necessary javascript files here (so they are added to the
-         * document HEAD). */
-        switch ($group) {
-        case 'flags':
-            Horde::addScriptFile('colorpicker.js', 'horde', true);
-            Horde::addScriptFile('flagmanagement.js', 'imp', true);
-
-            Horde::addInlineScript(array(
-                'ImpFlagmanagement.new_prompt = ' . Horde_Serialize::serialize(_("Please enter the label for the new flag:"), Horde_Serialize::JSON, Horde_Nls::getCharset()),
-                'ImpFlagmanagement.confirm_delete = ' . Horde_Serialize::serialize(_("Are you sure you want to delete this flag?"), Horde_Serialize::JSON, Horde_Nls::getCharset())
-            ));
-            break;
-        }
-    }
-
-    /**
-     * TODO
-     */
-    public function prefsHandle($item, $updated)
-    {
-        switch ($item) {
-        case 'sentmailselect':
-            return $this->_prefsSentmailSelect($updated);
-
-        case 'draftsselect':
-            return $updated | $this->_prefsHandleFolders($updated, 'drafts_folder', 'drafts', 'drafts_new');
-
-        case 'spamselect':
-            return $updated | $this->_prefsHandleFolders($updated, 'spam_folder', 'spam', 'spam_new');
-
-        case 'trashselect':
-            return $this->_prefsTrashSelect($updated);
-
-        case 'sourceselect':
-            return $this->_prefsSourceSelect($updated);
-
-        case 'initialpageselect':
-            $this->_prefsInitialPageSelect();
-            return true;
-
-        case 'encryptselect':
-            $this->_prefsEncryptSelect();
-            return true;
-
-        case 'defaultsearchselect':
-            $this->_prefsDefaultSearchSelect();
-            return true;
-
-        case 'soundselect':
-            return $GLOBALS['prefs']->setValue('nav_audio', Horde_Util::getFormData('nav_audio'));
-
-        case 'flagmanagement':
-            $this->_prefsFlagManagement();
-            return false;
-        }
-    }
-
-    /**
-     * Do anything that we need to do as a result of certain preferences
-     * changing.
-     */
-    public function prefsCallback()
-    {
-        global $prefs;
-
-        /* Always check to make sure we have a valid trash folder if delete to
-         * trash is active. */
-        if (($prefs->isDirty('use_trash') || $prefs->isDirty('trash_folder')) &&
-            $prefs->getValue('use_trash') &&
-            !$prefs->getValue('trash_folder') &&
-            !$prefs->getValue('use_vtrash')) {
-                $GLOBALS['notification']->push(_("You have activated move to Trash but no Trash folder is defined. You will be unable to delete messages until you set a Trash folder in the preferences."), 'horde.warning');
-            }
-
-        if ($prefs->isDirty('use_vtrash') || $prefs->isDirty('use_vinbox')) {
-            $imp_search = new IMP_Search();
-            $imp_search->initialize(true);
-        }
-
-        if ($prefs->isDirty('subscribe') || $prefs->isDirty('tree_view')) {
-            $imp_folder = IMP_Folder::singleton();
-            $imp_folder->clearFlistCache();
-            $imaptree = IMP_Imap_Tree::singleton();
-            $imaptree->init();
-        }
-
-        if ($prefs->isDirty('mail_domain')) {
-            $maildomain = preg_replace('/[^-\.a-z0-9]/i', '', $prefs->getValue('mail_domain'));
-            $prefs->setValue('maildomain', $maildomain);
-            if (!empty($maildomain)) {
-                $_SESSION['imp']['maildomain'] = $maildomain;
-            }
-        }
-
-        if ($prefs->isDirty('compose_popup')) {
-            Horde::addInlineScript(array(
-                'if (window.parent.frames.horde_menu) window.parent.frames.horde_menu.location.reload();'
-            ));
-        }
-    }
-
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return IMP::getMenu();
-    }
-
-    /**
-     * Setup notifications handler for the preferences page. This will only
-     * be called if in dimp view mode.
-     */
-    public function prefsStatus()
-    {
-        require_once dirname(__FILE__) . '/Application.php';
-        new IMP_Application(array('init' => array('authentication' => 'none')));
-
-        $notification = Horde_Notification::singleton();
-        $notification->detach('status');
-        $notification->attach('status', array('prefs' => true, 'viewmode' => 'dimp'), 'IMP_Notification_Listener_Status');
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsSentmailSelect($updated)
-    {
-        if (!$GLOBALS['conf']['user']['allow_folders'] ||
-            $GLOBALS['prefs']->isLocked('sent_mail_folder')) {
-            return $updated;
-        }
-
-        $sent_mail_folder = Horde_Util::getFormData('sent_mail_folder');
-        $sent_mail_new = Horde_String::convertCharset(Horde_Util::getFormData('sent_mail_new'), Horde_Nls::getCharset(), 'UTF7-IMAP');
-        $sent_mail_default = $GLOBALS['prefs']->getValue('sent_mail_folder');
-
-        if (empty($sent_mail_folder) && !empty($sent_mail_new)) {
-            $sent_mail_folder = $GLOBALS['imp_imap']->appendNamespace($sent_mail_new);
-        } elseif (($sent_mail_folder == '-1') && !empty($sent_mail_default)) {
-            $sent_mail_folder = $GLOBALS['imp_imap']->appendNamespace($sent_mail_default);
-        }
-
-        if (!empty($sent_mail_folder)) {
-            $imp_folder = IMP_Folder::singleton();
-            if (!$imp_folder->exists($sent_mail_folder)) {
-                $imp_folder->create($sent_mail_folder, $GLOBALS['prefs']->getValue('subscribe'));
-            }
-        }
-        $GLOBALS['identity']->setValue('sent_mail_folder', IMP::folderPref($sent_mail_folder, false));
-
-        return true;
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsHandlefolders($updated, $pref, $folder, $new)
-    {
-        if (!$GLOBALS['conf']['user']['allow_folders']) {
-            return $updated;
-        }
-
-        $folder = Horde_Util::getFormData($folder);
-        if (isset($folder) && !$GLOBALS['prefs']->isLocked($pref)) {
-            $new = Horde_String::convertCharset(Horde_Util::getFormData($new), Horde_Nls::getCharset(), 'UTF7-IMAP');
-            if ($folder == IMP::PREF_NO_FOLDER) {
-                $GLOBALS['prefs']->setValue($pref, '');
-            } else {
-                if (empty($folder) && !empty($new)) {
-                    $folder = $GLOBALS['imp_imap']->appendNamespace($new);
-                    $imp_folder = IMP_Folder::singleton();
-                    if (!$imp_folder->create($folder, $GLOBALS['prefs']->getValue('subscribe'))) {
-                        $folder = null;
-                    }
-                }
-                if (!empty($folder)) {
-                    $GLOBALS['prefs']->setValue($pref, IMP::folderPref($folder, false));
-                    return true;
-                }
-            }
-        }
-
-        return $updated;
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsTrashSelect($updated)
-    {
-        global $prefs;
-
-        if (Horde_Util::getFormData('trash') == IMP::PREF_VTRASH) {
-            if ($prefs->isLocked('use_vtrash')) {
-                return false;
-            }
-
-            $prefs->setValue('use_vtrash', 1);
-            $prefs->setValue('trash_folder', '');
-        } else {
-            if ($prefs->isLocked('trash_folder')) {
-                return false;
-            }
-
-            $updated = $updated | $this->_prefsHandleFolders($updated, 'trash_folder', 'trash', 'trash_new');
-            if ($updated) {
-                $prefs->setValue('use_vtrash', 0);
-                $prefs->setDirty('trash_folder', true);
-            }
-        }
-
-        return $updated;
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsSourceSelect($updated)
-    {
-        $search_sources = Horde_Util::getFormData('search_sources');
-        if (!is_null($search_sources)) {
-            $GLOBALS['prefs']->setValue('search_sources', $search_sources);
-            unset($_SESSION['imp']['cache']['ac_ajax']);
-            $updated = true;
-        }
-
-        $search_fields_string = Horde_Util::getFormData('search_fields_string');
-        if (!is_null($search_fields_string)) {
-            $GLOBALS['prefs']->setValue('search_fields', $search_fields_string);
-            $updated = true;
-        }
-
-        $add_source = Horde_Util::getFormData('add_source');
-        if (!is_null($add_source)) {
-            $GLOBALS['prefs']->setValue('add_source', $add_source);
-            $updated = true;
-        }
-
-        return $updated;
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsInitialPageSelect()
-    {
-        $initial_page = Horde_Util::getFormData('initial_page');
-        $GLOBALS['prefs']->setValue('initial_page', $initial_page);
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsEncryptSelect()
-    {
-        $default_encrypt = Horde_Util::getFormData('default_encrypt');
-        $GLOBALS['prefs']->setValue('default_encrypt', $default_encrypt);
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsDefaultSearchSelect()
-    {
-        $default_search = Horde_Util::getFormData('default_search');
-        $GLOBALS['prefs']->setValue('default_search', $default_search);
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsFlagManagement()
-    {
-        $imp_flags = IMP_Imap_Flags::singleton();
-        $action = Horde_Util::getFormData('flag_action');
-        $data = Horde_Util::getFormData('flag_data');
-
-        if ($action == 'add') {
-            $imp_flags->addFlag($data);
-            return;
-        }
-
-        $def_color = $GLOBALS['prefs']->getValue('msgflags_color');
-
-        // Don't set updated on these actions. User may want to do more actions.
-        foreach ($imp_flags->getList() as $key => $val) {
-            $md5 = hash('md5', $key);
-
-            switch ($action) {
-            case 'delete':
-                if ($data == ('bg_' . $md5)) {
-                    $imp_flags->deleteFlag($key);
-                }
-                break;
-
-            default:
-                /* Change labels for user-defined flags. */
-                if ($val['t'] == 'imapp') {
-                    $label = Horde_Util::getFormData('label_' . $md5);
-                    if (strlen($label) && ($label != $val['l'])) {
-                        $imp_flags->updateFlag($key, array('l' => $label));
-                    }
-                }
-
-                /* Change background for all flags. */
-                $bg = strtolower(Horde_Util::getFormData('bg_' . $md5));
-                if ((isset($val['b']) && ($bg != $val['b'])) ||
-                    (!isset($val['b']) && ($bg != $def_color))) {
-                        $imp_flags->updateFlag($key, array('b' => $bg));
-                }
-                break;
-            }
-        }
-    }
-
     /* IMP-specific functions. */
 
     /**
index c450d48..58e017d 100644 (file)
@@ -162,6 +162,8 @@ class IMP_Application extends Horde_Registry_Application
         IMP::initialize();
     }
 
+    /* Horde_Auth_Application methods. */
+
     /**
      * Return login parameters used on the login page.
      *
@@ -357,4 +359,338 @@ class IMP_Application extends Horde_Registry_Application
         return $auth->listUsers();
     }
 
+    /* Preferences display/handling methods. */
+
+    /**
+     * Code to run when viewing prefs for this application.
+     *
+     * @param string $group  The prefGroup name.
+     *
+     * @return array  A list of variables to export to the prefs display page.
+     */
+    public function prefsInit($group)
+    {
+        /* Add necessary javascript files here (so they are added to the
+         * document HEAD). */
+        switch ($group) {
+        case 'flags':
+            Horde::addScriptFile('colorpicker.js', 'horde', true);
+            Horde::addScriptFile('flagmanagement.js', 'imp', true);
+
+            Horde::addInlineScript(array(
+                'ImpFlagmanagement.new_prompt = ' . Horde_Serialize::serialize(_("Please enter the label for the new flag:"), Horde_Serialize::JSON, Horde_Nls::getCharset()),
+                'ImpFlagmanagement.confirm_delete = ' . Horde_Serialize::serialize(_("Are you sure you want to delete this flag?"), Horde_Serialize::JSON, Horde_Nls::getCharset())
+            ));
+            break;
+        }
+    }
+
+    /**
+     * Special preferences handling on update.
+     *
+     * @param string $item      The preference name.
+     * @param boolean $updated  Set to true if preference was updated.
+     *
+     * @return boolean  True if preference was updated.
+     */
+    public function prefsHandle($item, $updated)
+    {
+        switch ($item) {
+        case 'sentmailselect':
+            return $this->_prefsSentmailSelect($updated);
+
+        case 'draftsselect':
+            return $updated | $this->_prefsHandleFolders($updated, 'drafts_folder', 'drafts', 'drafts_new');
+
+        case 'spamselect':
+            return $updated | $this->_prefsHandleFolders($updated, 'spam_folder', 'spam', 'spam_new');
+
+        case 'trashselect':
+            return $this->_prefsTrashSelect($updated);
+
+        case 'sourceselect':
+            return $this->_prefsSourceSelect($updated);
+
+        case 'initialpageselect':
+            $this->_prefsInitialPageSelect();
+            return true;
+
+        case 'encryptselect':
+            $this->_prefsEncryptSelect();
+            return true;
+
+        case 'defaultsearchselect':
+            $this->_prefsDefaultSearchSelect();
+            return true;
+
+        case 'soundselect':
+            return $GLOBALS['prefs']->setValue('nav_audio', Horde_Util::getFormData('nav_audio'));
+
+        case 'flagmanagement':
+            $this->_prefsFlagManagement();
+            return false;
+        }
+    }
+
+    /**
+     * Do anything that we need to do as a result of certain preferences
+     * changing.
+     */
+    public function prefsCallback()
+    {
+        global $prefs;
+
+        /* Always check to make sure we have a valid trash folder if delete to
+         * trash is active. */
+        if (($prefs->isDirty('use_trash') || $prefs->isDirty('trash_folder')) &&
+            $prefs->getValue('use_trash') &&
+            !$prefs->getValue('trash_folder') &&
+            !$prefs->getValue('use_vtrash')) {
+                $GLOBALS['notification']->push(_("You have activated move to Trash but no Trash folder is defined. You will be unable to delete messages until you set a Trash folder in the preferences."), 'horde.warning');
+            }
+
+        if ($prefs->isDirty('use_vtrash') || $prefs->isDirty('use_vinbox')) {
+            $imp_search = new IMP_Search();
+            $imp_search->initialize(true);
+        }
+
+        if ($prefs->isDirty('subscribe') || $prefs->isDirty('tree_view')) {
+            $imp_folder = IMP_Folder::singleton();
+            $imp_folder->clearFlistCache();
+            $imaptree = IMP_Imap_Tree::singleton();
+            $imaptree->init();
+        }
+
+        if ($prefs->isDirty('mail_domain')) {
+            $maildomain = preg_replace('/[^-\.a-z0-9]/i', '', $prefs->getValue('mail_domain'));
+            $prefs->setValue('maildomain', $maildomain);
+            if (!empty($maildomain)) {
+                $_SESSION['imp']['maildomain'] = $maildomain;
+            }
+        }
+
+        if ($prefs->isDirty('compose_popup')) {
+            Horde::addInlineScript(array(
+                'if (window.parent.frames.horde_menu) window.parent.frames.horde_menu.location.reload();'
+            ));
+        }
+    }
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return IMP::getMenu();
+    }
+
+    /**
+     * Setup notifications handler for the preferences page. This will only
+     * be called if in dimp view mode.
+     */
+    public function prefsStatus()
+    {
+        require_once dirname(__FILE__) . '/Application.php';
+        new IMP_Application(array('init' => array('authentication' => 'none')));
+
+        $notification = Horde_Notification::singleton();
+        $notification->detach('status');
+        $notification->attach('status', array('prefs' => true, 'viewmode' => 'dimp'), 'IMP_Notification_Listener_Status');
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsSentmailSelect($updated)
+    {
+        if (!$GLOBALS['conf']['user']['allow_folders'] ||
+            $GLOBALS['prefs']->isLocked('sent_mail_folder')) {
+            return $updated;
+        }
+
+        $sent_mail_folder = Horde_Util::getFormData('sent_mail_folder');
+        $sent_mail_new = Horde_String::convertCharset(Horde_Util::getFormData('sent_mail_new'), Horde_Nls::getCharset(), 'UTF7-IMAP');
+        $sent_mail_default = $GLOBALS['prefs']->getValue('sent_mail_folder');
+
+        if (empty($sent_mail_folder) && !empty($sent_mail_new)) {
+            $sent_mail_folder = $GLOBALS['imp_imap']->appendNamespace($sent_mail_new);
+        } elseif (($sent_mail_folder == '-1') && !empty($sent_mail_default)) {
+            $sent_mail_folder = $GLOBALS['imp_imap']->appendNamespace($sent_mail_default);
+        }
+
+        if (!empty($sent_mail_folder)) {
+            $imp_folder = IMP_Folder::singleton();
+            if (!$imp_folder->exists($sent_mail_folder)) {
+                $imp_folder->create($sent_mail_folder, $GLOBALS['prefs']->getValue('subscribe'));
+            }
+        }
+        $GLOBALS['identity']->setValue('sent_mail_folder', IMP::folderPref($sent_mail_folder, false));
+
+        return true;
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsHandlefolders($updated, $pref, $folder, $new)
+    {
+        if (!$GLOBALS['conf']['user']['allow_folders']) {
+            return $updated;
+        }
+
+        $folder = Horde_Util::getFormData($folder);
+        if (isset($folder) && !$GLOBALS['prefs']->isLocked($pref)) {
+            $new = Horde_String::convertCharset(Horde_Util::getFormData($new), Horde_Nls::getCharset(), 'UTF7-IMAP');
+            if ($folder == IMP::PREF_NO_FOLDER) {
+                $GLOBALS['prefs']->setValue($pref, '');
+            } else {
+                if (empty($folder) && !empty($new)) {
+                    $folder = $GLOBALS['imp_imap']->appendNamespace($new);
+                    $imp_folder = IMP_Folder::singleton();
+                    if (!$imp_folder->create($folder, $GLOBALS['prefs']->getValue('subscribe'))) {
+                        $folder = null;
+                    }
+                }
+                if (!empty($folder)) {
+                    $GLOBALS['prefs']->setValue($pref, IMP::folderPref($folder, false));
+                    return true;
+                }
+            }
+        }
+
+        return $updated;
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsTrashSelect($updated)
+    {
+        global $prefs;
+
+        if (Horde_Util::getFormData('trash') == IMP::PREF_VTRASH) {
+            if ($prefs->isLocked('use_vtrash')) {
+                return false;
+            }
+
+            $prefs->setValue('use_vtrash', 1);
+            $prefs->setValue('trash_folder', '');
+        } else {
+            if ($prefs->isLocked('trash_folder')) {
+                return false;
+            }
+
+            $updated = $updated | $this->_prefsHandleFolders($updated, 'trash_folder', 'trash', 'trash_new');
+            if ($updated) {
+                $prefs->setValue('use_vtrash', 0);
+                $prefs->setDirty('trash_folder', true);
+            }
+        }
+
+        return $updated;
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsSourceSelect($updated)
+    {
+        $search_sources = Horde_Util::getFormData('search_sources');
+        if (!is_null($search_sources)) {
+            $GLOBALS['prefs']->setValue('search_sources', $search_sources);
+            unset($_SESSION['imp']['cache']['ac_ajax']);
+            $updated = true;
+        }
+
+        $search_fields_string = Horde_Util::getFormData('search_fields_string');
+        if (!is_null($search_fields_string)) {
+            $GLOBALS['prefs']->setValue('search_fields', $search_fields_string);
+            $updated = true;
+        }
+
+        $add_source = Horde_Util::getFormData('add_source');
+        if (!is_null($add_source)) {
+            $GLOBALS['prefs']->setValue('add_source', $add_source);
+            $updated = true;
+        }
+
+        return $updated;
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsInitialPageSelect()
+    {
+        $initial_page = Horde_Util::getFormData('initial_page');
+        $GLOBALS['prefs']->setValue('initial_page', $initial_page);
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsEncryptSelect()
+    {
+        $default_encrypt = Horde_Util::getFormData('default_encrypt');
+        $GLOBALS['prefs']->setValue('default_encrypt', $default_encrypt);
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsDefaultSearchSelect()
+    {
+        $default_search = Horde_Util::getFormData('default_search');
+        $GLOBALS['prefs']->setValue('default_search', $default_search);
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsFlagManagement()
+    {
+        $imp_flags = IMP_Imap_Flags::singleton();
+        $action = Horde_Util::getFormData('flag_action');
+        $data = Horde_Util::getFormData('flag_data');
+
+        if ($action == 'add') {
+            $imp_flags->addFlag($data);
+            return;
+        }
+
+        $def_color = $GLOBALS['prefs']->getValue('msgflags_color');
+
+        // Don't set updated on these actions. User may want to do more actions.
+        foreach ($imp_flags->getList() as $key => $val) {
+            $md5 = hash('md5', $key);
+
+            switch ($action) {
+            case 'delete':
+                if ($data == ('bg_' . $md5)) {
+                    $imp_flags->deleteFlag($key);
+                }
+                break;
+
+            default:
+                /* Change labels for user-defined flags. */
+                if ($val['t'] == 'imapp') {
+                    $label = Horde_Util::getFormData('label_' . $md5);
+                    if (strlen($label) && ($label != $val['l'])) {
+                        $imp_flags->updateFlag($key, array('l' => $label));
+                    }
+                }
+
+                /* Change background for all flags. */
+                $bg = strtolower(Horde_Util::getFormData('bg_' . $md5));
+                if ((isset($val['b']) && ($bg != $val['b'])) ||
+                    (!isset($val['b']) && ($bg != $def_color))) {
+                        $imp_flags->updateFlag($key, array('b' => $bg));
+                }
+                break;
+            }
+        }
+    }
+
 }
index 20172ad..b874ccf 100644 (file)
@@ -48,16 +48,6 @@ class Ingo_Api extends Horde_Registry_Api
     }
 
     /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Ingo::getMenu();
-    }
-
-    /**
      * Removes user data.
      *
      * @param string $user  Name of user to remove data for.
index 659209f..5411618 100644 (file)
@@ -13,4 +13,15 @@ class Ingo_Application extends Horde_Registry_Application
      * @var string
      */
     public $version = 'H4 (2.0-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Ingo::getMenu();
+    }
+
 }
diff --git a/jeta/lib/Api.php b/jeta/lib/Api.php
deleted file mode 100644 (file)
index 066ffa6..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-class Jeta_Api extends Horde_Registry_Api
-{
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Jeta::getMenu();
-    }
-
-}
index b514b5a..f1f53ac 100644 (file)
@@ -2,4 +2,15 @@
 class Jeta_Application extends Horde_Registry_Application
 {
     public $version = 'H4 (2.0-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Jeta::getMenu();
+    }
+
 }
diff --git a/kastalia/lib/Api.php b/kastalia/lib/Api.php
deleted file mode 100644 (file)
index f576d67..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-class Kastalia_Api extends Horde_Registry_Api
-{
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Kastalia::getMenu();
-    }
-
-}
index d602fc2..7c85d4f 100644 (file)
@@ -2,4 +2,15 @@
 class Kastalia_Application extends Horde_Registry_Application
 {
     public $version = '1.0.1';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Kastalia::getMenu();
+    }
+
 }
index 9496033..e35755b 100644 (file)
@@ -34,229 +34,6 @@ class Kronolith_Api extends Horde_Registry_Api
     }
 
     /**
-     * Code to run when viewing prefs for this application.
-     *
-     * @param string $group  The prefGroup name.
-     *
-     * @return array  A list of variables to export to the prefs display page.
-     */
-    public function prefsInit($group)
-    {
-        $out = array();
-
-        if (!$GLOBALS['prefs']->isLocked('day_hour_start') ||
-            !$GLOBALS['prefs']->isLocked('day_hour_end')) {
-            $out['day_hour_start_options'] = array();
-            for ($i = 0; $i <= 48; ++$i) {
-                $out['day_hour_start_options'][$i] = date(($GLOBALS['prefs']->getValue('twentyFour')) ? 'G:i' : 'g:ia', mktime(0, $i * 30, 0));
-            }
-            $out['day_hour_end_options'] = $out['day_hour_start_options'];
-        }
-
-        if (!empty($GLOBALS['conf']['holidays']['enable'])) {
-            if (class_exists('Date_Holidays')) {
-                foreach (Date_Holidays::getInstalledDrivers() as $driver) {
-                    if ($driver['id'] == 'Composite') {
-                        continue;
-                    }
-                    $_prefs['holiday_drivers']['enum'][$driver['id']] = $driver['title'];
-                }
-                asort($_prefs['holiday_drivers']['enum']);
-            } else {
-                $GLOBALS['notification']->push(_("Holidays support is not available on this server."), 'horde.error');
-            }
-        }
-
-        return $out;
-    }
-
-    /**
-     * TODO
-     */
-    public function prefsHandle($item, $updated)
-    {
-        switch ($item) {
-        case 'remote_cal_management':
-            return $this->_prefsRemoteCalManagement($updated);
-
-        case 'shareselect':
-            return $this->_prefsShareSelect($updated);
-
-        case 'holiday_drivers':
-            $this->_prefsHolidayDrivers($updated);
-            return true;
-
-        case 'sourceselect':
-            return $this->_prefsSourceSelect($updated);
-
-        case 'fb_cals_select':
-            $this->_prefsFbCalsSelect($updated);
-            return true;
-
-        case 'default_alarm_management':
-            $GLOBALS['prefs']->setValue('default_alarm', (int)Horde_Util::getFormData('alarm_value') * (int)Horde_Util::getFormData('alarm_unit'));
-            return true;
-        }
-    }
-
-    /**
-     * TODO
-     */
-    public function prefsCallback()
-    {
-        if ($GLOBALS['prefs']->isDirty('event_alarms')) {
-            $alarms = $GLOBALS['registry']->callByPackage('kronolith', 'listAlarms', array($_SERVER['REQUEST_TIME']));
-            if (!is_a($alarms, 'PEAR_Error') && !empty($alarms)) {
-                $horde_alarm = Horde_Alarm::factory();
-                foreach ($alarms as $alarm) {
-                    $alarm['start'] = new Horde_Date($alarm['start']);
-                    $alarm['end'] = new Horde_Date($alarm['end']);
-                    $horde_alarm->set($alarm);
-                }
-            }
-        }
-    }
-
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Kronolith::getMenu();
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsRemoteCalManagement($updated)
-    {
-        $calName = Horde_Util::getFormData('remote_name');
-        $calUrl  = trim(Horde_Util::getFormData('remote_url'));
-        $calUser = trim(Horde_Util::getFormData('remote_user'));
-        $calPasswd = trim(Horde_Util::getFormData('remote_password'));
-
-        $key = Horde_Auth::getCredential('password');
-        if ($key) {
-            $calUser = base64_encode(Secret::write($key, $calUser));
-            $calPasswd = base64_encode(Secret::write($key, $calPasswd));
-        }
-
-        $calActionID = Horde_Util::getFormData('remote_action', 'add');
-
-        if ($calActionID == 'add') {
-            if (!empty($calName) && !empty($calUrl)) {
-                $cals = unserialize($GLOBALS['prefs']->getValue('remote_cals'));
-                $cals[] = array('name' => $calName,
-                    'url'  => $calUrl,
-                    'user' => $calUser,
-                    'password' => $calPasswd);
-                $GLOBALS['prefs']->setValue('remote_cals', serialize($cals));
-                return $updated;
-            }
-        } elseif ($calActionID == 'delete') {
-            $cals = unserialize($GLOBALS['prefs']->getValue('remote_cals'));
-            foreach ($cals as $key => $cal) {
-                if ($cal['url'] == $calUrl) {
-                    unset($cals[$key]);
-                    break;
-                }
-            }
-            $GLOBALS['prefs']->setValue('remote_cals', serialize($cals));
-            return $updated;
-        } elseif ($calActionID == 'edit') {
-            $cals = unserialize($GLOBALS['prefs']->getValue('remote_cals'));
-            foreach ($cals as $key => $cal) {
-                if ($cal['url'] == $calUrl) {
-                    $cals[$key]['name'] = $calName;
-                    $cals[$key]['url'] = $calUrl;
-                    $cals[$key]['user'] = $calUser;
-                    $cals[$key]['password'] = $calPasswd;
-                    break;
-                }
-            }
-            $GLOBALS['prefs']->setValue('remote_cals', serialize($cals));
-            return $updated;
-        }
-
-        return false;
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsShareSelect($updated)
-    {
-        $default_share = Horde_Util::getFormData('default_share');
-        if (!is_null($default_share)) {
-            $sharelist = Kronolith::listCalendars();
-            if ((is_array($sharelist)) > 0 &&
-                isset($sharelist[$default_share])) {
-                $GLOBALS['prefs']->setValue('default_share', $default_share);
-                return true;
-            }
-        }
-
-        return $updated;
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsHolidayDrivers()
-    {
-        $holiday_driversSelected = Horde_Util::getFormData('holiday_drivers');
-        $holiday_driversFiltered = array();
-
-        if (is_array($holiday_driversSelected)) {
-            foreach ($holiday_driversSelected as $holiday_driver) {
-                $holiday_driversFiltered[] = $holiday_driver;
-            }
-        }
-
-        $GLOBALS['prefs']->setValue('holiday_drivers', serialize($holiday_driversFiltered));
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsSourceSelect($updated)
-    {
-        $search_sources = Horde_Util::getFormData('search_sources');
-        if (!is_null($search_sources)) {
-            $GLOBALS['prefs']->setValue('search_sources', $search_sources);
-            $updated = true;
-        }
-
-        $search_fields_string = Horde_Util::getFormData('search_fields_string');
-        if (!is_null($search_fields_string)) {
-            $GLOBALS['prefs']->setValue('search_fields', $search_fields_string);
-            $updated = true;
-        }
-
-        return $updated;
-    }
-
-    /**
-     * TODO
-     */
-    protected function _prefsHandleFbCalsSelect()
-    {
-        $fb_calsSelected = Horde_Util::getFormData('fb_cals');
-        $fb_cals = Kronolith::listCalendars();
-        $fb_calsFiltered = array();
-
-        if (isset($fb_calsSelected) && is_array($fb_calsSelected)) {
-            foreach ($fb_calsSelected as $fb_cal) {
-                $fb_calsFiltered[] = $fb_cal;
-            }
-        }
-
-        $GLOBALS['prefs']->setValue('fb_cals', serialize($fb_calsFiltered));
-    }
-
-    /**
      * Removes user data.
      *
      * @param string $user  Name of user to remove data for.
index d68693c..4d8a527 100644 (file)
@@ -7,4 +7,234 @@
 class Kronolith_Application extends Horde_Registry_Application
 {
     public $version = 'H3 (3.0-git)';
+
+    /**
+     * Code to run when viewing prefs for this application.
+     *
+     * @param string $group  The prefGroup name.
+     *
+     * @return array  A list of variables to export to the prefs display page.
+     */
+    public function prefsInit($group)
+    {
+        $out = array();
+
+        if (!$GLOBALS['prefs']->isLocked('day_hour_start') ||
+            !$GLOBALS['prefs']->isLocked('day_hour_end')) {
+            $out['day_hour_start_options'] = array();
+            for ($i = 0; $i <= 48; ++$i) {
+                $out['day_hour_start_options'][$i] = date(($GLOBALS['prefs']->getValue('twentyFour')) ? 'G:i' : 'g:ia', mktime(0, $i * 30, 0));
+            }
+            $out['day_hour_end_options'] = $out['day_hour_start_options'];
+        }
+
+        if (!empty($GLOBALS['conf']['holidays']['enable'])) {
+            if (class_exists('Date_Holidays')) {
+                foreach (Date_Holidays::getInstalledDrivers() as $driver) {
+                    if ($driver['id'] == 'Composite') {
+                        continue;
+                    }
+                    $_prefs['holiday_drivers']['enum'][$driver['id']] = $driver['title'];
+                }
+                asort($_prefs['holiday_drivers']['enum']);
+            } else {
+                $GLOBALS['notification']->push(_("Holidays support is not available on this server."), 'horde.error');
+            }
+        }
+
+        return $out;
+    }
+
+    /**
+     * Special preferences handling on update.
+     *
+     * @param string $item      The preference name.
+     * @param boolean $updated  Set to true if preference was updated.
+     *
+     * @return boolean  True if preference was updated.
+     */
+    public function prefsHandle($item, $updated)
+    {
+        switch ($item) {
+        case 'remote_cal_management':
+            return $this->_prefsRemoteCalManagement($updated);
+
+        case 'shareselect':
+            return $this->_prefsShareSelect($updated);
+
+        case 'holiday_drivers':
+            $this->_prefsHolidayDrivers($updated);
+            return true;
+
+        case 'sourceselect':
+            return $this->_prefsSourceSelect($updated);
+
+        case 'fb_cals_select':
+            $this->_prefsFbCalsSelect($updated);
+            return true;
+
+        case 'default_alarm_management':
+            $GLOBALS['prefs']->setValue('default_alarm', (int)Horde_Util::getFormData('alarm_value') * (int)Horde_Util::getFormData('alarm_unit'));
+            return true;
+        }
+    }
+
+    /**
+     * Do anything that we need to do as a result of certain preferences
+     * changing.
+     */
+    public function prefsCallback()
+    {
+        if ($GLOBALS['prefs']->isDirty('event_alarms')) {
+            $alarms = $GLOBALS['registry']->callByPackage('kronolith', 'listAlarms', array($_SERVER['REQUEST_TIME']));
+            if (!is_a($alarms, 'PEAR_Error') && !empty($alarms)) {
+                $horde_alarm = Horde_Alarm::factory();
+                foreach ($alarms as $alarm) {
+                    $alarm['start'] = new Horde_Date($alarm['start']);
+                    $alarm['end'] = new Horde_Date($alarm['end']);
+                    $horde_alarm->set($alarm);
+                }
+            }
+        }
+    }
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Kronolith::getMenu();
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsRemoteCalManagement($updated)
+    {
+        $calName = Horde_Util::getFormData('remote_name');
+        $calUrl  = trim(Horde_Util::getFormData('remote_url'));
+        $calUser = trim(Horde_Util::getFormData('remote_user'));
+        $calPasswd = trim(Horde_Util::getFormData('remote_password'));
+
+        $key = Horde_Auth::getCredential('password');
+        if ($key) {
+            $calUser = base64_encode(Secret::write($key, $calUser));
+            $calPasswd = base64_encode(Secret::write($key, $calPasswd));
+        }
+
+        $calActionID = Horde_Util::getFormData('remote_action', 'add');
+
+        if ($calActionID == 'add') {
+            if (!empty($calName) && !empty($calUrl)) {
+                $cals = unserialize($GLOBALS['prefs']->getValue('remote_cals'));
+                $cals[] = array('name' => $calName,
+                    'url'  => $calUrl,
+                    'user' => $calUser,
+                    'password' => $calPasswd);
+                $GLOBALS['prefs']->setValue('remote_cals', serialize($cals));
+                return $updated;
+            }
+        } elseif ($calActionID == 'delete') {
+            $cals = unserialize($GLOBALS['prefs']->getValue('remote_cals'));
+            foreach ($cals as $key => $cal) {
+                if ($cal['url'] == $calUrl) {
+                    unset($cals[$key]);
+                    break;
+                }
+            }
+            $GLOBALS['prefs']->setValue('remote_cals', serialize($cals));
+            return $updated;
+        } elseif ($calActionID == 'edit') {
+            $cals = unserialize($GLOBALS['prefs']->getValue('remote_cals'));
+            foreach ($cals as $key => $cal) {
+                if ($cal['url'] == $calUrl) {
+                    $cals[$key]['name'] = $calName;
+                    $cals[$key]['url'] = $calUrl;
+                    $cals[$key]['user'] = $calUser;
+                    $cals[$key]['password'] = $calPasswd;
+                    break;
+                }
+            }
+            $GLOBALS['prefs']->setValue('remote_cals', serialize($cals));
+            return $updated;
+        }
+
+        return false;
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsShareSelect($updated)
+    {
+        $default_share = Horde_Util::getFormData('default_share');
+        if (!is_null($default_share)) {
+            $sharelist = Kronolith::listCalendars();
+            if ((is_array($sharelist)) > 0 &&
+                isset($sharelist[$default_share])) {
+                $GLOBALS['prefs']->setValue('default_share', $default_share);
+                return true;
+            }
+        }
+
+        return $updated;
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsHolidayDrivers()
+    {
+        $holiday_driversSelected = Horde_Util::getFormData('holiday_drivers');
+        $holiday_driversFiltered = array();
+
+        if (is_array($holiday_driversSelected)) {
+            foreach ($holiday_driversSelected as $holiday_driver) {
+                $holiday_driversFiltered[] = $holiday_driver;
+            }
+        }
+
+        $GLOBALS['prefs']->setValue('holiday_drivers', serialize($holiday_driversFiltered));
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsSourceSelect($updated)
+    {
+        $search_sources = Horde_Util::getFormData('search_sources');
+        if (!is_null($search_sources)) {
+            $GLOBALS['prefs']->setValue('search_sources', $search_sources);
+            $updated = true;
+        }
+
+        $search_fields_string = Horde_Util::getFormData('search_fields_string');
+        if (!is_null($search_fields_string)) {
+            $GLOBALS['prefs']->setValue('search_fields', $search_fields_string);
+            $updated = true;
+        }
+
+        return $updated;
+    }
+
+    /**
+     * TODO
+     */
+    protected function _prefsHandleFbCalsSelect()
+    {
+        $fb_calsSelected = Horde_Util::getFormData('fb_cals');
+        $fb_cals = Kronolith::listCalendars();
+        $fb_calsFiltered = array();
+
+        if (isset($fb_calsSelected) && is_array($fb_calsSelected)) {
+            foreach ($fb_calsSelected as $fb_cal) {
+                $fb_calsFiltered[] = $fb_cal;
+            }
+        }
+
+        $GLOBALS['prefs']->setValue('fb_cals', serialize($fb_calsFiltered));
+    }
+
 }
index bb6afd5..cbafad1 100644 (file)
@@ -34,46 +34,6 @@ class Nag_Api extends Horde_Registry_Api
     }
 
     /**
-     * TODO
-     */
-    public function prefsHandle($item, $updated)
-    {
-        switch ($item) {
-        case 'tasklistselect':
-            $default_tasklist = Horde_Util::getFormData('default_tasklist');
-            if (!is_null($default_tasklist)) {
-                $tasklists = Nag::listTasklists();
-                if (is_array($tasklists) &&
-                    isset($tasklists[$default_tasklist])) {
-                    $GLOBALS['prefs']->setValue('default_tasklist', $default_tasklist);
-                    return true;
-                }
-            }
-            break;
-
-        case 'showsummaryselect':
-            $GLOBALS['prefs']->setValue('summary_categories', Horde_Util::getFormData('summary_categories'));
-            return true;
-
-        case 'defaultduetimeselect':
-            $GLOBALS['prefs']->setValue('default_due_time', Horde_Util::getFormData('default_due_time'));
-            return true;
-        }
-
-        return $updated;
-    }
-
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Nag::getMenu();
-    }
-
-    /**
      * Removes user data.
      *
      * @param string $user  Name of user to remove data for.
index a77904b..b0fbc0a 100644 (file)
@@ -13,4 +13,49 @@ class Nag_Application extends Horde_Registry_Application
      */
     public $version = 'H4 (3.0-git)';
 
+    /**
+     * Special preferences handling on update.
+     *
+     * @param string $item      The preference name.
+     * @param boolean $updated  Set to true if preference was updated.
+     *
+     * @return boolean  True if preference was updated.
+     */
+    public function prefsHandle($item, $updated)
+    {
+        switch ($item) {
+        case 'tasklistselect':
+            $default_tasklist = Horde_Util::getFormData('default_tasklist');
+            if (!is_null($default_tasklist)) {
+                $tasklists = Nag::listTasklists();
+                if (is_array($tasklists) &&
+                    isset($tasklists[$default_tasklist])) {
+                    $GLOBALS['prefs']->setValue('default_tasklist', $default_tasklist);
+                    return true;
+                }
+            }
+            break;
+
+        case 'showsummaryselect':
+            $GLOBALS['prefs']->setValue('summary_categories', Horde_Util::getFormData('summary_categories'));
+            return true;
+
+        case 'defaultduetimeselect':
+            $GLOBALS['prefs']->setValue('default_due_time', Horde_Util::getFormData('default_due_time'));
+            return true;
+        }
+
+        return $updated;
+    }
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Nag::getMenu();
+    }
+
 }
index 514a8cc..da84576 100644 (file)
@@ -41,21 +41,11 @@ class News_Api extends Horde_Registry_Api
     }
 
     /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return News::getMenu();
-    }
-
-    /**
      * Callback for comment API
      *
-     * @param int $id                Internal data identifier
-     * @param string $type      Type of data to retreive (title, owner...)
-     * @param array $params Additional parameters
+     * @param int $id        Internal data identifier
+     * @param string $type   Type of data to retreive (title, owner...)
+     * @param array $params  Additional parameters
      */
     public function commentCallback($id, $type = 'title', $params = null)
     {
index 400bcff..f109d93 100644 (file)
 class News_Application extends Horde_Registry_Application
 {
     public $version = 'H4 (0.1-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return News::getMenu();
+    }
+
 }
index b799261..542171a 100644 (file)
@@ -1,14 +1,4 @@
 <?php
 class Skeleton_Api extends Horde_Registry_Api
 {
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Skeleton::getMenu();
-    }
-
 }
index 8477a2f..acb0842 100644 (file)
@@ -2,4 +2,15 @@
 class Skeleton_Api extends Horde_Registry_Api
 {
     public $version = 'H4 (0.1-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Skeleton::getMenu();
+    }
+
 }
diff --git a/skoli/lib/Api.php b/skoli/lib/Api.php
deleted file mode 100644 (file)
index 2378134..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-class Skoli_Api extends Horde_Registry_Api
-{
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Skoli::getMenu();
-    }
-
-}
index 463357f..132db9f 100644 (file)
@@ -2,4 +2,15 @@
 class Skoli_Application extends Horde_Registry_Application
 {
     public $version = 'H4 (0.1-git)';
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Skoli::getMenu();
+    }
+
 }
index 0f66e9a..caf558e 100644 (file)
@@ -58,75 +58,6 @@ class Turba_Api extends Horde_Registry_Api
     }
 
     /**
-     * Code to run when viewing prefs for this application.
-     *
-     * @param string $group  The prefGroup name.
-     *
-     * @return array  A list of variables to export to the prefs display page.
-     */
-    public function prefsInit($group)
-    {
-        $out = array();
-
-        /* Assign variables for select lists. */
-        if (!$GLOBALS['prefs']->isLocked('default_dir')) {
-            require TURBA_BASE . '/config/sources.php';
-            $out['default_dir_options'] = array();
-            foreach ($cfgSources as $key => $info) {
-                $out['default_dir_options'][$key] = $info['title'];
-            }
-        }
-
-        foreach (Turba::getAddressBooks() as $key => $curSource) {
-            if (empty($curSource['map']['__uid'])) {
-                continue;
-            }
-            if (!empty($curSource['browse'])) {
-                $GLOBALS['_prefs']['sync_books']['enum'][$key] = $curSource['title'];
-            }
-            $sync_books = @unserialize($GLOBALS['prefs']->getValue('sync_books'));
-            if (empty($sync_books)) {
-                $GLOBALS['prefs']->setValue('sync_books', serialize(array(Turba::getDefaultAddressbook())));
-            }
-        }
-
-        return $out;
-    }
-
-    /**
-     * TODO
-     */
-    public function prefsHandle($item, $updated)
-    {
-        switch ($item) {
-        case 'columnselect':
-            $columns = Horde_Util::getFormData('columns');
-            if (!empty($columns)) {
-                $GLOBALS['prefs']->setValue('columns', $columns);
-                return true;
-            }
-            break;
-
-        case 'addressbookselect':
-            $addressbooks = Horde_Util::getFormData('addressbooks');
-            $GLOBALS['prefs']->setValue('addressbooks', str_replace("\r", '', $addressbooks));
-            return true;
-        }
-
-        return $updated;
-    }
-
-    /**
-     * Generate the menu to use on the prefs page.
-     *
-     * @return Horde_Menu  A Horde_Menu object.
-     */
-    public function prefsMenu()
-    {
-        return Turba::getMenu();
-    }
-
-    /**
      * Removes user data.
      *
      * @param string $user  Name of user to remove data for.
index 799240d..d176fc9 100644 (file)
@@ -13,4 +13,78 @@ class Turba_Application extends Horde_Registry_Application
      */
     public $version = 'H3 (3.0-git)';
 
+    /**
+     * Code to run when viewing prefs for this application.
+     *
+     * @param string $group  The prefGroup name.
+     *
+     * @return array  A list of variables to export to the prefs display page.
+     */
+    public function prefsInit($group)
+    {
+        $out = array();
+
+        /* Assign variables for select lists. */
+        if (!$GLOBALS['prefs']->isLocked('default_dir')) {
+            require TURBA_BASE . '/config/sources.php';
+            $out['default_dir_options'] = array();
+            foreach ($cfgSources as $key => $info) {
+                $out['default_dir_options'][$key] = $info['title'];
+            }
+        }
+
+        foreach (Turba::getAddressBooks() as $key => $curSource) {
+            if (empty($curSource['map']['__uid'])) {
+                continue;
+            }
+            if (!empty($curSource['browse'])) {
+                $GLOBALS['_prefs']['sync_books']['enum'][$key] = $curSource['title'];
+            }
+            $sync_books = @unserialize($GLOBALS['prefs']->getValue('sync_books'));
+            if (empty($sync_books)) {
+                $GLOBALS['prefs']->setValue('sync_books', serialize(array(Turba::getDefaultAddressbook())));
+            }
+        }
+
+        return $out;
+    }
+
+    /**
+     * Special preferences handling on update.
+     *
+     * @param string $item      The preference name.
+     * @param boolean $updated  Set to true if preference was updated.
+     *
+     * @return boolean  True if preference was updated.
+     */
+    public function prefsHandle($item, $updated)
+    {
+        switch ($item) {
+        case 'columnselect':
+            $columns = Horde_Util::getFormData('columns');
+            if (!empty($columns)) {
+                $GLOBALS['prefs']->setValue('columns', $columns);
+                return true;
+            }
+            break;
+
+        case 'addressbookselect':
+            $addressbooks = Horde_Util::getFormData('addressbooks');
+            $GLOBALS['prefs']->setValue('addressbooks', str_replace("\r", '', $addressbooks));
+            return true;
+        }
+
+        return $updated;
+    }
+
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Turba::getMenu();
+    }
+
 }