2012-09-18 17:09:48 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* eGroupWare - Wizard for Adressbook vCard import
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package addressbook
|
|
|
|
* @subpackage importexport
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Nathan Gray
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
2016-04-29 12:41:53 +02:00
|
|
|
use EGroupware\Api;
|
|
|
|
use EGroupware\Api\Acl;
|
|
|
|
|
2012-09-18 17:09:48 +02:00
|
|
|
class addressbook_wizard_import_vcard extends addressbook_import_vcard
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*/
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
$this->steps = array(
|
2012-10-01 19:59:44 +02:00
|
|
|
'wizard_step40' => lang('Choose charset'),
|
2012-09-18 17:09:48 +02:00
|
|
|
'wizard_step60' => lang('Choose owner of imported data'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-10-01 19:59:44 +02:00
|
|
|
function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
|
2016-04-29 12:41:53 +02:00
|
|
|
{
|
|
|
|
if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
|
|
|
|
// return from step40
|
|
|
|
if ($content['step'] == 'wizard_step40')
|
2012-10-01 19:59:44 +02:00
|
|
|
{
|
|
|
|
switch (array_search('pressed', $content['button']))
|
|
|
|
{
|
|
|
|
case 'next':
|
|
|
|
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
|
|
|
|
case 'previous' :
|
|
|
|
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
|
|
|
|
case 'finish':
|
|
|
|
return 'wizard_finish';
|
|
|
|
default :
|
|
|
|
return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// init step40
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$content['msg'] = $this->steps['wizard_step40'];
|
|
|
|
$content['step'] = 'wizard_step40';
|
|
|
|
if(!$content['charset'] && $content['plugin_options']['charset']) {
|
2016-04-29 12:41:53 +02:00
|
|
|
$content['charset'] = $content['plugin_options']['charset'];
|
|
|
|
}
|
|
|
|
$sel_options['charset'] = Api\Translation::get_installed_charsets()+
|
|
|
|
array(
|
|
|
|
'user' => lang('User preference'),
|
|
|
|
);
|
2012-10-01 19:59:44 +02:00
|
|
|
|
|
|
|
// Add in extra allowed charsets
|
2016-04-29 12:41:53 +02:00
|
|
|
$config = Api\Config::read('importexport');
|
|
|
|
$extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
|
|
|
|
if($extra_charsets)
|
|
|
|
{
|
|
|
|
$sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
|
|
|
|
}
|
2012-10-01 19:59:44 +02:00
|
|
|
|
|
|
|
$preserv = $content;
|
|
|
|
unset ($preserv['button']);
|
|
|
|
return 'addressbook.importexport_wizard_vcard_charset';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-18 17:09:48 +02:00
|
|
|
function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
|
|
|
|
{
|
|
|
|
if($this->debug) error_log(__METHOD__.print_r($content,true));
|
|
|
|
|
|
|
|
// return from step60
|
|
|
|
if ($content['step'] == 'wizard_step60')
|
|
|
|
{
|
|
|
|
switch (array_search('pressed', $content['button']))
|
|
|
|
{
|
|
|
|
case 'next':
|
|
|
|
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
|
|
|
|
case 'previous' :
|
|
|
|
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
|
|
|
|
case 'finish':
|
|
|
|
return 'wizard_finish';
|
|
|
|
default :
|
|
|
|
return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// init step60
|
|
|
|
else
|
|
|
|
{
|
2019-04-24 00:17:12 +02:00
|
|
|
$content['title'] = $this->steps['wizard_step60'];
|
2012-09-18 17:09:48 +02:00
|
|
|
$content['step'] = 'wizard_step60';
|
2022-02-24 16:58:32 +01:00
|
|
|
if (!array_key_exists('contact_owner', $content) && $content['plugin_options']) {
|
2012-09-18 17:09:48 +02:00
|
|
|
$content['contact_owner'] = $content['plugin_options']['contact_owner'];
|
|
|
|
}
|
2022-02-24 16:58:32 +01:00
|
|
|
if(!array_key_exists('change_owner', $content) && $content['plugin_options']) {
|
2012-09-18 17:09:48 +02:00
|
|
|
$content['change_owner'] = $content['plugin_options']['change_owner'];
|
|
|
|
}
|
|
|
|
|
2016-04-29 12:41:53 +02:00
|
|
|
$bocontacts = new Api\Contacts();
|
|
|
|
$sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD);
|
2012-09-18 17:09:48 +02:00
|
|
|
|
2019-04-24 00:17:12 +02:00
|
|
|
foreach(array('override_values') as $field)
|
|
|
|
{
|
2022-11-21 17:19:23 +01:00
|
|
|
if(!$content[$field] && is_array($content['plugin_options']) && array_key_exists($field, $content['plugin_options']))
|
2019-04-24 00:17:12 +02:00
|
|
|
{
|
|
|
|
$content[$field] = $content['plugin_options'][$field];
|
|
|
|
}
|
|
|
|
}
|
2012-09-18 17:09:48 +02:00
|
|
|
$preserv = $content;
|
|
|
|
unset ($preserv['button']);
|
|
|
|
return 'addressbook.importexport_wizard_vcard_chooseowner';
|
|
|
|
}
|
|
|
|
}
|
2022-02-24 16:58:32 +01:00
|
|
|
}
|