Ticket #8126: Implement readonly mailboxes in dimp view
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Mar 2009 19:01:57 +0000 (13:01 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Mar 2009 19:59:26 +0000 (13:59 -0600)
imp/js/src/DimpBase.js
imp/lib/Views/ListMessages.php
imp/message-dimp.php
imp/templates/chunks/message.php
imp/templates/index/index-dimp.inc
imp/themes/graphics/locked.png [new file with mode: 0644]
imp/themes/screen-dimp.css
imp/themes/silver/graphics/locked.png [new file with mode: 0644]
imp/themes/silver/screen-dimp.css

index 94b74b7..654bfd2 100644 (file)
@@ -446,7 +446,7 @@ var DimpBase = {
                 this.setMessageListTitle();
             }.bind(this),
             onComplete: function() {
-                var row, ssc,
+                var row, ssc, tmp,
                     l = this.viewport.getMetaData('label');
 
                 if (this.uid) {
@@ -489,6 +489,25 @@ var DimpBase = {
                             }
                         }
                     }
+
+                    /* Read-only changes. 'oa_setflag' is handled
+                     * elsewhere. */
+                    tmp = [ $('button_deleted') ].compact().invoke('up', 'SPAN');
+                    [ 'ctx_message_', 'ctx_draft_' ].each(function(c) {
+                        var t = $(c + 'setflag');
+                        if (t) {
+                            tmp = tmp.concat([ t, t.previous('DIV.sep'), t.next('DIV.sep') ]);
+                        }
+                        tmp = tmp.concat($(c + 'deleted', c + 'undeleted'));
+                    });
+
+                    if (this.viewport.getMetaData('readonly')) {
+                        tmp.compact().invoke('hide');
+                        $('folderName').next().show();
+                    } else {
+                        tmp.compact().invoke('show');
+                        $('folderName').next().hide();
+                    }
                 } else if (this.filtertoggle) {
                     if (this.filtertoggle == 1 &&
                         this.viewport.getMetaData('sortby') == DIMP.conf.sortthread) {
@@ -740,7 +759,13 @@ var DimpBase = {
             break;
 
         case 'ctx_otheractions':
-            $('oa_setflag', 'oa_sep1', 'oa_blacklist', 'oa_whitelist', 'oa_sep2', 'oa_undeleted').compact().invoke(this.viewport.getSelected().size() ? 'show' : 'hide');
+            tmp = $('oa_sep1', 'oa_blacklist', 'oa_whitelist', 'oa_sep2', 'oa_undeleted');
+            if (this.viewport.getMetaData('readonly')) {
+                $('oa_setflag').hide().previous('DIV.sep').hide();
+            } else {
+                tmp.push($('oa_setflag'));
+            }
+            tmp.compact().invoke(this.viewport.getSelected().size() ? 'show' : 'hide');
             break;
 
         default:
index 5a724fd..ef0baa8 100644 (file)
@@ -93,7 +93,7 @@ class IMP_Views_ListMessages
         /* Create the base object. */
         $result = new stdClass;
         $result->id = $mbox;
-        $result->reset = false;
+        $result->reset = 0;
         $result->totalrows = $msgcount;
         $result->label = $label;
         $result->cacheid = $imp_mailbox->getCacheID();
@@ -141,6 +141,9 @@ class IMP_Views_ListMessages
         if ($GLOBALS['imp_search']->isSearchMbox($mbox)) {
             $md->search = 1;
         }
+        if ($GLOBALS['imp_imap']->isReadOnly($mbox)) {
+            $md->readonly = 1;
+        }
 
         /* Check for mailbox existence now. If there are no messages, there
          * is a chance that the mailbox doesn't exist. If there is at least
index fbe0940..7d3b5b4 100644 (file)
@@ -19,6 +19,7 @@ if (!$index || !$folder) {
 }
 
 $imp_ui = new IMP_UI_Message();
+$readonly = $imp_imap->isReadOnly($folder);
 
 $args = array(
     'headers' => array_diff(array_keys($imp_ui->basicHeaders()), array('subject')),
@@ -63,6 +64,7 @@ foreach (array('from', 'to', 'cc', 'bcc', 'replyTo') as $val) {
         $compose_result['js'][] = 'DimpFullmessage.' . $val . ' = ' . Horde_Serialize::serialize($show_msg_result[$val], Horde_Serialize::JSON);
     }
 }
+
 IMP::addInlineScript($compose_result['js']);
 IMP::addInlineScript($compose_result['jsonload'], 'load');
 IMP::addInlineScript(array(DIMP::notify()), 'dom');
index 3c0befd..b8c9902 100644 (file)
@@ -49,9 +49,11 @@ function _createDAfmsg($text, $image, $id, $class = '', $show_text = true)
      <?php _createDAfmsg(_("Report Innocent"), 'Ham', 'button_ham', '', $show_text) ?>
     </span>
 <?php endif; ?>
+<?php if (!$readonly): ?>
     <span>
      <?php _createDAfmsg(_("Delete"), 'Delete', 'button_deleted', '', $show_text) ?>
     </span>
+<?php endif; ?>
    </div>
   </div>
 
index 24cc363..36dd71f 100644 (file)
@@ -165,6 +165,7 @@ function _simpleButton($id, $text, $image, $imagedir = null)
        <span class="rightFloat" id="msgHeader"></span>
        <span id="folderLoading" class="loadingImg" style="display:none"></span>
        <span id="folderName"></span>
+       <span class="iconImg readonlyImg" style="display:none" title="<?php echo htmlspecialchars(_("Read-Only")) ?>"></span>
       </div>
      </div>
 
diff --git a/imp/themes/graphics/locked.png b/imp/themes/graphics/locked.png
new file mode 100644 (file)
index 0000000..e79c2a5
Binary files /dev/null and b/imp/themes/graphics/locked.png differ
index 9fd54f7..0c4c43e 100644 (file)
@@ -1116,3 +1116,7 @@ span.keyupImg {
 span.keydownImg {
     background-image: url("graphics/key_down.png");
 }
+span.readonlyImg {
+    background-image: url("graphics/locked.png");
+    vertical-align: sub;
+}
diff --git a/imp/themes/silver/graphics/locked.png b/imp/themes/silver/graphics/locked.png
new file mode 100644 (file)
index 0000000..2ebc4f6
Binary files /dev/null and b/imp/themes/silver/graphics/locked.png differ
index 5ffe2c8..d65c3b4 100644 (file)
@@ -203,3 +203,6 @@ span.keyupImg {
 span.keydownImg {
     background-image: url("graphics/key_down.png");
 }
+span.readonlyImg {
+    background-image: url("graphics/locked.png");
+}