[enh] option pour ajouter les contacts dans le carnet du plugin "automatic_addressbook"

master
Vincent Adolphe 2019-05-17 11:30:51 +02:00 commité par root
Parent efe64f2c79
révision f947ad24dd
2 fichiers modifiés avec 13 ajouts et 3 suppressions

Voir le fichier

@ -192,7 +192,7 @@ class rcmail_contacts_utils
* @param string $user User name
* @param string $host Optional user host
*/
public function __construct($user, $host = null)
public function __construct($user, $host = null, $collected_contacts = false)
{
$this->db = rcmail_utils::db();
@ -200,7 +200,14 @@ class rcmail_contacts_utils
$this->username = $user;
$this->user_id = $this->get_user_id($this->username, $this->host);
$this->contacts = new rcube_contacts($this->db, $this->user_id);
if ($collected_contacts) {
log_msg('INFO', 'working on collected_contacts - if script stop here you probably need to install automatic_addressbook plugin');
require_once INSTALL_PATH . 'plugins/automatic_addressbook/automatic_addressbook_backend.php';
$this->contacts = new automatic_addressbook_backend($this->db, $this->user_id);
} else {
log_msg('INFO', 'working on contacts');
$this->contacts = new rcube_contacts($this->db, $this->user_id);
}
}
/**

Voir le fichier

@ -35,6 +35,8 @@ function print_usage()
echo " -d, --debug Enable debug mode\n";
echo " -c, --create_user Create user account if needed\n";
echo " -b, --batch Do not prompt for user, proceed anyway\n";
echo " -a, --aa_contacts Use automatic_addressbook instead of std\n";
echo " contacts. Need plugin automatic_adressbook\n";
}
// get arguments
@ -47,6 +49,7 @@ $args = rcube_utils::get_opt(array(
'h' => 'help:bool',
'c' => 'create_user:bool',
'b' => 'batch:bool',
'a' => 'aa_contacts:bool',
));
if ('help' == $_SERVER['argv'][1] || $args['help']) {
@ -99,7 +102,7 @@ if (!is_object($rc_user))
}
}
$contacts = new rcmail_contacts_utils($username, $args['host']);
$contacts = new rcmail_contacts_utils($username, $args['host'], $args['aa_contacts']);
$contacts->import($in, $args['replace'], !$args['batch']);
if (!empty($args['input'])) {