Skip to content

Commit

Permalink
merge userflags -> ratings
Browse files Browse the repository at this point in the history
this is an extra check and they're not really separated now.
  • Loading branch information
lachlan-00 committed Sep 6, 2021
1 parent 8145afb commit 0a8ae19
Show file tree
Hide file tree
Showing 53 changed files with 48 additions and 171 deletions.
7 changes: 1 addition & 6 deletions config/ampache.cfg.php.dist
Expand Up @@ -463,6 +463,7 @@ default_auth_level = "guest"

; 5 Star Ratings
; This allows ratings for almost any object in Ampache
: It also allows users to flag objects as a favorite
; POSSIBLE VALUES: false true
; DEFAULT: "true"
ratings = "true"
Expand All @@ -485,12 +486,6 @@ ratings = "true"
; DEFAULT: -1
;rating_file_tag_user = 1

; User flags/favorites
; This allows user flags for almost any object in Ampache as favorite
; POSSIBLE VALUES: false true
; DEFAULT: "true"
userflags = "true"

; Direct play
; This allows user to play directly a song or album
; POSSIBLE VALUES: false true
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
### Changed

* Always update time when updating songs and videos from tags
* Merge config 'ratings' and 'userflags' checks into ratings. (drop userflags)

### Fixed

Expand Down
33 changes: 15 additions & 18 deletions public/templates/header.inc.php
Expand Up @@ -430,17 +430,15 @@ function libitem_action(item, action)
</a>
</div>

