]> git.agnieray.net Git - galette.git/commitdiff
Display wrapped messages in mailing preview; add a parameter to disable auto-wrapping...
authorJohan Cwiklinski <johan@x-tnd.be>
Sun, 9 Mar 2014 08:44:35 +0000 (09:44 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sun, 9 Mar 2014 08:44:35 +0000 (09:44 +0100)
galette/lib/Galette/Core/GaletteMail.php
galette/lib/Galette/Core/Mailing.php
galette/lib/Galette/Core/Preferences.php
galette/templates/default/ajax_mailing_preview.tpl
galette/templates/default/mailing_adherents.tpl
galette/templates/default/preferences.tpl

index 47923d4727d78274b11f18345e1f6590df5cd977..a295be8676500284c46cd622766de4da74870d77 100644 (file)
@@ -71,6 +71,7 @@ class GaletteMail
     private $_message;
     private $_alt_message;
     private $_html;
+    private $_word_wrap = 70;
 
     private $_result;
     private $_errors = array();
@@ -155,7 +156,11 @@ class GaletteMail
         $this->_mail->CharSet = 'UTF-8';
         $this->_mail->SetLanguage($i18n->getAbbrev());
 
-        $this->_mail->WordWrap = 70;
+        if ( $preferences->pref_bool_wrap_mails ) {
+            $this->_mail->WordWrap = $this->_word_wrap;
+        } else {
+            $this->_word_wrap = 0;
+        }
     }
 
     /**
@@ -439,6 +444,23 @@ class GaletteMail
         return $this->_message;
     }
 
+    /**
+     * Get the message, wrapped
+     *
+     * @return string Wrapped message
+     */
+    public function getWrappedMessage()
+    {
+        if ( $this->_word_wrap > 0 ) {
+            return $this->_mail->wrapText(
+                $this->_message,
+                $this->_word_wrap
+            );
+        } else {
+            return $this->_message;
+        }
+    }
+
     /**
      * Sets the subject
      *
index 98ee249027d23a06278eee16aead7affbc51adc2..68fd5ded68aad1657d06c985b48112c4c87ceb4b 100644 (file)
@@ -458,6 +458,9 @@ class Mailing extends GaletteMail
             case 'message':
                 return $this->getMessage();
                 break;
+            case 'wrapped_message':
+                return $this->getWrappedMessage();
+                break;
             case 'html':
                 return $this->isHTML();
                 break;
index 90876c3307aae2953148b08f3238733af7132cde..3ec3407eed6a0a3c4c571cd01cd2dee4f1bb797f 100644 (file)
@@ -149,7 +149,8 @@ class Preferences
         'pref_linkedin' => '',
         'pref_mail_sign' => "{NAME}\r\n\r\n{WEBSITE}\r\n{GOOGLEPLUS}\r\n{FACEBOOK}\r\n{TWITTER}\r\n{LINKEDIN}\r\n{VIADEO}",
         /* New contribution script */
-        'pref_new_contrib_script' => ''
+        'pref_new_contrib_script' => '',
+        'pref_bool_wrap_mails' => true
     );
 
     /**
index 025202e48f27fdf6537e3c4951d3c4d3c525e2f6..cf52d7df41740911e74a225d83bee6ceed00b3c2 100644 (file)
@@ -35,7 +35,7 @@
             {if $mailing->html}
                     {$mailing->message}
             {else}
-                        <pre>{$mailing->message|escape}</pre>
+                    <pre>{$mailing->wrapped_message|escape}</pre>
             {/if}
             </div>
-        </section>
\ No newline at end of file
+        </section>
index cc3db9dfc808a32da87da59f1c33d58f6fa70e96..3f68a78b3c4953d168e94a26ec17b6bc053253a8 100644 (file)
             {if $mailing->html}
                     {$mailing->message}
             {else}
-                        <pre>{$mailing->message}</pre>
+                        <pre>{$mailing->wrapped_message}</pre>
             {/if}
                     </p>
                 </div>
                 <div>
                     <p>
                         <input type="submit" name="mailing_reset" class="button" id="btnback" value="{_T string="Modifiy mailing"}"/>
-                        <input type="submit" name="mailing_confirm" value="{_T string="Send"}"{if $GALETTE_MODE eq 'DEMO'} class="disabled" disabled="disabled"{/if}/>
+                        <input type="submit" name="mailing_confirm" id="btnsend" value="{_T string="Send"}"{if $GALETTE_MODE eq 'DEMO'} class="disabled" disabled="disabled"{/if}/>
                         <input type="submit" id="btncancel" name="mailing_cancel" value="{_T string="Cancel mailing"}"/>
                         <input type="hidden" name="mailing_objet" value="{$mailing->subject}"/>
                         <input type="hidden" name="mailing_corps" value="{$mailing->message|escape}"/>
index a8204f3231a90eebf7734ae7d8c6852e23be8b5c..eeedbf43f75709b3b7a9b531268e7ef932f93f04 100644 (file)
                     <input type="text" name="pref_email_newadh" id="pref_email_newadh" value="{$pref.pref_email_newadh}" maxlength="100" size="30"{if isset($required.pref_email_newadh) and $required.pref_email_newadh eq 1} required{/if}/>
                 </p>
                 <p>
-                    <label for="pref_bool_mailadh" class="bline tooltip" title="{_T string="Sends an email each time a new member registers online"}">{_T string="Send email to administrators ?"}</label>
+                    <label for="pref_bool_mailadh" class="bline tooltip" title="{_T string="Sends an email each time a new member registers online"}">{_T string="Send email to administrators?"}</label>
                     <span class="tip">{_T string="Sends an email each time a new member registers online"}</span>
                     <input type="checkbox" name="pref_bool_mailadh" id="pref_bool_mailadh" value="1" {if $pref.pref_bool_mailadh eq 1}checked="checked"{/if}{if isset($required.pref_bool_mailadh) and $required.pref_bool_mailadh eq 1} required{/if}/>
                 </p>
                 <p>
-                    <label for="pref_editor_enabled" class="bline tooltip" title="{_T string="Should HTML editor be activated on page load ?"}">{_T string="Activate HTML editor ?"}</label>
+                    <label for="pref_bool_wrap_mails" class="bline tooltip" title="{_T string="Automatically wrap text mails before sending"}">{_T string="Wrap text mails?"}</label>
+                    <span class="tip">{_T string="Automatically wrap text mails before sending. Make sure to wrap yourself if you disable that. Please note that current editing mailing will not be affected by a change."}</span>
+                    <input type="checkbox" name="pref_bool_wrap_mails" id="pref_bool_wrap_mails" value="1" {if $pref.pref_bool_wrap_mails eq 1}checked="checked"{/if}{if isset($required.pref_bool_wrap_mails) and $required.pref_bool_wrap_mails eq 1} required{/if}/>
+                </p>
+
+                <p>
+                    <label for="pref_editor_enabled" class="bline tooltip" title="{_T string="Should HTML editor be activated on page load ?"}">{_T string="Activate HTML editor?"}</label>
                     <span class="tip">{_T string="Should HTML editor be activated on page load ?"}</span>
                     <input type="checkbox" name="pref_editor_enabled" id="pref_editor_enabled" value="1" {if $pref.pref_editor_enabled eq 1}checked="checked"{/if}{if isset($required.pref_editor_enabled) and $required.pref_editor_enabled eq 1} required{/if}/>
                 </p>