dolibarr  19.0.0-dev
projects.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
3  * Copyright (C) 2005-2013 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
5  * Copyright (C) 2014-2015 Marcos GarcĂ­a <marcosgdf@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
26 if (!defined('NOTOKENRENEWAL')) {
27  define('NOTOKENRENEWAL', 1); // Disables token renewal
28 }
29 if (!defined('NOREQUIREMENU')) {
30  define('NOREQUIREMENU', '1');
31 }
32 if (!defined('NOREQUIREHTML')) {
33  define('NOREQUIREHTML', '1');
34 }
35 if (!defined('NOREQUIREAJAX')) {
36  define('NOREQUIREAJAX', '1');
37 }
38 if (!defined('NOREQUIRESOC')) {
39  define('NOREQUIRESOC', '1');
40 }
41 if (!defined('NOREQUIREHTML')) {
42  define('NOREQUIREHTML', '1');
43 }
44 
45 // Load Dolibarr environment
46 require '../../main.inc.php';
47 
48 $htmlname = GETPOST('htmlname', 'aZ09');
49 $socid = GETPOST('socid', 'int');
50 $mode = GETPOST('mode', 'aZ09');
51 $discard_closed = GETPOST('discardclosed', 'int');
52 
53 // Security check
54 restrictedArea($user, 'projet', 0, 'projet&project');
55 
56 
57 /*
58  * View
59  */
60 
61 dol_syslog("Call ajax projet/ajax/projects.php");
62 
63 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
64 
65 top_httphead('application/json');
66 
67 if (empty($htmlname) && !GETPOST('mode', 'aZ09')) {
68  return;
69 }
70 
71 // Mode to get list of projects
72 if (empty($mode) || $mode != 'gettasks') {
73  // When used from jQuery, the search term is added as GET param "term".
74  $searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : '');
75 
76  $formproject = new FormProjets($db);
77  $arrayresult = $formproject->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
78 }
79 
80 // Mode to get list of tasks
81 if ($mode == 'gettasks') {
82  $formproject = new FormProjets($db);
83  $formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
84  return;
85 }
86 
87 
88 $db->close();
89 
90 print json_encode($arrayresult);
Class to manage building of HTML components.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined('NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1494
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.