forked from extern/egroupware
Formatting
This commit is contained in:
parent
a6da8acffc
commit
a0a3fbb31a
@ -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 '<body bgcolor="' . $phpgw_info["theme"]["bg_color"] . '">';
|
||||
include('../header.inc.php');
|
||||
echo '<body bgcolor="' . $phpgw_info['theme']['bg_color'] . '">';
|
||||
}
|
||||
|
||||
// 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 "<B><CENTER>You must select a vcard. (*.vcf)</B></CENTER><BR><BR>";
|
||||
if ($action == 'GetFile')
|
||||
{
|
||||
echo '<b><center>You must select a vcard. (*.vcf)</b></center><br><br>';
|
||||
}
|
||||
|
||||
$t = new Template(PHPGW_APP_TPL);
|
||||
$t->set_file(array("vcardin" => "vcardin.tpl"));
|
||||
$t->set_file(array('vcardin' => 'vcardin.tpl'));
|
||||
|
||||
$vcard_header = "<p> <b>" . lang("Address book - VCard in") . "</b><hr><p>";
|
||||
$vcard_header = '<p> <b>' . lang('Address book - VCard in') . '</b><hr><p>';
|
||||
|
||||
$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();
|
||||
}
|
||||
?>
|
||||
|
@ -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 '<br>'.$name."=".$fields[$name]."\n";
|
||||
$buffer[$myexport[$name]] = $value;
|
||||
}
|
||||
@ -114,25 +131,28 @@
|
||||
$phpgw->common->exit;
|
||||
} /* !nolname && !nofname */
|
||||
|
||||
if($nofname) {
|
||||
echo "<BR><BR><CENTER>";
|
||||
echo lang("This person's first name was not in the address book.") ."<BR>";
|
||||
echo lang("Vcards require a first name entry.") . "<BR><BR>";
|
||||
echo "<a href=" . $phpgw->link("/addressbook/index.php",
|
||||
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . ">OK</a>";
|
||||
echo "</CENTER>";
|
||||
if($nofname)
|
||||
{
|
||||
echo '<br><br><center>';
|
||||
echo lang("This person's first name was not in the address book.") .'<br>';
|
||||
echo lang('Vcards require a first name entry.') . '<br><br>';
|
||||
echo '<a href="' . $phpgw->link('/addressbook/index.php',
|
||||
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
|
||||
echo '</center>';
|
||||
}
|
||||
|
||||
if($nolname) {
|
||||
echo "<BR><BR><CENTER>";
|
||||
echo lang("This person's last name was not in the address book.") . "<BR>";
|
||||
echo lang("Vcards require a last name entry.") . "<BR><BR>";
|
||||
echo "<a href=" . $phpgw->link("/addressbook/index.php",
|
||||
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . ">OK</a>";
|
||||
echo "</CENTER>";
|
||||
if($nolname)
|
||||
{
|
||||
echo '<br><br><center>';
|
||||
echo lang("This person's last name was not in the address book.") . '<br>';
|
||||
echo lang('Vcards require a last name entry.') . '<br><br>';
|
||||
echo '<a href="' . $phpgw->link('/addressbook/index.php',
|
||||
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
|
||||
echo '</center>';
|
||||
}
|
||||
|
||||
if($nolname || $nofname)
|
||||
{
|
||||
$phpgw->common->phpgw_footer();
|
||||
/* End of php. */
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user