Example #1
0
 /**
  * @param FolderCollection $_folders
  * @param XmlDomNode $_nodeTree
  * @param MailProcessor $_processor
  */
 function GetFoldersTreeXml(&$_folders, &$_nodeTree, &$_processor)
 {
     for ($_i = 0, $_count = $_folders->Count(); $_i < $_count; $_i++) {
         $_folder =& $_folders->Get($_i);
         $_folderNode = new XmlDomNode('folder');
         $_folderNode->AppendAttribute('id', $_folder->IdDb);
         $_folderNode->AppendAttribute('id_parent', $_folder->IdParent);
         $_folderNode->AppendAttribute('type', $_folder->Type);
         $_folderNode->AppendAttribute('sync_type', $_folder->SyncType);
         $_folderNode->AppendAttribute('hide', (int) $_folder->Hide);
         $_folderNode->AppendAttribute('fld_order', (int) $_folder->FolderOrder);
         if ($_folder->SyncType == FOLDERSYNC_DirectMode) {
             $_processor->GetFolderMessageCount($_folder);
         }
         $_folderNode->AppendAttribute('count', $_folder->MessageCount);
         $_folderNode->AppendAttribute('count_new', $_folder->UnreadMessageCount);
         $_folderNode->AppendAttribute('size', $_folder->Size);
         if (ConvertUtils::IsLatin($_folder->Name)) {
             $_folderNode->AppendChild(new XmlDomNode('name', ConvertUtils::ConvertEncoding($_folder->Name, CPAGE_UTF7_Imap, CPAGE_UTF8), true));
         } else {
             $_folderNode->AppendChild(new XmlDomNode('name', ConvertUtils::ConvertEncoding($_folder->Name, $_processor->_account->DefaultIncCharset, CPAGE_UTF8), true));
         }
         $_folderNode->AppendChild(new XmlDomNode('full_name', $_folder->FullName, true));
         if ($_folder->SubFolders != null && $_folder->SubFolders->Count() > 0) {
             $_foldersNode = new XmlDomNode('folders');
             CXmlProcessing::GetFoldersTreeXml($_folder->SubFolders, $_foldersNode, $_processor);
             $_folderNode->AppendChild($_foldersNode);
             unset($_foldersNode);
         }
         $_nodeTree->AppendChild($_folderNode);
         unset($_folderNode, $_folder);
     }
 }
    /**
     * @param int $pageNumber
     * @param string $condition
     * @param FolderCollection $folders
     * @param bool $inHeadersOnly
     * @param Account $account
     * @return WebMailMessageCollection
     */
    function SearchMessages($pageNumber, $condition, &$folders, $inHeadersOnly, &$account)
    {
        $tempstr = '';
        $foldersId = '';
        foreach (array_keys($folders->Instance()) as $key) {
            $folder =& $folders->Get($key);
            $foldersId .= $foldersId == '' ? $folder->IdDb : ',' . $folder->IdDb;
        }
        $filter = '';
        $asc = true;
        $this->_setSortOrder($account->DefaultOrder, $filter, $asc);
        $condition = str_replace('[', '[[]', $condition);
        $condition = $this->_escapeString('%' . $condition . '%');
        if ($inHeadersOnly) {
            if (($pageNumber - 1) * $account->MailsPerPage > 0) {
                $tempstr = ' AND id_msg NOT IN 
								(SELECT TOP %d id_msg FROM %sawm_messages 
								WHERE id_acct = %d AND id_folder_db IN (%s) AND	
								(from_msg LIKE %s OR to_msg LIKE %s OR cc_msg LIKE %s OR bcc_msg
								LIKE %s OR subject LIKE %s) ORDER BY %s %s)';
                $tempstr = sprintf($tempstr, ($pageNumber - 1) * $account->MailsPerPage, $this->_settings->DbPrefix, $account->Id, $foldersId, $condition, $condition, $condition, $condition, $condition, $filter, $asc ? 'ASC' : 'DESC');
            }
            $sql = 'SELECT TOP %d id_msg, %s AS uid, id_folder_db, from_msg, to_msg, cc_msg,
							bcc_msg, subject, %s AS nmsg_date, size, priority, x_spam,
							attachments, seen, flagged, deleted, replied, forwarded, grayed
						FROM %sawm_messages
						WHERE id_acct = %d AND id_folder_db IN (%s) AND	
							(from_msg LIKE %s OR to_msg LIKE %s OR cc_msg LIKE %s OR bcc_msg
							LIKE %s OR subject LIKE %s)%s
						ORDER BY %s %s';
            return sprintf($sql, $account->MailsPerPage, $this->_getMsgIdUidFieldName(true, $account->MailProtocol), CDateTime::GetMsSqlDateFormat('msg_date'), $this->_settings->DbPrefix, $account->Id, $foldersId, $condition, $condition, $condition, $condition, $condition, $tempstr, $filter, $asc ? 'ASC' : 'DESC');
        } else {
            if (($pageNumber - 1) * $account->MailsPerPage > 0) {
                $tempstr = ' AND id_msg NOT IN 
							(SELECT TOP %d id_msg FROM %sawm_messages
							WHERE id_acct = %d AND id_folder_db IN (%s) AND	
								(from_msg LIKE %s OR to_msg LIKE %s OR cc_msg LIKE %s OR bcc_msg
								LIKE %s OR subject LIKE %s OR body_text LIKE %s) ORDER BY %s %s)';
                $tempstr = sprintf($tempstr, ($pageNumber - 1) * $account->MailsPerPage, $this->_settings->DbPrefix, $account->Id, $foldersId, $condition, $condition, $condition, $condition, $condition, $condition, $filter, $asc ? 'ASC' : 'DESC');
            }
            $sql = 'SELECT TOP %d id_msg, %s AS uid, id_folder_db, from_msg, to_msg, cc_msg,
							bcc_msg, subject, %s AS nmsg_date, size, priority, x_spam,
							attachments, seen, flagged, deleted, replied, forwarded, grayed
						FROM %sawm_messages
						WHERE id_acct = %d AND id_folder_db IN (%s) AND	
							(from_msg LIKE %s OR to_msg LIKE %s OR cc_msg LIKE %s OR bcc_msg
							LIKE %s OR subject LIKE %s OR body_text LIKE %s)%s
						ORDER BY %s %s';
            return sprintf($sql, $account->MailsPerPage, $this->_getMsgIdUidFieldName(true, $account->MailProtocol), CDateTime::GetMsSqlDateFormat('msg_date'), $this->_settings->DbPrefix, $account->Id, $foldersId, $condition, $condition, $condition, $condition, $condition, $condition, $tempstr, $filter, $asc ? 'ASC' : 'DESC');
        }
    }
 /**
  * @param FolderCollection $folderCollection
  * @return String
  */
 function CreateHtmlFolderTree($folderCollection)
 {
     $out = '';
     for ($i = 0, $c = $folderCollection->Count(); $i < $c; $i++) {
         $folder =& $folderCollection->Get($i);
         $foldername = '';
         if (ConvertUtils::IsLatin($folder->Name)) {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->_pagebuilder->_proc->account->GetUserCharset());
         } else {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->_pagebuilder->_proc->account->DefaultIncCharset, $this->_pagebuilder->_proc->account->GetUserCharset());
         }
         $isselect = '';
         if ($this->_pagebuilder->_proc->currentFolder && $this->_pagebuilder->_proc->currentFolder->IdDb == $folder->IdDb) {
             $isselect = 'class="wm_select_folder"';
         }
         if (!$folder->Hide) {
             $out .= '<div style="padding-left: ' . $folder->Level * 8 . 'px;" ' . $isselect . '>';
             $out .= '<a href="?' . FOLDER_ID . '=' . $folder->IdDb . '">';
             $out .= '<img src="./skins/' . $this->_pagebuilder->SkinName() . '/folders/' . $this->GetFolderImg($folder) . '" />';
             switch ($folder->Type) {
                 default:
                 case FOLDERTYPE_Custom:
                     $out .= ConvertUtils::WMHtmlSpecialChars($foldername);
                     break;
                 case FOLDERTYPE_Inbox:
                     $out .= FolderInbox;
                     break;
                 case FOLDERTYPE_Drafts:
                     $out .= FolderDrafts;
                     break;
                 case FOLDERTYPE_SentItems:
                     $out .= FolderSentItems;
                     break;
                 case FOLDERTYPE_Trash:
                     $out .= FolderTrash;
                     break;
             }
             if ($folder->SyncType == FOLDERSYNC_DirectMode) {
                 $out .= '&nbsp;<span id="cnt_' . $folder->IdDb . '" class="wm_hide"></span></a>';
                 $out .= '&nbsp;<span title="' . ConvertUtils::AttributeQuote(DirectAccessTitle) . '" class="wm_folder_direct_mode">&nbsp;' . DirectAccess . '&nbsp;</span>';
             } else {
                 $out .= $folder->UnreadMessageCount > 0 ? '&nbsp;<span id="cnt_' . $folder->IdDb . '">(' . $folder->UnreadMessageCount . ')</span></a>' : '&nbsp;<span id="cnt_' . $folder->IdDb . '"></span></a>';
             }
             $out .= '</div>';
             if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
                 $out .= $this->CreateHtmlFolderTree($folder->SubFolders);
             }
         }
     }
     return $out;
 }
