From 65bc8762b1dbcfd267555d11fc933418168110d5 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 31 Dec 2007 04:08:35 +0000 Subject: fixed flag management interface, and potentially fixed an issue with use_auth=false --- admin/flag.php | 1 + docs/CHANGELOG | 1 + lib/class/catalog.class.php | 9 ++++++++- lib/class/flag.class.php | 27 +++++++++++++++++++-------- lib/init.php | 2 +- server/flag.ajax.php | 21 +++++++++++++++++++++ server/stats.ajax.php | 10 ++++++++++ templates/show_flag_row.inc.php | 36 ++++++++++++++++++++++++++++++++++++ templates/show_flagged.inc.php | 15 +-------------- 9 files changed, 98 insertions(+), 24 deletions(-) create mode 100644 templates/show_flag_row.inc.php diff --git a/admin/flag.php b/admin/flag.php index e281dd6e..bc5d9474 100644 --- a/admin/flag.php +++ b/admin/flag.php @@ -295,6 +295,7 @@ switch ($_REQUEST['action']) { case 'show_flagged': $flagged = Flag::get_all(); Browse::set_type('flagged'); + Browse::set_static_content(1); Browse::save_objects($flagged); Browse::show_objects($flagged); break; diff --git a/docs/CHANGELOG b/docs/CHANGELOG index bb4fb0ae..71d27312 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.4-Beta2 + - Fixed Flag Management Interface - Added Export Catalog to CSV - Added 'Add New...' option to other fields on Song Edit (Thx picasso) - Fixed incorrect index on localplay playlist after track deletion diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index fffcb302..34747853 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1134,7 +1134,14 @@ class Catalog { * updates the song info based on tags, this is called from a bunch of different places * and passes in a full fledged song object, so it's a static function */ - public static function update_song_from_tags($song,$sort_pattern,$rename_pattern) { + public static function update_song_from_tags($song,$sort_pattern='',$rename_pattern='') { + + // If the patterns aren't passed go look them up + if (!$sort_pattern OR !$rename_pattern) { + $catalog = new Catalog($song->catalog); + $sort_pattern = $catalog->sort_pattern; + $rename_pattern = $catalog->rename_pattern; + } /* Record the reading of these tags */ debug_event('tag-read',"Reading Tags from $song->file",'5','ampache-catalog'); diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php index d3f5ba56..28d7313a 100644 --- a/lib/class/flag.class.php +++ b/lib/class/flag.class.php @@ -182,28 +182,39 @@ class Flag { } // add /** - * delete_flag + * delete * This deletes the flagged entry and rescans the file to revert to the origional * state, in a perfect world, I could just roll the changes back... not until 3.4 + * or.. haha 3.5! */ - function delete_flag() { + public function delete() { - $sql = "DELETE FROM flagged WHERE id='$this->id'"; - $db_results = mysql_query($sql, dbh()); + // Re-scan the file + $song = new Song($this->object_id); + $info = Catalog::update_song_from_tags($song); + + // Delete the row + $sql = "DELETE FROM `flagged` WHERE `id`='$this->id'"; + $db_results = Dba::query($sql); + + // Reset the Last-Updated date so that it'll get re-scaned + $song->update_utime($song->id,1); return true; - } // delete_flag + } // delete /** * approve * This approves the current flag object ($this->id) by setting approved to * 1 */ - function approve() { + public function approve() { - $sql = "UPDATE flagged SET approved='1' WHERE id='$this->id'"; - $db_results = mysql_query($sql, dbh()); + $sql = "UPDATE `flagged` SET `approved`='1' WHERE `id`='$this->id'"; + $db_results = Dba::query($sql); + + $this->approved = 1; return true; diff --git a/lib/init.php b/lib/init.php index 01f15bb2..b28554bd 100644 --- a/lib/init.php +++ b/lib/init.php @@ -206,7 +206,7 @@ elseif (!Config::get('use_auth')) { $auth['access'] = '100'; $auth['offset_limit'] = 50; if (!vauth::check_session()) { - session_start(); + vauth::create_cookie(); vauth::session_create($auth); } $GLOBALS['user'] = new User(-1); diff --git a/server/flag.ajax.php b/server/flag.ajax.php index f06a4db6..a063c662 100644 --- a/server/flag.ajax.php +++ b/server/flag.ajax.php @@ -31,6 +31,19 @@ switch ($_REQUEST['action']) { break; } + // Remove the flag from the table + $flag = new Flag($_REQUEST['flag_id']); + $flag->delete(); + + $flagged = Flag::get_all(); + ob_start(); + Browse::set_type('flagged'); + Browse::set_static_content(1); + Browse::save_objects($flagged); + Browse::show_objects($flagged); + $results['browse_content'] = ob_get_contents(); + ob_end_clean(); + break; case 'accept': if (!Access::check('interface','75')) { @@ -38,6 +51,14 @@ switch ($_REQUEST['action']) { break; } + $flag = new Flag($_REQUEST['flag_id']); + $flag->approve(); + $flag->format(); + ob_start(); + require_once Config::get('prefix') . '/templates/show_flag_row.inc.php'; + $results['flagged_' . $flag->id] = ob_get_contents(); + ob_end_clean(); + break; default: $results['rfc3514'] = '0x1'; diff --git a/server/stats.ajax.php b/server/stats.ajax.php index 1ca6391b..c4c73d03 100644 --- a/server/stats.ajax.php +++ b/server/stats.ajax.php @@ -86,6 +86,16 @@ switch ($_REQUEST['action']) { // Ask the great and wise metadata $objects = metadata::find_missing_tracks($_REQUEST['id']); + if ($error = ob_get_contents()) { + ob_end_clean(); + ob_start(); + show_box_top(_('Find Missing Tracks')); + echo $error; + show_box_bottom(); + $results['additional_information'] = ob_get_contents(); + ob_end_clean(); + break; + } ob_start(); show_box_top(_('Find Missing Tracks')); require_once Config::get('prefix') . '/templates/show_objects.inc.php'; diff --git a/templates/show_flag_row.inc.php b/templates/show_flag_row.inc.php new file mode 100644 index 00000000..fc84053b --- /dev/null +++ b/templates/show_flag_row.inc.php @@ -0,0 +1,36 @@ + + + f_name; ?> + f_user; ?> + print_flag(); ?> + comment); ?> + print_status(); ?> + + approved) { ?> + id,'disable',_('Reject'),'reject_flag_' . $flag->id); ?> + + id,'enable',_('Enable'),'enable_flag_' . $flag->id); ?> + + + diff --git a/templates/show_flagged.inc.php b/templates/show_flagged.inc.php index 82c5d138..8c61113b 100644 --- a/templates/show_flagged.inc.php +++ b/templates/show_flagged.inc.php @@ -43,21 +43,8 @@ $web_path = Config::get('web_path'); foreach ($object_ids as $flag_id) { $flag = new Flag($flag_id); $flag->format(); + require Config::get('prefix') . '/templates/show_flag_row.inc.php'; ?> - - f_name; ?> - f_user; ?> - print_flag(); ?> - comment); ?> - print_status(); ?> - - approved) { ?> - id,'disable',_('Reject'),'reject_flag_' . $flag->id); ?> - - id,'enable',_('Enable'),'enable_flag_' . $flag->id); ?> - - - -- cgit