当前位置: 首页>>代码示例>>PHP>>正文


PHP Preference::clear_from_session方法代码示例

本文整理汇总了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();
}
开发者ID:cheese1,项目名称:ampache,代码行数:52,代码来源:preferences.php

示例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;
 }
开发者ID:nioc,项目名称:ampache,代码行数:36,代码来源:preference.class.php


注:本文中的Preference::clear_from_session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。