Fix PHPCS errors with ticketsup module

This commit is contained in:
jfefe 2018-03-11 11:54:30 +01:00
parent 0ac1d8b226
commit 0f96575b41
5 changed files with 95 additions and 99 deletions

View File

@ -31,9 +31,11 @@ if (!class_exists('FormCompany')) {
/** /**
* Classe permettant la generation du formulaire d'un nouveau ticket. * Classe permettant la generation du formulaire d'un nouveau ticket.
* *
* Utilisation: $formticketsup = new FormTicketsup($db) * @package Ticketsup
* $formticketsup->proprietes=1 ou chaine ou tableau de valeurs
* $formticketsup->show_form() affiche le formulaire * \remarks Utilisation: $formticketsup = new FormTicketsup($db)
* \remarks $formticketsup->proprietes=1 ou chaine ou tableau de valeurs
* \remarks $formticketsup->show_form() affiche le formulaire
*/ */
class FormTicketsup class FormTicketsup
{ {
@ -72,6 +74,7 @@ class FormTicketsup
public $withcancel; public $withcancel;
/** /**
*
* @var array $substit Substitutions * @var array $substit Substitutions
*/ */
public $substit = array(); public $substit = array();
@ -526,7 +529,7 @@ class FormTicketsup
$filterarray = explode(',', $filtertype); $filterarray = explode(',', $filtertype);
} }
$ticketstat->load_cache_categories_tickets(); $ticketstat->loadCacheCategoriesTickets();
print '<select id="select' . $htmlname . '" class="flat select_ticketcategory" name="' . $htmlname . '">'; print '<select id="select' . $htmlname . '" class="flat select_ticketcategory" name="' . $htmlname . '">';
if ($empty) { if ($empty) {
@ -624,7 +627,7 @@ class FormTicketsup
$filterarray = explode(',', $filtertype); $filterarray = explode(',', $filtertype);
} }
$ticketstat->load_cache_severities_tickets(); $ticketstat->loadCacheSeveritiesTickets();
print '<select id="select' . $htmlname . '" class="flat select_ticketseverity" name="' . $htmlname . '">'; print '<select id="select' . $htmlname . '" class="flat select_ticketseverity" name="' . $htmlname . '">';
if ($empty) { if ($empty) {

View File

@ -1,6 +1,6 @@
<?php <?php
/* <one line to give the program's name and a brief idea of what it does.> /*
* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io> * Copyright (C) 2013-2018 Jean-François FERRY <hello@librethic.io>
* 2016 Christophe Battarel <christophe@altairis.fr> * 2016 Christophe Battarel <christophe@altairis.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
@ -20,7 +20,13 @@
/** /**
* \file core/lib/ticketsup.lib.php * \file core/lib/ticketsup.lib.php
* \ingroup ticketsup * \ingroup ticketsup
* \brief This file is an example module library * \brief This file is a library for TicketSup module
*/
/**
* Build tabs for admin page
*
* @return array
*/ */
function ticketsupAdminPrepareHead() function ticketsupAdminPrepareHead()
{ {
@ -58,10 +64,9 @@ function ticketsupAdminPrepareHead()
} }
/** /**
* Prepare head for ticket card * Build tabs for a Ticketsup object
* * @param Ticketsup $object Ticketsup object
* @param Object $object Object Ticket * @return array
* @return array Array of tabs
*/ */
function ticketsup_prepare_head($object) function ticketsup_prepare_head($object)
{ {

View File

@ -533,7 +533,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$userstatic = new User($db); $userstatic = new User($db);
foreach (array('internal', 'external') as $source) { foreach (array('internal', 'external') as $source) {
$tmpobject = $object->dao; $tmpobject = $object->dao;
$tab = $tmpobject->liste_contact(-1, $source); $tab = $tmpobject->listeContact(-1, $source);
$num = count($tab); $num = count($tab);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {

View File

@ -343,7 +343,7 @@ class ActionsTicketsup
if ($ret) { if ($ret) {
// Si déjà un user assigné on le supprime des contacts // Si déjà un user assigné on le supprime des contacts
if ($useroriginassign > 0) { if ($useroriginassign > 0) {
$internal_contacts = $this->dao->liste_contact(-1, 'internal'); $internal_contacts = $this->dao->listeContact(-1, 'internal');
foreach ($internal_contacts as $key => $contact) { foreach ($internal_contacts as $key => $contact) {
if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) { if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) {
@ -475,7 +475,7 @@ class ActionsTicketsup
// Set parent company // Set parent company
if ($action == 'set_thirdparty' && $user->rights->societe->creer) { if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$result = $this->dao->set_customer(GETPOST('editcustomer', 'int')); $result = $this->dao->setCustomer(GETPOST('editcustomer', 'int'));
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: " . $url); header("Location: " . $url);
exit(); exit();
@ -609,8 +609,8 @@ class ActionsTicketsup
/** /**
* Add new message on a ticket (private area) * Add new message on a ticket (private area)
* *
* @param User $user Object user * @param User $user
* @param string $action Action * @param string $action
*/ */
private function newMessage($user, &$action) private function newMessage($user, &$action)
{ {
@ -820,8 +820,8 @@ class ActionsTicketsup
/** /**
* Add new message on a ticket (public area) * Add new message on a ticket (public area)
* *
* @param User $user Object user * @param User $user
* @param string $action Action * @param string $action
*/ */
private function newMessagePublic($user, &$action) private function newMessagePublic($user, &$action)
{ {
@ -964,9 +964,9 @@ class ActionsTicketsup
/** /**
* Fetch object * Fetch object
* *
* @param int $id Id * @param string $id
* @param int $track_id Track id * @param string $track_id
* @param string $ref Ref * @param string $ref
* @return void * @return void
*/ */
public function fetch($id = 0, $track_id = 0, $ref = '') public function fetch($id = 0, $track_id = 0, $ref = '')
@ -977,8 +977,7 @@ class ActionsTicketsup
/** /**
* print statut * print statut
* * @param int $mode Display mode
* @param int $mode Mode
* @return void * @return void
*/ */
public function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
@ -989,10 +988,9 @@ class ActionsTicketsup
} }
/** /**
* Get ticket info * Get ticket info
* *
* @param int $id Object id * @param int $id Object id
* @return void
*/ */
public function getInfo($id) public function getInfo($id)
{ {
@ -1004,10 +1002,9 @@ class ActionsTicketsup
} }
/** /**
* Get action title * Get action title
* *
* @param string $action Type of action * @param string $action Type of action
* @return string Label
*/ */
public function getTitle($action = '') public function getTitle($action = '')
{ {
@ -1029,8 +1026,7 @@ class ActionsTicketsup
/** /**
* View html list of logs * View html list of logs
* *
* @param boolean $show_user Show user who make action * @param boolean $show_user Show user who make action
* @return void
*/ */
public function viewTicketLogs($show_user = true) public function viewTicketLogs($show_user = true)
{ {
@ -1092,8 +1088,7 @@ class ActionsTicketsup
/** /**
* View list of logs with timeline view * View list of logs with timeline view
* *
* @param boolean $show_user Show user who make action * @param boolean $show_user Show user who make action
* @return void
*/ */
public function viewTimelineTicketLogs($show_user = true) public function viewTimelineTicketLogs($show_user = true)
{ {
@ -1139,9 +1134,8 @@ class ActionsTicketsup
/** /**
* Show ticket original message * Show ticket original message
* *
* @param User $user Object user * @param User $user $user wich display
* @param string $action Action * @param string $action Action mode
* @return void
*/ */
public function viewTicketOriginalMessage($user, $action = '') public function viewTicketOriginalMessage($user, $action = '')
{ {
@ -1196,9 +1190,8 @@ class ActionsTicketsup
/** /**
* View html list of message for ticket * View html list of message for ticket
* *
* @param boolean $show_private Show private messages * @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action * @param boolean $show_user Show user who make action
* @return void
*/ */
public function viewTicketMessages($show_private, $show_user = true) public function viewTicketMessages($show_private, $show_user = true)
{ {
@ -1268,9 +1261,8 @@ class ActionsTicketsup
/** /**
* View list of message for ticket with timeline display * View list of message for ticket with timeline display
* *
* @param boolean $show_private Show private messages * @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action * @param boolean $show_user Show user who make action
* @return void
*/ */
public function viewTicketTimelineMessages($show_private, $show_user = true) public function viewTicketTimelineMessages($show_private, $show_user = true)
{ {
@ -1419,12 +1411,12 @@ class ActionsTicketsup
/** /**
* Copy files into ticket directory * Copy files into ticket directory
* Used for files linked into messages
* *
* @return void * Used for files linked into messages
*/ */
public function copyFilesForTicket() public function copyFilesForTicket()
{ {
global $conf; global $conf;
// Create form object // Create form object
@ -1466,9 +1458,8 @@ class ActionsTicketsup
/** /**
* Print html navbar with link to set ticket status * 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 * @global type $langs
*/ */
public function viewStatusActions() public function viewStatusActions()
{ {
@ -1520,10 +1511,10 @@ class ActionsTicketsup
/** /**
* Hook to add email element template * Hook to add email element template
* *
* @param array $parameters Parameters * @param array $parameters Parameters
* @param Object $object Object * @param Ticketsup $object Object for action
* @param string $action Action * @param string $action Action string
* @param HookManager $hookmanager Hookmanager * @param HookManager $hookmanager Hookmanager object
* @return int * @return int
*/ */
public function emailElementlist($parameters, &$object, &$action, $hookmanager) public function emailElementlist($parameters, &$object, &$action, $hookmanager)

View File

@ -533,14 +533,15 @@ class Ticketsup extends CommonObject
/** /**
* Load all objects in memory from database * Load all objects in memory from database
* *
* @param User $user Object user * @param User $user User for action
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param int $limit page number * @param int $limit page number
* @param int $offset Offset * @param int $offset Offset for query
* @param int $arch archive or not (not used) * @param int $arch archive or not (not used)
* @param array $filter Filter * @param array $filter Filter for query
* @return int <0 if KO, >0 if OK * output
* @return int <0 if KO, >0 if OK
*/ */
public function fetchAll($user, $sortorder = 'ASC', $sortfield = 't.datec', $limit = '', $offset = 0, $arch = '', $filter = '') public function fetchAll($user, $sortorder = 'ASC', $sortfield = 't.datec', $limit = '', $offset = 0, $arch = '', $filter = '')
{ {
@ -1052,7 +1053,7 @@ class Ticketsup extends CommonObject
* *
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/ */
public function load_cache_categories_tickets() public function loadCacheCategoriesTickets()
{ {
global $langs; global $langs;
@ -1092,7 +1093,7 @@ class Ticketsup extends CommonObject
* *
* @return int Nb lignes chargees, 0 si deja chargees, <0 si ko * @return int Nb lignes chargees, 0 si deja chargees, <0 si ko
*/ */
public function load_cache_severities_tickets() public function loadCacheSeveritiesTickets()
{ {
global $langs; global $langs;
@ -1135,7 +1136,7 @@ class Ticketsup extends CommonObject
*/ */
public function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
{ {
return $this->LibStatut($this->fk_statut, $mode); return $this->libStatut($this->fk_statut, $mode);
} }
/** /**
@ -1144,7 +1145,7 @@ class Ticketsup extends CommonObject
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* \return string Label * \return string Label
*/ */
public function LibStatut($statut, $mode = 0) public function libStatut($statut, $mode = 0)
{ {
global $langs; global $langs;
@ -1289,11 +1290,10 @@ class Ticketsup extends CommonObject
} }
/** /**
* Renvoie nom clicable (avec eventuellement le picto) * Return clckable link to object
* * @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
* @param int $withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul * @param string $option Where to point the link
* @param string $option Sur quoi pointe le lien * @return string
* @return string Chaine avec URL
*/ */
public function getNomUrl($withpicto = 0, $option = '') public function getNomUrl($withpicto = 0, $option = '')
{ {
@ -1326,10 +1326,11 @@ class Ticketsup extends CommonObject
} }
/** /**
* Mark a message as read * Mark a message as read
* *
* @param User $user Object user * @param User $user User for action
* @return int <0 if KO, >0 if OK * @param int $notrigger Lauch trigger or not
* @return int 1 if ok, -1 otherwise
*/ */
public function markAsRead($user, $notrigger = 0) public function markAsRead($user, $notrigger = 0)
{ {
@ -1374,12 +1375,12 @@ class Ticketsup extends CommonObject
} }
/** /**
* Mark a message as read * Assign ticket to an user
* *
* @param User $user Object user * @param User $user User for action
* @param int $id_assign_user ID of user assigned * @param int $id_assign_user IP user assigned
* @param int $notrigger Disable trigger * @param int $notrigger Disable trigger if 1
* @return int <0 if KO, >0 if OK * @return number
*/ */
public function assignUser($user, $id_assign_user, $notrigger = 0) public function assignUser($user, $id_assign_user, $notrigger = 0)
{ {
@ -1428,10 +1429,10 @@ class Ticketsup extends CommonObject
* 1- create entry into database for message storage * 1- create entry into database for message storage
* 2- if trigger, send an email to ticket contacts * 2- if trigger, send an email to ticket contacts
* *
* @param User $user User that create * @param User $user User that create
* @param string $message Log message * @param string $message Log message
* @param int $noemail 0=send email after, 1=disable emails * @param int $noemail 0=send email after, 1=disable emails
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function createTicketLog(User $user, $message, $noemail = 0) public function createTicketLog(User $user, $message, $noemail = 0)
{ {
@ -1489,7 +1490,7 @@ class Ticketsup extends CommonObject
* @param string $message Log message * @param string $message Log message
* @return int <0 if KO, >0 if OK (number of emails sent) * @return int <0 if KO, >0 if OK (number of emails sent)
*/ */
private function sendLogByEmail($user, $log_message) private function sendLogByEmail($user, $message)
{ {
global $conf, $langs; global $conf, $langs;
@ -1498,8 +1499,8 @@ class Ticketsup extends CommonObject
$langs->load('ticketsup@ticketsup'); $langs->load('ticketsup@ticketsup');
// Retrieve email of all contacts (internal and external) // Retrieve email of all contacts (internal and external)
$contacts = $this->liste_contact(-1, 'internal'); $contacts = $this->listeContact(-1, 'internal');
$contacts = array_merge($contacts, $this->liste_contact(-1, 'external')); $contacts = array_merge($contacts, $this->listeContact(-1, 'external'));
/* If origin_email and no socid, we add email to the list * */ /* If origin_email and no socid, we add email to the list * */
if (!empty($this->origin_email) && empty($this->fk_soc)) { if (!empty($this->origin_email) && empty($this->fk_soc)) {
@ -1914,7 +1915,7 @@ class Ticketsup extends CommonObject
* @param int $id Id of thirdparty to set or '' to remove * @param int $id Id of thirdparty to set or '' to remove
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function set_customer($id) public function setCustomer($id)
{ {
if ($this->id) { if ($this->id) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "ticketsup"; $sql = "UPDATE " . MAIN_DB_PREFIX . "ticketsup";
@ -2031,7 +2032,7 @@ class Ticketsup extends CommonObject
*/ */
public function getInfosTicketInternalContact() public function getInfosTicketInternalContact()
{ {
return $this->liste_contact(-1, 'internal'); return $this->listeContact(-1, 'internal');
} }
/** /**
@ -2051,7 +2052,7 @@ class Ticketsup extends CommonObject
*/ */
public function getInfosTicketExternalContact() public function getInfosTicketExternalContact()
{ {
return $this->liste_contact(-1, 'external'); return $this->listeContact(-1, 'external');
} }
/** /**
@ -2077,7 +2078,6 @@ class Ticketsup extends CommonObject
/** /**
* Return id of all contacts for ticket * Return id of all contacts for ticket
* *
* @param int $exclude_self exclude_self Exclude current user form list
*/ */
public function getTicketAllContacts() public function getTicketAllContacts()
{ {
@ -2096,7 +2096,6 @@ class Ticketsup extends CommonObject
/** /**
* Return id of all contacts for ticket * Return id of all contacts for ticket
* *
* @param int $exclude_self exclude_self Exclude current user form list
*/ */
public function getTicketAllCustomerContacts() public function getTicketAllCustomerContacts()
{ {
@ -2109,11 +2108,10 @@ class Ticketsup extends CommonObject
} }
/** /**
* Check if contact are linked to the ticket. If yes, send mail and save trace into llx_notify. * Send message
* * @param string $subject Subject for message
* @param string $subject Subject * @param string $texte Text for message
* @param string $texte Message to send * @return int 1 if ok, -1 otherwise
* @return int <0 if KO, or number of changes if OK
*/ */
public function messageSend($subject, $texte) public function messageSend($subject, $texte)
{ {
@ -2241,7 +2239,7 @@ class Ticketsup extends CommonObject
* @param int $list 0:Return array contains all properties, 1:Return array contains just id * @param int $list 0:Return array contains all properties, 1:Return array contains just id
* @return array Array of contacts * @return array Array of contacts
*/ */
public function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') public function listeContact($statut = -1, $source = 'external', $list = 0)
{ {
global $langs; global $langs;
@ -2293,8 +2291,7 @@ class Ticketsup extends CommonObject
} }
$sql .= " ORDER BY t.lastname ASC"; $sql .= " ORDER BY t.lastname ASC";
//echo $sql; exit;
dol_syslog(get_class($this) . "::liste_contact sql=" . $sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);