Example #4
0
 /**
  * @param FolderCollection $folders
  * @return bool
  */
 function CreateFolders(&$folders)
 {
     $result = true;
     if ($folders == null) {
         return $result;
     }
     for ($i = 0, $count = $folders->Count(); $i < $count; $i++) {
         $folder =& $folders->Get($i);
         $result &= $this->CreateFolder($folder);
         if (!is_null($folder->SubFolders)) {
             for ($j = 0, $cc = $folder->SubFolders->Count(); $j < $cc; $j++) {
                 $subFolder =& $folder->SubFolders->Get($j);
                 $subFolder->IdParent = $folder->IdDb;
                 unset($subFolder);
             }
             $result &= $this->CreateFolders($folder->SubFolders);
         }
         unset($folder);
     }
     return $result;
 }
Example #5
0
 /**
  * @param FolderCollection $folders
  * @return bool
  */
 function CreateFolders(&$folders)
 {
     $result = true;
     if ($folders == null) {
         return $result;
     }
     for ($i = 0, $c = $folders->Count(); $i < $c; $i++) {
         $folder =& $folders->Get($i);
         if ($result && $folder) {
             $result &= $this->CreateFolder($folder);
             if ($folder->SubFolders && $result) {
                 for ($j = 0, $t = count($folder->SubFolders->Instance()); $j < $t; $j++) {
                     $subFolder =& $folder->SubFolders->Get($j);
                     $subFolder->IdParent = $folder->IdDb;
                     unset($subFolder);
                 }
                 $result &= $this->CreateFolders($folder->SubFolders);
             }
         }
         unset($folder);
     }
     return $result;
 }
    /**
     * @param FolderCollection $folders
     * @param int $messagesCount
     * @param int $messagesSize
     * @param Account $account
     * @return string
     */
    function CreateHtmlFolderTree(&$folders, &$messagesCount, &$messagesSize, &$account)
    {
        $out = array('', '');
        for ($i = 0, $count = $folders->Count(); $i < $count; $i++) {
            $folder =& $folders->Get($i);
            if ($i > 0) {
                $pr_folder =& $folders->Get($i - 1);
            }
            if ($i < $count - 1) {
                $nx_folder =& $folders->Get($i + 1);
            }
            $messagesCount += $folder->MessageCount;
            $messagesSize += $folder->Size;
            $foldername = '';
            if (ConvertUtils::IsLatin($folder->Name)) {
                $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
            } else {
                $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->setaccount->_pagebuilder->_proc->account->DefaultIncCharset, $this->setaccount->_pagebuilder->_proc->account->GetUserCharset());
            }
            $folderUrl = 'skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/' . GetFolderImg($folder->Type, MAILPROTOCOL_POP3);
            $hasChild = $folder->SubFolders != null;
            $hasMessages = $folder->MessageCount > 0;
            $disab = $hasChild || $hasMessages ? 'disabled="disabled" ' : '';
            $disab = $account->MailProtocol == MAILPROTOCOL_POP3 ? '' : $disab;
            $checkbox = $folder->Type == FOLDERTYPE_Custom ? '<input type="checkbox" id="ch_0" name="folders[' . ConvertUtils::AttributeQuote($folder->IdDb) . ']" value="' . ConvertUtils::AttributeQuote($folder->FullName) . '" class="wm_checkbox" ' . $disab . '/>' : '';
            $uphref = $i < 1 ? '<img src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/up_inactive.gif" />' : '<a onclick="return DoAlert();" href="' . ACTIONFILE . '?action=update&req=folderorder&cf_id=' . $folder->IdDb . '&rf_id=' . $pr_folder->IdDb . '"><img
					src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/up.gif" /></a>';
            $downhref = $i > $count - 2 ? '<img src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/down_inactive.gif" />' : '<a onclick="return DoAlert();" href="' . ACTIONFILE . '?action=update&req=folderorder&cf_id=' . $folder->IdDb . '&rf_id=' . $nx_folder->IdDb . '"><img
					src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/down.gif" /></a>';
            $eyeimg = $folder->Hide ? 'hide.gif' : 'show.gif';
            switch ($folder->Type) {
                default:
                case FOLDERTYPE_Custom:
                    $foldername = ConvertUtils::WMHtmlSpecialChars($foldername);
                    break;
                case FOLDERTYPE_Inbox:
                    $foldername = FolderInbox;
                    break;
                case FOLDERTYPE_Drafts:
                    $foldername = FolderDrafts;
                    break;
                case FOLDERTYPE_SentItems:
                    $foldername = FolderSentItems;
                    break;
                case FOLDERTYPE_Trash:
                    $foldername = FolderTrash;
                    break;
            }
            $nameSting = $folder->Type == FOLDERTYPE_Custom ? '<form action="' . ACTIONFILE . '?action=rename&req=folder" id="folder_form_' . $folder->IdDb . '" method="POST">
					<img src="' . $folderUrl . '" />
					<a href="#" onclick="EditFolder(' . $folder->IdDb . ');" id="folder_a_' . $folder->IdDb . '">' . $foldername . '</a>
					<input type="text" class="wm_hide" name="folderid" value="' . $folder->IdDb . '">
					<input type="text" class="wm_hide" name="fname" maxLength="30" id="folder_i_' . $folder->IdDb . '" value="' . ConvertUtils::AttributeQuote($foldername) . '"/></form>' : '<img src="' . ConvertUtils::AttributeQuote($folderUrl) . '" /> ' . $foldername;
            $imap4SyncTd = $this->setaccount->_editAccount->MailProtocol == MAILPROTOCOL_IMAP4 ? '
						<td><form id="syncform_' . $folder->IdDb . '" action="' . ACTIONFILE . '?action=update&req=foldersync" method="POST">
							<input type="hidden" name="folderid" value="' . $folder->IdDb . '">
							<select onchange="document.getElementById(\'syncform_' . $folder->IdDb . '\').submit();" name="synctype">
								<option value="' . FOLDERSYNC_DontSync . '" ' . ($folder->SyncType == FOLDERSYNC_DontSync ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNo . '</option>
								<option value="' . FOLDERSYNC_NewHeadersOnly . '" ' . ($folder->SyncType == FOLDERSYNC_NewHeadersOnly ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNewHeaders . '</option>
								<option value="' . FOLDERSYNC_AllHeadersOnly . '" ' . ($folder->SyncType == FOLDERSYNC_AllHeadersOnly ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeAllHeaders . '</option>
								<option value="' . FOLDERSYNC_NewEntireMessages . '" ' . ($folder->SyncType == FOLDERSYNC_NewEntireMessages ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeNewMessages . '</option>
								<option value="' . FOLDERSYNC_AllEntireMessages . '" ' . ($folder->SyncType == FOLDERSYNC_AllEntireMessages ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeAllMessages . '</option>
								<option value="' . FOLDERSYNC_DirectMode . '" ' . ($folder->SyncType == FOLDERSYNC_DirectMode ? 'selected="selected"' : '') . '>' . JS_LANG_SyncTypeDirectMode . '</option>
							</select></form>
						</td>
							' : '<td class="wm_hide"></td>';
            $out[0] .= '
						<tr>
							<td>' . $checkbox . '</td>
							<td class="wm_settings_mf_folder">
							<div style="padding-left: ' . $folder->Level * 8 . 'px;">
							' . $nameSting . '
							</div></td>
							<td>' . $folder->MessageCount . '</td>
							<td>' . GetFriendlySize($folder->Size) . '</td>
							' . $imap4SyncTd . '
							<td><a href="#" onclick="if (!DoAlert()) return false; document.location=\'' . ACTIONFILE . '?action=update&req=folderhide&folderid=' . $folder->IdDb . '\'"><img class="wm_settings_mf_show_hide" src="skins/' . $this->setaccount->_pagebuilder->SkinName() . '/folders/' . $eyeimg . '"></a>
							</td>
							<td class="wm_settings_mf_up_down">
								' . $uphref . $downhref . '
							</td>
						</tr>			
				';
            $out[1] .= '<option value="' . $folder->IdDb . '">' . str_repeat('&nbsp;', $folder->Level * 3) . $foldername . '</option>' . "\r\n";
            if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
                $temp = $this->CreateHtmlFolderTree($folder->SubFolders, $messagesCount, $messagesSize, $account);
                $out[0] .= $temp[0];
                $out[1] .= $temp[1];
            }
        }
        return $out;
    }
 /**
  * @param FolderCollection $folderCollection
  * @return String
  */
 function CreateFolderTree($folderCollection)
 {
     $out = '';
     for ($i = 0, $c = $folderCollection->Count(); $i < $c; $i++) {
         $folder =& $folderCollection->Get($i);
         if ($folder->Hide) {
             continue;
         }
         if ($folder->SyncType == FOLDERSYNC_DirectMode && $this->_pagebuilder->_proc->account->MailProtocol == MAILPROTOCOL_POP3) {
             continue;
         }
         $foldername = '';
         if (ConvertUtils::IsLatin($folder->Name)) {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, CPAGE_UTF7_Imap, $this->_pagebuilder->_proc->account->GetUserCharset());
         } else {
             $foldername = ConvertUtils::ConvertEncoding($folder->Name, $this->_pagebuilder->_proc->account->DefaultIncCharset, $this->_pagebuilder->_proc->account->GetUserCharset());
         }
         $out .= '<div onclick="MoveToFolder(\'' . $folder->IdDb . '\');" class="wm_menu_item" onmouseover="this.className=\'wm_menu_item_over\';" onmouseout="this.className=\'wm_menu_item\';">' . str_repeat('&nbsp;', (int) $folder->Level * 4);
         switch ($folder->Type) {
             default:
             case FOLDERTYPE_Custom:
                 $out .= ConvertUtils::WMHtmlSpecialChars($foldername);
                 break;
             case FOLDERTYPE_Inbox:
                 $out .= FolderInbox;
                 break;
             case FOLDERTYPE_Drafts:
                 $out .= FolderDrafts;
                 break;
             case FOLDERTYPE_SentItems:
                 $out .= FolderSentItems;
                 break;
             case FOLDERTYPE_Trash:
                 $out .= FolderTrash;
                 break;
         }
         $out .= '</div>';
         if ($folder->SubFolders != null && $folder->SubFolders->Count() > 0) {
             $out .= $this->CreateFolderTree($folder->SubFolders);
         }
     }
     return $out;
 }