thomascube
2008-07-15 5b3dd412d2e28f80fb2d12dbdcab992cc6f219a5
Check PERMANENTFLAGS before saving MDNSent flag (#1484963, #1485163)

6 files modified
58 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/html.php 5 ●●●●● patch | view | raw | blame | history
program/include/rcube_imap.php 15 ●●●●● patch | view | raw | blame | history
program/lib/imap.inc 28 ●●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 2 ●●● patch | view | raw | blame | history
program/steps/mail/show.inc 7 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -4,6 +4,7 @@
2008/07/14 (thomasb)
----------
- Re-enable autocomplete attribute for login form (#1485211)
- Check PERMANENTFLAGS before saving $MDNSent flag (#1484963, #1485163)
2008/06/30 (alec)
----------
program/include/html.php
@@ -248,7 +248,7 @@
{
    protected $tagname = 'input';
    protected $type = 'text';
    protected $allowed = array('type','name','value','size','tabindex','autocomplete','checked');
    protected $allowed = array('type','name','value','size','tabindex','autocomplete','checked','onchange');
    public function __construct($attrib = array())
    {
@@ -416,7 +416,7 @@
class html_textarea extends html
{
    protected $tagname = 'textarea';
    protected $allowed = array('name','rows','cols','wrap','tabindex');
    protected $allowed = array('name','rows','cols','wrap','tabindex','onchange');
    /**
     * Get HTML code for this object
@@ -473,6 +473,7 @@
{
    protected $tagname = 'select';
    protected $options = array();
    protected $allowed = array('name','size','tabindex','autocomplete','multiple','onchange');
    
    /**
     * Add a new option to this drop-down
program/include/rcube_imap.php
@@ -346,6 +346,21 @@
  /**
   * Checks the PERMANENTFLAGS capability of the current mailbox
   * and returns true if the given flag is supported by the IMAP server
   *
   * @param   string  Permanentflag name
   * @return  mixed   True if this flag is supported
   * @access  public
   */
  function check_permflag($flag)
    {
    $flagsmap = $GLOBALS['IMAP_FLAGS'];
    return (($imap_flag = $flagsmap[strtoupper($flag)]) && in_array_nocase($imap_flag, $this->conn->permanentflags));
    }
  /**
   * Returns the delimiter that is used by the IMAP server for folder separation
   *
   * @return  string  Delimiter string
program/lib/imap.inc
@@ -90,6 +90,16 @@
$GLOBALS['IMAP_SERVER_TZ'] = date('Z');
$GLOBALS['IMAP_FLAGS'] = array(
    'SEEN'     => '\\Seen',
    'DELETED'  => '\\Deleted',
    'RECENT'   => '\\Recent',
    'ANSWERED' => '\\Answered',
    'DRAFT'    => '\\Draft',
    'FLAGGED'  => '\\Flagged',
    'FORWARDED' => '$Forwarded',
    'MDNSENT'  => '$MDNSent');
$iil_error;
$iil_errornum;
$iil_selected;
@@ -113,6 +123,7 @@
    var $rootdir;
    var $delimiter;
    var $capability = array();
    var $permanentflags = array();
}
/**
@@ -142,7 +153,7 @@
    var $priority;
    var $mdn_to;
    var $mdn_sent = false;
    var $is_reply = false;
    var $is_draft = false;
    var $seen = false;
    var $deleted = false;
    var $recent = false;
@@ -732,6 +743,9 @@
                        if (strcasecmp($a[2], 'RECENT') == 0) {
                            $conn->recent = (int) $a[1];
                        }
            }
            else if (preg_match('/\[?PERMANENTFLAGS\s+\(([^\)]+)\)\]/U', $line, $match)) {
                $conn->permanentflags = explode(' ', $match[1]);
            }
        } while (!iil_StartsWith($line, 'sel1'));
@@ -1757,6 +1771,8 @@
                                $result[$id]->answered = true;
                            } else if (strcasecmp($val, '$Forwarded') == 0) {
                                $result[$id]->forwarded = true;
                            } else if (strcasecmp($val, 'Draft') == 0) {
                                $result[$id]->is_draft = true;
                            } else if (strcasecmp($val, '$MDNSent') == 0) {
                                $result[$id]->mdn_sent = true;
                            } else if (strcasecmp($val, 'Flagged') == 0) {
@@ -1909,15 +1925,7 @@
    }
    
    $fp    = $conn->fp;
    $flags = array(
        'SEEN'     => '\\Seen',
        'DELETED'  => '\\Deleted',
        'RECENT'   => '\\Recent',
        'ANSWERED' => '\\Answered',
        'DRAFT'    => '\\Draft',
        'FLAGGED'  => '\\Flagged',
        'FORWARDED' => '$Forwarded',
        'MDNSENT'  => '$MDNSent');
    $flags = $GLOBALS['IMAP_FLAGS'];
        
    $flag = strtoupper($flag);
    $flag = $flags[$flag];
program/steps/mail/func.inc
@@ -1069,7 +1069,7 @@
  $message = new rcube_message($uid);
  
  if ($message->headers->mdn_to && !$message->headers->mdn_sent)
  if ($message->headers->mdn_to && !$message->headers->mdn_sent && $IMAP->check_permflag('MDNSENT'))
  {
    $identity = $RCMAIL->user->get_identity();
    $sender = format_email_recipient($identity['email'], $identity['name']);
program/steps/mail/show.inc
@@ -82,8 +82,11 @@
  $OUTPUT->set_env('sender', $MESSAGE->sender['string']);
  
  // check for unset disposition notification
  if ($MESSAGE->headers->mdn_to && !$MESSAGE->headers->mdn_sent &&
      $mbox_name != $CONFIG['drafts_mbox'] && $mbox_name != $CONFIG['sent_mbox'])
  if ($MESSAGE->headers->mdn_to &&
      !$MESSAGE->headers->mdn_sent &&
      $IMAP->check_permflag('MDNSENT') &&
      $mbox_name != $CONFIG['drafts_mbox'] &&
      $mbox_name != $CONFIG['sent_mbox'])
  {
    if (intval($CONFIG['mdn_requests']) === 1)
    {