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


PHP Catalog::get_enable_filter方法代码示例

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


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

示例1: get_tag_objects

 /**
  * get_tag_objects
  * This gets the objects from a specified tag and returns an array of object ids, nothing more
  */
 public static function get_tag_objects($type, $tag_id, $count = '', $offset = '')
 {
     if (!Core::is_library_item($type)) {
         return false;
     }
     $limit_sql = "";
     if ($count) {
         $limit_sql = "LIMIT ";
         if ($offset) {
             $limit_sql .= intval($offset) . ',';
         }
         $limit_sql .= intval($count);
     }
     $sql = "SELECT DISTINCT `tag_map`.`object_id` FROM `tag_map` " . "WHERE `tag_map`.`tag_id` = ? AND `tag_map`.`object_type` = ? {$limit_sql} ";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= "AND " . Catalog::get_enable_filter($type, '`tag_map`.`object_id`');
     }
     $db_results = Dba::read($sql, array($tag_id, $type));
     $results = array();
     while ($row = Dba::fetch_assoc($db_results)) {
         $results[] = $row['object_id'];
     }
     return $results;
 }
开发者ID:nioc,项目名称:ampache,代码行数:28,代码来源:tag.class.php

示例2: get_filter_sql

 /**
  * get_filter_sql
  * This returns the filter part of the sql statement
  */
 private function get_filter_sql()
 {
     if (!is_array($this->_state['filter'])) {
         return '';
     }
     $sql = "WHERE 1=1 AND ";
     foreach ($this->_state['filter'] as $key => $value) {
         $sql .= $this->sql_filter($key, $value);
     }
     if (AmpConfig::get('catalog_disable')) {
         // Add catalog enabled filter
         switch ($this->get_type()) {
             case "video":
             case "song":
                 $dis = Catalog::get_enable_filter($this->get_type(), '`' . $this->get_type() . '`.`id`');
                 break;
             case "tag":
                 $dis = Catalog::get_enable_filter($this->get_type(), '`' . $this->get_type() . '`.`object_id`');
                 break;
         }
     }
     if (!empty($dis)) {
         $sql .= $dis . " AND ";
     }
     $sql = rtrim($sql, 'AND ') . ' ';
     return $sql;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:31,代码来源:query.class.php

示例3: get_highest_sql

 /**
  * get_highest_sql
  * Get highest sql
  */
 public static function get_highest_sql($type)
 {
     $type = Stats::validate_type($type);
     $sql = "SELECT `object_id` as `id`, AVG(`rating`) AS `rating` FROM rating" . " WHERE object_type = '" . $type . "'";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= " AND " . Catalog::get_enable_filter($type, '`object_id`');
     }
     $sql .= " GROUP BY object_id ORDER BY `rating` DESC ";
     return $sql;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:14,代码来源:rating.class.php

示例4: get_recent_sql

 /**
  * get_recent_sql
  * This returns the get_recent sql
  */
 public static function get_recent_sql($type, $user_id = '')
 {
     $type = self::validate_type($type);
     $user_sql = '';
     if (!empty($user_id)) {
         $user_sql = " AND `user` = '" . $user_id . "'";
     }
     $sql = "SELECT DISTINCT(`object_id`) as `id`, MAX(`date`) FROM object_count" . " WHERE `object_type` = '" . $type . "'" . $user_sql;
     if (AmpConfig::get('catalog_disable')) {
         $sql .= " AND " . Catalog::get_enable_filter($type, '`object_id`');
     }
     $sql .= " GROUP BY `object_id` ORDER BY MAX(`date`) DESC, `id` ";
     return $sql;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:18,代码来源:stats.class.php

示例5: get_latest_sql

 /**
  * get_latest_sql
  * Get the latest sql
  */
 public static function get_latest_sql($type, $user_id = null)
 {
     if (is_null($user_id)) {
         $user_id = $GLOBALS['user']->id;
     }
     $user_id = intval($user_id);
     $type = Stats::validate_type($type);
     $sql = "SELECT `object_id` as `id` FROM user_flag" . " WHERE object_type = '" . $type . "' AND `user` = '" . $user_id . "'";
     if (AmpConfig::get('catalog_disable')) {
         $sql .= " AND " . Catalog::get_enable_filter($type, '`object_id`');
     }
     $sql .= " ORDER BY `date` DESC ";
     return $sql;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:18,代码来源:userflag.class.php

示例6: get_latest_sql

 /**
  * get_latest_sql
  * Get the latest sql
  */
 public static function get_latest_sql($type, $user_id = null)
 {
     if (is_null($user_id)) {
         $user_id = $GLOBALS['user']->id;
     }
     $user_id = intval($user_id);
     $sql = "SELECT `user_flag`.`object_id` as `id`, `user_flag`.`object_type` as `type`, `user_flag`.`user` as `user` FROM `user_flag`";
     if ($user_id <= 0) {
         // Get latest only from user rights >= content manager
         $sql .= " LEFT JOIN `user` ON `user`.`id` = `user_flag`.`user`" . " WHERE `user`.`access` >= 50";
     }
     if (!is_null($type)) {
         if ($user_id <= 0) {
             $sql .= " AND";
         } else {
             $sql .= " WHERE";
         }
         $type = Stats::validate_type($type);
         $sql .= " `user_flag`.`object_type` = '" . $type . "'";
         if ($user_id > 0) {
             $sql .= " AND `user_flag`.`user` = '" . $user_id . "'";
         }
         if (AmpConfig::get('catalog_disable')) {
             $sql .= " AND " . Catalog::get_enable_filter($type, '`object_id`');
         }
     }
     $sql .= " ORDER BY `user_flag`.`date` DESC ";
     return $sql;
 }
开发者ID:nioc,项目名称:ampache,代码行数:33,代码来源:userflag.class.php

示例7: get_artists_like

 /**
  * get_artists_like
  * Returns a list of similar artists
  */
 public static function get_artists_like($artist_id, $limit = 10, $local_only = true)
 {
     $artist = new Artist($artist_id);
     $cache = self::get_recommendation_cache('artist', $artist_id, true);
     if (!$cache['id']) {
         $similars = array();
         $query = 'artist=' . rawurlencode($artist->name);
         $xml = self::get_lastfm_results('artist.getsimilar', $query);
         foreach ($xml->similarartists->children() as $child) {
             $name = $child->name;
             $mbid = (string) $child->mbid;
             $local_id = null;
             // First we check by MBID
             if ($mbid) {
                 $sql = "SELECT `artist`.`id` FROM `artist` WHERE `mbid` = ?";
                 if (AmpConfig::get('catalog_disable')) {
                     $sql .= " AND " . Catalog::get_enable_filter('artist', '`artist`.`id`');
                 }
                 $db_result = Dba::read($sql, array($mbid));
                 if ($result = Dba::fetch_assoc($db_result)) {
                     $local_id = $result['id'];
                 }
             }
             // Then we fall back to the less likely to work exact
             // name match
             if (is_null($local_id)) {
                 $searchname = Catalog::trim_prefix($name);
                 $searchname = Dba::escape($searchname['string']);
                 $sql = "SELECT `artist`.`id` FROM `artist` WHERE `name` = ?";
                 if (AmpConfig::get('catalog_disable')) {
                     $sql .= " AND " . Catalog::get_enable_filter('artist', '`artist`.`id`');
                 }
                 $db_result = Dba::read($sql, array($searchname));
                 if ($result = Dba::fetch_assoc($db_result)) {
                     $local_id = $result['id'];
                 }
             }
             // Then we give up
             if (is_null($local_id)) {
                 debug_event('Recommendation', "{$name} did not match any local artist", 5);
                 $similars[] = array('id' => null, 'name' => $name, 'mbid' => $mbid);
             } else {
                 debug_event('Recommendation', "{$name} matched local artist " . $local_id, 5);
                 $similars[] = array('id' => $local_id, 'name' => $name);
             }
         }
         if (count($similars) > 0) {
             self::update_recommendation_cache('artist', $artist_id, $similars);
         }
     }
     if (!isset($similars) || count($similars) == 0) {
         $similars = $cache['items'];
     }
     if ($similars) {
         $results = array();
         foreach ($similars as $similar) {
             if (!$local_only || !is_null($similar['id'])) {
                 $results[] = $similar;
             }
             if ($limit && count($results) >= $limit) {
                 break;
             }
         }
     }
     if (isset($results)) {
         return $results;
     }
     return false;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:73,代码来源:recommendation.class.php

示例8: 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


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