diff --git a/main/inc/lib/TicketManager.php b/main/inc/lib/TicketManager.php
index 336b59d6fb..699baf6b78 100644
--- a/main/inc/lib/TicketManager.php
+++ b/main/inc/lib/TicketManager.php
@@ -340,7 +340,6 @@ class TicketManager
}
}
-
// insert_ticket
$params = [
'project_id' => $project_id,
@@ -784,6 +783,10 @@ class TicketManager
$userId = !empty($userId) ? $userId : api_get_user_id();
$isAdmin = UserManager::is_admin($userId);
+ if (!isset($_GET['project_id'])) {
+ return [];
+ }
+
switch ($column) {
case 0:
$column = 'ticket_id';
@@ -856,67 +859,47 @@ class TicketManager
)";
}
- // Search advanced
- if (isset($_GET['submit_advanced'])) {
- $keyword_category = Database::escape_string(
- trim($_GET['keyword_category'])
- );
- $keyword_admin = Database::escape_string(
- trim($_GET['keyword_admin'])
- );
- $keyword_start_date_start = Database::escape_string(
- trim($_GET['keyword_start_date_start'])
- );
- $keyword_start_date_end = Database::escape_string(
- trim($_GET['keyword_start_date_end'])
- );
- $keyword_status = Database::escape_string(
- trim($_GET['keyword_status'])
- );
- $keyword_source = isset($_GET['keyword_source']) ? Database::escape_string(trim($_GET['keyword_source'])) : '';
- $keyword_priority = Database::escape_string(
- trim($_GET['keyword_priority'])
- );
+ $keywords = [
+ 'project_id' => 'ticket.project_id',
+ 'keyword_category' => 'ticket.category_id',
+ 'keyword_assigned_to' => 'ticket.assigned_last_user',
+ 'keyword_source' => 'ticket.source ',
+ 'keyword_status' => 'ticket.status_id',
+ 'keyword_priority' => 'ticket.priority_id'
+ ];
- $keyword_range = !empty($keyword_start_date_start) && !empty($keyword_start_date_end);
- $keyword_course = Database::escape_string(trim($_GET['keyword_course']));
- if ($keyword_category != '') {
- $sql .= " AND ticket.category_id = '$keyword_category' ";
+ foreach ($keywords as $keyword => $sqlLabel) {
+ if (isset($_GET[$keyword])) {
+ $data = Database::escape_string(trim($_GET[$keyword]));
+ $sql .= " AND $sqlLabel = '$data' ";
}
+ }
- if ($keyword_admin != '') {
- $sql .= " AND ticket.assigned_last_user = '$keyword_admin' ";
- }
- if ($keyword_status != '') {
- $sql .= " AND ticket.status_id = '$keyword_status' ";
- }
+ // Search advanced
+ $keyword_start_date_start = isset($_GET['keyword_start_date_start']) ? Database::escape_string(trim($_GET['keyword_start_date_start'])) : '';
+ $keyword_start_date_end = isset($_GET['keyword_start_date_end']) ? Database::escape_string(trim($_GET['keyword_start_date_end'])) : '';
+ $keyword_course = isset($_GET['keyword_course']) ? Database::escape_string(trim($_GET['keyword_course'])) : '';
+ $keyword_range = !empty($keyword_start_date_start) && !empty($keyword_start_date_end);
- if ($keyword_range == false && $keyword_start_date_start != '') {
- $sql .= " AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start' ";
- }
- if ($keyword_range && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
- $sql .= " AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start'
- AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'";
- }
- if ($keyword_priority != '') {
- $sql .= " AND ticket.priority_id = '$keyword_priority' ";
- }
- if ($keyword_source != '') {
- $sql .= " AND ticket.source = '$keyword_source' ";
- }
- if ($keyword_course != '') {
- $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
- $sql .= " AND ticket.course_id IN (
- SELECT id FROM $course_table
- WHERE (
- title LIKE '%$keyword_course%' OR
- code LIKE '%$keyword_course%' OR
- visual_code LIKE '%$keyword_course%'
- )
- )";
- }
+ if ($keyword_range == false && $keyword_start_date_start != '') {
+ $sql .= " AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start' ";
+ }
+ if ($keyword_range && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
+ $sql .= " AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start'
+ AND DATE_FORMAT(ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'";
}
+ if ($keyword_course != '') {
+ $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
+ $sql .= " AND ticket.course_id IN (
+ SELECT id FROM $course_table
+ WHERE (
+ title LIKE '%$keyword_course%' OR
+ code LIKE '%$keyword_course%' OR
+ visual_code LIKE '%$keyword_course%'
+ )
+ )";
+ }
$sql .= " ORDER BY $column $direction";
$sql .= " LIMIT $from, $number_of_items";
@@ -924,31 +907,9 @@ class TicketManager
$tickets = array();
$webPath = api_get_path(WEB_PATH);
while ($row = Database::fetch_assoc($result)) {
- /*$sql_unread = "SELECT
- COUNT(DISTINCT message.message_id) AS unread
- FROM $table_support_tickets ticket,
- $table_support_messages message,
- $table_main_user user
- WHERE ticket.ticket_id = message.ticket_id
- AND ticket.ticket_id = '{$row['col0']}'
- AND message.status = 'NOL'
- AND message.sys_insert_user_id = user.user_id ";
- if ($isAdmin) {
- $sql_unread .= " AND user.user_id
- NOT IN (SELECT user_id FROM $table_main_admin)
- AND ticket.status_id != '".self::STATUS_FORWARDED."' ";
- } else {
- $sql_unread .= " AND user.user_id
- IN (SELECT user_id FROM $table_main_admin) ";
- }
- $result_unread = Database::query($sql_unread);
- $unread = Database::fetch_object($result_unread)->unread;*/
-
$userInfo = api_get_user_info($row['sys_insert_user_id']);
$hrefUser = $webPath.'main/admin/user_information.php?user_id='.$userInfo['user_id'];
$name = " {$userInfo['complete_name_with_username']} ";
- $actions = '';
-
if ($row['assigned_last_user'] != 0) {
$assignedUserInfo = api_get_user_info($row['assigned_last_user']);
if (!empty($assignedUserInfo)) {
@@ -997,19 +958,6 @@ class TicketManager
$row['total_messages']
);
} else {
- $actions = '';
- /*
- $now = api_strtotime(api_get_utc_datetime());
- $last_edit_date = api_strtotime($row['sys_lastedit_datetime']);
- $dif = $now - $last_edit_date;
-
- if ($dif > 172800 && $row['priority_id'] === self::PRIORITY_NORMAL && $row['status_id'] != self::STATUS_CLOSE) {
- $actions .= '
- ';
- }
- if ($row['priority_id'] === self::PRIORITY_HIGH) {
- $actions .= '';
- }*/
$ticket = array(
$icon.' '.$row['subject'],
$row['status_name'],
@@ -1018,11 +966,6 @@ class TicketManager
$row['category_name']
);
}
- /*if ($unread > 0) {
- $ticket['0'] = $ticket['0'] . ' (' . $unread . ')
-
- ';
- }*/
if ($isAdmin) {
$ticket['0'] .= '
@@ -1048,6 +991,10 @@ class TicketManager
$userId = api_get_user_id();
+ if (!isset($_GET['project_id'])) {
+ return 0;
+ }
+
$sql = "SELECT COUNT(ticket.id) AS total
FROM $table_support_tickets ticket
INNER JOIN $table_support_category cat
@@ -1077,98 +1024,45 @@ class TicketManager
}
}
- // Search advanced
- if (isset($_GET['submit_advanced'])) {
- $keyword_category = Database::escape_string(
- trim($_GET['keyword_category'])
- );
- $keyword_admin = Database::escape_string(
- trim($_GET['keyword_admin'])
- );
- $keyword_start_date_start = Database::escape_string(
- trim($_GET['keyword_start_date_start'])
- );
- $keyword_start_date_end = Database::escape_string(
- trim($_GET['keyword_start_date_end'])
- );
- $keyword_status = Database::escape_string(
- trim($_GET['keyword_status'])
- );
- $keyword_source = isset($_GET['keyword_source']) ? Database::escape_string(trim($_GET['keyword_source'])) : '';
- $keyword_priority = Database::escape_string(
- trim($_GET['keyword_priority'])
- );
-
- $keyword_range = isset($_GET['keyword_dates']) ? Database::escape_string(trim($_GET['keyword_dates'])) : '';
- $keyword_course = Database::escape_string(
- trim($_GET['keyword_course'])
- );
+ $keywords = [
+ 'project_id' => 'ticket.project_id',
+ 'keyword_category' => 'ticket.category_id',
+ 'keyword_assigned_to' => 'ticket.assigned_last_user',
+ 'keyword_source' => 'ticket.source',
+ 'keyword_status' => 'ticket.status_id',
+ 'keyword_priority' => 'ticket.priority_id'
+ ];
- if ($keyword_category != '') {
- $sql .= " AND ticket.category_id = '$keyword_category' ";
+ foreach ($keywords as $keyword => $sqlLabel) {
+ if (isset($_GET[$keyword])) {
+ $data = Database::escape_string(trim($_GET[$keyword]));
+ $sql .= " AND $sqlLabel = '$data' ";
}
+ }
- if ($keyword_admin != '') {
- $sql .= " AND ticket.assigned_last_user = '$keyword_admin' ";
- }
- if ($keyword_status != '') {
- $sql .= " AND ticket.status_id = '$keyword_status' ";
- }
- if ($keyword_range == false && $keyword_start_date_start != '') {
- $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' ";
- }
- if ($keyword_range && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
- $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start'
- AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'";
- }
- if ($keyword_priority != '') {
- $sql .= " AND ticket.priority_id = '$keyword_priority' ";
- }
- if ($keyword_source != '') {
- $sql .= " AND ticket.source = '$keyword_source' ";
- }
- if ($keyword_priority != '') {
- $sql .= " AND ticket.priority_id = '$keyword_priority' ";
- }
- if ($keyword_course != '') {
- $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
- $sql .= " AND ticket.course_id IN ( ";
- $sql .= "SELECT id
- FROM $course_table
- WHERE (title LIKE '%$keyword_course%'
- OR code LIKE '%$keyword_course%'
- OR visual_code LIKE '%$keyword_course%' )) ";
- }
+ // Search advanced
+ $keyword_start_date_start = isset($_GET['keyword_start_date_start']) ? Database::escape_string(trim($_GET['keyword_start_date_start'])) : '';
+ $keyword_start_date_end = isset($_GET['keyword_start_date_end']) ? Database::escape_string(trim($_GET['keyword_start_date_end'])) : '';
+ $keyword_range = isset($_GET['keyword_dates']) ? Database::escape_string(trim($_GET['keyword_dates'])) : '';
+ $keyword_course = isset($_GET['keyword_course']) ? Database::escape_string(trim($_GET['keyword_course'])) : '';
+
+ if ($keyword_range == false && $keyword_start_date_start != '') {
+ $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' ";
}
- /*
- if ($keyword_unread == 'yes') {
- $sql .= " AND ticket.id IN ( ";
- $sql .= "SELECT ticket.id
- FROM $table_support_tickets ticket,
- $table_support_messages message,
- $table_main_user user
- WHERE ticket.id = message.ticket_id
- AND message.status = 'NOL'
- AND message.sys_insert_user_id = user.user_id
- AND user.user_id NOT IN (
- SELECT user_id FROM $table_main_admin
- ) AND ticket.status_id != '".self::STATUS_FORWARDED."'
- GROUP BY ticket.id)";
- } else {
- if ($keyword_unread == 'no') {
- $sql .= " AND ticket.id NOT IN ( ";
- $sql .= " SELECT ticket.id
- FROM $table_support_tickets ticket,
- $table_support_messages message,
- $table_main_user user
- WHERE ticket.id = message.ticket_id
- AND message.status = 'NOL'
- AND message.sys_insert_user_id = user.user_id
- AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin)
- AND ticket.status_id != '".self::STATUS_FORWARDED."'
- GROUP BY ticket.id)";
- }
- }*/
+ if ($keyword_range && $keyword_start_date_start != '' && $keyword_start_date_end != '') {
+ $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start'
+ AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'";
+ }
+ if ($keyword_course != '') {
+ $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
+ $sql .= " AND ticket.course_id IN ( ";
+ $sql .= "SELECT id
+ FROM $course_table
+ WHERE (title LIKE '%$keyword_course%'
+ OR code LIKE '%$keyword_course%'
+ OR visual_code LIKE '%$keyword_course%' )) ";
+ }
+
$res = Database::query($sql);
$obj = Database::fetch_object($res);
@@ -1293,7 +1187,6 @@ class TicketManager
if (api_is_platform_admin()) {
$sql .= " AND sys_insert_user_id = '$userId'";
} else {
-
$sql .= " AND sys_insert_user_id != '$userId'";
}
$result = Database::query($sql);
@@ -1652,9 +1545,7 @@ class TicketManager
$keyword_request_user = Database::escape_string(
trim($_GET['keyword_request_user'])
);
- $keyword_admin = Database::escape_string(
- trim($_GET['keyword_admin'])
- );
+ $keywordAssignedTo = (int) $_GET['keyword_assigned_to'];
$keyword_start_date_start = Database::escape_string(
trim($_GET['keyword_start_date_start'])
);
@@ -1692,8 +1583,8 @@ class TicketManager
OR concat(user.lastname,' ',user.firstname) LIKE '%$keyword_request_user%'
OR user.username LIKE '%$keyword_request_user%') ";
}
- if ($keyword_admin != '') {
- $sql .= " AND ticket.assigned_last_user = '$keyword_admin' ";
+ if (!empty($keywordAssignedTo)) {
+ $sql .= " AND ticket.assigned_last_user = $keywordAssignedTo ";
}
if ($keyword_status != '') {
$sql .= " AND ticket.status_id = '$keyword_status' ";
@@ -1789,6 +1680,8 @@ class TicketManager
/**
* @param string $url
+ * @param int $projectId
+ *
* @return FormValidator
*/
public static function getCategoryForm($url, $projectId)
@@ -1810,7 +1703,7 @@ class TicketManager
$items = Database::getManager()->getRepository('ChamiloTicketBundle:Status')->findAll();
$list = [];
- /** @var \Chamilo\TicketBundle\Entity\Status $row */
+ /** @var Status $row */
foreach ($items as $row) {
$list[$row->getId()] = $row->getName();
}
@@ -1859,7 +1752,7 @@ class TicketManager
$projects = Database::getManager()->getRepository('ChamiloTicketBundle:Priority')->findAll();
$list = [];
- /** @var \Chamilo\TicketBundle\Entity\Priority $row */
+ /** @var Priority $row */
foreach ($projects as $row) {
$list[$row->getId()] = $row->getName();
}
@@ -1935,8 +1828,6 @@ class TicketManager
$project->setName($params['name']);
$project->setDescription($params['description']);
$project->setInsertUserId(api_get_user_id());
- //$project->setEmail($params['email']);
-
Database::getManager()->persist($project);
Database::getManager()->flush();
}
diff --git a/main/ticket/assign_tickets.php b/main/ticket/assign_tickets.php
index 58397b3430..e58673d343 100644
--- a/main/ticket/assign_tickets.php
+++ b/main/ticket/assign_tickets.php
@@ -6,11 +6,12 @@
* @package chamilo.plugin.ticket
*/
+$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
if (!api_is_allowed_to_edit()) {
- api_not_allowed();
+ api_not_allowed(true);
}
$course_info = api_get_course_info();
$course_code = $course_info['code'];
diff --git a/main/ticket/categories.php b/main/ticket/categories.php
index eb0f1a1ff2..e0fa34cf2f 100644
--- a/main/ticket/categories.php
+++ b/main/ticket/categories.php
@@ -10,6 +10,8 @@ use ChamiloSession as Session;
// needed in order to load the plugin lang variables
$course_plugin = 'ticket';
+$cidReset = true;
+
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script(true);
diff --git a/main/ticket/new_ticket.php b/main/ticket/new_ticket.php
index 1e6618761c..97d7ca7957 100644
--- a/main/ticket/new_ticket.php
+++ b/main/ticket/new_ticket.php
@@ -5,6 +5,8 @@
* @package chamilo.plugin.ticket
*/
+$cidReset = true;
+
require_once __DIR__.'/../inc/global.inc.php';
if (!api_is_platform_admin() && api_get_setting('ticket_allow_student_add') != 'true') {
diff --git a/main/ticket/priorities.php b/main/ticket/priorities.php
index b11e64a9da..72dca990d3 100644
--- a/main/ticket/priorities.php
+++ b/main/ticket/priorities.php
@@ -6,6 +6,8 @@
* @package chamilo.plugin.ticket
*/
+$cidReset = true;
+
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script(true);
diff --git a/main/ticket/projects.php b/main/ticket/projects.php
index ce950e2890..71bf3b3529 100644
--- a/main/ticket/projects.php
+++ b/main/ticket/projects.php
@@ -6,6 +6,8 @@
* @package chamilo.plugin.ticket
*/
+$cidReset = true;
+
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script(true);
diff --git a/main/ticket/report.php b/main/ticket/report.php
index 167cf84068..e6a00e7177 100644
--- a/main/ticket/report.php
+++ b/main/ticket/report.php
@@ -4,6 +4,7 @@
/**
* @package chamilo.plugin.ticket
*/
+$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
diff --git a/main/ticket/settings.php b/main/ticket/settings.php
index 7d76eec2fc..b3c5efde70 100644
--- a/main/ticket/settings.php
+++ b/main/ticket/settings.php
@@ -1,6 +1,8 @@
';
$htmlHeadXtra[] = '