From 729a6aa364fa3f12cee948dc4d699a47b3ef62bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 25 Oct 2020 12:17:43 +0100 Subject: [PATCH] hook list --- htdocs/zapier/class/api_zapier.class.php | 24 +++++------ htdocs/zapier/hook_list.php | 54 ++++++++++++------------ 2 files changed, 37 insertions(+), 41 deletions(-) diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 9fbaf56c303..76c610fa2cd 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,9 +18,7 @@ use Luracast\Restler\RestException; -dol_include_once('/zapier/class/hook.class.php'); - - +require_once DOL_DOCUMENT_ROOT.'/zapier/class/hook.class.php'; /** * \file htdocs/zapier/class/api_zapier.class.php @@ -91,7 +89,6 @@ class ZapierApi extends DolibarrApi return $this->_cleanObjectDatas($this->hook); } - /** * Get list of possibles choices for module * @@ -126,16 +123,15 @@ class ZapierApi extends DolibarrApi return $arraychoices; } - /** * List hooks * * Get a list of hooks * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of order objects * @@ -211,12 +207,12 @@ class ZapierApi extends DolibarrApi } $result = $this->db->query($sql); - $i = 0; + $i = 0; if ($result) { - $num = $this->db->num_rows($result); + $num = $this->db->num_rows($result); while ($i < $num) { - $obj = $this->db->fetch_object($result); - $hook_static = new Hook($this->db); + $obj = $this->db->fetch_object($result); + $hook_static = new Hook($this->db); if ($hook_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($hook_static); } diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php index d36d909b399..9e987d88322 100644 --- a/htdocs/zapier/hook_list.php +++ b/htdocs/zapier/hook_list.php @@ -28,10 +28,10 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once __DIR__.'/class/hook.class.php'; +require_once DOL_DOCUMENT_ROOT.'/zapier/class/hook.class.php'; // Load translation files required by the page -$langs->loadLangs(array("mymodule@mymodule", "other")); +$langs->loadLangs(array("zapier", "other")); // The action 'add', 'create', 'edit', 'update', 'view', ... $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; @@ -51,7 +51,7 @@ $id = GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : (int) GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $page = 0; @@ -65,9 +65,9 @@ $pagenext = $page + 1; // Initialize technical objects $object = new Hook($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->zapier->dir_output.'/temp/massgeneration/'.$user->id; // Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('hooklist')); +$hookmanager->initHooks(array('zapierhooklist')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -90,7 +90,7 @@ if ($user->socid > 0) { //$socid = $user->socid; accessforbidden(); } -//$result = restrictedArea($user, 'mymodule', $id, ''); +//$result = restrictedArea($user, 'zapier', $id, ''); // Initialize array of search criterias $search_all = GETPOST("search_all", 'alpha'); @@ -160,9 +160,9 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Hook'; $objectlabel = 'Hook'; - $permissiontoread = $user->rights->mymodule->read; - $permissiontodelete = $user->rights->mymodule->delete; - $uploaddir = $conf->mymodule->dir_output; + $permissiontoread = $user->rights->zapier->read; + $permissiontodelete = $user->rights->zapier->delete; + $uploaddir = $conf->zapier->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -283,19 +283,19 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ llxHeader('', $title, $help_url); // Example : Adding jquery code -print ''; +// print ''; $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -320,7 +320,7 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if ($user->rights->zapier->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -335,7 +335,7 @@ print ''; print ''; $newcardbutton = ''; -//if ($user->rights->mymodule->creer) +//if ($user->rights->zapier->creer) //{ $newcardbutton = ''.$langs->trans('New').''; $newcardbutton .= ''; @@ -581,10 +581,10 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->mymodule->read; - $delallowed = $user->rights->mymodule->create; + $genallowed = $user->rights->zapier->read; + $delallowed = $user->rights->zapier->create; - print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + print $formfile->showdocuments('massfilesarea_zapier', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page