コード例 #1
0
ファイル: CalDAVDolibarr.php プロジェクト: Befox/cdav
 /**
  * Creates the backend
  *
  * @param user
  * @param db
  * @param langs
  */
 function __construct($user, $db, $langs, $cdavLib)
 {
     $this->user = $user;
     $this->db = $db;
     $this->langs = $langs;
     $this->cdavLib = $cdavLib;
     $this->langs->load("users");
     $this->langs->load("companies");
     $this->langs->load("agenda");
     $this->langs->load("commercial");
 }
コード例 #2
0
ファイル: CardDAVDolibarr.php プロジェクト: aternatik/cdav
 /**
  * Convert contact row to VCard string
  * 
  * @param row object
  * @return string
  */
 protected function _toVCard($obj)
 {
     $nick = [];
     $categ = [];
     if ($obj->soc_client) {
         $nick[] = $obj->soc_code_client;
         $categ[] = $this->langs->transnoentitiesnoconv('Customer');
     }
     if ($obj->soc_fournisseur) {
         $nick[] = $obj->soc_code_fournisseur;
         $categ[] = $this->langs->transnoentitiesnoconv('Supplier');
     }
     if (trim($obj->category_label) != '') {
         $categ[] = trim($obj->category_label);
     }
     if ($obj->priv) {
         $categ[] = $this->langs->transnoentitiesnoconv('ContactPrivate');
     } else {
         $categ[] = $this->langs->transnoentitiesnoconv('ContactPublic');
     }
     $soc_address = explode("\n", $obj->soc_address, 2);
     $soc_address[] = '';
     $soc_address[] = '';
     $address = explode("\n", $obj->address, 2);
     $address[] = '';
     $address[] = '';
     $carddata = "BEGIN:VCARD\n";
     $carddata .= "VERSION:3.0\n";
     $carddata .= "PRODID:-//Dolibarr CDav//FR\n";
     $carddata .= "UID:" . $obj->rowid . '-ct-' . CDAV_URI_KEY . "\n";
     $carddata .= "N;CHARSET=UTF-8:" . $obj->lastname . ";" . $obj->firstname . ";;" . $obj->civility . "\n";
     $carddata .= "FN;CHARSET=UTF-8:" . $obj->lastname . " " . $obj->firstname . "\n";
     $carddata .= "ORG;CHARSET=UTF-8:" . $obj->soc_nom . ";\n";
     $carddata .= "TITLE;CHARSET=UTF-8:" . $obj->poste . "\n";
     $carddata .= "CATEGORIES;CHARSET=UTF-8:" . implode(',', $categ) . "\n";
     $carddata .= "CLASS:" . ($obj->priv ? 'PRIVATE' : 'PUBLIC') . "\n";
     $carddata .= "ADR;TYPE=HOME;CHARSET=UTF-8:;" . $address[0] . ";" . $address[1] . ";" . $obj->town . ";;" . $obj->zip . ";" . $obj->country_label . "\n";
     $carddata .= "ADR;TYPE=WORK;CHARSET=UTF-8:;" . $soc_address[0] . ";" . $soc_address[1] . ";" . $obj->soc_town . ";;" . $obj->soc_zip . ";" . $obj->soc_country_label . "\n";
     $carddata .= "TEL;WORK;VOICE:" . $obj->phone . "\n";
     $carddata .= "TEL;HOME;VOICE:" . $obj->phone_perso . "\n";
     $carddata .= "TEL;CELL;VOICE:" . $obj->phone_mobile . "\n";
     $carddata .= "TEL;FAX:" . $obj->fax . "\n";
     $carddata .= "EMAIL;PREF;INTERNET:" . $obj->email . "\n";
     $carddata .= "EMAIL;INTERNET:" . $obj->soc_email . "\n";
     $carddata .= "X-JABBER:" . $obj->jabberid . "\n";
     $carddata .= "X-SKYPE:" . $obj->skype . "\n";
     $carddata .= "NOTE;CHARSET=UTF-8:" . strtr(trim($obj->note_public), array("\n" => "\\n* ", "\r" => "")) . "\n";
     $carddata .= "REV;TZID=" . date_default_timezone_get() . ":" . strtr($obj->lastupd, array(" " => "T", ":" => "", "-" => "")) . "\n";
     $carddata .= "END:VCARD\n";
     return $carddata;
 }
