OsStatus ManageFoldersWebCGI::getAllFolders(UtlString* out) { UtlString statusStr = " "; if( m_status == ADD_FOLDER_SUCCESS ) statusStr = "Folder added successfully" ; else if( m_status == EDIT_FOLDER_SUCCESS ) statusStr = "Folder edited successfully" ; else if( m_status == DELETE_FOLDER_SUCCESS ) statusStr = "Folder deleted successfully" ; else if( m_status == DELETE_FOLDER_FAILED ) statusStr = "Failed to delete folder. Please try again." ; // Get the folder names UtlSortedList folderList; MailboxManager* pMailboxManager = MailboxManager::getInstance(); pMailboxManager->getMailboxFolders( m_mailboxIdentity, folderList ); // Check if mailbox has folders other than the standard 3 UtlString dynamicHtml = HTML_BEGIN \ WEBPAGE_SNIPPET1 \ "Manage Folders" \ WEBPAGE_SNIPPET2 \ "manage_folders_page.htm" \ WEBPAGE_SNIPPET3 ; UtlString personalFolders ; bool personalFoldersFound = false ; while( folderList.entries() > 0 ) { // Show the list of folders so that the user can pick the one they want UtlString* rwFolderName = (UtlString*) folderList.removeAt(0); UtlString folderName = rwFolderName->data(); delete rwFolderName ; UtlString editStr = " " ; UtlString deleteStr = " " ; if( (folderName.compareTo("inbox", UtlString::ignoreCase) != 0) && (folderName.compareTo("saved", UtlString::ignoreCase) != 0) && (folderName.compareTo("deleted", UtlString::ignoreCase) != 0) ) { personalFoldersFound = true; // escape the folder name UtlString escapedFolderName = folderName ; HttpMessage::escape( escapedFolderName ); UtlString redirectUrl = m_cgiUrl + "?fromweb=yes&oldfoldername=" + escapedFolderName + "&action=" ; editStr = "<a href=\"" + redirectUrl + "geteditfolderui\"><img src=\"/images/editicon.gif\" width=\"12\" height=\"12\" border=\"0\"></a>"; deleteStr = "<a href=\"" + redirectUrl + "deletefolder\" onClick=\"return confirm('" + DELETE_CONFIRMATION + "');\"><img src=\"/images/del.gif\" width=\"12\" height=\"12\" border=\"0\"></a>"; if( personalFolders.isNull() ) { personalFolders = statusStr + WEBPAGE_SNIPPET4 + "<tr> \n" \ "<th>Personal Folder</th>\n" \ "<th width=\"15%\">Edit</th>\n" \ "<th width=\"15%\">Delete</th>\n" \ "</tr>\n" ; } personalFolders += "<tr> \n" \ "<td>" + folderName + "</td> \n" \ "<td align=\"center\">" + editStr + "</td> \n" \ "<td align=\"center\">" + deleteStr + "</td> \n" \ "</tr> \n" ; } } if( !personalFoldersFound ) { statusStr += "<br><br>There are no personal folders associated with this mailbox."; dynamicHtml += statusStr + "</td></tr>" ; } else { dynamicHtml += personalFolders ; } dynamicHtml += "</table>\n" \ "</td></tr>\n" \ "<tr>\n" \ "<td colspan=\"2\"> \n" \ "<form action=\"" + m_cgiUrl + "\" method=\"post\">\n" \ "<input type=\"hidden\" name=\"action\" value=\"getaddfolderui\">\n" \ "<input type=\"hidden\" name=\"fromweb\" value=\"yes\">\n" \ "<input type=\"submit\" value=\"Create Folder\">\n" \ "</form>\n" \ "</td> \n" \ "</tr> \n" \ "</table>\n" \ "</td>\n" \ "</tr>\n" \ "</table>\n" \ HTML_END ; if( out ) { out->remove(0); out->append( dynamicHtml.data() ); } return OS_SUCCESS ; }
OsStatus ManageFoldersWebCGI::getPersonalFolders(UtlString* out) { UtlString dynamicHtml( HTML_BEGIN ); UtlString redirectUrl = m_cgiUrl ; // Get the folder names UtlSortedList folderList; MailboxManager* pMailboxManager = MailboxManager::getInstance(); pMailboxManager->getMailboxFolders( m_mailboxIdentity, folderList ); // Check if mailbox has folders other than the standard 3 if ( folderList.entries() > 3 ) { if( folderList.entries() == 4 ) { // Just one custom folder is available. // Redirect to the CGI for displaying contents of the folder while( folderList.entries() > 0 ) { UtlString* rwFolderName = (UtlString*) folderList.removeAt(0); UtlString folderName = rwFolderName->data(); delete rwFolderName ; if( (folderName.compareTo("inbox", UtlString::ignoreCase) != 0) && (folderName.compareTo("saved", UtlString::ignoreCase) != 0) && (folderName.compareTo("deleted", UtlString::ignoreCase) != 0) ) { // escape the folder name UtlString escapedFolderName = folderName; HttpMessage::escape( escapedFolderName ); redirectUrl += "?action=playmsg&fromweb=yes&[email protected]&nextblockhandle=-1&category=" + escapedFolderName; break; } } dynamicHtml += REDIRECT_SCRIPT_BEGIN + redirectUrl + REDIRECT_SCRIPT_END \ HTML_END ; } else { dynamicHtml += "<form action=\"" + redirectUrl + "\">\n " + WEBPAGE_SNIPPET1 + "Personal Folders" + WEBPAGE_SNIPPET2 + "all_folders_managing_messages.htm" + WEBPAGE_SNIPPET3 + "Select the folder you want to view" + "</td></tr> \n"+ "<tr> \n" \ "<td colspan=\"2\" class=\"notetext\"> \n" ; while( folderList.entries() > 0 ) { // Show the list of folders so that the user can pick the one they want UtlString* rwFolderName = (UtlString*) folderList.removeAt(0); UtlString folderName = rwFolderName->data(); delete rwFolderName ; if( (folderName.compareTo("inbox", UtlString::ignoreCase) != 0) && (folderName.compareTo("saved", UtlString::ignoreCase) != 0) && (folderName.compareTo("deleted", UtlString::ignoreCase) != 0) ) { UtlString escapedFolderName = folderName ; HttpMessage::escape(escapedFolderName); dynamicHtml += "<input type=\"radio\" name=\"category\" value=\"" + escapedFolderName + "\">" + folderName + "<br>\n" ; } } dynamicHtml += "</td></tr>\n" \ "</table>\n" \ "<input type=\"hidden\" name=\"action\" value=\"playmsg\">\n" \ "<input type=\"hidden\" name=\"fromweb\" value=\"yes\">\n" \ "<input type=\"hidden\" name=\"from\" value=\"[email protected]\">\n" \ "<input type=\"hidden\" name=\"nextblockhandle\" value=\"-1\">\n" \ "<input type=\"submit\" value=\"View\">\n" \ "</form>\n" \ HTML_END ; } } else { // User does not have any personal folder. dynamicHtml += WEBPAGE_SNIPPET1 \ "Personal Folders" \ WEBPAGE_SNIPPET2 \ "all_folders_managing_messages.htm" \ WEBPAGE_SNIPPET3 \ "<br>You do not have any personal folders set up.<br><br>To add a personal folder, click Manage Folders." \ "</td></tr>\n" \ "</table> \n" \ HTML_END ; } if( out ) { out->remove(0); out->append( dynamicHtml.data() ); } return OS_SUCCESS ; }