Forgot to add a few files

This commit is contained in:
jengo 2000-11-03 21:11:39 +00:00
parent 78fdf2c804
commit 4fa39a29f5
2 changed files with 252 additions and 0 deletions

116
addressbook/vcardin.php Normal file
View File

@ -0,0 +1,116 @@
<?php
/**************************************************************************\
* phpGroupWare - E-Mail *
* http://www.phpgroupware.org *
* This file written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
if ($action == "Load Vcard"){
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True, "currentapp" => "addressbook");
include("../header.inc.php");
}else{
$phpgw_info["flags"]["currentapp"]="addressbook";
include("../header.inc.php");
echo '<body bgcolor="' . $phpgw_info["theme"]["bg_color"] . '">';
}
// Some on the methods where borrowed from
// Squirrelmail <Luke Ehresman> http://www.squirrelmail.org
$sep = $phpgw->common->filesystem_separator();
$uploaddir = $phpgw_info["server"]["temp_dir"] . $sep . $phpgw_info["user"]["sessionid"] . $sep;
if ($action == "Load Vcard") {
if($uploadedfile == "none" || $uploadedfile == "")
{
Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] .
"/addressbook/vcardin.php","action=GetFile"));
}
else
{
srand((double)microtime()*1000000);
$random_number = rand(100000000,999999999);
$newfilename = md5("$uploadedfile, $uploadedfile_name, " . $phpgw_info["user"]["sessionid"]
. time() . getenv("REMOTE_ADDR") . $random_number );
copy($uploadedfile, $uploaddir . $newfilename);
$ftp = fopen($uploaddir . $newfilename . ".info","w");
fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n");
fclose($ftp);
// This has to be non-interactive in case of a multi-entry vcard.
Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] .
"/addressbook/parsecard.php","filename=" . $uploaddir . $newfilename .
"&access=" . $access . "&n_groups=" . $phpgw->accounts->array_to_string($access,$n_groups)
));
}
}
if (! file_exists($phpgw_info["server"]["temp_dir"] . $sep . $phpgw_info["user"]["sessionid"]))
mkdir($phpgw_info["server"]["temp_dir"] . $sep . $phpgw_info["user"]["sessionid"],0700);
if ($action == "GetFile"){
echo "<B><CENTER>You must select a vcard. (*.vcf)</B></CENTER><BR><BR>";
}
?>
<form ENCTYPE="multipart/form-data" method="POST" action="<?php echo $phpgw->link("vcardin.php")?>">
<table border=0>
<tr>
<td>Vcard: <input type="file" name="uploadedfile"></td>
<td><input type="submit" name="action" value="Load Vcard"></td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td><?php echo lang("Access");?>:</td>
<td><?php echo lang("Which groups");?>:</td>
</tr>
<tr>
<td>
<select name="access">
<option value="private"<?php if($access == "private") echo "selected";?>>
<?php echo lang("private"); ?>
</option>
<option value="public"<?php if($access == "public") echo "selected";?>>
<?php echo lang("Global Public"); ?>
</option>
<option value="group"<?php if($access != "private" && $access != "public"
&& $access != "") echo "selected";?>>
<?php echo lang("Group Public"); ?>
</option>
</select>
</td>
<td colspan="3">
<select name=n_groups[] multiple size="5">
<?php
$user_groups = $phpgw->accounts->read_group_names($fields["ab_owner"]);
for ($i=0;$i<count($user_groups);$i++) {
echo "<option value=\"" . $user_groups[$i][0] . "\"";
if (ereg(",".$user_groups[$i][0].",",$access))
echo " selected";
echo ">" . $user_groups[$i][1] . "</option>\n";
}
?>
</select>
</td>
</tr>
</table>
</form>
<?php
if ($action != "Load Vcard")
$phpgw->common->phpgw_footer();
?>

136
addressbook/vcardout.php Normal file
View File

@ -0,0 +1,136 @@
<?php
/**************************************************************************\
* phpGroupWare - addressbook *
* http://www.phpgroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
if ($nolname || $nofname) {
$phpgw_info["flags"] = array("noheader" => False, "nonavbar" => False);
}else{
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
}
$phpgw_info["flags"]["currentapp"] = "addressbook";
include("../header.inc.php");
if (! $ab_id) {
Header("Location: " . $phpgw->link("index.php"));
exit;
}
if ($filter != "private")
$filtermethod = " or ab_access='public' " . $phpgw->accounts->sql_search("ab_access");
if($phpgw_info["apps"]["timetrack"]["enabled"]) {
$phpgw->db->query("SELECT * FROM addressbook as a, customers as c WHERE a.ab_company_id = c.company_id "
. "AND ab_id=$ab_id AND (ab_owner='"
. $phpgw_info["user"]["account_id"] . "' $filtermethod)");
} else {
$phpgw->db->query("SELECT * FROM addressbook "
. "WHERE ab_id=$ab_id AND (ab_owner='"
. $phpgw_info["user"]["account_id"] . "' $filtermethod)");
}
$phpgw->db->next_record();
if(!$nolname && !$nofname)
{
/* First name and last must be in the vcard. */
if($phpgw->db->f("ab_lastname") == "")
{
/* Run away here. */
Header("Location: " . $phpgw->link("vcardout.php","nolname=1&ab_id=$ab_id&start=$start&order=$order&filter=" . "$filter&query=$query&sort=$sort"));
}
if($phpgw->db->f("ab_firstname") =="" )
{
Header("Location: " . $phpgw->link("vcardout.php","nofname=1&ab_id=$ab_id&start=$start&order=$order&filter=" . "$filter&query=$query&sort=$sort"));
}
header("Content-type: text/X-VCARD");
$fn = explode("@",$phpgw->db->f("ab_email"));
$filename = sprintf("%s.vcf", $fn[0]);
header("Content-Disposition: attachment; filename=$filename");
printf("BEGIN:VCARD\r\n");
printf("N:%s;%s\r\n", $phpgw->db->f("ab_lastname"), $phpgw->db->f("ab_firstname"));
printf("FN:%s %s\r\n", $phpgw->db->f("ab_firstname"), $phpgw->db->f("ab_lastname"));
/* This stuff is optional. */
if($phpgw->db->f("ab_title") != "") /* Title */
printf("TITLE:%s\r\n",$phpgw->db->f("ab_title"));
if($phpgw->db->f("ab_email") != "") /* E-mail */
printf("EMAIL;INTERNET:%s\r\n", $phpgw->db->f("ab_email"));
if($phpgw->db->f("ab_hphone") != "") /* Home Phone */
printf("TEL;HOME:%s\r\n", $phpgw->db->f("ab_hphone"));
if($phpgw->db->f("ab_wphone") != "") /* Work Phone */
printf("TEL;WORK:%s\r\n", $phpgw->db->f("ab_wphone"));
if($phpgw->db->f("ab_mphone") != "") /* Mobile Phone */
printf("TEL;CELL:%s\r\n", $phpgw->db->f("ab_mphone"));
if($phpgw->db->f("ab_fax") != "") /* Fax Number */
printf("TEL;FAX:%s\r\n", $phpgw->db->f("ab_fax"));
if($phpgw->db->f("ab_pager") != "") /* Pager Number */
printf("TEL;PAGER:%s\r\n", $phpgw->db->f("ab_pager"));
// if($pgpgw->db->f("ab_ophone") != "") /* Other Phone */
// $NOTES .= "Other Phone: " . $phpgw->db->f("ab_ophone");
/* The address one is pretty icky. Send it if ANY of the fields are present. */
if($phpgw->db->f("ab_address2") != "" || /* Street Line 1 */
$phpgw->db->f("ab_street") != "" || /* Street Line 2 */
$phpgw->db->f("ab_city") != "" || /* City */
$phpgw->db->f("ab_state") != "" || /* State */
$phpgw->db->f("ab_zip") != "") /* Zip */
// Warning Ugly U.S. centric assumption made here.....
printf("ADR:;%s;%s;%s;%s;%s;%s\r\n", $phpgw->db->f("ab_address2"),
$phpgw->db->f("ab_street"),$phpgw->db->f("ab_city"),
$phpgw->db->f("ab_state"),$phpgw->db->f("ab_zip"),
"United States"
);
if($phpgw->db->f("ab_bday") != "" && $phpgw->db->f("ab_bday") != "//") /* Birthday */
printf("BDAY:%s\r\n", $phpgw->db->f("ab_bday")); /* This is not the right format. */
if($phpgw->db->f("ab_company") != "") /* Company Name (Really isn't company_name?) */
printf("ORG:%s\r\n", $phpgw->db->f("ab_company"));
if($phpgw->db->f("ab_notes") != "") /* Notes */
$NOTES .= $phpgw->db->f("ab_notes");
if($NOTES != "") /* All of the notes. */
printf("NOTE:%s\r\n", $NOTES);
/* End of Stuff. */
printf("VERSION:2.1\r\n");
printf("END:VCARD\r\n");
} /* !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("index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort") . ">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("index.php","order=$order&start=$start&filter=$filter&query=$query&sort=$sort") . ">OK</a>";
echo "</CENTER>";
}
if($nolname || $nofname)
$phpgw->common->phpgw_footer();
/* End of php. */
?>