diff --git a/sections/artist/autocomplete.php b/sections/artist/autocomplete.php index 64e7d9d3..ee7ca27a 100644 --- a/sections/artist/autocomplete.php +++ b/sections/artist/autocomplete.php @@ -44,10 +44,10 @@ if (stripos($Name,$FullName) === 0) { $Suggestions[] = display_str($Name); $Snatches[] = number_format($Snatch).' snatches'; - $Links[] = 'http'.($SSL?'s':'').'://'.$_SERVER['HTTP_HOST'].'/artist.php?id='.$ID; + $ArtistIDs[] = $ID; if (++$Matched > 9) { break; } } } -echo json_encode(array($FullName,$Suggestions,$Snatches,$Links)); +echo json_encode(array($FullName,$Suggestions,$Snatches,$ArtistIDs)); diff --git a/sections/requests/takenew_edit.php b/sections/requests/takenew_edit.php index 20cd5a39..1b1de179 100644 --- a/sections/requests/takenew_edit.php +++ b/sections/requests/takenew_edit.php @@ -389,19 +389,17 @@ FROM artists_alias AS aa WHERE aa.Name = '".db_string($Artist['name'])."'"); - if($DB->record_count() > 0) { - while($Result = $DB->next_record(MYSQLI_NUM, false)) { - list($ArtistID, $AliasID, $AliasName, $Redirect) = $Result; - if(!strcasecmp($Artist['name'], $AliasName)) { - if($Redirect) { - $AliasID = $Redirect; - } - break; + while(list($ArtistID, $AliasID, $AliasName, $Redirect) = $DB->next_record(MYSQLI_NUM, false)) { + if(!strcasecmp($Artist['name'], $AliasName)) { + if($Redirect) { + $AliasID = $Redirect; } + $ArtistForm[$Importance][$Num] = array('id' => $ArtistID, 'aliasid' => $AliasID, 'name' => $AliasName); + $Cache->delete_value('artist_'.$ArtistID); + break; } - $ArtistForm[$Importance][$Num] = array('id' => $ArtistID, 'aliasid' => $AliasID, 'name' => $AliasName); - $Cache->delete_value('artist_'.$ArtistID); - } else { + } + if(!$ArtistID) { //2. For each artist that didn't exist, create an artist. $DB->query("INSERT INTO artists_group (Name) VALUES ('".db_string($Artist['name'])."')"); $ArtistID = $DB->inserted_id(); diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php index 1c02658b..dcedc552 100644 --- a/sections/upload/upload_handle.php +++ b/sections/upload/upload_handle.php @@ -515,17 +515,16 @@ aa.Redirect FROM artists_alias AS aa WHERE aa.Name = '".db_string($Artist['name'])."'"); - if($DB->record_count() > 0){ - while($Result = $DB->next_record(MYSQLI_NUM, false)) { - list($ArtistID, $AliasID, $AliasName, $Redirect) = $Result; + if($DB->record_count() > 0) { + while(list($ArtistID, $AliasID, $AliasName, $Redirect) = $DB->next_record(MYSQLI_NUM, false)) { if(!strcasecmp($Artist['name'], $AliasName)) { if($Redirect) { $AliasID = $Redirect; } + $ArtistForm[$Importance][$Num] = array('id' => $ArtistID, 'aliasid' => $AliasID, 'name' => $AliasName); break; } } - $ArtistForm[$Importance][$Num] = array('id' => $ArtistID, 'aliasid' => $AliasID, 'name' => $AliasName); } } } diff --git a/static/functions/autocomplete.js b/static/functions/autocomplete.js index 63b9b5b5..882f0649 100644 --- a/static/functions/autocomplete.js +++ b/static/functions/autocomplete.js @@ -5,7 +5,7 @@ Spent hours debugging opera, turns out they reserve the global variable autocomp var autocomp = { id: "", value: "", - href: null, + artistid: null, timer: null, input: null, list: null, @@ -23,7 +23,7 @@ var autocomp = { }, end: function () { //this.input.value = this.value; - this.href = null; + this.artistid = null; this.highlight(-1); this.list.style.visibility = 'hidden'; clearTimeout(this.timer); @@ -35,7 +35,7 @@ var autocomp = { case 27: //esc break; case 8: //backspace - this.href = null; + this.artistid = null; this.list.style.visibility = 'hidden'; this.timer = setTimeout("autocomp.get('" + escape(this.input.value) + "');",500); break; @@ -43,17 +43,17 @@ var autocomp = { case 40: //down this.highlight(key); if(this.pos !== -1) { - this.href = this.list.children[this.pos].href; + this.artistid = this.list.children[this.pos].artistid; this.input.value = this.list.children[this.pos].textContent || this.list.children[this.pos].value; } break; case 13: - if(this.href != null) { - window.location = this.href; + if(this.artistid != null) { + window.location = this.id + '.php?id='+this.artistid; } return 0; default: - this.href = null; + this.artistid = null; this.timer = setTimeout("autocomp.get('" + escape(this.input.value) + "');",300); return 1; } @@ -107,7 +107,7 @@ var autocomp = { if (this.pos !== -1) { this.list.children[this.pos].className = "highlight"; } else { - this.href = null; + this.artistid = null; this.input.value = this.value; } }, @@ -133,12 +133,12 @@ var autocomp = { li = document.createElement('li'); li.innerHTML = data[1][i]; li.i = i; - li.href = data[3][i]; + li.artistid = data[3][i]; listener.set(li,'mouseover',function(){ autocomp.highlight(this.i); }); listener.set(li,'click',function(){ - window.location = this.href; + window.location = autocomp.id + '.php?id='+this.artistid; }); this.list.appendChild(li); }