Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.9.4

Bug #16387 channel-logout does not support logging out from a non-default channel
Submitted: 2009-06-29 14:21 UTC Modified: 2009-07-29 03:54 UTC
From: timj Assigned: timj
Status: Closed Package: PEAR (version 1.8.1)
PHP Version: 5.2.9 OS:
Roadmaps: 1.9.0    
Subscription  



Patch pear-bug-16387 Revisions
Revision 2009-06-29 14:21 UTC
Developer timj
 
Download patch

--- Command/Channels.php.orig	2009-06-29 14:11:46.000000000 +0100
+++ Command/Channels.php	2009-06-29 14:22:20.000000000 +0100
@@ -154,10 +154,11 @@
             'shortcut' => 'clo',
             'function' => 'doLogout',
             'options' => array(),
-            'doc' => '
-Logs out from the remote server.  This command does not actually
-connect to the remote server, it only deletes the stored username and
-password from your user configuration.',
+            'doc' => '<channel name>
+Logs out from a remote channel server.  If <channel name> is not supplied,
+the default channel is used. This command does not actually connect to the
+remote server, it only deletes the stored username and password from your user
+configuration.',
             ),
         );
 
@@ -862,17 +863,20 @@
     function doLogout($command, $options, $params)
     {
         $reg     = &$this->config->getRegistry();
-        $channel = $this->config->get('default_channel');
+        
+        // If a parameter is supplied, use that as the channel to log in to
+        $channel = isset($params[0]) ? $params[0] : $this->config->get('default_channel');
+        
         $chan    = $reg->getChannel($channel);
         if (PEAR::isError($chan)) {
             return $this->raiseError($chan);
         }
 
-        $server = $this->config->get('preferred_mirror');
+        $server = $this->config->get('preferred_mirror', null, $channel);
         $this->ui->outputData("Logging out from $server.", $command);
-        $this->config->remove('username');
-        $this->config->remove('password');
+        $this->config->remove('username', 'user', $channel);
+        $this->config->remove('password', 'user', $channel);
         $this->config->store();
         return true;
     }
-}
\ No newline at end of file
+}