summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/flag.php141
-rw-r--r--admin/modules.php42
-rwxr-xr-xdocs/CHANGELOG2
-rw-r--r--lib/album.lib.php2
-rw-r--r--lib/class/plugin.class.php218
-rw-r--r--lib/general.lib.php38
-rw-r--r--lib/init.php4
-rw-r--r--lib/preferences.php21
-rw-r--r--lib/ui.lib.php15
-rw-r--r--modules/admin.php239
-rw-r--r--modules/lib.php110
-rw-r--r--modules/plugins/Lastfm.plugin.php77
-rw-r--r--server/ajax.server.php10
-rw-r--r--templates/show_localplay_switch.inc.php6
-rw-r--r--templates/show_modules.inc.php43
-rw-r--r--templates/show_playtype_switch.inc.php16
-rw-r--r--templates/sidebar.inc.php12
-rw-r--r--templates/song_edit.inc2
18 files changed, 523 insertions, 475 deletions
diff --git a/admin/flag.php b/admin/flag.php
index e8416b6f..7ebe05d5 100644
--- a/admin/flag.php
+++ b/admin/flag.php
@@ -97,6 +97,49 @@ switch ($action) {
show_confirmation(_('Song Updated'),_('The requested song has been updated'),$_SESSION['source']);
break;
+ /* Done by 'Select' code passes array of song ids */
+ case 'mass_update':
+ $songs = $_REQUEST['songs'];
+ $catalog = new Catalog();
+ $object = $_REQUEST['update_field'];
+
+ /* Foreach the songs we need to update */
+ foreach ($songs as $song_id) {
+
+ $new_song = new Song($song_id);
+ $old_song = new Song();
+ $old_song->artist = $new_song->artist;
+ $old_song->album = $new_song->album;
+ $old_song->genre = $new_song->genre;
+
+ /* Restrict which fields can be updated */
+ switch ($object) {
+ case 'genre':
+ $new_song->genre = $catalog->check_genre(revert_string($_REQUEST['update_value']));
+ break;
+ case 'album':
+ $new_song->album = $catalog->check_album(revert_string($_REQUEST['update_value']));
+ break;
+ case 'aritst':
+ $new_song->artist = $catalog->check_artist(revert_string($_REQUEST['update_value']));
+ break;
+ default:
+ // Rien a faire
+ break;
+ } // end switch
+
+ /* Update this mofo, store an old copy for cleaning */
+ $song->update_song($song_id,$new_song);
+
+ /* Now that it's been updated clean old junk entries */
+ $cleaned = $catalog->clean_single_song($old_song);
+
+ $flag = new Flag();
+ $flag->add($song_id,'song','retag','Edited Song, auto-tag');
+
+ } // end foreach songs
+
+ break;
case 'reject_flag':
$flag_id = scrub_in($_REQUEST['flag_id']);
$flag = new Flag($flag_id);
@@ -145,104 +188,6 @@ switch ($action) {
break;
} // end switch
-
-/*
- @function edit_song_info
- @discussion yea this is just wrong
-*/
-function edit_song_info($song) {
- $info = new Song($song);
- preg_match("/^.*\/(.*?)$/",$info->file, $short);
- $filename = htmlspecialchars($short[1]);
- if(preg_match('/\.ogg$/',$short[1]))
- {
- $ogg = TRUE;
- $oggwarn = "<br/><br><em>This file is an OGG file, which Ampache only has limited support for.<br/>";
- $oggwarn .= "You can make changes to the database here, but Ampache will not change the actual file's information.</em><br/><br/>";
- }
-
-echo <<<EDIT_SONG_1
-<p><b>Editing $info->title</b></p>
-<form name="update_song" method="post" action="song.php">
-<table class="border" cellspacing="0">
- <tr class="table-header">
- <td colspan="3"><b>Editing $info->title</b></td>
- </tr>
-
- <tr class="odd">
- <td>File:</td>
- <td colspan="2">$filename $oggwarn</td>
- </tr>
-
- <tr class="odd">
- <td>Title:</td>
- <td colspan="2"><input type="text" name="title" size="60" value="$info->title" /></td>
- </tr>
-
- <tr class="even">
- <td>Artist:</td>
- <td>
-EDIT_SONG_1;
- show_artist_pulldown($info->artist);
-echo <<<EDIT_SONG_2
- </td>
- <td>or <input type="text" name="new_artist" size="30" value="" /></td>
- </tr>
-
- <tr class="odd">
- <td>Album:</td>
- <td>
-EDIT_SONG_2;
- show_album_pulldown($info->album);
-echo <<<EDIT_SONG_3
- </td>
- <td>or <input type="text" name="new_album" size="30" value="" /></td>
- </tr>
-
- <tr class="even">
- <td>Track:</td>
- <td colspan="2"><input type="text" size="4" maxlength="4" name="track" value="$info->track"></input></td>
- </tr>
-
- <tr class="odd">
- <td>Genre:</td>
- <td colspan="2">
-EDIT_SONG_3;
- show_genre_pulldown('genre',$info->genre);
-echo <<<EDIT_SONG_4
- </td>
-</tr>
- <tr class="even">
- <td>Year</td>
- <td colspan="2"><input type="text" size="4" maxlength="4" name="year" value="$info->year"></input></td>
- </tr>
-
-EDIT_SONG_4;
-if(!$ogg)
-{
-echo <<<EDIT_SONG_5
- <tr class="even">
- <td>&nbsp;</td>
- <td><input type="checkbox" name="update_id3" value="yes"></input>&nbsp; Update id3 tags </td>
- <td>&nbsp;</td>
- </tr>
-EDIT_SONG_5;
-}
-echo <<<EDIT_SONG_6
- <tr class="odd">
- <td> &nbsp; </td>
- <td colspan="2">
- <input type="hidden" name="song" value="$song" />
- <input type="hidden" name="current_artist_id" value="$info->artist" />
- <input type="submit" name="action" value="Update" />
- </td>
- </tr>
-</table>
-
-</form>
-EDIT_SONG_6;
-}
-
show_footer();
?>
diff --git a/admin/modules.php b/admin/modules.php
index 5dde981c..7e070610 100644
--- a/admin/modules.php
+++ b/admin/modules.php
@@ -57,6 +57,48 @@ switch ($action) {
$body = '';
show_confirmation($title,$body,$url);
break;
+ case 'install_plugin':
+ /* Verify that this plugin exists */
+ $plugins = get_plugins();
+ if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
+ debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
+ break;
+ }
+ $plugin = new Plugin($_REQUEST['plugin']);
+ $plugin->install();
+
+ /* Show Confirmation */
+ $url = conf('web_path') . '/admin/modules.php';
+ $title = _('Plugin Activated');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ case 'confirm_uninstall_plugin':
+ $plugin = scrub_in($_REQUEST['plugin']);
+ $url = conf('web_path') . '/admin/modules.php?action=uninstall_plugin&amp;plugin=' . $plugin;
+ $title = _('Are you sure you want to remove this plugin?');
+ $body = '';
+ show_confirmation($title,$body,$url,1);
+ break;
+ case 'uninstall_plugin':
+ /* Verify that this plugin exists */
+ $plugins = get_plugins();
+ if (!array_key_exists($_REQUEST['plugin'],$plugins)) {
+ debug_event('plugins','Error: Invalid Plugin: ' . $_REQUEST['plugin'] . ' selected','1');
+ break;
+ }
+ $plugin = new Plugin($_REQUEST['plugin']);
+ $plugin->uninstall();
+
+ /* Show Confirmation */
+ $url = conf('web_path') . '/admin/modules.php';
+ $title = _('Plugin Deactivated');
+ $body = '';
+ show_confirmation($title,$body,$url);
+ break;
+ case 'upgrade_plugin':
+
+ break;
default:
require_once (conf('prefix') . '/templates/show_modules.inc.php');
break;
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index e8561612..93d31e54 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,8 @@
--------------------------------------------------------------------------
v.3.3.3-Beta1
+ - Added Plugin Interface under Admin --> Modules
+ - Fixed playtype switcher so it shows all possible play methods
- Tweaked home page a little, remove pop songs and recent artists
- Added Recently Played to Main Page
- Fixed an issue on Browse by Albums and sorting by Artist after
diff --git a/lib/album.lib.php b/lib/album.lib.php
index 7d518ff8..fc030163 100644
--- a/lib/album.lib.php
+++ b/lib/album.lib.php
@@ -26,6 +26,4 @@ function get_albums($sql, $action=0) {
-
-
?>
diff --git a/lib/class/plugin.class.php b/lib/class/plugin.class.php
new file mode 100644
index 00000000..5a058ac5
--- /dev/null
+++ b/lib/class/plugin.class.php
@@ -0,0 +1,218 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2006 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.
+
+*/
+
+class Plugin {
+
+ /* Base Variables */
+ var $name;
+
+ /* constructed objects */
+ var $_plugin;
+
+ /**
+ * Constructor
+ * This constructor loads the Plugin config file which defines how to
+ * install/uninstall the plugin from Ampache's database
+ */
+ function Plugin($name) {
+
+ /* Load the plugin */
+ if (!$this->_get_info($name)) {
+ return false;
+ }
+
+ return true;
+
+ } // Plugin
+
+
+ /**
+ * _get_info
+ * This actually loads the config file for the plugin the name of the
+ * class contained within the config file must be Plugin[NAME OF FILE]
+ */
+ function _get_info($name) {
+
+ /* Require the file we want */
+ require_once(conf('prefix') . '/modules/plugins/' . $name . '.plugin.php');
+
+ $plugin_name = "Ampache$name";
+
+ $this->_plugin = new $plugin_name();
+
+ if (!$this->is_valid()) {
+ return false;
+ }
+
+ return true;
+
+ } // _get_info
+
+ /**
+ * is_valid
+ * This checks to make sure the plugin has the required functions and
+ * settings, Ampache requires Name/Description/Version (Int) and a
+ * install & uninstall method and Ampache must be within the min/max
+ * version specifications
+ */
+ function is_valid() {
+
+ /* Check the plugin to make sure it's got the needed vars */
+ if (!strlen($this->_plugin->name)) {
+ return false;
+ }
+ if (!strlen($this->_plugin->description)) {
+ return false;
+ }
+ if (!strlen($this->_plugin->version)) {
+ return false;
+ }
+
+ /* Make sure we've got the required methods */
+ if (!method_exists($this->_plugin,'install')) {
+ return false;
+ }
+
+ if (!method_exists($this->_plugin,'uninstall')) {
+ return false;
+ }
+
+ /* Make sure it's within the version confines */
+ $db_version = $this->get_ampache_db_version();
+
+ if ($db_version < $this->_plugin->min_ampache) {
+ return false;
+ }
+
+ if ($db_version > $this->_plugin->max_ampache) {
+ return false;
+ }
+
+ /* We've passed all of the tests its good */
+ return true;
+
+ } // is_valid
+
+ /**
+ * is_installed
+ * This checks to see if the current plugin is currently installed in the
+ * database, it doesn't check the files for integrity
+ */
+ function is_installed() {
+
+ /* All we do is check the version */
+ return $this->get_plugin_version();
+
+ } // is_installed
+
+ /**
+ * install
+ * This runs the install function of the plugin (must be called install)
+ * at the end it inserts a row into the update_info table to indicate
+ * That it's installed
+ */
+ function install() {
+
+ $this->_plugin->install();
+
+ $this->set_plugin_version($this->_plugin->version);
+
+ } // install
+
+ /**
+ * uninstall
+ * This runs the uninstall function of the plugin (must be called uninstall)
+ * at the end it removes the row from the update_info table to indicate
+ * that it isn't installed
+ */
+ function uninstall() {
+
+ $this->_plugin->uninstall();
+
+ $this->remove_plugin_version();
+
+ } // uninstall
+
+ /**
+ * get_plugin_version
+ * This returns the version of the currently installed plugin
+ */
+ function get_plugin_version() {
+
+ $name = sql_escape('Plugin_' . $this->_plugin->name);
+
+ $sql = "SELECT * FROM update_info WHERE `key`='$name'";
+ $db_results = mysql_query($sql,dbh());
+
+ $results = mysql_fetch_assoc($db_results);
+
+ return $results['value'];
+
+ } // get_plugin_version
+
+ /**
+ * get_ampache_db_version
+ * This function returns the Ampache database version
+ */
+ function get_ampache_db_version() {
+
+ $sql = "SELECT * FROM update_info WHERE `key`='db_version'";
+ $db_results = mysql_query($sql,dbh());
+
+ $results = mysql_fetch_assoc($db_results);
+
+ return $results['value'];
+
+ } // get_ampache_db_version
+
+ /**
+ * set_plugin_version
+ * This sets the plugin version in the update_info table
+ */
+ function set_plugin_version($version) {
+
+ $name = sql_escape('Plugin_' . $this->_plugin->name);
+ $version = sql_escape($version);
+
+ $sql = "INSERT INTO update_info SET `key`='$name', value='$version'";
+ $db_results = mysql_query($sql,dbh());
+
+ return true;
+
+ } // set_plugin_version
+
+ /**
+ * remove_plugin_version
+ * This removes the version row from the db done on uninstall
+ */
+ function remove_plugin_version() {
+
+ $name = sql_escape('Plugin_' . $this->_plugin->name);
+
+ $sql = "DELETE FROM update_info WHERE `key`='$name'";
+ $db_results = mysql_query($sql,dbh());
+
+ return true;
+
+ } // remove_plugin_version
+
+} //end plugin class
+?>
diff --git a/lib/general.lib.php b/lib/general.lib.php
index 697e0f50..b6c7c3fc 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -988,4 +988,42 @@ function get_user_from_username($username) {
} // get_user_from_username
+/**
+ * get_plugins
+ * This returns a list of the plugins and their information
+ */
+function get_plugins() {
+
+ /* Init our vars */
+ $plugins = array();
+
+ /* Open the dir */
+ $handle = opendir(conf('prefix') . '/modules/plugins');
+
+ if (!is_resource($handle)) {
+ debug_event('plugins','Error: Unable to read plugins directory','1');
+ }
+
+ while ($file = readdir($handle)) {
+ if (substr($file,-10,10) != 'plugin.php') { continue; }
+
+ /* Make sure it isn't a subdir */
+ if (!is_dir($file)) {
+
+ /* Get the Basename */
+ $plugin_name = basename($file,'.plugin.php');
+
+ /* Load it */
+ $plugin = new Plugin($plugin_name);
+ $plugins[$plugin_name] = $plugin;
+ } // if its not a subdir
+
+ } // end while
+
+
+ return $plugins;
+
+} // get_plugins
+
+
?>
diff --git a/lib/init.php b/lib/init.php
index 6418c826..483720fe 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -67,7 +67,7 @@ if (!$results = read_config($configfile,0)) {
}
/** This is the version.... fluf nothing more... **/
-$results['version'] = '3.3.3-Beta1 (Build 001)';
+$results['version'] = '3.3.3-Beta1 (Build 002)';
$results['raw_web_path'] = $results['web_path'];
$results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path'];
@@ -153,7 +153,6 @@ require_once(conf('prefix') . '/lib/playlist.lib.php');
require_once(conf('prefix') . '/lib/upload.php');
require_once(conf('prefix') . '/lib/democratic.lib.php');
require_once(conf('prefix') . '/modules/lib.php');
-require_once(conf('prefix') . '/modules/admin.php');
require_once(conf('prefix') . '/modules/catalog.php');
require_once(conf('prefix') . "/modules/id3/getid3/getid3.php");
require_once(conf('prefix') . '/modules/id3/vainfo.class.php');
@@ -170,6 +169,7 @@ if (conf('ratings')) {
// Classes
require_once(conf('prefix') . '/lib/class/localplay.class.php');
+require_once(conf('prefix') . '/lib/class/plugin.class.php');
require_once(conf('prefix') . '/lib/class/stats.class.php');
require_once(conf('prefix') . '/lib/class/catalog.class.php');
require_once(conf('prefix') . '/lib/class/stream.class.php');
diff --git a/lib/preferences.php b/lib/preferences.php
index 39755735..ac18479c 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -487,4 +487,25 @@ function update_preference_level($name,$level) {
} // update_preference_level
+/**
+ * fix_all_users_prefs
+ * This function is used by install/uninstall and fixes all of the users preferences
+ */
+function fix_all_users_prefs() {
+
+ $sql = "SELECT * FROM user";
+ $db_results = mysql_query($sql,dbh());
+
+ $user = new User();
+ $user->fix_preferences('-1');
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $user->fix_preferences($r['username']);
+ }
+
+ return true;
+
+} // fix_all_users_prefs
+
+
?>
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index c1f676ee..e1154b21 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -1426,5 +1426,20 @@ function xml_get_footer($type){
}
} //xml_get_footer
+/**
+ * show_manage_users
+ * This is the admin page for showing all of the users
+ */
+function show_manage_users() {
+
+ show_box_top(_('Manage Users'));
+ echo "<ul>\n\t<li><a href=\"".conf('web_path') . "/admin/users.php?action=show_add_user\">" . _('Add a new user') . "</a></li>\n</ul>\n";
+ show_box_bottom();
+
+ /* Show the Users */
+ show_users();
+
+} // show_manage_users
+
?>
diff --git a/modules/admin.php b/modules/admin.php
deleted file mode 100644
index 0be633e5..00000000
--- a/modules/admin.php
+++ /dev/null
@@ -1,239 +0,0 @@
-<?php
-/*
-
- This contains all of the subroutines for handling any
- administration function such as prefereneces, etc.
-
-*/
-
-/*
- * show_access_list
- *
- * Used in the access.inc template for getting information about
- * remote servers that have access to use this Ampache server's
- * catalog.
- */
-function show_access_list () {
- $dbh = dbh();
-
- $sql = "SELECT * FROM access_list";
- $db_result = mysql_query($sql, $dbh);
-
- if ( mysql_num_rows($db_result) ) {
- while ($host = mysql_fetch_object($db_result) ) {
-
- $ip = int2ip($host->ip);
-
- print("\t<tr><td bgcolor=\"" . conf('secondary_color') . "\">$host->name</td>".
- "<td bgcolor=\"" . conf('secondary_color') . "\">$ip</td>".
- "<td bgcolor=\"" . conf('secondary_color') . "\"><a href=\"" . conf('web_path') . "/access.php?action=delete_host&amp;id=$host->id\">Delete</td></tr>\n");
- }
- }
- else {
- print("\t<tr><td bgcolor=\"" . conf('secondary_color') . "\"colspan=\"3\">You don't have any hosts in your access list.</td></tr>\n");
- }
-} // show_access_list()
-
-
-/*
- * show_manage_users
- *
- */
-
-function show_manage_users () {
-
- show_box_top(_('Manage Users'));
- echo "<p>Use the following tools to manage the users that access your site.</p>\n";
- echo "<ul>\n\t<li><a href=\"".conf('web_path') . "/admin/users.php?action=show_add_user\">" . _("Add a new user") . "</a></li>\n</ul>\n";
- show_box_bottom();
-
- show_users();
-} // show_manage_users()
-
-
-/*
- * show_change_password
- *
- */
-
-function show_change_password ($username) {
-
- $user = get_user($username);
-
- print("<form name=\"change_password\" method=\"post\" action=\"user.php\">");
-
- print("<p style=\"font-size: 10px; font-weight: bold;\">Changing User Password</p>\n");
-
- print("<table width=\"90%\">");
-
- print("<tr>\n");
- print("<td>Enter password:</td>");
- print("<td><input type=password name=new_password_1 size=30 value=\"\"></td>");
- print("</tr>\n");
-
- print("<tr>\n");
- print("<td>Enter password again:</td>");
- print("<td><input type=password name=new_password_2 size=30 value=\"\"></td>");
- print("</tr>\n");
-
- print("</table>\n");
- print("<input type=submit name=\"action\" value=\"Change Password\">");
- print("</form>");
-} // show_change_password
-
-/*
- * show_update_user_info
- *
- */
-
-function show_update_user_info ($username) {
-
- $user = get_user($username);
-
- $user->offset_limit = abs($user->offset_limit);
-
- print("<form name=\"change_password\" method=\"post\" action=\"user.php\">");
-
- print("<p style=\"font-size: 10px; font-weight: bold;\">Changing User Information for $user->fullname</p>\n");
-
- print("<table width=\"90%\">");
-
- print("<tr>\n");
- print("<td>Fullname:</td>");
- print("<td><input type=text name=new_fullname size=30 value=\"$user->fullname\"></td>");
- print("</tr>\n");
-
- print("<tr>\n");
- print("<td>Email:</td>");
- print("<td><input type=text name=new_email size=30 value=\"$user->email\"></td>");
- print("</tr>\n");
-
- print("<tr>\n");
- print("<td>View Limit:</td>");
- print("<td><input type=text name=new_offset size=5 value=\"$user->offset_limit\"></td>");
- print("</tr>\n");
-
- print("</table>\n");
- print("<input type=submit name=\"action\" value=\"Update Profile\">");
- print("</form>");
-} // show_update_user_info()
-
-/*
- * show_delete_stats
- *
- */
-
-function show_delete_stats($username) {
- print("<form name=\"clear_statistics\" method=\"post\" action=\"user.php\">");
- print("<br>");
-
- if ( $username == 'all') {
- print("<p style=\"font-size: 10px; font-weight: bold;\">Delete Your Personal Statistics</p>\n");
- }
- else {
- print("<p style=\"font-size: 10px; font-weight: bold;\">Delete Your Personal Statistics</p>\n");
- }
-
- print("<input type=submit name=\"action\" value=\"Clear Stats\">");
- print("</form>");
-} // show_delete_stats()
-
-
-
-/*
- * get_user
- *
- */
-function get_user_byid ($id) {
-
-
- $sql = "SELECT * FROM user WHERE id='$id'";
- $db_result = mysql_query($sql, dbh());
- return (mysql_fetch_object($db_result));
-} // get_user_byid()
-
-function get_user ($username) {
-
-
- $sql = "SELECT * FROM user WHERE username='$username'";
- $db_result = mysql_query($sql, dbh());
-
- return (mysql_fetch_object($db_result));
-} // get_user()
-
-/*
- * delete_user
- *
- */
-
-function delete_user ($username) {
-
- // delete from the user table
- $sql = "DELETE FROM user WHERE username='$username'";
- $db_result = mysql_query($sql, dbh());
-
- // also delete playlists for user
- $sql = "DELETE FROM playlist WHERE username='$username'";
- $db_result = mysql_query($sql, dbh());
-
- delete_user_stats('all');
-
-} // delete_user()
-
-/*
- * update_user
- *
- */
-
-function update_user ($username, $fullname, $email, $access)
-{
- $dbh = libglue_param(libglue_param('dbh_name'));
- if(!$username || !$fullname || !$email || !$access) return 0;
- $sql = "UPDATE user ".
- "SET fullname='$fullname',".
- "email='$email',".
- "access='$access'".
- "WHERE username='$username'";
- $db_result = mysql_query($sql, $dbh);
- if($db_result) return 1;
- else return 0;
-} // update_user()
-
-/*
- * update_user_info
- *
- * this for use by 'user' to update limited amounts of info
- *
- */
-
-function update_user_info ($username, $fullname, $email,$offset) {
-
- $dbh = libglue_param(libglue_param('dbh_name'));
-
- $sql = "UPDATE user SET fullname='$fullname', email='$email', offset_limit='$offset' WHERE username='$username'";
- $db_result = mysql_query($sql, $dbh);
-
- // Update current session (so the views are updated)
- $_SESSION['offset_limit'] = $offset;
-
- return ($db_result)?1:0;
-
-} // update_user_info()
-
-
-/*
- * set_user_password
- *
- */
-
-function set_user_password ($username, $password1, $password2) {
-
- $dbh = libglue_param(libglue_param('dbh_name'));
- if($password1 !== $password2) return 0;
-
- $sql = "UPDATE user SET password=PASSWORD('$password1') WHERE username='$username' LIMIT 1";
- $db_result = mysql_query($sql, $dbh);
- return ($db_result)?1:0;
-} // set_user_password()
-
-?>
diff --git a/modules/lib.php b/modules/lib.php
index b90a6c4f..e51b8e4a 100644
--- a/modules/lib.php
+++ b/modules/lib.php
@@ -9,55 +9,6 @@
*/
-/*
- * show_album_pulldown()
- * OLD FUNCTION!! use show_album_select($name,$selected)
- */
-
-function show_album_pulldown ($album) {
-
- global $settings;
- $dbh = dbh();
-
- $sql = "SELECT id,name FROM album ORDER BY name";
- $db_result = mysql_query($sql, $dbh);
-
- echo "\n<select name=\"album\">\n";
-
- while ( $r = mysql_fetch_row($db_result) ) {
- // $r[0] = id, $r[1] = name
- if ( $album == $r[0] ) {
- echo "\t <option value=\"${r[0]}\" selected=\"selected\">".htmlspecialchars($r[1])."</option>\n";
- }
- else {
- echo "\t <option value=\"${r[0]}\">".htmlspecialchars($r[1])."</option>\n";
- }
- }//while
-
- echo "\n</select>\n";
-} // show_album_pulldown()
-
-
-/*
- * delete_user_stats()
- *
- * just delete stats for specific users or all of them
- *
- */
-
-function delete_user_stats ($user) {
-
- $dbh = dbh();
-
- if ( $user == 'all' ) {
- $sql = "DELETE FROM object_count";
- }
- else {
- $sql = "DELETE FROM object_count WHERE userid = '$user'";
- }
- $db_result = mysql_query($sql, $dbh);
-} // delete_user_stats()
-
/*********************************************************/
/* Functions for getting songs given artist, album or id */
@@ -90,54 +41,6 @@ function get_songs_from_album ($album) {
}
-function get_song_ids_from_album ($album) {
-
- $dbh = dbh();
-
- $song_ids = array();
-
- $query = "SELECT id FROM song" .
- " WHERE album = '$album'" .
- " ORDER BY track, title";
-
- $db_result = mysql_query($query, $dbh);
-
- while ( $r = mysql_fetch_object($db_result) ) {
- $song_ids[] = $r->id;
- }
-
- return $song_ids;
-
-}
-
-
-/*
- * get_song_ids_from_artist_and_album();
- *
- * Get all of the songs that are from this album and artist
- *
- */
-function get_song_ids_from_artist_and_album ($artist, $album) {
-
- global $settings;
- $dbh = dbh();
-
- $sql = "SELECT id FROM song" .
- " WHERE artist = '$artist'" .
- " AND album = '$album'" .
- " ORDER BY track, title";
- $db_result = mysql_query($sql, $dbh);
-
- $song_ids = array();
-
- while ( $r = mysql_fetch_object($db_result) ) {
- $song_ids[] = $r->id;
- }
-
- return $song_ids;
-}
-
-
// Used by playlist functions when you have an array of something of type
// and you want to extract the songs from it whether type is artists or albums
function get_songs_from_type ($type, $results, $artist_id = 0) {
@@ -232,19 +135,6 @@ function get_artist_info ($artist_id) {
}
-function get_artist_from_album ($album_id) {
-
- global $settings;
- $dbh = dbh();
-
- $query = "SELECT DISTINCT artist.id, artist.name FROM artist,song" .
- " WHERE song.album = '$album_id' AND song.artist = artist.id";
- $db_result = mysql_query($query, $dbh);
- $r = mysql_fetch_object($db_result);
- return $r;
-}
-
-
function get_album_name ($album, $dbh = 0) {
$album = new Album($album);
diff --git a/modules/plugins/Lastfm.plugin.php b/modules/plugins/Lastfm.plugin.php
new file mode 100644
index 00000000..cb833bea
--- /dev/null
+++ b/modules/plugins/Lastfm.plugin.php
@@ -0,0 +1,77 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2006 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.
+
+*/
+
+class AmpacheLastfm {
+
+ var $name ='Last.FM';
+ var $description ='Records your played songs to your Last.FM Account';
+ var $url ='';
+ var $version ='000001';
+ var $min_ampache ='333001';
+ var $max_ampache ='333005';
+
+ /**
+ * Constructor
+ * This function does nothing...
+ */
+ function PluginLastfm() {
+
+ return true;
+
+ } // PluginLastfm
+
+ /**
+ * install
+ * This is a required plugin function it inserts the required preferences
+ * into Ampache
+ */
+ function install() {
+
+ /* We need to insert the new preferences */
+ $sql = "INSERT INTO preferences (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
+ "VALUES ('lastfm_user',' ','Last.FM Username','25','string','options')";
+ $db_results = mysql_query($sql,dbh());
+
+ $sql = "INSERT INTO preferences (`name`,`value`,`description`,`level`,`type`,`catagory`) " .
+ "VALUES ('lastfm_pass',' ','Last.FM Password','25','string','options')";
+ $db_results = mysql_query($sql,dbh());
+
+ fix_all_users_prefs();
+
+ } // install
+
+ /**
+ * uninstall
+ * This is a required plugin function it removes the required preferences from
+ * the database returning it to its origional form
+ */
+ function uninstall() {
+
+ /* We need to remove the preivously added preferences */
+ $sql = "DELETE FROM preferences WHERE name='lastfm_pass' OR name='lastfm_user'";
+ $db_results = mysql_query($sql,dbh());
+
+ fix_all_users_prefs();
+
+ } // uninstall
+
+} // end AmpacheLastfm
+?>
diff --git a/server/ajax.server.php b/server/ajax.server.php
index b3059e33..9b399d60 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -83,14 +83,8 @@ switch ($action) {
$pref_id = get_preference_id('play_type');
$GLOBALS['user']->update_preference($pref_id,$_GET['type']);
- /* Now Replace the text as you should */
- $ajax_url = conf('ajax_url');
- $required_info = conf('ajax_info');
- ${$_GET['type']} = 'id="pt_active"';
- ob_start();
- require_once(conf('prefix') . '/templates/show_localplay_switch.inc.php');
- $results['play_type'] = ob_get_contents();
- ob_end_clean();
+ /* Uses a drop down, no need to replace text */
+ $results['play_type'] = '';
$xml_doc = xml_from_array($results);
echo $xml_doc;
break;
diff --git a/templates/show_localplay_switch.inc.php b/templates/show_localplay_switch.inc.php
deleted file mode 100644
index a0ca8cd1..00000000
--- a/templates/show_localplay_switch.inc.php
+++ /dev/null
@@ -1,6 +0,0 @@
-<span <?php echo $stream; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=change_play_type&amp;type=stream<?php echo $required_info; ?>');return true;">
- <?php echo _('Stream') ?>
-</span><br /><br />
-<span <?php echo $localplay; ?> onclick="ajaxPut('<?php echo $ajax_url; ?>?action=change_play_type&amp;type=localplay<?php echo $required_info; ?>');return true;">
- <?php echo _('Localplay'); ?>
-</span>
diff --git a/templates/show_modules.inc.php b/templates/show_modules.inc.php
index 5f735b61..268393cc 100644
--- a/templates/show_modules.inc.php
+++ b/templates/show_modules.inc.php
@@ -27,10 +27,14 @@
*/
/* Get Localplay Modules */
-$localplay_modules = get_localplay_controllers('disabled');
+$localplay_modules = get_localplay_controllers('disabled');
+/* Get Plugins */
+$plugins = get_plugins();
$web_path = conf('web_path');
?>
-<?php show_box_top(_('Modules')); ?>
+
+<!-- Localplay Modules -->
+<?php show_box_top(_('Localplay Modules')); ?>
<table class="border" border="0" cellspacing="0">
<tr class="table-header">
<th><?php echo _('Module Name'); ?></th>
@@ -58,3 +62,38 @@ foreach ($localplay_modules as $module) {
<?php } ?>
</table>
<?php show_box_bottom(); ?>
+
+
+<!-- Plugins -->
+<?php show_box_top(_('Available Plugins')); ?>
+<table>
+<tr class="table-header">
+ <td><?php echo _('Name'); ?></td>
+ <td><?php echo _('Description'); ?></td>
+ <td><?php echo _('Version'); ?></td>
+ <td><?php echo _('Action'); ?></td>
+</tr>
+<?php
+foreach ($plugins as $key=>$plugin) {
+ if (!$plugin->is_installed()) {
+ $action = "<a href=\"" . $web_path . "/admin/modules.php?action=install_plugin&amp;plugin=" . scrub_out($key) . "\">" .
+ _('Activate') . "</a>";
+ }
+ else {
+ $action = "<a href=\"" . $web_path . "/admin/modules.php?action=confirm_uninstall_plugin&amp;plugin=" . scrub_out($key) . "\">" .
+ _('Deactivate') . "</a>";
+ }
+?>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo scrub_out($plugin->_plugin->name); ?></td>
+ <td><?php echo scrub_out($plugin->_plugin->description); ?></td>
+ <td><?php echo scrub_out($plugin->_plugin->version); ?></td>
+ <td><?php echo $action; ?></td>
+</tr>
+<?php } if (!count($plugins)) { ?>
+<tr class="<?php echo flip_class(); ?>">
+ <td colspan="4"><span class="error"><?php echo _('No Records Found'); ?></span></td>
+</tr>
+<?php } ?>
+</table>
+<?php show_box_bottom(); ?>
diff --git a/templates/show_playtype_switch.inc.php b/templates/show_playtype_switch.inc.php
new file mode 100644
index 00000000..47248dcf
--- /dev/null
+++ b/templates/show_playtype_switch.inc.php
@@ -0,0 +1,16 @@
+<?php
+$name = "is_" . $GLOBALS['user']->prefs['play_type'];
+${$name} = 'selected="selected" ';
+?>
+<select style="font-size:0.9em;" name="type">
+ <?php if (conf('allow_stream_playback')) { ?>
+ <option onclick="ajaxPut('<?php echo $ajax_url; ?>?action=change_play_type&amp;type=stream<?php echo $required_info; ?>');return true;" <?php echo $is_stream; ?>><?php echo _('Stream'); ?></option>
+ <?php } if (conf('allow_localplay_playback')) { ?>
+ <option onclick="ajaxPut('<?php echo $ajax_url; ?>?action=change_play_type&amp;type=localplay<?php echo $required_info; ?>');return true;" <?php echo $is_localplay; ?>><?php echo _('Localplay'); ?></option>
+ <?php } if (conf('allow_downsample_playback')) { ?>
+ <option onclick="ajaxPut('<?php echo $ajax_url; ?>?action=change_play_type&amp;type=downsample<?php echo $required_info; ?>');return true;" <?php echo $is_downsample; ?>><?php echo _('Downsample'); ?></option>
+ <?php } if (conf('allow_democratic_playback')) { ?>
+ <option onclick="ajaxPut('<?php echo $ajax_url; ?>?action=change_play_type&amp;type=democratic<?php echo $required_info; ?>');return true;" <?php echo $is_democratic; ?>><?php echo _('Democratic'); ?></option>
+ <?php } ?>
+ <option onclick="ajaxPut('<?php echo $ajax_url; ?>?action=change_play_type&amp;type=xspf_player<?php echo $required_info; ?>');return true;" <?php echo $is_xspf_player; ?>><?php echo _('XSPF Player'); ?></option>
+</select>
diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php
index 0595dc7e..03b6392f 100644
--- a/templates/sidebar.inc.php
+++ b/templates/sidebar.inc.php
@@ -184,18 +184,16 @@ $web_path = conf('web_path');
<?php if ($GLOBALS['theme']['orientation'] != 'horizontal') { ?>
<li>
<?php require_once(conf('prefix') . '/templates/show_localplay_control.inc.php'); ?>
- <br />
- <?php $type = conf('play_type'); ${$type} = 'id="pt_active"'; ?>
+ </li>
+<?php } // if horizontal orientation ?>
+<?php } // if localplay access ?>
+ <li>
<?php
$required_info = conf('ajax_info');
$ajax_url = conf('ajax_url');
?>
- <span class="text-action" style="cursor:pointer;" id="play_type">
- <?php require_once(conf('prefix') . '/templates/show_localplay_switch.inc.php'); ?>
- </span>
+ <?php require_once(conf('prefix') . '/templates/show_playtype_switch.inc.php'); ?>
</li>
-<?php } // if horizontal orientation ?>
-<?php } // if localplay access ?>
<?php if ($GLOBALS['user']->prefs['play_type'] == 'democratic') { ?>
<li>
<a href="<?php echo $web_path; ?>/tv.php"><?php echo _('Democratic View'); ?></a>
diff --git a/templates/song_edit.inc b/templates/song_edit.inc
index cc93c7a5..7eac7f90 100644
--- a/templates/song_edit.inc
+++ b/templates/song_edit.inc
@@ -41,7 +41,7 @@ $target = conf('web_path').'/admin/flags.php';
</tr>
<tr>
<td>Album:</td>
- <td><?php show_album_pulldown($song->album); ?></td>
+ <td><?php show_album_select('album',$song->album); ?></td>
<td>or <input type="text" name="new_album" size="30" value=""></input></td>
</tr>
<tr>