<?php
if (AmpConfig::get('userflags') && Access::check('interface', 25)) { ?>
<?php if (AmpConfig::get('ratings') && Access::check('interface', 25)) { ?>
<div class="topmenu_item">
<a href="<?php echo $web_path ?>/stats.php?action=userflag">
<?php echo Ui::get_image('topmenu-favorite', $t_favorites); ?>
<span><?php echo $t_favorites ?></span>
</a>
</div>

<?php
}
<?php }
if (AmpConfig::get('allow_upload') && Access::check('interface', 25)) { ?>
<div class="topmenu_item">
<a href="<?php echo $web_path ?>/upload.php">
Expand Down Expand Up @@ -511,19 +509,18 @@ function libitem_action(item, action)

<div id="content" class="content-<?php echo AmpConfig::get('ui_fixed') ? (AmpConfig::get('topmenu') ? 'fixed-topmenu' : 'fixed') : 'float'; ?> <?php echo(($count_temp_playlist || AmpConfig::get('play_type') == 'localplay') ? '' : 'content-right-wild'); echo $isCollapsed ? ' content-left-wild' : ''; ?>">

<?php
if (Access::check('interface', 100)) {
echo '<div id=update_notify>';
//if (!AmpConfig::get('hide_ampache_messages', false)) {
// AutoUpdate::show_ampache_message();
//}
if (AmpConfig::get('autoupdate') && AutoUpdate::is_update_available()) {
AutoUpdate::show_new_version();
echo '<br />';
}
$count_temp_playlist = count(Core::get_global('user')->playlist->get_items());
<?php if (Access::check('interface', 100)) {
echo '<div id=update_notify>';
//if (!AmpConfig::get('hide_ampache_messages', false)) {
// AutoUpdate::show_ampache_message();
//}
if (AmpConfig::get('autoupdate') && AutoUpdate::is_update_available()) {
AutoUpdate::show_new_version();
echo '<br />';
}
$count_temp_playlist = count(Core::get_global('user')->playlist->get_items());

if (AmpConfig::get('int_config_version') > AmpConfig::get('config_version')) { ?>
if (AmpConfig::get('int_config_version') > AmpConfig::get('config_version')) { ?>
<div class="fatalerror">
<?php echo T_('Your Ampache config file is out of date!'); ?>
<br />
Expand All @@ -532,8 +529,8 @@ function libitem_action(item, action)
</div>
<?php
}
echo '</div>';
}
echo '</div>';
}
if (AmpConfig::get("ajax_load")) {
require Ui::find_template('show_web_player_embedded.inc.php');
} // load the web_player early to make sure the browser doesn't block audio playback?>
Expand Down
3 changes: 0 additions & 3 deletions public/templates/show_album.inc.php
Expand Up @@ -90,9 +90,6 @@
<span id="rating_<?php echo $album->id; ?>_album">
<?php echo Rating::show($album->id, 'album', true); ?>
</span>
<?php
} ?>
<?php if (AmpConfig::get('userflags')) { ?>
<span id="userflag_<?php echo $album->id; ?>_album">
<?php echo Userflag::show($album->id, 'album'); ?>
</span>
Expand Down
3 changes: 0 additions & 3 deletions public/templates/show_album_group_disks.inc.php
Expand Up @@ -90,9 +90,6 @@
<span id="rating_<?php echo $album->id; ?>_album">
<?php echo Rating::show($album->id, 'album'); ?>
</span>
<?php
} ?>
<?php if (AmpConfig::get('userflags')) { ?>
<span id="userflag_<?php echo $album->id; ?>_album">
<?php echo Userflag::show($album->id, 'album'); ?>
</span>
Expand Down
4 changes: 0 additions & 4 deletions public/templates/show_album_row.inc.php
Expand Up @@ -99,10 +99,6 @@
<span class="cel_rating" id="rating_<?php echo $libitem->id; ?>_album">
<?php echo Rating::show($libitem->id, 'album'); ?>
</span>
<?php
} ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_userflag" id="userflag_<?php echo $libitem->id; ?>_album">
<?php echo Userflag::show($libitem->id, 'album'); ?>
</span>
Expand Down
6 changes: 2 additions & 4 deletions public/templates/show_albums.inc.php
Expand Up @@ -36,7 +36,7 @@

$web_path = AmpConfig::get('web_path');
$thcount = 9;
$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$hide_genres = AmpConfig::get('hide_genres');
$is_table = $browse->is_grid_view();
$group_release = AmpConfig::get('album_release_type');
Expand Down Expand Up @@ -98,10 +98,8 @@
<tbody>
<?php if (AmpConfig::get('ratings')) {
Rating::build_cache('album', $object_ids);
Userflag::build_cache('album', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('album', $object_ids);
}

$show_direct_play_cfg = AmpConfig::get('directplay');
$directplay_limit = AmpConfig::get('direct_play_limit');
Expand Down
2 changes: 0 additions & 2 deletions public/templates/show_artist.inc.php
Expand Up @@ -85,8 +85,6 @@
<span id="rating_<?php echo (int) ($artist->id); ?>_artist">
<?php echo Rating::show($artist->id, 'artist', true); ?>
</span>
<?php } ?>
<?php if (AmpConfig::get('userflags')) { ?>
<span id="userflag_<?php echo $artist->id; ?>_artist">
<?php echo Userflag::show($artist->id, 'artist'); ?>
</span>
Expand Down
3 changes: 0 additions & 3 deletions public/templates/show_artist_row.inc.php
Expand Up @@ -84,9 +84,6 @@
<span class="cel_rating" id="rating_<?php echo $libitem->id; ?>_artist">
<?php echo Rating::show($libitem->id, 'artist'); ?>
</span>
<?php } ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_userflag" id="userflag_<?php echo $libitem->id; ?>_artist">
<?php echo Userflag::show($libitem->id, 'artist'); ?>
</span>
Expand Down
4 changes: 1 addition & 3 deletions public/templates/show_artists.inc.php
Expand Up @@ -38,7 +38,7 @@

$web_path = AmpConfig::get('web_path');
$thcount = 8;
$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$hide_genres = AmpConfig::get('hide_genres');
$is_table = $browse->is_grid_view();
// translate depending on the browse type
Expand Down Expand Up @@ -87,8 +87,6 @@
// Cache the ratings we are going to use
if (AmpConfig::get('ratings')) {
Rating::build_cache('artist', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('artist', $object_ids);
}

Expand Down
2 changes: 0 additions & 2 deletions public/templates/show_now_playing_row.inc.php
Expand Up @@ -112,8 +112,6 @@
<span id="rating_<?php echo $media->id; ?>_song">
<?php echo Rating::show($media->id, 'song'); ?>
</span>
<?php }
if (AmpConfig::get('userflags')) { ?>
<span id="userflag_<?php echo $media->id; ?>_song">
<?php echo Userflag::show($media->id, 'song'); ?>
</span>
Expand Down
2 changes: 0 additions & 2 deletions public/templates/show_playlist.inc.php
Expand Up @@ -55,8 +55,6 @@
<span id="rating_<?php echo $playlist->id; ?>_playlist">
<?php echo Rating::show($playlist->id, 'playlist'); ?>
</span>
<?php } ?>
<?php if (AmpConfig::get('userflags')) { ?>
<span id="userflag_<?php echo $playlist->id; ?>_playlist">
<?php echo Userflag::show($playlist->id, 'playlist'); ?>
</span>
Expand Down
4 changes: 0 additions & 4 deletions public/templates/show_playlist_media_row.inc.php
Expand Up @@ -73,10 +73,6 @@
<span class="cel_rating" id="rating_<?php echo $libitem->id ?>_<?php echo $object_type ?>">
<?php echo Rating::show($libitem->id, $object_type) ?>
</span>
<?php
} ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_userflag" id="userflag_<?php echo $libitem->id ?>_<?php echo $object_type ?>">
<?php echo Userflag::show($libitem->id, $object_type) ?>
</span>
Expand Down
2 changes: 1 addition & 1 deletion public/templates/show_playlist_medias.inc.php
Expand Up @@ -35,7 +35,7 @@
$web_path = AmpConfig::get('web_path');
$seconds = $browse->duration;
$duration = floor($seconds / 3600) . gmdate(":i:s", $seconds % 3600);
$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$hide_genres = AmpConfig::get('hide_genres');
$is_table = $browse->is_grid_view();
//mashup and grid view need different css
Expand Down
4 changes: 0 additions & 4 deletions public/templates/show_playlist_row.inc.php
Expand Up @@ -77,10 +77,6 @@
<span class="cel_rating" id="rating_<?php echo $libitem->id; ?>_playlist">
<?php echo Rating::show($libitem->id, 'playlist'); ?>
</span>
<?php
} ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_userflag" id="userflag_<?php echo $libitem->id; ?>_playlist">
<?php echo Userflag::show($libitem->id, 'playlist'); ?>
</span>
Expand Down
2 changes: 1 addition & 1 deletion public/templates/show_playlists.inc.php
Expand Up @@ -33,7 +33,7 @@

