dolibarr  x.y.z
oauthlogintokens.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2014-2018 Frederic France <frederic.france@netlogic.fr>
4  * Copyright (C) 2020 Nicolas ZABOURI <info@inovea-conseil.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 // Load Dolibarr environment
27 require '../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/oauth.lib.php'; // This define $list and $supportedoauth2array
30 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
31 use OAuth\Common\Storage\DoliStorage;
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array('admin', 'printing', 'oauth'));
35 
36 $action = GETPOST('action', 'aZ09');
37 $mode = GETPOST('mode', 'alpha');
38 $value = GETPOST('value', 'alpha');
39 $varname = GETPOST('varname', 'alpha');
40 $driver = GETPOST('driver', 'alpha');
41 
42 if (!empty($driver)) {
43  $langs->load($driver);
44 }
45 
46 if (!$mode) {
47  $mode = 'setup';
48 }
49 
50 if (!$user->admin) {
52 }
53 
54 
55 /*
56  * Action
57  */
58 
59 /*if (($mode == 'test' || $mode == 'setup') && empty($driver))
60 {
61  setEventMessages($langs->trans('PleaseSelectaDriverfromList'), null);
62  header("Location: ".$_SERVER['PHP_SELF'].'?mode=config');
63  exit;
64 }*/
65 
66 if ($action == 'setconst' && $user->admin) {
67  $error = 0;
68  $db->begin();
69 
70  $setupconstarray = GETPOST('setupdriver', 'array');
71 
72  foreach ($setupconstarray as $setupconst) {
73  //print '<pre>'.print_r($setupconst, true).'</pre>';
74 
75  $constname = dol_escape_htmltag($setupconst['varname']);
76  $constvalue = dol_escape_htmltag($setupconst['value']);
77  $consttype = dol_escape_htmltag($setupconst['type']);
78  $constnote = dol_escape_htmltag($setupconst['note']);
79 
80  $result = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
81  if (!($result > 0)) {
82  $error++;
83  }
84  }
85 
86  if (!$error) {
87  $db->commit();
88  setEventMessages($langs->trans("SetupSaved"), null);
89  } else {
90  $db->rollback();
91  dol_print_error($db);
92  }
93  $action = '';
94 }
95 
96 if ($action == 'setvalue' && $user->admin) {
97  $db->begin();
98 
99  $result = dolibarr_set_const($db, $varname, $value, 'chaine', 0, '', $conf->entity);
100  if (!($result > 0)) {
101  $error++;
102  }
103 
104  if (!$error) {
105  $db->commit();
106  setEventMessages($langs->trans("SetupSaved"), null);
107  } else {
108  $db->rollback();
109  dol_print_error($db);
110  }
111  $action = '';
112 }
113 
114 
115 /*
116  * View
117  */
118 
119 // Define $urlwithroot
120 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
121 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
122 //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
123 
124 $form = new Form($db);
125 
126 llxHeader('', $langs->trans("TokenManager"));
127 
128 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
129 print load_fiche_titre($langs->trans('ConfigOAuth'), $linkback, 'title_setup');
130 
131 $head = oauthadmin_prepare_head();
132 
133 print dol_get_fiche_head($head, 'tokengeneration', '', -1, '');
134 
135 if (GETPOST('error')) {
136  setEventMessages(GETPOST('error'), null, 'errors');
137 }
138 
139 if ($mode == 'setup' && $user->admin) {
140  print '<span class="opacitymedium">'.$langs->trans("OAuthSetupForLogin")."</span><br><br>\n";
141 
142  // Define $listinsetup
143  foreach ($conf->global as $key => $val) {
144  if (!empty($val) && preg_match('/^OAUTH_.*_ID$/', $key)) {
145  $provider = preg_replace('/_ID$/', '', $key);
146  $listinsetup[] = array(
147  $provider.'_NAME',
148  $provider.'_ID',
149  $provider.'_SECRET',
150  $provider.'_URLAUTHORIZE', // For custom oauth links
151  $provider.'_SCOPE' // For custom oauth links
152  );
153  }
154  }
155 
156  $oauthstateanticsrf = bin2hex(random_bytes(128/8));
157 
158  // $list is defined into oauth.lib.php to the list of supporter OAuth providers.
159  foreach ($listinsetup as $key) {
160  $supported = 0;
161  $keyforsupportedoauth2array = $key[0]; // May be OAUTH_GOOGLE_NAME or OAUTH_GOOGLE_xxx_NAME
162  $keyforsupportedoauth2array = preg_replace('/^OAUTH_/', '', $keyforsupportedoauth2array);
163  $keyforsupportedoauth2array = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array);
164  if (preg_match('/^.*-/', $keyforsupportedoauth2array)) {
165  $keyforprovider = preg_replace('/^.*-/', '', $keyforsupportedoauth2array);
166  } else {
167  $keyforprovider = '';
168  }
169  $keyforsupportedoauth2array = preg_replace('/-.*$/', '', $keyforsupportedoauth2array);
170  $keyforsupportedoauth2array = 'OAUTH_'.$keyforsupportedoauth2array.'_NAME';
171 
172 
173  $OAUTH_SERVICENAME = (empty($supportedoauth2array[$keyforsupportedoauth2array]['name']) ? 'Unknown' : $supportedoauth2array[$keyforsupportedoauth2array]['name'].($keyforprovider ? '-'.$keyforprovider : ''));
174 
175  $shortscope = '';
176  if (getDolGlobalString($key[4])) {
177  $shortscope = getDolGlobalString($key[4]);
178  }
179  $state = $shortscope; // TODO USe a better state
180 
181  // Define $urltorenew, $urltodelete, $urltocheckperms
182  // TODO Use array $supportedoauth2array
183  if ($keyforsupportedoauth2array == 'OAUTH_GITHUB_NAME') {
184  // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
185  // We pass this param list in to 'state' because we need it before and after the redirect.
186 
187  // Note: github does not accept csrf key inside the state parameter (only known values)
188  $urltorenew = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.$shortscope.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
189  $urltodelete = $urlwithroot.'/core/modules/oauth/github_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
190  $urltocheckperms = 'https://github.com/settings/applications/';
191  } elseif ($keyforsupportedoauth2array == 'OAUTH_GOOGLE_NAME') {
192  // List of keys that will be converted into scopes (from constants 'SCOPE_state_in_uppercase' in file of service).
193  // List of scopes for Google are here: https://developers.google.com/identity/protocols/oauth2/scopes
194  // We pass this key list into the param 'state' because we need it before and after the redirect.
195  $urltorenew = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'-'.$oauthstateanticsrf.'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
196  $urltodelete = $urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&token='.newToken().'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
197  $urltocheckperms = 'https://security.google.com/settings/security/permissions';
198  } elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_TEST_NAME') {
199  $urltorenew = $urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
200  $urltodelete = '';
201  $urltocheckperms = '';
202  } elseif ($keyforsupportedoauth2array == 'OAUTH_STRIPE_LIVE_NAME') {
203  $urltorenew = $urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
204  $urltodelete = '';
205  $urltocheckperms = '';
206  } elseif ($keyforsupportedoauth2array = 'OAUTH_OTHER_NAME') {
207  $urltorenew = $urlwithroot.'/core/modules/oauth/generic_oauthcallback.php?shortscope='.urlencode($shortscope).'&state='.urlencode($state).'&backtourl='.urlencode(DOL_URL_ROOT.'/admin/oauthlogintokens.php');
208  $urltodelete = '';
209  $urltocheckperms = '';
210  } else {
211  $urltorenew = '';
212  $urltodelete = '';
213  $urltocheckperms = '';
214  }
215 
216  if ($urltorenew) {
217  $urltorenew .= '&keyforprovider='.urlencode($keyforprovider);
218  }
219  if ($urltodelete) {
220  $urltodelete .= '&keyforprovider='.urlencode($keyforprovider);
221  }
222 
223 
224  // Show value of token
225  $tokenobj = null;
226  // Token
227  require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
228  // Dolibarr storage
229  $storage = new DoliStorage($db, $conf);
230  try {
231  $tokenobj = $storage->retrieveAccessToken($OAUTH_SERVICENAME);
232  } catch (Exception $e) {
233  // Return an error if token not found
234  }
235 
236  // Set other properties
237  $refreshtoken = false;
238  $expiredat = '';
239 
240  $expire = false;
241  // Is token expired or will token expire in the next 30 seconds
242  if (is_object($tokenobj)) {
243  $expire = ($tokenobj->getEndOfLife() !== $tokenobj::EOL_NEVER_EXPIRES && $tokenobj->getEndOfLife() !== $tokenobj::EOL_UNKNOWN && time() > ($tokenobj->getEndOfLife() - 30));
244  }
245  if ($key[1] != '' && $key[2] != '') {
246  if (is_object($tokenobj)) {
247  $refreshtoken = $tokenobj->getRefreshToken();
248 
249  $endoflife = $tokenobj->getEndOfLife();
250  if ($endoflife == $tokenobj::EOL_NEVER_EXPIRES) {
251  $expiredat = $langs->trans("Never");
252  } elseif ($endoflife == $tokenobj::EOL_UNKNOWN) {
253  $expiredat = $langs->trans("Unknown");
254  } else {
255  $expiredat = dol_print_date($endoflife, "dayhour", 'tzuserrel');
256  }
257  }
258  }
259 
260  $submit_enabled = 0;
261 
262  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=setup&amp;driver='.$driver.'" autocomplete="off">';
263  print '<input type="hidden" name="token" value="'.newToken().'">';
264  print '<input type="hidden" name="action" value="setconst">';
265 
266  print '<div class="div-table-responsive-no-min">';
267  print '<table class="noborder centpercent">'."\n";
268 
269  // Api Name
270  $label = $langs->trans($keyforsupportedoauth2array);
271  print '<tr class="liste_titre">';
272  print '<th class="titlefieldcreate">';
273  print img_picto('', $supportedoauth2array[$keyforsupportedoauth2array]['picto'], 'class="pictofixedwidth"');
274  if ($label == $keyforsupportedoauth2array) {
275  print $supportedoauth2array[$keyforsupportedoauth2array]['name'];
276  } else {
277  print $label;
278  }
279  if ($keyforprovider) {
280  print ' (<b>'.$keyforprovider.'</b>)';
281  } else {
282  print ' (<b>'.$langs->trans("NoName").'</b>)';
283  }
284  print '</th>';
285  print '<th></th>';
286  print '<th></th>';
287  print "</tr>\n";
288 
289  print '<tr class="oddeven">';
290  print '<td'.(empty($key['required']) ? '' : ' class="required"').'>';
291  //var_dump($key);
292  print $langs->trans("OAuthIDSecret").'</td>';
293  print '<td>';
294  print '<span class="opacitymedium">'.$langs->trans("SeePreviousTab").'</span>';
295  print '</td>';
296  print '<td>';
297  print '</td>';
298  print '</tr>'."\n";
299 
300  // Scopes
301  print '<tr class="oddeven">';
302  print '<td>'.$langs->trans("Scopes").'</td>';
303  print '<td colspan="2">';
304  $currentscopes = getDolGlobalString($key[4]);
305  print $currentscopes;
306  print '</td></tr>';
307 
308  print '<tr class="oddeven">';
309  print '<td'.(empty($key['required']) ? '' : ' class="required"').'>';
310  //var_dump($key);
311  print $langs->trans("IsTokenGenerated");
312  print '</td>';
313  print '<td>';
314  if (is_object($tokenobj)) {
315  print $form->textwithpicto(yn(1), $langs->trans("HasAccessToken").' : '.dol_print_date($storage->date_modification, 'dayhour').' state='.dol_escape_htmltag($storage->state));
316  } else {
317  print '<span class="opacitymedium">'.$langs->trans("NoAccessToken").'</span>';
318  }
319  print '</td>';
320  print '<td width="50%">';
321  // Links to delete/checks token
322  if (is_object($tokenobj)) {
323  //test on $storage->hasAccessToken($OAUTH_SERVICENAME) ?
324  print '<a class="button smallpaddingimp" href="'.$urltodelete.'">'.$langs->trans('DeleteAccess').'</a><br>';
325  }
326  // Request remote token
327  if ($urltorenew) {
328  print '<a class="button smallpaddingimp" href="'.$urltorenew.'">'.$langs->trans('GetAccess').'</a>';
329  print $form->textwithpicto('', $langs->trans('RequestAccess'));
330  print '<br>';
331  }
332  // Check remote access
333  if ($urltocheckperms) {
334  print '<br>'.$langs->trans("ToCheckDeleteTokenOnProvider", $OAUTH_SERVICENAME).': <a href="'.$urltocheckperms.'" target="_'.strtolower($OAUTH_SERVICENAME).'">'.$urltocheckperms.'</a>';
335  }
336  print '</td>';
337  print '</tr>';
338 
339  print '<tr class="oddeven">';
340  print '<td'.(empty($key['required']) ? '' : ' class="required"').'>';
341  //var_dump($key);
342  print $langs->trans("Token").'</td>';
343  print '<td colspan="2">';
344 
345  if (is_object($tokenobj)) {
346  //var_dump($tokenobj);
347  $tokentoshow = $tokenobj->getAccessToken();
348  print '<span class="" title="'.dol_escape_htmltag($tokentoshow).'">'.showValueWithClipboardCPButton($tokentoshow, 1, dol_trunc($tokentoshow, 32)).'</span><br>';
349  //print 'Refresh: '.$tokenobj->getRefreshToken().'<br>';
350  //print 'EndOfLife: '.$tokenobj->getEndOfLife().'<br>';
351  //var_dump($tokenobj->getExtraParams());
352  /*print '<br>Extra: <br><textarea class="quatrevingtpercent">';
353  print ''.join(',',$tokenobj->getExtraParams());
354  print '</textarea>';*/
355  }
356  print '</td>';
357  print '</tr>'."\n";
358 
359  if (is_object($tokenobj)) {
360  // Token refresh
361  print '<tr class="oddeven">';
362  print '<td'.($key['required'] ? ' class="required"' : '').'>';
363  //var_dump($key);
364  print $langs->trans("TOKEN_REFRESH");
365  print '</td>';
366  print '<td colspan="2">';
367  print '<span class="" title="'.dol_escape_htmltag($refreshtoken).'">'.showValueWithClipboardCPButton($refreshtoken, 1, dol_trunc($refreshtoken, 32)).'</span>';
368  print '</td>';
369  print '</tr>';
370 
371  // Token expired
372  print '<tr class="oddeven">';
373  print '<td'.(empty($key['required']) ? '' : ' class="required"').'>';
374  //var_dump($key);
375  print $langs->trans("TOKEN_EXPIRED");
376  print '</td>';
377  print '<td colspan="2">';
378  print yn($expire);
379  print '</td>';
380  print '</tr>';
381 
382  // Token expired at
383  print '<tr class="oddeven">';
384  print '<td'.(empty($key['required']) ? '' : ' class="required"').'>';
385  //var_dump($key);
386  print $langs->trans("TOKEN_EXPIRE_AT");
387  print '</td>';
388  print '<td colspan="2">';
389  print $expiredat;
390  print '</td>';
391  print '</tr>';
392  }
393 
394  print '</table>';
395  print '</div>';
396 
397  if (!empty($driver)) {
398  if ($submit_enabled) {
399  print $form->buttonsSaveCancel("Modify", '');
400  }
401  }
402 
403  print '</form>';
404  print '<br>';
405  }
406 }
407 
408 if ($mode == 'test' && $user->admin) {
409  print $langs->trans('PrintTestDesc'.$driver)."<br><br>\n";
410 
411  print '<div class="div-table-responsive-no-min">';
412  print '<table class="noborder centpercent">';
413  if (!empty($driver)) {
414  require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php';
415  $classname = 'printing_'.$driver;
416  $langs->load($driver);
417  $printer = new $classname($db);
418  //print '<pre>'.print_r($printer, true).'</pre>';
419  if (count($printer->getlistAvailablePrinters())) {
420  if ($printer->listAvailablePrinters() == 0) {
421  print $printer->resprint;
422  } else {
423  setEventMessages($printer->error, $printer->errors, 'errors');
424  }
425  } else {
426  print $langs->trans('PleaseConfigureDriverfromList');
427  }
428  }
429 
430  print '</table>';
431  print '</div>';
432 }
433 
434 if ($mode == 'userconf' && $user->admin) {
435  print $langs->trans('PrintUserConfDesc'.$driver)."<br><br>\n";
436 
437  print '<div class="div-table-responsive">';
438  print '<table class="noborder centpercent">';
439  print '<tr class="liste_titre">';
440  print '<th>'.$langs->trans("User").'</th>';
441  print '<th>'.$langs->trans("PrintModule").'</th>';
442  print '<th>'.$langs->trans("PrintDriver").'</th>';
443  print '<th>'.$langs->trans("Printer").'</th>';
444  print '<th>'.$langs->trans("PrinterLocation").'</th>';
445  print '<th>'.$langs->trans("PrinterId").'</th>';
446  print '<th>'.$langs->trans("NumberOfCopy").'</th>';
447  print '<th class="center">'.$langs->trans("Delete").'</th>';
448  print "</tr>\n";
449  $sql = "SELECT p.rowid, p.printer_name, p.printer_location, p.printer_id, p.copy, p.module, p.driver, p.userid, u.login";
450  $sql .= " FROM ".MAIN_DB_PREFIX."printing as p, ".MAIN_DB_PREFIX."user as u WHERE p.userid = u.rowid";
451  $resql = $db->query($sql);
452  while ($obj = $db->fetch_object($resql)) {
453  print '<tr class="oddeven">';
454  print '<td>'.$obj->login.'</td>';
455  print '<td>'.$obj->module.'</td>';
456  print '<td>'.$obj->driver.'</td>';
457  print '<td>'.$obj->printer_name.'</td>';
458  print '<td>'.$obj->printer_location.'</td>';
459  print '<td>'.$obj->printer_id.'</td>';
460  print '<td>'.$obj->copy.'</td>';
461  print '<td class="center">'.img_picto($langs->trans("Delete"), 'delete').'</td>';
462  print "</tr>\n";
463  }
464  print '</table>';
465  print '</div>';
466 }
467 
468 print dol_get_fiche_end();
469 
470 // End of page
471 llxFooter();
472 $db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:632
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
oauthadmin_prepare_head()
Return array of tabs to used on pages to setup cron module.
Definition: oauth.lib.php:278
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.