@@ -53,7 +53,9 @@ discard block |
||
53 | 53 | $dolmemcache=new Memcached(); |
54 | 54 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
55 | 55 | $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
56 | - if (! $result) return -1; |
|
56 | + if (! $result) { |
|
57 | + return -1; |
|
58 | + } |
|
57 | 59 | } |
58 | 60 | |
59 | 61 | $memoryid=session_name().'_'.$memoryid; |
@@ -63,13 +65,11 @@ discard block |
||
63 | 65 | if ($rescode == 0) |
64 | 66 | { |
65 | 67 | return count($data); |
66 | - } |
|
67 | - else |
|
68 | + } else |
|
68 | 69 | { |
69 | 70 | return -$rescode; |
70 | 71 | } |
71 | - } |
|
72 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
72 | + } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
73 | 73 | { |
74 | 74 | global $dolmemcache; |
75 | 75 | if (empty($dolmemcache) || ! is_object($dolmemcache)) |
@@ -77,7 +77,9 @@ discard block |
||
77 | 77 | $dolmemcache=new Memcache(); |
78 | 78 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
79 | 79 | $result=$dolmemcache->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
80 | - if (! $result) return -1; |
|
80 | + if (! $result) { |
|
81 | + return -1; |
|
82 | + } |
|
81 | 83 | } |
82 | 84 | |
83 | 85 | $memoryid=session_name().'_'.$memoryid; |
@@ -86,8 +88,7 @@ discard block |
||
86 | 88 | if ($result) |
87 | 89 | { |
88 | 90 | return count($data); |
89 | - } |
|
90 | - else |
|
91 | + } else |
|
91 | 92 | { |
92 | 93 | return -1; |
93 | 94 | } |
@@ -120,7 +121,9 @@ discard block |
||
120 | 121 | $m=new Memcached(); |
121 | 122 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
122 | 123 | $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
123 | - if (! $result) return -1; |
|
124 | + if (! $result) { |
|
125 | + return -1; |
|
126 | + } |
|
124 | 127 | } |
125 | 128 | |
126 | 129 | $memoryid=session_name().'_'.$memoryid; |
@@ -133,13 +136,11 @@ discard block |
||
133 | 136 | if ($rescode == 0) |
134 | 137 | { |
135 | 138 | return $data; |
136 | - } |
|
137 | - else |
|
139 | + } else |
|
138 | 140 | { |
139 | 141 | return -$rescode; |
140 | 142 | } |
141 | - } |
|
142 | - else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
143 | + } else if (! empty($conf->memcached->enabled) && class_exists('Memcache')) |
|
143 | 144 | { |
144 | 145 | global $m; |
145 | 146 | if (empty($m) || ! is_object($m)) |
@@ -147,7 +148,9 @@ discard block |
||
147 | 148 | $m=new Memcache(); |
148 | 149 | $tmparray=explode(':',$conf->global->MEMCACHED_SERVER); |
149 | 150 | $result=$m->addServer($tmparray[0], $tmparray[1]?$tmparray[1]:11211); |
150 | - if (! $result) return -1; |
|
151 | + if (! $result) { |
|
152 | + return -1; |
|
153 | + } |
|
151 | 154 | } |
152 | 155 | |
153 | 156 | $memoryid=session_name().'_'.$memoryid; |
@@ -158,8 +161,7 @@ discard block |
||
158 | 161 | if ($data) |
159 | 162 | { |
160 | 163 | return $data; |
161 | - } |
|
162 | - else |
|
164 | + } else |
|
163 | 165 | { |
164 | 166 | return -1; |
165 | 167 | } |
@@ -185,7 +187,9 @@ discard block |
||
185 | 187 | function dol_getshmopaddress($memoryid) |
186 | 188 | { |
187 | 189 | global $shmkeys,$shmoffset; |
188 | - if (empty($shmkeys[$memoryid])) return 0; |
|
190 | + if (empty($shmkeys[$memoryid])) { |
|
191 | + return 0; |
|
192 | + } |
|
189 | 193 | return $shmkeys[$memoryid]+$shmoffset; |
190 | 194 | } |
191 | 195 | |
@@ -202,7 +206,9 @@ discard block |
||
202 | 206 | foreach($shmkeys as $key => $val) |
203 | 207 | { |
204 | 208 | $result=dol_getshmop($key); |
205 | - if (! is_numeric($result) || $result > 0) $resarray[$key]=$result; |
|
209 | + if (! is_numeric($result) || $result > 0) { |
|
210 | + $resarray[$key]=$result; |
|
211 | + } |
|
206 | 212 | } |
207 | 213 | return $resarray; |
208 | 214 | } |
@@ -219,7 +225,9 @@ discard block |
||
219 | 225 | global $shmkeys,$shmoffset; |
220 | 226 | |
221 | 227 | //print 'dol_setshmop memoryid='.$memoryid."<br>\n"; |
222 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) return 0; |
|
228 | + if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_write")) { |
|
229 | + return 0; |
|
230 | + } |
|
223 | 231 | $shmkey=dol_getshmopaddress($memoryid); |
224 | 232 | $newdata=serialize($data); |
225 | 233 | $size=strlen($newdata); |
@@ -235,8 +243,7 @@ discard block |
||
235 | 243 | } |
236 | 244 | shmop_close($handle); |
237 | 245 | return ($shm_bytes_written1+$shm_bytes_written2); |
238 | - } |
|
239 | - else |
|
246 | + } else |
|
240 | 247 | { |
241 | 248 | print 'Error in shmop_open for memoryid='.$memoryid.' shmkey='.$shmkey.' 6+size=6+'.$size; |
242 | 249 | return -1; |
@@ -253,18 +260,22 @@ discard block |
||
253 | 260 | { |
254 | 261 | global $shmkeys,$shmoffset; |
255 | 262 | |
256 | - if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) return 0; |
|
263 | + if (empty($shmkeys[$memoryid]) || ! function_exists("shmop_open")) { |
|
264 | + return 0; |
|
265 | + } |
|
257 | 266 | $shmkey=dol_getshmopaddress($memoryid); |
258 | 267 | //print 'dol_getshmop memoryid='.$memoryid." shmkey=".$shmkey."<br>\n"; |
259 | 268 | $handle=@shmop_open($shmkey,'a',0,0); |
260 | 269 | if ($handle) |
261 | 270 | { |
262 | 271 | $size=trim(shmop_read($handle,0,6)); |
263 | - if ($size) $data=unserialize(shmop_read($handle,6,$size)); |
|
264 | - else return -1; |
|
272 | + if ($size) { |
|
273 | + $data=unserialize(shmop_read($handle,6,$size)); |
|
274 | + } else { |
|
275 | + return -1; |
|
276 | + } |
|
265 | 277 | shmop_close($handle); |
266 | - } |
|
267 | - else |
|
278 | + } else |
|
268 | 279 | { |
269 | 280 | return -2; |
270 | 281 | } |
@@ -38,7 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | dol_syslog("xcal.lib.php::build_calfile Build cal file ".$outputfile." to format ".$format); |
40 | 40 | |
41 | - if (empty($outputfile)) return -1; |
|
41 | + if (empty($outputfile)) { |
|
42 | + return -1; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Note: A cal file is an UTF8 encoded file |
44 | 46 | $calfileh=fopen($outputfile,'w'); |
@@ -48,7 +50,9 @@ discard block |
||
48 | 50 | $now=dol_now(); |
49 | 51 | |
50 | 52 | $encoding=''; |
51 | - if ($format == 'vcal') $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
53 | + if ($format == 'vcal') { |
|
54 | + $encoding='ENCODING=QUOTED-PRINTABLE:'; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | // Print header |
54 | 58 | fwrite($calfileh,"BEGIN:VCALENDAR\n"); |
@@ -152,8 +156,12 @@ discard block |
||
152 | 156 | fwrite($calfileh,"URL:".$url."\n"); |
153 | 157 | }; |
154 | 158 | |
155 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
156 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
159 | + if ($created) { |
|
160 | + fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
161 | + } |
|
162 | + if ($modified) { |
|
163 | + fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
164 | + } |
|
157 | 165 | fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
158 | 166 | fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
159 | 167 | |
@@ -178,9 +186,15 @@ discard block |
||
178 | 186 | //fwrite($calfileh,"X-MICROSOFT-CDO-BUSYSTATUS:1\n"); |
179 | 187 | //ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=Laurent Destailleur;X-NUM-GUESTS=0:mailto:[email protected] |
180 | 188 | |
181 | - if (! empty($location)) fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
182 | - if ($fulldayevent) fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
183 | - if ($fulldayevent) fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
189 | + if (! empty($location)) { |
|
190 | + fwrite($calfileh,"LOCATION:".$encoding.$location."\n"); |
|
191 | + } |
|
192 | + if ($fulldayevent) { |
|
193 | + fwrite($calfileh,"X-FUNAMBOL-ALLDAY:1\n"); |
|
194 | + } |
|
195 | + if ($fulldayevent) { |
|
196 | + fwrite($calfileh,"X-MICROSOFT-CDO-ALLDAYEVENT:1\n"); |
|
197 | + } |
|
184 | 198 | |
185 | 199 | // Date must be GMT dates |
186 | 200 | // Current date |
@@ -197,11 +211,14 @@ discard block |
||
197 | 211 | // End date |
198 | 212 | if ($fulldayevent) |
199 | 213 | { |
200 | - if (empty($enddate)) $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
201 | - } |
|
202 | - else |
|
214 | + if (empty($enddate)) { |
|
215 | + $enddate=dol_time_plus_duree($startdate,1,'d'); |
|
216 | + } |
|
217 | + } else |
|
203 | 218 | { |
204 | - if (empty($enddate)) $enddate=$startdate+$duration; |
|
219 | + if (empty($enddate)) { |
|
220 | + $enddate=$startdate+$duration; |
|
221 | + } |
|
205 | 222 | } |
206 | 223 | $prefix=''; |
207 | 224 | $enddatef = dol_print_date($enddate,'dayhourxcard',true); |
@@ -213,8 +230,12 @@ discard block |
||
213 | 230 | } |
214 | 231 | fwrite($calfileh,"DTEND".$prefix.":".$enddatef."\n"); |
215 | 232 | fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
216 | - if (! empty($transparency)) fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
217 | - if (! empty($category)) fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
233 | + if (! empty($transparency)) { |
|
234 | + fwrite($calfileh,"TRANSP:".$transparency."\n"); |
|
235 | + } |
|
236 | + if (! empty($category)) { |
|
237 | + fwrite($calfileh,"CATEGORIES:".$encoding.$category."\n"); |
|
238 | + } |
|
218 | 239 | fwrite($calfileh,"END:VEVENT\n"); |
219 | 240 | } |
220 | 241 | |
@@ -237,8 +258,12 @@ discard block |
||
237 | 258 | fwrite($calfileh,"URL:".$url."\n"); |
238 | 259 | }; |
239 | 260 | |
240 | - if ($created) fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
241 | - if ($modified) fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
261 | + if ($created) { |
|
262 | + fwrite($calfileh,"CREATED:".dol_print_date($created,'dayhourxcard',true)."\n"); |
|
263 | + } |
|
264 | + if ($modified) { |
|
265 | + fwrite($calfileh,"LAST-MODIFIED:".dol_print_date($modified,'dayhourxcard',true)."\n"); |
|
266 | + } |
|
242 | 267 | fwrite($calfileh,"SUMMARY:".$encoding.$summary."\n"); |
243 | 268 | fwrite($calfileh,"DESCRIPTION:".$encoding.$description."\n"); |
244 | 269 | fwrite($calfileh,'STATUS:CONFIRMED'."\n"); |
@@ -270,10 +295,10 @@ discard block |
||
270 | 295 | fwrite($calfileh,"END:VCALENDAR"); |
271 | 296 | |
272 | 297 | fclose($calfileh); |
273 | - if (! empty($conf->global->MAIN_UMASK)) |
|
274 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
275 | - } |
|
276 | - else |
|
298 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
299 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
300 | + } |
|
301 | + } else |
|
277 | 302 | { |
278 | 303 | dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); |
279 | 304 | return -2; |
@@ -299,7 +324,9 @@ discard block |
||
299 | 324 | |
300 | 325 | dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); |
301 | 326 | |
302 | - if (empty($outputfile)) return -1; |
|
327 | + if (empty($outputfile)) { |
|
328 | + return -1; |
|
329 | + } |
|
303 | 330 | |
304 | 331 | $fichier=fopen($outputfile,'w'); |
305 | 332 | if ($fichier) |
@@ -367,7 +394,9 @@ discard block |
||
367 | 394 | fwrite($fichier, "<author><![CDATA[".$author."]]></author>\n"); |
368 | 395 | fwrite($fichier, "<category><![CDATA[".$category."]]></category>\n"); |
369 | 396 | fwrite($fichier, "<description><![CDATA["); |
370 | - if ($description) fwrite($fichier, $description); |
|
397 | + if ($description) { |
|
398 | + fwrite($fichier, $description); |
|
399 | + } |
|
371 | 400 | //else fwrite($fichier, 'NoDesc'); |
372 | 401 | fwrite($fichier, "]]></description>\n"); |
373 | 402 | fwrite($fichier, "<pubDate>".date("r", $startdate)."</pubDate>\n"); |
@@ -382,8 +411,9 @@ discard block |
||
382 | 411 | fwrite($fichier, '</rss>'); |
383 | 412 | |
384 | 413 | fclose($fichier); |
385 | - if (! empty($conf->global->MAIN_UMASK)) |
|
386 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
414 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
415 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
416 | + } |
|
387 | 417 | } |
388 | 418 | } |
389 | 419 | |
@@ -447,8 +477,7 @@ discard block |
||
447 | 477 | $newpara .= $char; |
448 | 478 | } |
449 | 479 | $out .= $newpara; |
450 | - } |
|
451 | - else |
|
480 | + } else |
|
452 | 481 | { |
453 | 482 | $strlength=dol_strlen($line); |
454 | 483 | for ($j = 0; $j <= ($strlength - 1); $j++) |
@@ -491,13 +520,20 @@ discard block |
||
491 | 520 | $char = substr($line, $j, 1); |
492 | 521 | $ascii = ord($char); |
493 | 522 | |
494 | - if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) |
|
495 | - $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
523 | + if ( $ascii < 32 || $ascii == 61 || $ascii > 126 ) { |
|
524 | + $char = '=' . strtoupper(sprintf("%02X", $ascii)); |
|
525 | + } |
|
496 | 526 | |
497 | - if ((strlen($newpara) + strlen($char)) >= 76 ) // Do not use dol_strlen here, we need number of bytes |
|
527 | + if ((strlen($newpara) + strlen($char)) >= 76 ) { |
|
528 | + // Do not use dol_strlen here, we need number of bytes |
|
498 | 529 | { |
499 | - $out .= $newpara . '=' . "\r\n"; // CRLF |
|
500 | - if ($forcal) $out .= " "; // + Space for cal |
|
530 | + $out .= $newpara . '=' . "\r\n"; |
|
531 | + } |
|
532 | + // CRLF |
|
533 | + if ($forcal) { |
|
534 | + $out .= " "; |
|
535 | + } |
|
536 | + // + Space for cal |
|
501 | 537 | $newpara = ''; |
502 | 538 | } |
503 | 539 | $newpara .= $char; |
@@ -81,7 +81,9 @@ |
||
81 | 81 | $nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); |
82 | 82 | $head[$h][0] = DOL_URL_ROOT.'/ticket/contact.php?track_id='.$object->track_id; |
83 | 83 | $head[$h][1] = $langs->trans('ContactsAddresses'); |
84 | - if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
84 | + if ($nbContact > 0) { |
|
85 | + $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>'; |
|
86 | + } |
|
85 | 87 | $head[$h][2] = 'contact'; |
86 | 88 | $h++; |
87 | 89 | } |
@@ -103,7 +103,9 @@ discard block |
||
103 | 103 | print '<br>'; |
104 | 104 | |
105 | 105 | $logintouse = 'firstadmin'; |
106 | - if ($user->admin) $logintouse = $user->login; |
|
106 | + if ($user->admin) { |
|
107 | + $logintouse = $user->login; |
|
108 | + } |
|
107 | 109 | |
108 | 110 | print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>'; |
109 | 111 | |
@@ -115,16 +117,19 @@ discard block |
||
115 | 117 | if (empty($conf->global->CRON_DISABLE_TUTORIAL_CRON)) |
116 | 118 | { |
117 | 119 | $linuxlike=1; |
118 | - if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; |
|
119 | - if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; |
|
120 | + if (preg_match('/^win/i',PHP_OS)) { |
|
121 | + $linuxlike=0; |
|
122 | + } |
|
123 | + if (preg_match('/^mac/i',PHP_OS)) { |
|
124 | + $linuxlike=0; |
|
125 | + } |
|
120 | 126 | print $langs->trans("Note").': '; |
121 | 127 | if ($linuxlike) |
122 | 128 | { |
123 | 129 | print $langs->trans("CronExplainHowToRunUnix"); |
124 | 130 | print '<br>'; |
125 | 131 | print '<textarea class="quatrevingtpercent">*/5 * * * * pathtoscript/scripts/cron/cron_run_jobs.php '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$logintouse.' > '.DOL_DATA_ROOT.'/cron_run_jobs.php.log</textarea><br>'; |
126 | - } |
|
127 | - else |
|
132 | + } else |
|
128 | 133 | { |
129 | 134 | print $langs->trans("CronExplainHowToRunWin"); |
130 | 135 | } |
@@ -42,11 +42,15 @@ discard block |
||
42 | 42 | { |
43 | 43 | global $langs; |
44 | 44 | |
45 | - if (empty($hselected)) $hselected='report'; |
|
45 | + if (empty($hselected)) { |
|
46 | + $hselected='report'; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | print "\n\n<!-- start banner of report -->\n"; |
48 | 50 | |
49 | - if(! empty($varlink)) $varlink = '?'.$varlink; |
|
51 | + if(! empty($varlink)) { |
|
52 | + $varlink = '?'.$varlink; |
|
53 | + } |
|
50 | 54 | |
51 | 55 | $h=0; |
52 | 56 | $head[$h][0] = $_SERVER["PHP_SELF"].$varlink; |
@@ -71,7 +75,9 @@ discard block |
||
71 | 75 | print '<td>'; |
72 | 76 | print $reportname; |
73 | 77 | print '</td>'; |
74 | - if ($variante) print '<td></td>'; |
|
78 | + if ($variante) { |
|
79 | + print '<td></td>'; |
|
80 | + } |
|
75 | 81 | print '</tr>'; |
76 | 82 | |
77 | 83 | // Calculation mode |
@@ -81,7 +87,9 @@ discard block |
||
81 | 87 | print '<td width="110">'.$langs->trans("CalculationMode").'</td>'; |
82 | 88 | print '<td>'; |
83 | 89 | print $calcmode; |
84 | - if ($variante) print '<td></td>'; |
|
90 | + if ($variante) { |
|
91 | + print '<td></td>'; |
|
92 | + } |
|
85 | 93 | print '</td>'; |
86 | 94 | print '</tr>'; |
87 | 95 | } |
@@ -90,8 +98,12 @@ discard block |
||
90 | 98 | print '<tr>'; |
91 | 99 | print '<td>'.$langs->trans("ReportPeriod").'</td>'; |
92 | 100 | print '<td>'; |
93 | - if ($period) print $period; |
|
94 | - if ($variante) print '<td class="nowraponall">'.$periodlink.'</td>'; |
|
101 | + if ($period) { |
|
102 | + print $period; |
|
103 | + } |
|
104 | + if ($variante) { |
|
105 | + print '<td class="nowraponall">'.$periodlink.'</td>'; |
|
106 | + } |
|
95 | 107 | print '</td>'; |
96 | 108 | print '</tr>'; |
97 | 109 | |
@@ -99,7 +111,9 @@ discard block |
||
99 | 111 | print '<tr>'; |
100 | 112 | print '<td>'.$langs->trans("ReportDescription").'</td>'; |
101 | 113 | print '<td>'.$description.'</td>'; |
102 | - if ($variante) print '<td></td>'; |
|
114 | + if ($variante) { |
|
115 | + print '<td></td>'; |
|
116 | + } |
|
103 | 117 | print '</tr>'; |
104 | 118 | |
105 | 119 | // Ligne d'export |
@@ -108,7 +122,9 @@ discard block |
||
108 | 122 | print '<td>'; |
109 | 123 | print dol_print_date($builddate, 'dayhour'); |
110 | 124 | print '</td>'; |
111 | - if ($variante) print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>'; |
|
125 | + if ($variante) { |
|
126 | + print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>'; |
|
127 | + } |
|
112 | 128 | print '</tr>'; |
113 | 129 | |
114 | 130 | print '</table>'; |
@@ -76,9 +76,15 @@ discard block |
||
76 | 76 | $listofnames=array(); |
77 | 77 | $listofmimes=array(); |
78 | 78 | $keytoavoidconflict = empty($trackid)?'':'-'.$trackid; |
79 | - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
80 | - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
81 | - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
79 | + if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) { |
|
80 | + $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); |
|
81 | + } |
|
82 | + if (! empty($_SESSION["listofnames".$keytoavoidconflict])) { |
|
83 | + $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); |
|
84 | + } |
|
85 | + if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) { |
|
86 | + $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); |
|
87 | + } |
|
82 | 88 | |
83 | 89 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; |
84 | 90 | $formmail = new FormMail($db); |
@@ -102,7 +108,9 @@ discard block |
||
102 | 108 | */ |
103 | 109 | if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_POST['removAll'] && ! $_POST['removedfile'] && ! $_POST['cancel'] && !$_POST['modelselected']) |
104 | 110 | { |
105 | - if (empty($trackid)) $trackid = GETPOST('trackid','aZ09'); |
|
111 | + if (empty($trackid)) { |
|
112 | + $trackid = GETPOST('trackid','aZ09'); |
|
113 | + } |
|
106 | 114 | |
107 | 115 | $subject='';$actionmsg='';$actionmsg2=''; |
108 | 116 | |
@@ -116,34 +124,42 @@ discard block |
||
116 | 124 | if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user','expensereport', 'contact'))) |
117 | 125 | { |
118 | 126 | $result=$object->fetch_thirdparty(); |
119 | - if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok |
|
127 | + if ($object->element == 'user' && $result == 0) { |
|
128 | + $result=1; |
|
129 | + } |
|
130 | + // Even if not found, we consider ok |
|
120 | 131 | $thirdparty=$object->thirdparty; |
121 | 132 | $sendtosocid=$thirdparty->id; |
122 | - } |
|
123 | - else if ($object->element == 'member' || $object->element == 'user') |
|
133 | + } else if ($object->element == 'member' || $object->element == 'user') |
|
124 | 134 | { |
125 | 135 | $thirdparty=$object; |
126 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
127 | - } |
|
128 | - else if ($object->element == 'societe') |
|
136 | + if ($thirdparty->id > 0) { |
|
137 | + $sendtosocid=$thirdparty->id; |
|
138 | + } |
|
139 | + } else if ($object->element == 'societe') |
|
129 | 140 | { |
130 | 141 | $thirdparty=$object; |
131 | - if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; |
|
132 | - } |
|
133 | - else if ($object->element == 'contact') |
|
142 | + if ($thirdparty->id > 0) { |
|
143 | + $sendtosocid=$thirdparty->id; |
|
144 | + } |
|
145 | + } else if ($object->element == 'contact') |
|
134 | 146 | { |
135 | 147 | $contact=$object; |
136 | - if ($contact->id > 0) $sendtosocid=$contact->fetch_thirdparty()->id; |
|
148 | + if ($contact->id > 0) { |
|
149 | + $sendtosocid=$contact->fetch_thirdparty()->id; |
|
150 | + } |
|
151 | + } else { |
|
152 | + dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); |
|
137 | 153 | } |
138 | - else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); |
|
139 | 154 | |
140 | 155 | if (is_object($hookmanager)) |
141 | 156 | { |
142 | 157 | $parameters=array(); |
143 | 158 | $reshook=$hookmanager->executeHooks('initSendToSocid',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
144 | 159 | } |
160 | + } else { |
|
161 | + $thirdparty = $mysoc; |
|
145 | 162 | } |
146 | - else $thirdparty = $mysoc; |
|
147 | 163 | |
148 | 164 | if ($result > 0) |
149 | 165 | { |
@@ -158,8 +174,11 @@ discard block |
||
158 | 174 | $receiver=$_POST['receiver']; |
159 | 175 | if (! is_array($receiver)) |
160 | 176 | { |
161 | - if ($receiver == '-1') $receiver=array(); |
|
162 | - else $receiver=array($receiver); |
|
177 | + if ($receiver == '-1') { |
|
178 | + $receiver=array(); |
|
179 | + } else { |
|
180 | + $receiver=array($receiver); |
|
181 | + } |
|
163 | 182 | } |
164 | 183 | $tmparray=array(); |
165 | 184 | if (trim($_POST['sendto'])) |
@@ -172,18 +191,23 @@ discard block |
||
172 | 191 | foreach($receiver as $key=>$val) |
173 | 192 | { |
174 | 193 | // Recipient was provided from combo list |
175 | - if ($val == 'thirdparty') // Id of third party |
|
194 | + if ($val == 'thirdparty') { |
|
195 | + // Id of third party |
|
176 | 196 | { |
177 | 197 | $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
178 | 198 | } |
199 | + } |
|
179 | 200 | // Recipient was provided from combo list |
180 | - elseif ($val == 'contact') // Id of contact |
|
201 | + elseif ($val == 'contact') { |
|
202 | + // Id of contact |
|
181 | 203 | { |
182 | 204 | $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
183 | 205 | } |
184 | - elseif ($val) // Id du contact |
|
206 | + } elseif ($val) { |
|
207 | + // Id du contact |
|
185 | 208 | { |
186 | 209 | $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
210 | + } |
|
187 | 211 | $sendtoid[] = $val; |
188 | 212 | } |
189 | 213 | } |
@@ -208,8 +232,11 @@ discard block |
||
208 | 232 | $receivercc=$_POST['receivercc']; |
209 | 233 | if (! is_array($receivercc)) |
210 | 234 | { |
211 | - if ($receivercc == '-1') $receivercc=array(); |
|
212 | - else $receivercc=array($receivercc); |
|
235 | + if ($receivercc == '-1') { |
|
236 | + $receivercc=array(); |
|
237 | + } else { |
|
238 | + $receivercc=array($receivercc); |
|
239 | + } |
|
213 | 240 | } |
214 | 241 | $tmparray=array(); |
215 | 242 | if (trim($_POST['sendtocc'])) |
@@ -221,18 +248,23 @@ discard block |
||
221 | 248 | foreach($receivercc as $key=>$val) |
222 | 249 | { |
223 | 250 | // Recipient was provided from combo list |
224 | - if ($val == 'thirdparty') // Id of third party |
|
251 | + if ($val == 'thirdparty') { |
|
252 | + // Id of third party |
|
225 | 253 | { |
226 | 254 | $tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>'; |
227 | 255 | } |
256 | + } |
|
228 | 257 | // Recipient was provided from combo list |
229 | - elseif ($val == 'contact') // Id of contact |
|
258 | + elseif ($val == 'contact') { |
|
259 | + // Id of contact |
|
230 | 260 | { |
231 | 261 | $tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>'; |
232 | 262 | } |
233 | - elseif ($val) // Id du contact |
|
263 | + } elseif ($val) { |
|
264 | + // Id du contact |
|
234 | 265 | { |
235 | 266 | $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); |
267 | + } |
|
236 | 268 | //$sendtoid[] = $val; TODO Add also id of contact in CC ? |
237 | 269 | } |
238 | 270 | } |
@@ -266,22 +298,17 @@ discard block |
||
266 | 298 | $fromtype = GETPOST('fromtype','alpha'); |
267 | 299 | if ($fromtype === 'robot') { |
268 | 300 | $from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")) .' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; |
269 | - } |
|
270 | - elseif ($fromtype === 'user') { |
|
301 | + } elseif ($fromtype === 'user') { |
|
271 | 302 | $from = dol_string_nospecial($user->getFullName($langs), ' ', array(",")) .' <'.$user->email.'>'; |
272 | - } |
|
273 | - elseif ($fromtype === 'company') { |
|
303 | + } elseif ($fromtype === 'company') { |
|
274 | 304 | $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")) .' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>'; |
275 | - } |
|
276 | - elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
|
305 | + } elseif (preg_match('/user_aliases_(\d+)/', $fromtype, $reg)) { |
|
277 | 306 | $tmp=explode(',', $user->email_aliases); |
278 | 307 | $from = trim($tmp[($reg[1] - 1)]); |
279 | - } |
|
280 | - elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
|
308 | + } elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) { |
|
281 | 309 | $tmp=explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); |
282 | 310 | $from = trim($tmp[($reg[1] - 1)]); |
283 | - } |
|
284 | - elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
|
311 | + } elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) { |
|
285 | 312 | $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1]; |
286 | 313 | $resql = $db->query($sql); |
287 | 314 | $obj = $db->fetch_object($resql); |
@@ -289,8 +316,7 @@ discard block |
||
289 | 316 | { |
290 | 317 | $from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>'; |
291 | 318 | } |
292 | - } |
|
293 | - else { |
|
319 | + } else { |
|
294 | 320 | $from = dol_string_nospecial($_POST['fromname'], ' ', array(",")) . ' <' . $_POST['frommail'] .'>'; |
295 | 321 | } |
296 | 322 | |
@@ -321,7 +347,9 @@ discard block |
||
321 | 347 | { |
322 | 348 | $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); |
323 | 349 | $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); |
324 | - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); |
|
350 | + if ($sendtocc) { |
|
351 | + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); |
|
352 | + } |
|
325 | 353 | $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); |
326 | 354 | $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); |
327 | 355 | $actionmsg = dol_concatdesc($actionmsg, $message); |
@@ -400,15 +428,16 @@ discard block |
||
400 | 428 | } |
401 | 429 | |
402 | 430 | // Send mail (substitutionarray must be done just before this) |
403 | - if (empty($sendcontext)) $sendcontext = 'standard'; |
|
431 | + if (empty($sendcontext)) { |
|
432 | + $sendcontext = 'standard'; |
|
433 | + } |
|
404 | 434 | $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid,'', $sendcontext); |
405 | 435 | |
406 | 436 | if ($mailfile->error) |
407 | 437 | { |
408 | 438 | setEventMessages($mailfile->error, $mailfile->errors, 'errors'); |
409 | 439 | $action='presend'; |
410 | - } |
|
411 | - else |
|
440 | + } else |
|
412 | 441 | { |
413 | 442 | $result=$mailfile->sendfile(); |
414 | 443 | if ($result) |
@@ -437,7 +466,10 @@ discard block |
||
437 | 466 | // Initialisation of datas of object to call trigger |
438 | 467 | if (is_object($object)) |
439 | 468 | { |
440 | - if (empty($actiontypecode)) $actiontypecode='AC_OTH_AUTO'; // Event insert into agenda automatically |
|
469 | + if (empty($actiontypecode)) { |
|
470 | + $actiontypecode='AC_OTH_AUTO'; |
|
471 | + } |
|
472 | + // Event insert into agenda automatically |
|
441 | 473 | |
442 | 474 | $object->socid = $sendtosocid; // To link to a company |
443 | 475 | $object->sendtoid = $sendtoid; // To link to contact addresses. This is an array. |
@@ -482,11 +514,12 @@ discard block |
||
482 | 514 | setEventMessages($mesg, null, 'mesgs'); |
483 | 515 | |
484 | 516 | $moreparam=''; |
485 | - if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; |
|
517 | + if (isset($paramname2) || isset($paramval2)) { |
|
518 | + $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; |
|
519 | + } |
|
486 | 520 | header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); |
487 | 521 | exit; |
488 | - } |
|
489 | - else |
|
522 | + } else |
|
490 | 523 | { |
491 | 524 | $langs->load("other"); |
492 | 525 | $mesg='<div class="error">'; |
@@ -494,8 +527,7 @@ discard block |
||
494 | 527 | { |
495 | 528 | $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); |
496 | 529 | $mesg.='<br>'.$mailfile->error; |
497 | - } |
|
498 | - else |
|
530 | + } else |
|
499 | 531 | { |
500 | 532 | $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; |
501 | 533 | } |
@@ -505,16 +537,14 @@ discard block |
||
505 | 537 | $action = 'presend'; |
506 | 538 | } |
507 | 539 | } |
508 | - } |
|
509 | - else |
|
540 | + } else |
|
510 | 541 | { |
511 | 542 | $langs->load("errors"); |
512 | 543 | setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); |
513 | 544 | dol_syslog('Try to send email with no recipient defined', LOG_WARNING); |
514 | 545 | $action = 'presend'; |
515 | 546 | } |
516 | - } |
|
517 | - else |
|
547 | + } else |
|
518 | 548 | { |
519 | 549 | $langs->load("other"); |
520 | 550 | setEventMessages($langs->trans('ErrorFailedToReadObject',$object->element), null, 'errors'); |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | print '<div class="tagtd liste_titre" align="center">'.$langs->trans('Mandatory').'</div>'; |
23 | 23 | print '<div class="tagtd liste_titre"></div>'; |
24 | 24 | print '</form>'; |
25 | -} |
|
26 | -else |
|
25 | +} else |
|
27 | 26 | { |
28 | 27 | print '<form class="tagtr liste_titre">'; |
29 | 28 | print '<div class="tagtd liste_titre">'.$langs->trans('Resource').'</div>'; |
@@ -60,12 +59,12 @@ discard block |
||
60 | 59 | print '<div class="tagtd" align="center">'.$form->selectyesno('mandatory',$linked_resource['mandatory']?1:0,1).'</div>'; |
61 | 60 | print '<div class="tagtd" align="right"><input type="submit" class="button" value="'.$langs->trans("Update").'"></div>'; |
62 | 61 | print '</form>'; |
63 | - } |
|
64 | - else |
|
62 | + } else |
|
65 | 63 | { |
66 | 64 | $style=''; |
67 | - if ($linked_resource['rowid'] == GETPOST('lineid')) |
|
68 | - $style='style="background: orange;"'; |
|
65 | + if ($linked_resource['rowid'] == GETPOST('lineid')) { |
|
66 | + $style='style="background: orange;"'; |
|
67 | + } |
|
69 | 68 | |
70 | 69 | print '<form class="tagtr oddeven" '.$style.'>'; |
71 | 70 | |
@@ -98,8 +97,7 @@ discard block |
||
98 | 97 | print '</form>'; |
99 | 98 | } |
100 | 99 | } |
101 | -} |
|
102 | -else { |
|
100 | +} else { |
|
103 | 101 | print '<form class="tagtr oddeven">'; |
104 | 102 | print '<div class="tagtd opacitymedium">'.$langs->trans('NoResourceLinked').'</div>'; |
105 | 103 | print '<div class="tagtd opacitymedium"></div>'; |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | print "Error, template page can't be called as URL"; |
28 | 28 | exit; |
29 | 29 | } |
30 | -if (! is_object($form)) $form=new Form($db); |
|
30 | +if (! is_object($form)) { |
|
31 | + $form=new Form($db); |
|
32 | +} |
|
31 | 33 | |
32 | 34 | ?> |
33 | 35 | <!-- BEGIN PHP TEMPLATE commonfields_edit.tpl.php --> |
@@ -38,22 +40,38 @@ discard block |
||
38 | 40 | foreach($object->fields as $key => $val) |
39 | 41 | { |
40 | 42 | // Discard if extrafield is a hidden field on form |
41 | - if (abs($val['visible']) != 1) continue; |
|
43 | + if (abs($val['visible']) != 1) { |
|
44 | + continue; |
|
45 | + } |
|
42 | 46 | |
43 | - if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) continue; // We don't want this field |
|
47 | + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! verifCond($val['enabled'])) { |
|
48 | + continue; |
|
49 | + } |
|
50 | + // We don't want this field |
|
44 | 51 | |
45 | 52 | print '<tr><td'; |
46 | 53 | print ' class="titlefieldcreate'; |
47 | - if ($val['notnull'] > 0) print ' fieldrequired'; |
|
48 | - if ($val['type'] == 'text' || $val['type'] == 'html') print ' tdtop'; |
|
54 | + if ($val['notnull'] > 0) { |
|
55 | + print ' fieldrequired'; |
|
56 | + } |
|
57 | + if ($val['type'] == 'text' || $val['type'] == 'html') { |
|
58 | + print ' tdtop'; |
|
59 | + } |
|
49 | 60 | print '">'; |
50 | - if (! empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
51 | - else print $langs->trans($val['label']); |
|
61 | + if (! empty($val['help'])) { |
|
62 | + print $form->textwithpicto($langs->trans($val['label']), $val['help']); |
|
63 | + } else { |
|
64 | + print $langs->trans($val['label']); |
|
65 | + } |
|
52 | 66 | print '</td>'; |
53 | 67 | print '<td>'; |
54 | - if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key; |
|
55 | - elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key; |
|
56 | - else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key; |
|
68 | + if (in_array($val['type'], array('int', 'integer'))) { |
|
69 | + $value = GETPOSTISSET($key)?GETPOST($key, 'int'):$object->$key; |
|
70 | + } elseif ($val['type'] == 'text' || $val['type'] == 'html') { |
|
71 | + $value = GETPOSTISSET($key)?GETPOST($key,'none'):$object->$key; |
|
72 | + } else { |
|
73 | + $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key; |
|
74 | + } |
|
57 | 75 | //var_dump($val.' '.$key.' '.$value); |
58 | 76 | print $object->showInputField($val, $key, $value, '', '', '', 0); |
59 | 77 | print '</td>'; |
@@ -42,13 +42,14 @@ |
||
42 | 42 | { |
43 | 43 | $translationKey = (! empty($discount_type)) ? 'HasRelativeDiscountFromSupplier' : 'CompanyHasRelativeDiscount'; |
44 | 44 | print $langs->trans($translationKey, $fixedDiscount).'.'; |
45 | -} |
|
46 | -else |
|
45 | +} else |
|
47 | 46 | { |
48 | 47 | $translationKey = (! empty($discount_type)) ? 'HasNoRelativeDiscountFromSupplier' : 'CompanyHasNoRelativeDiscount'; |
49 | 48 | print $langs->trans($translationKey).'.'; |
50 | 49 | } |
51 | -if($isNewObject) print ' ('.$addrelativediscount.')'; |
|
50 | +if($isNewObject) { |
|
51 | + print ' ('.$addrelativediscount.')'; |
|
52 | +} |
|
52 | 53 | |
53 | 54 | // Is there is commercial discount or down payment available ? |
54 | 55 | if ($absolute_discount > 0) { |