summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 00:39:54 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 00:39:54 +0000
commitbf6e9f88d8fbd520cf7373fa58ad3c45c76904dd (patch)
tree29618126b20adc850be5f94d3014d9be78bb7f37 /lib
parent00bcfdca5f523093770321c22f8c429f3d318af8 (diff)
downloadampache-bf6e9f88d8fbd520cf7373fa58ad3c45c76904dd.tar.gz
ampache-bf6e9f88d8fbd520cf7373fa58ad3c45c76904dd.tar.bz2
ampache-bf6e9f88d8fbd520cf7373fa58ad3c45c76904dd.zip
- Added modules section to sidebar, conforming to new layout from r1127
- Re-enabled plugins, added openstrands plugin
Diffstat (limited to 'lib')
-rw-r--r--lib/class/plugin.class.php76
-rw-r--r--lib/class/user.class.php19
-rw-r--r--lib/general.lib.php37
-rw-r--r--lib/preferences.php21
4 files changed, 75 insertions, 78 deletions
diff --git a/lib/class/plugin.class.php b/lib/class/plugin.class.php
index 5a058ac5..e5b9c485 100644
--- a/lib/class/plugin.class.php
+++ b/lib/class/plugin.class.php
@@ -22,17 +22,17 @@
class Plugin {
/* Base Variables */
- var $name;
+ public $name;
/* constructed objects */
- var $_plugin;
+ public $_plugin;
/**
* Constructor
* This constructor loads the Plugin config file which defines how to
* install/uninstall the plugin from Ampache's database
*/
- function Plugin($name) {
+ public function __construct($name) {
/* Load the plugin */
if (!$this->_get_info($name)) {
@@ -41,7 +41,7 @@ class Plugin {
return true;
- } // Plugin
+ } // Constructor
/**
@@ -52,7 +52,7 @@ class Plugin {
function _get_info($name) {
/* Require the file we want */
- require_once(conf('prefix') . '/modules/plugins/' . $name . '.plugin.php');
+ require_once Config::get('prefix') . '/modules/plugins/' . $name . '.plugin.php';
$plugin_name = "Ampache$name";
@@ -67,6 +67,40 @@ class Plugin {
} // _get_info
/**
+ * get_plugins
+ * This returns an array of plugin names
+ */
+ public static function get_plugins() {
+
+ $results = array();
+
+ // Open up the plugin dir
+ $handle = opendir(Config::get('prefix') . '/modules/plugins');
+
+ if (!is_resource($handle)) {
+ debug_event('Plugins','Unable to read plugins directory','1');
+ }
+
+ // Recurse the directory
+ while ($file = readdir($handle)) {
+ // Ignore non-plugin files
+ if (substr($file,-10,10) != 'plugin.php') { continue; }
+ if (is_dir($file)) { continue; }
+
+ // It's a plugin record it
+ $plugin_name = basename($file,'.plugin.php');
+ $results[$plugin_name] = $plugin_name;
+
+ } // end while
+
+ // Little stupid but hey
+ ksort($results);
+
+ return $results;
+
+ } // get_plugins
+
+ /**
* is_valid
* This checks to make sure the plugin has the required functions and
* settings, Ampache requires Name/Description/Version (Int) and a
@@ -157,12 +191,12 @@ class Plugin {
*/
function get_plugin_version() {
- $name = sql_escape('Plugin_' . $this->_plugin->name);
+ $name = Dba::escape('Plugin_' . $this->_plugin->name);
- $sql = "SELECT * FROM update_info WHERE `key`='$name'";
- $db_results = mysql_query($sql,dbh());
+ $sql = "SELECT * FROM `update_info` WHERE `key`='$name'";
+ $db_results = Dba::query($sql);
- $results = mysql_fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
return $results['value'];
@@ -174,10 +208,10 @@ class Plugin {
*/
function get_ampache_db_version() {
- $sql = "SELECT * FROM update_info WHERE `key`='db_version'";
- $db_results = mysql_query($sql,dbh());
+ $sql = "SELECT * FROM `update_info` WHERE `key`='db_version'";
+ $db_results = Dba::query($sql);
- $results = mysql_fetch_assoc($db_results);
+ $results = Dba::fetch_assoc($db_results);
return $results['value'];
@@ -187,13 +221,13 @@ class Plugin {
* set_plugin_version
* This sets the plugin version in the update_info table
*/
- function set_plugin_version($version) {
+ public function set_plugin_version($version) {
- $name = sql_escape('Plugin_' . $this->_plugin->name);
- $version = sql_escape($version);
+ $name = Dba::escape('Plugin_' . $this->_plugin->name);
+ $version = Dba::escape($version);
- $sql = "INSERT INTO update_info SET `key`='$name', value='$version'";
- $db_results = mysql_query($sql,dbh());
+ $sql = "INSERT INTO `update_info` SET `key`='$name', `value`='$version'";
+ $db_results = Dba::query($sql);
return true;
@@ -203,12 +237,12 @@ class Plugin {
* remove_plugin_version
* This removes the version row from the db done on uninstall
*/
- function remove_plugin_version() {
+ public function remove_plugin_version() {
- $name = sql_escape('Plugin_' . $this->_plugin->name);
+ $name = Dba::escape('Plugin_' . $this->_plugin->name);
- $sql = "DELETE FROM update_info WHERE `key`='$name'";
- $db_results = mysql_query($sql,dbh());
+ $sql = "DELETE FROM `update_info` WHERE `key`='$name'";
+ $db_results = Dba::query($sql);
return true;
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 5867a4bb..fa498671 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -1102,6 +1102,25 @@ class User {
return true;
} // check_username
+
+ /**
+ * rebuild_all_preferences
+ * This rebuilds the user preferences for all installed users, called by the plugin functions
+ */
+ public static function rebuild_all_preferences() {
+
+ $sql = "SELECT * FROM `user`";
+ $db_results = Dba::query($sql);
+
+ User::fix_preferences('-1');
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ User::fix_preferences($row['id']);
+ }
+
+ return true;
+
+ } // rebuild_all_preferences
} //end user class
diff --git a/lib/general.lib.php b/lib/general.lib.php
index 3d60014f..5ce40831 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -739,43 +739,6 @@ function invert_boolean($value) {
} // invert_boolean
/**
- * 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
-
-/**
* unhtmlentities
* This is required to make thing work.. but holycrap is it ugly
*/
diff --git a/lib/preferences.php b/lib/preferences.php
index e956cef5..b35f3036 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -328,6 +328,7 @@ function create_preference_input($name,$value) {
echo "\t<option value=\"genre\">" . _('Related Genre') . "</option>";
echo "</select>\n";
break;
+ case 'mystrands_pass':
case 'lastfm_pass':
echo "<input type=\"password\" size=\"16\" name=\"$name\" value=\"******\" />";
break;
@@ -520,26 +521,6 @@ function update_preference_level($pref_id,$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
-
-/**
* fix_preferences
* This takes the preferences, explodes what needs to
* become an array and boolean everythings