/** * Sets value for given key name * * @param string $name * @param mixed $value * */ public static function setValue($name, $value) { $c = new Criteria(); $c->add(SettingPeer::NAME, $name); if (!($setting = SettingPeer::doSelectOne($c))) { $setting = new Setting(); $setting->setName($name); } $setting->setValue($value); $setting->save(); }
$user->setLanguages($this->suid, $m, $survey->getAllowedLanguages($m)); } $user->saveChanges(); } } } } function convertSurveySettings($row) { $query = "replace into " . Config::dbSurvey() . "_surveys (suid, name, description) values ("; $query .= prepareDatabaseString($this->suid) . ","; $query .= "'" . prepareDatabaseString($row["header"]) . "',"; $query .= "'')"; $this->db->executeQuery($query); $query = "replace into " . Config::dbSurvey() . "_versions (suid, vnid, name, description) values ("; $query .= prepareDatabaseString($this->suid) . ","; $query .= prepareDatabaseString(1) . ","; $query .= "'Current',"; $query .= "'Current version')"; $this->db->executeQuery($query); /* add default survey */ $setting = new Setting(); $setting->setSuid($this->suid); $setting->setObject(USCIC_SURVEY); $setting->setObjectType(OBJECT_SURVEY); $setting->setName(SETTING_DEFAULT_SURVEY); $setting->setValue($this->suid); $setting->setMode(MODE_CASI); // dummy $setting->setLanguage(1); // dummy $setting->save(); /* add default mode */ $setting = new Setting(); $setting->setSuid($this->suid); $setting->setObject(USCIC_SURVEY); $setting->setObjectType(OBJECT_SURVEY); $setting->setName(SETTING_DEFAULT_MODE); $setting->setMode(MODE_CASI); $setting->setLanguage(1); // dummy $setting->setValue(MODE_CASI); $setting->save(); /* add default language */ $setting = new Setting(); $setting->setSuid($this->suid); $setting->setObject(USCIC_SURVEY); $setting->setObjectType(OBJECT_SURVEY); $setting->setName(SETTING_DEFAULT_LANGUAGE);
fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_setting.php'; // --------------------------------- // } elseif ('add' == $action) { $setting = new Setting(); if ('user' == $setting_type) { $list_plugin_settings = $plugin_user_settings; } else { $list_plugin_settings = $plugin_settings; } if (!array_key_exists($setting_name, $list_plugin_settings)) { $setting_name = ''; } $setting->setFriendlyName($list_plugin_settings[$setting_name]['friendly_name']); $setting->setName($setting_name); $setting->setPlugin('email'); if ($setting_type == 'user') { $setting->setOwnerId($user_id); $setting->setType('user'); } else { $setting->setOwnerId(0); } if (fRequest::isPost()) { try { $setting->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $setting->store(); $setting_url = Setting::makeUrl('list', $setting_type); fMessaging::create('affected', fURL::get()); fMessaging::create('success', fURL::get(), 'The setting ' . $setting->getFriendlyName() . ' was successfully created');
function setSettingDirectly($object, $objecttype, $name, $value, $mode = "", $language = "") { $setting = new Setting(); $setting->setSuid($this->getSuid()); $setting->setLanguage($language); $setting->setMode($mode); $setting->setName($name); $setting->setObject($object); $setting->setObjectType($objecttype); $setting->setValue($value); $setting->save(); }
} return ""; } function getSettingValue($name, $default = true) { return $this->getSetting($name, $default)->getValue(); } function setSettingValue($name, $value) { /* determine index */ $index = strtoupper($name . getSurveyMode() . getSurveyLanguage() . $this->getObjectType()); /* don't store if follow generic/follow type (these are implicitly derived, * so no need to store them explicitly). Also don't store if empty (if something should be empty * like a text, then enter for example as value). * If we had a value stored before, then we remove it now. */ if (inArray($value, array("", SETTING_FOLLOW_GENERIC, SETTING_FOLLOW_TYPE))) { if (isset($this->settings[$index])) { $s = $this->settings[$index]; if ($s != null) { $s->remove(); } unset($this->settings[$index]); } return; } /* update */ if (isset($this->settings[$index])) { $this->settings[$index]->setValue($value); } else { /* create new */