From 8259372a9aeb189b0c14d55cab065438513361d6 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 12 Feb 2015 12:48:47 -0500 Subject: [PATCH] Added user editable email subjects. - Resolves VUFIND-1090. --- config/vufind/config.ini | 2 ++ module/VuFind/src/VuFind/Controller/AbstractBase.php | 5 +++++ .../blueprint/templates/Helpers/email-form-fields.phtml | 4 ++++ .../bootstrap3/templates/Helpers/email-form-fields.phtml | 8 ++++++++ .../templates/Helpers/email-form-fields.phtml | 4 ++++ 5 files changed, 23 insertions(+) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index e46c919095b..e572e3bcca2 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -355,6 +355,8 @@ require_login = true user_email_in_from = false ; Should we put the logged-in user's address in the "to" field by default? user_email_in_to = false +; Should the user be allowed to edit email subject lines? +user_editable_subjects = false ; Populate the "from" field with this value if user_email_in_from is false and/or no ; user is logged in: ;default_from = "no-reply@myuniversity.edu" diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index c2bbdee8599..c35227fb626 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -135,6 +135,8 @@ class AbstractBase extends AbstractActionController $config = $this->getServiceLocator()->get('VuFind\Config')->get('config'); $view->disableFrom = (isset($config->Mail->disable_from) && $config->Mail->disable_from); + $view->editableSubject = isset($config->Mail->user_editable_subjects) + && $config->Mail->user_editable_subjects; $user = $this->getUser(); // Send parameters back to view so form can be re-populated: @@ -143,6 +145,9 @@ class AbstractBase extends AbstractActionController if (!$view->disableFrom) { $view->from = $this->params()->fromPost('from'); } + if ($view->editableSubject) { + $view->subject = $this->params()->fromPost('subject'); + } $view->message = $this->params()->fromPost('message'); } diff --git a/themes/blueprint/templates/Helpers/email-form-fields.phtml b/themes/blueprint/templates/Helpers/email-form-fields.phtml index 72f6eec68f1..64039cf1bd1 100644 --- a/themes/blueprint/templates/Helpers/email-form-fields.phtml +++ b/themes/blueprint/templates/Helpers/email-form-fields.phtml @@ -4,6 +4,10 @@ <label class="displayBlock" for="email_from"><?=$this->transEsc('From')?>:</label> <input id="email_from" type="text" name="from" value="<?=isset($this->from) ? $this->from : ''?>" size="40" class="<?=$this->jqueryValidation(array('required'=>'This field is required', 'email'=>'Email address is invalid'))?>"/> <? endif; ?> +<? if ($this->editableSubject): ?> + <label class="displayBlock" for="email_subject"><?=$this->transEsc('email_subject')?>:</label> + <input id="email_subject" type="text" name="subject" value="<?=isset($this->subject) ? $this->subject : ''?>" size="40" class="<?=$this->jqueryValidation(array('required'=>'This field is required'))?>"/> +<? endif; ?> <label class="displayBlock" for="email_message"><?=$this->transEsc('Message')?>:</label> <textarea id="email_message" name="message" rows="3" cols="40"><?=isset($this->message) ? $this->message : ''?></textarea> <br/> diff --git a/themes/bootstrap3/templates/Helpers/email-form-fields.phtml b/themes/bootstrap3/templates/Helpers/email-form-fields.phtml index 25d914108bf..440997f097e 100644 --- a/themes/bootstrap3/templates/Helpers/email-form-fields.phtml +++ b/themes/bootstrap3/templates/Helpers/email-form-fields.phtml @@ -12,6 +12,14 @@ </div> </div> <? endif; ?> +<? if ($this->editableSubject): ?> + <div class="form-group"> + <label class="col-sm-3 control-label" for="email_subject"><?=$this->transEsc('email_subject')?>:</label> + <div class="col-sm-9"> + <input type="text" id="email_subject" oninvalid="$('#modal .fa-spinner').remove()" name="subject" value="<?=isset($this->subject) ? $this->subject : ''?>" size="40" class="form-control"/> + </div> + </div> +<? endif; ?> <div class="form-group"> <label class="col-sm-3 control-label" for="email_message"><?=$this->transEsc('Message')?>:</label> <div class="col-sm-9"> diff --git a/themes/jquerymobile/templates/Helpers/email-form-fields.phtml b/themes/jquerymobile/templates/Helpers/email-form-fields.phtml index 0e9e2a00eb9..dae7c7de436 100644 --- a/themes/jquerymobile/templates/Helpers/email-form-fields.phtml +++ b/themes/jquerymobile/templates/Helpers/email-form-fields.phtml @@ -5,6 +5,10 @@ <label for="email_from"><?=$this->transEsc('From')?>:</label> <input id="email_from" type="text" name="from" value="<?=isset($this->from) ? $this->from : ''?>" size="40" class="<?=$this->jqueryValidation(array('required'=>'This field is required', 'email'=>'Email address is invalid'))?>"/> <? endif; ?> + <? if ($this->editableSubject): ?> + <label for="email_subject"><?=$this->transEsc('email_subject')?>:</label> + <input id="email_subject" type="text" name="subject" value="<?=isset($this->subject) ? $this->subject : ''?>" size="40" class="<?=$this->jqueryValidation(array('required'=>'This field is required'))?>"/> + <? endif; ?> <label for="email_message"><?=$this->transEsc('Message')?>:</label> <textarea id="email_message" name="message"><?=isset($this->message) ? $this->message : ''?></textarea> </div> -- GitLab