Skip to content

Commit

Permalink
#IP-1744 Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nuxwin committed Sep 22, 2017
1 parent ffb55a0 commit e16a984
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -66,6 +66,7 @@ VAGRANT

YOUTRACK
IP-1742 i-MSCP upgrade error - Unknown 'mail_user' database table in database update r254
IP-1744 Couldn't go to support section - 302 redirect to index.php- reseller UI

------------------------------------------------------------------------------------------------------------------------
1.5.1
Expand Down
30 changes: 0 additions & 30 deletions gui/library/Functions/Tickets.php
Expand Up @@ -530,36 +530,6 @@ function _ticketGetLastDate($ticketId)
return date(Registry::get('config')['DATE_FORMAT'], $row['ticket_date']);
}

/**
* Checks if the support ticket system is globally enabled and (optionaly) if a
* specific reseller has permissions to access to it
*
* Note: If a reseller has not access to the support ticket system, it's means
* that all his customers have not access to it too.
*
* @param int $userId OPTIONAL Id of the user created the current user or null
* if admin
* @return bool TRUE if support ticket system is available, FALSE otherwise
*/
function hasTicketSystem($userId = NULL)
{
if (!Registry::get('config')['IMSCP_SUPPORT_SYSTEM']) {
return false;
}

if ($userId === NULL) {
return true;
}

$stmt = exec_query('SELECT support_system FROM reseller_props WHERE reseller_id = ?', $userId);

if (!$stmt->rowCount() || $stmt->fetchRow(PDO::FETCH_COLUMN == 'no')) {
return false;
}

return true;
}

