|
52 | 52 | $langs->loadLangs(["agenda", "other", "commercial", "companies", "idreamanewcalendar@idreamanewcalendar"]); |
53 | 53 |
|
54 | 54 | top_httphead('application/json', 1); |
55 | | -// dol_syslog('posted events ajax GET '.print_r($_GET, true), LOG_WARNING); |
56 | | -dol_syslog('posted events ajax POST ' . print_r($_POST, true), LOG_WARNING); |
57 | | -dol_syslog('posted events ajax REQUEST ' . print_r($_REQUEST, true), LOG_WARNING); |
| 55 | +// dol_syslog('posted events ajax GET '.print_r($_GET, true), LOG_DEBUG); |
| 56 | +// dol_syslog('posted events ajax POST '.print_r($_POST, true), LOG_DEBUG); |
| 57 | +// dol_syslog('posted events ajax REQUEST '.print_r($_REQUEST, true), LOG_DEBUG); |
58 | 58 | $action = GETPOSTISSET('action') ? GETPOST('action', 'aZ09') : 'getevents'; |
59 | 59 | $input = file_get_contents('php://input'); |
60 | 60 | switch ($action) { |
|
161 | 161 | // dol_syslog('posted events ajax REQUEST '.print_r($_POST, true), LOG_NOTICE); |
162 | 162 | if (GETPOSTISSET('schedule')) { |
163 | 163 | //$deletedevent = json_decode(GETPOST('schedule'), 'none'); |
164 | | - $deletedevent = json_decode($_POST['schedule']); |
| 164 | + $deletedevent = json_decode(GETPOST('schedule', 'none')); |
165 | 165 | dol_syslog('posted events ajax REQUEST ' . print_r($deletedevent, true), LOG_NOTICE); |
166 | 166 | $action = new ActionComm($db); |
167 | 167 | $action->fetch($deletedevent->id); |
|
187 | 187 | $sql .= ", dictp.code as country_code"; |
188 | 188 | } |
189 | 189 | $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; |
190 | | - if (!$user->rights->societe->client->voir && !$user->socid) { |
| 190 | + if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) { |
191 | 191 | $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; |
192 | 192 | } |
193 | | - if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { |
| 193 | + if (getDolGlobalInt('COMPANY_SHOW_ADDRESS_SELECTLIST')) { |
194 | 194 | $sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "c_country as dictp ON dictp.rowid=s.fk_pays"; |
195 | 195 | } |
196 | 196 | $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")"; |
197 | 197 | if (!empty($user->socid)) { |
198 | 198 | $sql .= " AND s.rowid = " . $user->socid; |
199 | 199 | } |
200 | | - if (!$user->rights->societe->client->voir && !$user->socid) { |
| 200 | + if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) { |
201 | 201 | $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; |
202 | 202 | } |
203 | | - if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) { |
| 203 | + if (getDolGlobalInt('COMPANY_HIDE_INACTIVE_IN_COMBOBOX')) { |
204 | 204 | $sql .= " AND s.status <> 0"; |
205 | 205 | } |
206 | 206 | // Add criteria |
207 | 207 | if ($filterkey && $filterkey != '') { |
208 | 208 | $sql .= " AND ("; |
209 | 209 | // Can use index if COMPANY_DONOTSEARCH_ANYWHERE is on |
210 | | - $prefix = empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE) ? '%' : ''; |
| 210 | + $prefix = !getDolGlobalInt('COMPANY_DONOTSEARCH_ANYWHERE') ? '%' : ''; |
211 | 211 | // For natural search |
212 | 212 | $scriteria = explode(' ', $filterkey); |
213 | 213 | $i = 0; |
|
224 | 224 | if (count($scriteria) > 1) { |
225 | 225 | $sql .= ")"; |
226 | 226 | } |
227 | | - if (!empty($conf->barcode->enabled)) { |
| 227 | + if (isModEnabled('barcode')) { |
228 | 228 | $sql .= " OR s.barcode LIKE '" . $db->escape($prefix . $filterkey) . "%'"; |
229 | 229 | } |
230 | 230 | $sql .= " OR s.code_client LIKE '" . $db->escape($prefix . $filterkey) . "%' OR s.code_fournisseur LIKE '" . $db->escape($prefix . $filterkey) . "%'"; |
|
236 | 236 | $resql = $db->query($sql); |
237 | 237 | while ($resql && $obj = $db->fetch_object($resql)) { |
238 | 238 | $label = ''; |
239 | | - if ($conf->global->SOCIETE_ADD_REF_IN_LIST) { |
| 239 | + if (getDolGlobalInt('SOCIETE_ADD_REF_IN_LIST')) { |
240 | 240 | if (($obj->client) && (!empty($obj->code_client))) { |
241 | 241 | $label = $obj->code_client . ' - '; |
242 | 242 | } |
|
289 | 289 | $sql .= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; |
290 | 290 | } |
291 | 291 | if ($socid > 0) { |
292 | | - if (empty($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) { |
| 292 | + if (!getDolGlobalString('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) { |
293 | 293 | $sql .= " AND (p.fk_soc = " . $socid . " OR p.fk_soc IS NULL)"; |
294 | | - } elseif ($conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') { |
| 294 | + } elseif (getDolGlobalString('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY') != 'all') { |
295 | 295 | // PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. |
296 | | - $sql .= " AND (p.fk_soc IN (" . $socid . ", " . $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY . ") OR p.fk_soc IS NULL)"; |
| 296 | + $sql .= " AND (p.fk_soc IN (" . $socid . ", " . getDolGlobalString('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY') . ") OR p.fk_soc IS NULL)"; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | if (!empty($filterkey)) { |
|
322 | 322 |
|
323 | 323 | if ($user->hasRight('agenda', 'allactions', 'read')) { |
324 | 324 | $sql = "SELECT DISTINCT u.rowid, u.lastname as lastname, u.firstname, u.statut, u.login, u.admin, u.entity"; |
325 | | - if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { |
| 325 | + if (isModEnabled('multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) { |
326 | 326 | $sql .= ", e.label"; |
327 | 327 | } |
328 | 328 | $sql .= " FROM " . MAIN_DB_PREFIX . "user as u"; |
329 | | - if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) { |
| 329 | + if (isModEnabled('multicompany') && $conf->entity == 1 && $user->admin && !$user->entity) { |
330 | 330 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entity as e ON e.rowid=u.entity"; |
331 | 331 | if ($force_entity) { |
332 | 332 | $sql .= " WHERE u.entity IN (0," . $force_entity . ")"; |
333 | 333 | } else { |
334 | 334 | $sql .= " WHERE u.entity IS NOT NULL"; |
335 | 335 | } |
336 | 336 | } else { |
337 | | - if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
| 337 | + if (getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { |
338 | 338 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ug"; |
339 | 339 | $sql .= " ON ug.fk_user = u.rowid"; |
340 | 340 | $sql .= " WHERE ug.entity = " . $conf->entity; |
|
345 | 345 | if (!empty($user->socid)) { |
346 | 346 | $sql .= " AND u.fk_soc = " . $user->socid; |
347 | 347 | } |
348 | | - if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) { |
| 348 | + if (getDolGlobalInt('USER_HIDE_INACTIVE_IN_COMBOBOX') || $noactive) { |
349 | 349 | $sql .= " AND u.statut <> 0"; |
350 | 350 | } |
351 | 351 | if (!empty($filterkey)) { |
352 | 352 | $sql .= natural_search(['u.firstname', 'u.lastname'], $db->escape($filterkey)); |
353 | 353 | } |
354 | | - if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { |
| 354 | + if (!getDolGlobalString('MAIN_FIRSTNAME_NAME_POSITION')) { |
355 | 355 | // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname |
356 | 356 | $sql .= " ORDER BY u.firstname ASC"; |
357 | 357 | } else { |
358 | 358 | $sql .= " ORDER BY u.lastname ASC"; |
359 | 359 | } |
360 | | - dol_syslog($sql, LOG_WARNING); |
361 | 360 | // Build output string |
362 | 361 | $resql = $db->query($sql); |
363 | 362 | while ($resql && $obj = $db->fetch_object($resql)) { |
|
411 | 410 | case 'gettypeactions': |
412 | 411 | $preselectedtypes = []; |
413 | 412 | $response = []; |
414 | | - if (!empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)) { |
| 413 | + if (getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE')) { |
415 | 414 | $preselectedtypes = explode(',', getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE')); |
416 | 415 | } |
417 | 416 | $sql = "SELECT id, code, libelle as label, module, type, color, picto"; |
@@ -543,7 +542,7 @@ function getDeletedEventsId($resourceId) |
543 | 542 | if ($resourceId != '1') { |
544 | 543 | return $events; |
545 | 544 | } |
546 | | - $sql = "SELECT fk_actioncomm FROM " . MAIN_DB_PREFIX . "actioncomm_deleted WHERE tms>'" . (int) (time() - (3 * 60 * 60)) . "'"; |
| 545 | + $sql = "SELECT fk_actioncomm FROM " . MAIN_DB_PREFIX . "actioncomm_deleted WHERE tms>'" . $db->idate(time() - (3 * 60 * 60)) . "'"; |
547 | 546 | $resql = $db->query($sql); |
548 | 547 | while ($resql && $obj = $db->fetch_object($resql)) { |
549 | 548 | $events[] = [ |
@@ -654,7 +653,7 @@ function getEvents($resourceId, $calendarName, $startDate, $endDate, $offset, $o |
654 | 653 | if ($pid) { |
655 | 654 | $sql .= " AND a.fk_project=" . $db->escape($pid); |
656 | 655 | } |
657 | | - if (!$user->rights->societe->client->voir && !$socid) { |
| 656 | + if (!$user->hasRight('societe', 'client', 'voir') && !$socid) { |
658 | 657 | $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")"; |
659 | 658 | } |
660 | 659 | if ($socid > 0) { |
@@ -777,7 +776,7 @@ function getEvents($resourceId, $calendarName, $startDate, $endDate, $offset, $o |
777 | 776 | } |
778 | 777 | // Is Editable ? |
779 | 778 | $isEditable = true; |
780 | | - if (($event->type_code == 'AC_OTH_AUTO') || (($user->id != $event->userownerid) && !$user->rights->agenda->allactions->create)) { |
| 779 | + if (($event->type_code == 'AC_OTH_AUTO') || (($user->id != $event->userownerid) && !$user->hasRight('agenda', 'allactions', 'create'))) { |
781 | 780 | $isEditable = false; |
782 | 781 | } |
783 | 782 |
|
@@ -848,8 +847,8 @@ function getEvents($resourceId, $calendarName, $startDate, $endDate, $offset, $o |
848 | 847 | // birthdays are readonly |
849 | 848 | 'editable' => false, |
850 | 849 | 'allDay' => true, |
851 | | - // color : The schedule text color |
852 | | - 'textColor' => isDarkColor($obj->color) ? '#ffffff' : '#000000', |
| 850 | + // color : The schedule text color (birthday events always use dark background #555555) |
| 851 | + 'textColor' => '#ffffff', |
853 | 852 | // backgroundColor : The schedule background color |
854 | 853 | 'backgroundColor' => '#555555', |
855 | 854 | // borderColor : The schedule border color |
@@ -975,7 +974,7 @@ function getEvents($resourceId, $calendarName, $startDate, $endDate, $offset, $o |
975 | 974 | //die($e); |
976 | 975 | return []; |
977 | 976 | } |
978 | | - dol_syslog('Ical : ' . $namecal . ' cachetime : ' . print_r($ical->events(), true), LOG_WARNING); |
| 977 | + dol_syslog('Ical : loaded ' . $namecal . ' cachetime : ' . $cachetime, LOG_DEBUG); |
979 | 978 | // on cache le fichier parsé |
980 | 979 | dol_filecache($cachedir, $filename, $ical); |
981 | 980 | } else { |
|
0 commit comments