- Posts: 8
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
<?php class CustomReplyTo extends PluginBase { protected $storage = 'DbStorage'; static protected $description = 'Set reply-to address'; static protected $name = 'CustomReplyTo'; public function init() { $this->subscribe('beforeEmail','beforeEmail'); $this->subscribe('beforeSurveyEmail','beforeEmail'); $this->subscribe('beforeTokenEmail','beforeEmail'); // Provides survey specific settings. $this->subscribe('beforeSurveySettings'); // Saves survey specific settings. $this->subscribe('newSurveySettings'); } public function beforeSurveySettings() { $pluginsettings = $this->getPluginSettings(true); $event = $this->getEvent(); $iSurveyID=$event->get('iSurveyID'); $event->set("surveysettings.{$iSurveyID}", array( 'name' => get_class($this), 'settings' => array( 'customReplyTo' => array( 'type' => 'string', 'label' => 'Custom Reply-To:', 'current' => $this->get('customReplyTo', 'Survey', $event->get('survey')) ) ) )); } /** * Save the settings */ public function newSurveySettings() { $event = $this->getEvent(); foreach ($event->get('settings') as $name => $value) { $this->set($name, $value, 'Survey', $event->get('survey')); } } /** * Set From and Bounce of PHPmailer to siteadminemail * @link https://www.limesurvey.org/manual/BeforeTokenEmail */ public function beforeEmail() { $emailsmtpuser = Yii::app()->getConfig('emailsmtpuser'); if(empty($emailsmtpuser)) { return; } $limeMailer = $this->getEvent()->get('mailer'); $limeMailer->AddReplyTo($this->get('customReplyTo', 'Survey', $event->get('survey'))); $this->getEvent()->set('updateDisable',$updateDisable); } }
$this->get('customReplyTo', 'Survey', $surveyId);
public function beforeEmail() { /* Global one (if you have a global settings array */ $customReplyTo = $this->get('customReplyTo'); /* get the current survey id */ $surveyId = $this->getEvent()->get('survey'); // Survey id as integer if($surveyId) { /* Maybe use globalk is empty ( == "") */ $customReplyTo = $this->get('customReplyTo', 'Survey', $surveyId); } if(empty($customReplyTo)) { return; } $limeMailer = $this->getEvent()->get('mailer'); $limeMailer->AddReplyTo($customReplyTo); }
class CustomReplyTo extends PluginBase { protected $storage = 'DbStorage'; static protected $description = 'Set reply-to address'; static protected $name = 'CustomReplyTo'; public function init() { $this->subscribe('beforeEmail','beforeEmail'); $this->subscribe('beforeSurveyEmail','beforeEmail'); $this->subscribe('beforeTokenEmail','beforeEmail'); // Provides survey specific settings. $this->subscribe('beforeSurveySettings'); // Saves survey specific settings. $this->subscribe('newSurveySettings'); } public function beforeSurveySettings() { $pluginsettings = $this->getPluginSettings(true); $event = $this->getEvent(); $iSurveyID=$event->get('iSurveyID'); $event->set("surveysettings.{$iSurveyID}", array( 'name' => get_class($this), 'settings' => array( 'customReplyTo' => array( 'type' => 'string', 'label' => 'Custom Reply-To:', 'current' => $this->get('customReplyTo', 'Survey', $event->get('survey')) ) ) )); } /** * Save the settings */ public function newSurveySettings() { $event = $this->getEvent(); foreach ($event->get('settings') as $name => $value) { $this->set($name, $value, 'Survey', $event->get('survey')); } } /** * Set From and Bounce of PHPmailer to siteadminemail * @link https://www.limesurvey.org/manual/BeforeTokenEmail */ public function beforeEmail() { /* Global one (if you have a global settings array */ $customReplyTo = $this->get('customReplyTo'); /* get the current survey id */ $surveyId = $this->getEvent()->get('survey'); // Survey id as integer if($surveyId) { /* Maybe use globalk is empty ( == "") */ $customReplyTo = $this->get('customReplyTo', 'Survey', $surveyId); } if(empty($customReplyTo)) { return; } $limeMailer = $this->getEvent()->get('mailer'); $limeMailer->AddReplyTo($customReplyTo); } }
Unsure,kclingerman wrote: The only issue I see now is when the plugin customToken is enabled, my customReplyTo plugin does not show up under the "Simple plugins" menu, only the customToken setting is shown. Is this an issue with limesurvey, or how the plugin was created?
$oEvent->set("surveysettings.{$this->id}", array(
$event->set("surveysettings.{$iSurveyID}", array(