$is_table = $browse->is_grid_view();
$show_art = AmpConfig::get('playlist_art') || $browse->is_mashup();
$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$hide_genres = AmpConfig::get('hide_genres');
//mashup and grid view need different css
$cel_cover = ($is_table) ? "cel_cover" : 'grid_cover';?>
Expand Down
3 changes: 0 additions & 3 deletions public/templates/show_podcast.inc.php
Expand Up @@ -51,9 +51,6 @@
<span id="rating_<?php echo (int) ($podcast->id); ?>_podcast">
<?php echo Rating::show($podcast->id, 'podcast'); ?>
</span>
<?php } ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span id="userflag_<?php echo $podcast->id; ?>_podcast">
<?php echo Userflag::show($podcast->id, 'podcast'); ?>
</span>
Expand Down
3 changes: 0 additions & 3 deletions public/templates/show_podcast_episode.inc.php
Expand Up @@ -45,9 +45,6 @@
<?php echo Rating::show($episode->id, 'podcast_episode'); ?>
</div>
</dd>
<?php } ?>

<?php if (AmpConfig::get('userflags')) { ?>
<dt><?php echo T_('Fav.'); ?></dt>
<dd>
<div id="userflag_<?php echo $episode->id; ?>_podcast_episode">
Expand Down
4 changes: 0 additions & 4 deletions public/templates/show_podcast_episode_row.inc.php
Expand Up @@ -94,10 +94,6 @@
<span class="cel_rating" id="rating_<?php echo $libitem->id; ?>_podcast_episode">
<?php echo Rating::show($libitem->id, 'podcast_episode'); ?>
</span>
<?php
} ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_userflag" id="userflag_<?php echo $libitem->id; ?>_podcast_episode">
<?php echo Userflag::show($libitem->id, 'podcast_episode'); ?>
</span>
Expand Down
4 changes: 1 addition & 3 deletions public/templates/show_podcast_episodes.inc.php
Expand Up @@ -33,7 +33,7 @@
/** @var array $object_ids */

$thcount = 6;
$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$is_mashup = $browse->is_mashup();
$is_table = $browse->is_grid_view();
//mashup and grid view need different css
Expand Down Expand Up @@ -72,8 +72,6 @@
<?php
if (AmpConfig::get('ratings')) {
Rating::build_cache('podcast_episode', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('podcast_episode', $object_ids);
}

Expand Down
4 changes: 0 additions & 4 deletions public/templates/show_podcast_row.inc.php
Expand Up @@ -63,10 +63,6 @@
<td class="cel_ratings">
<?php if (AmpConfig::get('ratings')) { ?>
<span class="cel_rating" id="rating_<?php echo $libitem->id; ?>_podcast"><?php echo Rating::show($libitem->id, 'podcast'); ?></span>
<?php
} ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_userflag" id="userflag_<?php echo $libitem->id; ?>_podcast"><?php echo Userflag::show($libitem->id, 'podcast'); ?></span>
<?php
} ?>
Expand Down
4 changes: 1 addition & 3 deletions public/templates/show_podcasts.inc.php
Expand Up @@ -34,7 +34,7 @@
/** @var array $object_ids */

