Qual: vcard is not really an external project but now a specific dolibarr class file, so i moved it into core/class
This commit is contained in:
parent
eded00d761
commit
4e8104a9ca
@ -29,9 +29,7 @@ NuSoap 0.9.5 LGPL 2.1 Yes Interfac
|
|||||||
OdtPHP 1.0.1 GPL 2.0 Yes Library to build/edit ODT files
|
OdtPHP 1.0.1 GPL 2.0 Yes Library to build/edit ODT files
|
||||||
Php-barcode 0.3pl1 GPL 2.0 Yes Bar code generation
|
Php-barcode 0.3pl1 GPL 2.0 Yes Bar code generation
|
||||||
PHPExcel 1.7.6 LGPL 2.1 Yes Read/Write XLS files, read ODS files
|
PHPExcel 1.7.6 LGPL 2.1 Yes Read/Write XLS files, read ODS files
|
||||||
SMTPs 1.15 GPL Yes SMTPS library
|
|
||||||
TCPDF 5.9.098 LGPL 3.0 Yes PDF generation
|
TCPDF 5.9.098 LGPL 3.0 Yes PDF generation
|
||||||
VCard 2.0 GPL 2.0 Yes VCard library
|
|
||||||
|
|
||||||
For licenses compatibility informations:
|
For licenses compatibility informations:
|
||||||
http://www.fsf.org/licensing/licenses/index_html
|
http://www.fsf.org/licensing/licenses/index_html
|
||||||
@ -45,6 +43,8 @@ Copyright (C) 2011
|
|||||||
- Regis Houssin <regis@dolibarr.fr>
|
- Regis Houssin <regis@dolibarr.fr>
|
||||||
- Juanjo Menent
|
- Juanjo Menent
|
||||||
- Philippe Grand
|
- Philippe Grand
|
||||||
|
- Jean Heimburger <jean@tiaris.info>
|
||||||
|
- Philippe Grand
|
||||||
|
|
||||||
Copyright (C) 2010
|
Copyright (C) 2010
|
||||||
- Laurent Destailleur <eldy@users.sourceforge.net>
|
- Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
|||||||
@ -20,13 +20,13 @@
|
|||||||
* \file htdocs/contact/vcard.php
|
* \file htdocs/contact/vcard.php
|
||||||
* \ingroup societe
|
* \ingroup societe
|
||||||
* \brief Onglet vcard d'un contact
|
* \brief Onglet vcard d'un contact
|
||||||
* \version $Id: vcard.php,v 1.27 2011/07/31 23:54:12 eldy Exp $
|
* \version $Id: vcard.php,v 1.28 2011/08/26 23:40:49 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/includes/vcard/vcard.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/vcard.class.php");
|
||||||
|
|
||||||
|
|
||||||
$contact = new Contact($db);
|
$contact = new Contact($db);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/*
|
||||||
* Class SMTPs
|
* Class SMTPs
|
||||||
*
|
*
|
||||||
* Class to construct and send SMTP compliant email, even to a secure
|
* Class to construct and send SMTP compliant email, even to a secure
|
||||||
@ -33,54 +33,59 @@
|
|||||||
* @author Laurent Destailleur <eldy@users.sourceforge.net>
|
* @author Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* @author Regis Houssin
|
* @author Regis Houssin
|
||||||
*
|
*
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
* @license GNU General Public Licence
|
* @license GNU General Public Licence
|
||||||
*
|
*
|
||||||
* $Id: smtps.php,v 1.1 2011/08/26 23:19:54 eldy Exp $
|
* $Id: smtps.php,v 1.2 2011/08/26 23:40:48 eldy Exp $
|
||||||
*
|
*
|
||||||
**/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/class/smtps.class.php
|
||||||
|
* \brief Class to manage SMTPS email sending
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// ** Class Constants
|
// ** Class Constants
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version number of Class
|
* Version number of Class
|
||||||
* @const SMTPs_VER
|
* @const SMTPs_VER
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('SMTPs_VER', '1.15', false);
|
define('SMTPs_VER', '1.15', false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTPs Success value
|
* SMTPs Success value
|
||||||
* @const SMTPs_SUCCEED
|
* @const SMTPs_SUCCEED
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('SMTPs_SUCCEED', true, false);
|
define('SMTPs_SUCCEED', true, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SMTPs Fail value
|
* SMTPs Fail value
|
||||||
* @const SMTPs_FAIL
|
* @const SMTPs_FAIL
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('SMTPs_FAIL', false, false);
|
define('SMTPs_FAIL', false, false);
|
||||||
|
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// ** Error codes and messages
|
// ** Error codes and messages
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Improper parameters
|
* Improper parameters
|
||||||
* @const SMTPs_INVALID_PARAMETERS
|
* @const SMTPs_INVALID_PARAMETERS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('SMTPs_INVALID_PARAMETERS', 50, false);
|
define('SMTPs_INVALID_PARAMETERS', 50, false);
|
||||||
|
|
||||||
|
|
||||||
// =============================================================
|
|
||||||
// =============================================================
|
|
||||||
// ** Class
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Class SMTPs
|
* Class SMTPs
|
||||||
*
|
*
|
||||||
* Class to construct and send SMTP compliant email, even
|
* Class to construct and send SMTP compliant email, even
|
||||||
@ -91,8 +96,8 @@
|
|||||||
**/
|
**/
|
||||||
class SMTPs
|
class SMTPs
|
||||||
{
|
{
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// ** Class Properties
|
// ** Class Properties
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property private string $_smtpsHost
|
* Property private string $_smtpsHost
|
||||||
@ -559,13 +564,13 @@ class SMTPs
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
function setDebug ( $_vDebug = false )
|
function setDebug ( $_vDebug = false )
|
||||||
{
|
{
|
||||||
$this->_debug = $_vDebug;
|
$this->_debug = $_vDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ** Class methods
|
// ** Class methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method public void buildRCPTlist( void )
|
* Method public void buildRCPTlist( void )
|
||||||
@ -812,10 +817,10 @@ class SMTPs
|
|||||||
return $_retVal;
|
return $_retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// ** Setter & Getter methods
|
// ** Setter & Getter methods
|
||||||
|
|
||||||
// ** Basic System configuration
|
// ** Basic System configuration
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method public void setConfig( mixed )
|
* Method public void setConfig( mixed )
|
||||||
@ -1341,7 +1346,7 @@ class SMTPs
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ** Message Construction
|
// ** Message Construction
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method public void setFrom( string )
|
* Method public void setFrom( string )
|
||||||
@ -1876,8 +1881,8 @@ class SMTPs
|
|||||||
$_header .= 'Subject: ' . $this->getSubject() . "\r\n"
|
$_header .= 'Subject: ' . $this->getSubject() . "\r\n"
|
||||||
. 'Date: ' . date("r") . "\r\n"
|
. 'Date: ' . date("r") . "\r\n"
|
||||||
. 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
|
. 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n";
|
||||||
// . 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
|
// . 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
|
||||||
// . 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
|
// . 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
|
||||||
|
|
||||||
if ( $this->getSensitivity() )
|
if ( $this->getSensitivity() )
|
||||||
$_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n";
|
$_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n";
|
||||||
@ -2003,9 +2008,9 @@ class SMTPs
|
|||||||
//$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n";
|
//$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n";
|
||||||
$content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary() . '"' . "\r\n";
|
$content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary() . '"' . "\r\n";
|
||||||
|
|
||||||
// TODO Restore
|
// TODO Restore
|
||||||
// . "\r\n"
|
// . "\r\n"
|
||||||
// . 'This is a multi-part message in MIME format.' . "\r\n";
|
// . 'This is a multi-part message in MIME format.' . "\r\n";
|
||||||
$content .= "Content-Transfer-Encoding: 8bit" . "\r\n";
|
$content .= "Content-Transfer-Encoding: 8bit" . "\r\n";
|
||||||
$content .= "\r\n";
|
$content .= "\r\n";
|
||||||
|
|
||||||
@ -2059,17 +2064,17 @@ class SMTPs
|
|||||||
// TODO Restore "\r\n"
|
// TODO Restore "\r\n"
|
||||||
$content .= "--" . $this->_getBoundary() . "\r\n"
|
$content .= "--" . $this->_getBoundary() . "\r\n"
|
||||||
. 'Content-Type: ' . $_content['mimeType'] . '; '
|
. 'Content-Type: ' . $_content['mimeType'] . '; '
|
||||||
// . 'charset="' . $this->getCharSet() . '"';
|
// . 'charset="' . $this->getCharSet() . '"';
|
||||||
. 'charset=' . $this->getCharSet() . '';
|
. 'charset=' . $this->getCharSet() . '';
|
||||||
|
|
||||||
// TODO Restore
|
// TODO Restore
|
||||||
// $content .= ( $type == 'html') ? '; name="HTML Part"' : '';
|
// $content .= ( $type == 'html') ? '; name="HTML Part"' : '';
|
||||||
$content .= "\r\n";
|
$content .= "\r\n";
|
||||||
// $content .= 'Content-Transfer-Encoding: ';
|
// $content .= 'Content-Transfer-Encoding: ';
|
||||||
// $content .= ( $type == 'html') ? 'quoted-printable' : $this->getTransEncodeType();
|
// $content .= ( $type == 'html') ? 'quoted-printable' : $this->getTransEncodeType();
|
||||||
// $content .= "\r\n"
|
// $content .= "\r\n"
|
||||||
// . 'Content-Disposition: inline' . "\r\n"
|
// . 'Content-Disposition: inline' . "\r\n"
|
||||||
// . 'Content-Description: ' . $type . ' message' . "\r\n";
|
// . 'Content-Description: ' . $type . ' message' . "\r\n";
|
||||||
|
|
||||||
if ( $this->getMD5flag() )
|
if ( $this->getMD5flag() )
|
||||||
$content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
|
$content .= 'Content-MD5: ' . $_content['md5'] . "\r\n";
|
||||||
@ -2081,7 +2086,7 @@ class SMTPs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close message boundries
|
// Close message boundries
|
||||||
// $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ;
|
// $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ;
|
||||||
$content .= "--" . $this->_getBoundary() . '--' . "\r\n" ;
|
$content .= "--" . $this->_getBoundary() . '--' . "\r\n" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2455,8 +2460,8 @@ class SMTPs
|
|||||||
return $this->server_parse($this->socket, $_returnCode);
|
return $this->server_parse($this->socket, $_returnCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// ** Error handling methods
|
// ** Error handling methods
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method private void _setErr( int code, string message )
|
* Method private void _setErr( int code, string message )
|
||||||
@ -2512,15 +2517,18 @@ class SMTPs
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
} // end of Class
|
} // end of Class
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// ** CSV Version Control Info
|
// ** CSV Version Control Info
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $Log: smtps.php,v $
|
* $Log: smtps.php,v $
|
||||||
|
* Revision 1.2 2011/08/26 23:40:48 eldy
|
||||||
|
* Qual: vcard is not really an external project but now a specific dolibarr class file, so i moved it into core/class
|
||||||
|
*
|
||||||
* Revision 1.1 2011/08/26 23:19:54 eldy
|
* Revision 1.1 2011/08/26 23:19:54 eldy
|
||||||
* Qual: smtps is not really an external project but now a specific dolibarr class file, so i moved it into core/class
|
* Qual: smtps is not really an external project but now a specific dolibarr class file, so i moved it into core/class
|
||||||
*
|
*
|
||||||
|
|||||||
298
htdocs/core/class/vcard.class.php
Executable file
298
htdocs/core/class/vcard.class.php
Executable file
@ -0,0 +1,298 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) Kai Blankenhorn <kaib@bitfolge.de>
|
||||||
|
* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.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.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* v2.0 Initial creation Kai Blankenhorn
|
||||||
|
* 2007 v3.0 Laurent Destailleur eldy@users.sourceforge.net
|
||||||
|
* Added functions (as in http://www.ietf.org/rfc/rfc2426.txt):
|
||||||
|
* setTitle setOrg setProdId setUID
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/core/class/vcard.class.php
|
||||||
|
* \brief Class to manage vCard files
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a string for vCard
|
||||||
|
*
|
||||||
|
* @param string String to encode
|
||||||
|
*/
|
||||||
|
function encode($string)
|
||||||
|
{
|
||||||
|
return str_replace(";","\;",(dol_quoted_printable_encode(utf8_decode($string))));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Taken from php documentation comments
|
||||||
|
* No more used
|
||||||
|
*
|
||||||
|
* @param input String
|
||||||
|
* @param line_max Max length of lines
|
||||||
|
*/
|
||||||
|
function dol_quoted_printable_encode($input, $line_max = 76)
|
||||||
|
{
|
||||||
|
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
|
||||||
|
$lines = preg_split("/(\?:\r\n|\r|\n)/", $input);
|
||||||
|
$eol = "\r\n";
|
||||||
|
$linebreak = "=0D=0A";
|
||||||
|
$escape = "=";
|
||||||
|
$output = "";
|
||||||
|
|
||||||
|
for ($j=0;$j<count($lines);$j++) {
|
||||||
|
$line = $lines[$j];
|
||||||
|
$linlen = strlen($line);
|
||||||
|
$newline = "";
|
||||||
|
for($i = 0; $i < $linlen; $i++) {
|
||||||
|
$c = substr($line, $i, 1);
|
||||||
|
$dec = ord($c);
|
||||||
|
if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only
|
||||||
|
$c = "=20";
|
||||||
|
} elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
|
||||||
|
$h2 = floor($dec/16); $h1 = floor($dec%16);
|
||||||
|
$c = $escape.$hex["$h2"].$hex["$h1"];
|
||||||
|
}
|
||||||
|
if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
|
||||||
|
$output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
|
||||||
|
$newline = " ";
|
||||||
|
}
|
||||||
|
$newline .= $c;
|
||||||
|
} // end of for
|
||||||
|
$output .= $newline;
|
||||||
|
if ($j<count($lines)-1) $output .= $linebreak;
|
||||||
|
}
|
||||||
|
return trim($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \class vCard
|
||||||
|
* \brief Class to buld vCard files
|
||||||
|
*/
|
||||||
|
class vCard
|
||||||
|
{
|
||||||
|
var $properties;
|
||||||
|
var $filename;
|
||||||
|
|
||||||
|
//var $encoding="UTF-8";
|
||||||
|
var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme du numero de telephone
|
||||||
|
*
|
||||||
|
* @param number numero de telephone
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
function setPhoneNumber($number, $type="") {
|
||||||
|
// type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE"
|
||||||
|
$key = "TEL";
|
||||||
|
if ($type!="") $key .= ";".$type;
|
||||||
|
$key.= ";CHARSET=".$this->encoding;
|
||||||
|
$this->properties[$key] = encode($number);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de la photo
|
||||||
|
* warning NON TESTE !
|
||||||
|
*
|
||||||
|
* @param type
|
||||||
|
* @param photo
|
||||||
|
*/
|
||||||
|
function setPhoto($type, $photo) { // $type = "GIF" | "JPEG"
|
||||||
|
$this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme du nom formate
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
function setFormattedName($name) {
|
||||||
|
$this->properties["FN;CHARSET=".$this->encoding] = encode($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme du nom complet
|
||||||
|
*
|
||||||
|
* @param family
|
||||||
|
* @param first
|
||||||
|
* @param additional
|
||||||
|
* @param prefix
|
||||||
|
* @param suffix
|
||||||
|
*/
|
||||||
|
function setName($family="", $first="", $additional="", $prefix="", $suffix="") {
|
||||||
|
$this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
|
||||||
|
$this->filename = "$first%20$family.vcf";
|
||||||
|
if ($this->properties["FN"]=="") $this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de l'anniversaire
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
*/
|
||||||
|
function setBirthday($date) { // $date format is YYYY-MM-DD
|
||||||
|
$this->properties["BDAY"] = $date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de l'adresse
|
||||||
|
*
|
||||||
|
* @param postoffice
|
||||||
|
* @param extended
|
||||||
|
* @param street
|
||||||
|
* @param city
|
||||||
|
* @param region
|
||||||
|
* @param zip
|
||||||
|
* @param country
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
function setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
|
||||||
|
// $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
|
||||||
|
$key = "ADR";
|
||||||
|
if ($type!="") $key.= ";$type";
|
||||||
|
$key.= ";CHARSET=".$this->encoding;
|
||||||
|
$this->properties[$key] = encode($name).";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);
|
||||||
|
|
||||||
|
if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "") {
|
||||||
|
//$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme du label
|
||||||
|
*
|
||||||
|
* @param postoffice
|
||||||
|
* @param extended
|
||||||
|
* @param street
|
||||||
|
* @param city
|
||||||
|
* @param region
|
||||||
|
* @param zip
|
||||||
|
* @param country
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
|
||||||
|
$label = "";
|
||||||
|
if ($postoffice!="") $label.= "$postoffice\r\n";
|
||||||
|
if ($extended!="") $label.= "$extended\r\n";
|
||||||
|
if ($street!="") $label.= "$street\r\n";
|
||||||
|
if ($zip!="") $label.= "$zip ";
|
||||||
|
if ($city!="") $label.= "$city\r\n";
|
||||||
|
if ($region!="") $label.= "$region\r\n";
|
||||||
|
if ($country!="") $country.= "$country\r\n";
|
||||||
|
|
||||||
|
$this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de l'email
|
||||||
|
*
|
||||||
|
* @param address EMail
|
||||||
|
* @param type Vcard type
|
||||||
|
*/
|
||||||
|
function setEmail($address,$type="internet,pref") {
|
||||||
|
$this->properties["EMAIL;TYPE=".$type] = $address;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de la note
|
||||||
|
*
|
||||||
|
* @param note
|
||||||
|
*/
|
||||||
|
function setNote($note) {
|
||||||
|
$this->properties["NOTE;CHARSET=".$this->encoding] = encode($note);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de la fonction
|
||||||
|
*
|
||||||
|
* @param title
|
||||||
|
*/
|
||||||
|
function setTitle($title) {
|
||||||
|
$this->properties["TITLE;CHARSET=".$this->encoding] = encode($title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de la societe
|
||||||
|
*
|
||||||
|
* @param org
|
||||||
|
*/
|
||||||
|
function setOrg($org) {
|
||||||
|
$this->properties["ORG;CHARSET=".$this->encoding] = encode($org);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme du logiciel generateur
|
||||||
|
*
|
||||||
|
* @param prodid
|
||||||
|
*/
|
||||||
|
function setProdId($prodid) {
|
||||||
|
$this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme du logiciel generateur
|
||||||
|
*
|
||||||
|
* @param uid
|
||||||
|
*/
|
||||||
|
function setUID($uid) {
|
||||||
|
$this->properties["UID;CHARSET=".$this->encoding] = encode($uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mise en forme de l'url
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
function setURL($url, $type="") {
|
||||||
|
// $type may be WORK | HOME
|
||||||
|
$key = "URL";
|
||||||
|
if ($type!="") $key.= ";$type";
|
||||||
|
$this->properties[$key] = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet d'obtenir une vcard
|
||||||
|
*/
|
||||||
|
function getVCard() {
|
||||||
|
$text = "BEGIN:VCARD\r\n";
|
||||||
|
//$text.= "VERSION:3.0\r\n";
|
||||||
|
$text.= "VERSION:2.1\r\n";
|
||||||
|
foreach($this->properties as $key => $value) {
|
||||||
|
$text.= "$key:$value\r\n";
|
||||||
|
}
|
||||||
|
$text.= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n";
|
||||||
|
$text.= "MAILER: Dolibarr\r\n";
|
||||||
|
$text.= "END:VCARD\r\n";
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* permet d'obtenir le nom de fichier
|
||||||
|
*/
|
||||||
|
function getFileName() {
|
||||||
|
return $this->filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
@ -1,6 +0,0 @@
|
|||||||
README (english)
|
|
||||||
----------------
|
|
||||||
|
|
||||||
This directory contains a PHP library for manipulating VCal format.
|
|
||||||
Author: Kai Blankenhorn
|
|
||||||
Licence: GPL 2.0
|
|
||||||
@ -1,295 +0,0 @@
|
|||||||
<?php
|
|
||||||
/***************************************************************************
|
|
||||||
|
|
||||||
php vCard class
|
|
||||||
(c) Kai Blankenhorn
|
|
||||||
www.bitfolge.de/en
|
|
||||||
kaib@bitfolge.de
|
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
***************************************************************************
|
|
||||||
2007 v3.0 Laurent Destailleur eldy@users.sourceforge.net
|
|
||||||
Added functions (as in http://www.ietf.org/rfc/rfc2426.txt):
|
|
||||||
setTitle setOrg setProdId setUID
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/includes/vcard/vcard.class.php
|
|
||||||
* \brief Classe permettant de creer un fichier vcard.
|
|
||||||
* \author Kai Blankenhorn.
|
|
||||||
* \version 2.0
|
|
||||||
*
|
|
||||||
* Ensemble des fonctions permettant de creer un fichier vcard.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function encode($string) {
|
|
||||||
//return escape($string);
|
|
||||||
return escape(dol_quoted_printable_encode(utf8_decode($string)));
|
|
||||||
}
|
|
||||||
|
|
||||||
function escape($string) {
|
|
||||||
return str_replace(";","\;",$string);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Taken from php documentation comments
|
|
||||||
* No more used
|
|
||||||
*/
|
|
||||||
function dol_quoted_printable_encode($input, $line_max = 76) {
|
|
||||||
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
|
|
||||||
$lines = preg_split("/(\?:\r\n|\r|\n)/", $input);
|
|
||||||
$eol = "\r\n";
|
|
||||||
$linebreak = "=0D=0A";
|
|
||||||
$escape = "=";
|
|
||||||
$output = "";
|
|
||||||
|
|
||||||
for ($j=0;$j<count($lines);$j++) {
|
|
||||||
$line = $lines[$j];
|
|
||||||
$linlen = strlen($line);
|
|
||||||
$newline = "";
|
|
||||||
for($i = 0; $i < $linlen; $i++) {
|
|
||||||
$c = substr($line, $i, 1);
|
|
||||||
$dec = ord($c);
|
|
||||||
if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only
|
|
||||||
$c = "=20";
|
|
||||||
} elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required
|
|
||||||
$h2 = floor($dec/16); $h1 = floor($dec%16);
|
|
||||||
$c = $escape.$hex["$h2"].$hex["$h1"];
|
|
||||||
}
|
|
||||||
if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
|
|
||||||
$output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay
|
|
||||||
$newline = " ";
|
|
||||||
}
|
|
||||||
$newline .= $c;
|
|
||||||
} // end of for
|
|
||||||
$output .= $newline;
|
|
||||||
if ($j<count($lines)-1) $output .= $linebreak;
|
|
||||||
}
|
|
||||||
return trim($output);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \class vCard
|
|
||||||
\brief Classe permettant de creer un fichier vcard
|
|
||||||
|
|
||||||
Ensemble des fonctions permettant de creer un fichier vcard
|
|
||||||
*/
|
|
||||||
|
|
||||||
class vCard {
|
|
||||||
var $properties;
|
|
||||||
var $filename;
|
|
||||||
|
|
||||||
//var $encoding="UTF-8";
|
|
||||||
var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme du numero de telephone
|
|
||||||
\param number numero de telephone
|
|
||||||
\param type
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setPhoneNumber($number, $type="") {
|
|
||||||
// type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE"
|
|
||||||
$key = "TEL";
|
|
||||||
if ($type!="") $key .= ";".$type;
|
|
||||||
$key.= ";CHARSET=".$this->encoding;
|
|
||||||
$this->properties[$key] = encode($number);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme de la photo
|
|
||||||
\param type
|
|
||||||
\param photo
|
|
||||||
\warning NON TESTE !
|
|
||||||
*/
|
|
||||||
|
|
||||||
// UNTESTED !!!
|
|
||||||
function setPhoto($type, $photo) { // $type = "GIF" | "JPEG"
|
|
||||||
$this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme du nom formate
|
|
||||||
\param name
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setFormattedName($name) {
|
|
||||||
$this->properties["FN;CHARSET=".$this->encoding] = encode($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme du nom complet
|
|
||||||
\param family
|
|
||||||
\param first
|
|
||||||
\param additional
|
|
||||||
\param prefix
|
|
||||||
\param suffix
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setName($family="", $first="", $additional="", $prefix="", $suffix="") {
|
|
||||||
$this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix);
|
|
||||||
$this->filename = "$first%20$family.vcf";
|
|
||||||
if ($this->properties["FN"]=="") $this->setFormattedName(trim("$prefix $first $additional $family $suffix"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme de l'anniversaire
|
|
||||||
\param date
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setBirthday($date) { // $date format is YYYY-MM-DD
|
|
||||||
$this->properties["BDAY"] = $date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme de l'adresse
|
|
||||||
\param postoffice
|
|
||||||
\param extended
|
|
||||||
\param street
|
|
||||||
\param city
|
|
||||||
\param region
|
|
||||||
\param zip
|
|
||||||
\param country
|
|
||||||
\param type
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setAddress($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
|
|
||||||
// $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL"
|
|
||||||
$key = "ADR";
|
|
||||||
if ($type!="") $key.= ";$type";
|
|
||||||
$key.= ";CHARSET=".$this->encoding;
|
|
||||||
$this->properties[$key] = encode($name).";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country);
|
|
||||||
|
|
||||||
if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "") {
|
|
||||||
//$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme du label
|
|
||||||
\param postoffice
|
|
||||||
\param extended
|
|
||||||
\param street
|
|
||||||
\param city
|
|
||||||
\param region
|
|
||||||
\param zip
|
|
||||||
\param country
|
|
||||||
\param type
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setLabel($postoffice="", $extended="", $street="", $city="", $region="", $zip="", $country="", $type="HOME;POSTAL") {
|
|
||||||
$label = "";
|
|
||||||
if ($postoffice!="") $label.= "$postoffice\r\n";
|
|
||||||
if ($extended!="") $label.= "$extended\r\n";
|
|
||||||
if ($street!="") $label.= "$street\r\n";
|
|
||||||
if ($zip!="") $label.= "$zip ";
|
|
||||||
if ($city!="") $label.= "$city\r\n";
|
|
||||||
if ($region!="") $label.= "$region\r\n";
|
|
||||||
if ($country!="") $country.= "$country\r\n";
|
|
||||||
|
|
||||||
$this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief Mise en forme de l'email
|
|
||||||
\param address EMail
|
|
||||||
\param type Vcard type
|
|
||||||
*/
|
|
||||||
function setEmail($address,$type="internet,pref") {
|
|
||||||
$this->properties["EMAIL;TYPE=".$type] = $address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme de la note
|
|
||||||
\param note
|
|
||||||
*/
|
|
||||||
|
|
||||||
function setNote($note) {
|
|
||||||
$this->properties["NOTE;CHARSET=".$this->encoding] = encode($note);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme de la fonction
|
|
||||||
\param title
|
|
||||||
*/
|
|
||||||
function setTitle($title) {
|
|
||||||
$this->properties["TITLE;CHARSET=".$this->encoding] = encode($title);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme de la societe
|
|
||||||
\param org
|
|
||||||
*/
|
|
||||||
function setOrg($org) {
|
|
||||||
$this->properties["ORG;CHARSET=".$this->encoding] = encode($org);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme du logiciel generateur
|
|
||||||
\param prodid
|
|
||||||
*/
|
|
||||||
function setProdId($prodid) {
|
|
||||||
$this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme du logiciel generateur
|
|
||||||
\param uid
|
|
||||||
*/
|
|
||||||
function setUID($uid) {
|
|
||||||
$this->properties["UID;CHARSET=".$this->encoding] = encode($uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief mise en forme de l'url
|
|
||||||
\param url
|
|
||||||
\param type
|
|
||||||
*/
|
|
||||||
function setURL($url, $type="") {
|
|
||||||
// $type may be WORK | HOME
|
|
||||||
$key = "URL";
|
|
||||||
if ($type!="") $key.= ";$type";
|
|
||||||
$this->properties[$key] = $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief permet d'obtenir une vcard
|
|
||||||
*/
|
|
||||||
|
|
||||||
function getVCard() {
|
|
||||||
$text = "BEGIN:VCARD\r\n";
|
|
||||||
//$text.= "VERSION:3.0\r\n";
|
|
||||||
$text.= "VERSION:2.1\r\n";
|
|
||||||
foreach($this->properties as $key => $value) {
|
|
||||||
$text.= "$key:$value\r\n";
|
|
||||||
}
|
|
||||||
$text.= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n";
|
|
||||||
$text.= "MAILER:php vCard class by Kai Blankenhorn\r\n";
|
|
||||||
$text.= "END:VCARD\r\n";
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief permet d'obtenir le nom de fichier
|
|
||||||
*/
|
|
||||||
|
|
||||||
function getFileName() {
|
|
||||||
return $this->filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
Loading…
Reference in New Issue
Block a user