diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 445686340e8..c5c3b38b29b 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -126,9 +126,10 @@ class FormTicket * * @param int $withdolfichehead With dol_get_fiche_head() and dol_get_fiche_end() * @param string $mode Mode ('create' or 'edit') + * @param int $public 1=If we show the form for the public interface * @return void */ - public function showForm($withdolfichehead = 0, $mode = 'edit') + public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0) { global $conf, $langs, $user, $hookmanager; @@ -182,6 +183,7 @@ class FormTicket if (isset($this->param['origin']) && $this->param['originid'] > 0) { // Parse element/subelement (ex: project_task) $element = $subelement = $this->param['origin']; + $regs = array(); if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) { $element = $regs[1]; $subelement = $regs[2]; @@ -208,7 +210,11 @@ class FormTicket // Group print ''; - $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', 2, 0, 0, 0, 'minwidth200'); + $filter = ''; + if ($public) { + $filter = 'public=1'; + } + $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 0, 0, 0, 'minwidth200'); print ''; // Severity @@ -307,7 +313,7 @@ class FormTicket if ($this->withfile == 2) { // Can add other files $out .= ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "\n"; @@ -439,8 +445,8 @@ class FormTicket print dol_get_fiche_end(); } - print '
'; - print ''; + print '
'; + print ''; if ($this->withcancel) { print "      "; print ''; @@ -551,7 +557,7 @@ class FormTicket * * @param string $selected Id categorie pre-selectionnée * @param string $htmlname Nom de la zone select - * @param string $filtertype To filter on field type in llx_c_ticket_category (array('code'=>xx,'label'=>zz)) + * @param string $filtertype To filter on some properties in llx_c_ticket_category ('public = 1'). This parameter must not come from input of users. * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code * @param int $empty 1=peut etre vide, 0 sinon * @param int $noadmininfo 0=Add admin info, 1=Disable admin info @@ -567,12 +573,6 @@ class FormTicket dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); - $filterarray = array(); - - if ($filtertype != '' && $filtertype != '-1') { - $filterarray = explode(',', $filtertype); - } - $ticketstat->loadCacheCategoriesTickets(); print ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "\n"; diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 5b7ba4ecf22..85b40430d4c 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -392,7 +392,7 @@ if ($action != "infos_success") { print '
'; } else { print '
'.$langs->trans('TicketPublicInfoCreateTicket').'
'; - $formticket->showForm(); + $formticket->showForm(0, 'edit', 1); } } diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 945e58630fe..125aa5acd82 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -432,7 +432,7 @@ if ($action == "view_ticketlist") { if (!empty($arrayfields['category.code']['checked'])) { print ''; - $formTicket->selectGroupTickets($search_category, 'search_category', '', 2, 1, 1); + $formTicket->selectGroupTickets($search_category, 'search_category', 'public=1', 2, 1, 1); print ''; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index da04a37dc93..8741fdc6b66 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -691,7 +691,7 @@ if ($action == 'create' || $action == 'presend') { $formticket->withextrafields = 1; $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid')); - $formticket->showForm(1, 'create'); + $formticket->showForm(1, 'create', 0); } elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { $formticket = new FormTicket($db); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 0ba818b8e0b..93806bb86aa 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1177,7 +1177,7 @@ class Ticket extends CommonObject } // Cache deja charge - $sql = "SELECT rowid, code, label, use_default, pos, description"; + $sql = "SELECT rowid, code, label, use_default, pos, description, public, active"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY pos"; @@ -1194,6 +1194,8 @@ class Ticket extends CommonObject $this->cache_category_tickets[$obj->rowid]['label'] = $label; $this->cache_category_tickets[$obj->rowid]['use_default'] = $obj->use_default; $this->cache_category_tickets[$obj->rowid]['pos'] = $obj->pos; + $this->cache_category_tickets[$obj->rowid]['public'] = $obj->public; + $this->cache_category_tickets[$obj->rowid]['active'] = $obj->active; $i++; } return $num;