mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 12:39:25 +01:00
Formatting, removal of some function params that are not needed
This commit is contained in:
parent
64ce202c13
commit
17de668f88
@ -12,37 +12,26 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
$phpgw_info["flags"]["currentapp"] = "addressbook";
|
||||
$phpgw_info["flags"]["enable_contacts_class"] = True;
|
||||
$phpgw_info["flags"]["enable_browser_class"] = True;
|
||||
include("../header.inc.php");
|
||||
$phpgw_info['flags'] = array(
|
||||
'currentapp' => 'addressbook',
|
||||
'enable_contacts_class' => True,
|
||||
'enable_browser_class' => True
|
||||
);
|
||||
include('../header.inc.php');
|
||||
|
||||
//$sep = $phpgw_info["server"]["dir_separator"];
|
||||
$sep = SEP;
|
||||
|
||||
// Construct a default basedn for Contacts if using LDAP
|
||||
$tmpbasedn = split(",",$phpgw_info["server"]["ldap_context"]);
|
||||
array_shift($tmpbasedn);
|
||||
for ($i=0;$i<count($tmpbasedn);$i++) {
|
||||
if($i==0) {
|
||||
$basedn = $tmpbasedn[$i];
|
||||
} else {
|
||||
$basedn = $basedn.",".$tmpbasedn[$i];
|
||||
}
|
||||
}
|
||||
$context = $phpgw_info["server"]["ldap_contact_context"];
|
||||
|
||||
if (!$convert)
|
||||
{
|
||||
$t = new Template(PHPGW_APP_TPL);
|
||||
$t->set_file(array("import" => "import.tpl"));
|
||||
$t->set_file(array('import' => 'import.tpl'));
|
||||
|
||||
$dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."import");
|
||||
$i=0; $myfilearray="";
|
||||
$dir_handle=opendir($phpgw_info['server']['app_root'] . $sep . 'import');
|
||||
$i=0; $myfilearray='';
|
||||
while ($file = readdir($dir_handle))
|
||||
{
|
||||
//echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file)." -->";
|
||||
if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file) )
|
||||
if ((substr($file, 0, 1) != '.') && is_file($phpgw_info['server']['app_root'] . $sep . 'import' . $sep . $file) )
|
||||
{
|
||||
$myfilearray[$i] = $file;
|
||||
$i++;
|
||||
@ -53,46 +42,44 @@
|
||||
for ($i=0;$i<count($myfilearray);$i++)
|
||||
{
|
||||
$fname = ereg_replace('_',' ',$myfilearray[$i]);
|
||||
$conv .= '<OPTION VALUE="'.$myfilearray[$i].'">'.$fname.'</OPTION>';
|
||||
$conv .= '<OPTION VALUE="' . $myfilearray[$i].'">' . $fname . '</OPTION>';
|
||||
}
|
||||
|
||||
$t->set_var("lang_cancel",lang("Cancel"));
|
||||
$t->set_var("lang_cat",lang("Select Category"));
|
||||
$t->set_var("cancel_url",$phpgw->link("/addressbook/index.php"));
|
||||
$t->set_var("navbar_bg",$phpgw_info["theme"]["navbar_bg"]);
|
||||
$t->set_var("navbar_text",$phpgw_info["theme"]["navbar_text"]);
|
||||
$t->set_var("import_text",lang("Import from LDIF, CSV, or VCard"));
|
||||
$t->set_var("action_url",$phpgw->link("/addressbook/import.php"));
|
||||
$t->set_var("cat_link",cat_option($cat_id,True,False));
|
||||
$t->set_var("tsvfilename","");
|
||||
$t->set_var("conv",$conv);
|
||||
$t->set_var("debug",lang("Debug output in browser"));
|
||||
$t->set_var("filetype",lang("LDIF"));
|
||||
$t->set_var("basedn",$basedn);
|
||||
$t->set_var("context",$context);
|
||||
$t->set_var("download",lang("Submit"));
|
||||
$t->set_var("start",$start);
|
||||
$t->set_var("sort",$sort);
|
||||
$t->set_var("order",$order);
|
||||
$t->set_var("filter",$filter);
|
||||
$t->set_var("query",$query);
|
||||
$t->set_var("cat_id",$cat_id);
|
||||
$t->pparse("out","import");
|
||||
$t->set_var('lang_cancel',lang('Cancel'));
|
||||
$t->set_var('lang_cat',lang('Select Category'));
|
||||
$t->set_var('cancel_url',$phpgw->link('/addressbook/index.php'));
|
||||
$t->set_var('navbar_bg',$phpgw_info['theme']['navbar_bg']);
|
||||
$t->set_var('navbar_text',$phpgw_info['theme']['navbar_text']);
|
||||
$t->set_var('import_text',lang('Import from LDIF, CSV, or VCard'));
|
||||
$t->set_var('action_url',$phpgw->link('/addressbook/import.php'));
|
||||
$t->set_var('cat_link',cat_option($cat_id,True,False));
|
||||
$t->set_var('tsvfilename','');
|
||||
$t->set_var('conv',$conv);
|
||||
$t->set_var('debug',lang('Debug output in browser'));
|
||||
$t->set_var('filetype',lang('LDIF'));
|
||||
$t->set_var('download',lang('Submit'));
|
||||
$t->set_var('start',$start);
|
||||
$t->set_var('sort',$sort);
|
||||
$t->set_var('order',$order);
|
||||
$t->set_var('filter',$filter);
|
||||
$t->set_var('query',$query);
|
||||
$t->set_var('cat_id',$cat_id);
|
||||
$t->pparse('out','import');
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
else
|
||||
{
|
||||
include ($phpgw_info["server"]["app_root"].$sep."import".$sep.$conv_type);
|
||||
include ($phpgw_info['server']['app_root'] . $sep . 'import' . $sep . $conv_type);
|
||||
|
||||
if ($private=="") { $private="public"; }
|
||||
if ($private == '') { $private = 'public'; }
|
||||
$row=0;
|
||||
$buffer=array();
|
||||
$this = new import_conv;
|
||||
$buffer = $this->import_start_file($buffer,$basedn,$context);
|
||||
$fp=fopen($tsvfile,"r");
|
||||
$buffer = $this->import_start_file($buffer);
|
||||
$fp=fopen($tsvfile,'r');
|
||||
if ($this->type == 'csv')
|
||||
{
|
||||
while ($data = fgetcsv($fp,8000,","))
|
||||
while ($data = fgetcsv($fp,8000,','))
|
||||
{
|
||||
$num = count($data);
|
||||
$row++;
|
||||
@ -106,7 +93,7 @@
|
||||
for ($c=0; $c<$num; $c++ )
|
||||
{
|
||||
//Send name/value pairs along with the buffer
|
||||
if ($this->import[$header[$c]]!="" && $data[$c]!="")
|
||||
if ($this->import[$header[$c]] != '' && $data[$c] != '')
|
||||
{
|
||||
$buffer = $this->import_new_attrib($buffer, $this->import[$header[$c]],$data[$c]);
|
||||
}
|
||||
@ -155,7 +142,7 @@
|
||||
$value = $url. ':' . $value;
|
||||
}
|
||||
//echo '<br>'.$j.': '.$name.' => '.$value;
|
||||
if ($this->import[$name] != "" && $value != "")
|
||||
if ($this->import[$name] != '' && $value != '')
|
||||
{
|
||||
$buffer = $this->import_new_attrib($buffer, $this->import[$name],$value);
|
||||
}
|
||||
@ -200,9 +187,9 @@
|
||||
fclose($fp);
|
||||
$buffer = $this->import_end_file($buffer,$private,$cat_id);
|
||||
|
||||
if ($download == "")
|
||||
if ($download == '')
|
||||
{
|
||||
if($conv_type=="Debug LDAP" || $conv_type=="Debug SQL" )
|
||||
if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL' )
|
||||
{
|
||||
// filename, default application/octet-stream, length of file, default nocache True
|
||||
$phpgw->browser->content_header($tsvfilename,'',strlen($buffer));
|
||||
@ -211,7 +198,7 @@
|
||||
else
|
||||
{
|
||||
echo "<pre>$buffer</pre>";
|
||||
echo '<a href="'.$phpgw->link("/addressbook/index.php",
|
||||
echo '<a href="'.$phpgw->link('/addressbook/index.php',
|
||||
"sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id")
|
||||
. '">'.lang("OK").'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
@ -220,7 +207,7 @@
|
||||
else
|
||||
{
|
||||
echo "<pre>$buffer</pre>";
|
||||
echo '<a href="'.$phpgw->link("/addressbook/index.php",
|
||||
echo '<a href="'.$phpgw->link('/addressbook/index.php',
|
||||
"sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id")
|
||||
. '">'.lang("OK").'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
|
@ -10,7 +10,7 @@
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
// array('LastName' => 'FullName','FirstName' => '+, ');
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
@ -22,71 +22,79 @@
|
||||
var $type = 'ldif';
|
||||
|
||||
var $import = array(
|
||||
"title" => "title",
|
||||
"givenname" => "n_given",
|
||||
"sn" => "n_family",
|
||||
"cn" => "fn",
|
||||
"o" => "org_name",
|
||||
"ou" => "org_unit",
|
||||
"streetaddress" => "adr_one_street",
|
||||
"locality" => "adr_one_locality",
|
||||
"st" => "adr_one_region",
|
||||
"postalcode" => "adr_one_postalcode",
|
||||
"countryname" => "adr_one_countryname",
|
||||
"telephonenumber" => "tel_work",
|
||||
"homephone" => "tel_home",
|
||||
"facsimiletelephonenumber" => "tel_fax",
|
||||
"xmozillaanyphone" => "ophone",
|
||||
"cellphone" => "tel_cell",
|
||||
"description" => "note",
|
||||
"pagerphone" => "tel_pager",
|
||||
"mail" => "email",
|
||||
"homeurl" => "url",
|
||||
"xmozillauseconferenceserver" => "",
|
||||
"xmozillanickname" => "",
|
||||
"xmozillausehtmlmail" => "",
|
||||
"modifytimestamp" => "",
|
||||
"objectclass" => ""
|
||||
'title' => 'title',
|
||||
'givenname' => 'n_given',
|
||||
'sn' => 'n_family',
|
||||
'cn' => 'fn',
|
||||
'o' => 'org_name',
|
||||
'ou' => 'org_unit',
|
||||
'streetaddress' => 'adr_one_street',
|
||||
'locality' => 'adr_one_locality',
|
||||
'st' => 'adr_one_region',
|
||||
'postalcode' => 'adr_one_postalcode',
|
||||
'countryname' => 'adr_one_countryname',
|
||||
'telephonenumber' => 'tel_work',
|
||||
'homephone' => 'tel_home',
|
||||
'facsimiletelephonenumber' => 'tel_fax',
|
||||
'xmozillaanyphone' => 'ophone',
|
||||
'cellphone' => 'tel_cell',
|
||||
'description' => 'note',
|
||||
'pagerphone' => 'tel_pager',
|
||||
'mail' => 'email',
|
||||
'homeurl' => 'url',
|
||||
'xmozillauseconferenceserver' => '',
|
||||
'xmozillanickname' => '',
|
||||
'xmozillausehtmlmail' => '',
|
||||
'modifytimestamp' => '',
|
||||
'objectclass' => ''
|
||||
);
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
function import_start_file($buffer)
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
function import_start_record($buffer)
|
||||
{
|
||||
$top=array();
|
||||
++$this->id;
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
function import_new_attrib($buffer,$name,$value)
|
||||
{
|
||||
// chop leading space from value
|
||||
$value = trim($value);
|
||||
$value = str_replace("\r","",$value);
|
||||
$value = str_replace('\r','',$value);
|
||||
//echo '<br>'.$name.' => '.$value;
|
||||
$this->currentrecord += array($name => $value);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer) {
|
||||
function import_end_record($buffer)
|
||||
{
|
||||
global $phpgw_info;
|
||||
$buffer[$this->id]="";
|
||||
while ( list($name, $value) = each($this->currentrecord)) {
|
||||
$buffer[$this->id]='';
|
||||
while ( list($name, $value) = each($this->currentrecord))
|
||||
{
|
||||
$buffer[$this->id][$name] = $value;
|
||||
//echo '<br>'.$this->id.': '.$name.' => '.$value;
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer,$access="private",$cat_id=0) {
|
||||
function import_end_file($buffer,$access='private',$cat_id=0)
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
$contacts = CreateObject("phpgwapi.contacts");
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
//echo '<br>';
|
||||
for ($i=1;$i<=count($buffer);$i++) {
|
||||
while ( list($name,$value) = @each($buffer[$i]) ) {
|
||||
for ($i=1;$i<=count($buffer);$i++)
|
||||
{
|
||||
while ( list($name,$value) = @each($buffer[$i]) )
|
||||
{
|
||||
//echo '<br>'.$i.': '.$name.' => '.$value;
|
||||
$entry[$i][$name] = $value;
|
||||
}
|
||||
@ -95,10 +103,10 @@
|
||||
$entry[$i]['adr_one_type'] = 'intl';
|
||||
$entry[$i]['adr_two_type'] = 'intl';
|
||||
//echo '<br>';
|
||||
$contacts->add($phpgw_info["user"]["account_id"],$entry[$i],$access,$cat_id);
|
||||
$contacts->add($phpgw_info['user']['account_id'],$entry[$i],$access,$cat_id);
|
||||
}
|
||||
$num = $i - 1;
|
||||
return "Successfully imported $num records into your addressbook.";
|
||||
return lang('Successfully imported x records into your addressbook.',$num);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
// array('LastName' => 'FullName','FirstName' => '+, ');
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
@ -30,129 +30,137 @@
|
||||
var $type = 'csv';
|
||||
|
||||
var $import = array(
|
||||
"Title" => "title",
|
||||
"First Name" => "n_given",
|
||||
"Middle Name" => "n_middle",
|
||||
"Last Name" => "n_family",
|
||||
"Suffix" => "n_suffix",
|
||||
"Company" => "org_name", //objectclass: organization
|
||||
"Department" => "org_unit", //objectclass: organizationalPerson
|
||||
"Job Title" => "title", //objectclass: organizationalPerson
|
||||
"Business Street" => "adr_one_street",
|
||||
"Business Street 2" => "address2",
|
||||
"Business Street 3" => "address3",
|
||||
"Business City" => "adr_one_locality",
|
||||
"Business State" => "adr_one_region",
|
||||
"Business Postal Code" => "adr_one_postalcode",
|
||||
"Business Country" => "adr_one_countryname",
|
||||
"Home Street" => "adr_two_street",
|
||||
"Home City" => "adr_two_locality",
|
||||
"Home State" => "adr_two_region",
|
||||
"Home Postal Code" => "adr_two_postalcode",
|
||||
"Home Country" => "adr_two_countryname",
|
||||
"Home Street 2" => "",
|
||||
"Home Street 3" => "",
|
||||
"Other Street" => "",
|
||||
"Other City" => "",
|
||||
"Other State" => "",
|
||||
"Other Postal Code" => "",
|
||||
"Other Country" => "",
|
||||
"Assistant's Phone" => "tel_msg",
|
||||
"Business Fax" => "tel_fax",
|
||||
"Business Phone" => "tel_work",
|
||||
"Business Phone 2" => "ophone",
|
||||
"Callback" => "",
|
||||
"Car Phone" => "tel_car",
|
||||
"Company Main Phone" => "",
|
||||
"Home Fax" => "",
|
||||
"Home Phone" => "tel_home",
|
||||
"Home Phone 2" => "", //This will make another homePhone entry
|
||||
"ISDN" => "tel_isdn",
|
||||
"Mobile Phone" => "tel_cell", //newPilotPerson
|
||||
"Other Fax" => "",
|
||||
"Other Phone" => "",
|
||||
"Pager" => "tel_pager",
|
||||
"Primary Phone" => "",
|
||||
"Radio Phone" => "",
|
||||
"TTY/TDD Phone" => "",
|
||||
"Telex" => "", //organization
|
||||
"Account" => "",
|
||||
"Anniversary" => "",
|
||||
"Assistant's Name" => "", //newPilotPerson
|
||||
"Billing Information" => "",
|
||||
"Birthday" => "bday",
|
||||
"Categories" => "",
|
||||
"Children" => "",
|
||||
"Directory Server" => "",
|
||||
"E-mail Address" => "email",
|
||||
"E-mail Display Name" => "",
|
||||
"E-mail 2 Address" => "email_home",
|
||||
"E-mail 2 Display Name" => "",
|
||||
"E-mail 3 Address" => "", //add another...
|
||||
"E-mail 3 Display Name" => "",
|
||||
"Gender" => "",
|
||||
"Government ID Number" => "",
|
||||
"Hobby" => "",
|
||||
"Initials" => "",
|
||||
"Internet Free Busy" => "",
|
||||
"Keywords" => "",
|
||||
"Language" => "",
|
||||
"Location" => "",
|
||||
"Manager's Name" => "",
|
||||
"Mileage" => "",
|
||||
"Notes" => "note",
|
||||
"Office Location" => "",
|
||||
"Organizational ID Number" => "",
|
||||
"PO Box" => "",
|
||||
"Priority" => "",
|
||||
"Private Profession" => "",
|
||||
"Referred By" => "",
|
||||
"Sensitivity" => "",
|
||||
"Spouse" => "",
|
||||
"User 1" => "",
|
||||
"User 2" => "",
|
||||
"User 3" => "",
|
||||
"User 4" => "",
|
||||
"Web Page" => "url"
|
||||
'Title' => 'title',
|
||||
'First Name' => 'n_given',
|
||||
'Middle Name' => 'n_middle',
|
||||
'Last Name' => 'n_family',
|
||||
'Suffix' => 'n_suffix',
|
||||
'Company' => 'org_name', //objectclass: organization
|
||||
'Department' => 'org_unit', //objectclass: organizationalPerson
|
||||
'Job Title' => 'title', //objectclass: organizationalPerson
|
||||
'Business Street' => 'adr_one_street',
|
||||
'Business Street 2' => 'address2',
|
||||
'Business Street 3' => 'address3',
|
||||
'Business City' => 'adr_one_locality',
|
||||
'Business State' => 'adr_one_region',
|
||||
'Business Postal Code' => 'adr_one_postalcode',
|
||||
'Business Country' => 'adr_one_countryname',
|
||||
'Home Street' => 'adr_two_street',
|
||||
'Home City' => 'adr_two_locality',
|
||||
'Home State' => 'adr_two_region',
|
||||
'Home Postal Code' => 'adr_two_postalcode',
|
||||
'Home Country' => 'adr_two_countryname',
|
||||
'Home Street 2' => '',
|
||||
'Home Street 3' => '',
|
||||
'Other Street' => '',
|
||||
'Other City' => '',
|
||||
'Other State' => '',
|
||||
'Other Postal Code' => '',
|
||||
'Other Country' => '',
|
||||
"Assistant's Phone" => 'tel_msg',
|
||||
'Business Fax' => 'tel_fax',
|
||||
'Business Phone' => 'tel_work',
|
||||
'Business Phone 2' => 'ophone',
|
||||
'Callback' => '',
|
||||
'Car Phone' => 'tel_car',
|
||||
'Company Main Phone' => '',
|
||||
'Home Fax' => '',
|
||||
'Home Phone' => 'tel_home',
|
||||
'Home Phone 2' => '', //This will make another homePhone entry
|
||||
'ISDN' => 'tel_isdn',
|
||||
'Mobile Phone' => 'tel_cell', //newPilotPerson
|
||||
'Other Fax' => '',
|
||||
'Other Phone' => '',
|
||||
'Pager' => 'tel_pager',
|
||||
'Primary Phone' => '',
|
||||
'Radio Phone' => '',
|
||||
'TTY/TDD Phone' => '',
|
||||
'Telex' => '', //organization
|
||||
'Account' => '',
|
||||
'Anniversary' => '',
|
||||
"Assistant's Name" => '', //newPilotPerson
|
||||
'Billing Information' => '',
|
||||
'Birthday' => 'bday',
|
||||
'Categories' => '',
|
||||
'Children' => '',
|
||||
'Directory Server' => '',
|
||||
'E-mail Address' => 'email',
|
||||
'E-mail Display Name' => '',
|
||||
'E-mail 2 Address' => 'email_home',
|
||||
'E-mail 2 Display Name' => '',
|
||||
'E-mail 3 Address' => '', //add another...
|
||||
'E-mail 3 Display Name' => '',
|
||||
'Gender' => '',
|
||||
'Government ID Number' => '',
|
||||
'Hobby' => '',
|
||||
'Initials' => '',
|
||||
'Internet Free Busy' => '',
|
||||
'Keywords' => '',
|
||||
'Language' => '',
|
||||
'Location' => '',
|
||||
"Manager's Name" => '',
|
||||
'Mileage' => '',
|
||||
'Notes' => 'note',
|
||||
'Office Location' => '',
|
||||
'Organizational ID Number' => '',
|
||||
'PO Box' => '',
|
||||
'Priority' => '',
|
||||
'Private Profession' => '',
|
||||
'Referred By' => '',
|
||||
'Sensitivity' => '',
|
||||
'Spouse' => '',
|
||||
'User 1' => '',
|
||||
'User 2' => '',
|
||||
'User 3' => '',
|
||||
'User 4' => '',
|
||||
'Web Page' => 'url'
|
||||
);
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
function import_start_file($buffer)
|
||||
{
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
function import_start_record($buffer)
|
||||
{
|
||||
$top=array();
|
||||
++$this->id;
|
||||
$this->currentrecord = $top;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
function import_new_attrib($buffer,$name,$value)
|
||||
{
|
||||
$value = trim($value);
|
||||
$value = str_replace("\n","<BR>",$value);
|
||||
$value = str_replace("\r","",$value);
|
||||
$value = str_replace('\n','<BR>',$value);
|
||||
$value = str_replace('\r','',$value);
|
||||
$this->currentrecord += array($name => $value);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer) {
|
||||
function import_end_record($buffer)
|
||||
{
|
||||
global $phpgw_info;
|
||||
$buffer[$this->id]="";
|
||||
while ( list($name, $value) = each($this->currentrecord)) {
|
||||
$buffer[$this->id]='';
|
||||
while ( list($name, $value) = each($this->currentrecord))
|
||||
{
|
||||
$buffer[$this->id][$name] = $value;
|
||||
//echo '<br>'.$name.' => '.$value;
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer,$access="private",$cat_id=0) {
|
||||
function import_end_file($buffer,$access='private',$cat_id=0)
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
$contacts = CreateObject("phpgwapi.contacts");
|
||||
$contacts = CreateObject('phpgwapi.contacts');
|
||||
//echo '<br>';
|
||||
for ($i=1;$i<=count($buffer);$i++) {
|
||||
while ( list($name,$value) = @each($buffer[$i]) ) {
|
||||
for ($i=1;$i<=count($buffer);$i++)
|
||||
{
|
||||
while ( list($name,$value) = @each($buffer[$i]) )
|
||||
{
|
||||
//echo '<br>'.$i.': '.$name.' => '.$value;
|
||||
$entry[$i][$name] = $value;
|
||||
}
|
||||
@ -161,10 +169,10 @@
|
||||
$entry[$i]['adr_one_type'] = 'intl';
|
||||
$entry[$i]['adr_two_type'] = 'intl';
|
||||
//echo '<br>';
|
||||
$contacts->add($phpgw_info["user"]["account_id"],$entry[$i],$access,$cat_id);
|
||||
$contacts->add($phpgw_info['user']['account_id'],$entry[$i],$access,$cat_id);
|
||||
}
|
||||
$num = $i - 1;
|
||||
return "Successfully imported $num records into your addressbook.";
|
||||
return lang('Successfully imported x records into your addressbook.',$num);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -18,7 +18,7 @@
|
||||
// before the value. For example, the following would add a comma and
|
||||
// a space between LastName and FirstName and store it in FullName:
|
||||
//
|
||||
// array("LastName" => "FullName","FirstName" => "+, ");
|
||||
// array('LastName' => 'FullName','FirstName' => '+, ');
|
||||
//
|
||||
// Also start with a '#' symbol and a comma separated list will be
|
||||
// turned into a number of the same entries.
|
||||
@ -36,53 +36,60 @@
|
||||
// This will be populated via the vcard->import var
|
||||
var $import = array();
|
||||
|
||||
function import_start_file($buffer,$j="",$k="") {
|
||||
function import_start_file($buffer)
|
||||
{
|
||||
$this->id = 0;
|
||||
$this->contacts = CreateObject("phpgwapi.contacts");
|
||||
$this->vcard = CreateObject("phpgwapi.vcard");
|
||||
$this->contacts = CreateObject('phpgwapi.contacts');
|
||||
$this->vcard = CreateObject('phpgwapi.vcard');
|
||||
$this->import = $this->vcard->import;
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_start_record($buffer) {
|
||||
function import_start_record($buffer)
|
||||
{
|
||||
++$this->id;
|
||||
$this->currentrecord = array();
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_new_attrib($buffer,$name,$value) {
|
||||
function import_new_attrib($buffer,$name,$value)
|
||||
{
|
||||
$value = trim($value);
|
||||
$value = ereg_replace("=0D=0A","\n",$value);
|
||||
//echo '<br>'.$this->id.": ".$name.' => '.$value;
|
||||
$value = ereg_replace('=0D=0A','\n',$value);
|
||||
//echo '<br>'.$this->id.': '.$name.' => '.$value;
|
||||
$this->currentrecord += array($name => $value);
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_record($buffer) {
|
||||
function import_end_record($buffer)
|
||||
{
|
||||
global $phpgw_info;
|
||||
$buffer[$this->id]="";
|
||||
while ( list($name, $value) = each($this->currentrecord)) {
|
||||
$buffer[$this->id]='';
|
||||
while ( list($name, $value) = each($this->currentrecord))
|
||||
{
|
||||
$buffer[$this->id][$name] = $value;
|
||||
//$buffer[$this->id]["private"] = $private;
|
||||
//$buffer[$this->id]['private'] = $private;
|
||||
//echo '<br>'.$name.' => '.$value;
|
||||
}
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
function import_end_file($buffer,$access="private",$cat_id=0) {
|
||||
function import_end_file($buffer,$access='private',$cat_id=0)
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
for ($i=1;$i<=count($buffer);$i++) {
|
||||
for ($i=1;$i<=count($buffer);$i++)
|
||||
{
|
||||
// Send the entire array to the vcard class in function.
|
||||
// It will parse the vcard fields and clean the array of extra
|
||||
// bogus values that get stuffed in.
|
||||
$entry = $this->vcard->in($buffer[$i]);
|
||||
// Now actually add the new entry
|
||||
$this->contacts->add($phpgw_info["user"]["account_id"],$entry,$access,$cat_id);
|
||||
$this->contacts->add($phpgw_info['user']['account_id'],$entry,$access,$cat_id);
|
||||
}
|
||||
$num = $i - 1;
|
||||
return "Successfully imported $num records into your addressbook.";
|
||||
return lang('Successfully imported x records into your addressbook.',$num);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user