Search The ForumSearch   RegisterRegister  LoginLogin

AfterLogic WebMail Pro

 AfterLogic Forum : AfterLogic WebMail Pro
Subject Topic: Problem with deletes Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
rob
Groupie
Groupie


Joined: 03 September 2008
Location: Canada
Online Status: Offline
Posts: 60
Posted: 17 September 2008 at 2:52pm | IP Logged Quote rob

We just noticed that when deleting an email from a folder such as the inbox, that it appears to delete the record from the database and then creates a new record in the trash folder for the piece of email.

For example, if the email had message id of 21601 in the awm_messages table, when i click delete, that id disappears and a new id of 25596 for example appears and its the same message.

How can I tweak the system to make it use the same message id? Ideally the system should just be doing an update of the record to set the in_folder_db column to that of the Trash folder.

Please help.

Rob
Back to Top View rob's Profile Search for other posts by rob
 
rob
Groupie
Groupie


Joined: 03 September 2008
Location: Canada
Online Status: Offline
Posts: 60
Posted: 17 September 2008 at 4:40pm | IP Logged Quote rob

After further investigation i see that a new id in the awm_messages table only occurs with a delete action and not with a move action.

If a piece of mail is dragged to another folder, or moved from the select option it retains the original id and only the in_folder_db value is updated.

But if delete is used to put the message into the trash folder, a new record is created then. We would like to simply use a move method into trash.
Back to Top View rob's Profile Search for other posts by rob
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 18 September 2008 at 5:39am | IP Logged Quote Andrew

We've sent you the update via e-mail.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
rob
Groupie
Groupie


Joined: 03 September 2008
Location: Canada
Online Status: Offline
Posts: 60
Posted: 18 September 2008 at 8:28am | IP Logged Quote rob

Thank you for the update. We have applied it and it appears to work fine.

Here it is for others for reference:

File class_mailprocessor.php (~635):

        function MoveMessages(&$messageIdUidSet, &$fromFolder, &$toFolder)
        {
                $GLOBALS[MailDefaultCharset] = $this->_account->DefaultIncCharset;
                $GLOBALS[MailOutputCharset] = $this->_account->DefaultOutCharset;
       
                $messageIdSet = array_keys($messageIdUidSet);
                $messageUidSet = array_values($messageIdUidSet);
       
                if (!$this->DbStorage->Connect() || !$this->MailStorage->Connect())
                {
                          return false;
                }
       
                $result = true;
                switch ($this->_account->MailProtocol)
                {
                          case MAILPROTOCOL_POP3:
                          case MAILPROTOCOL_WMSERVER:
                           
                                   switch ($fromFolder->SyncType)
                                   {
                                            case FOLDERSYNC_DontSync:
                                                     return $this->DbStorage->MoveMessages($messageIdSet, false, $fromFolder, $toFolder);
                                                     break;   
                                            default:
                                                     $downloadIds = $this->DbStorage->GetDownloadedIds($messageIdSet, $fromFolder, $this->_account->Id);
                                                     foreach ($messageIdSet as $IdMsg)
                                                     {
                                                               $arrId = array($IdMsg);
                                                               $arrUid = array($messageIdUidSet[$IdMsg]);
                                                               $arrIdUid[$IdMsg] = $messageIdUidSet[$IdMsg];
                                                               if ($result)
                                                               {
                                                                       if (in_array($IdMsg, $downloadIds))
                                                                       {
                                                                                $result &= $this->DbStorage->MoveMessages($arrId, false, $fromFolder, $toFolder);
                                                                       }
                                                                       else
                                                                       {
                                                                                $result &= $this->DbStorage->SaveMessages($this->GetMessages($ arrIdUid, $fromFolder), $toFolder);
                                                                                if ($result && $fromFolder->SyncType != FOLDERSYNC_DirectMode)
                                                                                {
                                                                                          $result &= $this->DbStorage->DeleteMessages($arrId, false, $fromFolder);
                                                                                }
                                                                                else
                                                                                {
                                                                                          $result &= $this->MailStorage->DeleteMessages($arrUid, true, $fromFolder);
                                                                                }
                                                                       }
                                                               }
                                                     }
                                             
                                                     /* OLD
                                                     $result = $this->DbStorage->SaveMessages($this->GetMessages($ messageIdUidSet, $fromFolder), $toFolder);
                                                     if ($result)
                                                     {
                                                               if ($result && $fromFolder->SyncType != FOLDERSYNC_DirectMode)
                                                               {
                                                                       $result &= $this->DbStorage->DeleteMessages($messageIdSet, false, $fromFolder);
                                                               }
                                                               else
                                                               {
                                                                       $result &= $this->MailStorage->DeleteMessages($messageUidSet, true, $fromFolder);
                                                               }
                                                     }*/
                                                     return $result;
                                                     break;
                                   }                                    
                                   break;
          
The previous loop which re-creates records is commented (/* OLD ... */), the new loop is above that comment.

Also, you should add the following function into DbStorage class in class_dbstorage.php file:


                function GetDownloadedIds($messageIdSet, $fromFolder, $accountId)
                {
                          $downloadedMsgIdSet = array();

                          $sql = 'SELECT id_msg FROM %sawm_messages
                                                     WHERE id_acct = %d AND downloaded = 1 AND id_folder_db = %d AND id_msg IN (%s)';

                          $sql = sprintf($sql, $this->_settings->DbPrefix, $accountId, $fromFolder->IdDb, implode(', ', $messageIdSet));

                          if ($this->_dbConnection->Execute($sql))
                          {
                                   while ($row = $this->_dbConnection->GetNextRecord())
                                   {
                                            $downloadedMsgIdSet[] = $row->id_msg;
                                   }
                          }

                          return $downloadedMsgIdSet;
                }
Back to Top View rob's Profile Search for other posts by rob
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 19 September 2008 at 12:15am | IP Logged Quote Andrew

Please don't publish fixes we sent you via e-mail on this forum anymore. These fixes are specific for certain versions of the product and customers may apply these changes for inappropriate version and get some bugs. We don't publish such fixes here because we try to prevent this. When somebody asks us to provide him with a fix which mentioned but not published on the forum, our experts check if it can be applied to the latest version or the version the customer use and make some changes if necessary before providing the fix.

Moreover, although WebMail Pro is shipped with full source code, it's not an open source product and only our company is allowed to decide whether to publish a part of the source code or not.

BTW, this fix has been included into the production version.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
rob
Groupie
Groupie


Joined: 03 September 2008
Location: Canada
Online Status: Offline
Posts: 60
Posted: 19 September 2008 at 9:42am | IP Logged Quote rob

Terribly sorry here. With the 24 hour delay in support replies i figured this could help others without having to wait a full day for a reply.

Maybe a private forum for paid members would come in handy so that members can help each other and build a knowledgebase that everyone can benefit from.

Back to Top View rob's Profile Search for other posts by rob
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide