瀏覽代碼

Merge branch '1.11.x' into session

Alex Aragon 8 年之前
父節點
當前提交
b4278f6d8a
共有 43 個文件被更改,包括 969 次插入1102 次删除
  1. 8 2
      app/Migrations/Schema/V111/Version111.php
  2. 15 15
      main/admin/configure_plugin.php
  3. 49 11
      main/coursecopy/classes/CourseRestorer.class.php
  4. 1 1
      main/coursecopy/classes/CourseSelectForm.class.php
  5. 13 1
      main/inc/lib/api.lib.php
  6. 1 2
      main/inc/lib/formvalidator/Element/DateTimePicker.php
  7. 2 2
      main/inc/lib/formvalidator/Element/SelectAjax.php
  8. 2 2
      main/inc/lib/internationalization.lib.php
  9. 16 16
      main/inc/lib/message.lib.php
  10. 81 159
      main/inc/lib/pear/HTML/QuickForm/select.php
  11. 7 5
      main/inc/lib/plugin.class.php
  12. 2 1
      main/inc/lib/plugin.lib.php
  13. 6 5
      main/inc/lib/social.lib.php
  14. 2 2
      main/inc/lib/usergroup.lib.php
  15. 2 2
      main/session/session_add.php
  16. 1 3
      main/social/group_topics.php
  17. 6 6
      main/social/group_view.php
  18. 1 0
      plugin/ticket/README.md
  19. 0 12
      plugin/ticket/config.install.php
  20. 0 23
      plugin/ticket/config.php
  21. 26 24
      plugin/ticket/database.php
  22. 5 3
      plugin/ticket/lang/english.php
  23. 2 0
      plugin/ticket/lang/french.php
  24. 2 0
      plugin/ticket/lang/spanish.php
  25. 0 1
      plugin/ticket/readme.txt
  26. 1 1
      plugin/ticket/src/assign_tickets.php
  27. 5 2
      plugin/ticket/src/categories.php
  28. 1 1
      plugin/ticket/src/categories_add_user.php
  29. 1 1
      plugin/ticket/src/course_user_list.php
  30. 1 1
      plugin/ticket/src/download.php
  31. 2 2
      plugin/ticket/src/index.php
  32. 120 256
      plugin/ticket/src/myticket.php
  33. 26 31
      plugin/ticket/src/new_ticket.php
  34. 1 2
      plugin/ticket/src/report.php
  35. 0 15
      plugin/ticket/src/test.html
  36. 367 381
      plugin/ticket/src/ticket.class.php
  37. 1 1
      plugin/ticket/src/ticket_assign_log.php
  38. 185 89
      plugin/ticket/src/ticket_details.php
  39. 1 5
      plugin/ticket/src/ticket_plugin.class.php
  40. 2 2
      plugin/ticket/src/tutor.php
  41. 3 3
      plugin/ticket/src/update_report.php
  42. 1 10
      plugin/vchamilo/index.php
  43. 1 1
      plugin/vchamilo/plugin.php

+ 8 - 2
app/Migrations/Schema/V111/Version111.php

@@ -137,9 +137,15 @@ class Version111 extends AbstractMigrationChamilo
         $this->addSql('DROP TABLE group_rel_tag');
         $this->addSql('DROP TABLE group_rel_group');
         $this->addSql('DROP TABLE groups');
-    }
 
-    /**
+        if ($schema->hasTable('plugin_ticket_ticket')) {
+            $this->addSql('ALTER TABLE plugin_ticket_ticket ADD COLUMN subject varchar(255) DEFAULT NULL;');
+            $this->addSql('ALTER TABLE plugin_ticket_ticket ADD COLUMN message text NOT NULL;');
+            $this->addSql('UPDATE plugin_ticket_ticket t INNER JOIN plugin_ticket_message as m  ON(t.ticket_id = m.ticket_id and message_id =1)  SET t.subject = m.subject');
+            $this->addSql('UPDATE plugin_ticket_ticket t INNER JOIN plugin_ticket_message as m  ON(t.ticket_id = m.ticket_id and message_id =1)  SET t.message = m.message');
+            $this->addSql('DELETE FROM plugin_ticket_message WHERE message_id = 1');
+        }
+}    /**
      * @param Schema $schema
      */
     public function postUp(Schema $schema)

+ 15 - 15
main/admin/configure_plugin.php

@@ -25,17 +25,23 @@ if (!in_array($pluginName, $installedPlugins) || empty($pluginInfo)) {
 
 global $_configuration;
 
-$message = null;
-$content = null;
+$message = '';
+$content = '';
 
 $currentUrl = api_get_self() . "?name=$pluginName";
 
 if (isset($pluginInfo['settings_form'])) {
+    /** @var FormValidator $form */
     $form = $pluginInfo['settings_form'];
     if (isset($form)) {
-        //We override the form attributes
+
+        // We override the form attributes
         $attributes = array('action' => $currentUrl, 'method' => 'POST');
         $form->updateAttributes($attributes);
+
+        if (isset($pluginInfo['settings'])) {
+            $form->setDefaults($pluginInfo['settings']);
+        }
         $content = Display::page_header($pluginInfo['title']);
         $content .= $form->toHtml();
     }
@@ -46,8 +52,6 @@ if (isset($pluginInfo['settings_form'])) {
 if (isset($form)) {
     if ($form->validate()) {
         $values = $form->exportValues();
-
-        //api_delete_category_settings_by_subkey($pluginName);
         $accessUrlId = api_get_current_access_url_id();
 
         api_delete_settings_params(
@@ -64,7 +68,8 @@ if (isset($form)) {
 
         foreach ($values as $key => $value) {
             api_add_setting(
-                $value, Database::escape_string($pluginName . '_' . $key),
+                $value,
+                Database::escape_string($pluginName . '_' . $key),
                 $pluginName,
                 'setting',
                 'Plugins',
@@ -76,28 +81,23 @@ if (isset($form)) {
                 1
             );
         }
+
         if (isset($values['show_main_menu_tab'])) {
             $objPlugin = $pluginInfo['plugin_class']::create();
             $objPlugin->manageTab($values['show_main_menu_tab']);
         }
 
-        $message = Display::return_message(get_lang('Updated'), 'success');
-
-        Session::write('message', $message);
+        Display::addFlash(Display::return_message(get_lang('Updated'), 'success'));
 
         header("Location: $currentUrl");
         exit;
     } else {
         foreach ($form->_errors as $error) {
-            $message .= Display::return_message($error, 'error');
+            Display::addFlash(Display::return_message($error, 'error'));
         }
     }
 }
 
-if (Session::has('message')) {
-    $message = Session::read('message');
-}
-
 $interbreadcrumb[] = array(
     'url' => api_get_path(WEB_CODE_PATH) . 'admin/index.php',
     'name' => get_lang('PlatformAdmin')
@@ -108,7 +108,7 @@ $interbreadcrumb[] = array(
 );
 
 $tpl = new Template($pluginName, true, true, false, true, false);
-$tpl->assign('message', $message);
+$tpl->assign('message', '');
 $tpl->assign('content', $content);
 $tpl->display_one_col_template();
 

+ 49 - 11
main/coursecopy/classes/CourseRestorer.class.php

@@ -465,6 +465,7 @@ class CourseRestorer
                                             'filetype' => self::DBUTF8($document->file_type),
                                             'size' => self::DBUTF8($document->size),
                                             'session_id' => $my_session_id,
+                                            'readonly' => 0
                                         ];
 
     									$document_id = Database::insert($table, $params);
@@ -889,6 +890,7 @@ class CourseRestorer
                                 'filetype' => self::DBUTF8($document->file_type),
                                 'size' => self::DBUTF8($document->size),
                                 'session_id' => $my_session_id,
+                                'readonly' => 0
                             ];
 
                             $document_id = Database::insert($table, $params);
@@ -1051,7 +1053,9 @@ class CourseRestorer
                 $params['forum_category'] = $cat_id;
                 $params['session_id'] = $sessionId;
 
-                unset($params['forum_id']);
+                $params['start_time'] = isset($params['start_time']) && $params['start_time'] === '0000-00-00 00:00:00' ? null : $params['start_time'];
+                $params['end_time'] = isset($params['end_time']) && $params['end_time'] === '0000-00-00 00:00:00' ? null : $params['end_time'];
+                $params['forum_id'] = 0;
                 unset($params['iid']);
 
                 $params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
@@ -1131,8 +1135,7 @@ class CourseRestorer
                         $this->course->info['path']
                     );
                     $params['session_id'] = intval($sessionId);
-
-                    unset($params['cat_id']);
+                    $params['cat_id'] = 0;
                     unset($params['iid']);
 
                     $params = self::DBUTF8_array($params);
@@ -1172,7 +1175,8 @@ class CourseRestorer
         $params['thread_replies'] = 0;
         $params['thread_views'] = 0;
         $params['session_id'] = intval($sessionId);
-        unset($params['thread_id']);
+        $params['thread_id'] = 0;
+
         unset($params['iid']);
 
         $new_id = Database::insert($table, $params);
@@ -1223,7 +1227,7 @@ class CourseRestorer
         $params['thread_id'] = $topic_id;
         $params['poster_id'] = $this->first_teacher_id;
         $params['post_date'] = api_get_utc_datetime();
-        unset($params['post_id']);
+        $params['post_id'] = 0;
         unset($params['iid']);
         $params['post_text'] = DocumentManager::replace_urls_inside_content_html_from_copy_course(
             $params['post_text'],
@@ -1545,6 +1549,7 @@ class CourseRestorer
                 $params['description_type'] = self::DBUTF8($descriptionType);
                 $params['title'] = self::DBUTF8($title);
                 $params['content'] = self::DBUTF8($description_content);
+                $params['progress'] = 0;
 
                 $id = Database::insert($table, $params);
                 if ($id) {
@@ -1736,6 +1741,9 @@ class CourseRestorer
                         $this->course->info['path']
                     );
 
+                    $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time;
+                    $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time;
+
 					global $_custom;
 					if (isset($_custom['exercises_clean_dates_when_restoring']) &&
                         $_custom['exercises_clean_dates_when_restoring']
@@ -1744,6 +1752,7 @@ class CourseRestorer
 						$quiz->end_time   = null;
 					}
 
+
                     $params = array(
                         'c_id' => $this->destination_course_id,
                         'title' => self::DBUTF8($quiz->title),
@@ -1755,9 +1764,7 @@ class CourseRestorer
                         'max_attempt' => (int)$quiz->max_attempt,
                         'results_disabled' => (int)$quiz->results_disabled,
                         'access_condition' => $quiz->access_condition,
-                        'start_time' => $quiz->start_time,
                         'pass_percentage' => $quiz->pass_percentage,
-                        'end_time' => $quiz->end_time,
                         'feedback_type' => (int)$quiz->feedback_type,
                         'random_answers' => (int)$quiz->random_answers,
                         'random_by_category' => $quiz->random_by_category,
@@ -1765,6 +1772,10 @@ class CourseRestorer
                         'propagate_neg' => $quiz->propagate_neg,
                         'text_when_finished' => $quiz->text_when_finished,
                         'expired_time' => (int)$quiz->expired_time,
+                        'start_time' => $quiz->start_time,
+                        'end_time' => $quiz->end_time,
+                        'save_correct_answers' => 0,
+                        'display_category_name' => 0
                     );
 
                     if ($respect_base_content) {
@@ -1902,6 +1913,8 @@ class CourseRestorer
                         'position' => $answer['position'],
                         'hotspot_coordinates' => $answer['hotspot_coordinates'],
                         'hotspot_type' => $answer['hotspot_type'],
+                        'id_auto' => 0,
+                        'destination' => ''
                     ];
                     $answerId = Database::insert($table_ans, $params);
 
@@ -1943,6 +1956,8 @@ class CourseRestorer
                         'position' => $answer['position'],
                         'hotspot_coordinates' => $answer['hotspot_coordinates'],
                         'hotspot_type' => $answer['hotspot_type'],
+                        'id_auto' => 0,
+                        'destination' => ''
                     ];
 
                     $answerId = Database::insert($table_ans, $params);
@@ -2461,6 +2476,9 @@ class CourseRestorer
                     }
                 }
 
+                $lp->expired_on = isset($lp->expired_on) && $lp->expired_on === '0000-00-00 00:00:00' ? null : $lp->expired_on;
+                $lp->publicated_on = isset($lp->publicated_on) && $lp->publicated_on === '0000-00-00 00:00:00' ? null : $lp->publicated_on;
+
                 $params = [
                     'c_id' => $this->destination_course_id,
                     'lp_type' => $lp->lp_type,
@@ -2486,6 +2504,14 @@ class CourseRestorer
                     'publicated_on' => empty($lp->publicated_on) ? api_get_utc_datetime() : self::DBUTF8($lp->publicated_on),
                     'expired_on' => self::DBUTF8($lp->expired_on),
                     'debug' => self::DBUTF8($lp->debug),
+                    'theme' => '',
+                    'session_id' => $session_id,
+                    'prerequisite' => 0,
+                    'hide_toc_frame' => 0,
+                    'seriousgame_mode' => 0,
+                    'category_id' => 0,
+                    'max_attempts' => 0,
+                    'subscribe_users' => 0
                 ];
 
                 if (!empty($condition_session)) {
@@ -2868,7 +2894,7 @@ class CourseRestorer
                 $params['description'] = self::DBUTF8($glossary->description);
                 $params['display_order'] = $glossary->display_order;
                 $params['name'] = self::DBUTF8($glossary->name);
-
+                $params['glossary_id'] = 0;
                 $my_id = Database::insert($table_glossary, $params);
                 if ($my_id) {
 
@@ -2930,6 +2956,18 @@ class CourseRestorer
                     'progress' => self::DBUTF8($wiki->progress),
                     'version' => intval($wiki->version),
                     'session_id' => !empty($session_id) ? intval($session_id) : 0,
+                    'addlock' => 0,
+                    'editlock' => 0,
+                    'visibility' => 0,
+                    'addlock_disc' => 0,
+                    'visibility_disc' => 0,
+                    'ratinglock_disc' => 0,
+                    'assignment' => 0,
+                    'comment' => '',
+                    'is_editing' => 0,
+                    'linksto' => 0,
+                    'tag' => '',
+                    'user_ip' => ''
                 ];
 
 				$new_id = Database::insert($table_wiki, $params);
@@ -2953,11 +2991,11 @@ class CourseRestorer
                         'fprogress1' => '',
                         'fprogress2' => '',
                         'fprogress3' => '',
-                        'max_size' => '',
+                        'max_size' => 0,
                         'max_text' => 0,
                         'max_version' => 0,
-                        'startdate_assig' => '',
-                        'enddate_assig' => '',
+                        'startdate_assig' => null,
+                        'enddate_assig' => null,
                         'delayedsubmit' => 0,
                     ];
 

+ 1 - 1
main/coursecopy/classes/CourseSelectForm.class.php

@@ -48,7 +48,7 @@ class CourseSelectForm
 				}
 				else{
 					el.style.display='none';
-					document.getElementById('img_'+item).src='<?php echo Display::returnIconPath('O.gif'); ?>';
+					document.getElementById('img_'+item).src='<?php echo Display::returnIconPath('0.gif'); ?>';
 				}
 			}
 

