messaging.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. /* Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/projet/messaging.php
  20. * \ingroup project
  21. * \brief Page with events on project
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  29. // Load translation files required by the page
  30. $langs->load("projects");
  31. $id = GETPOST('id', 'int');
  32. $ref = GETPOST('ref', 'alpha');
  33. $socid = GETPOST('socid', 'int');
  34. $action = GETPOST('action', 'aZ09');
  35. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  36. $sortfield = GETPOST("sortfield", "aZ09comma");
  37. $sortorder = GETPOST("sortorder", 'aZ09comma');
  38. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  39. $page = is_numeric($page) ? $page : 0;
  40. $page = $page == -1 ? 0 : $page;
  41. if (!$sortfield) {
  42. $sortfield = "a.datep,a.id";
  43. }
  44. if (!$sortorder) {
  45. $sortorder = "DESC";
  46. }
  47. $offset = $limit * $page;
  48. $pageprev = $page - 1;
  49. $pagenext = $page + 1;
  50. if (GETPOST('actioncode', 'array')) {
  51. $actioncode = GETPOST('actioncode', 'array', 3);
  52. if (!count($actioncode)) {
  53. $actioncode = '0';
  54. }
  55. } else {
  56. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
  57. }
  58. $search_rowid = GETPOST('search_rowid');
  59. $search_agenda_label = GETPOST('search_agenda_label');
  60. $hookmanager->initHooks(array('projectcardinfo'));
  61. // Security check
  62. $id = GETPOST("id", 'int');
  63. $socid = 0;
  64. //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
  65. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  66. if (!$user->hasRight('projet', 'lire')) {
  67. accessforbidden();
  68. }
  69. /*
  70. * Actions
  71. */
  72. $parameters = array('id'=>$socid);
  73. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  74. if ($reshook < 0) {
  75. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  76. }
  77. // Purge search criteria
  78. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
  79. $actioncode = '';
  80. $search_agenda_label = '';
  81. }
  82. /*
  83. * View
  84. */
  85. $form = new Form($db);
  86. $object = new Project($db);
  87. if ($id > 0 || !empty($ref)) {
  88. $object->fetch($id, $ref);
  89. $object->fetch_thirdparty();
  90. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  91. $object->fetchComments();
  92. }
  93. $object->info($object->id);
  94. }
  95. $agenda = (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) ? '/'.$langs->trans("Agenda") : '';
  96. $title = $langs->trans('Events').$agenda.' - '.$object->ref.' '.$object->name;
  97. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  98. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
  99. }
  100. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  101. llxHeader("", $title, $help_url);
  102. $head = project_prepare_head($object);
  103. print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  104. // Project card
  105. if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
  106. $tmpurl = $_SESSION['pageforbacktolist']['project'];
  107. $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
  108. $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  109. } else {
  110. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  111. }
  112. $morehtmlref = '<div class="refidno">';
  113. // Title
  114. $morehtmlref .= $object->title;
  115. // Thirdparty
  116. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  117. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
  118. }
  119. $morehtmlref .= '</div>';
  120. // Define a complementary filter for search of next/prev ref.
  121. if (!$user->hasRight('projet', 'all', 'lire')) {
  122. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  123. $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  124. }
  125. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  126. print '<div class="fichecenter">';
  127. print '<div class="underbanner clearboth"></div>';
  128. dol_print_object_info($object, 1);
  129. print '</div>';
  130. print '<div class="clearboth"></div>';
  131. print dol_get_fiche_end();
  132. // Actions buttons
  133. $out = '';
  134. $permok = $user->hasRight('agenda', 'myactions', 'create');
  135. if ($permok) {
  136. $out .= '&projectid='.$object->id;
  137. }
  138. //print '</div>';
  139. if (!empty($object->id)) {
  140. print '<br>';
  141. //print '<div class="tabsAction">';
  142. $morehtmlcenter = '';
  143. // Show link to change view in message
  144. $messagingUrl = DOL_URL_ROOT.'/projet/messaging.php?id='.$object->id;
  145. $morehtmlcenter .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 2);
  146. // Show link to change view in agenda
  147. $messagingUrl = DOL_URL_ROOT.'/projet/agenda.php?id='.$object->id;
  148. $morehtmlcenter .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1);
  149. // // Show link to send an email (if read and not closed)
  150. // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
  151. // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&private_message=0&send_email=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
  152. // $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus);
  153. // // Show link to add a private message (if read and not closed)
  154. // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
  155. // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
  156. // $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
  157. // Show link to add event
  158. if (isModEnabled('agenda')) {
  159. $addActionBtnRight = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
  160. $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight);
  161. }
  162. $param = '&id='.$object->id;
  163. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  164. $param .= '&contextpage='.$contextpage;
  165. }
  166. if ($limit > 0 && $limit != $conf->liste_limit) {
  167. $param .= '&limit='.$limit;
  168. }
  169. print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 0);
  170. // List of all actions
  171. $filters = array();
  172. $filters['search_agenda_label'] = $search_agenda_label;
  173. $filters['search_rowid'] = $search_rowid;
  174. show_actions_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  175. }
  176. // End of page
  177. llxFooter();
  178. $db->close();