本文整理汇总了PHP中Preferences类的典型用法代码示例。如果您正苦于以下问题:PHP Preferences类的具体用法?PHP Preferences怎么用?PHP Preferences使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Preferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPreference
public function setPreference($user_id, $key, $value)
{
$result = Doctrine_Query::create()->from('Preferences p')->andwhere('p.user_ref = ?', $user_id)->andWhere('p.pref_key = ?', $key)->fetchOne();
if (!$result) {
$result = new Preferences();
$result->fromArray(array('user_ref' => $user_id, 'pref_key' => $key));
}
$result->setPrefValue($value);
$result->save();
return true;
}
示例2: save_prefs
/**
* Saves user preferences
*/
function save_prefs($username, Preferences $prefs)
{
$data = array('options' => $prefs->to_json());
log_message('DEBUG', 'Storing user prefs [' . $prefs->to_json() . ']' . ' for user ' . $username);
$query = $this->db->get_where('prefs', array('username' => $username));
if ($query->num_rows() == 1) {
$this->db->update('prefs', $data, array('username' => $username));
} else {
$data['username'] = $username;
$this->db->insert('prefs', $data);
}
}
示例3: read
function read($sessId)
{
$prefs = new Preferences();
$idle = $prefs->idleTime();
$expiry = time() - $idle;
$query = "SELECT data FROM Sessions WHERE sessId='{$sessId}' AND lastAccess >= {$expiry}";
$data = parent::query($query);
if (isset($data[0])) {
return $data[0]['data'];
} else {
return '';
}
}
示例4: getInstance
/**
* @return Preferences
*/
public static function getInstance()
{
if (!self::$_instance) {
self::$_instance = new Preferences();
}
return self::$_instance;
}
示例5: dataField
function dataField($sessId)
{
$prefs = new Preferences();
$idle = $prefs->idleTime();
$expiry = time() - $idle;
$query = "SELECT data FROM Sessions WHERE sessId='{$sessId}' AND lastAccess >= {$expiry}";
$session = parent::query($query);
$validData = parent::validateIndexes($session, 0, 'data');
$vars = preg_split('/([a-z,A-Z]+)\\|/', $validData, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
if (isset($vars[1])) {
$validData = unserialize($vars[1]);
return $validData;
} else {
return null;
}
}
示例6: get_login
public function get_login()
{
$userDB = UserDB::getInstance();
if (!is_object($userDB)) {
return NULL;
}
$prefs = Preferences::getInstance();
$config = $prefs->get('AuthMethod', 'Auto');
if (array_key_exists('login', $_POST) && array_key_exists('uselogin', $config) && $config['uselogin'] == '1') {
$this->login = $_POST['login'];
} else {
$this->login = 'u' . gen_unique_string();
}
$u = new User();
$u->setAttribute('login', $this->login);
$u->setAttribute('password', $u->getAttribute('login'));
$u->setAttribute('displayname', 'user ' . $u->getAttribute('login'));
if ($userDB->add($u)) {
$user = $userDB->import($u->getAttribute('login'));
} else {
Logger::error('main', 'AuthMethod::Auto::get_login failed to add user ' . $u->getAttribute('login'));
return NULL;
}
if (!is_object($user)) {
return NULL;
}
$this->login = $user->getAttribute('login');
return $this->login;
}
示例7: getInstance
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = self::$mockmode ? new PreferencesMock() : new PreferencesImpl();
}
return self::$instance;
}
示例8: execute
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->disallowUserJs();
# Prevent hijacked user scripts from sniffing passwords etc.
$user = $this->getUser();
if ($user->isAnon()) {
$out->showErrorPage('prefsnologin', 'prefsnologintext', array($this->getTitle()->getPrefixedDBkey()));
return;
}
$this->checkReadOnly();
if ($par == 'reset') {
$this->showResetForm();
return;
}
$out->addModules('mediawiki.special.preferences');
if ($this->getRequest()->getCheck('success')) {
$out->wrapWikiMsg("<div class=\"successbox\"><strong>\n\$1\n</strong></div><div id=\"mw-pref-clear\"></div>", 'savedprefs');
}
$htmlForm = Preferences::getFormObject($user, $this->getContext());
$htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
$htmlForm->show();
}
示例9: execute
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->disallowUserJs();
# Prevent hijacked user scripts from sniffing passwords etc.
$this->requireLogin('prefsnologintext2');
$this->checkReadOnly();
if ($par == 'reset') {
$this->showResetForm();
return;
}
$out->addModules('mediawiki.special.preferences');
$out->addModuleStyles('mediawiki.special.preferences.styles');
if ($this->getRequest()->getCheck('success')) {
$out->wrapWikiMsg(Html::rawElement('div', array('class' => 'mw-preferences-messagebox successbox', 'id' => 'mw-preferences-success'), Html::element('p', array(), '$1')), 'savedprefs');
}
$this->addHelpLink('Help:Preferences');
// Load the user from the master to reduce CAS errors on double post (T95839)
$user = $this->getUser()->getInstanceForUpdate() ?: $this->getUser();
$htmlForm = Preferences::getFormObject($user, $this->getContext());
$htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
$sectionTitles = $htmlForm->getPreferenceSections();
$prefTabs = '';
foreach ($sectionTitles as $key) {
$prefTabs .= Html::rawElement('li', array('role' => 'presentation', 'class' => $key === 'personal' ? 'selected' : null), Html::rawElement('a', array('id' => 'preftab-' . $key, 'role' => 'tab', 'href' => '#mw-prefsection-' . $key, 'aria-controls' => 'mw-prefsection-' . $key, 'aria-selected' => $key === 'personal' ? 'true' : 'false', 'tabIndex' => $key === 'personal' ? 0 : -1), $htmlForm->getLegend($key)));
}
$out->addHTML(Html::rawElement('ul', array('id' => 'preftoc', 'role' => 'tablist'), $prefTabs));
$htmlForm->show();
}
示例10: getPreferencesForm
/**
* @param {String} $key valid key as specified in validTabs
* @return {HtmlForm}
*/
public function getPreferencesForm($key)
{
$prefs = array();
$user = $this->getUser();
$ctx = $this->getContext();
switch ($key) {
case 'personal':
Preferences::profilePreferences($user, $ctx, $prefs);
break;
case 'skin':
Preferences::skinPreferences($user, $ctx, $prefs);
break;
case 'dateformat':
Preferences::datetimePreferences($user, $ctx, $prefs);
break;
case 'files':
Preferences::filesPreferences($user, $ctx, $prefs);
break;
case 'rc':
Preferences::rcPreferences($user, $ctx, $prefs);
break;
}
Preferences::loadPreferenceValues($user, $ctx, $prefs);
$htmlForm = new PreferencesForm($prefs, $ctx, 'prefs');
$htmlForm->suppressReset();
$htmlForm->setModifiedUser($user);
$htmlForm->setId('mw-prefs-form');
$htmlForm->setSubmitText($ctx->msg('saveprefs')->text());
$htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
$htmlForm->setAction(SpecialPage::getTitleFor($this->getName(), $key)->getLocalUrl());
return $htmlForm;
}
示例11: execute
function execute($par)
{
global $wgOut, $wgUser, $wgRequest;
$this->setHeaders();
$this->outputHeader();
$wgOut->disallowUserJs();
# Prevent hijacked user scripts from sniffing passwords etc.
if ($wgUser->isAnon()) {
$wgOut->showErrorPage('prefsnologin', 'prefsnologintext', array($this->getTitle()->getPrefixedDBkey()));
return;
}
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return;
}
if ($par == 'reset') {
$this->showResetForm();
return;
}
$wgOut->addModules('mediawiki.legacy.prefs');
$wgOut->addModules('mediawiki.special.preferences');
if ($wgRequest->getCheck('success')) {
$wgOut->wrapWikiMsg("<div class=\"successbox\"><strong>\n\$1\n</strong></div><div id=\"mw-pref-clear\"></div>", 'savedprefs');
}
if ($wgRequest->getCheck('eauth')) {
$wgOut->wrapWikiMsg("<div class='error' style='clear: both;'>\n\$1\n</div>", 'eauthentsent', $wgUser->getName());
}
$htmlForm = Preferences::getFormObject($wgUser);
$htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
$htmlForm->show();
}
示例12: __construct
public function __construct()
{
parent::__construct();
$prefs = Preferences::getInstance();
if (!$prefs) {
die_error('get Preferences failed', __FILE__, __LINE__);
}
$a_pref = $prefs->get('UserGroupDB', 'activedirectory');
if (is_array($a_pref)) {
foreach ($a_pref as $k => $v) {
$this->preferences[$k] = $v;
}
}
// Generate parent (ldap) settings
$this->preferences['filter'] = '(objectClass=group)';
$this->preferences['match'] = array('name' => 'name', 'description' => 'description');
$this->preferences['group_match_user'] = array('user_field', 'group_field');
$this->preferences['user_field'] = 'memberOf';
$this->preferences['user_field_type'] = 'group_dn';
$this->preferences['group_field'] = 'member';
$this->preferences['group_field_type'] = 'user_dn';
$this->preferences['ou'] = '';
if (array_key_exists('use_child_group', $this->preferences)) {
if (in_array($this->preferences['use_child_group'], array(1, '1'))) {
$this->preferences['user_field'] .= ':1.2.840.113556.1.4.1941:';
$this->preferences['group_field'] .= ':1.2.840.113556.1.4.1941:';
}
}
}
示例13: execute
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->disallowUserJs();
# Prevent hijacked user scripts from sniffing passwords etc.
$user = $this->getUser();
if ($user->isAnon()) {
$out->showErrorPage('prefsnologin', 'prefsnologintext', array($this->getTitle()->getPrefixedDBkey()));
return;
}
$this->checkReadOnly();
if ($par == 'reset') {
$this->showResetForm();
return;
}
$out->addModules('mediawiki.special.preferences');
/* Wikia change begin - @author: macbre */
/* Enable custom notifications handling */
wfRunHooks('SpecialPreferencesOnRender', array(&$this));
/* Wikia change end */
if ($this->getRequest()->getCheck('success')) {
$out->wrapWikiMsg("<div class=\"successbox\"><strong>\n\$1\n</strong></div><div id=\"mw-pref-clear\"></div>", 'savedprefs');
}
if ($this->getRequest()->getCheck('eauth')) {
$out->wrapWikiMsg("<div class='error' style='clear: both;'>\n\$1</div>", 'eauthentsent', $user->getName());
}
$htmlForm = Preferences::getFormObject($user, $this->getContext());
$htmlForm->setSubmitCallback(array('Preferences', 'tryUISubmit'));
$htmlForm->show();
}
示例14: singleton
public static function singleton($options = array())
{
if (!isset(self::$instance)) {
self::$instance = new Preferences($options);
}
return self::$instance;
}
示例15: callMethod
public static function callMethod($method_name_, $type_, $element_ = NULL, $group_ = NULL)
{
Logger::debug('main', "Abstract_Liaison::callMethod ('{$method_name_}', '{$type_}', '{$element_}', '{$group_}')");
if ($type_ != 'UsersGroup') {
$method_to_call = array('Abstract_Liaison_sql', $method_name_);
$class_to_use = 'Abstract_Liaison_sql';
} else {
$prefs = Preferences::getInstance();
if (!$prefs) {
Logger::error('main', 'Abstract_Liaison::load get Preferences failed');
return NULL;
}
$mods_enable = $prefs->get('general', 'module_enable');
if (!in_array('UserGroupDB', $mods_enable)) {
Logger::error('main', 'Abstract_Liaison::load UserGroupDB module must be enabled');
return NULL;
}
$mod_usergroup_name = 'UserGroupDB_' . $prefs->get('UserGroupDB', 'enable');
$liaison_type = call_user_func(array($mod_usergroup_name, 'liaisonType'));
$method_to_call = array('Abstract_Liaison_' . $liaison_type, $method_name_);
$class_to_use = 'Abstract_Liaison_' . $liaison_type;
}
if (!method_exists($class_to_use, $method_name_)) {
Logger::error('main', "Abstract_Liaison::callMethod method '{$method_to_call}' does not exist");
return NULL;
}
return call_user_func($method_to_call, $type_, $element_, $group_);
}