dolibarr 24.0.1
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 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
59$mode = GETPOST('mode');
60
61// Security check
62$socid = 0;
63//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.
64if (!$user->hasRight('projet', 'lire')) {
66}
67
68// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
69$hookmanager->initHooks(array('projectcard', 'globalcard'));
70
71$extrafields = new ExtraFields($db);
72$object = new Project($db);
73
74// fetch optionals attributes and labels
75$extrafields->fetch_name_optionals_label($object->table_element);
76
77// Load object
78if ($id > 0 || !empty($ref)) {
79 $ret = $object->fetch($id, $ref); // If we create project, ref may be defined into POST but record does not yet exists into database
80 if ($ret > 0) {
81 $object->fetch_thirdparty();
82 if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
83 $object->fetchComments();
84 }
85 $id = $object->id;
86 }
87}
88
89// Security check - scoped to the specific project
90restrictedArea($user, 'projet', $object->id, 'projet&project');
91
92// include comment actions (after security check to prevent IDOR)
93include DOL_DOCUMENT_ROOT.'/core/actions_comments.inc.php';
94
95/*
96 * View
97*/
98
99$title = $langs->trans('CommentPage');
100
101llxHeader('', $title, '', '', 0, 0, '', '', '', 'mod-project page-card_comment');
102
103$form = new Form($db);
104$formother = new FormOther($db);
105$formfile = new FormFile($db);
106
107// Tabs for project
108$tab = 'project_comment';
109$head = project_prepare_head($object);
110print dol_get_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
111
112$param = ($mode == 'mine' ? '&mode=mine' : '');
113
114// Project card
115
116if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
117 $tmpurl = $_SESSION['pageforbacktolist']['project'];
118 $tmpurl = preg_replace('/__SOCID__/', (string) $object->socid, $tmpurl);
119 $linkback = '<a href="'.$tmpurl.(preg_match('/\?/', $tmpurl) ? '&' : '?'). 'restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
120} else {
121 $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
122}
123
124$morehtmlref = '<div class="refidno">';
125// Title
126$morehtmlref .= $object->title;
127// Thirdparty
128if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
129 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'project');
130}
131$morehtmlref .= '</div>';
132
133// Define a complementary filter for search of next/prev ref.
134if (!$user->hasRight('projet', 'all', 'lire')) {
135 $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
136 $object->next_prev_filter = "rowid:IN:".$db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0');
137}
138
139dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
140
141print '<div class="fichecenter">';
142print '<div class="fichehalfleft">';
143print '<div class="underbanner clearboth"></div>';
144
145print '<table class="border centpercent">';
146
147// Visibility
148print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
149if ($object->public) {
150 print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"');
151 print $langs->trans('SharedProject');
152} else {
153 print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"');
154 print $langs->trans('PrivateProject');
155}
156print '</td></tr>';
157
158// Budget
159print '<tr><td>'.$langs->trans("Budget").'</td><td>';
160if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) {
161 print price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
162}
163print '</td></tr>';
164
165// Date start - end project
166print '<tr><td>'.$langs->trans("Dates").'</td><td>';
167print dol_print_date($object->date_start, 'day');
168$end = dol_print_date($object->date_end, 'day');
169if ($end) {
170 print ' - '.$end;
171}
172print '</td></tr>';
173
174// Other attributes
175$cols = 2;
176// include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
177
178print '</table>';
179
180print '</div>';
181print '<div class="fichehalfright">';
182print '<div class="underbanner clearboth"></div>';
183
184print '<table class="border centpercent">';
185
186// Description
187print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
188print nl2br($object->description);
189print '</td></tr>';
190
191// Categories
192if (isModEnabled('category')) {
193 print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
194 print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
195 print "</td></tr>";
196}
197
198// Nb comments
199print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
200print $object->getNbComments();
201print '</td></tr>';
202
203print '</table>';
204
205print '</div>';
206print '</div>';
207
208print '<div class="clearboth"></div>';
209
210print dol_get_fiche_end();
211
212print '<br>';
213
214// Include comment tpl view
215include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_comment.tpl.php';
216
217// End of page
218llxFooter();
219$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:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
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, $mode=0)
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.