hook list

This commit is contained in:
Frédéric FRANCE 2020-10-25 12:17:43 +01:00
parent 8d08157018
commit 729a6aa364
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
2 changed files with 37 additions and 41 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> /* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -18,9 +18,7 @@
use Luracast\Restler\RestException; 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 * \file htdocs/zapier/class/api_zapier.class.php
@ -91,7 +89,6 @@ class ZapierApi extends DolibarrApi
return $this->_cleanObjectDatas($this->hook); return $this->_cleanObjectDatas($this->hook);
} }
/** /**
* Get list of possibles choices for module * Get list of possibles choices for module
* *
@ -126,16 +123,15 @@ class ZapierApi extends DolibarrApi
return $arraychoices; return $arraychoices;
} }
/** /**
* List hooks * List hooks
* *
* Get a list of hooks * Get a list of hooks
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @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')" * @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 * @return array Array of order objects
* *
@ -211,12 +207,12 @@ class ZapierApi extends DolibarrApi
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
$i = 0; $i = 0;
if ($result) { if ($result) {
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
while ($i < $num) { while ($i < $num) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$hook_static = new Hook($this->db); $hook_static = new Hook($this->db);
if ($hook_static->fetch($obj->rowid)) { if ($hook_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($hook_static); $obj_ret[] = $this->_cleanObjectDatas($hook_static);
} }

View File

@ -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/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.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 // 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', ... // The action 'add', 'create', 'edit', 'update', 'view', ...
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : '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; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', '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 (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 // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$page = 0; $page = 0;
@ -65,9 +65,9 @@ $pagenext = $page + 1;
// Initialize technical objects // Initialize technical objects
$object = new Hook($db); $object = new Hook($db);
$extrafields = new ExtraFields($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 // Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('hooklist')); $hookmanager->initHooks(array('zapierhooklist'));
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
@ -90,7 +90,7 @@ if ($user->socid > 0) {
//$socid = $user->socid; //$socid = $user->socid;
accessforbidden(); accessforbidden();
} }
//$result = restrictedArea($user, 'mymodule', $id, ''); //$result = restrictedArea($user, 'zapier', $id, '');
// Initialize array of search criterias // Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha'); $search_all = GETPOST("search_all", 'alpha');
@ -160,9 +160,9 @@ if (empty($reshook)) {
// Mass actions // Mass actions
$objectclass = 'Hook'; $objectclass = 'Hook';
$objectlabel = 'Hook'; $objectlabel = 'Hook';
$permissiontoread = $user->rights->mymodule->read; $permissiontoread = $user->rights->zapier->read;
$permissiontodelete = $user->rights->mymodule->delete; $permissiontodelete = $user->rights->zapier->delete;
$uploaddir = $conf->mymodule->dir_output; $uploaddir = $conf->zapier->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; 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); llxHeader('', $title, $help_url);
// Example : Adding jquery code // Example : Adding jquery code
print '<script type="text/javascript" language="javascript"> // print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() { // jQuery(document).ready(function() {
function init_myfunc() // function init_myfunc()
{ // {
jQuery("#myid").removeAttr(\'disabled\'); // jQuery("#myid").removeAttr(\'disabled\');
jQuery("#myid").attr(\'disabled\',\'disabled\'); // jQuery("#myid").attr(\'disabled\',\'disabled\');
} // }
init_myfunc(); // init_myfunc();
jQuery("#mybutton").click(function() { // jQuery("#mybutton").click(function() {
init_myfunc(); // init_myfunc();
}); // });
}); // });
</script>'; // </script>';
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
@ -320,7 +320,7 @@ $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->mymodule->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); if ($user->rights->zapier->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
@ -335,7 +335,7 @@ print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton = ''; $newcardbutton = '';
//if ($user->rights->mymodule->creer) //if ($user->rights->zapier->creer)
//{ //{
$newcardbutton = '<a class="butActionNew" href="hook_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle text-plus-circle">'.$langs->trans('New').'</span>'; $newcardbutton = '<a class="butActionNew" href="hook_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']).'"><span class="valignmiddle text-plus-circle">'.$langs->trans('New').'</span>';
$newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>'; $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
@ -581,10 +581,10 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n
$urlsource .= str_replace('&amp;', '&', $param); $urlsource .= str_replace('&amp;', '&', $param);
$filedir = $diroutputmassaction; $filedir = $diroutputmassaction;
$genallowed = $user->rights->mymodule->read; $genallowed = $user->rights->zapier->read;
$delallowed = $user->rights->mymodule->create; $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 // End of page