messaging.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. $contextpage = GETPOST('contextpage', 'aZ09');
  36. $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
  37. $sortfield = GETPOST("sortfield", "aZ09comma");
  38. $sortorder = GETPOST("sortorder", 'aZ09comma');
  39. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  40. $page = is_numeric($page) ? $page : 0;
  41. $page = $page == -1 ? 0 : $page;
  42. if (!$sortfield) {
  43. $sortfield = "a.datep,a.id";
  44. }
  45. if (!$sortorder) {
  46. $sortorder = "DESC";
  47. }
  48. $offset = $limit * $page;
  49. $pageprev = $page - 1;
  50. $pagenext = $page + 1;
  51. if (GETPOST('actioncode', 'array')) {
  52. $actioncode = GETPOST('actioncode', 'array', 3);
  53. if (!count($actioncode)) {
  54. $actioncode = '0';
  55. }
  56. } else {
  57. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
  58. }
  59. $search_rowid = GETPOST('search_rowid');
  60. $search_agenda_label = GETPOST('search_agenda_label');
  61. $hookmanager->initHooks(array('projectcardinfo'));
  62. // Security check
  63. $id = GETPOST("id", 'int');
  64. $socid = 0;
  65. //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.
  66. $result = restrictedArea($user, 'projet', $id, 'projet&project');
  67. if (!$user->hasRight('projet', 'lire')) {
  68. accessforbidden();
  69. }
  70. /*
  71. * Actions
  72. */
  73. $parameters = array('id'=>$socid);
  74. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  75. if ($reshook < 0) {
  76. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  77. }
  78. // Purge search criteria
  79. 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
  80. $actioncode = '';
  81. $search_agenda_label = '';
  82. }
  83. /*
  84. * View
  85. */
  86. $form = new Form($db);
  87. $object = new Project($db);
  88. if ($id > 0 || !empty($ref)) {
  89. $object->fetch($id, $ref);
  90. $object->fetch_thirdparty();
  91. if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) {
  92. $object->fetchComments();
  93. }
  94. $object->info($object->id);
  95. }
  96. $agenda = (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) ? '/'.$langs->trans("Agenda") : '';
  97. $title = $langs->trans('Events').$agenda.' - '.$object->ref.' '.$object->name;
  98. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  99. $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
  100. }
  101. $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
  102. llxHeader("", $title, $help_url);
  103. $head = project_prepare_head($object);
  104. print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
  105. // Project card
  106. if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
  107. $tmpurl = $_SESSION['pageforbacktolist']['project'];
  108. $tmpurl = preg_replace('/__SOCID__/', $object->socid, $tmpurl);
  109. $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  110. } else {
  111. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  112. }
  113. $morehtmlref = '<div class="refidno">';
  114. // Title
  115. $morehtmlref .= $object->title;
  116. // Thirdparty
  117. if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
  118. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
  119. }
  120. $morehtmlref .= '</div>';
  121. // Define a complementary filter for search of next/prev ref.
  122. if (!$user->hasRight('projet', 'all', 'lire')) {
  123. $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
  124. $object->next_prev_filter = "rowid IN (".$db->sanitize(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
  125. }
  126. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
  127. print '<div class="fichecenter">';
  128. print '<div class="underbanner clearboth"></div>';
  129. dol_print_object_info($object, 1);
  130. print '</div>';
  131. print '<div class="clearboth"></div>';
  132. print dol_get_fiche_end();
  133. // Actions buttons
  134. $out = '';
  135. $permok = $user->hasRight('agenda', 'myactions', 'create');
  136. if ($permok) {
  137. $out .= '&projectid='.$object->id;
  138. }
  139. //print '</div>';
  140. if (!empty($object->id)) {
  141. print '<br>';
  142. //print '<div class="tabsAction">';
  143. $morehtmlright = '';
  144. // Show link to change view in message
  145. $messagingUrl = DOL_URL_ROOT.'/projet/messaging.php?id='.$object->id;
  146. $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 2);
  147. // Show link to change view in agenda
  148. $messagingUrl = DOL_URL_ROOT.'/projet/agenda.php?id='.$object->id;
  149. $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1);
  150. // // Show link to send an email (if read and not closed)
  151. // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
  152. // $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';
  153. // $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus);
  154. // // Show link to add a private message (if read and not closed)
  155. // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
  156. // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
  157. // $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
  158. // Show link to add event
  159. if (isModEnabled('agenda')) {
  160. $addActionBtnRight = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
  161. $morehtmlright .= 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);
  162. }
  163. $param = '&id='.$object->id;
  164. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  165. $param .= '&contextpage='.urlencode($contextpage);
  166. }
  167. if ($limit > 0 && $limit != $conf->liste_limit) {
  168. $param .= '&limit='.((int) $limit);
  169. }
  170. require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
  171. $cachekey = 'count_events_project_'.$object->id;
  172. $nbEvent = dol_getcache($cachekey);
  173. $titlelist = $langs->trans("ActionsOnProject").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>': '');
  174. print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
  175. // List of all actions
  176. $filters = array();
  177. $filters['search_agenda_label'] = $search_agenda_label;
  178. $filters['search_rowid'] = $search_rowid;
  179. show_actions_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  180. }
  181. // End of page
  182. llxFooter();
  183. $db->close();