[cvs] [Wiki] changed: CustomizingPreferences

Ben Chavet ben at horde.org
Thu Oct 4 18:56:17 UTC 2007


ben  Thu, 04 Oct 2007 11:56:17 -0700

Modified page: http://wiki.horde.org/CustomizingPreferences
New Revision:  3.1
Change log:  add an _imp_hook_postlogin example

@@ -217,8 +217,40 @@
         return 'a:1:{i:0;s:' . strlen($uid) . ':"' . $uid . '";}';
     }
 }
 </code>
+
+This function makes sure that the default "Special" folders exist when a
user logs in.
+<code type="php">
+if (!function_exists('_imp_hook_postlogin')) {
+    function _imp_hook_postlogin($actionID, $isLogin)
+    {
+        $folderlist = $GLOBALS['registry']->callByPackage('imp',
'folderlist', array());
+
+        $folder = $GLOBALS['prefs']->getValue('drafts_folder');
+        if (!in_array($folder, array_keys($folderlist))) {
+            $result = $GLOBALS['registry']->callByPackage('imp',
'createFolder', array('folder' => $folder));
+        }
+
+        $folder = $GLOBALS['prefs']->getValue('sent_mail_folder');
+        if (!in_array($folder, array_keys($folderlist))) {
+            $result = $GLOBALS['registry']->callByPackage('imp',
'createFolder', array('folder' => $folder));
+        }
+
+        $folder = $GLOBALS['prefs']->getValue('spam_folder');
+        if (!in_array($folder, array_keys($folderlist))) {
+            $result = $GLOBALS['registry']->callByPackage('imp',
'createFolder', array('folder' => $folder));
+        }
+
+        $folder = $GLOBALS['prefs']->getValue('trash_folder');
+        if (!in_array($folder, array_keys($folderlist))) {
+            $result = $GLOBALS['registry']->callByPackage('imp',
'createFolder', array('folder' => $folder));
+        }
+
+    }
+}
+</code>
+
 --Ben Chavet

 ----


More information about the cvs mailing list