Fix version upgrade

This commit is contained in:
ivan 2017-12-06 20:53:10 -03:00
parent a81e7320b7
commit 83b1a7c69b
6 changed files with 23 additions and 16 deletions

View File

@ -83,10 +83,10 @@ class InitSettingsController extends Controller {
'registration' => !!Controller::request('registration'),
'user-system-enabled' => !!Controller::request('user-system-enabled'),
'last-stat-day' => date('YmdHi', strtotime(' -12 day ')),
'ticket-gap' => Hashing::generateRandomPrime(1000000, 9999999),
'ticket-first-number' => Hashing::generateRandomNumber(1000000, 9999999),
'file-gap' => Hashing::generateRandomPrime(1000000, 9999999),
'file-first-number' => Hashing::generateRandomNumber(1000000, 9999999),
'ticket-gap' => Hashing::generateRandomPrime(100000, 999999),
'ticket-first-number' => Hashing::generateRandomNumber(100000, 999999),
'file-gap' => Hashing::generateRandomPrime(100000, 999999),
'file-first-number' => Hashing::generateRandomNumber(100000, 999999),
'file-quantity' => 0,
'session-prefix' => 'opensupports-'.Hashing::generateRandomToken().'_'
]);

View File

@ -36,10 +36,10 @@ class MailSender {
public function setTemplate($type, $config) {
$mailTemplate = MailTemplate::getTemplate($type);
$compiledMailContent = $mailTemplate->compile($config);
$this->mailOptions = array_merge($this->mailOptions, $compiledMailContent);
}
public function send() {
$mailerInstance = $this->getMailerInstance();
@ -49,6 +49,7 @@ class MailSender {
throw new Exception('Mail sending data not available');
}
$mailerInstance->ClearAllRecipients();
$mailerInstance->addAddress($this->mailOptions['to']);
$mailerInstance->Subject = $this->mailOptions['subject'];
$mailerInstance->Body = $this->mailOptions['body'];
@ -88,4 +89,4 @@ class MailSender {
return $this->mailerInstance;
}
}
}

View File

@ -78,7 +78,7 @@ class Ticket extends DataStore {
$ticketQuantity = Ticket::count();
if ($ticketQuantity === 0) {
$ticketNumber = Setting::getSetting('ticket-first-number');
$ticketNumber = Setting::getSetting('ticket-first-number')->value;
} else {
$linearCongruentialGenerator->setGap(Setting::getSetting('ticket-gap')->value);
$linearCongruentialGenerator->setFirst(Setting::getSetting('ticket-first-number')->value);

View File

@ -16,7 +16,7 @@ class LinearCongruentialGeneratorTest extends TestCase {
$linearCongruentialGenerator = new LinearCongruentialGenerator();
$linearCongruentialGenerator->setRange($min, $max);
$linearCongruentialGenerator->setGap(Hashing::generateRandomPrime($min, $max));
$linearCongruentialGenerator->setFirst(Hashing::generateRandomNumber());
$linearCongruentialGenerator->setFirst(Hashing::generateRandomNumber($min, $max));
$used = [];

View File

@ -75,13 +75,14 @@ if($tickets = $mysql->query("SELECT * FROM ticket ORDER BY id ASC")) {
$ticketString = '';
foreach($emailTickets as $ticket) {
$ticketString += '<p>'
$ticketString += $ticket['old_number'];
$ticketString += '(old) => ';
$ticketString += $ticket['new_number'];
$ticketString += '(new) ';
$ticketString += $ticket['title'];
$ticketString += '</p>';
$ticketString .= '<p>';
$ticketString .= $ticket['old_number'];
$ticketString .= ' => ';
$ticketString .= $ticket['new_number'];
$ticketString .= ' ';
$ticketString .= htmlentities($ticket['title']);
$ticketString .= '</p>';
$ticketString .= PHP_EOL;
}
$mailSender->setMailContent([
@ -93,5 +94,7 @@ if($tickets = $mysql->query("SELECT * FROM ticket ORDER BY id ASC")) {
'tickets' => $ticketString,
])
]);
$mailSender->send();
}
}

View File

@ -1,4 +1,6 @@
<?php
require_once '../../server/vendor/autoload.php';
class MailSender {
private $mailOptions = [];
@ -38,6 +40,7 @@ class MailSender {
throw new Exception('Mail sending data not available');
}
$mailerInstance->ClearAllRecipients();
$mailerInstance->addAddress($this->mailOptions['to']);
$mailerInstance->Subject = $this->mailOptions['subject'];
$mailerInstance->Body = $this->mailOptions['body'];