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


PHP Preference::id_from_name方法代码示例

本文整理汇总了PHP中Preference::id_from_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Preference::id_from_name方法的具体用法?PHP Preference::id_from_name怎么用?PHP Preference::id_from_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Preference的用法示例。


在下文中一共展示了Preference::id_from_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_user_preferences

 /**
  * set_user_preferences
  * This sets up a (or all) user(s) to use democratic play. This sets
  * their play method and playlist method (clear on send) If no user is
  * passed it does it for everyone and also locks down the ability to
  * change to admins only
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public static function set_user_preferences($user = null)
 {
     //FIXME: Code in single user stuff
     $preference_id = Preference::id_from_name('play_type');
     Preference::update_level($preference_id, '75');
     Preference::update_all($preference_id, 'democratic');
     $allow_demo = Preference::id_from_name('allow_democratic_playback');
     Preference::update_all($allow_demo, '1');
     $play_method = Preference::id_from_name('playlist_method');
     Preference::update_all($play_method, 'clear');
     return true;
 }
开发者ID:cheese1,项目名称:ampache,代码行数:21,代码来源:democratic.class.php

示例2: get_now_playing

 /**
  * get_now_playing
  *
  * This returns the now playing information
  */
 public static function get_now_playing()
 {
     $sql = 'SELECT `session`.`agent`, `np`.* FROM `now_playing` AS `np` ';
     $sql .= 'LEFT JOIN `session` ON `session`.`id` = `np`.`id` ';
     if (AmpConfig::get('now_playing_per_user')) {
         $sql .= 'INNER JOIN ( ' . 'SELECT MAX(`insertion`) AS `max_insertion`, `user`, `id` ' . 'FROM `now_playing` ' . 'GROUP BY `user`' . ') `np2` ' . 'ON `np`.`user` = `np2`.`user` ' . 'AND `np`.`insertion` = `np2`.`max_insertion` ';
     }
     if (!Access::check('interface', '100')) {
         // We need to check only for users which have allowed view of personnal info
         $personal_info_id = Preference::id_from_name('allow_personal_info_now');
         if ($personal_info_id) {
             $current_user = $GLOBALS['user']->id;
             $sql .= "WHERE (`np`.`user` IN (SELECT `user` FROM `user_preference` WHERE ((`preference`='{$personal_info_id}' AND `value`='1') OR `user`='{$current_user}'))) ";
         }
     }
     $sql .= 'ORDER BY `np`.`expire` DESC';
     $db_results = Dba::read($sql);
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         $type = $row['object_type'];
         $media = new $type($row['object_id']);
         $media->format();
         $client = new User($row['user']);
         $results[] = array('media' => $media, 'client' => $client, 'agent' => $row['agent'], 'expire' => $row['expire']);
     }
     // end while
     return $results;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:33,代码来源:stream.class.php

示例3: get_recently_played

 /**
  * get_recently_played
  * This function returns the last X songs that have been played
  * it uses the popular threshold to figure out how many to pull
  * it will only return unique object
  * @param int $user_id
  * @return array
  */
 public static function get_recently_played($user_id = 0)
 {
     $user_id = intval($user_id);
     $sql = "SELECT `object_id`, `user`, `object_type`, `date`, `agent`, `geo_latitude`, `geo_longitude`, `geo_name` " . "FROM `object_count` WHERE `object_type` = 'song' AND `count_type` = 'stream' ";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= "AND " . Catalog::get_enable_filter('song', '`object_id`') . " ";
     }
     if ($user_id) {
         // If user is not empty, we're looking directly to user personal info (admin view)
         $sql .= "AND `user`='{$user_id}' ";
     } else {
         if (!Access::check('interface', '100')) {
             // If user identifier is empty, we need to retrieve only users which have allowed view of personnal info
             $personal_info_id = Preference::id_from_name('allow_personal_info_recent');
             if ($personal_info_id) {
                 $current_user = $GLOBALS['user']->id;
                 $sql .= "AND `user` IN (SELECT `user` FROM `user_preference` WHERE (`preference`='{$personal_info_id}' AND `value`='1') OR `user`='{$current_user}') ";
             }
         }
     }
     $sql .= "ORDER BY `date` DESC ";
     $db_results = Dba::read($sql);
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         if (empty($row['geo_name']) && $row['latitude'] && $row['longitude']) {
             $row['geo_name'] = Stats::get_cached_place_name($row['latitude'], $row['longitude']);
         }
         $results[] = $row;
         if (count($results) >= AmpConfig::get('popular_threshold')) {
             break;
         }
     }
     return $results;
 }
开发者ID:nioc,项目名称:ampache,代码行数:42,代码来源:song.class.php


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