+ 13 - 1
main/inc/lib/api.lib.php

@@ -5274,7 +5274,19 @@ function api_delete_category_settings_by_subkey($subkey, $access_url_id = 1) {
  * @param string $c
  * @return boolean  true on success, false on failure
  */
-function api_add_setting($val, $var, $sk = null, $type = 'textfield', $c = null, $title = '', $com = '', $sc = null, $skt = null, $a = 1, $v = 0) {
+function api_add_setting(
+    $val,
+    $var,
+    $sk = null,
+    $type = 'textfield',
+    $c = null,
+    $title = '',
+    $com = '',
+    $sc = null,
+    $skt = null,
+    $a = 1,
+    $v = 0
+) {
     if (empty($var) || !isset($val)) { return false; }
     $t_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
     $var = Database::escape_string($var);

+ 1 - 2
main/inc/lib/formvalidator/Element/DateTimePicker.php

@@ -32,12 +32,11 @@ class DateTimePicker extends HTML_QuickForm_text
 
         $id = $this->getAttribute('id');
         $value = $this->getValue();
-        $label = $this->getLabel();
 
         if (!empty($value)) {
             $value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
         }
-
+        
         return $this->getElementJS() . '
             <div class="input-group">
                 <span class="input-group-addon">

+ 2 - 2
main/inc/lib/formvalidator/Element/SelectAjax.php

@@ -7,9 +7,9 @@
 class SelectAjax extends HTML_QuickForm_select
 {
     /**
-     * Class constructor
+     * @inheritdoc
      */
-    public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
+    public function __construct($elementName, $elementLabel = '', $options = null, $attributes = null)
     {
         parent::__construct($elementName, $elementLabel, $options, $attributes);
     }

+ 2 - 2
main/inc/lib/internationalization.lib.php

@@ -1964,13 +1964,13 @@ function _api_convert_encoding_supports($encoding) {
  */
 function apiGetHumanDateTime($date, $showTime = true, $humanForm = false) {
     if ($showTime) {
-        if ($dateHuman) {
+        if ($humanForm) {
            return $date->format('j M Y H:i:s');    
         } else {
            return $date->format('Y-m-d H:i:s');     
         }
     } else {
-        if ($dateHuman) {
+        if ($humanForm) {
            return $date->format('j M Y');    
         } else {
            return $date->format('Y-m-d');     

+ 16 - 16
main/inc/lib/message.lib.php

@@ -1314,23 +1314,23 @@ class MessageManager
             ]);
             if (api_is_platform_admin()) {
                 $links .= Display::url(
-                        Display::returnFontAwesomeIcon('trash'),
-                        'group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic_id,
-                        [
-                            'class' => 'btn btn-default'
-                        ]
-                        );
+                    Display::returnFontAwesomeIcon('trash'),
+                    'group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic_id,
+                    [
+                        'class' => 'btn btn-default'
+                    ]
+                );
             }
             $links .= Display::url(
-                        Display::returnFontAwesomeIcon('pencil'),
-                        $urlEdit,
-                        [
-                            'class' => 'btn btn-default ajax',
-                            'title' => get_lang('Edit'),
-                            'data-title' => get_lang('Edit'),
-                            'data-size' => 'lg'
-                        ]
-                    );
+                Display::returnFontAwesomeIcon('pencil'),
+                $urlEdit,
+                [
+                    'class' => 'btn btn-default ajax',
+                    'title' => get_lang('Edit'),
+                    'data-title' => get_lang('Edit'),
+                    'data-size' => 'lg'
+                ]
+            );
         }
 
         $urlReply = api_get_path(WEB_CODE_PATH);
@@ -1358,7 +1358,7 @@ class MessageManager
         $links.= '</div>';
         $links.= '</div>';
 
-        $title = '<h4>'.Security::remove_XSS($main_message['title'].$delete_button, STUDENT, true).$links.'</h4>';
+        $title = '<h4>'.Security::remove_XSS($main_message['title'], STUDENT, true).$links.'</h4>';
 
         $userPicture = $user_sender_info['avatar'];
         $main_content .= '<div class="avatar-author">';

+ 81 - 159
main/inc/lib/pear/HTML/QuickForm/select.php

@@ -54,26 +54,25 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
      * @access    private
      */
     protected $_values = null;
-
     private $columnsSize;
 
     /**
      * Class constructor
      *
-     * @param     string    Select name attribute
-     * @param     mixed     Label(s) for the select
-     * @param     mixed     Data to be used to populate options
-     * @param     mixed     Either a typical HTML attribute string or an associative array
+     * @param     string    $elementName Select name attribute
+     * @param     mixed     $elementLabel Label(s) for the select
+     * @param     mixed     $options Data to be used to populate options
+     * @param     mixed     $attributes Either a typical HTML attribute string or an associative array
      * @since     1.0
      * @access    public
-     * @return    void
      */
     public function __construct(
-        $elementName = null,
-        $elementLabel = null,
+        $elementName,
+        $elementLabel = '',
         $options = null,
         $attributes = null
     ) {
+        $addBlank = '';
         if (is_array($attributes) || empty($attributes)) {
             $oldClass = '';
             if (!empty($attributes['class'])) {
@@ -81,17 +80,90 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
             }
             $attributes['class'] = $oldClass . ' selectpicker show-tick form-control';
             $attributes['data-live-search'] = 'true';
+
+            if (isset($attributes['placeholder'])) {
+                $addBlank =  $attributes['placeholder'];
+            }
+
+
         }
         $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
         $this->setColumnsSize($columnsSize);
         parent::__construct($elementName, $elementLabel, $attributes);
         $this->_persistantFreeze = true;
         $this->_type = 'select';
+
+        if ($addBlank !== '') {
+            if (isset($options)) {
+                $options = ['' => $addBlank] + $options;
+            } else {
+                $options = ['' => $addBlank];
+            }
+        }
         if (isset($options)) {
             $this->load($options);
         }
     }
 
+     /**
+     * Loads options from different types of data sources
+     *
+     * This method is a simulated overloaded method.  The arguments, other than the
+     * first are optional and only mean something depending on the type of the first argument.
+     * If the first argument is an array then all arguments are passed in order to loadArray.
+     * If the first argument is a db_result then all arguments are passed in order to loadDbResult.
+     * If the first argument is a string or a DB connection then all arguments are
+     * passed in order to loadQuery.
+     * @param     mixed     $options     Options source currently supports assoc array or DB_result
+     * @param     mixed     $param1     (optional) See function detail
+     * @param     mixed     $param2     (optional) See function detail
+     * @param     mixed     $param3     (optional) See function detail
+     * @param     mixed     $param4     (optional) See function detail
+     * @since     1.1
+     * @access    public
+     * @return    PEAR_Error on error or true
+     * @throws    PEAR_Error
+     */
+    private function load(&$options, $param1=null, $param2=null, $param3=null, $param4=null)
+    {
+        switch (true) {
+            case is_array($options):
+                return $this->loadArray($options, $param1);
+                break;
+        }
+    }
+
+    /**
+     * Loads the options from an associative array
+     *
+     * @param     array    $arr     Associative array of options
+     * @param     mixed    $values  (optional) Array or comma delimited string of selected values
+     * @since     1.0
+     * @access    public
+     * @return    PEAR_Error on error or true
+     * @throws    PEAR_Error
+     */
+    private function loadArray($arr, $values = null)
+    {
+        if (!is_array($arr)) {
+            return false;
+        }
+        if (isset($values)) {
+            $this->setSelected($values);
+        }
+        foreach ($arr as $key => $val) {
+            // Fix in order to use list of entities.
+            if (is_object($val)) {
+                $key = $val->getId();
+                $val = $val->__toString();
+            }
+
+            // Warning: new API since release 2.3
+            $this->addOption($val, $key);
+        }
+        return true;
+    }
+
     /**
      * Returns the current API version
      *
@@ -363,156 +435,6 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
         $this->_optgroups[] = array('label' => $label, 'options' => $options);
     }
 
-    /**
-     * Loads the options from an associative array
-     *
-     * @param     array    $arr     Associative array of options
-     * @param     mixed    $values  (optional) Array or comma delimited string of selected values
-     * @since     1.0
-     * @access    public
-     * @return    PEAR_Error on error or true
-     * @throws    PEAR_Error
-     */
-    function loadArray($arr, $values=null)
-    {
-        if (!is_array($arr)) {
-            return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array');
-        }
-        if (isset($values)) {
-            $this->setSelected($values);
-        }
-        foreach ($arr as $key => $val) {
-            // Fix in order to use list of entities.
-            if (is_object($val)) {
-                $key = $val->getId();
-                $val = $val->__toString();
-            }
-            // Warning: new API since release 2.3
-            $this->addOption($val, $key);
-        }
-        return true;
-    } // end func loadArray
-
-    // }}}
-    // {{{ loadDbResult()
-
-    /**
-     * Loads the options from DB_result object
-     *
-     * If no column names are specified the first two columns of the result are
-     * used as the text and value columns respectively
-     * @param     object    $result     DB_result object
-     * @param     string    $textCol    (optional) Name of column to display as the OPTION text
-     * @param     string    $valueCol   (optional) Name of column to use as the OPTION value
-     * @param     mixed     $values     (optional) Array or comma delimited string of selected values
-     * @since     1.0
-     * @access    public
-     * @return    PEAR_Error on error or true
-     * @throws    PEAR_Error
-     */
-    function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null)
-    {
-        if (!is_object($result) || !is_a($result, 'db_result')) {
-            return PEAR::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result');
-        }
-        if (isset($values)) {
-            $this->setValue($values);
-        }
-        $fetchMode = ($textCol && $valueCol) ? DB_FETCHMODE_ASSOC : DB_FETCHMODE_ORDERED;
-        while (is_array($row = $result->fetchRow($fetchMode)) ) {
-            if ($fetchMode == DB_FETCHMODE_ASSOC) {
-                $this->addOption($row[$textCol], $row[$valueCol]);
-            } else {
-                $this->addOption($row[0], $row[1]);
-            }
-        }
-        return true;
-    } // end func loadDbResult
-
-    // }}}
-    // {{{ loadQuery()
-
-    /**
-     * Queries a database and loads the options from the results
-     *
-     * @param     mixed     $conn       Either an existing DB connection or a valid dsn
-     * @param     string    $sql        SQL query string
-     * @param     string    $textCol    (optional) Name of column to display as the OPTION text
-     * @param     string    $valueCol   (optional) Name of column to use as the OPTION value
-     * @param     mixed     $values     (optional) Array or comma delimited string of selected values
-     * @since     1.1
-     * @access    public
-     * @return    void
-     * @throws    PEAR_Error
-     */
-    function loadQuery(&$conn, $sql, $textCol=null, $valueCol=null, $values=null)
-    {
-        if (is_string($conn)) {
-            require_once('DB.php');
-            $dbConn = &DB::connect($conn, true);
-            if (DB::isError($dbConn)) {
-                return $dbConn;
-            }
-        } elseif (is_subclass_of($conn, "db_common")) {
-            $dbConn = &$conn;
-        } else {
-            return PEAR::raiseError('Argument 1 of HTML_Select::loadQuery is not a valid type');
-        }
-        $result = $dbConn->query($sql);
-        if (DB::isError($result)) {
-            return $result;
-        }
-        $this->loadDbResult($result, $textCol, $valueCol, $values);
-        $result->free();
-        if (is_string($conn)) {
-            $dbConn->disconnect();
-        }
-        return true;
-    } // end func loadQuery
-
-    // }}}
-    // {{{ load()
-
-    /**
-     * Loads options from different types of data sources
-     *
-     * This method is a simulated overloaded method.  The arguments, other than the
-     * first are optional and only mean something depending on the type of the first argument.
-     * If the first argument is an array then all arguments are passed in order to loadArray.
-     * If the first argument is a db_result then all arguments are passed in order to loadDbResult.
-     * If the first argument is a string or a DB connection then all arguments are
-     * passed in order to loadQuery.
-     * @param     mixed     $options     Options source currently supports assoc array or DB_result
-     * @param     mixed     $param1     (optional) See function detail
-     * @param     mixed     $param2     (optional) See function detail
-     * @param     mixed     $param3     (optional) See function detail
-     * @param     mixed     $param4     (optional) See function detail
-     * @since     1.1
-     * @access    public
-     * @return    PEAR_Error on error or true
-     * @throws    PEAR_Error
-     */
-    function load(&$options, $param1=null, $param2=null, $param3=null, $param4=null)
-    {
-        switch (true) {
-            case is_array($options):
-                return $this->loadArray($options, $param1);
-                break;
-            case (is_a($options, 'db_result')):
-                return $this->loadDbResult($options, $param1, $param2, $param3);
-                break;
-            // Disabled by Chamilo team, 16-MAR-2010.
-            // TODO: To be verified (why it has been disabled).
-            //case (is_string($options) && !empty($options) || is_subclass_of($options, "db_common")):
-            //    return $this->loadQuery($options, $param1, $param2, $param3, $param4);
-            //    break;
-            //
-        }
-    } // end func load
-
-    // }}}
-    // {{{ toHtml()
-
     /**
      * Returns the SELECT in HTML
      *
@@ -520,7 +442,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
      * @access    public
      * @return    string
      */
-    function toHtml()
+    public function toHtml()
     {
         if ($this->_flagFrozen) {
             return $this->getFrozenHtml();

+ 7 - 5
main/inc/lib/plugin.class.php

@@ -81,8 +81,10 @@ class Plugin
 
         if ($form = $this->get_settings_form()) {
             $result['settings_form'] = $form;
+
             foreach ($this->fields as $name => $type) {
                 $value = $this->get($name);
+
                 if (is_array($type)) {
                     $value = $type['options'];
                 }
@@ -183,13 +185,12 @@ class Plugin
 
         foreach ($this->fields as $name => $type) {
             $options = null;
-            if (is_array($type) && isset($type['type']) && $type['type'] === "select") {
+            if (is_array($type) && isset($type['type']) && $type['type'] === 'select') {
                 $options = $type['options'];
                 $type = $type['type'];
             }
 
             $value = $this->get($name);
-
             $defaults[$name] = $value;
             $type = isset($type) ? $type : 'text';
 
@@ -267,7 +268,8 @@ class Plugin
     {
         $settings = $this->get_settings();
         foreach ($settings as $setting) {
-            if ($setting['variable'] == ($this->get_name() . '_' . $name)) {
+            if ($setting['variable'] == $this->get_name() . '_' . $name) {
+
                 return $setting['selected_value'];
             }
         }
@@ -281,7 +283,7 @@ class Plugin
      */
     public function get_settings()
     {
-        if (is_null($this->settings)) {
+        if (empty($this->settings)) {
             $settings = api_get_settings_params(
                 array(
                     "subkey = ? AND category = ? AND type = ? " => array($this->get_name(), 'Plugins', 'setting')
@@ -480,7 +482,7 @@ class Plugin
                     'visibility' => 1,
                     'admin' => 0,
                     'address' => 'squaregrey.gif',
-                    'added_tool' => 'NO',
+                    'added_tool' => 0,
                     'target' => '_self',
                     'category' => 'plugin',
                     'session_id' => 0

+ 2 - 1
main/inc/lib/plugin.lib.php

@@ -421,12 +421,13 @@ class AppPlugin
                 require $plugin_file;
             }
 
-            //extra options
+            // Extra options
             $plugin_settings = api_get_settings_params(
                 array(
                     "subkey = ? AND category = ? AND type = ? " => array($plugin_name, 'Plugins','setting')
                 )
             );
+            
             $settings_filtered = array();
             foreach ($plugin_settings as $item) {
                 $settings_filtered[$item['variable']] = $item['selected_value'];

+ 6 - 5
main/inc/lib/social.lib.php

@@ -1697,7 +1697,7 @@ class SocialManager extends UserManager
             $groupId,
             $userId
         );
-        
+
         $profileEditionLink = null;
 
         if ($currentUserId === $userId) {
@@ -1815,7 +1815,7 @@ class SocialManager extends UserManager
      * @param $show_full_profile
      * @return string
      */
-    public static function listMyFriendsBlock($user_id, $link_shared, $show_full_profile)
+    public static function listMyFriendsBlock($user_id, $link_shared = '', $show_full_profile = '')
     {
         //SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
         $friends = SocialManager::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
@@ -1828,8 +1828,9 @@ class SocialManager extends UserManager
             $friendHtml.= '<div class="list-group">';
             $j = 1;
             for ($k=0; $k < $number_friends; $k++) {
-                if ($j > $number_of_images) break;
-
+                if ($j > $number_of_images) {
+                    break;
+                }
                 if (isset($friends[$k])) {
                     $friend = $friends[$k];
                     $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
@@ -1854,7 +1855,7 @@ class SocialManager extends UserManager
                         $friendHtml .=  $friend_avatar.' <span class="username">' . $name_user . '</span>';
                         $friendHtml .= '<span class="status">' . $statusIcon . '</span>';
                     } else {
-                        $link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
+                        $link_shared = empty($link_shared) ? '' : '&'.$link_shared;
                         $friendHtml .= '<a href="profile.php?' .'u=' . $friend['friend_user_id'] . $link_shared . '" class="list-group-item">';
                         $friendHtml .=  $friend_avatar.' <span class="username-all">' . $name_user . '</span>';
                     }

+ 2 - 2
main/inc/lib/usergroup.lib.php

@@ -2060,10 +2060,10 @@ class UserGroup extends Model
                 break;
         }
         if (!empty($links)) {
-            $list .= '<ul class="nav nav-pills">';
+            $list = '<ul class="nav nav-pills">';
             $list .= $links;
             $list .= '</ul>';
-            $html .= Display::panelCollapse(get_lang('SocialGroups'), $list, 'sm-groups', array(), 'groups-acordeon', 'groups-collapse');    
+            $html .= Display::panelCollapse(get_lang('SocialGroups'), $list, 'sm-groups', array(), 'groups-acordeon', 'groups-collapse');
         }
         return $html;
     }

+ 2 - 2
main/session/session_add.php

@@ -19,8 +19,8 @@ SessionManager::protectSession(null, false);
 
 api_protect_limit_for_session_admin();
 
-$formSent=0;
-$errorMsg='';
+$formSent = 0;
+$errorMsg = '';
 
 // Crop picture plugin for session images
 $htmlHeadXtra[] = '<link  href="'. api_get_path(WEB_PATH) .'web/assets/cropper/dist/cropper.min.css" rel="stylesheet">';

+ 1 - 3
main/social/group_topics.php

@@ -51,9 +51,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
 }
 // My friends
 $friend_html = SocialManager::listMyFriendsBlock(
-    $user_id,
-    $link_shared,
-    $show_full_profile
+    $user_id
 );
 $content = null;
 $social_right_content = '';

+ 6 - 6
main/social/group_view.php

@@ -119,7 +119,7 @@ $usergroup = new UserGroup();
 
 if ($group_id != 0) {
     $group_info = $usergroup->get($group_id);
-    
+
 
     $interbreadcrumb[]= array ('url' =>'#','name' => $group_info['name']);
 
@@ -236,14 +236,14 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
     }
     $members = $usergroup->get_users_by_group($group_id, true);
     $member_content = '';
-    
+
     // My friends
     $friend_html = SocialManager::listMyFriendsBlock(
         $user_id,
-        $link_shared,
-        $show_full_profile
+        '',
+        ''
     );
-    
+
     // Members
     if (count($members) > 0) {
         if ($role == GROUP_USER_PERMISSION_ADMIN) {
@@ -288,7 +288,7 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
     }
     $headers = array(get_lang('Discussions'), get_lang('Members'));
     $socialForum = Display::tabs($headers, array($content, $member_content),'tabs');
-    
+
 } else {
     // if I already sent an invitation message
     if (!in_array(

+ 1 - 0
plugin/ticket/README.md

@@ -0,0 +1 @@
+Ticket management system features for Chamilo.

+ 0 - 12
plugin/ticket/config.install.php

@@ -1,12 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-/**
- * Loading of necessary libs
- *
- * @package chamilo.plugin.ticket
- */
-
-require_once '../../main/inc/global.inc.php';
-require_once 'src/ticket.class.php';
-require_once 'src/ticket_plugin.class.php';

+ 0 - 23
plugin/ticket/config.php

@@ -17,29 +17,6 @@ define('TABLE_TICKET_TICKET', 'plugin_ticket_ticket');
 define('TABLE_TICKET_CATEGORY_REL_USER', 'plugin_ticket_category_rel_user');
 define('TABLE_TICKET_MESSAGE_ATTACHMENTS', 'plugin_ticket_message_attachments');
 
-/* Ticket status constants */
-define('NEWTCK', 'NAT'); // New ticket unassigned responsible
-define('PENDING', 'PND'); // User waiting answer
-define('UNCONFIRMED', 'XCF'); // Waiting for user response
-define('CLOSE', 'CLS'); // Close ticket
-define('REENVIADO', 'REE'); // @todo delete option. This is a location of USIL
-
-/* Ticket priority constants */
-define('NORMAL', 'NRM');
-define('HIGH', 'HGH');
-define('LOW', 'LOW');
-
-/* Ticket source constants */
-define('SRC_EMAIL', 'MAI');
-define('SRC_PHONE', 'TEL');
-define('SRC_PRESC', 'PRE');
-define('SRC_PLATFORM', 'PLA');
-
-/* Ticket category constants */
-define('CAT_DOCU', 'DOC');
-define('CAT_FORO', 'FOR');
-define('CAT_ANNU', 'ANN');
-
 require_once __DIR__ . '/../../main/inc/global.inc.php';
 
 require_once api_get_path(SYS_PLUGIN_PATH) . PLUGIN_NAME . '/src/ticket_plugin.class.php';

+ 26 - 24
plugin/ticket/database.php

@@ -27,7 +27,7 @@ if (!Database::tableExists($table)) {
     $result = Database::query($sql);
 
     $tableLog = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
-    $sql = "CREATE TABLE IF NOT EXISTS ".$tableLog." (
+    $sql = "CREATE TABLE IF NOT EXISTS $tableLog (
             id int UNSIGNED NOT NULL AUTO_INCREMENT,
             ticket_id int UNSIGNED DEFAULT NULL,
             user_id int UNSIGNED DEFAULT NULL,
@@ -76,11 +76,11 @@ if (!Database::tableExists($table)) {
 }
 
 $table = Database::get_main_table(TABLE_TICKET_MESSAGE);
-$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+$sql = "CREATE TABLE IF NOT EXISTS $table (
         id int UNSIGNED NOT NULL AUTO_INCREMENT,
         message_id int UNSIGNED NOT NULL,
         ticket_id int UNSIGNED NOT NULL,
-        subject varchar(150) DEFAULT NULL,
+        subject varchar(255) DEFAULT NULL,
         message text NOT NULL,
         status char(3) NOT NULL,
         ip_address varchar(16) DEFAULT NULL,
@@ -89,11 +89,11 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         sys_lastedit_user_id int UNSIGNED DEFAULT NULL,
         sys_lastedit_datetime datetime DEFAULT NULL,
         PRIMARY KEY (id),
-        KEY FK_tick_message (ticket_id) )";
+        KEY FK_tick_message (ticket_id))";
 Database::query($sql);
 
 $table = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
-$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+$sql = "CREATE TABLE IF NOT EXISTS $table (
         id int UNSIGNED NOT NULL AUTO_INCREMENT,
         message_attch_id char(2) NOT NULL,
         message_id char(2) NOT NULL,
@@ -113,7 +113,7 @@ Database::query($sql);
 $table = Database::get_main_table(TABLE_TICKET_PRIORITY);
 
 if (!Database::tableExists($table)) {
-    $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+    $sql = "CREATE TABLE IF NOT EXISTS $table (
             id int UNSIGNED NOT NULL AUTO_INCREMENT,
             priority_id char(3) NOT NULL,
             priority varchar(20) DEFAULT NULL,
@@ -127,12 +127,13 @@ if (!Database::tableExists($table)) {
             PRIMARY KEY (id))";
     Database::query($sql);
 
-    //Default Priorities
+    // Default Priorities
     $defaultPriorities = array(
-        'NRM' => $objPlugin->get_lang('PriorityNormal'),
-        'HGH' => $objPlugin->get_lang('PriorityHigh'),
-        'LOW' => $objPlugin->get_lang('PriorityLow')
+        TicketManager::PRIORITY_NORMAL => $objPlugin->get_lang('PriorityNormal'),
+        TicketManager::PRIORITY_HIGH => $objPlugin->get_lang('PriorityHigh'),
+        TicketManager::PRIORITY_LOW => $objPlugin->get_lang('PriorityLow')
     );
+
     $i = 1;
     foreach ($defaultPriorities as $pId => $priority) {
         $attributes = array(
@@ -148,7 +149,7 @@ if (!Database::tableExists($table)) {
 
 $table = Database::get_main_table(TABLE_TICKET_PROJECT);
 if (!Database::tableExists($table)) {
-    $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+    $sql = "CREATE TABLE IF NOT EXISTS $table (
             id int UNSIGNED NOT NULL AUTO_INCREMENT,
             project_id char(3) NOT NULL,
             name varchar(50) DEFAULT NULL,
@@ -162,7 +163,7 @@ if (!Database::tableExists($table)) {
             PRIMARY KEY (id))";
     Database::query($sql);
 
-    //Default Project Table Ticket
+    // Default Project Table Ticket
     $attributes = array(
         'id' => 1,
         'project_id' => 1,
@@ -171,10 +172,10 @@ if (!Database::tableExists($table)) {
     Database::insert($table, $attributes);
 }
 
-//STATUS
+// STATUS
 $table = Database::get_main_table(TABLE_TICKET_STATUS);
 if (!Database::tableExists($table)) {
-    $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+    $sql = "CREATE TABLE IF NOT EXISTS $table (
             id int UNSIGNED NOT NULL AUTO_INCREMENT,
             status_id char(3) NOT NULL,
             name varchar(100) NOT NULL,
@@ -182,13 +183,13 @@ if (!Database::tableExists($table)) {
             PRIMARY KEY (id))";
     Database::query($sql);
 
-    //Default status
+    // Default status
     $defaultStatus = array(
-        'NAT' => $objPlugin->get_lang('StatusNew'),
-        'PND' => $objPlugin->get_lang('StatusPending'),
-        'XCF' => $objPlugin->get_lang('StatusUnconfirmed'),
-        'CLS' => $objPlugin->get_lang('StatusClose'),
-        'REE' => $objPlugin->get_lang('StatusForwarded')
+        TicketManager::STATUS_NEW => $objPlugin->get_lang('StatusNew'),
+        TicketManager::STATUS_PENDING => $objPlugin->get_lang('StatusPending'),
+        TicketManager::STATUS_UNCONFIRMED => $objPlugin->get_lang('StatusUnconfirmed'),
+        TicketManager::STATUS_CLOSE => $objPlugin->get_lang('StatusClose'),
+        TicketManager::STATUS_FORWARDED => $objPlugin->get_lang('StatusForwarded')
     );
 
     $i = 1;
@@ -204,19 +205,20 @@ if (!Database::tableExists($table)) {
 }
 
 $table = Database::get_main_table(TABLE_TICKET_TICKET);
-$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+$sql = "CREATE TABLE IF NOT EXISTS $table (
         ticket_id int UNSIGNED NOT NULL AUTO_INCREMENT,
         ticket_code char(12) DEFAULT NULL,
         project_id char(3) DEFAULT NULL,
         category_id char(3) NOT NULL,
         priority_id char(3) NOT NULL,
         course_id int UNSIGNED NOT NULL,
-        session_id int UNSIGNED NOT NULL DEFAULT '0',
-        request_user int UNSIGNED NOT NULL,
+        session_id int UNSIGNED NOT NULL DEFAULT '0',        
         personal_email varchar(150) DEFAULT NULL,
         assigned_last_user int UNSIGNED NOT NULL DEFAULT '0',
         status_id char(3) NOT NULL,
         total_messages int UNSIGNED NOT NULL DEFAULT '0',
+        subject varchar(255) DEFAULT NULL,
+        message text NOT NULL,
         keyword varchar(250) DEFAULT NULL,
         source char(3) NOT NULL,
         start_date datetime NOT NULL,
@@ -232,7 +234,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
 Database::query($sql);
 
 $table = Database::get_main_table(TABLE_TICKET_CATEGORY_REL_USER);
-$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+$sql = "CREATE TABLE IF NOT EXISTS $table (
         id int UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
         category_id INT NOT NULL,
         user_id INT NOT NULL

+ 5 - 3
plugin/ticket/lang/english.php

@@ -46,6 +46,7 @@ $strings['Priority'] = "Priority";
 $strings['PriorityHigh'] = "High";
 $strings['PriorityNormal'] = "Normal";
 $strings['PriorityLow'] = "Low";
+$strings['SrcPlatform'] = "Platforme";
 $strings['SrcEmail'] = "E-mail";
 $strings['SrcPhone'] = "Phone";
 $strings['SrcPresential'] = "In-person";
@@ -87,14 +88,15 @@ $strings['RequestConfirmation'] = "Request confirmation";
 $strings['TicketUpdated'] = "Ticket updated";
 $strings['TicketClosed'] = "Ticket closed";
 
-$strings['TicketXCreated'] = "Ticket <b>%s</b>created";
+$strings['TicketXCreated'] = "Ticket <b>%s</b> created";
 $strings['allow_category_edition'] = "Allow category edition";
 $strings['warn_admin_no_user_in_category'] = "Warn admin if category doesn't have users related";
 $strings['send_warning_to_all_admins'] = "Send warning to all admins, if category doesn't have users related";
 $strings['WarningCategoryXDoesntHaveUsers'] = "Warning: The category '%s' doesn't have users assigned";
 $strings['TicketInformation'] = 'Ticket information';
-$strings['CategoryWithNoUserNotificationSentToAdmins'] = 'Category <b>%s</b> with no user sent to all administrators.';
+$strings['CategoryWithNoUserNotificationSentToAdmins'] = 'Category <b>%s</b> has users, Ticket sent to all administrators.';
 $strings['TicketXAssignedToUserX'] = 'Ticket <b>#%s</b> assigned to user <b>%s</b>';
 $strings['TicketXCreatedWithNoCategory'] = 'Ticket <b>#%s</b> created with no category';
 
-
+$strings['UpdatedByX'] = 'Updated by %s';
+$strings['AssignedChangeFromXToY'] = 'Assignee changed from %s to %s';

+ 2 - 0
plugin/ticket/lang/french.php

@@ -85,3 +85,5 @@ $strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Veuillez sélectionner u
 $strings['RequestConfirmation'] = "Demander confirmation";
 $strings['TicketUpdated'] = "Ticket modifié";
 $strings['TicketClosed'] = "Ticket fermé";
+$strings['SrcPlatform'] = "Platforme";
+$strings['UpdatedByX'] = 'Updated by %s';

+ 2 - 0
plugin/ticket/lang/spanish.php

@@ -89,3 +89,5 @@ $strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Por favor, antes de regi
 $strings['RequestConfirmation'] = "Solicitar confirmación";
 $strings['TicketUpdated'] = "Ticket actualizado";
 $strings['TicketClosed'] = "Ticket cerrado";
+$strings['SrcPlatform'] = "Plataforma";
+$strings['UpdatedByX'] = 'Actualizado por %s';

+ 0 - 1
plugin/ticket/readme.txt

@@ -1 +0,0 @@
-This plugin provides the support ticket management system features

+ 1 - 1
plugin/ticket/src/assign_tickets.php

@@ -6,7 +6,7 @@
  * @package chamilo.plugin.ticket
  */
 
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 api_protect_course_script();

+ 5 - 2
plugin/ticket/src/categories.php

@@ -9,7 +9,7 @@
 $cidReset = true;
 // needed in order to load the plugin lang variables
 $course_plugin = 'ticket';
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 
 $plugin = TicketPlugin::create();
 
@@ -63,7 +63,10 @@ if (isset($_GET['action'])) {
                     'description' => $values['description'],
                     'total_tickets' => 0,
                     'sys_insert_user_id' => api_get_user_id(),
-                    'sys_insert_datetime' => api_get_utc_datetime()
+                    'sys_insert_datetime' => api_get_utc_datetime(),
+                    'category_id' => 0,
+                    'project_id' => 0,
+                    'course_required' => ''
                 ];
                 TicketManager::addCategory($params);
 

+ 1 - 1
plugin/ticket/src/categories_add_user.php

@@ -6,7 +6,7 @@
  * @package chamilo.plugin.ticket
  */
 $cidReset = true;
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 api_protect_admin_script(true);

+ 1 - 1
plugin/ticket/src/course_user_list.php

@@ -5,7 +5,7 @@
  * @package chamilo.plugin.ticket
  */
 
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 $userId = intval($_GET['user_id']);

+ 1 - 1
plugin/ticket/src/download.php

@@ -5,7 +5,7 @@
  * @package chamilo.plugin.ticket
  */
 
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 api_block_anonymous_users();

+ 2 - 2
plugin/ticket/src/index.php

@@ -6,6 +6,6 @@
  * @package chamilo.plugin.ticket
  */
 
-require_once '../config.php';
-header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php?message=success');
+require_once __DIR__.'/../config.php';
+header('Location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php');
 exit;

+ 120 - 256
plugin/ticket/src/myticket.php

@@ -9,17 +9,17 @@
 $cidReset = true;
 // needed in order to load the plugin lang variables
 $course_plugin = 'ticket';
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 
-$plugin = TicketPlugin::create();
+api_block_anonymous_users();
 
+$plugin = TicketPlugin::create();
 $tool_name = $plugin->get_lang('LastEdit');
-api_block_anonymous_users();
 
 $libPath = api_get_path(LIBRARY_PATH);
 $webLibPath = api_get_path(WEB_LIBRARY_PATH);
-$htmlHeadXtra[] = '<script type="text/javascript">
-function load_history_ticket (div_course,ticket_id) {
+$htmlHeadXtra[] = '<script>
+function load_history_ticket(div_course, ticket_id) {
     $.ajax({
         contentType: "application/x-www-form-urlencoded",
         beforeSend: function(object) {
@@ -34,21 +34,16 @@ function load_history_ticket (div_course,ticket_id) {
         }
     });
 }
-function clear_course_list (div_course) {
+function clear_course_list(div_course) {
     $("div#"+div_course).html("&nbsp;");
     $("div#"+div_course).hide("");
 }
 
-$(function() {
-    $( "#keyword_start_date_start" ).datepicker({ dateFormat: ' . "'dd/mm/yy'" . ' });
-    $( "#keyword_start_date_end" ).datepicker({ dateFormat: ' . "'dd/mm/yy'" . ' });
-});
-
 $(document).ready(function() {
     $("#advanced_search_form").css("display","none");
 });
 
-function display_advanced_search_form () {
+function display_advanced_search_form() {
     if ($("#advanced_search_form").css("display") == "none") {
         $("#advanced_search_form").css("display","block");
         $("#img_plus_and_minus").html(\'&nbsp;' . Display::return_icon('div_hide.gif', get_lang('Hide'), array('style' => 'vertical-align:middle')) . '&nbsp;' . get_lang('AdvancedSearch') . '\');
@@ -57,70 +52,7 @@ function display_advanced_search_form () {
         $("#img_plus_and_minus").html(\'&nbsp;' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . '&nbsp;' . get_lang('AdvancedSearch') . '\');
     }
 }
-</script>
-<style>
-.label2 {
-    float: left;
-    text-align: left;
-    width: 75px;
-}
-
-.label3 {
-    margin-left: 20px;
-    float: left;
-    text-align: left;
-    margin-top: 10px;
-    width: 95px;
-}
-
-.label4 {
-    float: left;
-    text-align: left;
-    margin-top: 10px;
-    width: 75px;
-}
-
-.formw2 {
-    float: left;
-    margin-left: 4px;
-    margin-top: 5px;
-}
-
-.blackboard_show {
-    float: left;
-    position: absolute;
-    border: 1px solid black;
-    width: 350px;
-    background-color: white;
-    z-index: 99;
-    padding: 3px;
-    display: inline;
-}
-
-.blackboard_hide {
-    display: none;
-}
-
-.advanced-parameters {
-    margin-top: 5px;
-}
-
-.remove-margin-top {
-    margin-top: 0px;
-}
-
-.select-margin-top {
-    margin-top: -5px;
-}
-
-.input-width {
-    width: 170px;
-}
-
-.fleft {
-    float: left;
-}
-</style>';
+</script>';
 
 $this_section = 'tickets';
 unset($_SESSION['this_section']);
@@ -138,68 +70,69 @@ if ($table->per_page == 0) {
     $table->per_page = 20;
 }
 
-if (isset($_GET['action'])) {
-    global $table;
-    $action = $_GET['action'];
-    switch ($action) {
-        case 'assign':
-            if ($isAdmin && isset($_GET['ticket_id']))
-                TicketManager::assign_ticket_user($_GET['ticket_id'], $user_id);
-            break;
-        case 'unassign':
-            if ($isAdmin && isset($_GET['ticket_id']))
-                TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
-            break;
-        case 'alert':
-            if (!$isAdmin && isset($_GET['ticket_id']))
-                TicketManager::send_alert($_GET['ticket_id'], $user_id);
-            break;
-        case 'export':
-            $data = array(
-                array(
-                    $plugin->get_lang('TicketNum'),
-                    $plugin->get_lang('Date'),
-                    $plugin->get_lang('DateLastEdition'),
-                    $plugin->get_lang('Category'),
-                    $plugin->get_lang('User'),
-                    $plugin->get_lang('Program'),
-                    $plugin->get_lang('Responsible'),
-                    $plugin->get_lang('Status'),
-                    $plugin->get_lang('Description')
-                )
+$action = isset($_GET['action']) ? $_GET['action'] : '';
+
+switch ($action) {
+    case 'assign':
+        if ($isAdmin && isset($_GET['ticket_id'])) {
+            TicketManager::assign_ticket_user($_GET['ticket_id'], $user_id);
+        }
+        break;
+    case 'unassign':
+        if ($isAdmin && isset($_GET['ticket_id'])) {
+            TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
+        }
+        break;
+    case 'alert':
+        if (!$isAdmin && isset($_GET['ticket_id'])) {
+            TicketManager::send_alert($_GET['ticket_id'], $user_id);
+        }
+        break;
+    case 'export':
+        $data = array(
+            array(
+                $plugin->get_lang('TicketNum'),
+                $plugin->get_lang('Date'),
+                $plugin->get_lang('DateLastEdition'),
+                $plugin->get_lang('Category'),
+                $plugin->get_lang('User'),
+                $plugin->get_lang('Program'),
+                $plugin->get_lang('Responsible'),
+                $plugin->get_lang('Status'),
+                $plugin->get_lang('Description')
+            )
+        );
+        $datos = $table->get_clean_html();
+        foreach ($datos as $ticket) {
+            $ticket[0] = substr(strip_tags($ticket[0]), 0, 12);
+            $ticket_rem = array(
+                utf8_decode(strip_tags($ticket[0])),
+                utf8_decode(api_html_entity_decode($ticket[1])),
+                utf8_decode(strip_tags($ticket[2])),
+                utf8_decode(strip_tags($ticket[3])),
+                utf8_decode(strip_tags($ticket[4])),
+                utf8_decode(strip_tags($ticket[5])),
+                utf8_decode(strip_tags($ticket[6])),
+                utf8_decode(strip_tags($ticket[7])),
+                utf8_decode(strip_tags(str_replace('&nbsp;', ' ', $ticket[9])))
             );
-            $datos = $table->get_clean_html();
-            foreach ($datos as $ticket) {
-                $ticket[0] = substr(strip_tags($ticket[0]), 0, 12);
-                $ticket_rem = array(
-                    utf8_decode(strip_tags($ticket[0])),
-                    utf8_decode(api_html_entity_decode($ticket[1])),
-                    utf8_decode(strip_tags($ticket[2])),
-                    utf8_decode(strip_tags($ticket[3])),
-                    utf8_decode(strip_tags($ticket[4])),
-                    utf8_decode(strip_tags($ticket[5])),
-                    utf8_decode(strip_tags($ticket[6])),
-                    utf8_decode(strip_tags($ticket[7])),
-                    utf8_decode(strip_tags(str_replace('&nbsp;', ' ', $ticket[9])))
-                );
-                $data[] = $ticket_rem;
-            }
-            Export::arrayToXls($data, $plugin->get_lang('Tickets'));
-            exit;
-            break;
-        case 'close_tickets':
-            TicketManager::close_old_tickets();
-            break;
-        default:
-            break;
-    }
+            $data[] = $ticket_rem;
+        }
+        Export::arrayToXls($data, $plugin->get_lang('Tickets'));
+        exit;
+        break;
+    case 'close_tickets':
+        TicketManager::close_old_tickets();
+        break;
+    default:
+        break;
 }
 
-// $nameTools = api_xml_http_response_encode($plugin->get_lang('MyTickets'));
 $user_id = api_get_user_id();
 $isAdmin = api_is_platform_admin();
 
 Display::display_header($plugin->get_lang('MyTickets'));
+
 if ($isAdmin) {
     $getParameters = [
         'keyword',
@@ -236,50 +169,43 @@ if ($isAdmin) {
     if (isset($_GET['submit_simple'])) {
         $get_parameter .= "&submit_simple=";
     }
-    //select categories
-    $select_types = '<select class="chzn-select" name = "keyword_category" id="keyword_category" ">';
-    $select_types .= '<option value="">---' . get_lang('Select') . '---</option>';
+
+    // Select categories
+    $selectTypes = [];
     $types = TicketManager::get_all_tickets_categories();
     foreach ($types as $type) {
-        $select_types.= "<option value = '" . $type['category_id'] . "'>" . $type['name'] . "</option>";
+        $selectTypes[$type['category_id']] = $type['name'];
     }
-    $select_types .= "</select>";
-    //select admins
-    $select_admins = '<select  class ="chzn-select" name = "keyword_admin" id="keyword_admin" ">';
-    $select_admins .= '<option value="">---' . get_lang('Select') . '---</option>';
-    $select_admins .= '<option value = "0">' . $plugin->get_lang('Unassigned') . '</option>';
+
     $admins = UserManager::get_user_list_like(array("status" => "1"), array("username"), true);
+    $selectAdmins = [
+        0 => $plugin->get_lang('Unassigned')
+    ];
     foreach ($admins as $admin) {
-        $select_admins.= "<option value = '" . $admin['user_id'] . "'>" . $admin['lastname'] . " ," . $admin['firstname'] . "</option>";
+        $selectAdmins[$admin['user_id']] = $admin['complete_name'];
     }
-    $select_admins .= "</select>";
-    //select status
-    $select_status = '<select  class ="chzn-select" name = "keyword_status" id="keyword_status" >';
-    $select_status .= '<option value="">---' . get_lang('Select') . '---</option>';
     $status = TicketManager::get_all_tickets_status();
+    $selectStatus = [];
     foreach ($status as $stat) {
-        $select_status.= "<option value = '" . $stat['status_id'] . "'>" . $stat['name'] . "</option>";
+        $selectStatus[$stat['status_id']] = $stat['name'];
     }
-    $select_status .= "</select>";
-    //select priority
-    $select_priority = '<select  name = "keyword_priority" id="keyword_priority" >';
-    $select_priority .= '<option value="">' . get_lang('All') . '</option>';
-    $select_priority .= '<option value="NRM">' . $plugin->get_lang('PriorityNormal') . '</option>';
-    $select_priority .= '<option value="HGH">' . $plugin->get_lang('PriorityHigh') . '</option>';
-    $select_priority .= '<option value="LOW">' . $plugin->get_lang('PriorityLow') . '</option>';
-    $select_priority .= "</select>";
 
-    //select unread
-    $select_unread = '<select  name = "keyword_unread" id="keyword_unread" >';
-    $select_unread .= '<option value="">' . get_lang('All') . '</option>';
-    $select_unread .= '<option value="yes">' . $plugin->get_lang('Unread') . '</option>';
-    $select_unread .= '<option value="no">' . $plugin->get_lang('Read')  . '</option>';
-    $select_unread .= "</select>";
+    $selectPriority = [
+        '' => get_lang('All'),
+        TicketManager::PRIORITY_NORMAL => $plugin->get_lang('PriorityNormal'),
+        TicketManager::PRIORITY_HIGH => $plugin->get_lang('PriorityHigh'),
+        TicketManager::PRIORITY_LOW => $plugin->get_lang('PriorityLow')
+    ];
+
+    $selectStatusUnread = [
+        '' => get_lang('All'),
+        'yes' => $plugin->get_lang('Unread'),
+        'no' => $plugin->get_lang('Read')
+    ];
+
     // Create a search-box
-    $form = new FormValidator('search_simple', 'get', '', '', null, false);
-    $renderer = & $form->defaultRenderer();
-    $renderer->setCustomElementTemplate('<span>{element}</span> ');
-    $form->addElement('text', 'keyword', get_lang('Keyword'), 'size="25"');
+    $form = new FormValidator('search_simple', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
+    $form->addText('keyword', get_lang('Keyword'), 'size="25"');
     $form->addButtonSearch(get_lang('Search'), 'submit_simple');
     $form->addElement('static', 'search_advanced_link', null,
             '<a href="javascript://" class = "advanced-parameters" onclick="display_advanced_search_form();">'
@@ -291,11 +217,9 @@ if ($isAdmin) {
     if (api_is_platform_admin()) {
         echo '<span class="left">' .
                 '<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .
-                    Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') . '</a>' .
+                    Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', ICON_SIZE_MEDIUM) . '</a>' .
                 '<a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' .
-                    Display::return_icon('export_excel.png', get_lang('Export'), '', '32') . '</a>';
-
-
+                    Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_MEDIUM) . '</a>';
         if ($plugin->get('allow_category_edition')) {
             echo Display::url(
                 Display::return_icon('folder_document.gif'),
@@ -303,92 +227,36 @@ if ($isAdmin) {
             );
         }
 
+        echo Display::url(
+            Display::return_icon('settings.png'),
+            api_get_path(WEB_CODE_PATH) . 'admin/configure_plugin.php?name=ticket'
+        );
+
         echo '</span>';
 
     }
     $form->display();
     echo '</div>';
-    echo '<form action="' . api_get_self() . '" method="get" name="advanced_search" id="advanced_search" display:"none">
-            <div id="advanced_search_form" style="display: block;">
-            <div>
-               <div class="form_header">' . get_lang('AdvancedSearch') . '</div>
-            </div>
-            <table >
-               <tbody>
-                  <tr>
-                     <td>
-                        <div>
-                           <div class="label2">' . get_lang('Category') . ': </div>
-                           <div class="formw2" style="margin-top: -5px;">' . $select_types . '</div>
-                        </div>
-                     </td>
-                     <td>
-                        <div>
-                           <div class="label3">' . get_lang('User') . ': </div>
-                           <div class="formw2"><input class="input-width" id="keyword_request_user" name="keyword_request_user" type="text"></div>
-                        </div>
-                     </td>
-                     <td>
-                        <div>
-                           <div class="label3">' . $plugin->get_lang('RegisterDate') . ': </div>
-                           <div class="formw2"><input class="input-width" id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div>
-                        </div>
-                     </td>
-                     <td>
-                        <div>
-                           <div class="label3"><input type="checkbox" name="keyword_dates" value="1">' . $plugin->get_lang('Untill') . '</div>
-                           <div class="formw2"><input class="input-width" id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div>
-                        </div>
-                     </td>
-                  </tr>
-                  <tr >
-                     <td>
-                        <div>
-                           <div class="label2">' . $plugin->get_lang('AssignedTo') . ': </div>
-                           <div class="formw2 select-margin-top">' . $select_admins . '</div>
-                        </div>
-                     </td>
-                     <td>
-                        <div>
-                           <div class="label3 remove-margin-top">' . get_lang('Status') . ':</div>
-                           <div class="formw2 select-margin-top">' . $select_status . '</div>
-                        </div>
-                     </td>
-                     <td>
-                        <div>
-                        <div>
-                           <div class="label3">' . $plugin->get_lang('Priority') . ': </div>
-                           <div class="formw2">' . $select_priority . '</div>
-                        </div>
-                     </td>
-                     <td>
-                        <div>
-                           <div>
-                              <div class="label3">' . get_lang('Status') . ': </div>
-                              <div class="formw2">' . $select_unread . '</div>
-                           </div>
-                     </td>
-                  </tr>
-                  <tr>
-                  <td>
-                  <div >
-                  <div class="label4">' . get_lang('Course') . ': </div>
-                  <div class="formw2">
-                  <input id="keyword_course" style="width: 170px;" name="keyword_course" type="text"></div>
-                  </div>
-                  </td>
-                  <td colspan= "3">
-                  <div>
-                  <button  name="submit_advanced" type="submit">' . get_lang('AdvancedSearch') . '</button>
-                  </div>
-                  </td>
-                  </tr>
-               </tbody>
-            </table>
-            </div>
-            <input name="_qf__advanced_search" type="hidden" value="">
-            <div class="clear">&nbsp;</div>
-         </form>';
+
+    $advancedSearchForm = new FormValidator(
+        'advanced_search',
+        'get',
+        api_get_self(),
+        null,
+        ['style' => 'display:"none"', 'id' => 'advanced_search_form']
+    );
+    $advancedSearchForm->addHeader(get_lang('AdvancedSearch'));
+    $advancedSearchForm->addSelect('keyword_category', get_lang('Category'), $selectTypes, ['placeholder' => get_lang('Select')]);
+    //$advancedSearchForm->addText('keyword_request_user', get_lang('User'), false);
+    $advancedSearchForm->addDateTimePicker('keyword_start_date_start', $plugin->get_lang('RegisterDate'));
+    $advancedSearchForm->addDateTimePicker('keyword_start_date_end', $plugin->get_lang('Untill'));
+    $advancedSearchForm->addSelect('keyword_admin', $plugin->get_lang('AssignedTo') , $selectAdmins, ['placeholder' => get_lang('All')]);
+    $advancedSearchForm->addSelect('keyword_status', get_lang('Status'), $selectStatus, ['placeholder' => get_lang('Select')]);
+    $advancedSearchForm->addSelect('keyword_priority', $plugin->get_lang('Priority'), $selectPriority, ['placeholder' => get_lang('All')]);
+    $advancedSearchForm->addSelect('keyword_unread', get_lang('Status'), $selectStatusUnread, ['placeholder' => get_lang('All')]);
+    $advancedSearchForm->addText('keyword_course', get_lang('Course'), false);
+    $advancedSearchForm->addButtonSearch(get_lang('AdvancedSearch'), 'submit_advanced');
+    $advancedSearchForm->display();
 } else {
     if ($plugin->get('allow_student_add') == 'true') {
         echo '<div class="actions" >';
@@ -397,8 +265,6 @@ if ($isAdmin) {
                     Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') .
                 '</a>' .
               '</span>';
-        echo '<span style="float:right;">' .
-        '</span>';
         echo '</div>';
     }
 }
@@ -408,11 +274,10 @@ if ($isAdmin) {
     $table->set_header(1, $plugin->get_lang('Date'), true);
     $table->set_header(2, $plugin->get_lang('DateLastEdition'), true);
     $table->set_header(3, $plugin->get_lang('Category'), true);
-    $table->set_header(4, $plugin->get_lang('User'), true);
-    $table->set_header(5, $plugin->get_lang('Responsible'), true);
+    $table->set_header(4, $plugin->get_lang('CreatedBy'), true);
+    $table->set_header(5, $plugin->get_lang('AssignedTo'), true);
     $table->set_header(6, $plugin->get_lang('Status'), true);
     $table->set_header(7, $plugin->get_lang('Message'), true);
-    $table->set_header(8, get_lang('Actions'), true);
 } else {
     echo '<center><h1>' . $plugin->get_lang('MyTickets') . '</h1></center>';
     echo '<center><p>' . $plugin->get_lang('MsgWelcome') . '</p></center>';
@@ -424,8 +289,7 @@ if ($isAdmin) {
     $table->set_header(2, $plugin->get_lang('DateLastEdition'), true);
     $table->set_header(3, $plugin->get_lang('Category'));
     $table->set_header(4, $plugin->get_lang('Status'), false);
-    $table->set_header(5, get_lang('Actions'), false);
-}       
+}
 
 $table->display();
 Display::display_footer();

+ 26 - 31
plugin/ticket/src/new_ticket.php

@@ -6,7 +6,7 @@
  */
 
 $cidReset = true;
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 if (!api_is_platform_admin() &&
@@ -151,7 +151,7 @@ div.divTicket {
     padding-top: 100px;
 }
 </style>';
-$types = TicketManager::get_all_tickets_categories();
+$types = TicketManager::get_all_tickets_categories('category.name ASC');
 $htmlHeadXtra[] = '<script language="javascript">
     var projects = ' . js_array($types, 'projects', 'project_id') . '
     var course_required = ' . js_array($types, 'course_required', 'course_required') . '
@@ -195,7 +195,7 @@ function show_form_send_ticket()
     // Category List
     $categoryList = array();
     foreach ($types as $type) {
-        $categoryList[$type['category_id']] = $type['name'] . ": " . $type['description'];
+        $categoryList[$type['category_id']] = $type['name'].': '.$type['description'];
     }
 
     // Status List
@@ -205,52 +205,51 @@ function show_form_send_ticket()
         'id' => 'status_id',
         'for' => 'status_id'
     );
-    $statusList[NEWTCK] = $plugin->get_lang('StatusNew');
+
+    $statusList[TicketManager::STATUS_NEW] = $plugin->get_lang('StatusNew');
     if (api_is_platform_admin()) {
         $statusAttributes = array(
             'id' => 'status_id',
             'for' => 'status_id',
             'style' => 'width: 562px;'
         );
-        $statusList[PENDING] = $plugin->get_lang('StatusPending');
-        $statusList[UNCONFIRMED] = $plugin->get_lang('StatusUnconfirmed');
-        $statusList[CLOSE] = $plugin->get_lang('StatusClose');
-        $statusList[REENVIADO] = $plugin->get_lang('StatusForwarded');
+        $statusList[TicketManager::STATUS_PENDING] = $plugin->get_lang('StatusPending');
+        $statusList[TicketManager::STATUS_UNCONFIRMED] = $plugin->get_lang('StatusUnconfirmed');
+        $statusList[TicketManager::STATUS_CLOSE] = $plugin->get_lang('StatusClose');
+        $statusList[TicketManager::STATUS_FORWARDED] = $plugin->get_lang('StatusForwarded');
     }
     //End Status List
 
-    //Source List
+    // Source List
     $sourceList = array();
     $sourceAttributes = array(
         'style' => 'display: none;',
         'id' => 'source_id',
         'for' => 'source_id'
     );
-    $sourceList[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform');
+    $sourceList[TicketManager::SOURCE_PLATFORM] = $plugin->get_lang('SrcPlatform');
     if (api_is_platform_admin()) {
         $sourceAttributes = array(
             'id' => 'source_id',
             'for' => 'source_id',
             'style' => 'width: 562px;'
         );
-        $sourceList[SRC_EMAIL] = $plugin->get_lang('SrcEmail');
-        $sourceList[SRC_PHONE] = $plugin->get_lang('SrcPhone');
-        $sourceList[SRC_PRESC] = $plugin->get_lang('SrcPresential');
+        $sourceList[TicketManager::SOURCE_EMAIL] = $plugin->get_lang('SrcEmail');
+        $sourceList[TicketManager::SOURCE_PHONE] = $plugin->get_lang('SrcPhone');
+        $sourceList[TicketManager::SOURCE_PRESENTIAL] = $plugin->get_lang('SrcPresential');
     }
-    //End Source List
 
-    //Priority List
+    // Priority List
     $priorityList = array();
-    $priorityList[NORMAL] = $plugin->get_lang('PriorityNormal');
-    $priorityList[HIGH] = $plugin->get_lang('PriorityHigh');
-    $priorityList[LOW] = $plugin->get_lang('PriorityLow');
-    //End Priority List
+    $priorityList[TicketManager::PRIORITY_NORMAL] = $plugin->get_lang('PriorityNormal');
+    $priorityList[TicketManager::PRIORITY_HIGH] = $plugin->get_lang('PriorityHigh');
+    $priorityList[TicketManager::PRIORITY_LOW] = $plugin->get_lang('PriorityLow');
 
     $form = new FormValidator(
         'send_ticket',
         'POST',
         api_get_self(),
-        "",
+        '',
         array(
             'enctype' => 'multipart/form-data',
             'onsubmit' => 'return validate()'
@@ -336,8 +335,6 @@ function show_form_send_ticket()
         );
     //}
 
-
-
     $form->addElement(
         'text',
         'personal_email',
@@ -347,7 +344,6 @@ function show_form_send_ticket()
         )
     );
 
-
     $form->addLabel('',
         Display::div(
             '',
@@ -393,7 +389,6 @@ function show_form_send_ticket()
         )
     );
 
-
     $form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
     $form->addLabel('', '<span id="filepaths"><div id="filepath_1"></div></span>');
 
@@ -429,7 +424,7 @@ function save_ticket()
     global $plugin;
     $category_id = $_POST['category_id'];
     $content = $_POST['content'];
-    if ($_POST['phone'] != "") {
+    if ($_POST['phone'] != '') {
         $content .= '<p style="color:red">&nbsp;' . get_lang('Phone') . ': ' . Security::remove_XSS($_POST['phone']). '</p>';
     }
     $course_id = isset($_POST['course_id']) ? $_POST['course_id'] : 0;
@@ -443,7 +438,6 @@ function save_ticket()
     $priority = $_POST['priority_id'];
     $status = $_POST['status_id'];
     $file_attachments = $_FILES;
-    $responsible = (api_is_platform_admin() ? api_get_user_id() : 0);
 
     if (TicketManager::insert_new_ticket(
         $category_id,
@@ -458,11 +452,12 @@ function save_ticket()
         $source,
         $priority,
         $status,
-        $user_id,
-        $responsible
-    )
-    ) {
-        header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php?message=success');
+        $user_id
+    )) {
+        Display::addFlash(
+            Display::return_message($plugin->get_lang('TckSuccessSave'), 'success')
+        );
+        header('Location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php');
         exit;
     } else {
         Display::display_header(get_lang('ComposeMessage'));

+ 1 - 2
plugin/ticket/src/report.php

@@ -5,9 +5,8 @@
  * @package chamilo.plugin.ticket
  */
 
-$language_file = array('trad4all');
 $cidReset = true;
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 api_block_anonymous_users();

+ 0 - 15
plugin/ticket/src/test.html

@@ -1,15 +0,0 @@
-<div class="actions">
-  <span style="float: right;">
-    <a href="/main/admin/user_add.php"><img title="Añadir usuarios" alt="Añadir usuarios" src="/main/img/icons/32/new_user.png"></a>
-  </span>
-  <form id="search_simple" name="search_simple" method="get" action="/main/admin/user_list.php" class="form-search">
-    <fieldset>
-    <span><input type="text" name="keyword" size="25"></span>
-    <span><button type="submit" name="submit" class="btn btn">Buscar</button></span>
-    <span><a onclick="display_advanced_search_form();" class="advanced_parameters" href="javascript://">
-      <span id="img_plus_and_minus">&nbsp;<img title="Mostrar" alt="Mostrar" src="/main/img/div_show.gif" style="vertical-align: middle">&nbsp;Advanced search</span></a>
-    </span>
-    <div class="clear"></div>
-    </fieldset>
-  </form>
-</div>

File diff suppressed because it is too large
+ 367 - 381
plugin/ticket/src/ticket.class.php


+ 1 - 1
plugin/ticket/src/ticket_assign_log.php

@@ -5,7 +5,7 @@
  * @package chamilo.plugin.ticket
  */
 
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 
 $plugin = TicketPlugin::create();
 

+ 185 - 89
plugin/ticket/src/ticket_details.php

@@ -6,7 +6,7 @@
  * @package chamilo.plugin.ticket
  */
 $cidReset = true;
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 api_block_anonymous_users();
@@ -16,15 +16,14 @@ $isAdmin = api_is_platform_admin();
 $interbreadcrumb[] = array('url' => 'myticket.php', 'name' => $plugin->get_lang('MyTickets'));
 $interbreadcrumb[] = array('url' => '#', 'name' => $plugin->get_lang('TicketDetail'));
 
-$disableReponseButtons = "";
-if ($isAdmin) {
+$disableReponseButtons = '';
+/*if ($isAdmin) {
     $disableReponseButtons = "$('#responseyes').attr('disabled', 'disabled');
                               $('#responseno').attr('disabled', 'disabled');";
-}
+}*/
 
-$htmlHeadXtra[] = '
-<script language="javascript">
-$(document).ready(function(){
+$htmlHeadXtra[] = '<script>
+$(document).ready(function() {
 	$("#dialog-form").dialog({
 		autoOpen: false,
 		height: 450,
@@ -44,7 +43,7 @@ $(document).ready(function(){
             $( "#dialog-form" ).dialog( "open" );
         });
 
-        $("input#responseyes").click(function () {
+        $(".responseyes").click(function () {
             if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('Yes')) . '. ' . $plugin->get_lang('IfYouAreSureTheTicketWillBeClosed') . '")){
                 return false;
             }
@@ -67,8 +66,7 @@ $(document).ready(function(){
                 return false;
             }
         });
-
-    ' . $disableReponseButtons . '
+        '.$disableReponseButtons.'
 });
 
 function validate() {
@@ -133,8 +131,7 @@ function add_image_form() {
 }
 </script>';
 
-$htmlHeadXtra[] = '
-<style>
+$htmlHeadXtra[] = '<style>
 div.row div.label2 {
 	float:left;
 	text-align: right;
@@ -195,13 +192,13 @@ if (!isset($_GET['ticket_id'])) {
 if (isset($_POST['response'])) {
     if ($user_id == $ticket['ticket']['request_user']) {
         $response = ($_POST['response'] == "1") ? true : ($_POST['response'] == "0" ? false : null);
-        if ($response && $ticket['ticket']['status_id'] == 'XCF') {
+        if ($response && $ticket['ticket']['status_id'] == TicketManager::STATUS_UNCONFIRMED) {
             TicketManager::close_ticket($_GET['ticket_id'], $user_id);
-            $ticket['ticket']['status_id'] = 'CLS';
+            $ticket['ticket']['status_id'] = TicketManager::STATUS_CLOSE;
             $ticket['ticket']['status'] = $plugin->get_lang('Closed');
-        } else if (!is_null($response) && $ticket['ticket']['status_id'] == 'XCF') {
-            TicketManager::update_ticket_status('PND', $_GET['ticket_id'], $user_id);
-            $ticket['ticket']['status_id'] = 'PND';
+        } else if (!is_null($response) && $ticket['ticket']['status_id'] == TicketManager::STATUS_UNCONFIRMED) {
+            TicketManager::update_ticket_status(TicketManager::STATUS_PENDING, $_GET['ticket_id'], $user_id);
+            $ticket['ticket']['status_id'] = TicketManager::STATUS_PENDING;
             $ticket['ticket']['status'] = $plugin->get_lang('StatusPending');
         }
     }
@@ -210,42 +207,46 @@ if (isset($_REQUEST['action'])) {
     $action = $_REQUEST['action'];
     switch ($action) {
         case 'assign':
-            if (api_is_platform_admin() && isset($_GET['ticket_id']))
+            if (api_is_platform_admin() && isset($_GET['ticket_id'])) {
                 TicketManager::assign_ticket_user($_GET['ticket_id'], $_POST['admins']);
-            $ticket['ticket']['assigned_last_user'] = $_POST['admins'];
+            }
+            Display::addFlash(Display::return_message(get_lang('Updated')));
+            header("Location:" . api_get_self() . "?ticket_id=" . $ticket_id);
+            exit;
             break;
         case 'unassign':
-            if (api_is_platform_admin() && isset($_GET['ticket_id']))
+            if (api_is_platform_admin() && isset($_GET['ticket_id'])) {
                 TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
-            $ticket['ticket']['assigned_last_user'] = 0;
+            }
+            Display::addFlash(Display::return_message(get_lang('Updated')));
+            header("Location:" . api_get_self() . "?ticket_id=" . $ticket_id);
+            exit;
             break;
         default:
             break;
     }
 }
 
-$titulo = 'Ticket #' . $ticket['ticket']['ticket_code'];
-$firstMessage = is_array($ticket['messages']) ? $ticket['messages'][0] : '';
-$subTitle = '';
-if (!empty($firstMessage) && isset($firstMessage['subject'])) {
-    $subTitle = $firstMessage['subject'];
-}
+$title = 'Ticket #' . $ticket['ticket']['ticket_code'];
 
 if (!isset($_POST['compose'])) {
     if (isset($_REQUEST['close'])) {
         TicketManager::close_ticket($_REQUEST['ticket_id'], $user_id);
-        $ticket['ticket']['status_id'] = 'CLS';
+        $ticket['ticket']['status_id'] = TicketManager::STATUS_CLOSE;
         $ticket['ticket']['status'] = $plugin->get_lang('Closed');
     }
-    $ticket['ticket']['request_user'] = intval($ticket['ticket']['request_user']);
+    /*$ticket['ticket']['request_user'] = intval($ticket['ticket']['request_user']);
     if ($ticket['ticket']['request_user'] == $user_id || intval($ticket['ticket']['assigned_last_user']) == $user_id) {
         TicketManager::update_message_status($ticket_id, $ticket['ticket']['request_user']);
-    }
+    }*/
     Display::display_header();
-    $form_close_ticket = "";
-    if ($ticket['ticket']['status_id'] != 'REE' && $ticket['ticket']['status_id'] != 'CLS' && $isAdmin) {
+    $form_close_ticket = '';
+        if ($ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED &&
+            $ticket['ticket']['status_id'] != TicketManager::STATUS_CLOSE &&
+            $isAdmin
+        ) {
         if (intval($ticket['ticket']['assigned_last_user']) == $user_id) {
-            if ($ticket['ticket']['status_id'] != 'CLS') {
+            if ($ticket['ticket']['status_id'] != TicketManager::STATUS_CLOSE) {
                 $form_close_ticket.= '<a href="' . api_get_self() . '?close=1&ticket_id=' . $ticket['ticket']['ticket_id'] . '" id="close" class="btn btn-danger" >';
                 $form_close_ticket.= get_lang('Close') . '</a>';
             }
@@ -253,19 +254,18 @@ if (!isset($_POST['compose'])) {
     }
 
     $img_assing = '';
-    if ($isAdmin && $ticket['ticket']['status_id'] != 'CLS' && $ticket['ticket']['status_id'] != 'REE') {
-        if ($ticket['ticket']['assigned_last_user'] != 0 && $ticket['ticket']['assigned_last_user'] == $user_id) {
-            $img_assing = '<a class="btn btn-warning" href="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '&amp;action=unassign" id="unassign">
-                           '.get_lang('Unassign').'
-                           </a>';
-        } else {
-            $img_assing = '<a href="#" id="assign" class="btn btn-success">'.get_lang('Assign').'</a>';
-
+    if (empty($ticket['ticket']['assigned_last_user'])) {
+        $img_assing = '<a href="#" id="assign" class="btn btn-success">'.get_lang('Assign').'</a>';
+    } else {
+        if ($isAdmin) {
+            $img_assing = '<a class="btn btn-warning" href="#" id="assign">
+                   '.get_lang('ChangeAssign').'
+                   </a>';
         }
     }
     $bold = '';
 
-    if ($ticket['ticket']['status_id'] == 'CLS') {
+    if ($ticket['ticket']['status_id'] == TicketManager::STATUS_CLOSE) {
         $bold = 'style = "font-weight: bold;"';
         echo "<style>
                 #confirmticket {
@@ -274,17 +274,17 @@ if (!isset($_POST['compose'])) {
               </style>";
     }
     if ($isAdmin) {
-        $senderData = get_lang('AddedBy') . ' ' . $ticket['ticket']['user_url'] . ' (' . $ticket['usuario']['username'] . ').';
+        $senderData = get_lang('AddedBy'). ' '.$ticket['ticket']['user_url'].' (' . $ticket['usuario']['username'] . ').';
     } else {
-        $senderData = get_lang('AddedBy') . ' ' . $ticket['usuario']['complete_name'] . ' (' . $ticket['usuario']['username'] . ').';
+        $senderData = get_lang('AddedBy'). ' '.$ticket['usuario']['complete_name'].' (' . $ticket['usuario']['username']. ').';
     }
 
     echo '
 			<table width="100%" >
 				<tr>
-	              <td colspan="3" style="width:65%">
-	              <h1>' . $titulo . ' '.$form_close_ticket.' '.$img_assing.' </h1>
-	              <h2>'.$subTitle.'</h2>
+	              <td colspan="3">
+	              <h1>'.$title.' '.$form_close_ticket.' '.$img_assing.' </h1>
+	              <h2>'.$ticket['ticket']['subject'].'</h2>
 	              <p>
 	                '.$senderData.' ' .
                     get_lang('Created') . ' '.
@@ -311,6 +311,17 @@ if (!isset($_POST['compose'])) {
 	            <tr>
 	                <td><p><b>' . $plugin->get_lang('Priority') . ': </b>' . $ticket['ticket']['priority'] . '<p></td>
 	            </tr>';
+
+    if (!empty($ticket['ticket']['assigned_last_user'])) {
+        $assignedUser = api_get_user_info($ticket['ticket']['assigned_last_user']);
+        echo '<tr>
+                <td><p><b>' . $plugin->get_lang('AssignedTo') . ': </b>' . $assignedUser['complete_name'] . '<p></td>
+            </tr>';
+    } else {
+        echo '<tr>
+                <td><p><b>' . $plugin->get_lang('AssignedTo') . ': </b>-<p></td>
+            </tr>';
+    }
     if ($ticket['ticket']['course_url'] != null) {
         echo '<tr>
 				<td><p>' . get_lang('Course') . ':</p></td>
@@ -320,17 +331,28 @@ if (!isset($_POST['compose'])) {
 	          </tr>';
     }
     echo '<tr>
-            <td><b>' . get_lang('Description') . ':</b> <br />
-            '.$firstMessage['message'].'</td>
+            <td>
+            <hr />
+            <b>' . get_lang('Description') . ':</b> <br />
+            '.$ticket['ticket']['message'].'
+            <hr />
+            </td>            
          </tr>
         ';
 
-    // select admins
+    // Select admins
     $select_admins = '<select  class ="chzn-select" style="width: 350px; " name = "admins" id="admins" ">';
 
-    $admins = UserManager::get_user_list_like(array("status" => "1"), array("username"), true);
+    $admins = UserManager::get_user_list_like(
+        array('status' => COURSEMANAGER), array('username'),
+        true
+    );
+
+    $select_admins .= '<option value="" >'.get_lang('None').'</option>';
+
     foreach ($admins as $admin) {
-        $select_admins.= "<option value = '" . $admin['user_id'] . "' " . (($user_id == $admin['user_id']) ? ("selected='selected'") : "") . ">" . $admin['lastname'] . ", " . $admin['firstname'] . "</option>";
+        $select_admins.= "<option value = '" . $admin['user_id'] . "' " . (($user_id == $admin['user_id']) ? ("selected='selected'") : '') . ">" .
+           $admin['complete_name'] . "</option>";
     }
     $select_admins .= "</select>";
     echo '<div id="dialog-form" title="' . $plugin->get_lang('AssignTicket') . '" >';
@@ -345,84 +367,158 @@ if (!isset($_POST['compose'])) {
     echo '</table>';
     $messages = $ticket['messages'];
 
-    unset($messages[0]);
+    $logs = TicketManager::get_assign_log($ticket_id);
+    $counter = 1;
     foreach ($messages as $message) {
-        $type = "success";
+        $date = Display::url(
+            date_to_str_ago($message['sys_insert_datetime']),
+            '#',
+            ['title' => api_get_local_time($message['sys_insert_datetime']), 'class' => 'boot-tooltip']
+        );
 
-        if ($message['admin']) {
-            $type = "normal";
-            if ($isAdmin) {
-                $message['message'] .= '<br/><b>' . $plugin->get_lang('AttendedBy') . ': ' . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
-            }
-        }else {
-            $message['message'] .= '<br /><b>' . get_lang('Sent') . ':</b> ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone());
+        $receivedMessage = '';
+        if (!empty($message['subject'])) {
+            $receivedMessage = '<b>'.get_lang('Subject') . ': </b> '.$message['subject'].'<br/>';
         }
+        $receivedMessage = '<b>'.get_lang('Message') . ':</b><br/>'.$message['message'].'<br/>';
 
-        $receivedMessage = '<b>' . get_lang('Subject') . ': </b> ' . $message['subject'] . '<br/>
-                            <b>' . get_lang('Message') . ':</b><br/>' . $message['message'] . '<br/>';
-        $attachementLinks = "";
-
-        if (isset($message['atachments'])) {
+        $attachmentLinks = '';
+        if (isset($message['attachments'])) {
             $attributeClass = array(
                 'class' => 'attachment-link'
             );
-            foreach ($message['atachments'] as $attach) {
-                $attachementLinks .= Display::tag('div', $attach['attachment_link'], $attributeClass);
+            foreach ($message['attachments'] as $attach) {
+                $attachmentLinks .= Display::tag('div', $attach['attachment_link'], $attributeClass);
             }
         }
 
-        $entireMessage = $receivedMessage . $attachementLinks;
-        echo Display::return_message($entireMessage, $type, false);
+        $entireMessage = $receivedMessage . $attachmentLinks;
+        $counterLink = Display::url('#'.$counter, api_get_self().'?ticket_id='.$ticket_id.'#note-'.$counter);
+        echo '<a id="note-'.$counter.'"> </a><h4>' . sprintf($plugin->get_lang('UpdatedByX'), $message['user_created']).' '.$date.
+            ' <span class="pull-right">'.$counterLink.'</span></h4>';
+        echo Display::div(
+            $entireMessage, ['class' => 'well']
+        );
+        $counter++;
     }
 
-    $subject = get_lang('ReplyShort') .": " . $firstMessage['subject'];
-    $user_admin = api_is_platform_admin();
-    if ($ticket['ticket']['status_id'] != 'REE' AND $ticket['ticket']['status_id'] != 'CLS') {
-        if (!$isAdmin && $ticket['ticket']['status_id'] != 'XCF') {
-            show_form_send_message();
+    $subject = get_lang('ReplyShort') .': '.$ticket['ticket']['subject'];
+
+    if ($ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED &&
+        $ticket['ticket']['status_id'] != TicketManager::STATUS_CLOSE
+    ) {
+        if (!$isAdmin && $ticket['ticket']['status_id'] != TicketManager::STATUS_UNCONFIRMED) {
+            show_form_send_message($ticket['ticket']);
         } else {
-            if (intval($ticket['ticket']['assigned_last_user']) == $user_id) {
-                show_form_send_message();
-                $cheked = "";
+            if (
+                $ticket['ticket']['assigned_last_user'] == $user_id ||
+                $ticket['ticket']['sys_insert_user_id'] == $user_id ||
+                $isAdmin
+            ) {
+                show_form_send_message($ticket['ticket']);
             }
         }
     }
 
     Display::display_footer();
-
 } else {
     $ticket_id = $_POST['ticket_id'];
     $content = $_POST['content'];
     $subject = $_POST['subject'];
-    $mensajeconfirmacion = isset($_POST['confirmation']) ? true : false;
+    $message = isset($_POST['confirmation']) ? true : false;
     $file_attachments = $_FILES;
     $user_id = api_get_user_id();
-    TicketManager::insert_message($ticket_id, $subject, $content, $file_attachments, $user_id, 'NOL', $mensajeconfirmacion);
-    header("location:" . api_get_self() . "?ticket_id=" . $ticket_id);
+
+    TicketManager::insert_message(
+        $ticket_id,
+        $subject,
+        $content,
+        $file_attachments,
+        $user_id,
+        'NOL',
+        $message
+    );
+
+    if ($isAdmin) {
+        TicketManager::updateTicket(
+            [
+                'priority_id' => $_POST['priority_id'],
+                'status_id' => $_POST['status_id']
+            ],
+            $ticket_id,
+            api_get_user_id()
+        );
+    }
+    Display::addFlash(Display::return_message(get_lang('Saved')));
+    header("Location:" . api_get_self() . "?ticket_id=" . $ticket_id);
     exit;
 }
 
-function show_form_send_message()
+/**
+ * @param array $ticket
+ */
+function show_form_send_message($ticket)
 {
     global $isAdmin;
-    global $ticket;
     global $subject;
     global $plugin;
 
-    Display::div('', array('span2'));
-
     $form = new FormValidator(
         'send_ticket',
         'POST',
-        api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'],
+        api_get_self() . '?ticket_id=' . $ticket['ticket_id'],
         '',
         array(
             'enctype' => 'multipart/form-data',
             'onsubmit' => 'return validate()',
-            'class' => 'span9 offset1 form-horizontal'
+            'class' => 'form-horizontal'
         )
     );
 
+    if ($isAdmin) {
+        $statusList[TicketManager::STATUS_NEW] = $plugin->get_lang('StatusNew');
+        $statusAttributes = array(
+            'id' => 'status_id',
+            'for' => 'status_id',
+            'style' => 'width: 562px;'
+        );
+        $statusList[TicketManager::STATUS_PENDING] = $plugin->get_lang('StatusPending');
+        $statusList[TicketManager::STATUS_UNCONFIRMED] = $plugin->get_lang('StatusUnconfirmed');
+        $statusList[TicketManager::STATUS_CLOSE] = $plugin->get_lang('StatusClose');
+        $statusList[TicketManager::STATUS_FORWARDED] = $plugin->get_lang('StatusForwarded');
+
+        $form->addElement(
+            'select',
+            'status_id',
+            get_lang('Status'),
+            $statusList,
+            $statusAttributes
+        );
+
+        $priorityList = array();
+        $priorityList[TicketManager::PRIORITY_NORMAL] = $plugin->get_lang('PriorityNormal');
+        $priorityList[TicketManager::PRIORITY_HIGH] = $plugin->get_lang('PriorityHigh');
+        $priorityList[TicketManager::PRIORITY_LOW] = $plugin->get_lang('PriorityLow');
+
+        $form->addElement(
+            'select',
+            'priority_id',
+            $plugin->get_lang('Priority'),
+            $priorityList,
+            array(
+                'id' => 'priority_id',
+                'for' => 'priority_id'
+            )
+        );
+
+        $form->setDefaults(
+            [
+                'priority_id' =>  $ticket['priority_id'],
+                'status_id' =>  $ticket['status_id'],
+            ]
+        );
+    }
+
     $form->addElement(
         'text',
         'subject',
@@ -434,7 +530,7 @@ function show_form_send_message()
         )
     );
 
-    $form->addElement('hidden', 'ticket_id', $_GET['ticket_id']);
+    $form->addElement('hidden', 'ticket_id', $ticket['ticket_id']);
 
     $form->addHtmlEditor(
         'content',

+ 1 - 5
plugin/ticket/src/ticket_plugin.class.php

@@ -34,7 +34,7 @@ class TicketPlugin extends Plugin
         );
 
         parent::__construct(
-            '2.0',
+            '3.0',
             'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier, Julio Montoya',
             $settings
         );
@@ -55,8 +55,6 @@ class TicketPlugin extends Plugin
     public function uninstall()
     {
         $tblSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
-        $t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
-        $t_tool = Database::get_course_table(TABLE_TOOL_LIST);
         $tblTicketTicket = Database::get_main_table(TABLE_TICKET_TICKET);
         $tblTicketStatus = Database::get_main_table(TABLE_TICKET_STATUS);
         $tblTicketProject = Database::get_main_table(TABLE_TICKET_PROJECT);
@@ -97,6 +95,4 @@ class TicketPlugin extends Plugin
             echo "<script>location.href = '" . $_SERVER['REQUEST_URI'] . "';</script>";
         }
     }
-
-
 }

+ 2 - 2
plugin/ticket/src/tutor.php

@@ -5,10 +5,10 @@
  * @package chamilo.plugin.ticket
  */
 
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
-require_once 'tutor_report.lib.php';
+require_once __DIR__.'/tutor_report.lib.php';
 
 $htmlHeadXtra[] = '
 	<script type="text/javascript">

+ 3 - 3
plugin/ticket/src/update_report.php

@@ -5,7 +5,7 @@
  * @package chamilo.plugin.ticket
  */
 
-require_once '../config.php';
+require_once __DIR__.'/../config.php';
 $plugin = TicketPlugin::create();
 
 $work_id = intval($_POST['work_id']);
@@ -17,8 +17,8 @@ if (!api_is_allowed_to_edit()) {
     Display::display_error_message($plugin->get_lang("DeniedAccess"));
 } else {
     $sql = "UPDATE " . Database::get_main_table('rp_reporte_semanas') . "
-        SET work_id = '$work_id', forum_id = '$forum_id'
-        WHERE  id ='$rs_id'";
+            SET work_id = '$work_id', forum_id = '$forum_id'
+            WHERE  id ='$rs_id'";
     Database::query($sql);
     Display::display_confirmation_message(get_lang('UpdatedSuccessfully'));
 }

+ 1 - 10
plugin/vchamilo/index.php

@@ -18,15 +18,7 @@ $_template['show_message'] = true;
 $_template['title'] = $plugininstance->get_lang('hostlist');
 
 $tablename = Database::get_main_table('vchamilo');
-$sql = "
-    SELECT 
-        sitename,
-        root_web
-    FROM
-        $tablename
-    WHERE
-        visible = 1
-";
+$sql = "SELECT sitename, root_web FROM $tablename WHERE visible = 1";
 
 if ($virtualChamilo == '%'){
     $result = Database::query($sql);
@@ -36,5 +28,4 @@ if ($virtualChamilo == '%'){
             $_template['hosts'][] = $vchamilo;
         }
     }
-} else {
 }

+ 1 - 1
plugin/vchamilo/plugin.php

@@ -59,7 +59,7 @@ $wwwroot = $_configuration['root_web'];
 
 //A simple select
 $options = array(0 => $plugininstance->get_lang('no'), 1 => $plugininstance->get_lang('yes'));
-$form->addlabel('', '<a class="btn btn-primary" href="'.api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php">'.
+$form->addLabel('', '<a class="btn btn-primary" href="'.api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php">'.
     $plugininstance->get_lang('manage_instances').'</a>');
 $form->addElement('header', $plugininstance->get_lang('enabling'));
 $form->addElement('select', 'enable_virtualisation', $plugininstance->get_lang('enable_virtualisation'), $options);

Some files were not shown because too many files changed in this diff