2018-03-10 04:23:59 +01:00
< ? php
2018-03-11 18:28:27 +01:00
/* Copyright ( C ) - 2013 - 2018 Jean - François FERRY < hello @ librethic . io >
2018-03-10 04:23:59 +01:00
*
* 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
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2018-03-11 18:28:27 +01:00
*
* Module descriptor for ticket system
2018-03-10 04:23:59 +01:00
*/
/**
2019-02-03 18:47:55 +01:00
* \defgroup ticket Module Ticket
2019-09-04 15:11:06 +02:00
* \brief Module for ticket and request management .
2018-06-04 21:49:29 +02:00
* \file core / modules / modTicket . class . php
* \ingroup ticket
* \brief Description and activation file for module Ticket
2018-03-10 04:23:59 +01:00
*/
require_once DOL_DOCUMENT_ROOT . " /core/modules/DolibarrModules.class.php " ;
2018-03-11 18:28:27 +01:00
2018-03-10 04:23:59 +01:00
/**
2018-06-04 21:49:29 +02:00
* Description and activation class for module Ticket
2018-03-10 04:23:59 +01:00
*/
2018-06-04 21:49:29 +02:00
class modTicket extends DolibarrModules
2018-03-10 04:23:59 +01:00
{
/**
* Constructor . Define names , constants , directories , boxes , permissions
*
* @ param DoliDB $db Database handler
*/
public function __construct ( $db )
{
global $langs , $conf ;
$this -> db = $db ;
// Id for module (must be unique).
// Use a free id here
// (See in Home -> System information -> Dolibarr for list of used modules id).
2018-03-11 18:28:27 +01:00
$this -> numero = 56000 ;
2018-03-10 04:23:59 +01:00
// Key text used to identify module (for permissions, menus, etc...)
2018-06-04 21:49:29 +02:00
$this -> rights_class = 'ticket' ;
2018-03-10 04:23:59 +01:00
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page
$this -> family = " crm " ;
// Module position in the family
2018-10-06 11:57:53 +02:00
$this -> module_position = '60' ;
2018-03-10 04:23:59 +01:00
// Module label (no space allowed)
// used if translation string 'ModuleXXXName' not found
// (where XXX is value of numeric property 'numero' of module)
$this -> name = preg_replace ( '/^mod/i' , '' , get_class ( $this ));
// Module description
// used if translation string 'ModuleXXXDesc' not found
// (where XXX is value of numeric property 'numero' of module)
$this -> description = " Incident/support ticket management " ;
// Possible values for version are: 'development', 'experimental' or version
2019-02-11 19:16:37 +01:00
$this -> version = 'dolibarr' ;
2018-03-10 04:23:59 +01:00
// 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 );
// 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'
// If file is in module/img directory under name object_pictovalue.png
// use this->picto='pictovalue@module'
2018-06-04 21:49:29 +02:00
$this -> picto = 'ticket' ; // mypicto@ticket
2018-03-10 04:23:59 +01:00
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
2018-06-04 21:49:29 +02:00
// for default path (eg: /ticket/core/xxxxx) (0=disable, 1=enable)
// for specific path of parts (eg: /ticket/core/modules/barcode)
// for specific css file (eg: /ticket/css/ticket.css.php)
2018-03-10 04:23:59 +01:00
$this -> module_parts = array (
// Set this to 1 if module has its own trigger directory
'triggers' => 1 ,
);
// Data directories to create when module is enabled.
2018-06-04 21:49:29 +02:00
// Example: this->dirs = array("/ticket/temp");
2018-03-10 04:23:59 +01:00
$this -> dirs = array ();
// Config pages. Put here list of php pages
2018-06-04 21:49:29 +02:00
// stored into ticket/admin directory, used to setup module.
$this -> config_page_url = array ( " ticket.php " );
2018-03-10 04:23:59 +01:00
// Dependencies
2018-07-10 22:32:55 +02:00
$this -> hidden = false ; // A condition to hide module
2019-04-10 15:11:38 +02:00
$this -> depends = array ( 'modAgenda' ); // List of module class names as string that must be enabled if this module is enabled
2018-07-10 22:32:55 +02:00
$this -> requiredby = array (); // List of module ids to disable if this one is disabled
$this -> conflictwith = array (); // List of module class names as string this module is in conflict with
$this -> phpmin = array ( 5 , 4 ); // Minimum version of PHP required by module
2018-06-04 21:49:29 +02:00
$this -> langfiles = array ( " ticket " );
2019-06-19 12:53:28 +02:00
2018-03-10 04:23:59 +01:00
// Constants
// List of particular constants to add when module is enabled
// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example:
2019-03-04 19:19:09 +01:00
$this -> const = array (
1 => array ( 'TICKET_ENABLE_PUBLIC_INTERFACE' , 'chaine' , '0' , 'Enable ticket public interface' , 0 ),
2 => array ( 'TICKET_ADDON' , 'chaine' , 'mod_ticket_simple' , 'Ticket ref module' , 0 )
);
2018-03-10 04:23:59 +01:00
$this -> tabs = array (
2018-06-04 21:49:29 +02:00
'thirdparty:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?socid=__ID__' ,
'project:+ticket:Tickets:@ticket:$user->rights->ticket->read:/ticket/list.php?projectid=__ID__' ,
2018-03-10 04:23:59 +01:00
);
2018-07-10 22:32:55 +02:00
// Dictionaries
2018-06-04 21:49:29 +02:00
if ( ! isset ( $conf -> ticket -> enabled )) {
$conf -> ticket = new stdClass ();
$conf -> ticket -> enabled = 0 ;
2018-03-10 04:23:59 +01:00
}
$this -> dictionaries = array (
2018-06-04 21:49:29 +02:00
'langs' => 'ticket' ,
2020-02-07 12:48:41 +01:00
'tabname' => array ( MAIN_DB_PREFIX . " c_ticket_type " , MAIN_DB_PREFIX . " c_ticket_severity " , MAIN_DB_PREFIX . " c_ticket_category " , MAIN_DB_PREFIX . " c_ticket_resolution " ),
'tablib' => array ( " TicketDictType " , " TicketDictSeverity " , " TicketDictCategory " , " TicketDictResolution " ),
'tabsql' => array ( 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_type as f' , 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_severity as f' , 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_category as f' , 'SELECT f.rowid as rowid, f.code, f.pos, f.label, f.active, f.use_default FROM ' . MAIN_DB_PREFIX . 'c_ticket_resolution as f' ),
'tabsqlsort' => array ( " pos ASC " , " pos ASC " , " pos ASC " , " pos ASC " ),
'tabfield' => array ( " pos,code,label,use_default " , " pos,code,label,use_default " , " pos,code,label,use_default " , " pos,code,label,use_default " ),
'tabfieldvalue' => array ( " pos,code,label,use_default " , " pos,code,label,use_default " , " pos,code,label,use_default " , " pos,code,label,use_default " ),
'tabfieldinsert' => array ( " pos,code,label,use_default " , " pos,code,label,use_default " , " pos,code,label,use_default " , " pos,code,label,use_default " ),
'tabrowid' => array ( " rowid " , " rowid " , " rowid " , " rowid " ),
'tabcond' => array ( $conf -> ticket -> enabled , $conf -> ticket -> enabled , $conf -> ticket -> enabled , $conf -> ticket -> enabled ),
'tabhelp' => array ( array ( 'code' => $langs -> trans ( " EnterAnyCode " ), 'use_default' => $langs -> trans ( " Enter0or1 " )), array ( 'code' => $langs -> trans ( " EnterAnyCode " ), 'use_default' => $langs -> trans ( " Enter0or1 " )), array ( 'code' => $langs -> trans ( " EnterAnyCode " ), 'use_default' => $langs -> trans ( " Enter0or1 " )), array ( 'code' => $langs -> trans ( " EnterAnyCode " ), 'use_default' => $langs -> trans ( " Enter0or1 " ))),
2018-03-10 04:23:59 +01:00
);
// Boxes
// Add here list of php file(s) stored in core/boxes that contains class to show a box.
$this -> boxes = array (); // Boxes list
$r = 0 ;
// Example:
2018-06-04 21:49:29 +02:00
$this -> boxes [ $r ][ 1 ] = " box_last_ticket " ;
2018-03-10 04:23:59 +01:00
$r ++ ;
2018-06-04 21:49:29 +02:00
$this -> boxes [ $r ][ 1 ] = " box_last_modified_ticket " ;
2018-03-10 04:23:59 +01:00
$r ++ ;
// Permissions
$this -> rights = array (); // Permission array used by this module
2018-03-13 13:56:45 +01:00
$r = 0 ;
2018-03-11 18:28:27 +01:00
$this -> rights [ $r ][ 0 ] = 56001 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Read ticket " ; // libelle de la permission
2018-03-10 04:23:59 +01:00
$this -> rights [ $r ][ 2 ] = 'r' ; // type de la permission (deprecie a ce jour)
2019-05-07 23:03:45 +02:00
$this -> rights [ $r ][ 3 ] = 0 ; // La permission est-elle une permission par defaut
2018-03-10 04:23:59 +01:00
$this -> rights [ $r ][ 4 ] = 'read' ;
2018-03-13 13:56:45 +01:00
$r ++ ;
2018-03-11 18:28:27 +01:00
$this -> rights [ $r ][ 0 ] = 56002 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Create les tickets " ; // libelle de la permission
2018-03-10 04:23:59 +01:00
$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' ;
2018-03-13 13:56:45 +01:00
$r ++ ;
2018-03-11 18:28:27 +01:00
$this -> rights [ $r ][ 0 ] = 56003 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Delete les tickets " ; // libelle de la permission
2018-03-10 04:23:59 +01:00
$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' ;
2018-03-13 13:56:45 +01:00
$r ++ ;
2018-03-11 18:28:27 +01:00
$this -> rights [ $r ][ 0 ] = 56004 ; // id de la permission
$this -> rights [ $r ][ 1 ] = " Manage tickets " ; // libelle de la permission
2018-03-10 04:23:59 +01:00
//$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' ;
2018-03-13 13:56:45 +01:00
$r ++ ;
2018-03-11 18:28:27 +01:00
$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
2018-03-10 04:23:59 +01:00
$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' ;
$this -> rights [ $r ][ 5 ] = 'all' ;
// Main menu entries
$this -> menus = array (); // List of menus to add
$r = 0 ;
$this -> menu [ $r ] = array ( 'fk_menu' => 0 , // Put 0 if this is a top menu
'type' => 'top' , // This is a Top menu entry
'titre' => 'Ticket' ,
2018-06-04 21:49:29 +02:00
'mainmenu' => 'ticket' ,
2018-03-10 04:23:59 +01:00
'leftmenu' => '1' , // Use 1 if you also want to add left menu entries using this descriptor.
2018-06-04 21:49:29 +02:00
'url' => '/ticket/index.php' ,
'langs' => 'ticket' , // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
2018-12-15 15:35:59 +01:00
'position' => 88 ,
2018-06-04 21:49:29 +02:00
'enabled' => '$conf->ticket->enabled' , // Define condition to show or hide menu entry. Use '$conf->ticket->enabled' if entry must be visible if module is enabled.
'perms' => '$user->rights->ticket->read' , // Use 'perms'=>'$user->rights->ticket->level1->level2' if you want your menu with a permission rules
2018-03-10 04:23:59 +01:00
'target' => '' ,
'user' => 2 ); // 0=Menu for internal users, 1=external users, 2=both
$r ++ ;
2018-06-04 21:49:29 +02:00
$this -> menu [ $r ] = array ( 'fk_menu' => 'fk_mainmenu=ticket' ,
2018-03-10 04:23:59 +01:00
'type' => 'left' ,
'titre' => 'Ticket' ,
2018-06-04 21:49:29 +02:00
'mainmenu' => 'ticket' ,
'leftmenu' => 'ticket' ,
'url' => '/ticket/index.php' ,
'langs' => 'ticket' ,
2018-03-10 04:23:59 +01:00
'position' => 101 ,
2018-06-04 21:49:29 +02:00
'enabled' => '$conf->ticket->enabled' ,
'perms' => '$user->rights->ticket->read' ,
2018-03-10 04:23:59 +01:00
'target' => '' ,
'user' => 2 );
$r ++ ;
2018-06-04 21:49:29 +02:00
$this -> menu [ $r ] = array ( 'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2018-03-10 04:23:59 +01:00
'type' => 'left' ,
'titre' => 'NewTicket' ,
2018-06-04 21:49:29 +02:00
'mainmenu' => 'ticket' ,
2019-03-05 12:18:36 +01:00
'url' => '/ticket/card.php?action=create' ,
2018-06-04 21:49:29 +02:00
'langs' => 'ticket' ,
2018-03-10 04:23:59 +01:00
'position' => 102 ,
2018-06-04 21:49:29 +02:00
'enabled' => '$conf->ticket->enabled' ,
'perms' => '$user->rights->ticket->write' ,
2018-03-10 04:23:59 +01:00
'target' => '' ,
'user' => 2 );
$r ++ ;
2018-06-04 21:49:29 +02:00
$this -> menu [ $r ] = array ( 'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2018-03-10 04:23:59 +01:00
'type' => 'left' ,
'titre' => 'List' ,
2018-06-04 21:49:29 +02:00
'mainmenu' => 'ticket' ,
'leftmenu' => 'ticketlist' ,
'url' => '/ticket/list.php?search_fk_status=non_closed' ,
'langs' => 'ticket' ,
2019-02-26 13:20:58 +01:00
'position' => 103 ,
2018-06-04 21:49:29 +02:00
'enabled' => '$conf->ticket->enabled' ,
'perms' => '$user->rights->ticket->read' ,
2018-03-10 04:23:59 +01:00
'target' => '' ,
'user' => 2 );
$r ++ ;
2018-06-04 21:49:29 +02:00
$this -> menu [ $r ] = array ( 'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
2018-03-10 04:23:59 +01:00
'type' => 'left' ,
2018-06-04 21:49:29 +02:00
'titre' => 'MenuTicketMyAssign' ,
'mainmenu' => 'ticket' ,
'leftmenu' => 'ticketmy' ,
2019-02-26 13:20:58 +01:00
'url' => '/ticket/list.php?mode=mine&search_fk_status=non_closed' ,
2018-06-04 21:49:29 +02:00
'langs' => 'ticket' ,
2018-03-10 04:23:59 +01:00
'position' => 105 ,
2018-06-04 21:49:29 +02:00
'enabled' => '$conf->ticket->enabled' ,
'perms' => '$user->rights->ticket->read' ,
2018-03-10 04:23:59 +01:00
'target' => '' ,
'user' => 0 );
$r ++ ;
2019-02-11 14:51:59 +01:00
$this -> menu [ $r ] = array ( 'fk_menu' => 'fk_mainmenu=ticket,fk_leftmenu=ticket' ,
'type' => 'left' ,
'titre' => 'Statistics' ,
'mainmenu' => 'ticket' ,
'url' => '/ticket/stats/index.php' ,
'langs' => 'ticket' ,
'position' => 107 ,
'enabled' => '$conf->ticket->enabled' ,
'perms' => '$user->rights->ticket->read' ,
'target' => '' ,
'user' => 0 );
$r ++ ;
2018-03-10 04:23:59 +01:00
}
/**
2018-03-13 14:00:35 +01:00
* Function called when module is enabled .
* The init function add constants , boxes , permissions and menus ( defined in constructor ) into Dolibarr database .
* It also creates data directories
2018-03-10 04:23:59 +01:00
*
2018-03-13 14:00:35 +01:00
* @ param string $options Options when enabling module ( '' , 'noboxes' )
* @ return int 1 if OK , 0 if KO
2018-03-10 04:23:59 +01:00
*/
public function init ( $options = '' )
{
$sql = array (
2018-06-04 21:49:29 +02:00
array ( " sql " => " insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110120, 'ticket', 'internal', 'SUPPORTTEC', 'Utilisateur assigné au ticket', 1); " , " ignoreerror " => 1 ),
array ( " sql " => " insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110121, 'ticket', 'internal', 'CONTRIBUTOR', 'Intervenant', 1); " , " ignoreerror " => 1 ),
array ( " sql " => " insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110122, 'ticket', 'external', 'SUPPORTCLI', 'Contact client suivi incident', 1); " , " ignoreerror " => 1 ),
array ( " sql " => " insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (110123, 'ticket', 'external', 'CONTRIBUTOR', 'Intervenant', 1); " , " ignoreerror " => 1 ),
2018-03-10 04:23:59 +01:00
);
return $this -> _init ( $sql , $options );
}
}