Merge branch 'master' of https://github.com/opensupports/opensupports into invite-users-feature

This commit is contained in:
Maxi Redigonda 2019-11-14 15:11:37 -03:00
commit bc38411275
12 changed files with 112 additions and 32 deletions

View File

@ -66,9 +66,7 @@ class ActivityRow extends React.Component {
<div className="activity-row">
<Icon {...this.getIconProps()} className="activity-row__icon"/>
<span>
<Link className="activity-row__name-link" to={this.getNameLinkDestination()}>
{this.props.author.name}
</Link>
{this.renderAuthorName()}
</span>
<span className="activity-row__message"> {i18n('ACTIVITY_' + this.props.type)} </span>
{_.includes(ticketRelatedTypes, this.props.type) ? this.renderTicketNumber() : this.props.to}
@ -77,6 +75,18 @@ class ActivityRow extends React.Component {
);
}
renderAuthorName() {
let name = this.props.author.name;
if (this.props.author.id) {
name = <Link className="activity-row__name-link" to={this.getNameLinkDestination()}>
{this.props.author.name}
</Link>;
}
return name;
}
renderTicketNumber() {
let ticketNumber = (this.props.mode === 'staff') ? this.props.ticketNumber : this.props.to;

View File

@ -300,7 +300,7 @@ export default {
'DELETE_USER_DESCRIPTION': 'O usuário não será capaz de entrar no sistema e todos os seus chamados serão apagados. Além disso, o e-mail não poderá mais ser usado.',
'DELETE_TOPIC_DESCRIPTION': 'Ao excluir o tópico, todos os artigos dele serão apagados.',
'EDIT_TOPIC_DESCRIPTION': 'Aqui você pode alterar o nome, o ícone ea cor do ícone do tópico.',
'ADD_ARTICLE_DESCRIPTION': 'Aqui você pode adicionar um artigo que estará disponível para cada usuário. Ele será adicionado dentro da categoria {categoria}.',
'ADD_ARTICLE_DESCRIPTION': 'Aqui você pode adicionar um artigo que estará disponível para cada usuário. Ele será adicionado dentro da categoria {category}.',
'LIST_ARTICLES_DESCRIPTION': 'Esta é uma lista de artigos que inclui informações sobre nossos serviços.',
'ADD_TOPIC_DESCRIPTION': 'Aqui você pode adicionar um tópico que funciona como uma categoria para artigos.',
'DELETE_ARTICLE_DESCRIPTION': 'Você vai excluir este artigo para sempre.',

View File

@ -272,7 +272,7 @@ export default {
'INSTALLATION_COMPLETED': 'Installation abgeschlossen.',
'INSTALLATION_COMPLETED_DESCRIPTION': 'Die Installation von OpenSupports ist abgeschlossen. Umleitung zum Admin-Panel...',
'STEP_TITLE': 'Schritt {aktuell} von {total} - {title}',
'STEP_TITLE': 'Schritt {current} von {total} - {title}',
'STEP_1_DESCRIPTION': 'Wählen Sie Ihre bevorzugte Sprache für den Installationsassistenten aus.',
'STEP_2_DESCRIPTION': 'Hier sind die Voraussetzungen für das Ausführen von OpenSupports aufgelistet. Bitte stellen Sie sicher, dass alle Anforderungen erfüllt sind.',
'STEP_3_DESCRIPTION': 'Bitte füllen Sie die MySQL-Datenbankkonfiguration aus.',

View File

@ -206,7 +206,7 @@ export default {
'TYPE': 'Tipo',
'SELECT_INPUT': 'Seleccionar entrada',
'TEXT_INPUT': 'Entrada de texto',
'OPTION': 'Opción {índice}',
'OPTION': 'Opción {index}',
'OPTIONS': 'Opciones',
'FIELD_DESCRIPTION': 'Descripción del campo (opcional)',
'DESCRIPTION_ADD_CUSTOM_TAG': 'Aquí puedes agregar una nueva etiqueta personalizada',

View File

@ -300,7 +300,7 @@
'DELETE_USER_DESCRIPTION': 'Ο χρήστης δεν θα μπορέσει να συνδεθεί με τη γήρανση και όλα τα εισιτήρια του θα διαγραφούν. Επίσης, το ηλεκτρονικό ταχυδρομείο δεν μπορεί πλέον να χρησιμοποιηθεί.',
'DELETE_TOPIC_DESCRIPTION': 'Διαγράφοντας το θέμα, όλα τα άρθρα σε αυτό θα διαγραφούν.',
'EDIT_TOPIC_DESCRIPTION': 'Εδώ μπορείτε να αλλάξετε το όνομα, το εικονίδιο και το χρώμα του εικονιδίου του θέματος.',
'ADD_ARTICLE_DESCRIPTION': 'Εδώ μπορείτε να προσθέσετε ένα άρθρο που θα είναι διαθέσιμο για κάθε χρήστη. Θα προστεθεί μέσα στην κατηγορία {κατηγορία}.',
'ADD_ARTICLE_DESCRIPTION': 'Εδώ μπορείτε να προσθέσετε ένα άρθρο που θα είναι διαθέσιμο για κάθε χρήστη. Θα προστεθεί μέσα στην κατηγορία {category}.',
'LIST_ARTICLES_DESCRIPTION': 'Αυτή είναι μια λίστα με άρθρα που περιλαμβάνουν πληροφορίες σχετικά με τις υπηρεσίες μας.',
'ADD_TOPIC_DESCRIPTION': 'Εδώ μπορείτε να προσθέσετε ένα θέμα που λειτουργεί ως κατηγορία για άρθρα.',
'DELETE_ARTICLE_DESCRIPTION': 'Πρόκειται να διαγράψετε αυτό το άρθρο για πάντα.',

View File

@ -206,7 +206,7 @@ export default {
'TYPE': 'genere',
'SELECT_INPUT': 'Seleziona input',
'TEXT_INPUT': 'L\'immissione di testo',
'OPTION': 'Opzione {indice}',
'OPTION': 'Opzione {index}',
'OPTIONS': 'Opzioni',
'FIELD_DESCRIPTION': 'Descrizione del campo (facoltativo)',
'DESCRIPTION_ADD_CUSTOM_TAG': 'qui puoi aggiungere un nuovo tag personalizzato',

View File

@ -300,7 +300,7 @@ export default {
'DELETE_USER_DESCRIPTION': 'O usuário não será capaz de entrar no envelhecimento e todos os seus bilhetes serão apagados. Além disso, o e-mail não pode mais ser usado.',
'DELETE_TOPIC_DESCRIPTION': 'Ao excluir o tópico, todos os artigos dele serão apagados.',
'EDIT_TOPIC_DESCRIPTION': 'Aqui você pode alterar o nome, o ícone ea cor do ícone do tópico.',
'ADD_ARTICLE_DESCRIPTION': 'Aqui você pode adicionar um artigo que estará disponível para cada usuário. Ele será adicionado dentro da categoria {categoria}.',
'ADD_ARTICLE_DESCRIPTION': 'Aqui você pode adicionar um artigo que estará disponível para cada usuário. Ele será adicionado dentro da categoria {category}.',
'LIST_ARTICLES_DESCRIPTION': 'Esta é uma lista de artigos que inclui informações sobre nossos serviços.',
'ADD_TOPIC_DESCRIPTION': 'Aqui você pode adicionar um tópico que funciona como uma categoria para artigos.',
'DELETE_ARTICLE_DESCRIPTION': 'Você vai excluir este artigo para sempre.',

View File

@ -37,9 +37,10 @@ class CommentController extends Controller {
private $ticket;
private $content;
private $session;
public function validations() {
$session = Session::getInstance();
$this->session = Session::getInstance();
if (Controller::isUserSystemEnabled() || Controller::isStaffLogged()) {
return [
@ -64,11 +65,11 @@ class CommentController extends Controller {
'error' => ERRORS::INVALID_CONTENT
],
'ticketNumber' => [
'validation' => DataValidator::equals($session->getTicketNumber()),
'validation' => DataValidator::equals($this->session->getTicketNumber()),
'error' => ERRORS::INVALID_TICKET
],
'csrf_token' => [
'validation' => DataValidator::equals($session->getToken()),
'validation' => DataValidator::equals($this->session->getToken()),
'error' => ERRORS::INVALID_TOKEN
]
]
@ -78,16 +79,16 @@ class CommentController extends Controller {
public function handler() {
$this->requestData();
$this->user = Controller::getLoggedUser();
$ticketAuthor = $this->ticket->authorToArray();
$isAuthor = $this->ticket->isAuthor(Controller::getLoggedUser()) || Session::getInstance()->isTicketSession();
$isOwner = $this->ticket->isOwner(Controller::getLoggedUser());
$user = Controller::getLoggedUser();
$isAuthor = $this->ticket->isAuthor($this->user) || $this->session->isTicketSession();
$isOwner = $this->ticket->isOwner($this->user);
if(!Controller::isStaffLogged() && Controller::isUserSystemEnabled() && !$isAuthor){
throw new RequestException(ERRORS::NO_PERMISSION);
}
if(!$user->canManageTicket($this->ticket)) {
if(!$this->session->isTicketSession() && !$this->user->canManageTicket($this->ticket)) {
throw new RequestException(ERRORS::NO_PERMISSION);
}
@ -99,8 +100,8 @@ class CommentController extends Controller {
'name' => $this->ticket->owner->name,
'staff' => true
]);
} else if($isOwner) {
!Controller::request('private') ? $this->sendMail($ticketAuthor) : null;
} else if($isOwner && !Controller::request('private')) {
$this->sendMail($ticketAuthor);
}
Log::createLog('COMMENT', $this->ticket->ticketNumber);
@ -129,12 +130,12 @@ class CommentController extends Controller {
));
if(Controller::isStaffLogged()) {
$this->ticket->unread = !$this->ticket->isAuthor(Controller::getLoggedUser());
$this->ticket->unreadStaff = !$this->ticket->isOwner(Controller::getLoggedUser());
$comment->authorStaff = Controller::getLoggedUser();
$this->ticket->unread = !$this->ticket->isAuthor($this->user);
$this->ticket->unreadStaff = !$this->ticket->isOwner($this->user);
$comment->authorStaff = $this->user;
} else if(Controller::isUserSystemEnabled()) {
$this->ticket->unreadStaff = true;
$comment->authorUser = Controller::getLoggedUser();
$comment->authorUser = $this->user;
}
$this->ticket->addEvent($comment);

View File

@ -115,10 +115,16 @@ class CreateController extends Controller {
}
}
Log::createLog('CREATE_TICKET', $this->ticketNumber);
Response::respondSuccess([
'ticketNumber' => $this->ticketNumber
]);
if(!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) {
$session = Session::getInstance();
$session->createTicketSession($this->ticketNumber);
}
Log::createLog('CREATE_TICKET', $this->ticketNumber);
}
private function storeTicket() {

View File

@ -22,21 +22,36 @@ class Log extends DataStore {
'authorUser',
'authorStaff',
'to',
'date'
'date',
'authorName'
];
}
public static function createLog($type, $to, $author = null) {
$session = Session::getInstance();
$authorName = '';
if($session->isTicketSession()) {
$ticketNumber = $session->getTicketNumber();
$ticket = Ticket::getByTicketNumber($ticketNumber);
$authorName = $ticket->authorToArray()['name'];
}
if($author === null) {
$author = Controller::getLoggedUser();
}
if(!$author->isNull()) {
$authorName = $author->name;
}
$log = new Log();
$log->setProperties(array(
'type' => $type,
'to' => $to,
'date' => Date::getCurrentDate()
'date' => Date::getCurrentDate(),
'authorName' => $authorName
));
if($author instanceof User) {
@ -55,8 +70,8 @@ class Log extends DataStore {
'type' => $this->type,
'to' => $this->to,
'author' => [
'name' => $author->name,
'id' => $author->id,
'name' => $this->authorName,
'id' => ($author && !$author->isNull()) ? $author->id : null,
'staff' => $author instanceof Staff
],
'date' => $this->date

View File

@ -83,15 +83,16 @@ class Ticketevent extends DataStore {
public function toArray() {
$user = ($this->authorStaff) ? $this->authorStaff : $this->authorUser;
$author = $this->ticket->authorToArray();
return [
'type' => $this->type,
'ticketNumber' => $this->ticket->ticketNumber,
'author' => [
'name' => $user ? $user->name : null,
'name' => $user ? $user->name : $author['name'],
'staff' => $user instanceOf Staff,
'id' => $user ? $user->id : null,
'customfields' => $user->xownCustomfieldvalueList ? $user->xownCustomfieldvalueList->toArray() : [],
'customfields' => ($user && $user->xownCustomfieldvalueList) ? $user->xownCustomfieldvalueList->toArray() : [],
],
'edited' => $this->editedContent
];

View File

@ -65,6 +65,35 @@ describe'system/disable-user-system' do
(result['status']).should.equal('success')
end
it 'should be able to comment on ticket as a non-logged user' do
result = request('/ticket/create', {
title: 'Doubt about Russian language',
content: 'Stariy means old in Russian?',
departmentId: 1,
language: 'en',
name: 'Abraham Einstein',
email: 'abrahameinstein@opensupports.com'
})
(result['status']).should.equal('success')
ticketNumber = result['data']['ticketNumber']
result = request('/ticket/check', {
ticketNumber: ticketNumber,
email: 'abrahameinstein@opensupports.com',
captcha: 'valid'
})
token = result['data']['token']
(result['status']).should.equal('success');
result = request('/ticket/comment', {
content: 'I actually think it is not like that, but anyways, thanks',
ticketNumber: ticketNumber,
csrf_token: token
})
(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');
@ -84,6 +113,26 @@ describe'system/disable-user-system' do
(result['status']).should.equal('success')
end
it 'should be able to get the latest events as admin' do
result = request('/staff/last-events', {
page: 1,
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
(result['data'].size).should.equal(10)
end
it 'should be able to get system logs as admin' do
result = request('/system/get-logs', {
page: 1,
csrf_userid: $csrf_userid,
csrf_token: $csrf_token
})
(result['status']).should.equal('success')
(result['data'].size).should.equal(10)
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',
@ -156,8 +205,7 @@ describe'system/disable-user-system' do
numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" )
(numberOftickets.num_rows).should.equal(52)
(numberOftickets.num_rows).should.equal(53)
end
it 'should not enable the user system' do
@ -169,6 +217,5 @@ describe'system/disable-user-system' do
(result['status']).should.equal('fail')
(result['message']).should.equal('SYSTEM_USER_IS_ALREADY_ENABLED')
end
end