From 7445869d2a78de0be431e83642452e8f414eded2 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 1 Apr 2015 13:11:32 -0500
Subject: [PATCH] email: Add warning for archive folder for POP

This patch adds an error to the page if unable to configure the archive
folder and POP was selected as the mailbox protocol. Generally, POP servers
do not support anything but the INBOX
---
 include/class.email.php     | 8 ++++++--
 include/staff/email.inc.php | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/class.email.php b/include/class.email.php
index d38806f75..26cd68648 100644
--- a/include/class.email.php
+++ b/include/class.email.php
@@ -296,8 +296,12 @@ class Email {
 
             if(!isset($vars['postfetch']))
                 $errors['postfetch']=__('Indicate what to do with fetched emails');
-            elseif(!strcasecmp($vars['postfetch'],'archive') && !$vars['mail_archivefolder'] )
-                $errors['postfetch']=__('Valid folder required');
+            elseif(!strcasecmp($vars['postfetch'],'archive')) {
+                if ($vars['mail_protocol'] == 'POP')
+                    $errors['postfetch'] =  __('POP mail servers do not support folders');
+                elseif (!$vars['mail_archivefolder'])
+                    $errors['postfetch'] = __('Valid folder required');
+            }
         }
 
         if($vars['smtp_active']) {
diff --git a/include/staff/email.inc.php b/include/staff/email.inc.php
index 1ae20c19f..2ee0222fa 100644
--- a/include/staff/email.inc.php
+++ b/include/staff/email.inc.php
@@ -218,7 +218,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
             <td>
 		<span>
 			<select name="mail_proto">
-                <option value=''>&mdash; <?php __('Select protocol'); ?> &mdash;</option>
+                <option value=''>&mdash; <?php echo __('Select protocol'); ?> &mdash;</option>
 <?php
     foreach (MailFetcher::getSupportedProtos() as $proto=>$desc) { ?>
                 <option value="<?php echo $proto; ?>" <?php
-- 
GitLab