public function getSettings() { $settings = parent::getSettings(); foreach ($settings as $name => $value) { $configValue = craft()->config->get($name, 'usermanual'); $settings->{$name} = is_null($configValue) ? $value : $configValue; } // Allow handles from config if (!is_numeric($settings->section)) { $section = craft()->sections->getSectionByHandle('homepage'); if ($section) { $settings->section = $section->id; } } return $settings; }
/** * 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; } }
/** * @param BasePlugin $plugin * @return array */ private function getPluginDefinition(BasePlugin $plugin) { return array('isInstalled' => $plugin->isInstalled, 'isEnabled' => $plugin->isEnabled, 'settings' => $plugin->getSettings()->attributes); }
/** * List of conditions that must be met before bar can be embedded * @param BasePlugin $plugin * @return bool */ private function _canEmbed($plugin) { return !craft()->isConsole() && !craft()->request->isCpRequest() && craft()->userSession->isLoggedIn() && $plugin->getSettings()->autoEmbed == 1; }
/** * Get all settings from plugin core class * * @return Market_SettingsModel */ public function getSettings() { $data = $this->_plugin->getSettings(); return Market_SettingsModel::populateModel($data); }