Open mbischof opened 4 years ago
class SurveySettings extends PluginBase { static protected $description = 'SurveySettings Plugin'; static protected $name = 'SurveySettings'; protected $storage = 'DbStorage'; public function init() { $this->subscribe('beforeSurveySettings'); $this->subscribe('newSurveySettings'); } public function beforeSurveySettings() { $event = $this->event; $surveyId = intval($event->get('survey')); $event->set("surveysettings.{$this->id}", array( 'name' => get_class($this), 'settings' => array( 'isActive' => array( 'type' => 'boolean', 'label' => 'enable for this survey', 'current' => $this->get('isActive', 'Survey', $surveyId, false) ), ) )); } public function newSurveySettings() { $event = $this->event; foreach ($event->get('settings') as $name => $value) { $this->set($name, $value, 'Survey', $event->get('survey')); } } }