fixes #478 - import now uses AddAliasEvent rather than manually adding itself

This commit is contained in:
Daku 2015-03-20 22:45:33 +00:00 committed by Shish
parent 6289402f2e
commit 845543b2ba

View File

@ -153,11 +153,12 @@ class AliasEditor extends Extension {
foreach(explode("\n", $csv) as $line) {
$parts = str_getcsv($line);
if(count($parts) == 2) {
$pair = array("oldtag" => $parts[0], "newtag" => $parts[1]);
if(!$database->get_row("SELECT * FROM aliases WHERE oldtag=:oldtag AND lower(newtag)=lower(:newtag)", $pair)){
if(!$database->get_row("SELECT * FROM aliases WHERE oldtag=:newtag", array("newtag" => $pair['newtag']))){
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", $pair);
}
try {
$aae = new AddAliasEvent($parts[0], $parts[1]);
send_event($aae);
}
catch(AddAliasException $ex) {
$this->theme->display_error(500, "Error adding alias", $ex->getMessage());
}
}
}