Skip to content

Commit

Permalink
Sur la branche master: v2.23 correct filed with carriage return
Browse files Browse the repository at this point in the history
  • Loading branch information
jpfox committed Mar 31, 2023
1 parent e9c0e4c commit ec59bc0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
18 changes: 17 additions & 1 deletion class/CardDAVDolibarr.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ protected function _contactToVCard($obj)
$address[]='';
$address[]='';

// remove carriage return in data
$objvars = get_object_vars($obj);
foreach ($objvars as $key => $value)
{
if(is_string($value))
$obj->$key = strtr(trim($value), array("\n"=>"\\n", "\r"=>""));
}

$carddata ="BEGIN:VCARD\n";
$carddata.="VERSION:3.0\n";
$carddata.="PRODID:-//Dolibarr CDav//FR\n";
Expand Down Expand Up @@ -398,7 +406,15 @@ protected function _thirdpartyToVCard($obj)
}
$address[]='';
$address[]='';


// remove carriage return in data
$objvars = get_object_vars($obj);
foreach ($objvars as $key => $value)
{
if(is_string($value))
$obj->$key = strtr(trim($value), array("\n"=>"\\n", "\r"=>""));
}

$carddata ="BEGIN:VCARD\n";
$carddata.="VERSION:3.0\n";
$carddata.="PRODID:-//Dolibarr CDav//FR\n";
Expand Down
2 changes: 1 addition & 1 deletion core/modules/modCDav.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function __construct($db)
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "Allows caldav and carddav clients to sync with Dolibarr.";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = '2.22';
$this->version = '2.23';
// Key used in llx_const table to save module status enabled/disabled (where CDAV is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
Expand Down
12 changes: 6 additions & 6 deletions lib/cdav.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ public function toVCalendar($calid, $obj, $bHeader)
$caldata.="UID:".$obj->id.'-ev-'./*$calid.'-cal-'.*/ CDAV_URI_KEY."\n";
else
$caldata.="UID:".$obj->sourceuid."\n";
$caldata.="SUMMARY:".$obj->label."\n";
$caldata.="SUMMARY:".strtr(trim($obj->label), array("\n"=>"\\n", "\r"=>""))."\n";
$caldata.="URL:".dol_buildpath("/comm/action/card.php?id=".$obj->id, 2)."\n";
$caldata.="LOCATION:".$location."\n";
$caldata.="LOCATION:".strtr(trim($location), array("\n"=>"\\n", "\r"=>""))."\n";
$caldata.="PRIORITY:".$obj->priority."\n";
if($obj->fulldayevent)
{
Expand Down Expand Up @@ -285,9 +285,9 @@ public function toVCalendar($calid, $obj, $bHeader)
if(!empty($obj->proj_desc))
$caldata.="💼⚠️ ".strtr(trim(strip_tags($obj->proj_desc)), array("\n"=>"\\n💼⚠️ ", "\r"=>""))."\\n";
if(!empty($obj->soc_town))
$caldata.="💼🏁 ".$obj->soc_town."\\n";
$caldata.="💼🏁 ".strtr(trim($obj->soc_town), array("\n"=>"\\n", "\r"=>""))."\\n";
if(!empty($obj->soc_nom))
$caldata.="💼🏢 ".$obj->soc_nom."\\n";
$caldata.="💼🏢 ".strtr(trim($obj->soc_nom), array("\n"=>"\\n", "\r"=>""))."\\n";
if(!empty($obj->soc_phone))
$caldata.="💼☎️ ".$obj->soc_phone."\\n";
if(!empty($obj->firstname) || !empty($obj->lastname))
Expand Down Expand Up @@ -336,9 +336,9 @@ public function toVCalendar($calid, $obj, $bHeader)
$caldata.="LAST-MODIFIED:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
$caldata.="DTSTAMP:".gmdate('Ymd\THis', strtotime($obj->lastupd))."Z\n";
$caldata.="UID:".$obj->id.'-'.$obj->elem_source.'-'./*$calid.'-cal-'.*/ CDAV_URI_KEY."\n";
$caldata.="SUMMARY:[".$obj->proj_title."]".$obj->label."\n";
$caldata.="SUMMARY:[".strtr(trim($obj->proj_title), array("\n"=>"\\n", "\r"=>""))."]".strtr(trim($obj->label), array("\n"=>"\\n", "\r"=>""))."\n";
$caldata.="URL:".dol_buildpath("/projet/tasks/task.php?id=".$obj->id."&withproject=".$obj->fk_projet,2)."\n";
$caldata.="LOCATION:".$location."\n";
$caldata.="LOCATION:".strtr(trim($location), array("\n"=>"\\n", "\r"=>""))."\n";
$caldata.="PRIORITY:".$obj->priority."\n";

$caldata.="DTSTART;TZID=".$timezone.":".strtr($obj->dateo,array(" "=>"T", ":"=>"", "-"=>""))."\n";
Expand Down

0 comments on commit ec59bc0

Please sign in to comment.