1 | <?php |
||
2 | |||
3 | /* Copyright (C) 2005 Rodolphe Quiedeville <[email protected]> |
||
4 | * Copyright (C) 2006-2017 Laurent Destailleur <[email protected]> |
||
5 | * Copyright (C) 2010-2012 Regis Houssin <[email protected]> |
||
6 | * Copyright (C) 2024 MDW <[email protected]> |
||
7 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||
8 | * |
||
9 | * This program is free software; you can redistribute it and/or modify |
||
10 | * it under the terms of the GNU General Public License as published by |
||
11 | * the Free Software Foundation; either version 3 of the License, or |
||
12 | * (at your option) any later version. |
||
13 | * |
||
14 | * This program is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU General Public License |
||
20 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
21 | */ |
||
22 | |||
23 | use Dolibarr\Code\Categories\Classes\Categorie; |
||
24 | use Dolibarr\Code\Core\Classes\ExtraFields; |
||
25 | use Dolibarr\Code\Core\Classes\Form; |
||
26 | use Dolibarr\Code\Core\Classes\FormFile; |
||
27 | use Dolibarr\Code\Core\Classes\FormOther; |
||
28 | use Dolibarr\Code\Projet\Classes\Project; |
||
29 | use Dolibarr\Lib\ViewMain; |
||
30 | |||
31 | /** |
||
32 | * \file htdocs/projet/comment.php |
||
33 | * \ingroup project |
||
34 | * \brief Page of a project |
||
35 | */ |
||
36 | |||
37 | // Load Dolibarr environment |
||
38 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||
39 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/project.lib.php'; |
||
40 | |||
41 | // Load translation files required by the page |
||
42 | $langs->loadLangs(array('projects', 'companies')); |
||
43 | |||
44 | $id = GETPOSTINT('id'); |
||
45 | $idcomment = GETPOSTINT('idcomment'); |
||
46 | $ref = GETPOST("ref", 'alpha', 1); // task ref |
||
47 | $objectref = GETPOST("taskref", 'alpha'); // task ref |
||
48 | $action = GETPOST('action', 'aZ09'); |
||
49 | $confirm = GETPOST('confirm', 'alpha'); |
||
50 | $withproject = GETPOSTINT('withproject'); |
||
51 | |||
52 | // Security check |
||
53 | $socid = 0; |
||
54 | //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. |
||
55 | if (!$user->hasRight('projet', 'lire')) { |
||
56 | accessforbidden(); |
||
57 | } |
||
58 | |||
59 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
60 | $hookmanager->initHooks(array('projectcard', 'globalcard')); |
||
61 | |||
62 | $extrafields = new ExtraFields($db); |
||
63 | $object = new Project($db); |
||
64 | |||
65 | // fetch optionals attributes and labels |
||
66 | $extrafields->fetch_name_optionals_label($object->table_element); |
||
67 | |||
68 | // Load object |
||
69 | if ($id > 0 || !empty($ref)) { |
||
70 | $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database |
||
71 | if ($ret > 0) { |
||
72 | $object->fetch_thirdparty(); |
||
73 | if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) { |
||
74 | $object->fetchComments(); |
||
75 | } |
||
76 | $id = $object->id; |
||
77 | } |
||
78 | } |
||
79 | |||
80 | // include comment actions |
||
81 | include DOL_DOCUMENT_ROOT . '/core/actions_comments.inc.php'; |
||
82 | |||
83 | /* |
||
84 | * View |
||
85 | */ |
||
86 | |||
87 | $title = $langs->trans('CommentPage'); |
||
88 | |||
89 | ViewMain::llxHeader('', $title, ''); |
||
90 | |||
91 | $form = new Form($db); |
||
92 | $formother = new FormOther($db); |
||
93 | $formfile = new FormFile($db); |
||
94 | |||
95 | // Tabs for project |
||
96 | $tab = 'project_comment'; |
||
97 | $head = project_prepare_head($object); |
||
98 | print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public ? 'projectpub' : 'project')); |
||
99 | |||
100 | $param = ($mode == 'mine' ? '&mode=mine' : ''); |
||
101 | |||
102 | // Project card |
||
103 | |||
104 | if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) { |
||
105 | $tmpurl = $_SESSION['pageforbacktolist']['project']; |
||
106 | $tmpurl = preg_replace('/__SOCID__/', (string)$object->socid, $tmpurl); |
||
107 | $linkback = '<a href="' . $tmpurl . (preg_match('/\?/', $tmpurl) ? '&' : '?') . 'restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
108 | } else { |
||
109 | $linkback = '<a href="' . constant('BASE_URL') . '/projet/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
110 | } |
||
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'); |
||
0 ignored issues
–
show
|
|||
118 | } |
||
119 | $morehtmlref .= '</div>'; |
||
120 | |||
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) ? implode(',', array_keys($objectsListId)) : '0') . ")"; |
||
125 | } |
||
126 | |||
127 | dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); |
||
128 | |||
129 | print '<div class="fichecenter">'; |
||
130 | print '<div class="fichehalfleft">'; |
||
131 | print '<div class="underbanner clearboth"></div>'; |
||
132 | |||
133 | print '<table class="border centpercent">'; |
||
134 | |||
135 | // Visibility |
||
136 | print '<tr><td class="titlefield">' . $langs->trans("Visibility") . '</td><td>'; |
||
137 | if ($object->public) { |
||
138 | print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); |
||
139 | print $langs->trans('SharedProject'); |
||
140 | } else { |
||
141 | print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); |
||
142 | print $langs->trans('PrivateProject'); |
||
143 | } |
||
144 | print '</td></tr>'; |
||
145 | |||
146 | // Budget |
||
147 | print '<tr><td>' . $langs->trans("Budget") . '</td><td>'; |
||
148 | if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { |
||
149 | print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); |
||
150 | } |
||
151 | print '</td></tr>'; |
||
152 | |||
153 | // Date start - end project |
||
154 | print '<tr><td>' . $langs->trans("Dates") . '</td><td>'; |
||
155 | print dol_print_date($object->date_start, 'day'); |
||
156 | $end = dol_print_date($object->date_end, 'day'); |
||
157 | if ($end) { |
||
158 | print ' - ' . $end; |
||
159 | } |
||
160 | print '</td></tr>'; |
||
161 | |||
162 | // Other attributes |
||
163 | $cols = 2; |
||
164 | // include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; |
||
165 | |||
166 | print '</table>'; |
||
167 | |||
168 | print '</div>'; |
||
169 | print '<div class="fichehalfright">'; |
||
170 | print '<div class="underbanner clearboth"></div>'; |
||
171 | |||
172 | print '<table class="border centpercent">'; |
||
173 | |||
174 | // Description |
||
175 | print '<td class="titlefield tdtop">' . $langs->trans("Description") . '</td><td>'; |
||
176 | print nl2br($object->description); |
||
177 | print '</td></tr>'; |
||
178 | |||
179 | // Categories |
||
180 | if (isModEnabled('category')) { |
||
181 | print '<tr><td class="valignmiddle">' . $langs->trans("Categories") . '</td><td>'; |
||
182 | print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); |
||
183 | print "</td></tr>"; |
||
184 | } |
||
185 | |||
186 | // Nb comments |
||
187 | print '<td class="titlefield">' . $langs->trans("NbComments") . '</td><td>'; |
||
188 | print $object->getNbComments(); |
||
189 | print '</td></tr>'; |
||
190 | |||
191 | print '</table>'; |
||
192 | |||
193 | print '</div>'; |
||
194 | print '</div>'; |
||
195 | |||
196 | print '<div class="clearboth"></div>'; |
||
197 | |||
198 | print dol_get_fiche_end(); |
||
199 | |||
200 | print '<br>'; |
||
201 | |||
202 | // Include comment tpl view |
||
203 | include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_comment.tpl.php'; |
||
204 | |||
205 | // End of page |
||
206 | ViewMain::llxFooter(); |
||
207 | $db->close(); |
||
208 |
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.