Add a special abstract method PlUser::password(): we want to be able to
[platal.git] / classes / mmlist.php
index b70fcbf..9dadd09 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2007 Polytechnique.org                              *
+ *  Copyright (C) 2003-2008 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
 
 class MMList extends XmlrpcClient
 {
-    public function __construct($uid, $pass, $fqdn = null)
+    public function __construct($user, $pass = null, $fqdn = null)
     {
         global $globals;
+        if ($user instanceof PlUser) {
+            $fqdn = $pass;
+            $uid  = $user->id();
+            $pass = $user->password();
+        } else {
+            $uid = $user;
+        }
 
         $dom = is_null($fqdn) ? $globals->mail->domain : $fqdn;
         $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom";
         parent::__construct($url);
         if ($globals->debug & DEBUG_BT) {
             $this->bt = new PlBacktrace('MMList');
-        }   
-    }
-
-    public function __call($method, $args)
-    {
-        return parent::__call($method, $args);
+        }
     }
 }