Przeglądaj źródła

Fix scrutinizer

Laurent Destailleur 3 lat temu
rodzic
commit
d997dfc96e

+ 5 - 1
htdocs/core/class/html.formticket.class.php

@@ -735,6 +735,7 @@ class FormTicket
 				}
 
 				print '>';
+
 				$value = ' ';
 				if ($format == 0) {
 					$value = ($maxlength ? dol_trunc($arraytypes['label'], $maxlength) : $arraytypes['label']);
@@ -746,7 +747,7 @@ class FormTicket
 					$value = $arraytypes['code'];
 				}
 
-				print $value;
+				print $value ? $value : ' ';
 				print '</option>';
 			}
 		}
@@ -841,6 +842,7 @@ class FormTicket
 
 					print '>';
 
+					$value = '';
 					if ($format == 0) {
 						$value = ($maxlength ? dol_trunc($label, $maxlength) : $label);
 					}
@@ -1174,6 +1176,8 @@ class FormTicket
 				}
 
 				print '>';
+
+				$value = '';
 				if ($format == 0) {
 					$value = ($maxlength ? dol_trunc($arrayseverities['label'], $maxlength) : $arrayseverities['label']);
 				}

+ 4 - 4
htdocs/core/class/utils_diff.class.php

@@ -247,6 +247,7 @@ class Diff
 		$html = '';
 
 		// loop over the lines in the diff
+		$element = 'unknown';
 		foreach ($diff as $line) {
 			// extend the HTML with the line
 			switch ($line[1]) {
@@ -260,10 +261,7 @@ class Diff
 					$element = 'ins';
 					break;
 			}
-			$html .=
-			'<'.$element.'>'
-			. htmlspecialchars($line[0])
-				. '</'.$element.'>';
+			$html .= '<'.$element.'>'.dol_escape_htmltag($line[0]).'</'.$element.'>';
 
 			// extend the HTML with the separator
 			$html .= $separator;
@@ -286,6 +284,8 @@ class Diff
 		// initialise the HTML
 		$html = $indentation."<table class=\"diff\">\n";
 
+		$rightCell = $leftCell = '';
+
 		// loop over the lines in the diff
 		$index = 0;
 		$nbdiff = count($diff);

+ 3 - 1
htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php

@@ -387,10 +387,12 @@ class InterfaceTicketEmail extends DolibarrTriggers
 
 		$trackid = 'tic'.$object->id;
 
+		$old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO');
+
 		if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
-			$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
 			$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
 		}
+
 		include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 		$mailfile = new CMailFile($subject, $sendto, $from, $message_customer, $filepath, $mimetype, $filename, '', '', 0, -1, '', '', $trackid, '', 'ticket');
 		if ($mailfile->error) {

+ 7 - 2
htdocs/ticket/class/api_tickets.class.php

@@ -187,10 +187,14 @@ class Tickets extends DolibarrApi
 		if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) {
 			$num = count($this->ticket->cache_logs_ticket);
 			$i = 0;
+			$user_action = new User($this->db);
+
 			while ($i < $num) {
+				$userstring = '';
 				if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) {
-					$user_action = new User($this->db);
 					$user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']);
+
+					$userstring = dolGetFirstLastname($user_action->firstname, $user_action->lastname);
 				}
 
 				// Now define messages
@@ -198,7 +202,7 @@ class Tickets extends DolibarrApi
 				'id' => $this->ticket->cache_logs_ticket[$i]['id'],
 				'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
 				'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'],
-				'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname),
+				'fk_user_action_string' => $userstring,
 				'message' => $this->ticket->cache_logs_ticket[$i]['message'],
 				'datec' => $this->ticket->cache_logs_ticket[$i]['datec'],
 				);
@@ -243,6 +247,7 @@ class Tickets extends DolibarrApi
 		}
 
 		// If the internal user must only see his customers, force searching by him
+		$search_sale = 0;
 		if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) {
 			$search_sale = DolibarrApiAccess::$user->id;
 		}

+ 27 - 21
htdocs/ticket/class/ticket.class.php

