/** */ function __construct() { $config = isset(\jApp::config()->jcommunity) ? \jApp::config()->jcommunity : null; if ($config) { if (isset($config['loginResponse'])) { $this->responseType = $config['loginResponse']; } } if (class_exists('jPref')) { $pref = \jPref::get('jcommunity_registrationEnabled'); if ($pref !== null) { $this->registrationEnabled = $pref; } $pref = \jPref::get('jcommunity_resetPasswordEnabled'); if ($pref !== null) { $this->resetPasswordEnabled = $pref; } } else { if ($config) { if (isset($config['registrationEnabled'])) { $this->registrationEnabled = !!$config['registrationEnabled']; } if (isset($config['resetPasswordEnabled'])) { $this->resetPasswordEnabled = !!$config['resetPasswordEnabled']; } } } }
/** * Add a preference into the preference config. * * @param jPrefItem $preference the preference to add */ public function addPreference($pref) { self::_loadIniModifier(); $section = 'pref:' . $pref->id; self::$_ini->setValue('type', $pref->type, $section); self::$_ini->setValue('locale', $pref->locale, $section); self::$_ini->setValue('group', $pref->group, $section); self::$_ini->setValue('read_acl_subject', $pref->read_acl_subject, $section); self::$_ini->setValue('write_acl_subject', $pref->write_acl_subject, $section); self::$_ini->setValue('default_value', $pref->default_value, $section); self::$_ini->save(jApp::config()->chmodFile); if ($pref->value !== null) { jPref::set($pref->id, $pref->value); } elseif ($pref->default_value !== null) { jPref::set($pref->id, $pref->default_value); } }
public function loadValue() { $this->value = jPref::get($this->id); }
/** * Clear the local cache */ public static function clearCache() { self::$_prefs = null; }
/** * */ public function reset() { $rep = $this->getResponse('redirect'); $rep->action = 'jpref_admin~prefs:index'; $id = $this->param('id', 0); $pref = jPrefManager::getPref($id); if (!$id || !$pref || empty($pref->default_value) && $pref->type != 'boolean') { return $rep; } if (!$pref->isWritable()) { jMessage::add(jLocale::get('jacl2~errors.action.right.needed'), 'error'); return $rep; } $dvalue = $pref->default_value; if ($pref->type == 'integer') { $dvalue = (int) $dvalue; } elseif ($pref->type == 'decimal') { $dvalue = (double) $dvalue; } elseif ($pref->type == 'boolean') { if ($dvalue == 'false') { $dvalue = false; } else { if ($dvalue == 'true') { $dvalue = true; } } } jPref::set($pref->id, $dvalue); jMessage::add(jLocale::get('jpref_admin~admin.message.pref.reseted'), 'notice'); return $rep; }