예제 #1
0
 public function prepSettings($settings)
 {
     return parent::prepSettings($settings);
 }
예제 #2
0
 /**
  * Saves a plugin's settings.
  *
  * @param BasePlugin $plugin   The plugin.
  * @param array      $settings The plugin’s new settings.
  *
  * @return bool Whether the plugin’s settings were saved successfully.
  */
 public function savePluginSettings(BasePlugin $plugin, $settings)
 {
     // Give the plugin a chance to prep the settings from post
     $preppedSettings = $plugin->prepSettings($settings);
     // Set the prepped settings on the plugin
     $plugin->setSettings($preppedSettings);
     // Validate them, now that it's a model
     if ($plugin->getSettings()->validate()) {
         // JSON-encode them and save the plugin row
         $settings = JsonHelper::encode($plugin->getSettings()->getAttributes());
         $affectedRows = craft()->db->createCommand()->update('plugins', array('settings' => $settings), array('class' => $plugin->getClassHandle()));
         return (bool) $affectedRows;
     }
 }
예제 #3
0
 /**
  * Saves a plugin's settings.
  *
  * @param BasePlugin $plugin
  * @param mixed $settings
  * @return bool
  */
 public function savePluginSettings(BasePlugin $plugin, $settings)
 {
     // Give the plugin a chance to modify the settings
     $settings = $plugin->prepSettings($settings);
     $settings = JsonHelper::encode($settings);
     $affectedRows = craft()->db->createCommand()->update('plugins', array('settings' => $settings), array('class' => $plugin->getClassHandle()));
     return (bool) $affectedRows;
 }