2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class AuthorSetEvent extends Event
|
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
public Image $image;
|
|
|
|
public User $user;
|
|
|
|
public string $author;
|
2019-05-28 16:59:38 +00:00
|
|
|
|
|
|
|
public function __construct(Image $image, User $user, string $author)
|
|
|
|
{
|
2020-01-26 13:19:35 +00:00
|
|
|
parent::__construct();
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->image = $image;
|
|
|
|
$this->user = $user;
|
|
|
|
$this->author = $author;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-20 20:48:47 +00:00
|
|
|
/**
|
|
|
|
* @phpstan-type ArtistArtist array{id:int,artist_id:int,user_name:string,name:string,notes:string,type:string,posts:int}
|
|
|
|
* @phpstan-type ArtistAlias array{id:int,alias_id:int,alias_name:string,alias:string}
|
|
|
|
* @phpstan-type ArtistMember array{id:int,name:string}
|
|
|
|
* @phpstan-type ArtistUrl array{id:int,url:string}
|
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
class Artists extends Extension
|
|
|
|
{
|
2020-01-26 13:19:35 +00:00
|
|
|
/** @var ArtistsTheme */
|
2023-06-27 14:56:49 +00:00
|
|
|
protected Themelet $theme;
|
2020-01-26 13:19:35 +00:00
|
|
|
|
2024-01-15 18:01:48 +00:00
|
|
|
public function onInitExt(InitExtEvent $event): void
|
|
|
|
{
|
2024-06-19 13:16:01 +00:00
|
|
|
global $config;
|
2024-01-15 18:01:48 +00:00
|
|
|
Image::$prop_types["author"] = ImagePropType::STRING;
|
2024-06-19 13:16:01 +00:00
|
|
|
$config->set_default_int("artistsPerPage", 20);
|
2024-01-15 18:01:48 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onImageInfoSet(ImageInfoSetEvent $event): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $user;
|
2024-02-20 21:28:14 +00:00
|
|
|
$author = $event->get_param("author");
|
|
|
|
if ($user->can(Permissions::EDIT_IMAGE_ARTIST) && $author) {
|
|
|
|
send_event(new AuthorSetEvent($event->image, $user, $author));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $user;
|
|
|
|
$artistName = $this->get_artistName_by_imageID($event->image->id);
|
2019-05-28 16:59:38 +00:00
|
|
|
if (!$user->is_anonymous()) {
|
2015-09-27 00:03:58 +00:00
|
|
|
$event->add_part($this->theme->get_author_editor_html($artistName), 42);
|
|
|
|
}
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onSearchTermParse(SearchTermParseEvent $event): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2020-01-26 16:38:26 +00:00
|
|
|
if (is_null($event->term)) {
|
|
|
|
return;
|
|
|
|
}
|
2020-01-26 13:19:35 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$matches = [];
|
2019-08-02 20:05:49 +00:00
|
|
|
if (preg_match("/^(author|artist)[=|:](.*)$/i", $event->term, $matches)) {
|
2020-01-29 20:22:50 +00:00
|
|
|
$char = $matches[2];
|
2023-11-11 21:49:12 +00:00
|
|
|
$event->add_querylet(new Querylet("author = :author_char", ["author_char" => $char]));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onHelpPageBuilding(HelpPageBuildingEvent $event): void
|
2019-08-02 20:05:49 +00:00
|
|
|
{
|
2023-11-11 21:49:12 +00:00
|
|
|
if ($event->key === HelpPages::SEARCH) {
|
2023-07-10 18:03:54 +00:00
|
|
|
$event->add_block(new Block("Artist", $this->theme->get_help_html()));
|
2019-08-02 20:05:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $config, $database;
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2019-11-03 19:49:52 +00:00
|
|
|
if ($this->get_version("ext_artists_version") < 1) {
|
2012-03-11 02:09:33 +00:00
|
|
|
$database->create_table("artists", "
|
|
|
|
id SCORE_AIPK,
|
|
|
|
user_id INTEGER NOT NULL,
|
|
|
|
name VARCHAR(255) NOT NULL,
|
2019-11-03 19:25:51 +00:00
|
|
|
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2012-03-11 02:09:33 +00:00
|
|
|
notes TEXT,
|
|
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE
|
|
|
|
");
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2012-03-11 02:09:33 +00:00
|
|
|
$database->create_table("artist_members", "
|
|
|
|
id SCORE_AIPK,
|
|
|
|
artist_id INTEGER NOT NULL,
|
|
|
|
user_id INTEGER NOT NULL,
|
|
|
|
name VARCHAR(255) NOT NULL,
|
2019-11-03 19:25:51 +00:00
|
|
|
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2012-03-11 02:09:33 +00:00
|
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|
|
|
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
|
|
|
");
|
|
|
|
$database->create_table("artist_alias", "
|
|
|
|
id SCORE_AIPK,
|
|
|
|
artist_id INTEGER NOT NULL,
|
|
|
|
user_id INTEGER NOT NULL,
|
2019-11-03 19:25:51 +00:00
|
|
|
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
2012-03-11 02:09:33 +00:00
|
|
|
alias VARCHAR(255),
|
|
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|
|
|
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
|
|
|
");
|
|
|
|
$database->create_table("artist_urls", "
|
|
|
|
id SCORE_AIPK,
|
|
|
|
artist_id INTEGER NOT NULL,
|
|
|
|
user_id INTEGER NOT NULL,
|
2019-11-03 19:25:51 +00:00
|
|
|
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2012-03-11 02:09:33 +00:00
|
|
|
url VARCHAR(1000) NOT NULL,
|
|
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE,
|
|
|
|
FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE
|
|
|
|
");
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute("ALTER TABLE images ADD COLUMN author VARCHAR(255) NULL");
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-11-03 19:49:52 +00:00
|
|
|
$this->set_version("ext_artists_version", 1);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onAuthorSet(AuthorSetEvent $event): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
|
|
|
|
|
|
|
$author = strtolower($event->author);
|
2019-05-28 16:59:38 +00:00
|
|
|
if (strlen($author) === 0 || strpos($author, " ")) {
|
|
|
|
return;
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
$paddedAuthor = str_replace(" ", "_", $author);
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$artistID = null;
|
|
|
|
if ($this->artist_exists($author)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$artistID = $this->get_artist_id($author);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (is_null($artistID) && $this->alias_exists_by_name($paddedAuthor)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$artistID = $this->get_artistID_by_aliasName($paddedAuthor);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (is_null($artistID) && $this->member_exists_by_name($paddedAuthor)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$artistID = $this->get_artistID_by_memberName($paddedAuthor);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (is_null($artistID) && $this->url_exists_by_url($author)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$artistID = $this->get_artistID_by_url($author);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
if (!is_null($artistID)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$artistName = $this->get_artistName_by_artistID($artistID);
|
2019-05-28 16:59:38 +00:00
|
|
|
} else {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->save_new_artist($author, "");
|
|
|
|
$artistName = $author;
|
|
|
|
}
|
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"UPDATE images SET author = :author WHERE id = :id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['author' => $artistName, 'id' => $event->image->id]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
2015-09-27 00:03:58 +00:00
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onPageRequest(PageRequestEvent $event): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2014-03-30 12:26:48 +00:00
|
|
|
global $page, $user;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/list/{page}")) {
|
|
|
|
$this->get_listing(page_number($event->get_arg('page')));
|
2024-02-10 23:03:14 +00:00
|
|
|
$this->theme->sidebar_options("neutral");
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/new")) {
|
|
|
|
if (!$user->is_anonymous()) {
|
|
|
|
$this->theme->new_artist_composer();
|
|
|
|
} else {
|
|
|
|
$this->theme->display_error(401, "Error", "You must be registered and logged in to create a new artist.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/new_artist")) {
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/new"));
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/create")) {
|
|
|
|
if (!$user->is_anonymous()) {
|
|
|
|
$newArtistID = $this->add_artist();
|
|
|
|
if ($newArtistID == -1) {
|
|
|
|
$this->theme->display_error(400, "Error", "Error when entering artist data.");
|
|
|
|
} else {
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $newArtistID));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->theme->display_error(401, "Error", "You must be registered and logged in to create a new artist.");
|
|
|
|
}
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/view/{artistID}")) {
|
|
|
|
$artistID = $event->get_iarg('artistID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$artist = $this->get_artist($artistID);
|
|
|
|
$aliases = $this->get_alias($artist['id']);
|
|
|
|
$members = $this->get_members($artist['id']);
|
|
|
|
$urls = $this->get_urls($artist['id']);
|
|
|
|
|
|
|
|
$userIsLogged = !$user->is_anonymous();
|
|
|
|
$userIsAdmin = $user->can(Permissions::ARTISTS_ADMIN);
|
|
|
|
|
|
|
|
$images = Search::find_images(limit: 4, tags: Tag::explode($artist['name']));
|
|
|
|
|
|
|
|
$this->theme->show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin);
|
|
|
|
/*
|
|
|
|
if ($userIsLogged) {
|
|
|
|
$this->theme->show_new_alias_composer($artistID);
|
|
|
|
$this->theme->show_new_member_composer($artistID);
|
|
|
|
$this->theme->show_new_url_composer($artistID);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
$this->theme->sidebar_options("editor", $artistID, $userIsAdmin);
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/edit/{artistID}")) {
|
|
|
|
$artistID = $event->get_iarg('artistID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$artist = $this->get_artist($artistID);
|
|
|
|
$aliases = $this->get_alias($artistID);
|
|
|
|
$members = $this->get_members($artistID);
|
|
|
|
$urls = $this->get_urls($artistID);
|
|
|
|
|
|
|
|
if (!$user->is_anonymous()) {
|
|
|
|
$this->theme->show_artist_editor($artist, $aliases, $members, $urls);
|
|
|
|
|
|
|
|
$userIsAdmin = $user->can(Permissions::ARTISTS_ADMIN);
|
|
|
|
$this->theme->sidebar_options("editor", $artistID, $userIsAdmin);
|
|
|
|
} else {
|
|
|
|
$this->theme->display_error(401, "Error", "You must be registered and logged in to edit an artist.");
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
}
|
2024-02-10 23:03:14 +00:00
|
|
|
if ($event->page_matches("artist/edit_artist")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/edit/" . $artistID));
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/edited")) {
|
|
|
|
$artistID = int_escape($event->get_POST('id'));
|
|
|
|
$this->update_artist();
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/nuke_artist")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/nuke/" . $artistID));
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/nuke/{artistID}")) {
|
|
|
|
$artistID = $event->get_iarg('artistID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$this->delete_artist($artistID); // this will delete the artist, its alias, its urls and its members
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/list"));
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/add_alias")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$this->theme->show_new_alias_composer($artistID);
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/add_member")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$this->theme->show_new_member_composer($artistID);
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/add_url")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$this->theme->show_new_url_composer($artistID);
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/alias/add")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$this->add_alias();
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/alias/delete/{aliasID}")) {
|
|
|
|
$aliasID = $event->get_iarg('aliasID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$artistID = $this->get_artistID_by_aliasID($aliasID);
|
|
|
|
$this->delete_alias($aliasID);
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/alias/edit/{aliasID}")) {
|
|
|
|
$aliasID = $event->get_iarg('aliasID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$alias = $this->get_alias_by_id($aliasID);
|
|
|
|
$this->theme->show_alias_editor($alias);
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/alias/edited")) {
|
|
|
|
$this->update_alias();
|
|
|
|
$aliasID = int_escape($event->req_POST('aliasID'));
|
|
|
|
$artistID = $this->get_artistID_by_aliasID($aliasID);
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/url/add")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$this->add_urls();
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/url/delete/{urlID}")) {
|
|
|
|
$urlID = $event->get_iarg('urlID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$artistID = $this->get_artistID_by_urlID($urlID);
|
|
|
|
$this->delete_url($urlID);
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/url/edit/{urlID}")) {
|
|
|
|
$urlID = $event->get_iarg('urlID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$url = $this->get_url_by_id($urlID);
|
|
|
|
$this->theme->show_url_editor($url);
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/url/edited")) {
|
|
|
|
$this->update_url();
|
|
|
|
$urlID = int_escape($event->req_POST('urlID'));
|
|
|
|
$artistID = $this->get_artistID_by_urlID($urlID);
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/member/add")) {
|
|
|
|
$artistID = int_escape($event->req_POST('artist_id'));
|
|
|
|
$this->add_members();
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/member/delete/{memberID}")) {
|
|
|
|
$memberID = $event->get_iarg('memberID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$artistID = $this->get_artistID_by_memberID($memberID);
|
|
|
|
$this->delete_member($memberID);
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
2024-02-11 11:34:09 +00:00
|
|
|
if ($event->page_matches("artist/member/edit/{memberID}")) {
|
|
|
|
$memberID = $event->get_iarg('memberID');
|
2024-02-10 23:03:14 +00:00
|
|
|
$member = $this->get_member_by_id($memberID);
|
|
|
|
$this->theme->show_member_editor($member);
|
|
|
|
}
|
|
|
|
if ($event->page_matches("artist/member/edited")) {
|
|
|
|
$this->update_member();
|
|
|
|
$memberID = int_escape($event->req_POST('memberID'));
|
|
|
|
$artistID = $this->get_artistID_by_memberID($memberID);
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(make_link("artist/view/" . $artistID));
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistName_by_imageID(int $imageID): string
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
$result = $database->get_row("SELECT author FROM images WHERE id = :id", ['id' => $imageID]);
|
2020-01-26 13:19:35 +00:00
|
|
|
return $result['author'] ?? "";
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function url_exists_by_url(string $url): bool
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
$result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE url = :url", ['url' => $url]);
|
2009-12-24 07:36:09 +00:00
|
|
|
return ($result != 0);
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function member_exists_by_name(string $member): bool
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
$result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE name = :name", ['name' => $member]);
|
2009-12-24 07:36:09 +00:00
|
|
|
return ($result != 0);
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function alias_exists_by_name(string $alias): bool
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
$result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE alias = :alias", ['alias' => $alias]);
|
2009-12-24 07:36:09 +00:00
|
|
|
return ($result != 0);
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function alias_exists(int $artistID, string $alias): bool
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_one(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT COUNT(1) FROM artist_alias WHERE artist_id = :artist_id AND alias = :alias",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist_id' => $artistID, 'alias' => $alias]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
return ($result != 0);
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistID_by_url(string $url): int
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2024-02-10 23:03:14 +00:00
|
|
|
return (int) $database->get_one("SELECT artist_id FROM artist_urls WHERE url = :url", ['url' => $url]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistID_by_memberName(string $member): int
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2024-02-10 23:03:14 +00:00
|
|
|
return (int) $database->get_one("SELECT artist_id FROM artist_members WHERE name = :name", ['name' => $member]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
2015-09-27 00:03:58 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistName_by_artistID(int $artistID): string
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2024-02-10 23:03:14 +00:00
|
|
|
return (string) $database->get_one("SELECT name FROM artists WHERE id = :id", ['id' => $artistID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistID_by_aliasID(int $aliasID): int
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2024-02-10 23:03:14 +00:00
|
|
|
return (int) $database->get_one("SELECT artist_id FROM artist_alias WHERE id = :id", ['id' => $aliasID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistID_by_memberID(int $memberID): int
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2024-02-10 23:03:14 +00:00
|
|
|
return (int) $database->get_one("SELECT artist_id FROM artist_members WHERE id = :id", ['id' => $memberID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistID_by_urlID(int $urlID): int
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2024-02-10 23:03:14 +00:00
|
|
|
return (int) $database->get_one("SELECT artist_id FROM artist_urls WHERE id = :id", ['id' => $urlID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function delete_alias(int $aliasID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
$database->execute("DELETE FROM artist_alias WHERE id = :id", ['id' => $aliasID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function delete_url(int $urlID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
$database->execute("DELETE FROM artist_urls WHERE id = :id", ['id' => $urlID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function delete_member(int $memberID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
$database->execute("DELETE FROM artist_members WHERE id = :id", ['id' => $memberID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
2024-01-20 20:48:47 +00:00
|
|
|
* @return ArtistAlias
|
2024-01-20 14:10:59 +00:00
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_alias_by_id(int $aliasID): array
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
return $database->get_row("SELECT * FROM artist_alias WHERE id = :id", ['id' => $aliasID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
2024-01-20 20:48:47 +00:00
|
|
|
* @return ArtistUrl
|
2024-01-20 14:10:59 +00:00
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_url_by_id(int $urlID): array
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
return $database->get_row("SELECT * FROM artist_urls WHERE id = :id", ['id' => $urlID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
2024-01-20 20:48:47 +00:00
|
|
|
* @return ArtistMember
|
2024-01-20 14:10:59 +00:00
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_member_by_id(int $memberID): array
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2023-11-11 21:49:12 +00:00
|
|
|
return $database->get_row("SELECT * FROM artist_members WHERE id = :id", ['id' => $memberID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function update_artist(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
'id' => 'int',
|
|
|
|
'name' => 'string,lower',
|
|
|
|
'notes' => 'string,trim,nullify',
|
|
|
|
'aliases' => 'string,trim,nullify',
|
|
|
|
'aliasesIDs' => 'string,trim,nullify',
|
|
|
|
'members' => 'string,trim,nullify',
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
$artistID = $inputs['id'];
|
|
|
|
$name = $inputs['name'];
|
|
|
|
$notes = $inputs['notes'];
|
2009-12-24 07:36:09 +00:00
|
|
|
$userID = $user->id;
|
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$aliasesAsString = $inputs["aliases"];
|
|
|
|
$aliasesIDsAsString = $inputs["aliasesIDs"];
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$membersAsString = $inputs["members"];
|
|
|
|
$membersIDsAsString = $inputs["membersIDs"];
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$urlsAsString = $inputs["urls"];
|
|
|
|
$urlsIDsAsString = $inputs["urlsIDs"];
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2020-10-25 19:31:58 +00:00
|
|
|
if (str_contains($name, " ")) {
|
2009-12-24 07:36:09 +00:00
|
|
|
return;
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"UPDATE artists SET name = :name, notes = :notes, updated = now(), user_id = :user_id WHERE id = :id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['name' => $name, 'notes' => $notes, 'user_id' => $userID, 'id' => $artistID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
// ALIAS MATCHING SECTION
|
|
|
|
$i = 0;
|
2019-05-28 16:59:38 +00:00
|
|
|
$aliasesAsArray = is_null($aliasesAsString) ? [] : explode(" ", $aliasesAsString);
|
2024-01-15 14:21:33 +00:00
|
|
|
$aliasesIDsAsArray = is_null($aliasesIDsAsString) ? [] : array_map(fn ($n) => int_escape($n), explode(" ", $aliasesIDsAsString));
|
2019-05-28 16:59:38 +00:00
|
|
|
while ($i < count($aliasesAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
// if an alias was updated
|
2019-05-28 16:59:38 +00:00
|
|
|
if ($i < count($aliasesIDsAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->save_existing_alias($aliasesIDsAsArray[$i], $aliasesAsArray[$i], $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
} else {
|
2009-12-24 07:36:09 +00:00
|
|
|
// if we already updated all, save new ones
|
|
|
|
$this->save_new_alias($artistID, $aliasesAsArray[$i], $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
// if we have more ids than alias, then some alias have been deleted -- delete them from db
|
2019-05-28 16:59:38 +00:00
|
|
|
while ($i < count($aliasesIDsAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->delete_alias($aliasesIDsAsArray[$i++]);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
// MEMBERS MATCHING SECTION
|
|
|
|
$i = 0;
|
2019-05-28 16:59:38 +00:00
|
|
|
$membersAsArray = is_null($membersAsString) ? [] : explode(" ", $membersAsString);
|
2024-01-15 14:21:33 +00:00
|
|
|
$membersIDsAsArray = is_null($membersIDsAsString) ? [] : array_map(fn ($n) => int_escape($n), explode(" ", $membersIDsAsString));
|
2019-05-28 16:59:38 +00:00
|
|
|
while ($i < count($membersAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
// if a member was updated
|
2019-05-28 16:59:38 +00:00
|
|
|
if ($i < count($membersIDsAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->save_existing_member($membersIDsAsArray[$i], $membersAsArray[$i], $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
} else {
|
2009-12-24 07:36:09 +00:00
|
|
|
// if we already updated all, save new ones
|
2015-09-12 10:43:28 +00:00
|
|
|
$this->save_new_member($artistID, $membersAsArray[$i], $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
// if we have more ids than members, then some members have been deleted -- delete them from db
|
2019-05-28 16:59:38 +00:00
|
|
|
while ($i < count($membersIDsAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->delete_member($membersIDsAsArray[$i++]);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
// URLS MATCHING SECTION
|
|
|
|
$i = 0;
|
2024-01-20 20:48:47 +00:00
|
|
|
assert(is_string($urlsAsString));
|
2009-12-24 07:36:09 +00:00
|
|
|
$urlsAsString = str_replace("\r\n", "\n", $urlsAsString);
|
|
|
|
$urlsAsString = str_replace("\n\r", "\n", $urlsAsString);
|
2024-01-15 13:40:18 +00:00
|
|
|
$urlsAsArray = empty($urlsAsString) ? [] : explode("\n", $urlsAsString);
|
2024-01-15 14:21:33 +00:00
|
|
|
$urlsIDsAsArray = is_null($urlsIDsAsString) ? [] : array_map(fn ($n) => int_escape($n), explode(" ", $urlsIDsAsString));
|
2019-05-28 16:59:38 +00:00
|
|
|
while ($i < count($urlsAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
// if an URL was updated
|
2015-09-27 00:03:58 +00:00
|
|
|
if ($i < count($urlsIDsAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->save_existing_url($urlsIDsAsArray[$i], $urlsAsArray[$i], $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
} else {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->save_new_url($artistID, $urlsAsArray[$i], $userID);
|
|
|
|
}
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
}
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2009-12-24 07:36:09 +00:00
|
|
|
// if we have more ids than urls, then some urls have been deleted -- delete them from db
|
2019-05-28 16:59:38 +00:00
|
|
|
while ($i < count($urlsIDsAsArray)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->delete_url($urlsIDsAsArray[$i++]);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function update_alias(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
"aliasID" => "int",
|
|
|
|
"alias" => "string,lower",
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
$this->save_existing_alias($inputs['aliasID'], $inputs['alias'], $user->id);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function save_existing_alias(int $aliasID, string $alias, int $userID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"UPDATE artist_alias SET alias = :alias, updated = now(), user_id = :user_id WHERE id = :id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['alias' => $alias, 'user_id' => $userID, 'id' => $aliasID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function update_url(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
"urlID" => "int",
|
|
|
|
"url" => "string",
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
$this->save_existing_url($inputs['urlID'], $inputs['url'], $user->id);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function save_existing_url(int $urlID, string $url, int $userID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"UPDATE artist_urls SET url = :url, updated = now(), user_id = :user_id WHERE id = :id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['url' => $url, 'user_id' => $userID, 'id' => $urlID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function update_member(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
"memberID" => "int",
|
|
|
|
"name" => "string,lower",
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
$this->save_existing_member($inputs['memberID'], $inputs['name'], $user->id);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function save_existing_member(int $memberID, string $memberName, int $userID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"UPDATE artist_members SET name = :name, updated = now(), user_id = :user_id WHERE id = :id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['name' => $memberName, 'user_id' => $userID, 'id' => $memberID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
private function add_artist(): int
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
"name" => "string,lower",
|
|
|
|
"notes" => "string,optional",
|
|
|
|
"aliases" => "string,lower,optional",
|
|
|
|
"members" => "string,lower,optional",
|
|
|
|
"urls" => "string,optional"
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
|
|
|
|
$name = $inputs["name"];
|
2020-10-25 19:31:58 +00:00
|
|
|
if (str_contains($name, " ")) {
|
2009-12-24 07:36:09 +00:00
|
|
|
return -1;
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$notes = $inputs["notes"];
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$aliases = $inputs["aliases"];
|
|
|
|
$members = $inputs["members"];
|
|
|
|
$urls = $inputs["urls"];
|
2009-12-24 07:36:09 +00:00
|
|
|
$userID = $user->id;
|
|
|
|
|
2014-04-19 06:33:34 +00:00
|
|
|
//$artistID = "";
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
//// WE CHECK IF THE ARTIST ALREADY EXISTS ON DATABASE; IF NOT WE CREATE
|
2019-05-28 16:59:38 +00:00
|
|
|
if (!$this->artist_exists($name)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$artistID = $this->save_new_artist($name, $notes);
|
|
|
|
log_info("artists", "Artist {$artistID} created by {$user->name}");
|
2019-05-28 16:59:38 +00:00
|
|
|
} else {
|
2009-12-24 07:36:09 +00:00
|
|
|
$artistID = $this->get_artist_id($name);
|
2015-09-27 00:03:58 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
if (!is_null($aliases)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$aliasArray = explode(" ", $aliases);
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($aliasArray as $alias) {
|
|
|
|
if (!$this->alias_exists($artistID, $alias)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->save_new_alias($artistID, $alias, $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
if (!is_null($members)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$membersArray = explode(" ", $members);
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($membersArray as $member) {
|
|
|
|
if (!$this->member_exists($artistID, $member)) {
|
2015-09-12 10:43:28 +00:00
|
|
|
$this->save_new_member($artistID, $member, $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
if (!is_null($urls)) {
|
2024-01-20 20:48:47 +00:00
|
|
|
assert(is_string($urls));
|
2009-12-24 07:36:09 +00:00
|
|
|
//delete double "separators"
|
|
|
|
$urls = str_replace("\r\n", "\n", $urls);
|
|
|
|
$urls = str_replace("\n\r", "\n", $urls);
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2009-12-24 07:36:09 +00:00
|
|
|
$urlsArray = explode("\n", $urls);
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($urlsArray as $url) {
|
|
|
|
if (!$this->url_exists($artistID, $url)) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$this->save_new_url($artistID, $url, $userID);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
return $artistID;
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function save_new_artist(string $name, string $notes): int
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database, $user;
|
2023-06-25 20:31:11 +00:00
|
|
|
$database->execute("
|
2015-09-27 00:03:58 +00:00
|
|
|
INSERT INTO artists (user_id, name, notes, created, updated)
|
2019-11-27 11:22:46 +00:00
|
|
|
VALUES (:user_id, :name, :notes, now(), now())
|
2023-11-11 21:49:12 +00:00
|
|
|
", ['user_id' => $user->id, 'name' => $name, 'notes' => $notes]);
|
2023-06-25 20:31:11 +00:00
|
|
|
return $database->get_last_insert_id('artists_id_seq');
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function artist_exists(string $name): bool
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_one(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT COUNT(1) FROM artists WHERE name = :name",
|
2023-11-11 21:49:12 +00:00
|
|
|
['name' => $name]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
return ($result != 0);
|
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
2024-01-20 20:48:47 +00:00
|
|
|
* @return ArtistArtist
|
2024-01-20 14:10:59 +00:00
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artist(int $artistID): array
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_row(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT * FROM artists WHERE id = :id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['id' => $artistID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2009-12-24 07:36:09 +00:00
|
|
|
|
|
|
|
$result["name"] = stripslashes($result["name"]);
|
|
|
|
$result["notes"] = stripslashes($result["notes"]);
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
2024-01-20 20:48:47 +00:00
|
|
|
* @return ArtistMember[]
|
2024-01-20 14:10:59 +00:00
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_members(int $artistID): array
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_all(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT * FROM artist_members WHERE artist_id = :artist_id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist_id' => $artistID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$num = count($result);
|
2024-02-10 23:03:14 +00:00
|
|
|
for ($i = 0; $i < $num; $i++) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$result[$i]["name"] = stripslashes($result[$i]["name"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
2015-09-27 00:03:58 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
2024-01-20 20:48:47 +00:00
|
|
|
* @return ArtistUrl[]
|
2024-01-20 14:10:59 +00:00
|
|
|
*/
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_urls(int $artistID): array
|
|
|
|
{
|
2009-12-24 07:36:09 +00:00
|
|
|
global $database;
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_all(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT id, url FROM artist_urls WHERE artist_id = :artist_id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist_id' => $artistID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$num = count($result);
|
2024-02-10 23:03:14 +00:00
|
|
|
for ($i = 0; $i < $num; $i++) {
|
2009-12-24 07:36:09 +00:00
|
|
|
$result[$i]["url"] = stripslashes($result[$i]["url"]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artist_id(string $name): int
|
|
|
|
{
|
|
|
|
global $database;
|
2024-02-10 23:03:14 +00:00
|
|
|
return (int) $database->get_one(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT id FROM artists WHERE name = :name",
|
2023-11-11 21:49:12 +00:00
|
|
|
['name' => $name]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function get_artistID_by_aliasName(string $alias): int
|
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-02-10 23:03:14 +00:00
|
|
|
return (int) $database->get_one(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT artist_id FROM artist_alias WHERE alias = :alias",
|
2023-11-11 21:49:12 +00:00
|
|
|
['alias' => $alias]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function delete_artist(int $artistID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"DELETE FROM artists WHERE id = :id",
|
2023-11-11 21:49:12 +00:00
|
|
|
['id' => $artistID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
/*
|
2024-02-10 23:03:14 +00:00
|
|
|
* HERE WE GET THE LIST OF ALL ARTIST WITH PAGINATION
|
|
|
|
*/
|
|
|
|
private function get_listing(int $pageNumber): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $config, $database;
|
|
|
|
|
|
|
|
$artistsPerPage = $config->get_int("artistsPerPage");
|
|
|
|
|
|
|
|
$listing = $database->get_all(
|
|
|
|
"
|
2024-02-10 23:03:14 +00:00
|
|
|
(
|
|
|
|
SELECT a.id, a.user_id, a.name, u.name AS user_name, COALESCE(t.count, 0) AS posts
|
|
|
|
, 'artist' as type, a.id AS artist_id, a.name AS artist_name, a.updated
|
|
|
|
FROM artists AS a
|
|
|
|
INNER JOIN users AS u
|
|
|
|
ON a.user_id = u.id
|
|
|
|
LEFT OUTER JOIN tags AS t
|
|
|
|
ON a.name = t.tag
|
|
|
|
GROUP BY a.id, a.user_id, a.name, u.name
|
|
|
|
ORDER BY a.updated DESC
|
|
|
|
)
|
|
|
|
|
|
|
|
UNION
|
|
|
|
|
|
|
|
(
|
|
|
|
SELECT aa.id, aa.user_id, aa.alias AS name, u.name AS user_name, COALESCE(t.count, 0) AS posts
|
|
|
|
, 'alias' as type, a.id AS artist_id, a.name AS artist_name, aa.updated
|
|
|
|
FROM artist_alias AS aa
|
|
|
|
INNER JOIN users AS u
|
|
|
|
ON aa.user_id = u.id
|
|
|
|
INNER JOIN artists AS a
|
|
|
|
ON aa.artist_id = a.id
|
|
|
|
LEFT OUTER JOIN tags AS t
|
|
|
|
ON aa.alias = t.tag
|
|
|
|
GROUP BY aa.id, a.user_id, aa.alias, u.name, a.id, a.name
|
|
|
|
ORDER BY aa.updated DESC
|
|
|
|
)
|
|
|
|
|
|
|
|
UNION
|
|
|
|
|
|
|
|
(
|
|
|
|
SELECT m.id, m.user_id, m.name AS name, u.name AS user_name, COALESCE(t.count, 0) AS posts
|
|
|
|
, 'member' AS type, a.id AS artist_id, a.name AS artist_name, m.updated
|
|
|
|
FROM artist_members AS m
|
|
|
|
INNER JOIN users AS u
|
|
|
|
ON m.user_id = u.id
|
|
|
|
INNER JOIN artists AS a
|
|
|
|
ON m.artist_id = a.id
|
|
|
|
LEFT OUTER JOIN tags AS t
|
|
|
|
ON m.name = t.tag
|
|
|
|
GROUP BY m.id, m.user_id, m.name, u.name, a.id, a.name
|
|
|
|
ORDER BY m.updated DESC
|
|
|
|
)
|
2009-12-24 07:36:09 +00:00
|
|
|
ORDER BY updated DESC
|
2019-11-27 11:22:46 +00:00
|
|
|
LIMIT :offset, :limit
|
2019-05-28 16:59:38 +00:00
|
|
|
",
|
|
|
|
[
|
2023-11-11 21:49:12 +00:00
|
|
|
"offset" => $pageNumber * $artistsPerPage,
|
|
|
|
"limit" => $artistsPerPage
|
2019-11-27 11:22:46 +00:00
|
|
|
]
|
2019-11-02 19:57:34 +00:00
|
|
|
);
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$number_of_listings = count($listing);
|
|
|
|
|
2024-02-10 23:03:14 +00:00
|
|
|
for ($i = 0; $i < $number_of_listings; $i++) {
|
2019-05-28 16:59:38 +00:00
|
|
|
$listing[$i]["name"] = stripslashes($listing[$i]["name"]);
|
|
|
|
$listing[$i]["user_name"] = stripslashes($listing[$i]["user_name"]);
|
|
|
|
$listing[$i]["artist_name"] = stripslashes($listing[$i]["artist_name"]);
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$count = $database->get_one("
|
2015-09-27 00:03:58 +00:00
|
|
|
SELECT COUNT(1)
|
2009-12-24 07:36:09 +00:00
|
|
|
FROM artists AS a
|
|
|
|
LEFT OUTER JOIN artist_members AS am
|
|
|
|
ON a.id = am.artist_id
|
|
|
|
LEFT OUTER JOIN artist_alias AS aa
|
|
|
|
ON a.id = aa.artist_id
|
2015-09-27 00:03:58 +00:00
|
|
|
");
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-02-10 23:03:14 +00:00
|
|
|
$totalPages = (int) ceil($count / $artistsPerPage);
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->theme->list_artists($listing, $pageNumber + 1, $totalPages);
|
|
|
|
}
|
2019-08-07 19:53:59 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
/*
|
2024-02-10 23:03:14 +00:00
|
|
|
* HERE WE ADD AN ALIAS
|
|
|
|
*/
|
2024-01-20 14:10:59 +00:00
|
|
|
private function add_urls(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
"artistID" => "int",
|
|
|
|
"urls" => "string",
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
$artistID = $inputs["artistID"];
|
|
|
|
$urls = explode("\n", $inputs["urls"]);
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($urls as $url) {
|
|
|
|
if (!$this->url_exists($artistID, $url)) {
|
2015-09-27 00:03:58 +00:00
|
|
|
$this->save_new_url($artistID, $url, $user->id);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-27 00:03:58 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function save_new_url(int $artistID, string $url, int $userID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (:artist_id, now(), now(), :url, :user_id)",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist' => $artistID, 'url' => $url, 'user_id' => $userID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function add_alias(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
"artistID" => "int",
|
|
|
|
"aliases" => "string,lower",
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
$artistID = $inputs["artistID"];
|
|
|
|
$aliases = explode(" ", $inputs["aliases"]);
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($aliases as $alias) {
|
|
|
|
if (!$this->alias_exists($artistID, $alias)) {
|
2015-09-27 00:03:58 +00:00
|
|
|
$this->save_new_alias($artistID, $alias, $user->id);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-27 00:03:58 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function save_new_alias(int $artistID, string $alias, int $userID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (:artist_id, now(), now(), :alias, :user_id)",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist_id' => $artistID, 'alias' => $alias, 'user_id' => $userID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function add_members(): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$inputs = validate_input([
|
2015-09-27 00:03:58 +00:00
|
|
|
"artistID" => "int",
|
|
|
|
"members" => "string,lower",
|
2019-05-28 16:59:38 +00:00
|
|
|
]);
|
2015-09-27 00:03:58 +00:00
|
|
|
$artistID = $inputs["artistID"];
|
|
|
|
$members = explode(" ", $inputs["members"]);
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($members as $member) {
|
|
|
|
if (!$this->member_exists($artistID, $member)) {
|
2015-09-27 00:03:58 +00:00
|
|
|
$this->save_new_member($artistID, $member, $user->id);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-27 00:03:58 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
private function save_new_member(int $artistID, string $member, int $userID): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$database->execute(
|
2019-11-27 11:22:46 +00:00
|
|
|
"INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (:artist_id, :name, now(), now(), :user_id)",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist' => $artistID, 'name' => $member, 'user_id' => $userID]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function member_exists(int $artistID, string $member): bool
|
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_one(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT COUNT(1) FROM artist_members WHERE artist_id = :artist_id AND name = :name",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist_id' => $artistID, 'name' => $member]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
|
|
|
return ($result != 0);
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
private function url_exists(int $artistID, string $url): bool
|
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_one(
|
2019-11-27 11:22:46 +00:00
|
|
|
"SELECT COUNT(1) FROM artist_urls WHERE artist_id = :artist_id AND url = :url",
|
2023-11-11 21:49:12 +00:00
|
|
|
['artist_id' => $artistID, 'url' => $url]
|
2015-09-27 00:03:58 +00:00
|
|
|
);
|
|
|
|
return ($result != 0);
|
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
/**
|
|
|
|
* HERE WE GET THE INFO OF THE ALIAS
|
2024-01-20 14:10:59 +00:00
|
|
|
*
|
|
|
|
* @return array<string, mixed>
|
2019-05-28 16:59:38 +00:00
|
|
|
*/
|
|
|
|
private function get_alias(int $artistID): array
|
|
|
|
{
|
2015-09-27 00:03:58 +00:00
|
|
|
global $database;
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2015-09-27 00:03:58 +00:00
|
|
|
$result = $database->get_all("
|
|
|
|
SELECT id AS alias_id, alias AS alias_name
|
|
|
|
FROM artist_alias
|
2019-11-27 11:22:46 +00:00
|
|
|
WHERE artist_id = :artist_id
|
2015-09-27 00:03:58 +00:00
|
|
|
ORDER BY alias ASC
|
2023-11-11 21:49:12 +00:00
|
|
|
", ['artist_id' => $artistID]);
|
2009-12-24 07:36:09 +00:00
|
|
|
|
2023-01-11 11:41:13 +00:00
|
|
|
$rc = count($result);
|
2024-02-10 23:03:14 +00:00
|
|
|
for ($i = 0; $i < $rc; $i++) {
|
2015-09-27 00:03:58 +00:00
|
|
|
$result[$i]["alias_name"] = stripslashes($result[$i]["alias_name"]);
|
|
|
|
}
|
|
|
|
return $result;
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-12-24 07:36:09 +00:00
|
|
|
}
|