set ticket author correctly (#817)

* set ticket author correctly

* x
This commit is contained in:
Guillermo Giuliana 2020-06-24 02:12:13 -03:00 committed by GitHub
parent b0b3ed7238
commit 7daa53e47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -283,7 +283,7 @@ class SearchControllerTest extends TestCase {
'page' => 1,
'query' => 'stark'
]),
"SELECT ticket.id FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE (ticket.title LIKE :query or ticket.content LIKE :query or ticket.ticket_number LIKE :query or (ticketevent.type = 'COMMENT' and ticketevent.content LIKE :query) ) GROUP BY ticket.id ORDER BY CASE WHEN (ticket.ticket_number LIKE :query) THEN 1 WHEN (ticket.title LIKE :query2) THEN 2 WHEN (ticket.title LIKE :query) THEN 3 WHEN ( ticket.content LIKE :query) THEN 4 WHEN (ticketevent.content LIKE :query) THEN 5 END asc, ticket.closed asc, ticket.owner_id asc, ticket.unread_staff asc, ticket.priority desc, ticket.date desc LIMIT 10 OFFSET 0"
"SELECT ticket.id FROM (ticket LEFT JOIN tag_ticket ON tag_ticket.ticket_id = ticket.id LEFT JOIN ticketevent ON ticketevent.ticket_id = ticket.id) WHERE (ticket.title LIKE :query or ticket.content LIKE :query or ticket.ticket_number LIKE :query or (ticketevent.type = 'COMMENT' and ticketevent.content LIKE :query) ) GROUP BY ticket.id ORDER BY CASE WHEN (ticket.ticket_number LIKE :query) THEN 1 WHEN (ticket.title LIKE :queryAtBeginning) THEN 2 WHEN (ticket.title LIKE :query) THEN 3 WHEN ( ticket.content LIKE :query) THEN 4 WHEN (ticketevent.content LIKE :query) THEN 5 END asc, ticket.closed asc, ticket.owner_id asc, ticket.unread_staff asc, ticket.priority desc, ticket.date desc LIMIT 10 OFFSET 0"
);
$this->assertEquals(

View File

@ -16,7 +16,8 @@ if ($mysql->query("SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '
} else {
print '-not_registered column already exists' . PHP_EOL;
}
if(!Setting::getSetting('user-system-enabled')->isNull() && !Setting::getSetting('user-system-enabled')->getValue() ) {
if(!Setting::getSetting('user-system-enabled')->isNull() && !Setting::getSetting('user-system-enabled')->getValue()) {
$ticketList = Ticket::getAll();
foreach($ticketList as $ticket) {
@ -25,6 +26,7 @@ if(!Setting::getSetting('user-system-enabled')->isNull() && !Setting::getSetting
}
$userInstance = User::getDataStore($ticket->authorEmail, 'email');
$ticketInstance = Ticket::getByTicketNumber($ticket->ticketNumber);
if($userInstance->isNull()) {
@ -38,16 +40,19 @@ if(!Setting::getSetting('user-system-enabled')->isNull() && !Setting::getSetting
'tickets' => 0,
'email' => $ticket->authorEmail,
'password' => Hashing::hashPassword($password),
'not_registered' => 1,
'notRegistered' => 1,
'verificationToken' => null
]);
$userInstance->store();
}
$userInstance->tickets = $userInstance->tickets + 1;
$userInstance->sharedTicketList->add($ticket);
$userInstance->store();
$ticketInstance->author = $userInstance;
$ticketInstance->store();
}
} else {
print '-The tickets created already have owner Users' . PHP_EOL;
@ -116,3 +121,5 @@ if ($mysql->query("SELECT * FROM setting WHERE name='user-system-enabled' ")->nu
print 'Update Completed!' . PHP_EOL;