isSpecialFolder intentions vs functionality..

Michael Peddemors <[email protected]>
Newsgroups gmane.mail.squirrelmail.devel
Organization LinuxMagic Inc.
Message-ID <[email protected]>
I noticed that it seems that the intention when plugin hooks set a new 
isSpecialFolder, the autocreation in left_main.php does not have any calls to 
try and autocreate those special folders..

(PS, in version 1.4.9 we stop listing them as available for deletion, 
subscription etc, but not all code is acting accordingly, ie auto deletion, 
autosubscription)

/* If requested and not yet complete, attempt to autocreate folders. */
if ($auto_create_special && !$auto_create_done) {
    $autocreate = array($sent_folder, $trash_folder, $draft_folder);
    foreach( $autocreate as $folder ) {
        if (($folder != '') && ($folder != 'none')) {
            if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
                sqimap_mailbox_create($imapConnection, $folder, '');
            } else if (!sqimap_mailbox_is_subscribed($imapConnection, 
$folder)) {
                sqimap_subscribe($imapConnection, $folder);
            }
        }
    }

    /* Let the world know that autocreation is complete! Hurrah! */
    $auto_create_done = TRUE;
    sqsession_register($auto_create_done, 'auto_create_done');
    /* retrieve the mailboxlist. We do this at a later stage again but if
       the right_frame loads faster then the second call retrieves a cached
       version of the mailboxlist without the newly created folders.
       The second parameter forces a non cached mailboxlist return.
     */
    $boxes = sqimap_mailbox_list($imapConnection,true);
}


I believe that the intention should be that $auto_create should be a dynamic 
list?  eg.. the 'filters' plugin, (Not that we use it) would not get 
it's 'filter' folder auto created.

As well, the person should be auto subscribed to any 
isSpecialMailbox($box,$include_subs=false)

As well, the logic is wrong, if we auto create the folder we miss auto 
subscribing it.

I suggest something like.. (NOT TESTED) the following:

/* If requested and not yet complete, attempt to autocreate folders. */
if ($auto_create_special && !$auto_create_done) {
    // We assume inbox is always there 
    $autocreate = array($sent_folder, $trash_folder, $draft_folder);
    foreach ($squirrelmail_plugin_hooks['special_mailbox'] as $spFolder) {
        $autocreate[] = $spFolder;
    }
    foreach( $autocreate as $folder ) {
        if (($folder != '') && ($folder != 'none')) {
            if ( !sqimap_mailbox_exists($imapConnection, $folder)) {
                sqimap_mailbox_create($imapConnection, $folder, '');
            }
            if (!sqimap_mailbox_is_subscribed($imapConnection, $folder)) {
                sqimap_subscribe($imapConnection, $folder);
            }
        }
    }

    /* Let the world know that autocreation is complete! Hurrah! */
    $auto_create_done = TRUE;
    sqsession_register($auto_create_done, 'auto_create_done');
    /* retrieve the mailboxlist. We do this at a later stage again but if
       the right_frame loads faster then the second call retrieves a cached
       version of the mailboxlist without the newly created folders.
       The second parameter forces a non cached mailboxlist return.
     */
    $boxes = sqimap_mailbox_list($imapConnection,true);
}

I think that instead of using an array to set auto_create folders, it might 
even be better to setSpecialFolers during an earleir stage..

Comments welcome..

-- 
--
"Catch the Magic of Linux..."
------------------------------------------------------------------------
Michael Peddemors - President/CEO - LinuxMagic
Products, Services, Support and Development
Visit us at http://www.linuxmagic.com
------------------------------------------------------------------------
A Wizard IT Company - For More Info http://www.wizard.ca
"LinuxMagic" is a Registered TradeMark of Wizard Tower TechnoServices Ltd.
------------------------------------------------------------------------
604-589-0037 Beautiful British Columbia, Canada

This email and any electronic data contained are confidential and intended 
solely for the use of the individual or entity to which they are addressed. 
Please note that any views or opinions presented in this email are solely 
those of the author and are not intended to  represent those of the company.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: [email protected]
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.