get_info.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. /* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This file is a modified version of datepicker.php from phpBSM to fix some
  5. * bugs, to add new features and to dramatically increase speed.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/core/get_info.php
  22. * \brief File to return a single page with just logged user info, to be used by other frontend
  23. */
  24. //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
  25. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
  26. //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
  27. //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
  28. if (!defined('NOCSRFCHECK')) {
  29. define('NOCSRFCHECK', 1);
  30. }
  31. if (!defined('NOTOKENRENEWAL')) {
  32. define('NOTOKENRENEWAL', 1);
  33. }
  34. //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language and need security layer
  35. if (!defined('NOREQUIREMENU')) {
  36. define('NOREQUIREMENU', 1);
  37. }
  38. require_once '../main.inc.php';
  39. if (GETPOST('lang', 'aZ09')) {
  40. $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
  41. }
  42. $langs->load("main");
  43. $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
  44. $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
  45. /*
  46. * View
  47. */
  48. $title = $langs->trans("Info");
  49. // URL http://mydolibarr/core/get_info.php?dol_use_jmobile=1 can be used for tests
  50. $head = '<!-- Info user page -->'."\n";
  51. $arrayofjs = array();
  52. $arrayofcss = array();
  53. top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
  54. print '<body>'."\n";
  55. print '<div style="padding: 20px;">';
  56. //print '<br>';
  57. // Define link to login card
  58. $appli = constant('DOL_APPLICATION_TITLE');
  59. if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
  60. $appli = $conf->global->MAIN_APPLICATION_TITLE;
  61. if (preg_match('/\d\.\d/', $appli)) {
  62. if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) {
  63. $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
  64. }
  65. } else {
  66. $appli .= " ".DOL_VERSION;
  67. }
  68. } else {
  69. $appli .= " ".DOL_VERSION;
  70. }
  71. if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) {
  72. $appli .= "<br>".$langs->trans("LevelOfFeature").': '.getDolGlobalInt('MAIN_FEATURES_LEVEL');
  73. }
  74. $logouttext = '';
  75. if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
  76. //$logouthtmltext=$appli.'<br>';
  77. if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') {
  78. $logouthtmltext .= $langs->trans("Logout").'<br>';
  79. $logouttext .= '<a href="'.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'">';
  80. //$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
  81. $logouttext .= '<span class="fa fa-sign-out atoplogin"></span>';
  82. $logouttext .= '</a>';
  83. } else {
  84. $logouthtmltext .= $langs->trans("NoLogoutProcessWithAuthMode", $_SESSION["dol_authmode"]);
  85. $logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
  86. }
  87. }
  88. print '<div class="login_block_getinfo">'."\n";
  89. // Add login user link
  90. $toprightmenu .= '<div class="login_block_user">';
  91. // Login name with photo and tooltip
  92. $mode = -1;
  93. $toprightmenu .= '<div class="inline-block nowrap"><div class="inline-block login_block_elem login_block_elem_name" style="padding: 0px;">';
  94. $toprightmenu .= $user->getNomUrl($mode, '', -1, 0, 11, 0, ($user->firstname ? 'firstname' : -1), 'atoplogin');
  95. $toprightmenu .= '</div></div>';
  96. $toprightmenu .= '</div>'."\n";
  97. $toprightmenu .= '<div class="login_block_other">';
  98. // Execute hook printTopRightMenu (hooks should output string like '<div class="login"><a href="">mylink</a></div>')
  99. $parameters = array();
  100. $result = $hookmanager->executeHooks('printTopRightMenu', $parameters); // Note that $action and $object may have been modified by some hooks
  101. if (is_numeric($result)) {
  102. if (empty($result)) {
  103. $toprightmenu .= $hookmanager->resPrint; // add
  104. } else {
  105. $toprightmenu = $hookmanager->resPrint; // replace
  106. }
  107. } else {
  108. $toprightmenu .= $result; // For backward compatibility
  109. }
  110. if (!isset($form) || !is_object($form)) {
  111. include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
  112. $form = new Form($db);
  113. }
  114. // Link to module builder
  115. if (!empty($conf->modulebuilder->enabled)) {
  116. $text = '<a href="'.DOL_URL_ROOT.'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools" target="modulebuilder">';
  117. //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"');
  118. $text .= '<span class="fa fa-bug atoplogin"></span>';
  119. $text .= '</a>';
  120. $toprightmenu .= $form->textwithtooltip('', $langs->trans("ModuleBuilder"), 2, 1, $text, 'login_block_elem', 2);
  121. }
  122. // Link to print main content area
  123. /*
  124. if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $conf->browser->layout != 'phone')
  125. {
  126. $qs=dol_escape_htmltag($_SERVER["QUERY_STRING"]);
  127. if (is_array($_POST))
  128. {
  129. foreach($_POST as $key=>$value) {
  130. if ($key!=='action' && $key!=='password' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value);
  131. }
  132. }
  133. $qs.=(($qs && $morequerystring)?'&':'').$morequerystring;
  134. $text ='<a href="'.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.$qs.($qs?'&':'').'optioncss=print" target="_blank" rel="noopener noreferrer">';
  135. //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"');
  136. $text.='<span class="fa fa-print atoplogin"></span>';
  137. $text.='</a>';
  138. $toprightmenu .= $form->textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2);
  139. }
  140. */
  141. // Link to Dolibarr wiki pages
  142. /*
  143. if (empty($conf->global->MAIN_HELP_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
  144. {
  145. $langs->load("help");
  146. $helpbaseurl='';
  147. $helppage='';
  148. $mode='';
  149. if (empty($helppagename)) $helppagename='EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
  150. // Get helpbaseurl, helppage and mode from helppagename and langs
  151. $arrayres=getHelpParamFor($helppagename,$langs);
  152. $helpbaseurl=$arrayres['helpbaseurl'];
  153. $helppage=$arrayres['helppage'];
  154. $mode=$arrayres['mode'];
  155. // Link to help pages
  156. if ($helpbaseurl && $helppage)
  157. {
  158. $text='';
  159. $title=$appli.'<br>';
  160. $title.=$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage');
  161. if ($mode == 'wiki') $title.=' - '.$langs->trans("PageWiki").' &quot;'.dol_escape_htmltag(strtr($helppage,'_',' ')).'&quot;';
  162. $text.='<a class="help" target="_blank" rel="noopener noreferrer" href="';
  163. if ($mode == 'wiki') $text.=sprintf($helpbaseurl,urlencode(html_entity_decode($helppage)));
  164. else $text.=sprintf($helpbaseurl,$helppage);
  165. $text.='">';
  166. //$text.=img_picto('', 'helpdoc_top').' ';
  167. $text.='<span class="fa fa-question-circle atoplogin"></span>';
  168. //$toprightmenu.=$langs->trans($mode == 'wiki' ? 'OnlineHelp': 'Help');
  169. //if ($mode == 'wiki') $text.=' ('.dol_trunc(strtr($helppage,'_',' '),8).')';
  170. $text.='</a>';
  171. //$toprightmenu.='</div>'."\n";
  172. $toprightmenu .= $form->textwithtooltip('',$title,2,1,$text,'login_block_elem',2);
  173. }
  174. }
  175. */
  176. // Logout link
  177. if (GETPOST('withlogout', 'int')) {
  178. $toprightmenu .= $form->textwithtooltip('', $logouthtmltext, 2, 1, $logouttext, 'login_block_elem', 2);
  179. }
  180. $toprightmenu .= '</div>';
  181. print $toprightmenu;
  182. print "</div>\n"; // end div class="login_block"
  183. print '</div>';
  184. print '</body></html>'."\n";
  185. $db->close();