Merge pull request #325 from ivandiazwm/master
Fix usery system disabled issues, prepare 4.3.0 upgrade
This commit is contained in:
commit
8882b53b3b
|
@ -1,6 +1,6 @@
|
|||

|
||||
|
||||
[](https://travis-ci.org/opensupports/opensupports) v4.2.0
|
||||
[](https://travis-ci.org/opensupports/opensupports) v4.3.0
|
||||
|
||||
OpenSupports is an open source ticket system built primarily with PHP and ReactJS.
|
||||
Please, visit our website for more information: [http://www.opensupports.com/](http://www.opensupports.com/)
|
||||
|
|
|
@ -7,9 +7,10 @@ class MainLayoutFooter extends React.Component {
|
|||
render() {
|
||||
return (
|
||||
<div className={this.getClass()}>
|
||||
{(this.props.adminPanelOpened) ? this.renderExtraLinks() : null}
|
||||
{this.props.adminPanelOpened ? this.renderExtraLinks() : null}
|
||||
<div className="main-layout-footer__powered">
|
||||
Powered by <a className="main-layout-footer__os-link" href="http://www.opensupports.com/" target="_blank">OpenSupports</a>
|
||||
<span> {this.props.adminPanelOpened ? `v${opensupports_version}` : null}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
opensupports_version = '4.3.0';
|
||||
root = 'http://localhost:3000';
|
||||
apiRoot = 'http://localhost:3000/api';
|
||||
globalIndexPath = '';
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<div id="app"></div>
|
||||
|
||||
<script>
|
||||
opensupports_version = '4.3.0';
|
||||
root = "<?=$url ?>";
|
||||
apiRoot = '<?=$url ?>/api';
|
||||
globalIndexPath = "<?=$path ?>";
|
||||
|
|
|
@ -45,7 +45,7 @@ class UnAssignStaffController extends Controller {
|
|||
$ticket = Ticket::getByTicketNumber($ticketNumber);
|
||||
$owner = $ticket->owner;
|
||||
|
||||
if($ticket->isOwner($user) || $user->level > 2) {
|
||||
if($owner && ($ticket->isOwner($user) || $user->level > 2)) {
|
||||
if(!$ticket->isAuthor($owner)) {
|
||||
$owner->sharedTicketList->remove($ticket);
|
||||
$owner->store();
|
||||
|
|
|
@ -141,7 +141,7 @@ class CommentController extends Controller {
|
|||
|
||||
$email = $recipient['email'];
|
||||
$name = $recipient['name'];
|
||||
$isStaff = $recipient['staff'];
|
||||
$isStaff = array_key_exists('staff', $recipient) && $recipient['staff'];
|
||||
|
||||
$url = Setting::getSetting('url')->getValue();
|
||||
|
||||
|
|
|
@ -141,6 +141,8 @@ class Ticket extends DataStore {
|
|||
];
|
||||
} else {
|
||||
return [
|
||||
'id' => NULL,
|
||||
'staff' => false,
|
||||
'name' => $this->authorName,
|
||||
'email' => $this->authorEmail
|
||||
];
|
||||
|
@ -188,7 +190,7 @@ class Ticket extends DataStore {
|
|||
if(!Controller::isStaffLogged() && $ticketEvent->private) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
|
@ -202,10 +204,11 @@ class Ticket extends DataStore {
|
|||
public function isAuthor($user) {
|
||||
$ticketAuthor = $this->authorToArray();
|
||||
if(is_string($user)) return $user == $ticketAuthor['email'];
|
||||
if(!($user instanceof DataStore) || $user->isNull()) return false;
|
||||
return $user->id == $ticketAuthor['id'] && ($user instanceof Staff) == $ticketAuthor['staff'];
|
||||
}
|
||||
|
||||
public function isOwner($user) {
|
||||
return $this->owner && $user->id == $this->owner->id && ($user instanceof Staff);
|
||||
return !$user->isNull() && $this->owner && $user->id == $this->owner->id && ($user instanceof Staff);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,40 @@ describe'system/disable-user-system' do
|
|||
(result['status']).should.equal('success')
|
||||
end
|
||||
|
||||
it 'should be able to assign and respond tickets' do
|
||||
Scripts.login($staff[:email], $staff[:password], true);
|
||||
ticket = $database.getLastRow('ticket');
|
||||
result = request('/staff/assign-ticket', {
|
||||
ticketNumber: ticket['ticket_number'],
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
})
|
||||
(result['status']).should.equal('success')
|
||||
|
||||
result = request('/ticket/comment', {
|
||||
ticketNumber: ticket['ticket_number'],
|
||||
content: 'This is a staff response for a ticket without an user',
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
})
|
||||
(result['status']).should.equal('success')
|
||||
end
|
||||
|
||||
it 'should be be able to create a ticket as an admin' do
|
||||
result = request('/ticket/create', {
|
||||
title: 'created by staff with user system disabled',
|
||||
content: 'an staff created this ticket while user system disabled',
|
||||
departmentId: 1,
|
||||
language: 'en',
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
(result['status']).should.equal('success')
|
||||
ticket = $database.getRow('ticket', result['data']['ticketNumber'], 'ticket_number')
|
||||
(ticket['author_id']).should.equal(nil)
|
||||
(ticket['author_staff_id']).should.equal('1')
|
||||
end
|
||||
|
||||
it 'should not disable the user system if it is already disabled 'do
|
||||
request('/user/logout')
|
||||
Scripts.login($staff[:email], $staff[:password], true)
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
require_once '../mysql_connect.php';
|
||||
|
||||
$filePath = '../../api/files';
|
||||
|
||||
print 'Begin update v4.3.0...' . PHP_EOL;
|
||||
|
||||
// Change profile pics
|
||||
print '[1/3] Updating profile pics..' . PHP_EOL;
|
||||
$queryResult = $mysql->query("SELECT id,profile_pic FROM staff") or die(PHP_EOL . 'Error: profile_pic can\'t be found on `staff` table'. PHP_EOL);
|
||||
while($staff = $queryResult->fetch_array(MYSQLI_ASSOC)) {
|
||||
global $filePath;
|
||||
$id = $staff['id'];
|
||||
$profilePicFileName = $staff['profile_pic'];
|
||||
$updatedProfilePicFileName = "p_$profilePicFileName";
|
||||
|
||||
if(!$profilePicFileName || $profilePicFileName[0] == 'p') continue;
|
||||
|
||||
rename("$filePath/$profilePicFileName", "$filePath/$updatedProfilePicFileName")
|
||||
or die("Error: could not change file name from $profilePicFileName to $updatedProfilePicFileName");
|
||||
|
||||
$mysql->query("UPDATE staff SET profile_pic='$updatedProfilePicFileName' WHERE id='$id'")
|
||||
or die (PHP_EOL . "Error: could not update profile_pic for staff id:$id" . PHP_EOL);
|
||||
}
|
||||
|
||||
// Change ticket attachments
|
||||
print '[2/3] Updating ticket attachments...' . PHP_EOL;
|
||||
function updateTicketFile($ticketNumber, $fileName) {
|
||||
global $filePath;
|
||||
$updatedFileName = "t$ticketNumber" . "_$fileName";
|
||||
|
||||
rename("$filePath/$fileName", "$filePath/$updatedFileName")
|
||||
or die(PHP_EOL . "Error: could not change file name from $fileName to $updatedFileName" . PHP_EOL);
|
||||
|
||||
return $updatedFileName;
|
||||
}
|
||||
|
||||
$queryResult = $mysql->query("SELECT id,ticket_number,file FROM ticket");
|
||||
while($queryResult && $ticket = $queryResult->fetch_array(MYSQLI_ASSOC)) {
|
||||
$id = $ticket['id'];
|
||||
|
||||
if(!$ticket['file'] || $ticket['file'][0] == 't') continue;
|
||||
|
||||
$updatedFileName = updateTicketFile($ticket['ticket_number'], $ticket['file']);
|
||||
|
||||
$mysql->query("UPDATE ticket SET file='$updatedFileName' WHERE id='$id'")
|
||||
or die (PHP_EOL . "Error: could not update file for ticket id:$id" . PHP_EOL);
|
||||
}
|
||||
|
||||
// Change ticket attachments
|
||||
print '[3/3] Updating ticketevent attachments...' . PHP_EOL;
|
||||
$queryResult = $mysql->query("SELECT id,ticket_id,file FROM ticketevent");
|
||||
while($queryResult && $ticketEvent = $queryResult->fetch_array(MYSQLI_ASSOC)) {
|
||||
$id = $ticketEvent['id'];
|
||||
$ticketId = $ticketEvent['ticket_id'];
|
||||
$ticketQuery = $mysql->query("SELECT ticket_number FROM ticket WHERE id='$ticketId'") or die(PHP_EOL . "Error: could not find ticket id:$id" . PHP_EOL);
|
||||
$ticketNumber = $ticketQuery->fetch_array()[0];
|
||||
|
||||
if(!$ticketEvent['file'] || $ticketEvent['file'][0] == 't') continue;
|
||||
|
||||
$updatedFileName = updateTicketFile($ticketNumber, $ticketEvent['file']);
|
||||
|
||||
$mysql->query("UPDATE ticketevent SET file='$updatedFileName' WHERE id='$id'")
|
||||
or die (PHP_EOL . "Error: could not update file for ticketevent id:$id" . PHP_EOL);
|
||||
}
|
||||
|
||||
print 'Update Completed!' . PHP_EOL;
|
Loading…
Reference in New Issue