Formatting

This commit is contained in:
Miles Lott 2001-05-21 07:56:46 +00:00
parent a6da8acffc
commit a0a3fbb31a
2 changed files with 126 additions and 90 deletions

View File

@ -12,20 +12,24 @@
/* $Id$ */ /* $Id$ */
if ($action == "Load Vcard") { if ($action == 'Load Vcard')
$phpgw_info["flags"] = array( {
"noheader" => True, "nonavbar" => True, $phpgw_info['flags'] = array(
"currentapp" => "addressbook", 'noheader' => True,
"enable_contacts_class" => True 'nonavbar' => True,
'currentapp' => 'addressbook',
'enable_contacts_class' => True
); );
include("../header.inc.php"); include('../header.inc.php');
} else { }
$phpgw_info["flags"] = array( else
"currentapp" => "addressbook", {
"enable_contacts_class" => True $phpgw_info['flags'] = array(
'currentapp' => 'addressbook',
'enable_contacts_class' => True
); );
include("../header.inc.php"); include('../header.inc.php');
echo '<body bgcolor="' . $phpgw_info["theme"]["bg_color"] . '">'; echo '<body bgcolor="' . $phpgw_info['theme']['bg_color'] . '">';
} }
// Some of the methods where borrowed from // Some of the methods where borrowed from
@ -33,39 +37,48 @@
// (only the uploaddir naming anymore) // (only the uploaddir naming anymore)
$sep = SEP; $sep = SEP;
$uploaddir = $phpgw_info["server"]["temp_dir"] . $sep; $uploaddir = $phpgw_info['server']['temp_dir'] . $sep;
if ($action == "Load Vcard") { if ($action == 'Load Vcard')
if($uploadedfile == "none" || $uploadedfile == "") { {
Header("Location: " . $phpgw->link("/addressbook/vcardin.php","action=GetFile")); if($uploadedfile == 'none' || $uploadedfile == '')
} else { {
Header('Location: ' . $phpgw->link('/addressbook/vcardin.php','action=GetFile'));
}
else
{
srand((double)microtime()*1000000); srand((double)microtime()*1000000);
$random_number = rand(100000000,999999999); $random_number = rand(100000000,999999999);
$newfilename = md5("$uploadedfile, $uploadedfile_name, " $newfilename = md5("$uploadedfile, $uploadedfile_name, "
. time() . getenv("REMOTE_ADDR") . $random_number ); . time() . getenv("REMOTE_ADDR") . $random_number );
copy($uploadedfile, $uploaddir . $newfilename); copy($uploadedfile, $uploaddir . $newfilename);
$ftp = fopen($uploaddir . $newfilename . ".info","w"); $ftp = fopen($uploaddir . $newfilename . '.info','w');
fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n"); fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n");
fclose($ftp); fclose($ftp);
$filename = $uploaddir . $newfilename; $filename = $uploaddir . $newfilename;
$contacts = CreateObject("phpgwapi.contacts"); $contacts = CreateObject('phpgwapi.contacts');
$vcard = CreateObject("phpgwapi.vcard"); $vcard = CreateObject('phpgwapi.vcard');
$myimport = $vcard->import; $myimport = $vcard->import;
$buffer = array(); $buffer = array();
$fp=fopen($filename,"r"); $fp=fopen($filename,'r');
while ($data = fgets($fp,8000)) { while ($data = fgets($fp,8000))
{
list($name,$value,$extra) = split(':', $data); list($name,$value,$extra) = split(':', $data);
if (substr($value,0,5) == "http") { if (substr($value,0,5) == 'http')
$value = $value . ":".$extra; {
$value = $value . ':'.$extra;
} }
if ($name && $value) { if ($name && $value)
{
reset($vcard->import); reset($vcard->import);
while ( list($fname,$fvalue) = each($vcard->import) ) { while ( list($fname,$fvalue) = each($vcard->import) )
if ( strstr(strtolower($name), $vcard->import[$fname]) ) { {
if ( strstr(strtolower($name), $vcard->import[$fname]) )
{
$value = trim($value); $value = trim($value);
$value = ereg_replace("=0D=0A","\n",$value); $value = ereg_replace("=0D=0A","\n",$value);
$buffer += array($name => $value); $buffer += array($name => $value);
@ -76,34 +89,37 @@
fclose($fp); fclose($fp);
$entry = $vcard->in($buffer); $entry = $vcard->in($buffer);
$contacts->add($phpgw_info["user"]["account_id"],$entry); $contacts->add($phpgw_info['user']['account_id'],$entry);
// Delete the temp file. // Delete the temp file.
unlink($filename); unlink($filename);
unlink($filename . ".info"); unlink($filename . '.info');
Header("Location: " . $phpgw->link("/addressbook/", "cd=14")); Header('Location: ' . $phpgw->link('/addressbook/', 'cd=14'));
} }
} }
if ($action == "GetFile"){ if ($action == 'GetFile')
echo "<B><CENTER>You must select a vcard. (*.vcf)</B></CENTER><BR><BR>"; {
echo '<b><center>You must select a vcard. (*.vcf)</b></center><br><br>';
} }
$t = new Template(PHPGW_APP_TPL); $t = new Template(PHPGW_APP_TPL);
$t->set_file(array("vcardin" => "vcardin.tpl")); $t->set_file(array('vcardin' => 'vcardin.tpl'));
$vcard_header = "<p>&nbsp;<b>" . lang("Address book - VCard in") . "</b><hr><p>"; $vcard_header = '<p>&nbsp;<b>' . lang('Address book - VCard in') . '</b><hr><p>';
$t->set_var(vcard_header,$vcard_header); $t->set_var(vcard_header,$vcard_header);
$t->set_var(action_url,$phpgw->link("/addressbook/vcardin.php")); $t->set_var(action_url,$phpgw->link('/addressbook/vcardin.php'));
$t->set_var(lang_access,lang("Access")); $t->set_var(lang_access,lang('Access'));
$t->set_var(lang_groups,lang("Which groups")); $t->set_var(lang_groups,lang('Which groups'));
$t->set_var(access_option,$access_option); $t->set_var(access_option,$access_option);
$t->set_var(group_option,$group_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(); $phpgw->common->phpgw_footer();
}
?> ?>

View File

@ -12,33 +12,37 @@
/* $Id$ */ /* $Id$ */
if ($nolname || $nofname) { if ($nolname || $nofname)
$phpgw_info["flags"] = array( {
"noheader" => False, $phpgw_info['flags'] = array(
"nonavbar" => False, 'noheader' => False,
"noappheader" => False, 'nonavbar' => False,
"noappfooter" => False 'noappheader' => False,
'noappfooter' => False
); );
} else { }
$phpgw_info["flags"] = array( else
"noheader" => True, {
"nonavbar" => True, $phpgw_info['flags'] = array(
"noappheader" => True, 'noheader' => True,
"noappfooter" => True 'nonavbar' => True,
'noappheader' => True,
'noappfooter' => True
); );
} }
$phpgw_info["flags"]["enable_contacts_class"] = True; $phpgw_info['flags']['enable_contacts_class'] = True;
$phpgw_info["flags"]["enable_browser_class"] = True; $phpgw_info['flags']['enable_browser_class'] = True;
$phpgw_info["flags"]["currentapp"] = "addressbook"; $phpgw_info['flags']['currentapp'] = 'addressbook';
include("../header.inc.php"); include('../header.inc.php');
if (! $ab_id) { if (!$ab_id)
Header("Location: " . $phpgw->link("/addressbook/index.php")); {
Header('Location: ' . $phpgw->link('/addressbook/index.php'));
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} }
$this = CreateObject("phpgwapi.contacts"); $this = CreateObject('phpgwapi.contacts');
// First, make sure they have permission to this entry // First, make sure they have permission to this entry
$check = addressbook_read_entry($ab_id,array('owner' => 'owner')); $check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
@ -51,39 +55,50 @@
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} }
$extrafields = array("address2" => "address2"); $extrafields = array('address2' => 'address2');
$qfields = $this->stock_contact_fields + $extrafields; $qfields = $this->stock_contact_fields + $extrafields;
$fieldlist = addressbook_read_entry($ab_id,$qfields); $fieldlist = addressbook_read_entry($ab_id,$qfields);
$fields = $fieldlist[0]; $fields = $fieldlist[0];
$email = $fields["email"]; $email = $fields['email'];
$emailtype = $fields["email_type"]; if (!$emailtype) { $fields["email_type"] = 'INTERNET'; } $emailtype = $fields['email_type'];
$hemail = $fields["email_home"]; if (!$emailtype)
$hemailtype = $fields["email_home_type"]; if (!$hemailtype) { $fields["email_home_type"] = 'INTERNET'; } {
$firstname = $fields["n_given"]; $fields['email_type'] = 'INTERNET';
$lastname = $fields["n_family"]; }
$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. */ /* First name and last must be in the vcard. */
if($lastname == "") { if($lastname == '')
{
/* Run away here. */ /* 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")); "nolname=1&ab_id=$ab_id&start=$start&order=$order&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id"));
} }
if($firstname == "" ) { if($firstname == '')
Header("Location: " . $phpgw->link("/addressbook/vcardout.php", {
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")); "nofname=1&ab_id=$ab_id&start=$start&order=$order&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id"));
} }
if ($email) if ($email)
{ {
$fn = explode("@",$email); $fn = explode('@',$email);
$filename = sprintf("%s.vcf", $fn[0]); $filename = sprintf("%s.vcf", $fn[0]);
} }
elseif ($hemail) elseif ($hemail)
{ {
$fn = explode("@",$hemail); $fn = explode('@',$hemail);
$filename = sprintf("%s.vcf", $fn[0]); $filename = sprintf("%s.vcf", $fn[0]);
} }
else else
@ -93,13 +108,15 @@
} }
// create vcard object // create vcard object
$vcard = CreateObject("phpgwapi.vcard"); $vcard = CreateObject('phpgwapi.vcard');
// set translation variable // set translation variable
$myexport = $vcard->export; $myexport = $vcard->export;
// check that each $fields exists in the export array and // check that each $fields exists in the export array and
// set a new array to equal the translation and original value // set a new array to equal the translation and original value
while( list($name,$value) = each($fields) ) { while( list($name,$value) = each($fields) )
if ($myexport[$name] && ($value != "") ) { {
if ($myexport[$name] && ($value != "") )
{
//echo '<br>'.$name."=".$fields[$name]."\n"; //echo '<br>'.$name."=".$fields[$name]."\n";
$buffer[$myexport[$name]] = $value; $buffer[$myexport[$name]] = $value;
} }
@ -114,25 +131,28 @@
$phpgw->common->exit; $phpgw->common->exit;
} /* !nolname && !nofname */ } /* !nolname && !nofname */
if($nofname) { if($nofname)
echo "<BR><BR><CENTER>"; {
echo lang("This person's first name was not in the address book.") ."<BR>"; echo '<br><br><center>';
echo lang("Vcards require a first name entry.") . "<BR><BR>"; echo lang("This person's first name was not in the address book.") .'<br>';
echo "<a href=" . $phpgw->link("/addressbook/index.php", echo lang('Vcards require a first name entry.') . '<br><br>';
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . ">OK</a>"; echo '<a href="' . $phpgw->link('/addressbook/index.php',
echo "</CENTER>"; "order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
echo '</center>';
} }
if($nolname) { if($nolname)
echo "<BR><BR><CENTER>"; {
echo lang("This person's last name was not in the address book.") . "<BR>"; echo '<br><br><center>';
echo lang("Vcards require a last name entry.") . "<BR><BR>"; echo lang("This person's last name was not in the address book.") . '<br>';
echo "<a href=" . $phpgw->link("/addressbook/index.php", echo lang('Vcards require a last name entry.') . '<br><br>';
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . ">OK</a>"; echo '<a href="' . $phpgw->link('/addressbook/index.php',
echo "</CENTER>"; "order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
echo '</center>';
} }
if($nolname || $nofname) if($nolname || $nofname)
{
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
/* End of php. */ }
?> ?>