本文整理汇总了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;
}
示例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;
}
示例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;
}