get_info.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 <http://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')) define('NOCSRFCHECK',1);
  29. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
  30. //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
  31. if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
  32. require_once '../main.inc.php';
  33. if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
  34. $langs->load("main");
  35. $right=($langs->trans("DIRECTION")=='rtl'?'left':'right');
  36. $left=($langs->trans("DIRECTION")=='rtl'?'right':'left');
  37. /*
  38. * View
  39. */
  40. $title=$langs->trans("Info");
  41. // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
  42. $head='<!-- Quick access -->'."\n";
  43. $arrayofjs=array();
  44. $arrayofcss=array();
  45. top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
  46. print '<body>'."\n";
  47. print '<div style="padding: 20px;">';
  48. //print '<br>';
  49. $nbofsearch=0;
  50. // Define link to login card
  51. $appli=constant('DOL_APPLICATION_TITLE');
  52. if (! empty($conf->global->MAIN_APPLICATION_TITLE))
  53. {
  54. $appli=$conf->global->MAIN_APPLICATION_TITLE;
  55. if (preg_match('/\d\.\d/', $appli))
  56. {
  57. if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core
  58. }
  59. else $appli.=" ".DOL_VERSION;
  60. }
  61. else $appli.=" ".DOL_VERSION;
  62. if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $appli.="<br>".$langs->trans("LevelOfFeature").': '.$conf->global->MAIN_FEATURES_LEVEL;
  63. $logouttext='';
  64. if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
  65. {
  66. //$logouthtmltext=$appli.'<br>';
  67. if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http')
  68. {
  69. $logouthtmltext.=$langs->trans("Logout").'<br>';
  70. $logouttext .='<a href="'.DOL_URL_ROOT.'/user/logout.php">';
  71. //$logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
  72. $logouttext .='<span class="fa fa-sign-out atoplogin"></span>';
  73. $logouttext .='</a>';
  74. }
  75. else
  76. {
  77. $logouthtmltext.=$langs->trans("NoLogoutProcessWithAuthMode",$_SESSION["dol_authmode"]);
  78. $logouttext .= img_picto($langs->trans('Logout').":".$langs->trans('Logout'), 'logout_top.png', 'class="login"', 0, 0, 1);
  79. }
  80. }
  81. print '<div class="login_block_getinfo">'."\n";
  82. // Add login user link
  83. $toprightmenu.='<div class="login_block_user">';
  84. // Login name with photo and tooltip
  85. $mode=-1;
  86. $toprightmenu.='<div class="inline-block nowrap"><div class="inline-block login_block_elem login_block_elem_name" style="padding: 0px;">';
  87. $toprightmenu.=$user->getNomUrl($mode, '', -1, 0, 11, 0, ($user->firstname ? 'firstname' : -1),'atoplogin');
  88. $toprightmenu.='</div></div>';
  89. $toprightmenu.='</div>'."\n";
  90. $toprightmenu.='<div class="login_block_other">';
  91. // Execute hook printTopRightMenu (hooks should output string like '<div class="login"><a href="">mylink</a></div>')
  92. $parameters=array();
  93. $result=$hookmanager->executeHooks('printTopRightMenu',$parameters); // Note that $action and $object may have been modified by some hooks
  94. if (is_numeric($result))
  95. {
  96. if (empty($result)) $toprightmenu.=$hookmanager->resPrint; // add
  97. else $toprightmenu=$hookmanager->resPrint; // replace
  98. }
  99. else $toprightmenu.=$result; // For backward compatibility
  100. // Link to module builder
  101. if (! empty($conf->modulebuilder->enabled))
  102. {
  103. $text ='<a href="'.DOL_URL_ROOT.'/modulebuilder/index.php?mainmenu=home&leftmenu=admintools" target="_modulebuilder">';
  104. //$text.= img_picto(":".$langs->trans("ModuleBuilder"), 'printer_top.png', 'class="printer"');
  105. $text.='<span class="fa fa-bug atoplogin"></span>';
  106. $text.='</a>';
  107. $toprightmenu.=@Form::textwithtooltip('',$langs->trans("ModuleBuilder"),2,1,$text,'login_block_elem',2);
  108. }
  109. // Link to print main content area
  110. /*
  111. if (empty($conf->global->MAIN_PRINT_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $conf->browser->layout != 'phone')
  112. {
  113. $qs=dol_escape_htmltag($_SERVER["QUERY_STRING"]);
  114. if (is_array($_POST))
  115. {
  116. foreach($_POST as $key=>$value) {
  117. if ($key!=='action' && $key!=='password' && !is_array($value)) $qs.='&'.$key.'='.urlencode($value);
  118. }
  119. }
  120. $qs.=(($qs && $morequerystring)?'&':'').$morequerystring;
  121. $text ='<a href="'.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.$qs.($qs?'&':'').'optioncss=print" target="_blank">';
  122. //$text.= img_picto(":".$langs->trans("PrintContentArea"), 'printer_top.png', 'class="printer"');
  123. $text.='<span class="fa fa-print atoplogin"></span>';
  124. $text.='</a>';
  125. $toprightmenu.=@Form::textwithtooltip('',$langs->trans("PrintContentArea"),2,1,$text,'login_block_elem',2);
  126. }
  127. */
  128. // Link to Dolibarr wiki pages
  129. /*
  130. if (empty($conf->global->MAIN_HELP_DISABLELINK) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
  131. {
  132. $langs->load("help");
  133. $helpbaseurl='';
  134. $helppage='';
  135. $mode='';
  136. if (empty($helppagename)) $helppagename='EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
  137. // Get helpbaseurl, helppage and mode from helppagename and langs
  138. $arrayres=getHelpParamFor($helppagename,$langs);
  139. $helpbaseurl=$arrayres['helpbaseurl'];
  140. $helppage=$arrayres['helppage'];
  141. $mode=$arrayres['mode'];
  142. // Link to help pages
  143. if ($helpbaseurl && $helppage)
  144. {
  145. $text='';
  146. $title=$appli.'<br>';
  147. $title.=$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage');
  148. if ($mode == 'wiki') $title.=' - '.$langs->trans("PageWiki").' &quot;'.dol_escape_htmltag(strtr($helppage,'_',' ')).'&quot;';
  149. $text.='<a class="help" target="_blank" rel="noopener" href="';
  150. if ($mode == 'wiki') $text.=sprintf($helpbaseurl,urlencode(html_entity_decode($helppage)));
  151. else $text.=sprintf($helpbaseurl,$helppage);
  152. $text.='">';
  153. //$text.=img_picto('', 'helpdoc_top').' ';
  154. $text.='<span class="fa fa-question-circle atoplogin"></span>';
  155. //$toprightmenu.=$langs->trans($mode == 'wiki' ? 'OnlineHelp': 'Help');
  156. //if ($mode == 'wiki') $text.=' ('.dol_trunc(strtr($helppage,'_',' '),8).')';
  157. $text.='</a>';
  158. //$toprightmenu.='</div>'."\n";
  159. $toprightmenu.=@Form::textwithtooltip('',$title,2,1,$text,'login_block_elem',2);
  160. }
  161. }
  162. */
  163. // Logout link
  164. if (GETPOST('withlogout','int')) $toprightmenu.=@Form::textwithtooltip('',$logouthtmltext,2,1,$logouttext,'login_block_elem',2);
  165. $toprightmenu.='</div>';
  166. print $toprightmenu;
  167. print "</div>\n"; // end div class="login_block"
  168. print '</div>';
  169. print '</body></html>'."\n";
  170. $db->close();