dolibarr 25.0.0-alpha
comment.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
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
28// Load Dolibarr environment
29require '../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
31require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
38require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
39
48// Load translation files required by the page
49$langs->loadLangs(array('projects', 'companies'));
50
51$id = GETPOSTINT('id');
52$idcomment = GETPOSTINT('idcomment');
53$ref = GETPOST("ref", 'alpha', 1); // task ref
54$objectref = GETPOST("taskref", 'alpha'); // task ref
55$action = GETPOST('action', 'aZ09');
56$confirm = GETPOST('confirm', 'alpha');
57$withproject = GETPOSTINT('withproject');
58$mode = GETPOST('mode', 'aZ');
59
60$mode = GETPOST('mode');
61
62// Security check
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 assignment.
65if (!$user->hasRight('projet', 'lire')) {
67}
68
69// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
70$hookmanager->initHooks(array('projectcard', 'globalcard'));
71
72$extrafields = new ExtraFields($db);
73$object = new Project($db);
74
75// fetch optionals attributes and labels
76$extrafields->fetch_name_optionals_label($object->table_element);
77
78// Load object
79if ($id > 0 || !empty($ref)) {
80 $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
81 if ($ret > 0) {
82 $object->fetch_thirdparty();
83 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
84 $object->fetchComments();
85 }
86 $id = $object->id;
87 }
88}
89
90// Security check - scoped to the specific project
91restrictedArea($user, 'projet', $object->id, 'projet&project');
92
93// include comment actions (after security check to prevent IDOR)
94include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
95
96/*
97 * View
98*/
99
100$title = $langs->trans('CommentPage');
101
102llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-project page-card_comment');
103
104$form = new Form($db);
105$formother = new FormOther($db);
106$formfile = new FormFile($db);
107
108// Tabs for project
109$tab = 'project_comment';
110$head = project_prepare_head($object);
111print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
112
113$param = ($mode == 'mine' ? '&mode=mine' : '');
114
115// Project card
116
117if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
118 $tmpurl = $_SESSION['pageforbacktolist']['project'];
119 $tmpurl = preg_replace('/__SOCID__/', (string) $object->socid, $tmpurl);
120 $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
121} else {
122 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
123}
124
125$morehtmlref = '<div class="refidno">';
126// Title
127$morehtmlref .= $object->title;
128// Thirdparty
129if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
130 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
131}
132$morehtmlref .= '</div>';
133
134// Define a complementary filter for search of next/prev ref.
135if (!$user->hasRight('projet', 'all', 'lire')) {
136 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
137 $object->next_prev_filter = "rowid:IN:".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0');
138}
139
140dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
141
142print '<div class="fichecenter">';
143print '<div class="fichehalfleft">';
144print '<div class="underbanner clearboth"></div>';
145
146print '<table class="border centpercent">';
147
148// Visibility
149print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
150if ($object->public) {
151 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
152 print $langs->trans('SharedProject');
153} else {
154 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
155 print $langs->trans('PrivateProject');
156}
157print '</td></tr>';
158
159// Budget
160print '<tr><td>'.$langs->trans("Budget").'</td><td>';
161if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
162 print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
163}
164print '</td></tr>';
165
166// Date start - end project
167print '<tr><td>'.$langs->trans("Dates").'</td><td>';
168print dol_print_date($object->date_start, 'day');
169$end = dol_print_date($object->date_end, 'day');
170if ($end) {
171 print ' - '.$end;
172}
173print '</td></tr>';
174
175// Other attributes
176$cols = 2;
177// include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
178
179print '</table>';
180
181print '</div>';
182print '<div class="fichehalfright">';
183print '<div class="underbanner clearboth"></div>';
184
185print '<table class="border centpercent">';
186
187// Description
188print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
189print nl2br($object->description);
190print '</td></tr>';
191
192// Categories
193if (isModEnabled('category')) {
194 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
195 print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
196 print "</td></tr>";
197}
198
199// Nb comments
200print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
201print $object->getNbComments();
202print '</td></tr>';
203
204print '</table>';
205
206print '</div>';
207print '</div>';
208
209print '<div class="clearboth"></div>';
210
211print dol_get_fiche_end();
212
213print '<br>';
214
215// Include comment tpl view
216include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
217
218// End of page
219llxFooter();
220$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage projects.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.