diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-10-10 06:08:33 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-10-10 06:08:33 +0000 |
commit | 32349846fbd66e4ebc44e63d37fbcd8cff5a8a73 (patch) | |
tree | 6aa1acd81fcf798150ba2c702116aa5f4dcde63b | |
parent | 8045c0121ca3e22af2945faa072c5de4b329d7d8 (diff) | |
download | ampache-32349846fbd66e4ebc44e63d37fbcd8cff5a8a73.tar.gz ampache-32349846fbd66e4ebc44e63d37fbcd8cff5a8a73.tar.bz2 ampache-32349846fbd66e4ebc44e63d37fbcd8cff5a8a73.zip |
fixed two MPD issues, can now disable localplay modules, added check for PHP5
-rw-r--r-- | admin/modules.php | 15 | ||||
-rwxr-xr-x | docs/CHANGELOG | 4 | ||||
-rw-r--r-- | lib/class/localplay.class.php | 19 | ||||
-rw-r--r-- | lib/init.php | 6 | ||||
-rw-r--r-- | modules/localplay/mpd.controller.php | 14 | ||||
-rw-r--r-- | modules/mpd/mpd.class.php | 22 | ||||
-rw-r--r-- | templates/sidebar_localplay.inc.php | 4 |
7 files changed, 65 insertions, 19 deletions
diff --git a/admin/modules.php b/admin/modules.php index 42f82ef5..baeb1748 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -44,10 +44,23 @@ switch ($_REQUEST['action']) { header("Location:" . Config::get('web_path') . '/admin/modules.php?action=show_localplay'); break; case 'confirm_uninstall_localplay': - + $type = scrub_in($_REQUEST['type']); + $url = Config::get('web_path') . '/admin/modules.php?action=uninstall_localplay&type=' . $type; + $title = _('Are you sure you want to remove this plugin?'); + $body = ''; + show_confirmation($title,$body,$url); break; case 'uninstall_localplay': + $type = scrub_in($_REQUEST['type']); + $localplay = new Localplay($type); + $localplay->uninstall(); + + /* Show Confirmation */ + $url = Config::get('web_path') . '/admin/modules.php?action=show_localplay'; + $title = _('Plugin Deactivated'); + $body = ''; + show_confirmation($title,$body,$url); break; case 'install_plugin': /* Verify that this plugin exists */ diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 70ae18bb..2ca9a0f0 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,10 @@ -------------------------------------------------------------------------- v.3.4-Alpha3 + - Fixed an issue where MPD was clearing all but last song in submit + if its initial state was not play + - Added check for PHP5 to prevent ugly errors if missing + - Fixed issue with NULL localplay controller causing fatal error - Fixed the Localplay Controls - Fixed Gathering album art to only gather for changed albums - Fixed display of catalog to correctly show catalog stats diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 2b0d6b12..6e01bfe0 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -218,6 +218,25 @@ class Localplay { } // install /** + * uninstall + * This runs the uninstall for the localplay controller we've + * currently pimped out + */ + public function uninstall() { + + // Run the players uninstaller + $this->_player->uninstall(); + + // If its our current player, reset player to nothing + if ($GLOBALS['user']->prefs['localplay_controller'] == $this->type) { + Preference::update('localplay_controller',$GLOBALS['user']->id,''); + } + + return true; + + } // uninstall + + /** * connect * This function attempts to connect to the localplay * player that we are using diff --git a/lib/init.php b/lib/init.php index 2f76a005..bf6c69c4 100644 --- a/lib/init.php +++ b/lib/init.php @@ -27,6 +27,12 @@ // fixes some CSS issues ob_start(); +// Do a check for PHP5 because nothing will work without it +if (strcmp('5.0.0',phpversion()) > 0) { + echo "ERROR: Ampache requires PHP5"; + exit; +} + // Set the Error level manualy... I'm to lazy to fix notices error_reporting(E_ALL ^ E_NOTICE); diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index 4b3c953f..117c4c33 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -247,10 +247,13 @@ class AmpacheMpd extends localplay_controller { * functions to generate the URL it needs */ public function add($object) { - - if (is_null($this->_mpd->ClearPLIfStopped())) { - debug_event('mpd_add', 'Error: Unable to clear the MPD playlist ' . $this->_mpd->errStr,'1'); - } + + // If we haven't added anything then check to see if we should clear + if ($this->_add_count < '1') { + if (is_null($this->_mpd->ClearPLIfStopped())) { + debug_event('mpd_add', 'Error: Unable to clear the MPD playlist ' . $this->_mpd->errStr,'1'); + } + } // edn if no add count $url = $this->get_url($object); @@ -258,6 +261,9 @@ class AmpacheMpd extends localplay_controller { debug_event('mpd_add',"Error: Unable to add $url to MPD " . $this->_mpd->errStr,'1'); return false; } + else { + $this->_add_count++; + } return true; diff --git a/modules/mpd/mpd.class.php b/modules/mpd/mpd.class.php index 52ace825..529465fa 100644 --- a/modules/mpd/mpd.class.php +++ b/modules/mpd/mpd.class.php @@ -107,7 +107,6 @@ class mpd { // Misc Other Vars var $mpd_class_version = "1.2"; - var $debugging = FALSE; // Set to TRUE to turn extended debugging on. var $errStr = ""; // Used for maintaining information about the last error message var $command_queue; // The list of commands for bulk command sending @@ -118,7 +117,7 @@ class mpd { * * Builds the MPD object, connects to the server, and refreshes all local object properties. */ - function mpd($srv,$port,$pwd = NULL) { + public function __construct($srv,$port,$pwd = NULL) { $this->host = $srv; $this->port = $port; $this->password = $pwd; @@ -162,9 +161,8 @@ class mpd { * NOTE: This is called automatically upon object instantiation; you should not need to call this directly. */ public function Connect() { - if ( $this->debugging ) echo "mpd->Connect() / host: ".$this->host.", port: ".$this->port."\n"; + debug_event('MPD',"mpd->Connect() / host: ".$this->host.", port: ".$this->port,'5'); $this->mpd_sock = fsockopen($this->host,$this->port,$errNo,$errStr,6); - /* Vollmerize this bizatch, if we've got php4.3+ we should * have these functions and we need them */ @@ -182,7 +180,8 @@ class mpd { if (!$this->mpd_sock) { $this->errStr = "Socket Error: $errStr ($errNo)"; return NULL; - } else { + } + else { while(!feof($this->mpd_sock) && !$status['timed_out']) { $response = fgets($this->mpd_sock,1024); if (function_exists('socket_get_status')) { @@ -213,7 +212,7 @@ class mpd { * use (see MPD_CMD_* constant definitions above). */ function SendCommand($cmdStr,$arg1 = "",$arg2 = "") { - if ( $this->debugging ) echo "mpd->SendCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2."\n"; + debug_event('MPD',"mpd->SendCommand() / cmd: ".$cmdStr.", args: ".$arg1." ".$arg2,'5'); if ( ! $this->connected ) { echo "mpd->SendCommand() / Error: Not connected\n"; } else { @@ -250,7 +249,7 @@ class mpd { // Build the response string $respStr .= $response; } - if ( $this->debugging ) echo "mpd->SendCommand() / response: '".$respStr."'\n"; + debug_event('MPD',"mpd->SendCommand() / response: '".$respStr,'5'); } return $respStr; } @@ -875,7 +874,6 @@ class mpd { if ( ($this->state == MPD_STATE_PLAYING) || ($this->state == MPD_STATE_PAUSED) ) { list ($this->current_track_position, $this->current_track_length ) = split(":",$status['time']); } else { -// $this->current_track_id = -1; $this->current_track_position = -1; $this->current_track_length = -1; } @@ -968,7 +966,7 @@ class mpd { /* GetPlaylist() * * Retrieves the playlist from the server and tosses it into a multidimensional array. - * + * * NOTE: This function really should not be used. Instead, use $this->playlist. The function * will most likely be deprecated in future releases. */ @@ -986,13 +984,13 @@ class mpd { */ function ClearPLIfStopped() { - if ( $this->debugging ) echo "mpd->ClearPLIfStopped()\n"; + debug_event('MPD',"Running: mpd->ClearPLIfStopped()",'5'); $this->RefreshInfo(); if ($resp = ($this->state == MPD_STATE_STOPPED)) { $this->PLClear(); + return true; } - if ( $this->debugging ) echo "mpd->ClearPLIfStopped() / return\n"; - return $resp; + return false; } // ClearPLIfStopped diff --git a/templates/sidebar_localplay.inc.php b/templates/sidebar_localplay.inc.php index eb24c2e4..42eda299 100644 --- a/templates/sidebar_localplay.inc.php +++ b/templates/sidebar_localplay.inc.php @@ -1,11 +1,11 @@ +<ul class="sb2" id="sb_localplay"> +<?php if (Config::get('allow_localplay_playback') AND $GLOBALS['user']->prefs['localplay_controller']) { ?> <?php // Little bit of work to be done here $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); $current_instance = $localplay->current_instance(); $class = $current_instance ? '' : ' class="active_instance"'; ?> -<ul class="sb2" id="sb_localplay"> -<?php if (Config::get('allow_localplay_playback')) { ?> <?php if ($GLOBALS['user']->has_access('50')) { ?> <li><h4><?php echo _('Localplay'); ?></h4> <ul class="sb3" id="sb_localplay_info"> |