[cvs] [Wiki] created: ImpAutomaticDefaultFolderCreation
Wiki Guest
wikiguest at horde.org
Wed Jun 7 11:30:47 PDT 2006
guest [64.9.120.91] Wed, 07 Jun 2006 11:30:47 -0700
Created page: http://wiki.horde.org/ImpAutomaticDefaultFolderCreation
After scouring Google for several days looking for a solution to this common question, and after subtle prodding on the Imp mailing list, I decided to roll my own method of making IMP create the default sent, trash, drafts, and spam folders as defined in "horde/imp/config/prefs.php" the first time a user logs in. This code was written for IMP 4.1.x.
What we need to do is create a Maintenance Task in the IMP The first thing we need to do is create a maintenance task. This is done by creating a PHP script called "horde/imp/lib/Maintenance/Tasks/create_default_folders.php" which contains the following class:
<code type="php">
<?php
class Maintenance_Task_create_default_folders extends Maintenance_Task {
function doMaintenance() {
global $imp, $prefs, $notification;
require_once IMP_BASE . '/lib/Folder.php';
$folder_options = array(
'sent_mail_folder', 'drafts_folder', 'trash_folder', 'spam_folder'
);
foreach ($folder_options as $this_folder) {
$folder = IMP::folderPref($prefs->getValue($this_folder, true), true);
if ($folder) {
$imp_folder = &IMP_Folder::singleton();
if (!$imp_folder->exists($folder)) {
$imp_folder->create($folder, true);
}
}
}
return true;
}
function describeMaintenance() {
return _("This process makes sure the default folders are created on your account.");
}
}
?>
</code>
Now you'll need to edit "horde/imp/lib/Maintenance/imp.php" to reflect this change:
<code type="php">
var $maint_tasks = array(
'tos_agreement' => MAINTENANCE_FIRST_LOGIN,
'create_default_folders' => MAINTENANCE_FIRST_LOGIN,
// If you have users who often "accidently" delete their folders, you can do this instead:
// 'create_default_folders' => MAINTENANCE_EVERY,
'fetchmail_login' => MAINTENANCE_EVERY,
'rename_sentmail_monthly' => MAINTENANCE_MONTHLY,
'delete_sentmail_monthly' => MAINTENANCE_MONTHLY,
'delete_attachments_monthly' => MAINTENANCE_MONTHLY,
'purge_trash' => MAINTENANCE_MONTHLY
);
</code>
Finally, add a preference in "horde/imp/config/prefs.php" like this:
<code type="php">
$_prefs['create_default_folders'] = array(
'value' => 1,
'locked' => false,
'shared' => false,
'type' => 'implicit');
</code>
More information about the cvs
mailing list