/**
* Gets the answers of the selected ticket and generates its output.
*
Expand Down
5 changes: 2 additions & 3 deletions gui/public/admin/ticket_closed.php
Expand Up @@ -27,10 +27,9 @@

check_login('admin');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart);
iMSCP_Registry::get('config')['IMSCP_SUPPORT_SYSTEM'] or showBadRequestErrorPage();

if (!hasTicketSystem()) {
redirectTo('index.php');
} elseif (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if (isset($_GET['ticket_id'])) {
reopenTicket(intval($_GET['ticket_id']));
}

Expand Down
7 changes: 2 additions & 5 deletions gui/public/admin/ticket_delete.php
Expand Up @@ -27,14 +27,11 @@

check_login('admin');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart);

if (!hasTicketSystem()) {
redirectTo('index.php');
}
iMSCP_Registry::get('config')['IMSCP_SUPPORT_SYSTEM'] or showBadRequestErrorPage();

$previousPage = 'ticket_system';

if (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if (isset($_GET['ticket_id'])) {
$ticketId = intval($_GET['ticket_id']);
$stmt = exec_query(
'SELECT ticket_status FROM tickets WHERE ticket_id = ? AND (ticket_from = ? OR ticket_to = ?)', [
Expand Down
5 changes: 2 additions & 3 deletions gui/public/admin/ticket_system.php
Expand Up @@ -27,10 +27,9 @@

check_login('admin');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart);
iMSCP_Registry::get('config')['IMSCP_SUPPORT_SYSTEM'] or showBadRequestErrorPage();

if (!hasTicketSystem()) {
redirectTo('index.php');
} elseif (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if (isset($_GET['ticket_id'])) {
closeTicket(intval($_GET['ticket_id']));
}

Expand Down
5 changes: 1 addition & 4 deletions gui/public/admin/ticket_view.php
Expand Up @@ -34,10 +34,7 @@

check_login('admin');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart);

if (!hasTicketSystem() || !isset($_GET['ticket_id'])) {
showBadRequestErrorPage();
}
iMSCP_Registry::get('config')['IMSCP_SUPPORT_SYSTEM'] && isset($_GET['ticket_id']) or showBadRequestErrorPage();

$ticketId = intval($_GET['ticket_id']);
$status = getTicketStatus($ticketId);
Expand Down
5 changes: 2 additions & 3 deletions gui/public/client/ticket_closed.php
Expand Up @@ -34,10 +34,9 @@

check_login('user');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
customerHasFeature('support') or showBadRequestErrorPage();

if (!customerHasFeature('support')) {
showBadRequestErrorPage();
} elseif (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if (isset($_GET['ticket_id'])) {
reopenTicket(intval($_GET['ticket_id']));
}

Expand Down
2 changes: 1 addition & 1 deletion gui/public/client/ticket_delete.php
Expand Up @@ -39,7 +39,7 @@
$userId = $_SESSION['user_id'];
$previousPage = 'ticket_system';

if (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if (isset($_GET['ticket_id'])) {
$ticketId = intval($_GET['ticket_id']);

$query = "
Expand Down
5 changes: 2 additions & 3 deletions gui/public/client/ticket_system.php
Expand Up @@ -34,10 +34,9 @@

check_login('user');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);
customerHasFeature('support') or showBadRequestErrorPage();

if (!customerHasFeature('support')) {
showBadRequestErrorPage();
} elseif (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if(isset($_GET['ticket_id'])) {
closeTicket(intval($_GET['ticket_id']));
}

Expand Down
5 changes: 1 addition & 4 deletions gui/public/client/ticket_view.php
Expand Up @@ -34,10 +34,7 @@

check_login('user');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onClientScriptStart);

if (!customerHasFeature('support') || !isset($_GET['ticket_id'])) {
showBadRequestErrorPage();
}
customerHasFeature('support') && isset($_GET['ticket_id']) or showBadRequestErrorPage();

$ticketId = intval($_GET['ticket_id']);
$status = getTicketStatus($ticketId);
Expand Down
4 changes: 1 addition & 3 deletions gui/public/reseller/ticket_closed.php
Expand Up @@ -36,9 +36,7 @@
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onResellerScriptStart);
resellerHasFeature('support') or showBadRequestErrorPage();

if (!hasTicketSystem($_SESSION['user_id'])) {
redirectTo('index.php');
} elseif (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if (isset($_GET['ticket_id'])) {
reopenTicket(intval($_GET['ticket_id']));
}

Expand Down
4 changes: 0 additions & 4 deletions gui/public/reseller/ticket_create.php
Expand Up @@ -36,10 +36,6 @@
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onResellerScriptStart);
resellerHasFeature('support') or showBadRequestErrorPage();

if (!hasTicketSystem($_SESSION['user_id'])) {
redirectTo('index.php');
}

if (isset($_POST['uaction'])) {
if (empty($_POST['subject'])) {
set_page_message(tr('You must specify a subject.'), 'error');
Expand Down
4 changes: 0 additions & 4 deletions gui/public/reseller/ticket_delete.php
Expand Up @@ -36,10 +36,6 @@
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onResellerScriptStart);
resellerHasFeature('support') or showBadRequestErrorPage();

if (!hasTicketSystem($_SESSION['user_id'])) {
redirectTo('index.php');
}

$previousPage = 'ticket_system';

if (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
Expand Down
5 changes: 1 addition & 4 deletions gui/public/reseller/ticket_system.php
Expand Up @@ -38,10 +38,7 @@

$_SESSION['previousPage'] = 'ticket_system.php';

// Checks if support ticket system is activated and if the reseller can access to it
if (!hasTicketSystem($_SESSION['user_id'])) {
redirectTo('index.php');
} elseif (isset($_GET['ticket_id']) && !empty($_GET['ticket_id'])) {
if (isset($_GET['ticket_id'])) {
closeTicket(intval($_GET['ticket_id']));
}

Expand Down
9 changes: 1 addition & 8 deletions gui/public/reseller/ticket_view.php
Expand Up @@ -34,14 +34,7 @@

check_login('reseller');
iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onResellerScriptStart);

if (!resellerHasFeature('support') || !hasTicketSystem($_SESSION['user_id'])) {
redirectTo('index.php');
}

if (!isset($_GET['ticket_id'])) {
showBadRequestErrorPage();
}
resellerHasFeature('support') && isset($_GET['ticket_id']) or showBadRequestErrorPage();

$ticketId = intval($_GET['ticket_id']);
$status = getTicketStatus($ticketId);
Expand Down

0 comments on commit e16a984

Please sign in to comment.