Add my tickets and all tickets link, fix query to handle projects.

Add cidReset

See BT#12632
pull/2487/head
jmontoyaa 8 years ago
parent c4fd46650a
commit 0a695ca611
  1. 279
      main/inc/lib/TicketManager.php
  2. 3
      main/ticket/assign_tickets.php
  3. 2
      main/ticket/categories.php
  4. 2
      main/ticket/new_ticket.php
  5. 2
      main/ticket/priorities.php
  6. 2
      main/ticket/projects.php
  7. 1
      main/ticket/report.php
  8. 2
      main/ticket/settings.php
  9. 2
      main/ticket/status.php
  10. 46
      main/ticket/ticket_details.php
  11. 35
      main/ticket/tickets.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 = "<a href='$hrefUser'> {$userInfo['complete_name_with_username']} </a>";
$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 .= '<a href="'.api_get_path(WEB_CODE_PATH).'ticket/tickets.php?ticket_id=' . $row['ticket_id'] . '&amp;action=alert">
<img src="' . Display::returnIconPath('exclamation.png') . '" border="0" /></a>';
}
if ($row['priority_id'] === self::PRIORITY_HIGH) {
$actions .= '<img src="' . Display::returnIconPath('admin_star.png') . '" border="0" />';
}*/
$ticket = array(
$icon.' '.$row['subject'],
$row['status_name'],
@ -1018,11 +966,6 @@ class TicketManager
$row['category_name']
);
}
/*if ($unread > 0) {
$ticket['0'] = $ticket['0'] . '&nbsp;&nbsp;(' . $unread . ')<a href="ticket_details.php?ticket_id=' . $row['ticket_id'] . '">
<img src="' . Display::returnIconPath('message_new.png') . '" border="0" title="' . $unread . ' ' . get_lang('Messages') . '"/>
</a>';
}*/
if ($isAdmin) {
$ticket['0'] .= '&nbsp;&nbsp;<a href="javascript:void(0)" onclick="load_history_ticket(\'div_'.$row['ticket_id'].'\','.$row['ticket_id'].')">
<img onclick="load_course_list(\'div_' . $row['ticket_id'].'\','.$row['ticket_id'].')" onmouseover="clear_course_list (\'div_'.$row['ticket_id'].'\')" src="'.Display::returnIconPath('history.gif').'" title="'.get_lang('Historial').'" alt="'.get_lang('Historial').'"/>
@ -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();
}

@ -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'];

@ -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);

@ -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') {

@ -6,6 +6,8 @@
* @package chamilo.plugin.ticket
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script(true);

@ -6,6 +6,8 @@
* @package chamilo.plugin.ticket
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script(true);

@ -4,6 +4,7 @@
/**
* @package chamilo.plugin.ticket
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();

@ -6,6 +6,8 @@
* @package chamilo.plugin.ticket
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script(true);

@ -2,9 +2,11 @@
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
@ -108,44 +110,6 @@ function add_image_form() {
</script>';
$htmlHeadXtra[] = '<style>
div.row div.label2 {
float:left;
text-align: right;
width:22%;
}
div.row div.formw2 {
width:50%;
margin-left: 2%;
margin-right: 16%;
float:left;
}
.messageuser, .messagesupport {
border: 1px solid;
margin: 10px 0px;
padding:15px 10px 15px 50px;
background-repeat: no-repeat;
background-position: 10px center;
width:50%;
behavior: url(/pie/PIE.htc);
}
.messageuser {
color: #00529B;
-moz-border-radius: 15px 15px 15px 15px;
-webkit-border-radius: 15px 15px 15px 15px;
background-color: #BDE5F8;
margin-left:20%;
border-radius:15px;
float: left;
}
.messagesupport {
color: #4F8A10;
-moz-border-radius: 15px 15px 15px 15px;
-webkit-border-radius: 15px 15px 15px 15px;
background-color: #DFF2BF;
margin-right: 20%;
float: right;
border-radius:15px;
}
.attachment-link {
margin: 12px;
}
@ -325,7 +289,6 @@ if (!isset($_POST['compose'])) {
['class' => 'well']
);
}
$counter++;
}
@ -337,8 +300,7 @@ if (!isset($_POST['compose'])) {
if (!$isAdmin && $ticket['ticket']['status_id'] != TicketManager::STATUS_UNCONFIRMED) {
show_form_send_message($ticket['ticket']);
} else {
if (
$ticket['ticket']['assigned_last_user'] == $user_id ||
if ($ticket['ticket']['assigned_last_user'] == $user_id ||
$ticket['ticket']['sys_insert_user_id'] == $user_id ||
$isAdmin
) {

@ -139,8 +139,7 @@ if (!empty($projectId)) {
'keyword',
'keyword_status',
'keyword_category',
'keyword_request_user',
'keyword_admin',
'keyword_assigned_to',
'keyword_start_date',
'keyword_unread',
'Tickets_per_page',
@ -270,6 +269,36 @@ if (!empty($projectId)) {
)
);
$ticketLabel = get_lang('AllTickets');
$url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$projectId;
if (!isset($_GET['keyword_assigned_to'])) {
$ticketLabel = get_lang('MyTickets');
$url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$projectId.'&keyword_assigned_to='.api_get_user_id();
}
$options = '';
if (api_is_platform_admin()) {
$options .=Display::url(
get_lang('Projects'),
api_get_path(WEB_CODE_PATH).'ticket/projects.php'
);
}
$options .= Display::url(
$ticketLabel,
$url
);
if (api_is_platform_admin()) {
echo Display::toolbarAction(
'options',
array(
$options
)
);
}
$advancedSearchForm = new FormValidator(
'advanced_search',
'get',
@ -289,7 +318,7 @@ if (!empty($projectId)) {
$advancedSearchForm->addDateTimePicker('keyword_start_date_start', get_lang('Created'));
$advancedSearchForm->addDateTimePicker('keyword_start_date_end', get_lang('Until'));
$advancedSearchForm->addSelect(
'keyword_admin',
'keyword_assigned_to',
get_lang('AssignedTo'),
$selectAdmins,
['placeholder' => get_lang('All')]

Loading…
Cancel
Save