$thcount = 7;
$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$is_table = $browse->is_grid_view();
// translate once
$count_text = T_('# Played');
Expand Down Expand Up @@ -84,8 +84,6 @@
<?php
if (AmpConfig::get('ratings')) {
Rating::build_cache('podcast', $object_ids);
}
if (AmpConfig::get('userflags')) {
Userflag::build_cache('podcast', $object_ids);
}

Expand Down
3 changes: 0 additions & 3 deletions public/templates/show_random_albums.inc.php
Expand Up @@ -70,9 +70,6 @@
if (Access::check('interface', 25)) { ?>
<?php if (AmpConfig::get('ratings')) { ?>
<span class="cel_rating" id="rating_<?php echo $album->id; ?>_album"><?php echo Rating::show($album->id, 'album'); ?></span>
<?php } ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_rating" id="userflag_<?php echo $album->id; ?>_album"><?php echo Userflag::show($album->id, 'album'); ?></span>
<?php } ?>
<?php } ?>
Expand Down
3 changes: 0 additions & 3 deletions public/templates/show_random_videos.inc.php
Expand Up @@ -67,9 +67,6 @@
if (Access::check('interface', 25)) { ?>
<?php if (AmpConfig::get('ratings')) { ?>
<span class="cel_rating" id="rating_<?php echo $video->id; ?>_video"><?php echo Rating::show($video->id, 'video'); ?></span>
<?php } ?>

<?php if (AmpConfig::get('userflags')) { ?>
<span class="cel_rating" id="userflag_<?php echo $video->id; ?>_video"><?php echo Userflag::show($video->id, 'video'); ?></span>
<?php } ?>
<?php } ?>
Expand Down
13 changes: 5 additions & 8 deletions public/templates/show_recommended_artists.inc.php
Expand Up @@ -28,7 +28,7 @@
use Ampache\Repository\Model\Userflag;
use Ampache\Module\Util\Ui;

$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$hide_genres = AmpConfig::get('hide_genres');
$thcount = 7;
//mashup and grid view need different css
Expand Down Expand Up @@ -66,15 +66,12 @@
</tr>
</thead>
<tbody>
<?php
<?php if (AmpConfig::get('ratings')) {
// Cache the ratings we are going to use
if (AmpConfig::get('ratings')) {
Rating::build_cache('artist', $object_ids);
}
Rating::build_cache('artist', $object_ids);
// Cache the userflags we are going to use
if (AmpConfig::get('userflags')) {
Userflag::build_cache('artist', $object_ids);
}
Userflag::build_cache('artist', $object_ids);
}

/* Foreach through every artist that has been passed to us */
foreach ($object_ids as $artist_id) {
Expand Down
6 changes: 2 additions & 4 deletions public/templates/show_songs.inc.php
Expand Up @@ -39,7 +39,7 @@
/** @var string $limit_threshold */

$web_path = AmpConfig::get('web_path');
$show_ratings = User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags'));
$show_ratings = User::is_registered() && (AmpConfig::get('ratings'));
$hide_genres = AmpConfig::get('hide_genres');
$thcount = 7;
$is_table = $browse->is_grid_view();
Expand Down Expand Up @@ -107,8 +107,6 @@
<th class="cel_ratings optional"><?php echo T_('Rating'); ?></th>
<?php if (AmpConfig::get('ratings')) {
Rating::build_cache('song', $object_ids);
} ?>
<?php if (AmpConfig::get('userflags')) {
Userflag::build_cache('song', $object_ids);
} ?>
<?php
Expand Down Expand Up @@ -136,7 +134,7 @@
if ($libitem->enabled || Access::check('interface', 50)) {
$content = $talFactory->createTalView()
->setContext('USER_IS_REGISTERED', User::is_registered())
->setContext('USING_RATINGS', User::is_registered() && (AmpConfig::get('ratings') || AmpConfig::get('userflags')))
->setContext('USING_RATINGS', User::is_registered() && (AmpConfig::get('ratings')))
->setContext('SONG', $guiFactory->createSongViewAdapter($gatekeeper, $libitem))
->setContext('CONFIG', $guiFactory->createConfigViewAdapter())
->setContext('ARGUMENT_PARAM', $argument_param)
Expand Down

0 comments on commit 0a8ae19

Please sign in to comment.