<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2011 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";
}
}
- public function __call($method, $args)
- {
- return parent::__call($method, $args);
+ /**
+ * Replace email in all lists where user has subscribe
+ * @param $old_email old email address used in mailing lits
+ * @param $new_email new email to use in place of the old one
+ * @return number of mailing lists changed
+ */
+ public function replace_email_in_all($old_email, $new_email) {
+ $all_lists = $this->get_lists($old_email);
+ if (!$all_lists) {
+ return 0;
+ }
+ $changed_lists = 0;
+ foreach ($all_lists as $list) {
+ if ($list->sub) {
+ $this->replace_email($list->list, $old_email, $new_email);
+ $changed_lists++;
+ }
+ }
+ return $changed_lists;
}
}