diff --git a/main/course_description/resources/js/main.js b/main/course_description/resources/js/main.js index e1e85681e6..964ea0232f 100755 --- a/main/course_description/resources/js/main.js +++ b/main/course_description/resources/js/main.js @@ -1,44 +1,40 @@ +function Proxy() { +} -function Proxy() {}; - -Proxy.prototype.root = function(){ +Proxy.prototype.root = function () { return www + '/main/inc/ajax/course_description.ajax.php'; } -Proxy.prototype.post = function(data, f){ - if(typeof(sec_token)!=='undefined'){ +Proxy.prototype.post = function (data, f) { + if (typeof(sec_token) !== 'undefined') { data.sec_token = sec_token; } $.post(this.root(), data, f, 'json'); } - var CourseDescription = new Proxy(); -CourseDescription.del = function(c_id, id, f) -{ +CourseDescription.del = function (c_id, id, f) { var data = { - c_id: c_id, - id: id, + c_id: c_id, + id: id, action: 'delete' }; this.post(data, f); }; -CourseDescription.delete_by_course = function(c_id, session_id, f) -{ +CourseDescription.delete_by_course = function (c_id, session_id, f) { var data = { - c_id: c_id, - session_id: session_id, + c_id: c_id, + session_id: session_id, action: 'delete_by_course' }; this.post(data, f); }; - var message = {}; -message.update = function(data){ - text = typeof(data)=='string' ? data : data.message; - $('#messages').html(text) +message.update = function (data) { + text = typeof(data) == 'string' ? data : data.message; + $('#messages').html(text); } \ No newline at end of file diff --git a/main/inc/lib/TicketManager.php b/main/inc/lib/TicketManager.php index 8691297cf6..63bee19159 100644 --- a/main/inc/lib/TicketManager.php +++ b/main/inc/lib/TicketManager.php @@ -196,7 +196,7 @@ class TicketManager $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER); foreach ($users as $userId) { - if (self::userIsAssignedToCategory($userId, $categoryId) == false) { + if (self::userIsAssignedToCategory($userId, $categoryId) === false) { $params = [ 'category_id' => $categoryId, 'user_id' => $userId, @@ -217,8 +217,8 @@ class TicketManager public static function userIsAssignedToCategory($userId, $categoryId) { $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER); - $userId = intval($userId); - $categoryId = intval($categoryId); + $userId = (int) $userId; + $categoryId = (int) $categoryId; $sql = "SELECT * FROM $table WHERE category_id = $categoryId AND user_id = $userId"; $result = Database::query($sql); @@ -234,7 +234,7 @@ class TicketManager public static function getUsersInCategory($categoryId) { $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER); - $categoryId = intval($categoryId); + $categoryId = (int) $categoryId; $sql = "SELECT * FROM $table WHERE category_id = $categoryId"; $result = Database::query($sql); @@ -247,7 +247,7 @@ class TicketManager public static function deleteAllUserInCategory($categoryId) { $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER); - $categoryId = intval($categoryId); + $categoryId = (int) $categoryId; $sql = "DELETE FROM $table WHERE category_id = $categoryId"; Database::query($sql); } @@ -583,8 +583,8 @@ class TicketManager $ticketId, $userId ) { - $ticketId = intval($ticketId); - $userId = intval($userId); + $ticketId = (int) $ticketId; + $userId = (int) $userId; if (empty($ticketId)) { return false; @@ -636,8 +636,8 @@ class TicketManager $status = 'NOL', $sendConfirmation = false ) { - $ticketId = intval($ticketId); - $userId = intval($userId); + $ticketId = (int) $ticketId; + $userId = (int) $userId; $table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); if ($sendConfirmation) { @@ -764,24 +764,26 @@ class TicketManager * @param int $number_of_items * @param $column * @param $direction - * @param int $userId * * @return array */ - public static function get_tickets_by_user_id( + public static function getTicketsByCurrentUser( $from, $number_of_items, $column, - $direction, - $userId = 0 + $direction ) { $table_support_category = Database::get_main_table(TABLE_TICKET_CATEGORY); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_priority = Database::get_main_table(TABLE_TICKET_PRIORITY); $table_support_status = Database::get_main_table(TABLE_TICKET_STATUS); $direction = !empty($direction) ? $direction : 'DESC'; - $userId = !empty($userId) ? $userId : api_get_user_id(); + $userId = api_get_user_id(); $userInfo = api_get_user_info($userId); + + if (empty($userInfo)) { + return []; + } $isAdmin = UserManager::is_admin($userId); if (!isset($_GET['project_id'])) { @@ -995,11 +997,9 @@ class TicketManager } /** - * @param int $userId - * * @return int */ - public static function get_total_tickets_by_user_id($userId = 0) + public static function getTotalTicketsCurrentUser() { $table_support_category = Database::get_main_table(TABLE_TICKET_CATEGORY); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); @@ -1106,7 +1106,7 @@ class TicketManager /** * @param int $id * - * @return MessageAttachment + * @return false|MessageAttachment */ public static function getTicketMessageAttachment($id) { diff --git a/main/inc/lib/plugin.class.php b/main/inc/lib/plugin.class.php index d968051cb6..93620c9405 100755 --- a/main/inc/lib/plugin.class.php +++ b/main/inc/lib/plugin.class.php @@ -978,4 +978,12 @@ class Plugin return $tool; } + + /** + * @param bool $value + */ + public function setHasPersonalEvents($value) + { + $this->hasPersonalEvents = $value; + } } diff --git a/main/ticket/tickets.php b/main/ticket/tickets.php index 6255e7ee80..2e60379579 100644 --- a/main/ticket/tickets.php +++ b/main/ticket/tickets.php @@ -59,8 +59,8 @@ $projectId = isset($_GET['project_id']) ? (int) $_GET['project_id'] : 0; $table = new SortableTable( 'Tickets', - ['TicketManager', 'get_total_tickets_by_user_id'], - ['TicketManager', 'get_tickets_by_user_id'], + ['TicketManager', 'getTotalTicketsCurrentUser'], + ['TicketManager', 'getTicketsByCurrentUser'], 2, 20, 'DESC' diff --git a/plugin/learning_calendar/LearningCalendarPlugin.php b/plugin/learning_calendar/LearningCalendarPlugin.php index a638b192ce..e74e7ad197 100644 --- a/plugin/learning_calendar/LearningCalendarPlugin.php +++ b/plugin/learning_calendar/LearningCalendarPlugin.php @@ -15,10 +15,10 @@ class LearningCalendarPlugin extends Plugin */ protected function __construct() { - $this->hasPersonalEvents = true; $version = '0.1'; $author = 'Julio Montoya'; parent::__construct($version, $author, ['enabled' => 'boolean']); + $this->setHasPersonalEvents(true); } /**