Skip to content

Commit

Permalink
revised album bin handling
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan committed Jan 8, 2025
1 parent 799d993 commit bd09d57
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 25 deletions.
5 changes: 4 additions & 1 deletion api/Albums.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2025 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -140,6 +140,9 @@ public static function fromRecord($rec, $wantTracks = true) {
case "coll":
$value = $rec["iscoll"]?true:false;
break;
case "bin":
$value = $rec["location"] == ILibrary::LOCATION_STORAGE ? $rec[$field] ?? null : null;
break;
default:
$value = $rec[$field] ?? null;
break;
Expand Down
4 changes: 2 additions & 2 deletions api/OffsetPaginationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2025 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -191,7 +191,7 @@ protected function paginateOffset(RequestInterface $request, array $paginateOps,
$key = $locationMap[$normalKey];

// allow optional bin constraint for storage
if($key == "G" && $request->hasFilter("bin"))
if($key == ILibrary::LOCATION_STORAGE && $request->hasFilter("bin"))
$key .= "|" . $request->filterValue("bin");
}

Expand Down
8 changes: 7 additions & 1 deletion engine/ILibrary.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2025 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -62,6 +62,12 @@ interface ILibrary {
"S"=>"Single",
];

const LOCATION_AWAITING_REVIEW = 'E';
const LOCATION_IN_REVIEW = 'F';
const LOCATION_REVIEWED = 'H';
const LOCATION_STORAGE = 'G';
const LOCATION_LIBRARY = 'L';

const LOCATIONS = [
"D"=>"Received",
"E"=>"Review Shelf",
Expand Down
15 changes: 12 additions & 3 deletions engine/impl/EditorImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2025 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -50,8 +50,17 @@ private function getNextPubkey() {
}

public function insertUpdateAlbum(&$album, $tracks, $label) {
if($album["location"] != "F" && $album["location"] != "G")
$album["bin"] = "";
switch($album["location"]) {
case ILibrary::LOCATION_STORAGE:
break;
case ILibrary::LOCATION_IN_REVIEW:
$oa = $album['tag'] ? Engine::api(ILibrary::class)->search(ILibrary::ALBUM_KEY, 0, 1, $album['tag']) : [];
$album['bin'] = count($oa) && $oa[0]['location'] == ILibrary::LOCATION_IN_REVIEW ? $oa[0]['bin'] : '';
break;
default:
$album['bin'] = '';
break;
}

$name = $label && array_key_exists("name", $label) ?
mb_substr(trim($label["name"]), 0, PlaylistEntry::MAX_FIELD_LENGTH) : null;
Expand Down
22 changes: 8 additions & 14 deletions engine/impl/ReviewImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@
* Music review operations
*/
class ReviewImpl extends DBO implements IReview {
// these codes are defined in ILibrary::LOCATIONS
private const ALBUM_AWAITING_REVIEW = 'E'; // Review Shelf
private const ALBUM_IN_REVIEW = 'F'; // Out for Review
private const ALBUM_REVIEWED = 'H'; // Pending Approval
private const ALBUM_LIBRARY = 'L'; // Library

private const REVIEW_SHELF = [
self::ALBUM_AWAITING_REVIEW,
self::ALBUM_IN_REVIEW,
self::ALBUM_REVIEWED
ILibrary::LOCATION_AWAITING_REVIEW,
ILibrary::LOCATION_IN_REVIEW,
ILibrary::LOCATION_REVIEWED
];

private function getRecentSubquery($user = "", $weeks = 0, $loggedIn = 0) {
Expand Down Expand Up @@ -205,7 +199,7 @@ protected function syncHashtags(int $tag, string $user, ?string $review = null)
public function insertReview($tag, $private, $airname, $review, $user) {
// we must do these first as caller depends on lastInsertId from INSERT
$this->syncHashtags($tag, $user, $private ? null : $review);
$prev = $this->updateReviewShelf($tag, null, self::ALBUM_REVIEWED);
$prev = $this->updateReviewShelf($tag, null, ILibrary::LOCATION_REVIEWED);

$query = "INSERT INTO reviews " .
"(tag, user, created, private, review, airname) VALUES (" .
Expand Down Expand Up @@ -266,7 +260,7 @@ public function deleteReview($tag, $user) {
// delete any associated hashtags
if($count) {
$this->syncHashtags($tag, $user);
$this->updateReviewShelf($tag, null, self::ALBUM_AWAITING_REVIEW);
$this->updateReviewShelf($tag, null, ILibrary::LOCATION_AWAITING_REVIEW);
}

return $count;
Expand Down Expand Up @@ -303,13 +297,13 @@ function updateReviewShelf(int $tag, ?string $user = null, ?string $status = nul
if(!in_array($ostatus, self::REVIEW_SHELF))
return null;

$location = $ostatus == self::ALBUM_REVIEWED ?
self::ALBUM_LIBRARY : self::ALBUM_AWAITING_REVIEW;
$location = $ostatus == ILibrary::LOCATION_REVIEWED ?
ILibrary::LOCATION_LIBRARY : ILibrary::LOCATION_AWAITING_REVIEW;

$query = "UPDATE albumvol SET location = ?, bin = ?, updated = NOW() WHERE tag = ?";
$stmt = $this->prepare($query);
$stmt->bindValue(1, $status ??
($user ? self::ALBUM_IN_REVIEW : $location));
($user ? ILibrary::LOCATION_IN_REVIEW : $location));
$stmt->bindValue(2, $user);
$stmt->bindValue(3, $tag);
return $stmt->execute() ? $result : null;
Expand Down
2 changes: 1 addition & 1 deletion js/editor.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function changeList(list) {
html += '>' + htmlify(val) + '</A>';
field.html(html);
} else {
field.html(htmlify(key != 'bin' || items[index].attributes['location'] == 'Storage' ? val : ''));
field.html(htmlify(val));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions ui/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zookeeper Online
*
* @author Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]>
* @copyright Copyright (C) 1997-2025 Jim Mason <[email protected]>
* @link https://zookeeper.ibinx.com/
* @license GPL-3.0
*
Expand Down Expand Up @@ -1139,7 +1139,7 @@ private function albumForm() {
$amedium = $row["medium"];
$aformat = $row["size"];
$alocation = $row["location"];
$bin = $row["bin"];
$bin = $alocation == ILibrary::LOCATION_STORAGE ? $row["bin"] : '';
$coll = substr($artist, 0, 8) == "[coll]: ";
$name = $_REQUEST["name"];
if(!$name) {
Expand Down Expand Up @@ -1201,7 +1201,7 @@ private function albumForm() {
echo " <OPTION VALUE=\"$code\"$selected>$location\n";
}
?>
</SELECT>&nbsp;&nbsp;<SPAN ID=lbin STYLE="visibility:<?php echo ($alocation == 'G')?"visible":"hidden";?>">Bin:&nbsp;</SPAN><INPUT NAME=bin TYPE=text CLASS=text SIZE=10 maxlength='8' VALUE="<?php echo $bin;?>" STYLE="visibility:<?php echo ($alocation == 'G')?"visible":"hidden";?>"></TD></TR>
</SELECT>&nbsp;&nbsp;<SPAN ID=lbin STYLE="visibility:<?php echo ($alocation == ILibrary::LOCATION_STORAGE) ? "visible" : "hidden"; ?>">Bin:&nbsp;</SPAN><INPUT NAME=bin TYPE=text CLASS=text SIZE=10 maxlength='8' VALUE="<?php echo $bin;?>" STYLE="visibility:<?php echo ($alocation == ILibrary::LOCATION_STORAGE) ? "visible" : "hidden"; ?>"></TD></TR>
<?php
if(!$_REQUEST["new"]) {
?>
Expand Down

0 comments on commit bd09d57

Please sign in to comment.