Merge pull request #22793 from Hystepik/develop#2

Fix : php 8.1 warnings in ticket
This commit is contained in:
Laurent Destailleur 2022-11-09 15:24:50 +01:00 committed by GitHub
commit bb6163edee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 18 deletions

View File

@ -1317,7 +1317,7 @@ class ActionComm extends CommonObject
dol_syslog(get_class()."::getActions", LOG_DEBUG);
require_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager = new HookManager($this->db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('agendadao'));

View File

@ -1270,7 +1270,7 @@ class FormTicket
// Define output language
$outputlangs = $langs;
$newlang = '';
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->param['langsmodels'])) {
$newlang = $this->param['langsmodels'];
}
if (!empty($newlang)) {
@ -1281,7 +1281,7 @@ class FormTicket
// Get message template for $this->param["models"] into c_email_templates
$arraydefaultmessage = -1;
if ($this->param['models'] != 'none') {
if (isset($this->param['models']) && $this->param['models'] != 'none') {
$model_id = 0;
if (array_key_exists('models_id', $this->param)) {
$model_id = (int) $this->param["models_id"];
@ -1323,7 +1323,7 @@ class FormTicket
// Define output language
$outputlangs = $langs;
$newlang = '';
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($this->param['langsmodels'])) {
$newlang = $this->param['langsmodels'];
}
if (!empty($newlang)) {
@ -1380,7 +1380,12 @@ class FormTicket
print '<input type="hidden" name="action" value="'.$this->action.'">';
print '<input type="hidden" name="actionbis" value="add_message">';
print '<input type="hidden" name="backtopage" value="'.$this->backtopage.'">';
print '<input type="hidden" name="trackid" value="'.$this->trackid.'">';
if (!empty($this->trackid)) {
print '<input type="hidden" name="trackid" value="'.$this->trackid.'">';
} else {
print '<input type="hidden" name="trackid" value="'.(empty($this->track_id) ? '' : $this->track_id).'">';
$keytoavoidconflict = empty($this->track_id) ? '' : '-'.$this->track_id; // track_id instead of trackid
}
foreach ($this->param as $key => $value) {
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
}
@ -1392,7 +1397,7 @@ class FormTicket
$arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id);
}
$result = $formmail->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
$result = $formmail->fetchAllEMailTemplate(!empty($this->param["models"]) ? $this->param["models"] : "", $user, $outputlangs);
if ($result < 0) {
setEventMessages($this->error, $this->errors, 'errors');
}
@ -1404,7 +1409,7 @@ class FormTicket
print '<table class="border" width="'.$width.'">';
// External users can't send message email
if ($user->rights->ticket->write && !$user->socid) {
if ($user->hasRight("ticket", "write") && !$user->socid) {
$ticketstat = new Ticket($this->db);
$res = $ticketstat->fetch('', '', $this->track_id);
@ -1556,7 +1561,7 @@ class FormTicket
// Deal with format differences between message and signature (text / HTML)
if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
$this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']);
} elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
} elseif (!dol_textishtml($defaultmessage) && isset($this->substit['__USER_SIGNATURE__']) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) {
$defaultmessage = dol_nl2br($defaultmessage);
}
if (GETPOSTISSET("message") && !GETPOST('modelselected')) {
@ -1569,7 +1574,7 @@ class FormTicket
}
print '<tr><td colspan="2"><label for="message"><span class="fieldrequired">'.$langs->trans("Message").'</span>';
if ($user->rights->ticket->write && !$user->socid) {
if ($user->hasRight("ticket", "write") && !$user->socid) {
$texttooltip = $langs->trans("TicketMessageHelp");
if (getDolGlobalString('TICKET_MESSAGE_MAIL_INTRO') || getDolGlobalString('TICKET_MESSAGE_MAIL_SIGNATURE')) {
$texttooltip .= '<br><br>'.$langs->trans("ForEmailMessageWillBeCompletedWith").'...';

View File

@ -310,11 +310,11 @@ if (empty($reshook)) {
}
}
if (is_array($searched_companies)) {
if (!empty($searched_companies) && is_array($searched_companies)) {
$object->fk_soc = $searched_companies[0]->id;
}
if (is_array($contacts) and count($contacts) > 0) {
if (is_array($contacts) && count($contacts) > 0) {
$object->fk_soc = $contacts[0]->socid;
$usertoassign = $contacts[0]->id;
}
@ -329,7 +329,7 @@ if (empty($reshook)) {
if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
$error++;
$errors = array($langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
array_push($object->errors, array($langs->trans("AlreadyTooMuchPostOnThisIPAdress")));
array_push($object->errors, $langs->trans("AlreadyTooMuchPostOnThisIPAdress"));
$action = 'create_ticket';
}

View File

@ -62,6 +62,8 @@ $cancel = GETPOST('cancel', 'aZ09');
$track_id = GETPOST('track_id', 'alpha');
$email = strtolower(GETPOST('email', 'alpha'));
$suffix = "";
$moreforfilter = "";
if (GETPOST('btn_view_ticket_list')) {
unset($_SESSION['track_id_customer']);
@ -364,7 +366,7 @@ if ($action == "view_ticketlist") {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON ec.fk_c_type_contact = tc.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON ec.fk_socpeople = sp.rowid";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
if (isset($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)";
}
$sql .= " WHERE t.entity IN (".getEntity('ticket').")";
@ -736,7 +738,7 @@ if ($action == "view_ticketlist") {
print '</p>';
print '<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans('Email').'</span></label>';
print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $_SESSION['customer_email']).'" />';
print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : (!empty($_SESSION['customer_email']) ? $_SESSION['customer_email'] : "")).'" />';
print '</p>';
print '<p style="text-align: center; margin-top: 1.5em;">';

View File

@ -63,6 +63,7 @@ $cancel = GETPOST('cancel', 'aZ09');
$track_id = GETPOST('track_id', 'alpha');
$email = GETPOST('email', 'email');
$suffix = "";
if (GETPOST('btn_view_ticket')) {
unset($_SESSION['email_customer']);
@ -205,7 +206,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a
$triggersendname = 'TICKET_SENTBYMAIL';
$paramname = 'id';
$autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add
$trackid = 'tic'.$object->id;
if (!empty($object->id)) $trackid = 'tic'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
@ -401,7 +402,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a
print '</p>';
print '<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans('Email').'</span></label>';
print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $_SESSION['customer_email']).'" />';
print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : (!empty($_SESSION['customer_email']) ? $_SESSION['customer_email'] : "")).'" />';
print '</p>';
print '<p style="text-align: center; margin-top: 1.5em;">';

View File

@ -199,7 +199,7 @@ class ActionsTicket
print '<tr class="liste_titre trforfield"><td class="nowrap titlefield">';
print $langs->trans("InitialMessage");
print '</td><td>';
if ($user->rights->ticket->manage) {
if ($user->hasRight("ticket", "manage")) {
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=edit_message_init&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->trans('Modify')).'</a>';
}
print '</td></tr>';

View File

@ -1666,7 +1666,7 @@ class Ticket extends CommonObject
*/
public function loadCacheMsgsTicket()
{
if (is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) {
if (!empty($this->cache_msgs_ticket) && is_array($this->cache_msgs_ticket) && count($this->cache_msgs_ticket)) {
return 0;
}