@@ -1584,28 +1584,28 @@ class Ticket extends CommonObject
 		// foreach contact send email with notification message
 		if (count($contacts) > 0) {
 			foreach ($contacts as $key => $info_sendto) {
-				$message = '';
+				$tmpmessage = '';
 				$subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNotificationEmailSubject', $this->track_id);
-				$message .= $langs->transnoentities('TicketNotificationEmailBody', $this->track_id)."\n\n";
-				$message .= $langs->transnoentities('Title').' : '.$this->subject."\n";
+				$tmpmessage .= $langs->transnoentities('TicketNotificationEmailBody', $this->track_id)."\n\n";
+				$tmpmessage .= $langs->transnoentities('Title').' : '.$this->subject."\n";
 
 				$recipient_name = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1');
 				$recipient = (!empty($recipient_name) ? $recipient_name : $info_sendto['email']).' ('.strtolower($info_sendto['libelle']).')';
-				$message .= $langs->transnoentities('TicketNotificationRecipient').' : '.$recipient."\n";
-				$message .= "\n";
-				$message .= '* '.$langs->transnoentities('TicketNotificationLogMessage').' *'."\n";
-				$message .= dol_html_entity_decode($log_message, ENT_QUOTES | ENT_HTML5)."\n";
+				$tmpmessage .= $langs->transnoentities('TicketNotificationRecipient').' : '.$recipient."\n";
+				$tmpmessage .= "\n";
+				$tmpmessage .= '* '.$langs->transnoentities('TicketNotificationLogMessage').' *'."\n";
+				$tmpmessage .= dol_html_entity_decode($message, ENT_QUOTES | ENT_HTML5)."\n";
 
 				if ($info_sendto['source'] == 'internal') {
 					$url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$this->track_id;
-					$message .= "\n".$langs->transnoentities('TicketNotificationEmailBodyInfosTrackUrlinternal').' : <a href="'.$url_internal_ticket.'">'.$this->track_id.'</a>'."\n";
+					$tmpmessage .= "\n".$langs->transnoentities('TicketNotificationEmailBodyInfosTrackUrlinternal').' : <a href="'.$url_internal_ticket.'">'.$this->track_id.'</a>'."\n";
 				} else {
 					$url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$this->track_id;
-					$message .= "\n".$langs->transnoentities('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$this->track_id.'</a>'."\n";
+					$tmpmessage .= "\n".$langs->transnoentities('TicketNewEmailBodyInfosTrackUrlCustomer').' : <a href="'.$url_public_ticket.'">'.$this->track_id.'</a>'."\n";
 				}
 
-				$message .= "\n";
-				$message .= $langs->transnoentities('TicketEmailPleaseDoNotReplyToThisEmail')."\n";
+				$tmpmessage .= "\n";
+				$tmpmessage .= $langs->transnoentities('TicketEmailPleaseDoNotReplyToThisEmail')."\n";
 
 				$from = $conf->global->MAIN_INFO_SOCIETE_NOM.'<'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>';
 				$replyto = $from;
@@ -1615,7 +1615,7 @@ class Ticket extends CommonObject
 				$filename = array();
 				$mimetype = array();
 
-				$message = dol_nl2br($message);
+				$tmpmessage = dol_nl2br($tmpmessage);
 
 				if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
 					$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
@@ -1624,7 +1624,7 @@ class Ticket extends CommonObject
 				include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 				$sendtocc = '';
 				$deliveryreceipt = 0;
-				$mailfile = new CMailFile($subject, $info_sendto['email'], $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0);
+				$mailfile = new CMailFile($subject, $info_sendto['email'], $from, $tmpmessage, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0);
 				if ($mailfile->error || $mailfile->errors) {
 					setEventMessages($mailfile->error, $mailfile->errors, 'errors');
 				} else {
@@ -2131,12 +2131,13 @@ class Ticket extends CommonObject
 	{
 		$array_contact = array();
 
-		$array_contact = $this->getIdTicketInternalContact($exclude_self);
+		$array_contact = $this->getIdTicketInternalContact();
 
-		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact($exclude_self));
+		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
 
-		$array_contact = array_merge($array_contact, $this->getIdTicketInternalInvolvedContact($exclude_self));
-		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact($exclude_self));
+		$array_contact = array_merge($array_contact, $this->getIdTicketInternalInvolvedContact());
+
+		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
 
 		return $array_contact;
 	}
@@ -2150,8 +2151,9 @@ class Ticket extends CommonObject
 	{
 		$array_contact = array();
 
-		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact($exclude_self));
-		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact($exclude_self));
+		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerContact());
+
+		$array_contact = array_merge($array_contact, $this->getIdTicketCustomerInvolvedContact());
 
 		return $array_contact;
 	}
@@ -2825,11 +2827,14 @@ class Ticket extends CommonObject
 				$filename = $mimefilename_list;
 				$mimetype = $mimetype_list;
 
-				// Envoi du mail
+				// Send email
+
+				$old_MAIN_MAIL_AUTOCOPY_TO = getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO');
+
 				if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
-					$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
 					$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
 				}
+
 				include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 				$trackid = "tic".$this->id;
 				$mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, '', 'ticket');
@@ -2850,6 +2855,7 @@ class Ticket extends CommonObject
 						}
 					}
 				}
+
 				if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
 					$conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
 				}