From: Michael M Slusarz Date: Fri, 1 Oct 2010 23:06:42 +0000 (-0600) Subject: Implement stationery in dimp. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5f103ca671950049ca293b37d9c456f0812cd488;p=horde.git Implement stationery in dimp. --- diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 21dd3139c..8ba91b7a3 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] Implement stationery support in DIMP. [mms] Add preference to control displayed content for multipart/alternative parts (Request #6711). [mms] Allow multiple messages to be forwarded in a single outgoing message diff --git a/imp/js/compose-dimp.js b/imp/js/compose-dimp.js index 315540ed8..67a59964b 100644 --- a/imp/js/compose-dimp.js +++ b/imp/js/compose-dimp.js @@ -142,6 +142,22 @@ var DimpCompose = { : l.l; } + /* Stationery switch. */ + if (id == 's') { + DimpCore.doAction('stationery', { + html: Number(IMP_Compose_Base.editor_on), + id: s, + identity: $F('identity'), + text: (IMP_Compose_Base.editor_on ? this.rte.getData() : $F('composeMessage')) + }, { + ajaxopts: { asynchronous: false }, + callback: function(r) { + this.setBodyText(r.response.text); + }.bind(this) + }); + return; + } + $(k.opts.input).setValue(s); $(k.opts.label).writeAttribute('title', l.escapeHTML()).setText(l.truncate(15)).up(1).show(); @@ -1042,6 +1058,15 @@ var DimpCompose = { this.setPopdownLabel('e', $F('encrypt')); } + /* Create stationery list. */ + if (DIMP.conf_compose.stationery) { + this.createPopdown('s', { + base: $('stationery_label').up(), + data: DIMP.conf_compose.stationery, + label: 'stationery_label' + }); + } + // Automatically resize compose address fields. new TextareaResize('to'); new TextareaResize('cc'); diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index 8b90fbc1d..f0e0c2b61 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -1229,6 +1229,41 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application } /** + * AJAX action: Load stationery. + * + * Variables used: + *
+     * 'html' - (integer) In HTML compose mode?
+     * 'id' - (integer) The stationery entry to use.
+     * 'identity' - (integer) The current identity.
+     * 'text' - (string) The message body text.
+     * 
+ * + * @return object An object with the following entries: + *
+     * 'text' - (string) The new message text.
+     * 
+ */ + public function stationery() + { + global $injector, $notification, $prefs; + + $identity = $injector->getInstance('IMP_Identity'); + if (isset($this->_vars->identity) && + !$prefs->isLocked('default_identity')) { + $identity->setDefault($this->_vars->identity); + } + $stationery = $injector->getInstance('IMP_Compose_Stationery'); + + $result = new stdClass; + $result->text = $stationery->getContent($this->_vars->id, $identity, strval($this->_vars->text), $this->_vars->html); + + $notification->push(sprintf(_("Loaded stationery \"%s\"."), $stationery[$this->_vars->id]['n']), 'horde.message'); + + return $result; + } + + /** * AJAX action: Delete a draft. * * Variables used: diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index 60beca655..3bee373f5 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -149,6 +149,9 @@ class IMP_Views_Compose $t->set('encrypt', IMP::ENCRYPT_NONE); } + $stationery = $GLOBALS['injector']->getInstance('IMP_Compose_Stationery'); + $t->set('stationery', count($stationery)); + $select_list = array(); foreach ($identity->getSelectList() as $id => $from) { $select_list[] = array( diff --git a/imp/templates/dimp/compose/compose.html b/imp/templates/dimp/compose/compose.html index 11c1bbbc3..e07a2920a 100644 --- a/imp/templates/dimp/compose/compose.html +++ b/imp/templates/dimp/compose/compose.html @@ -67,6 +67,11 @@ + +
+ Stationery +
+
diff --git a/imp/templates/dimp/javascript_defs_dimp.php b/imp/templates/dimp/javascript_defs_dimp.php index cfda7b71f..4752f8c91 100644 --- a/imp/templates/dimp/javascript_defs_dimp.php +++ b/imp/templates/dimp/javascript_defs_dimp.php @@ -225,6 +225,18 @@ if (in_array(basename($_SERVER['PHP_SELF']), array('compose-dimp.php', 'message- } $code['conf_compose']['encrypt'] = $encrypt; } + + $stationery = $GLOBALS['injector']->getInstance('IMP_Compose_Stationery'); + if (count($stationery)) { + $slist = array(); + foreach ($stationery as $key => $val) { + $slist[] = array( + 'l' => htmlspecialchars($val['n']), + 'v' => intval($key) + ); + } + $code['conf_compose']['stationery'] = $slist; + } } Horde::addInlineScript(array(