websiteaccount.lib.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/website/lib/websiteaccount.lib.php
  19. * \ingroup website
  20. * \brief Library files with common functions for WebsiteAccount
  21. */
  22. /**
  23. * Prepare array of tabs for SocieteAccount
  24. *
  25. * @param SocieteAccount $object SocieteAccount
  26. * @return array Array of tabs
  27. */
  28. function websiteaccountPrepareHead($object)
  29. {
  30. global $db, $langs, $conf;
  31. $h = 0;
  32. $head = array();
  33. $head[$h][0] = dol_buildpath("/website/websiteaccount_card.php", 1).'?id='.$object->id;
  34. $head[$h][1] = $langs->trans("WebsiteAccount");
  35. $head[$h][2] = 'card';
  36. $h++;
  37. /*if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
  38. {
  39. $nbNote = 0;
  40. if(!empty($object->fields['note_private'])) $nbNote++;
  41. if(!empty($object->fields['note_public'])) $nbNote++;
  42. $head[$h][0] = dol_buildpath('/monmodule/websiteaccount_note.php', 1).'?id='.$object->id;
  43. $head[$h][1] = $langs->trans('Notes');
  44. if ($nbNote > 0) $head[$h][1].= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
  45. $head[$h][2] = 'note';
  46. $h++;
  47. }*/
  48. /*
  49. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  50. require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
  51. $upload_dir = $conf->monmodule->dir_output . "/websiteaccount/" . dol_sanitizeFileName($object->ref);
  52. $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
  53. $nbLinks=Link::count($db, $object->element, $object->id);
  54. $head[$h][0] = dol_buildpath("/monmodule/websiteaccount_document.php", 1).'?id='.$object->id;
  55. $head[$h][1] = $langs->trans('Documents');
  56. if (($nbFiles+$nbLinks) > 0) $head[$h][1].= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.($nbFiles+$nbLinks).'</span>' : '');
  57. $head[$h][2] = 'document';
  58. $h++;
  59. $head[$h][0] = dol_buildpath("/monmodule/websiteaccount_agenda.php", 1).'?id='.$object->id;
  60. $head[$h][1] = $langs->trans("Events");
  61. $head[$h][2] = 'agenda';
  62. $h++;
  63. */
  64. // Show more tabs from modules
  65. // Entries must be declared in modules descriptor with line
  66. //$this->tabs = array(
  67. // 'entity:+tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__'
  68. //); // to add new tab
  69. //$this->tabs = array(
  70. // 'entity:-tabname:Title:@monmodule:/monmodule/mypage.php?id=__ID__'
  71. //); // to remove a tab
  72. complete_head_from_modules($conf, $langs, $object, $head, $h, 'websiteaccount@website');
  73. complete_head_from_modules($conf, $langs, $object, $head, $h, 'websiteaccount@website', 'remove');
  74. return $head;
  75. }