summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-12 05:30:30 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-12 05:30:30 +0000
commit7be9eb4ea1e868fa0725334697057e1b7b994460 (patch)
tree5d4c634f2d64f2202cad95b4ce74c87838655e3d
parent12f679cf51ed9440c44cdc0cb178687f0ad17c3b (diff)
downloadampache-7be9eb4ea1e868fa0725334697057e1b7b994460.tar.gz
ampache-7be9eb4ea1e868fa0725334697057e1b7b994460.tar.bz2
ampache-7be9eb4ea1e868fa0725334697057e1b7b994460.zip
re-added ability to delete catalogs, fixed exception error with id3 library
-rw-r--r--admin/catalog.php14
-rw-r--r--admin/index.php18
-rw-r--r--admin/preferences.php102
-rw-r--r--images/icon_disable.pngbin587 -> 715 bytes
-rw-r--r--lib/class/catalog.class.php14
-rwxr-xr-xlib/class/vainfo.class.php7
-rw-r--r--lib/ui.lib.php23
-rw-r--r--preferences.php16
-rw-r--r--templates/show_add_user.inc.php2
-rw-r--r--templates/show_preferences.inc.php4
-rw-r--r--templates/show_users.inc.php13
-rw-r--r--templates/sidebar_admin.inc.php7
12 files changed, 78 insertions, 142 deletions
diff --git a/admin/catalog.php b/admin/catalog.php
index 8c29fa9c..37403d0c 100644
--- a/admin/catalog.php
+++ b/admin/catalog.php
@@ -99,13 +99,12 @@ switch ($_REQUEST['action']) {
break;
case 'delete_catalog':
/* 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 */
- $catalog = new Catalog($_REQUEST['catalog_id']);
- $catalog->delete_catalog();
- $next_url = conf('web_path') . '/admin/index.php';
- show_confirmation(_('Catalog Deleted'),_('The Catalog and all associated records has been deleted'),$nexturl);
+ Catalog::delete($_REQUEST['catalog_id']);
+ $next_url = Config::get('web_path') . '/admin/index.php';
+ show_confirmation(_('Catalog Deleted'),_('The Catalog and all associated records have been deleted'),$nexturl);
break;
case 'remove_disabled':
if (conf('demo_mode')) { break; }
@@ -226,9 +225,10 @@ switch ($_REQUEST['action']) {
break;
case 'show_delete_catalog':
/* Stop the demo hippies */
- if (conf('demo_mode')) { break; }
+ if (Config::get('demo_mode')) { break; }
+
$catalog = new Catalog($_REQUEST['catalog_id']);
- $nexturl = conf('web_path') . '/admin/catalog.php?action=delete_catalog&amp;catalog_id=' . scrub_out($_REQUEST['catalog_id']);
+ $nexturl = Config::get('web_path') . '/admin/catalog.php?action=delete_catalog&amp;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);
break;
case 'show_customize_catalog':
diff --git a/admin/index.php b/admin/index.php
index 99631f29..3fd759af 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2006 Ampache.org
+ Copyright (c) 2001 - 2007 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -22,19 +22,13 @@
require '../lib/init.php';
-$action = scrub_in($_REQUEST['action']);
-
if (!$GLOBALS['user']->has_access(100)) {
access_denied();
exit();
}
-require_once Config::get('prefix') . '/templates/header.inc.php';
-?>
-<div id="admin-tools">
- <?php require Config::get('prefix') . '/templates/show_admin_tools.inc.php'; ?>
-</div>
-<div id="admin-info">
- <?php require Config::get('prefix') . '/templates/show_admin_info.inc.php'; ?>
-</div>
-<?php show_footer(); ?>
+show_header();
+
+
+
+show_footer();
diff --git a/admin/preferences.php b/admin/preferences.php
deleted file mode 100644
index bc3c653f..00000000
--- a/admin/preferences.php
+++ /dev/null
@@ -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();
-
-
-?>
diff --git a/images/icon_disable.png b/images/icon_disable.png
index c149c2bc..08f24936 100644
--- a/images/icon_disable.png
+++ b/images/icon_disable.png
Binary files differ
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index c25d9c3f..7e598e00 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -105,7 +105,7 @@ class Catalog {
public static function get_catalog_ids() {
$sql = "SELECT `id` FROM `catalog`";
- $db_results = Dba::qery($sql);
+ $db_results = Dba::query($sql);
while ($r = Dba::fetch_assoc($db_results)) {
$results[] = $r['id'];
@@ -2061,20 +2061,22 @@ class Catalog {
/**
* delete
* 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
- $sql = "DELETE FROM `song` WHERE `catalog` = '$this->id'";
+ $sql = "DELETE FROM `song` WHERE `catalog` = '$catalog_id'";
$db_results = Dba::query($sql);
// 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);
// Run the Aritst/Album Cleaners...
- self::clean($this->id);
+ self::clean($catalog_id);
} // delete
diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php
index e2212838..85b12659 100755
--- a/lib/class/vainfo.class.php
+++ b/lib/class/vainfo.class.php
@@ -88,7 +88,12 @@ class vainfo {
function get_info() {
/* 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 */
$this->type = $this->_get_type();
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index a1283841..aa407adf 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -1424,4 +1424,27 @@ function ajax_include($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
+
?>
diff --git a/preferences.php b/preferences.php
index a83890d2..9cbb8dd6 100644
--- a/preferences.php
+++ b/preferences.php
@@ -28,7 +28,7 @@ if (!$_REQUEST['tab']) { $_REQUEST['tab'] = 'interface'; }
// Switch on the action
switch($_REQUEST['action']) {
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();
exit;
}
@@ -38,6 +38,11 @@ switch($_REQUEST['action']) {
$user_id = '-1';
$fullname = _('Server');
}
+ elseif ($_REQUEST['method'] == 'user') {
+ $user_id = $_REQUEST['user_id'];
+ $client = new User($user_id);
+ $fullname = $client->fullname;
+ }
else {
$user_id = $GLOBALS['user']->id;
$fullname = $GLOBALS['user']->fullname;
@@ -58,6 +63,15 @@ switch($_REQUEST['action']) {
$fullname= _('Server');
$preferences = $GLOBALS['user']->get_preferences(-1,$_REQUEST['tab']);
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:
$fullname = $GLOBALS['user']->fullname;
$preferences = $GLOBALS['user']->get_preferences(0,$_REQUEST['tab']);
diff --git a/templates/show_add_user.inc.php b/templates/show_add_user.inc.php
index ed9ac236..38871dc1 100644
--- a/templates/show_add_user.inc.php
+++ b/templates/show_add_user.inc.php
@@ -73,6 +73,8 @@
<select name="access">
<option value="5" <?php echo $on_5; ?>><?php echo _('Guest'); ?></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>
</select>
</td>
diff --git a/templates/show_preferences.inc.php b/templates/show_preferences.inc.php
index 0ecc4984..81b2c06e 100644
--- a/templates/show_preferences.inc.php
+++ b/templates/show_preferences.inc.php
@@ -35,7 +35,9 @@ if ($_REQUEST['tab'] != 'account' && $_REQUEST['tab'] != 'modules') {
<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="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
} // end if not account
if ($_REQUEST['tab'] == 'account') {
diff --git a/templates/show_users.inc.php b/templates/show_users.inc.php
index 640978c7..087aa85b 100644
--- a/templates/show_users.inc.php
+++ b/templates/show_users.inc.php
@@ -30,22 +30,14 @@ $web_path = Config::get('web_path');
</tr>
<tr class="table-header">
<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>
- </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>
- </a>
</td>
<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>
- </a>
</td>
<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>
- </a>
</td>
<td align="center">
<b><?php echo _('Activity'); ?></b>
@@ -69,7 +61,7 @@ foreach ($object_ids as $user_id) {
?>
<tr class="<?php echo flip_class(); ?>" align="center">
<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; ?>)
</a>
</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; ?>">
<?php echo get_user_icon('edit'); ?>
</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'); ?>
</a>
+-->
<?php
//FIXME: Fix this for the extra permission levels
if ($working_user->disabled == '1') {
diff --git a/templates/sidebar_admin.inc.php b/templates/sidebar_admin.inc.php
index e35d1d98..04c68612 100644
--- a/templates/sidebar_admin.inc.php
+++ b/templates/sidebar_admin.inc.php
@@ -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>
<hr />
<?php
- $catalogs = Catalog::get_catalogs();
+ $catalogs = Catalog::get_catalog_ids();
foreach ($catalogs as $catalog_id) {
$catalog = new Catalog($catalog_id);
?>
<strong><a href="<?php echo $web_path; ?>/admin/catalog?action=show_customize_catalog">
<?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 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=clean_catalog&amp;catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Clean'); ?></a>
-<?php } ?>
+<?php } // end foreach catalogs ?>
<hr />
<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>