1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

re-added ability to delete catalogs, fixed exception error with id3 library

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-07-12 05:30:30 +00:00
parent 12f679cf51
commit 7be9eb4ea1
12 changed files with 78 additions and 142 deletions

View file

@ -99,13 +99,12 @@ switch ($_REQUEST['action']) {
break; break;
case 'delete_catalog': case 'delete_catalog':
/* Make sure they aren't in demo mode */ /* Make sure they aren't in demo mode */
if (conf('demo_mode')) { break; } if (Config::get('demo_mode')) { break; }
/* Delete the sucker, we don't need to check perms as thats done above */ /* Delete the sucker, we don't need to check perms as thats done above */
$catalog = new Catalog($_REQUEST['catalog_id']); Catalog::delete($_REQUEST['catalog_id']);
$catalog->delete_catalog(); $next_url = Config::get('web_path') . '/admin/index.php';
$next_url = conf('web_path') . '/admin/index.php'; show_confirmation(_('Catalog Deleted'),_('The Catalog and all associated records have been deleted'),$nexturl);
show_confirmation(_('Catalog Deleted'),_('The Catalog and all associated records has been deleted'),$nexturl);
break; break;
case 'remove_disabled': case 'remove_disabled':
if (conf('demo_mode')) { break; } if (conf('demo_mode')) { break; }
@ -226,9 +225,10 @@ switch ($_REQUEST['action']) {
break; break;
case 'show_delete_catalog': case 'show_delete_catalog':
/* Stop the demo hippies */ /* Stop the demo hippies */
if (conf('demo_mode')) { break; } if (Config::get('demo_mode')) { break; }
$catalog = new Catalog($_REQUEST['catalog_id']); $catalog = new Catalog($_REQUEST['catalog_id']);
$nexturl = conf('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']); $nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&catalog_id=' . scrub_out($_REQUEST['catalog_id']);
show_confirmation(_('Delete Catalog'),_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1); show_confirmation(_('Delete Catalog'),_('Do you really want to delete this catalog?') . " -- $catalog->name ($catalog->path)",$nexturl,1);
break; break;
case 'show_customize_catalog': case 'show_customize_catalog':

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
Copyright (c) 2001 - 2006 Ampache.org Copyright (c) 2001 - 2007 Ampache.org
All rights reserved. All rights reserved.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -22,19 +22,13 @@
require '../lib/init.php'; require '../lib/init.php';
$action = scrub_in($_REQUEST['action']);
if (!$GLOBALS['user']->has_access(100)) { if (!$GLOBALS['user']->has_access(100)) {
access_denied(); access_denied();
exit(); exit();
} }
require_once Config::get('prefix') . '/templates/header.inc.php'; show_header();
?>
<div id="admin-tools">
<?php require Config::get('prefix') . '/templates/show_admin_tools.inc.php'; ?>
</div> show_footer();
<div id="admin-info">
<?php require Config::get('prefix') . '/templates/show_admin_info.inc.php'; ?>
</div>
<?php show_footer(); ?>

View file

@ -1,102 +0,0 @@
<?php
/*
Copyright (c) 2001 - 2005 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License v2
as published by the Free Software Foundation
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* Preferences page
* Preferences page for whole site, and where
* the admins do editing of other users preferences
* @package Preferences
* @catagory Admin
* @author Karl Vollmer
*/
require('../lib/init.php');
if (!$GLOBALS['user']->has_access(100)) {
access_denied();
}
$user_id = scrub_in($_REQUEST['user_id']);
$action = scrub_in($_REQUEST['action']);
if (!$user_id) { $user_id ='-1'; }
$temp_user = new User($user_id);
$temp_user->username = $user_id;
show_template('header');
switch($action) {
case 'user':
$fullname = "ADMIN - " . $temp_user->fullname;
$preferences = $temp_user->get_preferences();
break;
case 'update_preferences':
if (conf('demo_mode')) { break; }
update_preferences($user_id);
if ($user_id != '-1') {
$fullname = "ADMIN - " . $temp_user->fullname;
$_REQUEST['action'] = 'user';
$preferences = $temp_user->get_preferences();
}
else {
$fullname = _('Site');
init_preferences();
$GLOBALS['user']->set_preferences();
set_theme();
$preferences = $temp_user->get_preferences();
}
break;
case 'fix_preferences':
$temp_user->fix_preferences($user_id);
$preferences = $temp_user->get_preferences($user_id);
break;
case 'set_preferences':
/* Update the preferences */
foreach ($_REQUEST['prefs'] as $name=>$level) {
update_preference_level($name,$level);
} // end foreach preferences
case 'show_set_preferences':
/* Get all preferences */
$preferences = get_preferences();
require_once(conf('prefix') . '/templates/show_preference_admin.inc.php');
break;
default:
$preferences = $temp_user->get_preferences();
$fullname = _('Site');
break;
} // End Switch Action
// OMG HORRIBLE HACK Beatings for the programmer
if ($action != 'show_set_preferences' AND $action != 'set_preferences') {
// Set Target
$target = "/admin/preferences.php";
// Show the default preferences page
require (conf('prefix') . "/templates/show_preferences.inc");
}
// FOOTER
show_footer();
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 715 B

Before After
Before After

View file

@ -105,7 +105,7 @@ class Catalog {
public static function get_catalog_ids() { public static function get_catalog_ids() {
$sql = "SELECT `id` FROM `catalog`"; $sql = "SELECT `id` FROM `catalog`";
$db_results = Dba::qery($sql); $db_results = Dba::query($sql);
while ($r = Dba::fetch_assoc($db_results)) { while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id']; $results[] = $r['id'];
@ -2061,20 +2061,22 @@ class Catalog {
/** /**
* delete * delete
* Deletes the catalog and everything assoicated with it * Deletes the catalog and everything assoicated with it
* assumes $this * it takes the catalog id
*/ */
public static function delete() { public static function delete($catalog_id) {
$catalog_id = Dba::escape($catalog_id);
// First remove the songs in this catalog // First remove the songs in this catalog
$sql = "DELETE FROM `song` WHERE `catalog` = '$this->id'"; $sql = "DELETE FROM `song` WHERE `catalog` = '$catalog_id'";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
// Next Remove the Catalog Entry it's self // Next Remove the Catalog Entry it's self
$sql = "DELETE FROM `catalog` WHERE `id` = '$this->id'"; $sql = "DELETE FROM `catalog` WHERE `id` = '$catalog_id'";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
// Run the Aritst/Album Cleaners... // Run the Aritst/Album Cleaners...
self::clean($this->id); self::clean($catalog_id);
} // delete } // delete

View file

@ -88,7 +88,12 @@ class vainfo {
function get_info() { function get_info() {
/* Get the Raw file information */ /* Get the Raw file information */
$this->_raw = $this->_getID3->analyze($this->filename); try {
$this->_raw = $this->_getID3->analyze($this->filename);
}
catch (Exception $error) {
debug_event('getid3',$e->message,'1');
}
/* Figure out what type of file we are dealing with */ /* Figure out what type of file we are dealing with */
$this->type = $this->_get_type(); $this->type = $this->_get_type();

View file

@ -1424,4 +1424,27 @@ function ajax_include($include) {
} // ajax_include } // ajax_include
/**
* ajax_button
* This is a generic function that generates the on(whateva) URL for ajaxie hotness
* it takes a action url, icon name, alt tag and form_id (option)
*/
function ajax_button($action,$icon,$alt,$post_id='') {
$url = Config::get('ajax_url') . $action;
$icon_url = Config::get('web_path') . '/images/icons/' . $icon . '.png';
if ($post) {
$ajax_string = "ajaxPost('$url','$post');";
}
else {
$ajax_string = "ajaxPut('$url');";
}
$string = "<span onclick=\"$ajax_string;return true\">\n\t<img src=\"$icon_url\" border=\"0\" style=\"cursor:pointer;\" alt=\"$alt\" />\n</span>\n";
return $string;
} // ajax_button
?> ?>

View file

@ -28,7 +28,7 @@ if (!$_REQUEST['tab']) { $_REQUEST['tab'] = 'interface'; }
// Switch on the action // Switch on the action
switch($_REQUEST['action']) { switch($_REQUEST['action']) {
case 'update_preferences': case 'update_preferences':
if ($_REQUEST['method'] == 'admin' && !$GLOBALS['user']->has_access('100')) { if (($_REQUEST['method'] == 'admin' OR $_REQUEST['method'] == 'user') && !$GLOBALS['user']->has_access('100')) {
access_denied(); access_denied();
exit; exit;
} }
@ -38,6 +38,11 @@ switch($_REQUEST['action']) {
$user_id = '-1'; $user_id = '-1';
$fullname = _('Server'); $fullname = _('Server');
} }
elseif ($_REQUEST['method'] == 'user') {
$user_id = $_REQUEST['user_id'];
$client = new User($user_id);
$fullname = $client->fullname;
}
else { else {
$user_id = $GLOBALS['user']->id; $user_id = $GLOBALS['user']->id;
$fullname = $GLOBALS['user']->fullname; $fullname = $GLOBALS['user']->fullname;
@ -58,6 +63,15 @@ switch($_REQUEST['action']) {
$fullname= _('Server'); $fullname= _('Server');
$preferences = $GLOBALS['user']->get_preferences(-1,$_REQUEST['tab']); $preferences = $GLOBALS['user']->get_preferences(-1,$_REQUEST['tab']);
break; break;
case 'user':
if (!$GLOBALS['user']->has_access('100')) {
access_denied();
exit;
}
$client = new User($_REQUEST['user_id']);
$fullname = $client->fullname;
$preferences = $client->get_preferences(0,$_REQUEST['tab']);
break;
default: default:
$fullname = $GLOBALS['user']->fullname; $fullname = $GLOBALS['user']->fullname;
$preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']); $preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']);

View file

@ -73,6 +73,8 @@
<select name="access"> <select name="access">
<option value="5" <?php echo $on_5; ?>><?php echo _('Guest'); ?></option> <option value="5" <?php echo $on_5; ?>><?php echo _('Guest'); ?></option>
<option value="25" <?php echo $on_25; ?>><?php echo _('User'); ?></option> <option value="25" <?php echo $on_25; ?>><?php echo _('User'); ?></option>
<option value="50" <?php echo $on_50; ?>><?php echo _('Content Manager'); ?></option>
<option value="75" <?php echo $on_75; ?>><?php echo _('Catalog Manager'); ?></option>
<option value="100" <?php echo $on_100; ?>><?php echo _('Admin'); ?></option> <option value="100" <?php echo $on_100; ?>><?php echo _('Admin'); ?></option>
</select> </select>
</td> </td>

View file

@ -35,7 +35,9 @@ if ($_REQUEST['tab'] != 'account' && $_REQUEST['tab'] != 'modules') {
<input class="button" type="submit" value="<?php echo _('Update Preferences'); ?>" /> <input class="button" type="submit" value="<?php echo _('Update Preferences'); ?>" />
<input type="hidden" name="tab" value="<?php echo scrub_out($_REQUEST['tab']); ?>" /> <input type="hidden" name="tab" value="<?php echo scrub_out($_REQUEST['tab']); ?>" />
<input type="hidden" name="method" value="<?php echo scrub_out($_REQUEST['action']); ?>" /> <input type="hidden" name="method" value="<?php echo scrub_out($_REQUEST['action']); ?>" />
<input class="button" type="submit" name="action" value="<?php echo _("Cancel"); ?>" /> <?php if ($GLOBALS['user']->has_access('100')) { ?>
<input type="hidden" name="user_id" value="<?php echo scrub_out($_REQUEST['user_id']); ?>" />
<?php } ?>
<?php <?php
} // end if not account } // end if not account
if ($_REQUEST['tab'] == 'account') { if ($_REQUEST['tab'] == 'account') {

View file

@ -30,22 +30,14 @@ $web_path = Config::get('web_path');
</tr> </tr>
<tr class="table-header"> <tr class="table-header">
<td align="center"> <td align="center">
<a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=fullname&amp;sort_order=0">
<b><?php echo _('Fullname'); ?></b> <b><?php echo _('Fullname'); ?></b>
</a>
<a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=username&amp;sort_order=0">
<b>(<?php echo _('Username'); ?>)</b> <b>(<?php echo _('Username'); ?>)</b>
</a>
</td> </td>
<td align="center"> <td align="center">
<a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=last_seen&amp;sort_order=0">
<b><?php echo _('Last Seen'); ?></b> <b><?php echo _('Last Seen'); ?></b>
</a>
</td> </td>
<td align="center"> <td align="center">
<a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=create_date&amp;sort_order=0">
<b><?php echo _('Registration Date'); ?></b> <b><?php echo _('Registration Date'); ?></b>
</a>
</td> </td>
<td align="center"> <td align="center">
<b><?php echo _('Activity'); ?></b> <b><?php echo _('Activity'); ?></b>
@ -69,7 +61,7 @@ foreach ($object_ids as $user_id) {
?> ?>
<tr class="<?php echo flip_class(); ?>" align="center"> <tr class="<?php echo flip_class(); ?>" align="center">
<td align="left"> <td align="left">
<a href="<?php echo $web_path; ?>/admin/users.php?action=edit&amp;user_id=<?php echo $client->id; ?>"> <a href="<?php echo $web_path; ?>/stats.php?action=show_user&amp;user_id=<?php echo $client->id; ?>">
<?php echo $client->fullname; ?> (<?php echo $client->username; ?>) <?php echo $client->fullname; ?> (<?php echo $client->username; ?>)
</a> </a>
</td> </td>
@ -92,9 +84,10 @@ foreach ($object_ids as $user_id) {
<a href="<?php echo $web_path; ?>/admin/users.php?action=show_edit&amp;user_id=<?php echo $client->id; ?>"> <a href="<?php echo $web_path; ?>/admin/users.php?action=show_edit&amp;user_id=<?php echo $client->id; ?>">
<?php echo get_user_icon('edit'); ?> <?php echo get_user_icon('edit'); ?>
</a> </a>
<a href="<?php echo $web_path; ?>/admin/preferences.php?action=user&amp;user_id=<?php echo $client->id; ?>"> <!-- <a href="<?php echo $web_path; ?>/preferences.php?action=user&amp;user_id=<?php echo $client->id; ?>">
<?php echo get_user_icon('preferences'); ?> <?php echo get_user_icon('preferences'); ?>
</a> </a>
-->
<?php <?php
//FIXME: Fix this for the extra permission levels //FIXME: Fix this for the extra permission levels
if ($working_user->disabled == '1') { if ($working_user->disabled == '1') {

View file

@ -2,17 +2,20 @@
<span><a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_add_catalog"><?php echo _('Add a Catalog'); ?></a></span> <span><a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_add_catalog"><?php echo _('Add a Catalog'); ?></a></span>
<hr /> <hr />
<?php <?php
$catalogs = Catalog::get_catalogs(); $catalogs = Catalog::get_catalog_ids();
foreach ($catalogs as $catalog_id) { foreach ($catalogs as $catalog_id) {
$catalog = new Catalog($catalog_id); $catalog = new Catalog($catalog_id);
?> ?>
<strong><a href="<?php echo $web_path; ?>/admin/catalog?action=show_customize_catalog"> <strong><a href="<?php echo $web_path; ?>/admin/catalog?action=show_customize_catalog">
<?php echo $catalog->name; ?> <?php echo $catalog->name; ?>
<a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=show_delete_catalog&amp;catalog_id=<?php echo $catalog->id; ?>">
<?php echo get_user_icon('delete','',_('Delete Catalog')); ?>
</a>
</a></strong><br /> </a></strong><br />
<a href="<?php echo $web_path; ?>/admin/catalog.php?action=add_to_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Add'); ?></a> <a href="<?php echo $web_path; ?>/admin/catalog.php?action=add_to_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Add'); ?></a>
| <a href="<?php echo $web_path; ?>/admin/catalog.php?action=update_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Verify'); ?></a> | <a href="<?php echo $web_path; ?>/admin/catalog.php?action=update_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Verify'); ?></a>
| <a href="<?php echo $web_path; ?>/admin/catalog.php?action=clean_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Clean'); ?></a> | <a href="<?php echo $web_path; ?>/admin/catalog.php?action=clean_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Clean'); ?></a>
<?php } ?> <?php } // end foreach catalogs ?>
<hr /> <hr />
<h4><?php echo _('User Tools'); ?></h4> <h4><?php echo _('User Tools'); ?></h4>
<span><a href="<?php echo $web_path; ?>/admin/users.php?action=show_add_user"><?php echo _('Add User'); ?></a></span> <span><a href="<?php echo $web_path; ?>/admin/users.php?action=show_add_user"><?php echo _('Add User'); ?></a></span>