diff --git a/addressbook/vcardin.php b/addressbook/vcardin.php index 4b49e65f73..e7fd36baf6 100644 --- a/addressbook/vcardin.php +++ b/addressbook/vcardin.php @@ -12,20 +12,24 @@ /* $Id$ */ - if ($action == "Load Vcard") { - $phpgw_info["flags"] = array( - "noheader" => True, "nonavbar" => True, - "currentapp" => "addressbook", - "enable_contacts_class" => True + if ($action == 'Load Vcard') + { + $phpgw_info['flags'] = array( + 'noheader' => True, + 'nonavbar' => True, + 'currentapp' => 'addressbook', + 'enable_contacts_class' => True ); - include("../header.inc.php"); - } else { - $phpgw_info["flags"] = array( - "currentapp" => "addressbook", - "enable_contacts_class" => True + include('../header.inc.php'); + } + else + { + $phpgw_info['flags'] = array( + 'currentapp' => 'addressbook', + 'enable_contacts_class' => True ); - include("../header.inc.php"); - echo ''; + include('../header.inc.php'); + echo ''; } // Some of the methods where borrowed from @@ -33,39 +37,48 @@ // (only the uploaddir naming anymore) $sep = SEP; - $uploaddir = $phpgw_info["server"]["temp_dir"] . $sep; + $uploaddir = $phpgw_info['server']['temp_dir'] . $sep; - if ($action == "Load Vcard") { - if($uploadedfile == "none" || $uploadedfile == "") { - Header("Location: " . $phpgw->link("/addressbook/vcardin.php","action=GetFile")); - } else { + if ($action == 'Load Vcard') + { + if($uploadedfile == 'none' || $uploadedfile == '') + { + Header('Location: ' . $phpgw->link('/addressbook/vcardin.php','action=GetFile')); + } + else + { srand((double)microtime()*1000000); $random_number = rand(100000000,999999999); $newfilename = md5("$uploadedfile, $uploadedfile_name, " . time() . getenv("REMOTE_ADDR") . $random_number ); copy($uploadedfile, $uploaddir . $newfilename); - $ftp = fopen($uploaddir . $newfilename . ".info","w"); + $ftp = fopen($uploaddir . $newfilename . '.info','w'); fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n"); fclose($ftp); $filename = $uploaddir . $newfilename; - $contacts = CreateObject("phpgwapi.contacts"); - $vcard = CreateObject("phpgwapi.vcard"); + $contacts = CreateObject('phpgwapi.contacts'); + $vcard = CreateObject('phpgwapi.vcard'); $myimport = $vcard->import; $buffer = array(); - $fp=fopen($filename,"r"); - while ($data = fgets($fp,8000)) { + $fp=fopen($filename,'r'); + while ($data = fgets($fp,8000)) + { list($name,$value,$extra) = split(':', $data); - if (substr($value,0,5) == "http") { - $value = $value . ":".$extra; + if (substr($value,0,5) == 'http') + { + $value = $value . ':'.$extra; } - if ($name && $value) { + if ($name && $value) + { reset($vcard->import); - while ( list($fname,$fvalue) = each($vcard->import) ) { - if ( strstr(strtolower($name), $vcard->import[$fname]) ) { + while ( list($fname,$fvalue) = each($vcard->import) ) + { + if ( strstr(strtolower($name), $vcard->import[$fname]) ) + { $value = trim($value); $value = ereg_replace("=0D=0A","\n",$value); $buffer += array($name => $value); @@ -76,34 +89,37 @@ fclose($fp); $entry = $vcard->in($buffer); - $contacts->add($phpgw_info["user"]["account_id"],$entry); + $contacts->add($phpgw_info['user']['account_id'],$entry); // Delete the temp file. unlink($filename); - unlink($filename . ".info"); - Header("Location: " . $phpgw->link("/addressbook/", "cd=14")); + unlink($filename . '.info'); + Header('Location: ' . $phpgw->link('/addressbook/', 'cd=14')); } } - if ($action == "GetFile"){ - echo "
You must select a vcard. (*.vcf)


"; + if ($action == 'GetFile') + { + echo '
You must select a vcard. (*.vcf)


'; } $t = new Template(PHPGW_APP_TPL); - $t->set_file(array("vcardin" => "vcardin.tpl")); + $t->set_file(array('vcardin' => 'vcardin.tpl')); - $vcard_header = "

 " . lang("Address book - VCard in") . "


"; + $vcard_header = '

 ' . lang('Address book - VCard in') . '


'; $t->set_var(vcard_header,$vcard_header); - $t->set_var(action_url,$phpgw->link("/addressbook/vcardin.php")); - $t->set_var(lang_access,lang("Access")); - $t->set_var(lang_groups,lang("Which groups")); + $t->set_var(action_url,$phpgw->link('/addressbook/vcardin.php')); + $t->set_var(lang_access,lang('Access')); + $t->set_var(lang_groups,lang('Which groups')); $t->set_var(access_option,$access_option); $t->set_var(group_option,$group_option); - $t->pparse("out","vcardin"); + $t->pparse('out','vcardin'); - if ($action != "Load Vcard") + if ($action != 'Load Vcard') + { $phpgw->common->phpgw_footer(); + } ?> diff --git a/addressbook/vcardout.php b/addressbook/vcardout.php index fadb3c70bf..afa0fca9b9 100644 --- a/addressbook/vcardout.php +++ b/addressbook/vcardout.php @@ -12,33 +12,37 @@ /* $Id$ */ - if ($nolname || $nofname) { - $phpgw_info["flags"] = array( - "noheader" => False, - "nonavbar" => False, - "noappheader" => False, - "noappfooter" => False + if ($nolname || $nofname) + { + $phpgw_info['flags'] = array( + 'noheader' => False, + 'nonavbar' => False, + 'noappheader' => False, + 'noappfooter' => False ); - } else { - $phpgw_info["flags"] = array( - "noheader" => True, - "nonavbar" => True, - "noappheader" => True, - "noappfooter" => True + } + else + { + $phpgw_info['flags'] = array( + 'noheader' => True, + 'nonavbar' => True, + 'noappheader' => True, + 'noappfooter' => True ); } - $phpgw_info["flags"]["enable_contacts_class"] = True; - $phpgw_info["flags"]["enable_browser_class"] = True; - $phpgw_info["flags"]["currentapp"] = "addressbook"; - include("../header.inc.php"); + $phpgw_info['flags']['enable_contacts_class'] = True; + $phpgw_info['flags']['enable_browser_class'] = True; + $phpgw_info['flags']['currentapp'] = 'addressbook'; + include('../header.inc.php'); - if (! $ab_id) { - Header("Location: " . $phpgw->link("/addressbook/index.php")); + if (!$ab_id) + { + Header('Location: ' . $phpgw->link('/addressbook/index.php')); $phpgw->common->phpgw_exit(); } - $this = CreateObject("phpgwapi.contacts"); + $this = CreateObject('phpgwapi.contacts'); // First, make sure they have permission to this entry $check = addressbook_read_entry($ab_id,array('owner' => 'owner')); @@ -51,39 +55,50 @@ $phpgw->common->phpgw_exit(); } - $extrafields = array("address2" => "address2"); + $extrafields = array('address2' => 'address2'); $qfields = $this->stock_contact_fields + $extrafields; $fieldlist = addressbook_read_entry($ab_id,$qfields); $fields = $fieldlist[0]; - $email = $fields["email"]; - $emailtype = $fields["email_type"]; if (!$emailtype) { $fields["email_type"] = 'INTERNET'; } - $hemail = $fields["email_home"]; - $hemailtype = $fields["email_home_type"]; if (!$hemailtype) { $fields["email_home_type"] = 'INTERNET'; } - $firstname = $fields["n_given"]; - $lastname = $fields["n_family"]; + $email = $fields['email']; + $emailtype = $fields['email_type']; + if (!$emailtype) + { + $fields['email_type'] = 'INTERNET'; + } + $hemail = $fields['email_home']; + $hemailtype = $fields['email_home_type']; + if (!$hemailtype) + { + $fields['email_home_type'] = 'INTERNET'; + } + $firstname = $fields['n_given']; + $lastname = $fields['n_family']; - if(!$nolname && !$nofname) { + if(!$nolname && !$nofname) + { /* First name and last must be in the vcard. */ - if($lastname == "") { + if($lastname == '') + { /* Run away here. */ - Header("Location: " . $phpgw->link("/addressbook/vcardout.php", + Header('Location: ' . $phpgw->link('/addressbook/vcardout.php', "nolname=1&ab_id=$ab_id&start=$start&order=$order&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id")); } - if($firstname == "" ) { - Header("Location: " . $phpgw->link("/addressbook/vcardout.php", + if($firstname == '') + { + Header('Location: ' . $phpgw->link('/addressbook/vcardout.php', "nofname=1&ab_id=$ab_id&start=$start&order=$order&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id")); } if ($email) { - $fn = explode("@",$email); + $fn = explode('@',$email); $filename = sprintf("%s.vcf", $fn[0]); } elseif ($hemail) { - $fn = explode("@",$hemail); + $fn = explode('@',$hemail); $filename = sprintf("%s.vcf", $fn[0]); } else @@ -93,13 +108,15 @@ } // create vcard object - $vcard = CreateObject("phpgwapi.vcard"); + $vcard = CreateObject('phpgwapi.vcard'); // set translation variable $myexport = $vcard->export; // check that each $fields exists in the export array and // set a new array to equal the translation and original value - while( list($name,$value) = each($fields) ) { - if ($myexport[$name] && ($value != "") ) { + while( list($name,$value) = each($fields) ) + { + if ($myexport[$name] && ($value != "") ) + { //echo '
'.$name."=".$fields[$name]."\n"; $buffer[$myexport[$name]] = $value; } @@ -114,25 +131,28 @@ $phpgw->common->exit; } /* !nolname && !nofname */ - if($nofname) { - echo "

"; - echo lang("This person's first name was not in the address book.") ."
"; - echo lang("Vcards require a first name entry.") . "

"; - echo "OK"; - echo "
"; + if($nofname) + { + echo '

'; + echo lang("This person's first name was not in the address book.") .'
'; + echo lang('Vcards require a first name entry.') . '

'; + echo '' . lang('OK') . ''; + echo '
'; } - if($nolname) { - echo "

"; - echo lang("This person's last name was not in the address book.") . "
"; - echo lang("Vcards require a last name entry.") . "

"; - echo "OK"; - echo "
"; + if($nolname) + { + echo '

'; + echo lang("This person's last name was not in the address book.") . '
'; + echo lang('Vcards require a last name entry.') . '

'; + echo '' . lang('OK') . ''; + echo '
'; } if($nolname || $nofname) + { $phpgw->common->phpgw_footer(); - /* End of php. */ + } ?>