summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-11-26 20:28:46 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-11-26 20:28:46 +0000
commit9c8be228a73a602ac3e91e30bf980dd1cc695a81 (patch)
tree46b3b2dc825f652410aba04f2d148b566e5b61e5 /modules
parenta41697ea25a58ea5db5ed46a251fb62364626b1b (diff)
downloadampache-9c8be228a73a602ac3e91e30bf980dd1cc695a81.tar.gz
ampache-9c8be228a73a602ac3e91e30bf980dd1cc695a81.tar.bz2
ampache-9c8be228a73a602ac3e91e30bf980dd1cc695a81.zip
playlist switcher, plugin interface and the shell of a lastfm plugin (need patch file)
Diffstat (limited to 'modules')
-rw-r--r--modules/admin.php239
-rw-r--r--modules/lib.php110
-rw-r--r--modules/plugins/Lastfm.plugin.php77
3 files changed, 77 insertions, 349 deletions
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
+?>