Issues (2811)

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

Labels
Severity
1
<?php
2
3
/* Copyright (C) 2010       Regis Houssin               <[email protected]>
4
 * Copyright (C) 2012       Laurent Destailleur         <[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\Code\User\Classes\User;
25
use Dolibarr\Lib\ViewMain;
26
27
/**
28
 *  \file       htdocs/projet/note.php
29
 *  \ingroup    project
30
 *  \brief      Fiche d'information sur un projet
31
 */
32
33
// Load Dolibarr environment
34
require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php';
35
require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/project.lib.php';
36
37
// Load translation files required by the page
38
$langs->load('projects');
39
40
$action = GETPOST('action', 'aZ09');
41
$id = GETPOSTINT('id');
42
$ref = GETPOST('ref', 'alpha');
43
44
$mine = (isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'mine') ? 1 : 0;
45
//if (! $user->rights->projet->all->lire) $mine=1;  // Special for projects
46
47
$object = new Project($db);
48
49
include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once
50
if (getDolGlobalString('PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($object, 'fetchComments') && empty($object->comments)) {
51
    $object->fetchComments();
52
}
53
54
// Security check
55
$socid = 0;
56
//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.
57
$hookmanager->initHooks(array('projetnote'));
58
$result = restrictedArea($user, 'projet', $id, 'projet&project');
59
60
$permissionnote = $user->hasRight('projet', 'creer'); // Used by the include of actions_setnotes.inc.php
61
62
63
/*
64
 * Actions
65
 */
66
67
$parameters = array();
68
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
69
if ($reshook < 0) {
70
    setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
71
}
72
if (empty($reshook)) {
73
    include DOL_DOCUMENT_ROOT . '/core/actions_setnotes.inc.php'; // Must be include, not include_once
74
}
75
76
77
/*
78
 * View
79
 */
80
81
$title = $langs->trans("Notes") . ' - ' . $object->ref . ' ' . $object->name;
82
if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/projectnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
83
    $title = $object->ref . ' ' . $object->name . ' - ' . $langs->trans("Note");
84
}
85
$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
86
ViewMain::llxHeader("", $title, $help_url);
87
88
$form = new Form($db);
89
$userstatic = new User($db);
90
91
$now = dol_now();
92
93
if ($id > 0 || !empty($ref)) {
94
    // To verify role of users
95
    //$userAccess = $object->restrictedProjectArea($user,'read');
96
    $userWrite = $object->restrictedProjectArea($user, 'write');
97
    //$userDelete = $object->restrictedProjectArea($user,'delete');
98
    //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
99
100
    $head = project_prepare_head($object);
101
    print dol_get_fiche_head($head, 'notes', $langs->trans('Project'), -1, ($object->public ? 'projectpub' : 'project'));
102
103
104
    // Project card
105
106
    if (!empty($_SESSION['pageforbacktolist']) && !empty($_SESSION['pageforbacktolist']['project'])) {
107
        $tmpurl = $_SESSION['pageforbacktolist']['project'];
108
        $tmpurl = preg_replace('/__SOCID__/', (string)$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="' . constant('BASE_URL') . '/projet/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
112
    }
113
114
    $morehtmlref = '<div class="refidno">';
115
    // Title
116
    $morehtmlref .= $object->title;
117
    // Thirdparty
118
    if (!empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
119
        $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

119
        $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...
120
    }
121
    $morehtmlref .= '</div>';
122
123
    // Define a complementary filter for search of next/prev ref.
124
    if (!$user->hasRight('projet', 'all', 'lire')) {
125
        $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
126
        $object->next_prev_filter = "rowid IN (" . $db->sanitize(count($objectsListId) ? implode(',', array_keys($objectsListId)) : '0') . ")";
127
    }
128
129
    dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
130
131
132
    print '<div class="fichecenter">';
133
    print '<div class="underbanner clearboth"></div>';
134
135
    $cssclass = "titlefield";
136
    include DOL_DOCUMENT_ROOT . '/core/tpl/notes.tpl.php';
137
138
    print '</div>';
139
140
    print '<div class="clearboth"></div>';
141
142
    print dol_get_fiche_end();
143
}
144
145
// End of page
146
ViewMain::llxFooter();
147
$db->close();
148