Issues (2811)

public/htdocs/projet/messaging.php (1 issue)

Labels
Severity
1
<?php
2
3
/* Copyright (C) 2005-2016  Laurent Destailleur         <[email protected]>
4
 * Copyright (C) 2005-2009  Regis Houssin               <[email protected]>
5
 * Copyright (C) 2024		MDW							<[email protected]>
6
 * Copyright (C) 2024       Rafael San José             <[email protected]>
7
 *
8
 * This program is free software; you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation; either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
use Dolibarr\Code\Core\Classes\Form;
23
use Dolibarr\Code\Projet\Classes\Project;
24
use Dolibarr\Lib\ViewMain;
25
26
/**
27
 *      \file       htdocs/projet/messaging.php
28
 *      \ingroup    project
29
 *      \brief      Page with events on project
30
 */
31
32
// Load Dolibarr environment
33
require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php';
34
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/functions2.lib.php';
35
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/project.lib.php';
36
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/company.lib.php';
37
38
// Load translation files required by the page
39
$langs->load("projects");
40
41
$id = GETPOSTINT('id');
42
$ref = GETPOST('ref', 'alpha');
43
$socid = GETPOSTINT('socid');
44
$action = GETPOST('action', 'aZ09');
45
$contextpage = GETPOST('contextpage', 'aZ09');
46
47
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
48
$sortfield = GETPOST("sortfield", "aZ09comma");
49
$sortorder = GETPOST("sortorder", 'aZ09comma');
50
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
51
$page = is_numeric($page) ? $page : 0;
52
$page = $page == -1 ? 0 : $page;
53
if (!$sortfield) {
54
    $sortfield = "a.datep,a.id";
55
}
56
if (!$sortorder) {
57
    $sortorder = "DESC";
58
}
59
$offset = $limit * $page;
60
$pageprev = $page - 1;
61
$pagenext = $page + 1;
62
63
if (GETPOST('actioncode', 'array')) {
64
    $actioncode = GETPOST('actioncode', 'array', 3);
65
    if (!count($actioncode)) {
66
        $actioncode = '0';
67
    }
68
} else {
69
    $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
70
}
71
$search_rowid = GETPOST('search_rowid');
72
$search_agenda_label = GETPOST('search_agenda_label');
73
74
$hookmanager->initHooks(array('projectcardinfo'));
75
76
// Security check
77
$id = GETPOSTINT("id");
78
$socid = 0;
79
//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 assignment.
80
$result = restrictedArea($user, 'projet', $id, 'projet&project');
81
82
if (!$user->hasRight('projet', 'lire')) {
83
    accessforbidden();
84
}
85
86
87
/*
88
 * Actions
89
 */
90
91
$parameters = array('id' => $socid);
92
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
93
if ($reshook < 0) {
94
    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
95
}
96
97
// Purge search criteria
98
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
99
    $actioncode = '';
100
    $search_agenda_label = '';
101
}
102
103
/*
104
 * View
105
 */
106
107
$form = new Form($db);
108
$object = new Project($db);
109
110
if ($id > 0 || !empty($ref)) {
111
    $object->fetch($id, $ref);
112
    $object->fetch_thirdparty();
113
    if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
114
        $object->fetchComments();
115
    }
116
    $object->info($object->id);
117
}
118
$agenda = (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) ? '/' . $langs->trans("Agenda") : '';
119
$title = $langs->trans('Events') . $agenda . ' - ' . $object->ref . ' ' . $object->name;
120
if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/projectnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
121
    $title = $object->ref . ' ' . $object->name . ' - ' . $langs->trans("Info");
122
}
123
$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
124
ViewMain::llxHeader("", $title, $help_url);
125
126
$head = project_prepare_head($object);
127
128
print dol_get_fiche_head($head, 'agenda', $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project'));
129
130
131
// Project card
132
133
if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
134
    $tmpurl = $_SESSION['pageforbacktolist']['project'];
135
    $tmpurl = preg_replace('/__SOCID__/', (string)$object->socid, $tmpurl);
136
    $linkback = '<a href="' . $tmpurl . (preg_match('/\?/', $tmpurl) ? '&' : '?') . 'restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
137
} else {
138
    $linkback = '<a href="' . constant('BASE_URL') . '/projet/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
139
}
140
141
$morehtmlref = '<div class="refidno">';
142
// Title
143
$morehtmlref .= $object->title;
144
// Thirdparty
145
if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
146
    $morehtmlref .= '<br>' . $object->thirdparty->getNomUrl(1, 'project');
0 ignored issues
show
The method getNomUrl() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

146
    $morehtmlref .= '<br>' . $object->thirdparty->/** @scrutinizer ignore-call */ getNomUrl(1, 'project');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
147
}
148
$morehtmlref .= '</div>';
149
150
// Define a complementary filter for search of next/prev ref.
151
if (!$user->hasRight('projet', 'all', 'lire')) {
152
    $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
153
    $object->next_prev_filter = "rowid IN (" . $db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0') . ")";
154
}
155
156
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
157
158
159
print '<div class="fichecenter">';
160
print '<div class="underbanner clearboth"></div>';
161
162
dol_print_object_info($object, 1);
163
164
print '</div>';
165
166
print '<div class="clearboth"></div>';
167
168
print dol_get_fiche_end();
169
170
171
// Actions buttons
172
173
$out = '';
174
$permok = $user->hasRight('agenda', 'myactions', 'create');
175
if ($permok) {
176
    $out .= '&projectid=' . $object->id;
177
}
178
179
180
//print '</div>';
181
182
if (!empty($object->id)) {
183
    print '<br>';
184
185
    //print '<div class="tabsAction">';
186
    $morehtmlright = '';
187
188
    // Show link to change view in message
189
    $messagingUrl = constant('BASE_URL') . '/projet/messaging.php?id=' . $object->id;
190
    $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 2);
191
192
    // Show link to change view in agenda
193
    $messagingUrl = constant('BASE_URL') . '/projet/agenda.php?id=' . $object->id;
194
    $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1);
195
196
197
    // // Show link to send an email (if read and not closed)
198
    // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
199
    // $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';
200
    // $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', $btnstatus);
201
202
    // // Show link to add a private message (if read and not closed)
203
    // $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
204
    // $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
205
    // $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
206
207
    // Show link to add event
208
    if (isModEnabled('agenda')) {
209
        $addActionBtnRight = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
210
        $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', constant('BASE_URL') . '/comm/action/card.php?action=create' . $out . '&socid=' . $object->socid . '&backtopage=' . $_SERVER["PHP_SELF"] . ('?id=' . $object->id), '', $addActionBtnRight);
211
    }
212
213
    $param = '&id=' . $object->id;
214
    if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
215
        $param .= '&contextpage=' . urlencode($contextpage);
216
    }
217
    if ($limit > 0 && $limit != $conf->liste_limit) {
218
        $param .= '&limit=' . ((int)$limit);
219
    }
220
221
    require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/memory.lib.php';
222
    $cachekey = 'count_events_project_' . $object->id;
223
    $nbEvent = dol_getcache($cachekey);
224
225
    $titlelist = $langs->trans("ActionsOnProject") . (is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">(' . $nbEvent . ')</span>' : '');
226
227
    print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
228
229
    // List of all actions
230
    $filters = array();
231
    $filters['search_agenda_label'] = $search_agenda_label;
232
    $filters['search_rowid'] = $search_rowid;
233
234
    show_actions_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
235
}
236
237
// End of page
238
ViewMain::llxFooter();
239
$db->close();
240