From 8b6dea218b7c1d7bfae68875b2e15492f7dd80b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Mar 2018 18:28:27 +0100 Subject: [PATCH] Dolibarrize module --- htdocs/core/modules/modTicketsup.class.php | 51 ++++++-------- .../class/actions_ticketsup.class.php | 70 +++++++++---------- .../ticketsup/class/api_ticketsups.class.php | 8 +-- htdocs/ticketsup/list.php | 30 ++++---- htdocs/ticketsup/new.php | 2 +- 5 files changed, 75 insertions(+), 86 deletions(-) diff --git a/htdocs/core/modules/modTicketsup.class.php b/htdocs/core/modules/modTicketsup.class.php index 52830ef4924..38299617788 100644 --- a/htdocs/core/modules/modTicketsup.class.php +++ b/htdocs/core/modules/modTicketsup.class.php @@ -1,6 +1,5 @@ +/* Copyright (C) - 2013-2018 Jean-François FERRY * * 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 @@ -14,17 +13,20 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * Module descriptor for ticket system */ /** * \defgroup ticketsup Ticketsup module - * \brief Ticketsup module descriptor. + * \brief Ticketsup module descriptor. * \file core/modules/modTicketsup.class.php - * \ingroup ticketsup - * \brief Description and activation file for module Ticketsup + * \ingroup ticketsup + * \brief Description and activation file for module Ticketsup */ require_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php"; + /** * Description and activation class for module Ticketsup */ @@ -45,13 +47,10 @@ class modTicketsup extends DolibarrModules // Id for module (must be unique). // Use a free id here // (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 110120; + $this->numero = 56000; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'ticketsup'; - $this->editor_name = "Dolibarr"; - $this->editor_web = "https://dolibrr.org"; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page $this->family = "crm"; @@ -70,9 +69,6 @@ class modTicketsup extends DolibarrModules // Key used in llx_const table to save module status enabled/disabled // (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); - // Where to store the module in setup page - // (0=common,1=interface,2=others,3=very specific) - $this->special = 2; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png // use this->picto='pictovalue' @@ -119,7 +115,7 @@ class modTicketsup extends DolibarrModules $this->requiredby = array(); // Minimum version of PHP required by module $this->phpmin = array(5, 3); - $this->langfiles = array("ticketsup"); + $this->langfiles = array("ticketsup"); // Constants // List of particular constants to add when module is enabled // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) @@ -168,43 +164,36 @@ class modTicketsup extends DolibarrModules $r = 0; $r++; - $this->rights[$r][0] = 110120; // id de la permission - $this->rights[$r][1] = "Créer un ticket"; // libelle de la permission - $this->rights[$r][2] = 'c'; // type de la permission (deprecie a ce jour) - $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'create'; - - $r++; - $this->rights[$r][0] = 110121; // id de la permission - $this->rights[$r][1] = "Lire les tickets"; // libelle de la permission + $this->rights[$r][0] = 56001; // id de la permission + $this->rights[$r][1] = "Read ticket"; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 1; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'read'; $r++; - $this->rights[$r][0] = 110122; // id de la permission - $this->rights[$r][1] = "Modifier les tickets"; // libelle de la permission + $this->rights[$r][0] = 56002; // id de la permission + $this->rights[$r][1] = "Create les tickets"; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'write'; $r++; - $this->rights[$r][0] = 110123; // id de la permission - $this->rights[$r][1] = "Supprimer les tickets"; // libelle de la permission + $this->rights[$r][0] = 56003; // id de la permission + $this->rights[$r][1] = "Delete les tickets"; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'delete'; $r++; - $this->rights[$r][0] = 110124; // id de la permission - $this->rights[$r][1] = "Gérer les tickets"; // libelle de la permission + $this->rights[$r][0] = 56004; // id de la permission + $this->rights[$r][1] = "Manage tickets"; // libelle de la permission //$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'manage'; $r++; - $this->rights[$r][0] = 110125; // id de la permission - $this->rights[$r][1] = 'Voir tous les tickets (non effectif pour les utilisateurs externes, toujours limités au tiers dont ils dépendent)'; // libelle de la permission + $this->rights[$r][0] = 56005; // id de la permission + $this->rights[$r][1] = 'See all tickets, even if not assigned to (not effective for external users, always restricted to the thirdpardy they depends on)'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'view'; @@ -250,7 +239,7 @@ class modTicketsup extends DolibarrModules 'langs' => 'ticketsup@ticketsup', 'position' => 102, 'enabled' => 1, - 'perms' => '$user->rights->ticketsup->create', + 'perms' => '$user->rights->ticketsup->write', 'target' => '', 'user' => 2); $r++; diff --git a/htdocs/ticketsup/class/actions_ticketsup.class.php b/htdocs/ticketsup/class/actions_ticketsup.class.php index c5ddadf6a54..259be1eca2b 100644 --- a/htdocs/ticketsup/class/actions_ticketsup.class.php +++ b/htdocs/ticketsup/class/actions_ticketsup.class.php @@ -134,7 +134,7 @@ class ActionsTicketsup ////} } - if (GETPOST('add_ticket') && $user->rights->ticketsup->create) { + if (GETPOST('add_ticket') && $user->rights->ticketsup->write) { $error = 0; if (!GETPOST("subject")) { @@ -602,7 +602,7 @@ class ActionsTicketsup } } } - + return 0; } @@ -707,7 +707,7 @@ class ActionsTicketsup if ($conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKETS_NOTIFICATION_EMAIL_TO, $sendto)) { if(!empty($conf->global->TICKETS_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKETS_NOTIFICATION_EMAIL_TO; } - + // altairis: dont try to send email if no recipient if (!empty($sendto)) { $this->sendTicketMessageByEmail($subject, $message, '', $sendto); @@ -779,13 +779,13 @@ class ActionsTicketsup if (!empty($this->dao->origin_email)) { $sendto[] = $this->dao->origin_email; } - + if ($this->dao->fk_soc > 0 && ! in_array($this->dao->origin_email, $sendto)) { $this->dao->socid = $this->dao->fk_soc; $this->dao->fetch_thirdparty(); if(!empty($this->dao->thirdparty->email)) $sendto[] = $this->dao->thirdparty->email; } - + // altairis: Add global email address reciepient if ($conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKETS_NOTIFICATION_EMAIL_TO, $sendto)) { if(!empty($conf->global->TICKETS_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKETS_NOTIFICATION_EMAIL_TO; @@ -963,7 +963,7 @@ class ActionsTicketsup /** * Fetch object - * + * * @param int $id Id * @param int $track_id Track id * @param string $ref Ref @@ -977,7 +977,7 @@ class ActionsTicketsup /** * print statut - * + * * @param int $mode Mode * @return void */ @@ -1088,7 +1088,7 @@ class ActionsTicketsup print '
' . $langs->trans('NoLogForThisTicket') . '
'; } } - + /** * View list of logs with timeline view * @@ -1098,10 +1098,10 @@ class ActionsTicketsup public function viewTimelineTicketLogs($show_user = true) { global $conf, $langs, $bc; - + // Load logs in cache $ret = $this->dao->loadCacheLogsTicket(); - + if (is_array($this->dao->cache_logs_ticket) && count($this->dao->cache_logs_ticket) > 0) { print '
'; @@ -1110,13 +1110,13 @@ class ActionsTicketsup print '
'; //print ''; print '
'; - + print '
'; print dol_nl2br($arraylogs['message']); - + print ''; print dol_print_date($arraylogs['datec'], 'dayhour'); - + if ($show_user) { if ($arraylogs['fk_user_create'] > 0) { $userstat = new User($this->db); @@ -1148,13 +1148,13 @@ class ActionsTicketsup global $langs; if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') { // MESSAGE - + print '
'; print ''; print ''; print ''; } - + // Initial message print ''; print ''; - + print ''; - + print ''; @@ -1209,7 +1209,7 @@ class ActionsTicketsup $action = GETPOST('action'); $this->viewTicketOriginalMessage($user, $action); - + if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) { print_titre($langs->trans('TicketMailExchanges')); @@ -1264,7 +1264,7 @@ class ActionsTicketsup print '
' . $langs->trans('NoMsgForThisTicket') . '
'; } } - + /** * View list of message for ticket with timeline display * @@ -1275,11 +1275,11 @@ class ActionsTicketsup public function viewTicketTimelineMessages($show_private, $show_user = true) { global $conf, $langs, $user, $bc; - + // Load logs in cache $ret = $this->dao->loadCacheMsgsTicket(); $action = GETPOST('action'); - + if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) { print '
'; @@ -1291,13 +1291,13 @@ class ActionsTicketsup print '
'; print ''; print '
'; - + print '
'; print $arraymsgs['message']; - + print ''; print dol_print_date($arraymsgs['datec'], 'dayhour'); - + if ($show_user) { if ($arraymsgs['fk_user_action'] > 0) { $userstat = new User($this->db); @@ -1324,7 +1324,7 @@ class ActionsTicketsup /** * load_previous_next_ref - * + * * @param string $filter Filter * @param int $fieldid Id * @return int 0 @@ -1420,7 +1420,7 @@ class ActionsTicketsup /** * Copy files into ticket directory * Used for files linked into messages - * + * * @return void */ public function copyFilesForTicket() @@ -1467,7 +1467,7 @@ class ActionsTicketsup /** * Print html navbar with link to set ticket status * $selected : 0=>'NotRead', 1=>'Read', 3=>'Answered', 4=>'Assigned', 5 => 'InProgress', 6=> 'Waiting', 8=>'Closed', 9=>'Deleted' - * + * * @return void */ public function viewStatusActions() @@ -1506,17 +1506,17 @@ class ActionsTicketsup print '

'; } - + /** * deleteObjectLinked - * + * * @return number - */ + */ public function deleteObjectLinked() { return $this->dao->deleteObjectLinked(); } - + /** * Hook to add email element template * @@ -1529,13 +1529,13 @@ class ActionsTicketsup public function emailElementlist($parameters, &$object, &$action, $hookmanager) { global $langs; - + $error = 0; - + if (in_array('admin', explode(':', $parameters['context']))) { $this->results = array('ticketsup_send' => $langs->trans('MailToSendTicketsupMessage')); } - + if (! $error) { return 0; // or return 1 to replace standard code } else { diff --git a/htdocs/ticketsup/class/api_ticketsups.class.php b/htdocs/ticketsup/class/api_ticketsups.class.php index fdfe4adae6c..bda05dd589c 100644 --- a/htdocs/ticketsup/class/api_ticketsups.class.php +++ b/htdocs/ticketsup/class/api_ticketsups.class.php @@ -303,7 +303,7 @@ class Ticketsups extends DolibarrApi public function post($request_data = null) { $ticketstatic = new Ticketsup($this->db); - if (! DolibarrApiAccess::$user->rights->ticketsup->create) { + if (! DolibarrApiAccess::$user->rights->ticketsup->write) { throw new RestException(401); } // Check mandatory fields @@ -334,7 +334,7 @@ class Ticketsups extends DolibarrApi public function postNewMessage($request_data = null) { $ticketstatic = new Ticketsup($this->db); - if (! DolibarrApiAccess::$user->rights->ticketsup->create) { + if (! DolibarrApiAccess::$user->rights->ticketsup->write) { throw new RestException(401); } // Check mandatory fields @@ -365,7 +365,7 @@ class Ticketsups extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->ticketsup->create) { + if (! DolibarrApiAccess::$user->rights->ticketsup->write) { throw new RestException(401); } @@ -398,7 +398,7 @@ class Ticketsups extends DolibarrApi */ public function delete($id) { - if (! DolibarrApiAccess::$user->rights->ticketsup->supprimer) { + if (! DolibarrApiAccess::$user->rights->ticketsup->delete) { throw new RestException(401); } $result = $this->ticketsup->fetch($id); diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index 5661a78de71..43c405c5578 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -159,7 +159,7 @@ if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - + // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { @@ -175,7 +175,7 @@ if (empty($reshook)) { $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation } - + // Mass actions $objectclass='Ticketsup'; $objectlabel='Ticketsup'; @@ -285,14 +285,14 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) else { $sql.= $db->plimit($limit+1, $offset); - + $resql=$db->query($sql); if (! $resql) { dol_print_error($db); exit; } - + $num = $db->num_rows($resql); } @@ -513,7 +513,7 @@ foreach($object->fields as $key => $val) print '
'; - + } elseif ($key == 'type_code') { print ''; } else { - + print ''; } } @@ -586,14 +586,14 @@ while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); if (empty($obj)) break; // Should not happen - + // Store properties in $object $object->id = $obj->rowid; foreach($object->fields as $key => $val) { if (isset($obj->$key)) $object->$key = $obj->$key; } - + // Show here line of result print ''; foreach($object->fields as $key => $val) @@ -633,9 +633,9 @@ while ($i < min($num, $limit)) } print ''; if (! $i) $totalarray['nbfield']++; - + print ''; - + $i++; } @@ -691,18 +691,18 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb { $hidegeneratedfilelistifempty=1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); $formfile = new FormFile($db); - + // Show list of available documents $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->ticketsup->read; - $delallowed=$user->rights->ticketsup->create; - + $delallowed=$user->rights->ticketsup->write; + print $formfile->showdocuments('massfilesarea_ticketsup','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } diff --git a/htdocs/ticketsup/new.php b/htdocs/ticketsup/new.php index 3fb4294f150..4cf1ec3d749 100644 --- a/htdocs/ticketsup/new.php +++ b/htdocs/ticketsup/new.php @@ -44,7 +44,7 @@ $notnotifytiersatcreate = !empty($notNotifyTiers); $action = GETPOST('action', 'alpha', 3); // Protection if external user -if (!$user->rights->ticketsup->read || !$user->rights->ticketsup->create) { +if (!$user->rights->ticketsup->read || !$user->rights->ticketsup->write) { accessforbidden(); }
'; @@ -1163,9 +1163,9 @@ class ActionsTicketsup print '' . img_edit($langs->trans('Modify')) . ' ' . $langs->trans('Modify') . ''; } print '
'; if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') { // MESSAGE @@ -1181,7 +1181,7 @@ class ActionsTicketsup } else { print dol_nl2br($this->dao->message); } - + //print '
' . $this->dao->message . '
'; } print '
'; $object->printSelectStatus(dol_escape_htmltag($search[$key])); print ''; $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1); @@ -527,7 +527,7 @@ foreach($object->fields as $key => $val) $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1); print '