本文整理汇总了PHP中Preference::clear_from_session方法的典型用法代码示例。如果您正苦于以下问题:PHP Preference::clear_from_session方法的具体用法?PHP Preference::clear_from_session怎么用?PHP Preference::clear_from_session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Preference
的用法示例。
在下文中一共展示了Preference::clear_from_session方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_preferences
function update_preferences($pref_id = 0)
{
/* Get current keys */
$sql = "SELECT `id`,`name`,`type` FROM `preference`";
/* If it isn't the System Account's preferences */
if ($pref_id != '-1') {
$sql .= " WHERE `catagory` != 'system'";
}
$db_results = Dba::read($sql);
$results = array();
// Collect the current possible keys
while ($r = Dba::fetch_assoc($db_results)) {
$results[] = array('id' => $r['id'], 'name' => $r['name'], 'type' => $r['type']);
}
// end collecting keys
/* Foreach through possible keys and assign them */
foreach ($results as $data) {
/* Get the Value from POST/GET var called $data */
$name = $data['name'];
$apply_to_all = 'check_' . $data['name'];
$new_level = 'level_' . $data['name'];
$id = $data['id'];
$value = scrub_in($_REQUEST[$name]);
/* Some preferences require some extra checks to be performed */
switch ($name) {
case 'transcode_bitrate':
$value = Stream::validate_bitrate($value);
break;
default:
break;
}
if (preg_match('/_pass$/', $name)) {
if ($value == '******') {
unset($_REQUEST[$name]);
} else {
if (preg_match('/md5_pass$/', $name)) {
$value = md5($value);
}
}
}
/* Run the update for this preference only if it's set */
if (isset($_REQUEST[$name])) {
Preference::update($id, $pref_id, $value, $_REQUEST[$apply_to_all]);
}
if (Access::check('interface', '100') && $_REQUEST[$new_level]) {
Preference::update_level($id, $_REQUEST[$new_level]);
}
}
// end foreach preferences
// Now that we've done that we need to invalidate the cached preverences
Preference::clear_from_session();
}
示例2: update
/**
* update
* This updates a single preference from the given name or id
*/
public static function update($preference, $user_id, $value, $applytoall = false, $applytodefault = false)
{
// First prepare
if (!is_numeric($preference)) {
$id = self::id_from_name($preference);
$name = $preference;
} else {
$name = self::name_from_id($preference);
$id = $preference;
}
if ($applytoall and Access::check('interface', '100')) {
$user_check = "";
} else {
$user_check = " AND `user`='{$user_id}'";
}
if ($applytodefault and Access::check('interface', '100')) {
$sql = "UPDATE `preference` SET `value`='{$value}' WHERE `id`='{$id}'";
Dba::write($sql);
}
$value = Dba::escape($value);
if (self::has_access($name)) {
$user_id = Dba::escape($user_id);
$sql = "UPDATE `user_preference` SET `value`='{$value}' WHERE `preference`='{$id}'{$user_check}";
Dba::write($sql);
Preference::clear_from_session();
parent::remove_from_cache('get_by_user', $user_id);
return true;
} else {
debug_event('denied', $GLOBALS['user'] ? $GLOBALS['user']->username : '???' . ' attempted to update ' . $name . ' but does not have sufficient permissions', 3);
}
return false;
}