コード例 #3
0
ファイル: CardDAVDolibarr.php プロジェクト: Befox/cdav
 /**
  * Convert contact row to VCard string
  * 
  * @param row object
  * @return string
  */
 protected function _toVCard($obj)
 {
     global $conf;
     $nick = [];
     $categ = [];
     if ($obj->soc_client) {
         $nick[] = $obj->soc_code_client;
         $categ[] = $this->langs->transnoentitiesnoconv('Customer');
     }
     if ($obj->soc_fournisseur) {
         $nick[] = $obj->soc_code_fournisseur;
         $categ[] = $this->langs->transnoentitiesnoconv('Supplier');
     }
     if ($obj->priv) {
         $categ[] = $this->langs->transnoentitiesnoconv('ContactPrivate');
     } else {
         $categ[] = $this->langs->transnoentitiesnoconv('ContactPublic');
     }
     if (!empty($conf->categorie->enabled) && !empty($this->user->rights->categorie->lire)) {
         if (trim($obj->category_label) != '') {
             $categ[] = trim($obj->category_label);
         }
     }
     $soc_address = explode("\n", $obj->soc_address, 2);
     foreach ($soc_address as $kAddr => $vAddr) {
         $soc_address[$kAddr] = trim(str_replace(array("\r", "\t"), ' ', str_replace("\n", ' | ', trim($vAddr))));
     }
     $soc_address[] = '';
     $soc_address[] = '';
     $address = explode("\n", $obj->address, 2);
     foreach ($address as $kAddr => $vAddr) {
         $address[$kAddr] = trim(str_replace(array("\r", "\t"), ' ', str_replace("\n", ' | ', trim($vAddr))));
     }
     $address[] = '';
     $address[] = '';
     $carddata = "BEGIN:VCARD\n";
     $carddata .= "VERSION:3.0\n";
     $carddata .= "PRODID:-//Dolibarr CDav//FR\n";
     $carddata .= "UID:" . $obj->rowid . '-ct-' . CDAV_URI_KEY . "\n";
     $carddata .= "N;CHARSET=UTF-8:" . str_replace(';', '\\;', $obj->lastname) . ";" . str_replace(';', '\\;', $obj->firstname) . ";;" . str_replace(';', '\\;', $obj->civility) . "\n";
     $carddata .= "FN;CHARSET=UTF-8:" . str_replace(';', '\\;', $obj->lastname . " " . $obj->firstname) . "\n";
     if (!empty($obj->soc_nom)) {
         $carddata .= "ORG;CHARSET=UTF-8:" . str_replace(';', '\\;', $obj->soc_nom) . ";\n";
     }
     if (!empty($obj->poste)) {
         $carddata .= "TITLE;CHARSET=UTF-8:" . str_replace(';', '\\;', $obj->poste) . "\n";
     }
     if (count($categ) > 0) {
         $carddata .= "CATEGORIES;CHARSET=UTF-8:" . str_replace(';', '\\;', implode(',', $categ)) . "\n";
     }
     $carddata .= "CLASS:" . ($obj->priv ? 'PRIVATE' : 'PUBLIC') . "\n";
     $carddata .= "ADR;TYPE=HOME;CHARSET=UTF-8:;" . str_replace(';', '\\;', $address[1]) . ";" . str_replace(';', '\\;', $address[0]) . ";";
     $carddata .= str_replace(';', '\\;', $obj->town) . ";;" . str_replace(';', '\\;', $obj->zip) . ";" . str_replace(';', '\\;', $obj->country_label) . "\n";
     $carddata .= "ADR;TYPE=WORK;CHARSET=UTF-8:;" . str_replace(';', '\\;', $soc_address[1]) . ";" . str_replace(';', '\\;', $soc_address[0]) . ";";
     $carddata .= str_replace(';', '\\;', $obj->soc_town) . ";;" . str_replace(';', '\\;', $obj->soc_zip) . ";" . str_replace(';', '\\;', $obj->soc_country_label) . "\n";
     $carddata .= "TEL;TYPE=WORK,VOICE:" . str_replace(';', '\\;', trim($obj->phone) == '' ? $obj->soc_phone : $obj->phone) . "\n";
     if (!empty($obj->phone_perso)) {
         $carddata .= "TEL;TYPE=HOME,VOICE:" . str_replace(';', '\\;', $obj->phone_perso) . "\n";
     }
     if (!empty($obj->phone_mobile)) {
         $carddata .= "TEL;TYPE=CELL,VOICE:" . str_replace(';', '\\;', $obj->phone_mobile) . "\n";
     }
     if (!empty($obj->soc_fax)) {
         $carddata .= "TEL;TYPE=WORK,FAX:" . str_replace(';', '\\;', $obj->soc_fax) . "\n";
     }
     if (!empty($obj->fax)) {
         $carddata .= "TEL;TYPE=HOME,FAX:" . str_replace(';', '\\;', $obj->fax) . "\n";
     }
     if (!empty($obj->email)) {
         $carddata .= "EMAIL;PREF=1,INTERNET:" . str_replace(';', '\\;', $obj->email) . "\n";
     }
     if (!empty($obj->soc_email)) {
         $carddata .= "EMAIL;INTERNET:" . str_replace(';', '\\;', $obj->soc_email) . "\n";
     }
     if (!empty($obj->jabberid)) {
         $carddata .= "X-JABBER:" . str_replace(';', '\\;', $obj->jabberid) . "\n";
     }
     if (!empty($obj->skype)) {
         $carddata .= "X-SKYPE:" . str_replace(';', '\\;', $obj->skype) . "\n";
     }
     if (!empty($obj->birthday)) {
         $carddata .= "BDAY:" . str_replace(';', '\\;', $obj->birthday) . "\n";
     }
     if (!empty($obj->note_public)) {
         $carddata .= "NOTE;CHARSET=UTF-8:" . str_replace(';', '\\;', strtr(trim($obj->note_public), array("\n" => "\\n", "\r" => ""))) . "\n";
     }
     $carddata .= "REV;TZID=" . date_default_timezone_get() . ":" . strtr($obj->lastupd, array(" " => "T", ":" => "", "-" => "")) . "\n";
     $carddata .= "END:VCARD\n";
     return $carddata;
 }