Kaynağa Gözat

Merge branch '6715' of github.com:FraGoTe/chamilo-lms into FraGoTe-6715

Yannick Warnier 11 yıl önce
ebeveyn
işleme
a2c1d81da0

+ 4 - 1
documentation/changelog.html

@@ -284,7 +284,10 @@ standards (but still much less than Firefox, Chrome, Opera or even Safari)</p>
 <ul>
     <li></li>
 </ul>
-
+<h3>Removals</h3>
+<ul>
+  <li>Custom tabs can no longer be defined directly in the settings_current table. If you have custom_tabs in this table (select * from settings_current where variable='show_tabs' AND subkey like 'custom_tab_%'), please add them through the hompeage edition screen.</li>
+</ul>
 
 <h1>Chamilo 1.9.6 - Rochefort, 4th of June, 2013</h1>
 <h3>Release notes - summary</h3>

+ 16 - 14
main/inc/lib/banner.lib.php

@@ -16,7 +16,7 @@
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  */
 function get_tabs() {
-	global $_course;
+    global $_course;
 
     $navigation = array();
 
@@ -110,12 +110,14 @@ function get_tabs() {
 	}*/
 
 	// Custom tabs
-	for ($i = 1; $i<=3; $i++)
-		if (api_get_setting('custom_tab_'.$i.'_name') && api_get_setting('custom_tab_'.$i.'_url')) {
-                    $navigation['custom_tab_'.$i]['url'] = api_get_setting('custom_tab_'.$i.'_url');
-                    $navigation['custom_tab_'.$i]['title'] = api_get_setting('custom_tab_'.$i.'_name');
-                    $navigation['custom_tab_'.$i]['key'] = 'custom_tab_'.$i;
-		}
+	for ($i = 1; $i <= 3; $i++) {
+            if (api_get_setting('show_tabs', 'custom_tab_' . $i) == 'true') {
+                $setting = api_get_full_setting('show_tabs', 'custom_tab_' . $i);
+                $navigation['custom_tab_' . $i]['url'] = $setting[0]['comment'];
+                $navigation['custom_tab_' . $i]['title'] = $setting[0]['title'];
+                $navigation['custom_tab_' . $i]['key'] = 'custom_tab_' . $i;
+            }
+        }
 
 	// Platform administration
 	if (api_is_platform_admin(true)) {
@@ -231,10 +233,10 @@ function return_notification_menu() {
 
 function return_navigation_array() {
 
-    $navigation         = array();
-    $menu_navigation    = array();
-    $possible_tabs      = get_tabs();
-
+    $navigation = array();
+    $menu_navigation = array();
+    $possible_tabs = get_tabs();
+    
     // Campus Homepage
     if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
         $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
@@ -327,12 +329,12 @@ function return_navigation_array() {
         }
 
         // Custom tabs
-        for ($i=1;$i<=3;$i++) {
-            if (api_get_setting('show_tabs', 'custom_tab_'.$i) == 'true' && isset($possible_tabs['custom_tab_'.$i])) {
+        for ($i=1; $i <= 3; $i++) {
+            if (api_get_setting('show_tabs', 'custom_tab_' . $i) == 'true' && isset($possible_tabs['custom_tab_' . $i])) {
                 $navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
             } else {
                 if (isset($possible_tabs['custom_tab_'.$i])) {
-                    $menu_navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
+                    $menu_navigation['custom_tab_' . $i] = $possible_tabs['custom_tab_' . $i];
                 }
             }
         }

+ 26 - 0
main/inc/lib/main_api.lib.php

@@ -7199,3 +7199,29 @@ function api_get_origin()
 
     return null;
 }
+/**
+ * Get the entire setting row
+ * @param string $variable
+ * @param string $key
+ * @return array
+ */
+function api_get_full_setting($variable, $key = null) {
+    $variable = Database::escape_string($variable);
+    $sql = "SELECT *
+            FROM settings_current 
+            WHERE variable = '$variable' ";
+    
+    if (!empty($key)) {
+        $key = Database::escape_string($key);
+        $sql .= "AND subkey = '$key'";
+    }
+    
+    $result = Database::query($sql);
+    $setting = array();
+    
+    while ($row = Database::fetch_assoc($result)) {
+        $setting[] = $row;
+    }
+    
+    return $setting;
+}

+ 174 - 1
main/inc/lib/plugin.class.php

@@ -462,4 +462,177 @@ class Plugin
     {
 
     }
-}
+    
+    /**
+     * Add a tab to chamilo's platform
+     * @param type $tabName
+     */
+    public function addTab($tabName, $url)
+    {
+        $sql = "SELECT * 
+                FROM settings_current
+                WHERE variable = 'show_tabs'
+                AND subkey like 'custom_tab_%'";
+        $result = Database::query($sql);
+        
+        $customTabsNum = Database::count_rows($result);
+        
+        $tabNum = $customTabsNum + 1;
+        
+        //Avoid Tab Name Spaces
+        $tabNameNoSpaces = preg_replace('/\s+/', '', $tabName);
+        $subkeytext = "Tabs" . $tabNameNoSpaces;
+        $subkey = 'custom_tab_' . $tabNum;
+        $attributes = array(
+            'variable' => 'show_tabs',
+            'subkey' => $subkey,
+            'type' => 'checkbox',
+            'category' => 'Platform',
+            'selected_value' => 'true',
+            'title' => $tabName,
+            'comment' => $url,
+            'subkeytext' => $subkeytext,
+            'access_url' => 1,
+            'access_url_changeable' => 0,
+            'access_url_locked' => 0
+        );
+        $resp = Database::insert('settings_current', $attributes);
+        
+        //Save the id
+        $settings = $this->get_settings();
+        $setData = array (
+            'comment' => $subkey
+        );
+        $whereCond = array(
+            'id = ?' => key($settings)
+        );
+        
+        Database::update('settings_current', $setData, $whereCond);
+        
+        return $resp;
+    }
+    
+    /**
+     * Delete a tab to chamilo's platform
+     * @param type $key
+     */
+    public function deleteTab($key)
+    {
+        $sql = "SELECT * 
+                FROM settings_current
+                WHERE variable = 'show_tabs'
+                AND subkey <> '$key'";
+        $resp = $result = Database::query($sql);
+        $customTabsNum = Database::count_rows($result);
+        
+        if (!empty($key)) {
+            $whereCond = array(
+                    'variable = ? AND subkey = ?' => array('show_tabs', $key)
+            );
+            Database::delete('settings_current', $whereCond);
+
+            //if there is more than one tab
+            //reenumerate them
+            if ($customTabsNum > 0) {
+                $i = 1;
+                while ($row = Database::fetch_assoc($result)) {
+                    $attributes = array(
+                        'subkey' => 'custom_tab_' . $i
+                    );
+                    $resp = $this->updateTab($row['subkey'], $attributes);
+                    $i++;
+                }
+
+            }
+        }
+        
+        return $resp;
+    }
+    
+    /**
+     * Update the tabs attributes
+     * @param string $key
+     * @param array $attributes
+     * @return boolean
+     */
+    public function updateTab($key, $attributes)
+    {
+        $whereCond = array(
+            'variable = ? AND subkey = ?' => array('show_tabs', $key)
+        );
+        $resp = Database::update('settings_current', $attributes, $whereCond);
+        return $resp;
+    }
+    
+    /**
+     * Add aditional plugin Settings
+     * @param array $settings
+     */
+    public function addExtraSettings($settings) 
+    {
+        $pluginName = $this->get_name();
+        $resp = false;
+        foreach ($settings as $setting => $value) {
+            $attributes = array(
+                'variable' => 'plugin_settings_' . $pluginName,
+                'subkey' => $setting,
+                'selected_value' => $value,
+                'category' => 'PluginSettings'
+            );
+            if (empty($this->getExtraSettingValue($setting))) {
+                $resp = Database::insert('settings_current', $attributes);
+            }
+        }
+        
+        return $resp;
+    }
+    
+    /**
+     * Edit aditional Plugin Settings
+     * @param array $settings
+     */
+    public function editExtraSetting($key, $attributes)
+    {
+        $pluginName = $this->get_name();
+        
+        $whereCond = array(
+            'variable = ? AND subkey = ?' => array('plugin_settings_' . $pluginName, $key)
+        );
+        
+        $resp = Database::update('settings_current', $attributes, $whereCond);
+         
+        return $resp;
+    }
+    
+    
+    /**
+     * Delete all aditional plugin settings
+     */
+    public function deleteExtraSettings() 
+    {
+        $pluginName = $this->get_name();
+        $whereCond = array(
+            'variable = ?' => 'plugin_settings_' . $pluginName
+        );
+        $resp = Database::delete('settings_current', $whereCond);
+        
+        return $resp;
+    }
+    
+    /**
+     * Give extra setting value
+     * @param string $settingName
+     */
+    public function getExtraSettingValue($settingName)
+    {
+        $pluginName = $this->get_name();
+        $fullSetting = api_get_full_setting('plugin_settings_' . $pluginName, $settingName);
+        
+        if (empty($fullSetting)) {
+            return false;
+        } else {
+            $setting = current($fullSetting);
+            return $setting['selected_value'];
+        }
+    }
+}

+ 5 - 3
main/inc/lib/plugin.lib.php

@@ -180,15 +180,17 @@ class AppPlugin
         } else {
             $urlId = intval($urlId);
         }
-        api_delete_settings_params(
-            array('category = ? AND access_url = ? AND subkey = ? ' => array('Plugins', $urlId, $pluginName))
-        );
+        // First call the custom uninstall to allow full access to global settings
         $pluginPath = api_get_path(SYS_PLUGIN_PATH).$pluginName.'/uninstall.php';
         if (is_file($pluginPath) && is_readable($pluginPath)) {
             // Execute the uninstall procedure.
 
             require $pluginPath;
         }
+        // Second remove all remaining global settings
+        api_delete_settings_params(
+            array('category = ? AND access_url = ? AND subkey = ? ' => array('Plugins', $urlId, $pluginName))
+        );
     }
 
     /**

+ 2 - 2
plugin/ticket/config.install.php

@@ -9,5 +9,5 @@
 require_once '../../main/inc/global.inc.php';
 require_once api_get_path(LIBRARY_PATH).'plugin.class.php';
 
-require_once 'lib/ticket.class.php';
-require_once 'lib/ticket_plugin.class.php';
+require_once 'src/ticket.class.php';
+require_once 'src/ticket_plugin.class.php';

+ 11 - 9
plugin/ticket/config.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  * @package chamilo.plugin.ticket
@@ -23,25 +24,26 @@ define('REENVIADO', 'REE'); // @todo delete option. This is a location of USIL
 
 /* Ticket priority constants */
 define('NORMAL', 'NRM');
-define('HIGH', 'ALT');
+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(LIBRARY_PATH).'plugin.class.php';
-require_once api_get_path(LIBRARY_PATH).'course.lib.php';
-require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
-require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
+require_once __DIR__ . '/../../main/inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
+require_once api_get_path(LIBRARY_PATH) . 'course.lib.php';
+require_once api_get_path(LIBRARY_PATH) . 'mail.lib.inc.php';
+require_once api_get_path(LIBRARY_PATH) . 'export.lib.inc.php';
+require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
 
-require_once api_get_path(PLUGIN_PATH).PLUGIN_NAME.'/lib/ticket.class.php';
-require_once api_get_path(PLUGIN_PATH).PLUGIN_NAME.'/lib/ticket_plugin.class.php';
-require_once api_get_path(PLUGIN_PATH).PLUGIN_NAME.'/src/ticket.class.php';
+require_once api_get_path(PLUGIN_PATH) . PLUGIN_NAME . '/src/ticket_plugin.class.php';
+require_once api_get_path(PLUGIN_PATH) . PLUGIN_NAME . '/src/ticket.class.php';

+ 102 - 12
plugin/ticket/database.php

@@ -2,6 +2,10 @@
 /**
  * Contains the SQL for the tickets management plugin database structure
  */
+
+
+$objPlugin = new TicketPlugin();
+
 $table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
 $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         iid int unsigned not null,
@@ -13,6 +17,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         KEY FK_ticket_assigned_log (ticket_id))";
 Database::query($sql);
 
+//Category
 $table = Database::get_main_table(TABLE_TICKET_CATEGORY);
 $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         iid int unsigned not null,
@@ -29,8 +34,44 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         PRIMARY KEY (iid))";
 Database::query($sql);
 
+//Default Categories
+$categoRow = array(
+    $objPlugin->get_lang('Enrollment') => $objPlugin->get_lang('TicketsAboutEnrollment'),
+    $objPlugin->get_lang('GeneralInformation') => $objPlugin->get_lang('TicketsAboutGeneralInformation'),
+    $objPlugin->get_lang('RequestAndTramits') => $objPlugin->get_lang('TicketsAboutRequestAndTramits'),
+    $objPlugin->get_lang('AcademicIncidence') => $objPlugin->get_lang('TicketsAboutAcademicIncidence'),
+    $objPlugin->get_lang('VirtualCampus') => $objPlugin->get_lang('TicketsAboutVirtualCampus'),
+    $objPlugin->get_lang('OnlineEvaluation') => $objPlugin->get_lang('TicketsAboutOnlineEvaluation')
+);
+$i = 1;
+foreach ($categoRow as $category => $description) {
+    //Online evaluation requires a course
+    if ($i == 6) {
+        $attributes = array(
+            'iid' => $i, 
+            'category_id' => $i,
+            'name' => $category,
+            'description' => $description,
+            'project_id' => 1,
+            'course_required' => 1
+        );
+    } else {
+        $attributes = array(
+            'iid' => $i, 
+            'category_id' => $i,
+            'project_id' => 1,
+            'description' => $description,
+            'name' => $category
+        );
+    }
+    
+    Database::insert($table, $attributes);
+    $i++;
+}
+//END default categories
 $table = Database::get_main_table(TABLE_TICKET_MESSAGE);
 $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
+        iid int UNSIGNED NOT NULL AUTO_INCREMENT,
         message_id int UNSIGNED NOT NULL,
         ticket_id int UNSIGNED NOT NULL,
         subject varchar(150) DEFAULT NULL,
@@ -41,13 +82,13 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         sys_insert_datetime datetime DEFAULT NULL,
         sys_lastedit_user_id int UNSIGNED DEFAULT NULL,
         sys_lastedit_datetime datetime DEFAULT NULL,
-        PRIMARY KEY (message_id),
+        PRIMARY KEY (iid),
         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." (
-        iid int unsigned not null,
+        iid int UNSIGNED NOT NULL AUTO_INCREMENT,
         message_attch_id char(2) NOT NULL,
         message_id char(2) NOT NULL,
         ticket_id int UNSIGNED NOT NULL,
@@ -62,9 +103,10 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         KEY ticket_message_id_fk (message_id))";
 Database::query($sql);
 
+//Priority
 $table = Database::get_main_table(TABLE_TICKET_PRIORITY);
 $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
-        iid int unsigned not null,
+        iid int UNSIGNED NOT NULL AUTO_INCREMENT,
         priority_id char(3) NOT NULL,
         priority varchar(20) DEFAULT NULL,
         priority_desc varchar(250) DEFAULT NULL,
@@ -76,10 +118,28 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         sys_lastedit_datetime datetime DEFAULT NULL,
         PRIMARY KEY (iid))";
 Database::query($sql);
+//Default Priorities
+$defaultPriorities = array(
+    'NRM' => get_lang('Normal'),
+    'HGH' => get_lang('High'),
+    'LOW' => get_lang('Low')
+);
+$i = 1;
+foreach ($defaultPriorities as $pId => $priority) {
+    $attributes = array(
+        'iid' => $i,
+        'priority_id' => $pId,
+        'priority' => $priority,
+        'priority_desc' => $priority
+    );
+    Database::insert($table, $attributes);
+    $i++;
+}
+//End
 
 $table = Database::get_main_table(TABLE_TICKET_PROJECT);
 $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
-        iid int unsigned not null,
+        iid int UNSIGNED NOT NULL AUTO_INCREMENT,
         project_id char(3) NOT NULL,
         name varchar(50) DEFAULT NULL,
         description varchar(250) DEFAULT NULL,
@@ -91,15 +151,44 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         sys_lastedit_datetime datetime DEFAULT NULL,
         PRIMARY KEY (iid))";
 Database::query($sql);
+//Default Project Table Ticket
+$attributes = array(
+    'iid' => 1,
+    'project_id' => 1,
+    'name' => 'Ticket System'
+);
+Database::insert($table, $attributes);
+//END
 
+//STATUS
 $table = Database::get_main_table(TABLE_TICKET_STATUS);
 $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
-        iid int unsigned not null,
+        iid int UNSIGNED NOT NULL AUTO_INCREMENT,
         status_id char(3) NOT NULL,
         name varchar(100) NOT NULL,
         description varchar(255) DEFAULT NULL,
         PRIMARY KEY (iid))";
 Database::query($sql);
+//Default status
+$defaultStatus = array(
+    'NAT' => get_lang('New'),
+    'PND' => $objPlugin->get_lang('Pending'),
+    'XCF' => $objPlugin->get_lang('Unconfirmed'),
+    'CLS' => get_lang('Close'),
+    'REE' => get_lang('Forwarded')
+);
+
+$i = 1;
+foreach ($defaultStatus as $abr => $status) {
+    $attributes = array(
+        'iid' => $i,
+        'status_id' => $abr,
+        'name' => $status
+    );
+    Database::insert($table, $attributes);
+    $i ++;
+}
+//END
 
 $table = Database::get_main_table(TABLE_TICKET_TICKET);
 $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
@@ -109,6 +198,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         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,
         personal_email varchar(150) DEFAULT NULL,
         assigned_last_user int UNSIGNED NOT NULL DEFAULT '0',
@@ -128,10 +218,10 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
         KEY FK_ticket_category (project_id,category_id))";
 Database::query($sql);
 
-// Menu main tabs
-//$table = Database::get_main_table('ticket_ticket');
-//$sql = "INSERT INTO settings_current
-//(variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable)
-//VALUES
-//('show_tabs', 'tickets', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsTickets', 1)";
-//Database::query($sql);
+//Menu main tabs
+$objPlugin->addTab('Ticket', '/plugin/ticket/src/myticket.php');
+//Extra Settings
+$extraSettings = array(
+    'allow_add' => 'true'
+);
+$objPlugin->addExtraSettings($extraSettings);

+ 8 - 3
plugin/ticket/lang/spanish.php

@@ -65,7 +65,12 @@ $strings['SrcPhone']         = "Telefono";
 $strings['SrcPresential']    = "Presencial";
 
 //
+$strings['TicketAssignedMsg']    = "<p>Estimado(a) %s </p><p>Se le ha sido asignado el <a href=\"%s\">ticket %s</a></p><p>Mensaje enviado desde el sistema de ticket.</p>";
+$strings['TicketAssignX'] = "[TICKETS] Asignacion de Ticket #%s ";
+$strings['AreYouSureYouWantToCloseTheTicket'] = "¿Esta seguro que quiere cerrar el ticket?";
+$strings['AreYouSureYouWantToUnassignTheTicket'] = "¿Esta seguro que quiere desasignarse el ticket?";
+$strings['YouMustWriteAMessage'] = "Debe escribir un mensaje";
+$strings['LastResponse'] = "Ultima Respuesta";
 
-$strings['TckAssignedMsg']    = "<p>Estimado(a):</p><p> ? ? </p>
-								<p>Se le ha sido asignado el ticket ? <a href=\"?\">Ticket</a></p>
-							    <p>Mensaje enviado desde el sistema de ticket.</p>";
+$strings['AssignTicket'] = "Asignar Ticket";
+$strings['AttendedBy'] = "Atendido por";

+ 0 - 40
plugin/ticket/lib/ticket.class.php

@@ -1,40 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
- * This class defines the basis of the ticket management system plugin
- * @package chamilo.plugin.ticket
- */
-/**
- * Ticket class
- */
-class Ticket {
-
-    public $url;
-    public $salt;
-    public $api;
-    public $user_complete_name = null;
-    public $protocol = 'http://';
-    private $debug = false;
-    public $logout_url = null;
-    public $plugin_enabled = false;
-
-    /**
-     * Constructor (generates a connection to the API and the Chamilo settings
-     * required for the connection to the videoconference server)
-     */
-    function __construct()
-    {
-
-        // initialize video server settings from global settings
-        $plugin = TicketPlugin::create();
-    }
-    /**
-     * Checks whether a user is teacher in the current course
-     * @return bool True if the user can be considered a teacher in this course, false otherwise
-     */
-    function is_teacher()
-    {
-        return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
-    }
-
-}

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

@@ -20,14 +20,14 @@ $course_code = $course_info['code'];
 echo '<form action="tutor.php" name="assign" id ="assign">';
 echo '<div id="confirmation"></div>';
 $id = intval($_GET['id']);
-$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
-$sql ="SELECT * FROM $table_reporte_semanas WHERE id = '$id'";
+$tblWeeklyReport = Database::get_main_table('rp_reporte_semanas');
+$sql ="SELECT * FROM $tblWeeklyReport WHERE id = '$id'";
 $sql_tasks = "SELECT id AS colid, title as coltitle
     FROM ".Database::get_course_table(TABLE_STUDENT_PUBLICATION , $course_info['dbName'])."
     WHERE parent_id = 0
         AND id NOT IN (
             SELECT work_id
-            FROM $table_reporte_semanas
+            FROM $tblWeeklyReport
             WHERE course_code = '$course_code'
                 AND id != '$id'
         )";
@@ -35,7 +35,7 @@ $sql_forum = "SELECT thread_id AS colid, thread_title AS coltitle
     FROM ".Database::get_course_table(TABLE_FORUM_THREAD, $course_info['dbName'])."
     WHERE thread_id NOT IN (
         SELECT forum_id
-            FROM $table_reporte_semanas
+            FROM $tblWeeklyReport
             WHERE course_code = '$course_code'
                 AND id != '$id'
     )";
@@ -44,25 +44,25 @@ $result_tareas = Database::query($sql_tasks);
 $result_forum = Database::query($sql_forum);
 
 echo '<div class="row">
-        <input type="hidden" id="rs_id" name ="rs_id" value="'.$id.'">
-        <div class="formw">'.get_lang('PleaseSelectTasks').'</div>
+        <input type="hidden" id="rs_id" name ="rs_id" value="' . $id . '">
+        <div class="formw">' . get_lang('PleaseSelectTasks') . '</div>
     </div>';
 echo '<div class="row"><div class="formw"><select name ="work_id" id="work_id">';
-echo '<option value="0"'.(($row['colid']==$rs->work_id)?"selected":"").'>'.get_lang('PleaseSelect').'</option>';
-while ($row = Database::fetch_assoc($result_tasks)){
-    echo '<option value="'.$row['colid'].'"'.(($row['colid']==$rs->work_id)?"selected":"").'>'.$row['coltitle'].'</option>';
+echo '<option value="0"' . (($row['colid'] == $rs->work_id) ? "selected" : "") . '>' . get_lang('PleaseSelect') . '</option>';
+while ($row = Database::fetch_assoc($result_tasks)) {
+    echo '<option value="' . $row['colid'] . '"' . (($row['colid'] == $rs->work_id) ? "selected" : "") . '>' . $row['coltitle'] . '</option>';
 }
 echo '</select></div><div>';
 echo '<div class="row">
-        <div class="formw">'.get_lang('PleaseSelectThread').'</div>
+        <div class="formw">' . get_lang('PleaseSelectThread') . '</div>
     </div>';
 echo '<div class="row"><div class="formw"><select name ="forum_id" id="forum_id">';
-echo '<option value="0"'.(($row['colid']==$rs->work_id)?"forum_id":"").'>'.get_lang('PleaseSelect').'</option>';
-while ($row = Database::fetch_assoc($result_forum)){
-    echo '<option value="'.$row['colid'].'"'.(($row['colid']==$rs->forum_id)?"selected":"").'>'.$row['coltitle'].'</option>';
+echo '<option value="0"' . (($row['colid'] == $rs->work_id) ? "forum_id" : "") . '>' . get_lang('PleaseSelect') . '</option>';
+while ($row = Database::fetch_assoc($result_forum)) {
+    echo '<option value="' . $row['colid'] . '"' . (($row['colid'] == $rs->forum_id) ? "selected" : "") . '>' . $row['coltitle'] . '</option>';
 }
 echo '</select></div><div>';
 echo '<div class="row">
-        <div class="formw"><button class="save" name="edit" type="button" value="'.get_lang('Edit').'" onClick="save('."$id".');">'.get_lang('Edit').'</button></div>
+        <div class="formw"><button class="save" name="edit" type="button" value="' . get_lang('Edit') . '" onClick="save(' . "$id" . ');">' . get_lang('Edit') . '</button></div>
     </div>';
-echo '</form>';
+echo '</form>';

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

@@ -13,23 +13,23 @@ $plugin = TicketPlugin::create();
 
 $user_id = intval($_GET['user_id']);
 $user_info = api_get_user_info($user_id);
-$courses_list = CourseManager::get_courses_list_by_user_id($user_id,false,true);
+$courses_list = CourseManager::get_courses_list_by_user_id($user_id, false, true);
 ?>
 <div class="row">
-	<div class="label2"><?php echo get_lang('User')?>:</div>
-       <div class="formw2" id="user_request"><?php echo $user_info['firstname']." ".$user_info['lastname'] ;?></div>
+    <div class="label2"><?php echo get_lang('User') ?>:</div>
+    <div class="formw2" id="user_request"><?php echo $user_info['firstname'] . " " . $user_info['lastname']; ?></div>
 </div>
 <div class="row" id="divCourse">
-	<div class="label2"><?php echo get_lang('Course')?>:</div>
-	<div class="formw2" id="courseuser">
-	 <select  class="chzn-select" name = "course_id" id="course_id"  style="width:95%;">
-		<option value="0">---<?php echo get_lang('Select')?>---</option>
-		<?php
-		foreach ($courses_list as $key => $course) {
-			$courseinfo = CourseManager::get_course_information($course['code']);
-			echo '<option value="'. $courseinfo['code'].'"> '.$courseinfo['title'].'</option>';
-		}
-		?>
-	</select>
-	</div>
+    <div class="label2"><?php echo get_lang('Course') ?>:</div>
+    <div class="formw2" id="courseuser">
+        <select  class="chzn-select" name = "course_id" id="course_id"  style="width:95%;">
+            <option value="0">---<?php echo get_lang('Select') ?>---</option>
+            <?php
+            foreach ($courses_list as $key => $course) {
+                $courseinfo = CourseManager::get_course_information($course['code']);
+                echo '<option value="' . $courseinfo['code'] . '"> ' . $courseinfo['title'] . '</option>';
+            }
+            ?>
+        </select>
+    </div>
 </div>

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

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  *
@@ -53,4 +54,4 @@ if (Security::check_abs_path($full_file_name, $path_message_attach)) {
     DocumentManager::file_send_for_download($full_file_name, true, $title);
 }
 
-exit;
+exit;

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

@@ -8,4 +8,4 @@
  * Code
  */
 require_once '../config.php';
-header('location:'.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/src/myticket.php?message=success');
+header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php?message=success');

+ 107 - 59
plugin/ticket/src/myticket.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  * This script is the Tickets plugin main entry point
@@ -20,14 +21,14 @@ api_block_anonymous_users();
 
 $libPath = api_get_path(LIBRARY_PATH);
 $webLibPath = api_get_path(WEB_LIBRARY_PATH);
-require_once $libPath. 'formvalidator/FormValidator.class.php';
+require_once $libPath . 'formvalidator/FormValidator.class.php';
 require_once $libPath . 'group_portal_manager.lib.php';
 $htmlHeadXtra[] = '<script type="text/javascript">
 function load_history_ticket (div_course,ticket_id) {
     $.ajax({
         contentType: "application/x-www-form-urlencoded",
         beforeSend: function(object) {
-        $("div#"+div_course).html("<img src=\''.$webLibPath.'javascript/indicator.gif\' />"); },
+        $("div#"+div_course).html("<img src=\'' . $webLibPath . 'javascript/indicator.gif\' />"); },
         type: "POST",
         url: "ticket_assign_log.php",
         data: "ticket_id="+ticket_id,
@@ -63,15 +64,26 @@ function display_advanced_search_form () {
 }
 </script>
 <style>
-div.row div.label2 {
+.label2 {
     float: left;
-    width: 35%;
     text-align: left;
+    width: 75px;
 }
-div.row div.formw2 {
-    width: 65%;
+
+.label3 {
+    margin-left: 20px;
     float: left;
+    text-align: left;
+    margin-top: 5px;
+    width: 50px;
 }
+
+.formw2 {
+    float: left;
+    margin-left: 4px;
+    margin-top: 5px;
+}
+
 .blackboard_show {
     float: left;
     position: absolute;
@@ -82,6 +94,7 @@ div.row div.formw2 {
     padding: 3px;
     display: inline;
 }
+
 .blackboard_hide {
     display: none;
 }
@@ -90,8 +103,7 @@ div.row div.formw2 {
 $this_section = 'tickets';
 unset($_SESSION['this_section']);
 
-$table = new SortableTable('Tickets', array('TicketManager', 'get_total_tickets_by_user_id'), 
-            array('TicketManager', 'get_tickets_by_user_id'), 2, 20, 'DESC');
+$table = new SortableTable('Tickets', array('TicketManager', 'get_total_tickets_by_user_id'), array('TicketManager', 'get_tickets_by_user_id'), 2, 20, 'DESC');
 if ($table->per_page == 0) {
     $table->per_page = 20;
 }
@@ -113,11 +125,33 @@ if (isset($_GET['action'])) {
                 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('Message'), $plugin->get_lang('Description')));
+            $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($ticket[8])), utf8_decode(strip_tags($ticket[10])));
+                $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::export_table_xls($data, $plugin->get_lang('Tickets'));
@@ -146,7 +180,7 @@ if ($isAdmin) {
         $get_parameter .= "&submit_simple=";
     }
     //select categories
-    $select_types .= '<select class="chzn-select" style="width: 200px; "  name = "keyword_category" id="keyword_category" ">';
+    $select_types .= '<select class="chzn-select" name = "keyword_category" id="keyword_category" ">';
     $select_types .= '<option value="">---' . get_lang('Select') . '---</option>';
     $types = TicketManager::get_all_tickets_categories();
     foreach ($types as $type) {
@@ -154,7 +188,7 @@ if ($isAdmin) {
     }
     $select_types .= "</select>";
     //select admins
-    $select_admins .= '<select  class ="chzn-select" style="width: 200px; " name = "keyword_admin" id="keyword_admin" ">';
+    $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);
@@ -163,7 +197,7 @@ if ($isAdmin) {
     }
     $select_admins .= "</select>";
     //select status
-    $select_status .= '<select  class ="chzn-select" style="width: 200px; " name = "keyword_status" id="keyword_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();
     foreach ($status as $stat) {
@@ -171,18 +205,18 @@ if ($isAdmin) {
     }
     $select_status .= "</select>";
     //select priority
-    $select_priority .= '<select  style="width: 200px; " name = "keyword_priority" id="keyword_priority" >';
+    $select_priority .= '<select  name = "keyword_priority" id="keyword_priority" >';
     $select_priority .= '<option value="">' . get_lang('All') . '</option>';
     $select_priority .= '<option value="NRM">' . get_lang('PriorityNormal') . '</option>';
-    $select_priority .= '<option value="ALT">' . get_lang('PriorityHigh') . '</option>';
+    $select_priority .= '<option value="HGH">' . get_lang('PriorityHigh') . '</option>';
     $select_priority .= '<option value="LOW">' . get_lang('PriorityLow') . '</option>';
     $select_priority .= "</select>";
 
     //select unread
-    $select_unread = '<select  style="width: 100px; " name = "keyword_unread" id="keyword_unread" >';
+    $select_unread = '<select  name = "keyword_unread" id="keyword_unread" >';
     $select_unread .= '<option value="">' . get_lang('All') . '</option>';
-    $select_unread .= '<option value="yes">' . get_lang('Read') . '</option>';
-    $select_unread .= '<option value="no">' . get_lang('Unread') . '</option>';
+    $select_unread .= '<option value="yes">' . get_lang('Unread') . '</option>';
+    $select_unread .= '<option value="no">' . get_lang('Read')  . '</option>';
     $select_unread .= "</select>";
     // Create a search-box
     $form = new FormValidator('search_simple', 'get', '', '', null, false);
@@ -190,19 +224,21 @@ if ($isAdmin) {
     $renderer->setElementTemplate('<span>{element}</span> ');
     $form->addElement('text', 'keyword', get_lang('keyword'), 'size="25"');
     $form->addElement('style_submit_button', 'submit_simple', get_lang('Search'), 'class="search"');
-    $form->addElement('static', 'search_advanced_link', null, '<a href="javascript://" class = "advanced_parameters" onclick="display_advanced_search_form();"><span id="img_plus_and_minus">&nbsp;' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . ' ' . get_lang('AdvancedSearch') . '</span></a>');
+    $form->addElement('static', 'search_advanced_link', null, 
+            '<a href="javascript://" class = "advanced_parameters" onclick="display_advanced_search_form();">'
+            . '<span id="img_plus_and_minus">&nbsp;'
+            . Display::return_icon('div_show.gif', get_lang('Show'), 
+            array('style' => 'vertical-align:middle')) . ' '
+            . get_lang('AdvancedSearch') . '</span></a>');
 
-    echo '<div class="actions" style="width:100%;">';
+    echo '<div class="actions" >';
     if (api_is_platform_admin()) {
-        /* echo '<span style="float:right;">'.
-          '<a href="'.api_get_self().'?action=close_tickets">'.Display::return_icon('warning.png',$plugin->get_lang('TckClose'),'','32').'</a>'.
-          '</span>'; */
         echo '<span style="float:right;">' .
-        '<a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' . 
-        Display::return_icon('import_excel.png', get_lang('Export'), '', '32') . '</a>' .
+        '<a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' .
+            Display::return_icon('import_excel.png', get_lang('Export'), '', '32') . '</a>' .
         '</span>';
         echo '<span style="float:right;">' .
-        '<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/s/new_ticket.php">' . 
+        '<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .
         Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') . '</a>' .
         '</span>';
         echo '<span style="float:right;">' .
@@ -212,75 +248,75 @@ if ($isAdmin) {
     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 class="row">
+            <div>
                <div class="form_header">' . get_lang('AdvancedSearch') . '</div>
             </div>
-            <table width="100%">
+            <table >
                <tbody>
                   <tr>
-                     <td width="30%">
-                        <div class="row">
-                           <div class="label2">' . get_lang('Category') . '</div>
-                           <div class="formw2">' . $select_types . '</div>
+                     <td>
+                        <div>
+                           <div class="label2">' . get_lang('Category') . ': </div>
+                           <div class="formw2" style="margin-top: -5px;">' . $select_types . '</div>
                         </div>
                      </td>
-                     <td width="25%">
-                        <div class="row">
-                           <div class="label2">' . get_lang('User') . '</div>
+                     <td>
+                        <div>
+                           <div class="label3">' . get_lang('User') . ': </div>
                            <div class="formw2"><input id="keyword_request_user" name="keyword_request_user" type="text"></div>
                         </div>
                      </td>
-                     <td width="25%">
-                        <div class="row">
-                           <div class="label2">' . $plugin->get_lang('RegisterDate') . ':</div>
+                     <td>
+                        <div>
+                           <div class="label3">' . $plugin->get_lang('RegisterDate') . ': </div>
                            <div class="formw2"><input id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div>
                         </div>
                      </td>
-                     <td width="20%">
-                        <div class="row">
-                           <div class="label2"><input type="checkbox" name="keyword_dates" value="1">' . get_lang('Untill') . ':</div>
+                     <td>
+                        <div>
+                           <div class="label3"><input type="checkbox" name="keyword_dates" value="1">' . get_lang('Untill') . ':</div>
                            <div class="formw2"><input id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div>
                         </div>
                      </td>
                   </tr>
                   <tr >
                      <td>
-                        <div class="row">
-                           <div class="label2">' . $plugin->get_lang('AssignedTo') . ':</div>
-                           <div class="formw2">' . $select_admins . '</div>
+                        <div>
+                           <div class="label2">' . $plugin->get_lang('AssignedTo') . ': </div>
+                           <div class="formw2" style="margin-top: -5px;">' . $select_admins . '</div>
                         </div>
                      </td>
                      <td>
-                        <div class="row">
-                           <div class="label2">' . get_lang('Status') . ':</div>
-                           <div class="formw2">' . $select_status . '</div>
+                        <div>
+                           <div class="label3">' . get_lang('Status') . ':</div>
+                           <div class="formw2"  style="margin-top: -5px;">' . $select_status . '</div>
                         </div>
                      </td>
                      <td>
-                        <div class="row">
-                        <div class="row">
-                           <div class="label2">' . $plugin->get_lang('Priority') . ':</div>
+                        <div>
+                        <div>
+                           <div class="label3">' . $plugin->get_lang('Priority') . ': </div>
                            <div class="formw2">' . $select_priority . '</div>
                         </div>
                      </td>
                      <td>
-                        <div class="row">
-                           <div class="row">
-                              <div class="label2">' . $plugin->get_lang('Priority') . ':</div>
+                        <div>
+                           <div>
+                              <div class="label3">' . $plugin->get_lang('MessageStatus') . ': </div>
                               <div class="formw2">' . $select_unread . '</div>
                            </div>
                      </td>
                   </tr>
                   <tr>
-                  <td width="30%">
-                  <div class="row" >
-                  <div class="label2">' . get_lang('Course') . '</div>
+                  <td>
+                  <div >
+                  <div class="label2">' . get_lang('Course') . ': </div>
                   <div class="formw2">
-                  <input id="keyword_course" name="keyword_course" type="text"></div>
+                  <input id="keyword_course" style="width: 170px;" name="keyword_course" type="text"></div>
                   </div>
                   </td>
                   <td colspan= "3">
-                  <div class="row">
+                  <div>
                   <button  name="submit_advanced" type="submit">' . get_lang('AdvancedSearch') . '</button>
                   </div>
                   </td>
@@ -291,6 +327,18 @@ if ($isAdmin) {
             <input name="_qf__advanced_search" type="hidden" value="">
             <div class="clear">&nbsp;</div>
          </form>';
+} else {
+    if ($plugin->getExtraSettingValue('allow_add') == 'true') {
+        echo '<div class="actions" >';
+        echo '<span style="float:right;">' .
+                '<a href="' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php">' .
+                    Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') . 
+                '</a>' .
+              '</span>';
+        echo '<span style="float:right;">' .
+        '</span>';
+        echo '</div>';
+    }
 }
 
 
@@ -320,4 +368,4 @@ if ($isAdmin) {
 }
 
 $table->display();
-Display::display_footer();
+Display::display_footer();

+ 337 - 285
plugin/ticket/src/new_ticket.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  * @package chamilo.plugin.ticket
@@ -6,21 +7,23 @@
 /**
  * INIT SECTION
  */
-$language_file = array('messages','userInfo', 'admin');
+$language_file = array('messages', 'userInfo', 'admin');
 $cidReset = true;
 require_once '../config.php';
 $plugin = TicketPlugin::create();
 
+if (!api_is_platform_admin() && $plugin->getExtraSettingValue('allow_add') != 'true') {
+    header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php');
+    exit;
+}
+
 api_block_anonymous_users();
-require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
-require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
+require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
 
-$htmlHeadXtra[]='
+$htmlHeadXtra[] = '
 <script>
-$(document).ready(function(){
-	document.getElementById("divEmail").style.display="none";
-});
-function load_course_list (div_course,my_user_id) {
+function load_course_list (div_course, my_user_id, user_email) {
 	 $.ajax({
 		contentType: "application/x-www-form-urlencoded",
 		type: "GET",
@@ -29,62 +32,61 @@ function load_course_list (div_course,my_user_id) {
 		success: function(datos) {
 			$("div#user_request").html(datos);		
 			$("#user_id_request").val(my_user_id);
+                        $("#personal_email").val(user_email);
 			$("#btnsubmit").attr("disabled", false);
 		}
 	});
 }
 function changeType() {
-var selected = document.getElementById("category_id").selectedIndex;
-var id = document.getElementById("category_id").options[selected].value  ;
-	document.getElementById("project_id").value= projects[id];
-	document.getElementById("other_area").value= other_area[id];
-	document.getElementById("email").value= email[id];
-	document.getElementById("divEmail").style.display="none";
+    var selected = document.getElementById("category_id").selectedIndex;
+    var id = $("#category_id").val();
+    $("#project_id").val(projects[id]);
+    $("#other_area").val(other_area[id]);
+    $("#email").val(email[id]);
 	if(parseInt(course_required[id]) == 0){
-		document.getElementById("divCourse").style.display="none";		
-		if( id != "CUR"){
-			document.getElementById("divEmail").style.display="";
-			document.getElementById("personal_email").required="required";	
-		}			
-		document.getElementById("course_id").disabled=true;	
-		document.getElementById("course_id").value=0;			
+            $("#divCourse").css("display", "none");		
+            if( id != "CUR"){
+                $("#divEmail").css("display", "block");
+                $("#personal_email").attr("required","required");
+            }			
+            $("#course_id").disabled = true;	
+            $("#course_id").value = 0;			
 	}else{	
-		document.getElementById("divCourse").style.display = "";
-		document.getElementById("course_id").disabled=false;
-		document.getElementById("course_id").value=0;
-		document.getElementById("personal_email").value="";
+            $("#divCourse").css("display", "block");
+            $("#course_id").prop("disabled", false);
+            $("#course_id").val(0);
 	}
 }
 function handleClick2(myRadio) {
-	var user_id = myRadio.value;
-	document.getElementById("user_id_request").value = user_id;
-	alert(document.getElementById("user_id_request").value);
+    var user_id = myRadio.value;
+    document.getElementById("user_id_request").value = user_id;
+    alert(document.getElementById("user_id_request").value);
 }
 function validate() {
-	var re  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; 
-	fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML();
-	document.getElementById("content").value= fckEditor1val;
-	var selected = document.getElementById("category_id").selectedIndex;
-	var id = document.getElementById("category_id").options[selected].value;
-	if(document.getElementById("user_id_request").value == ""){
-		alert("'.$plugin->get_lang("ValidUser").'");
-		return false;
-	}else if( id == 0){
-		alert("'.$plugin->get_lang("ValidType").'");
-		return false;
-	}else if(document.getElementById("subject").value == ""){
-		alert("'.$plugin->get_lang("ValidSubject").'");
-		return false;
-	}else if(parseInt(course_required[id]) == 1 && document.getElementById("course_id").value == 0){
-		alert("'.$plugin->get_lang("ValidCourse").'");
-		return false;
-	}else if(id !="CUR" && parseInt(course_required[id]) != 1  && !re.test(document.getElementById("personal_email").value)){
-		alert("'.$plugin->get_lang("ValidEmail").'");
-		return false;
-	}else if(fckEditor1val ==""){
-		alert("'.$plugin->get_lang("ValidMessage").'");
-		return false;
-	}
+    var re  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; 
+    fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML();
+    document.getElementById("content").value= fckEditor1val;
+    var selected = document.getElementById("category_id").selectedIndex;
+    var id = document.getElementById("category_id").options[selected].value;
+    if (document.getElementById("user_id_request").value == "") {
+            alert("' . $plugin->get_lang("ValidUser") . '");
+            return false;
+    } else if(id == 0) {
+            alert("' . $plugin->get_lang("ValidType") . '");
+            return false;
+    } else if(document.getElementById("subject").value == "") {
+            alert("' . $plugin->get_lang("ValidSubject") . '");
+            return false;
+    } else if(parseInt(course_required[id]) == 1 && document.getElementById("course_id").value == 0) {
+            alert("' . $plugin->get_lang("ValidCourse") . '");
+            return false;
+    } else if(id != "CUR" && parseInt(course_required[id]) != 1  && !re.test(document.getElementById("personal_email").value)) {
+            alert("' . $plugin->get_lang("ValidEmail") . '");
+            return false;
+    } else if(fckEditor1val == "") {
+            alert("' . $plugin->get_lang("ValidMessage") . '");
+            return false;
+    }
 }
 
 var counter_image = 1;
@@ -106,8 +108,7 @@ function add_image_form() {
 	filepaths.appendChild(elem1);
 	id_elem1 = "filepath_"+counter_image;
 	id_elem1 = "\'"+id_elem1+"\'";
-	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"'.api_get_path(WEB_CODE_PATH).'img/delete.gif\"></a>";
-	//document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<input type=\"text\" name=\"legend[]\" size=\"20\" />";
+	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif\"></a>";
 	if (filepaths.childNodes.length == 6) {
 		var link_attach = document.getElementById("link-more-attach");
 		if (link_attach) {
@@ -135,20 +136,21 @@ div.divTicket {
 </style>';
 $types = TicketManager::get_all_tickets_categories();
 $htmlHeadXtra[] = '<script language="javascript">
-		var projects = '.js_array($types,'projects','project_id'). '
-		var course_required = '.js_array($types,'course_required','course_required').'
-		var other_area = '.js_array($types,'other_area','other_area').'
-		var email = '.js_array($types,'email','email').'
+		var projects = ' . js_array($types, 'projects', 'project_id') . '
+		var course_required = ' . js_array($types, 'course_required', 'course_required') . '
+		var other_area = ' . js_array($types, 'other_area', 'other_area') . '
+		var email = ' . js_array($types, 'email', 'email') . '
 		 </script>';
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
-$htmlHeadXtra[] = '<link  href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
+$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
+$htmlHeadXtra[] = '<link  href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
 
 /**
  * @param $s
  * @return string
  */
-function js_str($s) {
-	return '"'.addcslashes($s, "\0..\37\"\\").'"';
+function js_str($s)
+{
+    return '"' . addcslashes($s, "\0..\37\"\\") . '"';
 }
 
 /**
@@ -157,143 +159,156 @@ function js_str($s) {
  * @param $key
  * @return string
  */
-function js_array($array,$name,$key) {
-	$temp=array();
-	$return = "new Array(); ";
-	foreach ($array as $value){
-		$return .= $name."['".$value['category_id']."'] ='".$value[$key]."'; ";
-	}
-	return $return;
+function js_array($array, $name, $key)
+{
+    $temp = array();
+    $return = "new Array(); ";
+    foreach ($array as $value) {
+        $return .= $name . "['" . $value['category_id'] . "'] ='" . $value[$key] . "'; ";
+    }
+    return $return;
 }
 
 /**
  *
  */
-function show_form_send_ticket(){
-	global $types, $plugin;
-	echo '<div class="divTicket">';
-	echo '<form enctype="multipart/form-data" action="'.api_get_self().'" method="post" name="send_ticket" id="send_ticket"
+function show_form_send_ticket()
+{
+    global $types, $plugin;
+    echo '<div class="divTicket">';
+    echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket"
  	onsubmit="return validate()" style="width:100%">';
-	echo '<input name="user_id_request" id="user_id_request" type="hidden" value="">';
-	
-	// Category
-	$select_types = '<div class="row">
-	<div class="label2">'.get_lang('Category').': </div>
+    echo '<input name="user_id_request" id="user_id_request" type="hidden" value="">';
+
+    // Category
+    $select_types = '<div class="row">
+	<div class="label2">' . get_lang('Category') . ': </div>
        <div class="formw2">';
-	$select_types .= '<select style="width: 95%; "   name = "category_id" id="category_id" onChange="changeType();">';
-	$select_types .= '<option value="0">---'.get_lang('Select').'---</option>';
-	foreach ($types as $type) {
-		$select_types.= "<option value = '".$type['category_id']."'>".$type['name'].":  <br/>".$type['description']."</option>";
-	}
-	$select_types .= "</select>";
-	$select_types .= '</div></div>';
-	echo $select_types;
-	
-	// Course
-	$courses_list = CourseManager::get_courses_list_by_user_id($user_id,false,true);
-	 $select_course = '<div id="user_request" >
+    $select_types .= '<select style="width: 95%; "   name = "category_id" id="category_id" onChange="changeType();">';
+    $select_types .= '<option value="0">---' . get_lang('Select') . '---</option>';
+    foreach ($types as $type) {
+        $select_types.= "<option value = '" . $type['category_id'] . "'>" . $type['name'] . ":  <br/>" . $type['description'] . "</option>";
+    }
+    $select_types .= "</select>";
+    $select_types .= '</div></div>';
+    echo $select_types;
+
+    // Course
+    $courses_list = CourseManager::get_courses_list_by_user_id($user_id, false, true);
+    $select_course = '<div id="user_request" >
 	 </div>';
-	echo $select_course;
-	
-	// Status
-	$status = array();
-	$status[NEWTCK] = $plugin->get_lang('StsNew');
-	$status[PENDING] = $plugin->get_lang('StsPending');
-	$status[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed');
-	$status[CLOSE] = $plugin->get_lang('StsClose');
-	$status[REENVIADO] = $plugin->get_lang('StsReenviado');
-	$select_status = '
-	<div class="row"  >
-		<div class="label2"  >'.get_lang('Status').': </div>
+    echo $select_course;
+
+    // Status
+    $status = array();
+    $status[NEWTCK] = $plugin->get_lang('StsNew');
+    $showStatus = "style='display: none;'";
+    if (api_is_platform_admin()) {
+        $showStatus = "";
+        $status[PENDING] = $plugin->get_lang('StsPending');
+        $status[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed');
+        $status[CLOSE] = $plugin->get_lang('StsClose');
+        $status[REENVIADO] = $plugin->get_lang('StsReenviado');
+    }
+    $select_status = '
+	<div class="row" ' . $showStatus . ' >
+		<div class="label2"  >' . get_lang('Status') . ': </div>
 		<div class="formw2">
 			<select style="width: 95%; " name = "status_id" id="status_id">';
-	//$status = TicketManager::get_all_tickets_status();
-	foreach ($status as $sts_key => $sts_name) {
-		if($sts_key=='PND'){
-			$select_status .=  "<option value = '".$sts_key."' selected >".$sts_name."</option>";
-		}else{
-			$select_status.= "<option value = '".$sts_key."'>".$sts_name."</option>";
-		}
-	}
-	$select_status .= '
+    //$status = TicketManager::get_all_tickets_status();
+    foreach ($status as $sts_key => $sts_name) {
+        if ($sts_key == 'PND') {
+            $select_status .= "<option value = '" . $sts_key . "' selected >" . $sts_name . "</option>";
+        } else {
+            $select_status.= "<option value = '" . $sts_key . "'>" . $sts_name . "</option>";
+        }
+    }
+    $select_status .= '
 			</select>
 		</div>
 	</div>';
-	echo $select_status;
-	
-	// Source
-	$source = array();
-	$source[SRC_EMAIL] = $plugin->get_lang('SrcEmail');
-	$source[SRC_PHONE] = $plugin->get_lang('SrcPhone');
-	$source[SRC_PRESC] = $plugin->get_lang('SrcPresential');
-	$select_source = '
-	<div class="row">
-	<div class="label2">'.$plugin->get_lang('Source').':</div>
+    echo $select_status;
+
+    // Source
+    $source = array();
+    if (api_is_platform_admin()) {
+        $showBlock = "";
+        $source[SRC_EMAIL] = $plugin->get_lang('SrcEmail');
+        $source[SRC_PHONE] = $plugin->get_lang('SrcPhone');
+        $source[SRC_PRESC] = $plugin->get_lang('SrcPresential');
+    } else {
+        $showBlock = "style='display: none;'";
+        $source[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform');
+    }
+    
+    $select_source = '
+	<div class="row" ' . $showBlock . '>
+	<div class="label2">' . $plugin->get_lang('Source') . ':</div>
        <div class="formw2">
 			<select style="width: 95%; " name="source_id" id="source_id" >';
-	foreach ($source as $src_key => $src_name) {
-		$select_source.= "<option value = '".$src_key."'>".$src_name."</option>";
-	}
-	$select_source .='
+    foreach ($source as $src_key => $src_name) {
+        $select_source.= "<option value = '" . $src_key . "'>" . $src_name . "</option>";
+    }
+    $select_source .='
 			</select>
 		</div>
 	</div>';
-	echo $select_source;
-	
-	// Subject
-	echo '<div class="row" ><div class ="label2">'.get_lang('Subject').':</div>
+    echo $select_source;
+
+    // Subject
+    echo '<div class="row" ><div class ="label2">' . get_lang('Subject') . ':</div>
        		<div class="formw2"><input type = "text" id ="subject" name="subject" value="" required ="" style="width:94%"/></div>
 		  </div>';
-	
-	// Email
-	echo '<div class="row" id="divEmail" ><div class ="label2">'.$plugin->get_lang('PersonalEmail').':</div>
+
+    // Email
+    echo '<div class="row" id="divEmail" ><div class ="label2">' . $plugin->get_lang('PersonalEmail') . ':</div>
        		<div class="formw2"><input type = "email" id ="personal_email" name="personal_email" value=""  style="width:94%"/></div>
 		  </div>';
-	echo '<input name="project_id" id="project_id" type="hidden" value="">';
-	echo '<input name="other_area" id="other_area" type="hidden" value="">';
-	echo '<input name="email" id="email" type="hidden" value="">';
-	
-	// Message
-	echo '<div class="row">
-		<div class="label2">'.get_lang('Message').'</div>
+    echo '<input name="project_id" id="project_id" type="hidden" value="">';
+    echo '<input name="other_area" id="other_area" type="hidden" value="">';
+    echo '<input name="email" id="email" type="hidden" value="">';
+
+    // Message
+    echo '<div class="row">
+		<div class="label2">' . get_lang('Message') . '</div>
 		<div class="formw2">
 			<input type="hidden" id="content" name="content" value="" style="display:none">
-		<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [  [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [  ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS=/main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS=/main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref='.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none">
+		<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [  [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [  ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS=/main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS=/main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none">
 		<iframe id="content___Frame" src="/main/inc/lib/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Messages" width="95%" height="250" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border: 0px; background-color: transparent; background-image: none; width: 95%; height: 250px;">
 		</iframe>
 		</div>
 	</div>';
-	
-	// Phone
-	echo '<div class="row" ><div class ="label2">'.get_lang('Phone').' ('.$plugin->get_lang('Optional').'):</div>
-       		<div class="formw2"><input type = "text" id ="phone" name="phone" value="" onkeyup="valid(this,'."'allowspace'".')" onblur="valid(this,'."'allowspace'".')" style="width:94%"/></div>
+
+    // Phone
+    echo '<div class="row" ><div class ="label2">' . get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . '):</div>
+       		<div class="formw2"><input type = "text" id ="phone" name="phone" value="" style="width:94%"/></div>
 		  </div>';
-	
-	// Priority
-	$select_priority = '<div class="row"  >
-	<div class="label2"  >'.$plugin->get_lang('Priority').': </div>
+
+    // Priority
+    $select_priority = '<div class="row"  >
+	<div class="label2"  >' . $plugin->get_lang('Priority') . ': </div>
 	<div class="formw2">';
-	
-	$priority = array();
-	$priority[NORMAL] = $plugin->get_lang('PriorityNormal');
-	$priority[HIGH] = $plugin->get_lang('PriorityHigh');
-	$priority[LOW] = $plugin->get_lang('PriorityLow');
-	
-	$select_priority .= '<select style="width: 85px; " name = "priority_id" id="priority_id">';
-	foreach ($priority as $prty_key => $prty_name) {
-		if($sts_key== NORMAL){
-			$select_priority .=  "<option value = '".$prty_key."' selected >".$prty_name."</option>";
-		}else{
-			$select_priority.= "<option value = '".$prty_key."'>".$prty_name."</option>";
-		}
-	}
-	$select_priority .= "</select>";
-	$select_priority .= '</div></div>';
-	echo $select_priority;
-	
-	// Input file attach
-	echo '<div class="row">
-		<div class="label2">'.get_lang('FilesAttachment').'</div>
+
+    $priority = array();
+    $priority[NORMAL] = $plugin->get_lang('PriorityNormal');
+    $priority[HIGH] = $plugin->get_lang('PriorityHigh');
+    $priority[LOW] = $plugin->get_lang('PriorityLow');
+
+    $select_priority .= '<select style="width: 85px; " name = "priority_id" id="priority_id">';
+    foreach ($priority as $prty_key => $prty_name) {
+        if ($sts_key == NORMAL) {
+            $select_priority .= "<option value = '" . $prty_key . "' selected >" . $prty_name . "</option>";
+        } else {
+            $select_priority.= "<option value = '" . $prty_key . "'>" . $prty_name . "</option>";
+        }
+    }
+    $select_priority .= "</select>";
+    $select_priority .= '</div></div>';
+    echo $select_priority;
+
+    // Input file attach
+    echo '<div class="row">
+		<div class="label2">' . get_lang('FilesAttachment') . '</div>
 		<div class="formw2">
 				<span id="filepaths">
 				<div id="filepath_1">
@@ -301,67 +316,85 @@ function show_form_send_ticket(){
 				</div></span>
 		</div>
 	</div>';
-	echo '<div class="row">
+    echo '<div class="row">
 		<div class="formw2">
 			<span id="link-more-attach">
-				<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;
-					('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')
+				<a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span>&nbsp;
+					(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')
 			</div>
 		</div>';
-	echo '<div class="row">
+    echo '<div class="row">
 		<div class="label2">
 		</div>
-		<div class="formw2"><button class="save" name="compose"  type="submit" id="btnsubmit">'.get_lang('SendMessage').'</button>
+		<div class="formw2"><button class="save" name="compose"  type="submit" id="btnsubmit">' . get_lang('SendMessage') . '</button>
 		</div>
 	</div>';
-	echo '</form></div>';
+    echo '</form></div>';
 }
 
 /**
  *
  */
-function save_ticket(){
-	global $plugin;
-	$category_id	= $_POST['category_id'];
-	$content		= $_POST['content'];
-	if ($_POST['phone']!="")	$content.=	'<p style="color:red">&nbsp;'.get_lang('Phone').': '.$_POST['phone'].'</p>';
-	$course_id		= $_POST['course_id'];
-	$project_id		= $_POST['project_id'];
-	$subject		= $_POST['subject'];
-	$other_area		= (int)$_POST['other_area'];
-	$email			= $_POST['email'];
-	$personal_email	= $_POST['personal_email'];
-	$source 		= $_POST['source_id'];
-	$user_id		= $_POST['user_id_request'];
-	$priority       = $_POST['priority_id'];
-	$status			= $_POST['status_id'];
-	$file_attachments =	$_FILES;
-	if(TicketManager::insert_new_ticket($category_id, $course_id, $project_id, $other_area, $email, $subject, $content,$personal_email, $file_attachments,$source,$priority,$status,$user_id,api_get_user_id())){
-		header('location:'.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/myticket.php?message=success');
-	}else{
-		Display::display_header(get_lang('ComposeMessage'));
-		Display::display_error_message($plugin->get_lang('ErrorRegisterMessage'));
-	}
+function save_ticket()
+{
+    global $plugin;
+    $category_id = $_POST['category_id'];
+    $content = $_POST['content'];
+    if ($_POST['phone'] != "") {
+        $content .= '<p style="color:red">&nbsp;' . get_lang('Phone') . ': ' . $_POST['phone'] . '</p>';
+    }
+    $course_id = $_POST['course_id'];
+    $project_id = $_POST['project_id'];
+    $subject = $_POST['subject'];
+    $other_area = (int) $_POST['other_area'];
+    $email = $_POST['email'];
+    $personal_email = $_POST['personal_email'];
+    $source = $_POST['source_id'];
+    $user_id = $_POST['user_id_request'];
+    $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, $course_id, $project_id, 
+            $other_area, $email, $subject, $content, 
+            $personal_email, $file_attachments, 
+            $source, $priority, $status, $user_id, 
+            $responsible)) {
+        header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php?message=success');
+    } else {
+        Display::display_header(get_lang('ComposeMessage'));
+        Display::display_error_message($plugin->get_lang('ErrorRegisterMessage'));
+    }
 }
+
 /**
  * Get the total number of users on the platform
  * @see SortableTable#get_total_number_of_items()
  */
-function get_number_of_users() {
-	$user_table = Database :: get_main_table(TABLE_MAIN_USER);
-	$sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM $user_table u";
+function get_number_of_users()
+{
+    $user_table = Database :: get_main_table(TABLE_MAIN_USER);
+    $sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM $user_table u";
     if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) {
-    	$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
-    	$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+        $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
     }
-	if ( isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string(trim($_GET['keyword']));
-		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%'  OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%'  OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%') ";
-	}
-	$res = Database::query($sql);
-	$obj = Database::fetch_object($res);
-	return $obj->total_number_of_items;
+    if (isset($_GET['keyword'])) {
+        $keyword = Database::escape_string(trim($_GET['keyword']));
+        $sql .= " WHERE (u.firstname LIKE '%$keyword%' OR 
+                  u.lastname LIKE '%$keyword%'  OR 
+                  concat(u.firstname,' ',u.lastname) LIKE '%$keyword%'  OR 
+                  concat(u.lastname,' ',u.firstname) LIKE '%$keyword%' OR 
+                  u.username LIKE '%$keyword%' OR 
+                  u.email LIKE '%$keyword%'  OR 
+                  u.official_code LIKE '%$keyword%') ";
+    }
+    $res = Database::query($sql);
+    $obj = Database::fetch_object($res);
+    return $obj->total_number_of_items;
 }
+
 /**
  * Get the users to display on the current page (fill the sortable-table)
  * @param   int     offset of first user to recover
@@ -372,95 +405,114 @@ function get_number_of_users() {
  */
 function get_user_data($from, $number_of_items, $column, $direction)
 {
-	$user_table = Database :: get_main_table(TABLE_MAIN_USER);
-	$admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
-	$sql = "SELECT
-                 u.user_id				AS col0,
-                 u.official_code		AS col2,
-				 ".(api_is_western_name_order()
-                 ? "u.firstname 			AS col3,
-                 u.lastname 			AS col4,"
-                 : "u.lastname 			AS col3,
-                 u.firstname 			AS col4,")."
-                 u.username				AS col5,
-                 u.email				AS col6,
-                 u.status				AS col7,
-                 u.active				AS col8,
-                 u.user_id				AS col9 ".
-                 ", u.expiration_date      AS exp ".
-            " FROM $user_table u ";
+    $user_table = Database :: get_main_table(TABLE_MAIN_USER);
+    $admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
+    
+    if (api_is_western_name_order()) {
+        $col34 = "u.firstname AS col3,
+                  u.lastname AS col4,";
+    } else {
+        $col34 = "u.lastname AS col3,
+                  u.firstname AS col4,";
+    }
+    
+    $sql = "SELECT
+                u.user_id AS col0,
+                u.official_code AS col2,
+        	$col34
+                u.username AS col5,
+                u.email AS col6,
+                u.status AS col7,
+                u.active AS col8,
+                u.user_id AS col9 , 
+                u.expiration_date AS exp
+            FROM $user_table u ";
 
-   	if (isset ($_GET['keyword']) ) {
-		$keyword = Database::escape_string(trim($_GET['keyword']));
-		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%' OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
-	} 
-    if (!in_array($direction, array('ASC','DESC'))) {
-    	$direction = 'ASC';
+    if (isset($_GET['keyword'])) {
+        $keyword = Database::escape_string(trim($_GET['keyword']));
+        $sql .= " WHERE (u.firstname LIKE '%$keyword%' OR 
+                  u.lastname LIKE '%$keyword%' OR 
+                  concat(u.firstname,' ',u.lastname) LIKE '%$keyword%' OR 
+                  concat(u.lastname,' ',u.firstname) LIKE '%$keyword%' OR  
+                  u.username LIKE '%$keyword%'  OR 
+                  u.official_code LIKE '%$keyword%' OR 
+                  u.email LIKE '%$keyword%' )";
+    }
+    if (!in_array($direction, array('ASC', 'DESC'))) {
+        $direction = 'ASC';
     }
     $column = intval($column);
-    $from 	= intval($from);
+    $from = intval($from);
     $number_of_items = intval($number_of_items);
 
-	$sql .= " ORDER BY col$column $direction ";
-	$sql .= " LIMIT $from,$number_of_items";
+    $sql .= " ORDER BY col$column $direction ";
+    $sql .= " LIMIT $from,$number_of_items";
 
-	$res = Database::query($sql);
+    $res = Database::query($sql);
 
-	$users = array ();
+    $users = array();
     $t = time();
-	while ($user = Database::fetch_row($res)) {
-		$image_path 	= UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
-		$user_profile 	= UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
-		if (!api_is_anonymous()) {
-			$photo = '<center><a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$user[0].'" title="'.get_lang('Info').'"><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2],$user[3]).'"  title="'.api_get_person_name($user[2], $user[3]).'" /></a></center>';
-		} else {
-			$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></center>';
-		}
-		$user_id= $user[0];
-        $button = '<a href="'.api_get_self().'?user_request='.$user[0].'">'.Display::return_icon('view_more_stats.gif', get_lang('Info')).'</a>';
-        $button= '<a  href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')">
-					<img onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')"  src="../../../main/img/view_more_stats.gif" title="'.get_lang('Courses').'" alt="'.get_lang('Courses').'"/>
-					</a>&nbsp;&nbsp;';
-        $users[] = array($photo,$user[1],$user[2],$user[3],$user[4],$user[5],$button);        
-	}
-	return $users;
+    while ($user = Database::fetch_row($res)) {
+        $user_id = $user[0];
+        $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
+        $user_profile = UserManager::get_picture_user($user_id, $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
+        if (!api_is_anonymous()) {
+            $photo = '<center><a href="' . api_get_path(WEB_PATH) . 'whoisonline.php?origin=user_list&id=' . $user_id . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '"  title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
+        } else {
+            $photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
+        }
+        $button = '<a  href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ', \'' . $user[5] . '\')">'
+                    . Display::return_icon('view_more_stats.gif', get_lang('Info')) .
+                   '</a>&nbsp;&nbsp;';
+        $users[] = array($photo, $user_id, $user[2], $user[3], $user[4], $user[5], $button);
+    }
+    return $users;
 }
 
-
-
 if (!isset($_POST['compose'])) {
-    Display::display_header(get_lang('ComposeMessage'));
-    echo '
-<div class="actions">
-  <span style="float: right;">&nbsp;</span>
-  <form id="search_simple" name="search_simple" method="get" action="'.api_get_self().'" class="form-search">
-    <fieldset>
-    <span><label for="keyword">'.get_lang('langSearchAUser').': &nbsp;</label><input type="text" name="keyword" size="25"></span>
-    <span><button type="submit" name="submit" class="btn btn">'.get_lang('Search').'</button></span>
-    <div class="clear"></div>
-    </fieldset>
-  </form>
-</div>';
-    if (isset($_GET['keyword'])){
-        $table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
-        $table->set_header(0, '', false, 'width="18px"');
-        $table->set_header(0, get_lang('Photo'), false);
-        $table->set_header(1, get_lang('OfficialCode'));
-        if (api_is_western_name_order()) {
-            $table->set_header(2, get_lang('FirstName'));
-            $table->set_header(3, get_lang('LastName'));
-        } else {
-            $table->set_header(2, get_lang('LastName'));
-            $table->set_header(3, get_lang('FirstName'));
+     if (api_is_platform_admin()) {
+        Display::display_header(get_lang('ComposeMessage'));
+        echo '
+            <div class="actions">
+              <span style="float: right;">&nbsp;</span>
+              <form id="search_simple" name="search_simple" method="get" action="' . api_get_self() . '" class="form-search">
+                <fieldset>
+                <span><label for="keyword">' . get_lang('langSearchAUser') . ': &nbsp;</label><input type="text" name="keyword" size="25"></span>
+                <span><button type="submit" name="submit" class="btn btn">' . get_lang('Search') . '</button></span>
+                <div class="clear"></div>
+                </fieldset>
+              </form>
+            </div>';
+        if (isset($_GET['keyword'])) {
+            $table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
+            $table->set_header(0, '', false, 'width="18px"');
+            $table->set_header(0, get_lang('Photo'), false);
+            $table->set_header(1, get_lang('OfficialCode'));
+            if (api_is_western_name_order()) {
+                $table->set_header(2, get_lang('FirstName'));
+                $table->set_header(3, get_lang('LastName'));
+            } else {
+                $table->set_header(2, get_lang('LastName'));
+                $table->set_header(3, get_lang('FirstName'));
+            }
+            $table->set_header(4, get_lang('LoginName'));
+            $table->set_header(5, get_lang('Email'));
+            $table->set_header(6, get_lang('Action'));
+            $table->display();
         }
-        $table->set_header(4, get_lang('LoginName'));
-        $table->set_header(5, get_lang('Email'));
-        $table->set_header(6, get_lang('Action'));
-        $table->display();
-    }
-    //if(isset($_GET['user_request']))
+     } else {
+        $userInfo = api_get_user_info();
+        $htmlHeadXtra[] = "
+             <script>
+                $(document).ready(function(){
+                    load_course_list('div_{$userInfo['user_id']}', '{$userInfo['user_id']}', '{$userInfo['email']}');
+                });
+             </script>
+             ";
+        Display::display_header(get_lang('ComposeMessage'));
+     }
     show_form_send_ticket();
-}else{
+} else {
     save_ticket();
 }
 

+ 193 - 159
plugin/ticket/src/report.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  * @package chamilo.plugin.ticket
@@ -6,38 +7,38 @@
 /**
  * INIT SECTION
  */
-$language_file= array('messages','userInfo', 'admin','trad4all');
-$cidReset	= true;
+$language_file = array('messages', 'userInfo', 'admin', 'trad4all');
+$cidReset = true;
 require_once '../config.php';
 $plugin = TicketPlugin::create();
 
 api_block_anonymous_users();
-require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
-require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
+require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
 
-if(!api_is_allowed_to_edit()){
-	api_not_allowed();
+if (!api_is_allowed_to_edit()) {
+    api_not_allowed();
 }
 //$nameTools = api_xml_http_response_encode(get_lang('Soporte Virtual'));
-$this_section = 'Reportes';
+$this_section = 'Reports';
 unset($_SESSION['this_section']);
 
-$htmlHeadXtra[]='
+$htmlHeadXtra[] = '
 <script language="javascript">
 $(document).ready(function(){
-	 $( "#keyword_start_date_start" ).datepicker({ dateFormat: '."'yy-mm-dd'".' });
-   	$( "#keyword_start_date_end" ).datepicker({ dateFormat: '."'yy-mm-dd'".' });
+    $( "#keyword_start_date_start" ).datepicker({ dateFormat: ' . "'yy-mm-dd'" . ' });
+    $( "#keyword_start_date_end" ).datepicker({ dateFormat: ' . "'yy-mm-dd'" . ' });
 });
 function validate(){
-  if( $("#keyword_start_date_start").val() != "" &&  $("#keyword_start_date_end").val() != ""){
-   datestart = $("#keyword_start_date_start").val();
-   dateend = $("#keyword_start_date_end").val();
-   dif = $.datepicker.parseDate("dd/mm/yy", datestart) -  $.datepicker.parseDate("dd/mm/yy", dateend);
-   if(dif > 0){
-	alert("La fecha final no puede ser mayor a la fecha inicial");
-   			return false;
-   			}
-  }
+    if( $("#keyword_start_date_start").val() != "" &&  $("#keyword_start_date_end").val() != ""){
+        datestart = $("#keyword_start_date_start").val();
+        dateend = $("#keyword_start_date_end").val();
+        dif = $.datepicker.parseDate("dd/mm/yy", datestart) -  $.datepicker.parseDate("dd/mm/yy", dateend);
+        if(dif > 0){
+            alert("La fecha final no puede ser mayor a la fecha inicial");
+            return false;
+        }
+    }
 }
 function load_course_list (div_course,my_user_id) {
 	 $.ajax({
@@ -62,99 +63,115 @@ div.row div.formw2 {
     width:90%;
 	float:left
 }
-div.formulario {
+div.ticket-form {
     width: 70%;
-	float: center;
-	margin-left: 15%;
+    float: center;
+    margin-left: 15%;
 	
 }
 
 </style>';
 $types = TicketManager::get_all_tickets_categories();
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
-$htmlHeadXtra[] = '<link  href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
+$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
+$htmlHeadXtra[] = '<link  href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
 $tools = array();
-$tools['todas']= array('id'=>'','name'=>get_lang('Todas'));
-$tools['announcement']= array('id'=>'announcement','name'=>get_lang('Announcement'));
+$tools['todas'] = array('id' => '', 'name' => get_lang('Todas'));
+$tools['announcement'] = array('id' => 'announcement', 'name' => get_lang('Announcement'));
 // $tools[]= array('id'=>'assignment','name'=>get_lang('Assignment'));
-$tools['calendar_event']= array('id'=>'calendar_event','name'=>get_lang('Calendar_event'));
-$tools['chat']= array('id'=>'chat','name'=>get_lang('Chat'));
-$tools['conference']= array('id'=>'conference','name'=>get_lang('Conference'));
-$tools['course_description']= array('id'=>'course_description','name'=>get_lang('Course_description'));
-$tools['document']= array('id'=>'document','name'=>get_lang('Document'));
-$tools['dropbox']= array('id'=>'dropbox','name'=>get_lang('Dropbox'));
-$tools['group']= array('id'=>'group','name'=>get_lang('Group'));
-$tools['learnpath']= array('id'=>'learnpath','name'=>get_lang('Learnpath'));
-$tools['link']= array('id'=>'link','name'=>get_lang('Link'));
-$tools['quiz']= array('id'=>'quiz','name'=>get_lang('Quiz'));
-$tools['student_publication']= array('id'=>'student_publication','name'=>get_lang('Student_publication'));
-$tools['user']= array('id'=>'user','name'=>get_lang('User'));
-$tools['forum']= array('id'=>'forum','name'=>get_lang('Forum'));
-
-function js_str($s) {
-	return '"'.addcslashes($s, "\0..\37\"\\").'"';
+$tools['calendar_event'] = array('id' => 'calendar_event', 'name' => get_lang('Calendar_event'));
+$tools['chat'] = array('id' => 'chat', 'name' => get_lang('Chat'));
+$tools['conference'] = array('id' => 'conference', 'name' => get_lang('Conference'));
+$tools['course_description'] = array('id' => 'course_description', 'name' => get_lang('Course_description'));
+$tools['document'] = array('id' => 'document', 'name' => get_lang('Document'));
+$tools['dropbox'] = array('id' => 'dropbox', 'name' => get_lang('Dropbox'));
+$tools['group'] = array('id' => 'group', 'name' => get_lang('Group'));
+$tools['learnpath'] = array('id' => 'learnpath', 'name' => get_lang('Learnpath'));
+$tools['link'] = array('id' => 'link', 'name' => get_lang('Link'));
+$tools['quiz'] = array('id' => 'quiz', 'name' => get_lang('Quiz'));
+$tools['student_publication'] = array('id' => 'student_publication', 'name' => get_lang('Student_publication'));
+$tools['user'] = array('id' => 'user', 'name' => get_lang('User'));
+$tools['forum'] = array('id' => 'forum', 'name' => get_lang('Forum'));
+/**
+ * Returns the escaped string.
+ * @param string $s
+ * @return string
+ */
+function js_str($s)
+{
+    return '"' . addcslashes($s, "\0..\37\"\\") . '"';
 }
-
-function show_form(){
-	global $types; 
-	global $tools;
-	echo '<div class="formulario">';
-	echo '<form enctype="multipart/form-data" action="'.api_get_self().'" method="post" name="send_ticket" id="send_ticket"
+/**
+ * This function is to show the ticket form
+ * @global array $tools
+ */
+function show_form()
+{
+    global $tools;
+    echo '<div class="ticket-form">';
+    echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket"
  	onsubmit="return validate()" style="width:100%">';
-	
-	$courses_list = CourseManager::get_courses_list_by_user_id($user_id,false,true);
-	 $select_course = '<div id="user_request" >
+
+    $courses_list = CourseManager::get_courses_list_by_user_id($user_id, false, true);
+    $select_course = '<div id="user_request" >
 	 </div>';
-	echo $select_course;
-	//select status
-	$select_tool = '<div class="row"  >
-	<div class="label2"  >Herramienta:</div>
+    echo $select_course;
+    //select status
+    $select_tool = '<div class="row"  >
+	<div class="label2"  >' . get_lang('Tool') .':</div>
 	<div class="formw2">';
-	$select_tool .= '<select style="width: 95%; " name = "tool" id="tool" >';
-	$status = TicketManager::get_all_tickets_status();
-	foreach ($tools as $tool) {
-			$select_tool .=  "<option value = '".$tool['id']."' selected >".$tool['name']."</option>";
-	}
-	$select_tool .= "</select>";
-	$select_tool .= '</div></div>';
-	echo $select_tool;
-	echo '<div class="row">
-			<div class="label2">Desde:</div>
-			<div class="formw2"><input id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div>
-		  </div>
-			<div class="row">
-			<div class="label2">Hasta</div>
-			<div class="formw2"><input id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div>
-			</div>';
-	echo '</div>';
-	echo '<div class="row">
+    $select_tool .= '<select style="width: 95%; " name = "tool" id="tool" >';
+    
+    foreach ($tools as $tool) {
+        $select_tool .= "<option value = '" . $tool['id'] . "' selected >" . $tool['name'] . "</option>";
+    }
+    $select_tool .= "</select>";
+    $select_tool .= '</div></div>';
+    echo $select_tool;
+    echo '<div class="row">
+	      <div class="label2">' . get_lang('From') . ':</div>
+              <div class="formw2"><input id="keyword_start_date_start" name="keyword_start_date_start" type="text"></div>
+          </div>
+	  <div class="row">
+	      <div class="label2"> ' . get_lang('To') . '</div>
+	      <div class="formw2"><input id="keyword_start_date_end" name="keyword_start_date_end" type="text"></div>
+	  </div>';
+    echo '</div>';
+    echo '<div class="row">
 		<div class="label2">
 		</div>
 		<div class="formw2">	
-			<button class="save" name="report" type="submit" id="btnsubmit" disabled="disabled">Generar Reporte</button>
+			<button class="save" name="report" type="submit" id="btnsubmit" disabled="disabled">' . get_lang('CompleteReport') .'</button>
 		</div>
 	</div>';
-	
 }
+
 /**
  * Get the total number of users on the platform
  * @see SortableTable#get_total_number_of_items()
  */
-function get_number_of_users() {
-	$user_table = Database :: get_main_table(TABLE_MAIN_USER);
-	$sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM $user_table u";
+function get_number_of_users()
+{
+    $user_table = Database :: get_main_table(TABLE_MAIN_USER);
+    $sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM $user_table u";
     if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) {
-    	$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
-    	$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+        $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
     }
-	if ( isset ($_GET['keyword'])) {
-		$keyword = Database::escape_string(trim($_GET['keyword']));
-		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%'  OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%'  OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%') ";
-	}
-	$res = Database::query($sql);
-	$obj = Database::fetch_object($res);
-	return $obj->total_number_of_items;
+    if (isset($_GET['keyword'])) {
+        $keyword = Database::escape_string(trim($_GET['keyword']));
+        $sql .= " WHERE (u.firstname LIKE '%$keyword%' OR 
+                  u.lastname LIKE '%$keyword%'  OR 
+                  concat(u.firstname,' ',u.lastname) LIKE '%$keyword%' OR 
+                  concat(u.lastname,' ',u.firstname) LIKE '%$keyword%' OR 
+                  u.username LIKE '%$keyword%' OR 
+                  u.email LIKE '%$keyword %'  OR 
+                  u.official_code LIKE '%$keyword%') ";
+    }
+    $res = Database::query($sql);
+    $obj = Database::fetch_object($res);
+    return $obj->total_number_of_items;
 }
+
 /**
  * Get the users to display on the current page (fill the sortable-table)
  * @param   int     offset of first user to recover
@@ -165,71 +182,79 @@ function get_number_of_users() {
  */
 function get_user_data($from, $number_of_items, $column, $direction)
 {
-	$user_table = Database :: get_main_table(TABLE_MAIN_USER);
-	$admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
-	$sql = "SELECT
-                 u.user_id				AS col0,
-                 u.official_code		AS col2,
-				 ".(api_is_western_name_order()
-                 ? "u.firstname 			AS col3,
-                 u.lastname 			AS col4,"
-                 : "u.lastname 			AS col3,
-                 u.firstname 			AS col4,")."
-                 u.username				AS col5,
-                 u.email				AS col6,
-                 u.status				AS col7,
-                 u.active				AS col8,
-                 u.user_id				AS col9 ".
-                 ", u.expiration_date      AS exp ".
-            " FROM $user_table u ";
+    $user_table = Database :: get_main_table(TABLE_MAIN_USER);
+    $admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
+    
+    if (api_is_western_name_order()) {
+        $col34 = "u.firstname AS col3,
+                  u.lastname AS col4,";
+    } else {
+        $col34 = "u.lastname AS col3,
+                  u.firstname AS col4,";
+    }
+    
+    $sql = "SELECT
+                 u.user_id AS col0, 
+                 u.official_code AS col2, 
+		 $col34 
+                 u.username AS col5, 
+                 u.email AS col6, 
+                 u.status AS col7, 
+                 u.active AS col8, 
+                 u.user_id AS col9, 
+              u.expiration_date AS exp 
+           FROM $user_table u ";
 
-   	if (isset ($_GET['keyword']) ) {
-		$keyword = Database::escape_string(trim($_GET['keyword']));
-		$sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%' OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%'  OR u.official_code LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
-	} 
-    if (!in_array($direction, array('ASC','DESC'))) {
-    	$direction = 'ASC';
+    if (isset($_GET['keyword'])) {
+        $keyword = Database::escape_string(trim($_GET['keyword']));
+        $sql .= " WHERE (u.firstname LIKE '%$keyword%' OR
+                  u.lastname LIKE '%$keyword%' OR 
+                  concat(u.firstname,' ',u.lastname) LIKE '%$keyword%' OR 
+                  concat(u.lastname,' ',u.firstname) LIKE '%$keyword%' OR 
+                  u.username LIKE '%$keyword%'  OR 
+                  u.official_code LIKE '%$keyword%' 
+                  OR u.email LIKE '%$keyword%' )";
+    }
+    if (!in_array($direction, array('ASC', 'DESC'))) {
+        $direction = 'ASC';
     }
     $column = intval($column);
-    $from 	= intval($from);
+    $from = intval($from);
     $number_of_items = intval($number_of_items);
 
-	$sql .= " ORDER BY col$column $direction ";
-	$sql .= " LIMIT $from,$number_of_items";
+    $sql .= " ORDER BY col$column $direction ";
+    $sql .= " LIMIT $from,$number_of_items";
 
-	$res = Database::query($sql);
+    $res = Database::query($sql);
 
-	$users = array ();
-    $t = time();
-	while ($user = Database::fetch_row($res)) {
-		$image_path 	= UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
-		$user_profile 	= UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
-		if (!api_is_anonymous()) {
-			$photo = '<center><a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$user[0].'" title="'.get_lang('Info').'"><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2],$user[3]).'"  title="'.api_get_person_name($user[2], $user[3]).'" /></a></center>';
-		} else {
-			$photo = '<center><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" /></center>';
-		}
-		$user_id= $user[0];
-        $button = '<a href="'.api_get_self().'?user_request='.$user[0].'">'.Display::return_icon('view_more_stats.gif', get_lang('Info')).'</a>';
-        $button= '<a  href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')">
-					<img onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')"  src="../../../main/img/view_more_stats.gif" title="'.get_lang('Courses').'" alt="'.get_lang('Courses').'"/>
+    $users = array();
+    while ($user = Database::fetch_row($res)) {
+        $image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true);
+        $user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" ');
+        if (!api_is_anonymous()) {
+            $photo = '<center><a href="' . api_get_path(WEB_PATH) . 'whoisonline.php?origin=user_list&id=' . $user[0] . '" title="' . get_lang('Info') . '"><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '"  title="' . api_get_person_name($user[2], $user[3]) . '" /></a></center>';
+        } else {
+            $photo = '<center><img src="' . $user_profile['file'] . '" ' . $user_profile['style'] . ' alt="' . api_get_person_name($user[2], $user[3]) . '" title="' . api_get_person_name($user[2], $user[3]) . '" /></center>';
+        }
+        $user_id = $user[0];
+        $button = '<a href="' . api_get_self() . '?user_request=' . $user[0] . '">' . Display::return_icon('view_more_stats.gif', get_lang('Info')) . '</a>';
+        $button = '<a  href="javascript:void(0)" onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')">
+					<img onclick="load_course_list(\'div_' . $user_id . '\',' . $user_id . ')"  src="../../../main/img/view_more_stats.gif" title="' . get_lang('Courses') . '" alt="' . get_lang('Courses') . '"/>
 					</a>&nbsp;&nbsp;';
-        $users[] = array($photo,$user[1],$user[2],$user[3],$user[4],$user[5],$button);        
-	}
-	return $users;
+        $users[] = array($photo, $user[1], $user[2], $user[3], $user[4], $user[5], $button);
+    }
+    return $users;
 }
 
-
-
-Display::display_header('Reportes');
+Display::display_header('Reports');
 echo '<div class="actions">
-    <form action="'.api_get_self().'" method="get" name="search_simple" id="search_simple">
+    <form action="' . api_get_self() . '" method="get" name="search_simple" id="search_simple">
         <input name="user_id_request" id="user_id_request" type="hidden" value="">
         <span><label for="keyword">B&uacute;squeda del usuario: </label><input size="25" name="keyword" type="text" id="keyword"></span>
         <span><button class="search" name="submit" type="submit">Buscar</button></span>
         <div class="clear">&nbsp;</div>
     </form></div>';
-if (isset($_GET['keyword'])){
+if (isset($_GET['keyword'])) {
     $table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
     $table->set_header(0, '', false, 'width="18px"');
     $table->set_header(0, get_lang('Photo'), false);
@@ -252,42 +277,51 @@ if (isset($_POST['report'])) {
     $course_id = $_POST['course_id'];
     $tool = $_POST['tool'];
     $course_info = api_get_course_info_by_id($course_id);
-    $user_id =  $_POST['user_id_request'];
-    $sql ="SELECT  u.username , CONCAT(u.lastname, ' ', u.firstname) AS fullname, DATE_SUB(access.access_date,INTERVAL 5 HOUR) AS  access_date, c.title AS curso, access_tool AS herramienta
-            FROM  ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS)." access
-            LEFT JOIN  ".Database::get_main_table(TABLE_MAIN_USER)." u ON access.access_user_id = u.user_id
-            LEFT JOIN  ".Database::get_main_table(TABLE_MAIN_COURSE)." c ON access.access_cours_code = c.CODE
-            WHERE access.access_cours_code = '".$course_info['code']."' AND u.user_id = '$user_id' ";
-    if($tool!= '') $sql.="AND access.access_tool = '$tool' ";
+    $user_id = $_POST['user_id_request'];
+    $sql = "SELECT  
+                u.username , CONCAT(u.lastname, ' ', u.firstname) AS fullname, 
+                DATE_SUB(access.access_date,INTERVAL 5 HOUR) AS  access_date, 
+                c.title AS course, access_tool AS tool
+            FROM  " . Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS) . " access
+            LEFT JOIN  " . Database::get_main_table(TABLE_MAIN_USER) . " u ON access.access_user_id = u.user_id
+            LEFT JOIN  " . Database::get_main_table(TABLE_MAIN_COURSE) . " c ON access.access_cours_code = c.CODE
+            WHERE access.access_cours_code = '" . $course_info['code'] . "' AND u.user_id = '$user_id' ";
+    if ($tool != '') {
+        $sql.="AND access.access_tool = '$tool' ";
+    }
+    
     $start_date = $_POST['keyword_start_date_start'];
-    $end_date 	= $_POST['keyword_start_date_end'];
-    if ($start_date != '' || $end_date != ''){
+    $end_date = $_POST['keyword_start_date_end'];
+    
+    if ($start_date != '' || $end_date != '') {
         $sql .= " HAVING ";
-        if ($start_date != '') $sql .=  "  access_date >= '$start_date'   ";
+        if ($start_date != '')
+            $sql .= "  access_date >= '$start_date'   ";
         if ($end_date != '') {
-            $sql = ($start_date == '')?$sql:($sql." AND ");
-            $sql .=  "  access_date <= '$end_date'   ";
+            $sql = ($start_date == '') ? $sql : ($sql . " AND ");
+            $sql .= "  access_date <= '$end_date'   ";
         }
-
     }
     $result = Database::query($sql);
     $table_result = new SortableTable();
     $table_result->set_header(0, get_lang('User'), false);
     $table_result->set_header(1, get_lang('Fullname'), false);
-    $table_result->set_header(2, get_lang('Fecha'), false);
-    $table_result->set_header(3, get_lang('curso'), false);
-    $table_result->set_header(4, get_lang('Herramienta'), false);
-    while ($row = Database::fetch_assoc($result)){
-        $row = array(0 =>$row['username'],1 =>$row['fullname'],2 => $row['access_date'],3 =>$row['curso'],4 =>get_lang($tools[$row['herramienta']]['name']));
+    $table_result->set_header(2, get_lang('Date'), false);
+    $table_result->set_header(3, get_lang('Course'), false);
+    $table_result->set_header(4, get_lang('Tool'), false);
+    while ($row = Database::fetch_assoc($result)) {
+        $row = array(
+                $row['username'],
+                $row['fullname'],
+                $row['access_date'],
+                $row['course'],
+                get_lang($tools[$row['tool']]['name'])
+            );
         $table_result->addRow($row);
     }
     $table_result->display();
-
-
-}else{
+} else {
     show_form();
 }
 
-
-
 Display::display_footer();

+ 118 - 93
plugin/ticket/src/send_ticket.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  *
@@ -7,16 +8,16 @@
 /**
  * INIT SECTION
  */
-$language_file = array('messages','userInfo', 'admin');
+$language_file = array('messages', 'userInfo', 'admin');
 $cidReset = true;
 require_once '../config.php';
 $plugin = TicketPlugin::create();
 
 api_block_anonymous_users();
-require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
-require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
+require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
 
-$htmlHeadXtra[]='
+$htmlHeadXtra[] = '
 <script>
 $(document).ready(function(){
 	if(document.getElementById("divEmail")){
@@ -53,19 +54,19 @@ function validate() {
 	var selected = document.getElementById("category_id").selectedIndex;
 	var id = document.getElementById("category_id").options[selected].value;
 	if( id == 0){
-		alert("'.$plugin->get_lang("ValidType").'");
+		alert("' . $plugin->get_lang("ValidType") . '");
 		return false;
 	}else if(document.getElementById("subject").value == ""){
-		alert("'.$plugin->get_lang("ValidSubject").'");
+		alert("' . $plugin->get_lang("ValidSubject") . '");
 		return false;
 	}else if(parseInt(course_required[id]) == 1 && document.getElementById("course_id").value == 0){
-		alert("'.$plugin->get_lang("ValidCourse").'");
+		alert("' . $plugin->get_lang("ValidCourse") . '");
 		return false;
 	}else if(id !="CUR" && parseInt(course_required[id]) != 1  && !re.test(document.getElementById("personal_email").value)){
-		alert("'.$plugin->get_lang("ValidEmail").'");
+		alert("' . $plugin->get_lang("ValidEmail") . '");
 		return false;
 	}else if(fckEditor1val ==""){
-		alert("'.$plugin->get_lang("ValidMessage").'");
+		alert("' . $plugin->get_lang("ValidMessage") . '");
 		return false;
 	}
 }
@@ -89,8 +90,7 @@ function add_image_form() {
 	filepaths.appendChild(elem1);
 	id_elem1 = "filepath_"+counter_image;
 	id_elem1 = "\'"+id_elem1+"\'";
-	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"'.api_get_path(WEB_CODE_PATH).'img/delete.gif\"></a>";
-	//document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<input type=\"text\" name=\"legend[]\" size=\"20\" />";
+	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif\"></a>";
 	if (filepaths.childNodes.length == 6) {
 		var link_attach = document.getElementById("link-more-attach");
 		if (link_attach) {
@@ -128,79 +128,99 @@ div.divTicket {
 </style>';
 $types = TicketManager::get_all_tickets_categories();
 $htmlHeadXtra[] = '<script language="javascript">
-		var projects = '.js_array($types,'projects','project_id'). '
-		var course_required = '.js_array($types,'course_required','course_required').'
-		var other_area = '.js_array($types,'other_area','other_area').'
-		var email = '.js_array($types,'email','email').'
+		var projects = ' . js_array($types, 'projects', 'project_id') . '
+		var course_required = ' . js_array($types, 'course_required', 'course_required') . '
+		var other_area = ' . js_array($types, 'other_area', 'other_area') . '
+		var email = ' . js_array($types, 'email', 'email') . '
 		document.getElementById("divCourse").style.display="none";	
 		 </script>';
-$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
-$htmlHeadXtra[] = '<link  href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
+$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
+$htmlHeadXtra[] = '<link  href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
+
+/**
+ * @todo Delete this function, it already exists in report.php
+ * @param string $s
+ * @return string
+ */
 
-function js_str($s) {
-	return '"'.addcslashes($s, "\0..\37\"\\").'"';
+function js_str($s)
+{
+    return '"' . addcslashes($s, "\0..\37\"\\") . '"';
 }
 
-function js_array($array,$name,$key) {
-	$temp=array();
-	$return = "new Array(); ";
-	foreach ($array as $value){
-		$return .= $name."['".$value['category_id']."'] ='".$value[$key]."'; ";
-	}
-	return $return;
+/**
+ * This is a javascript helper to generate and array
+ * @param array $array
+ * @param string $name
+ * @param integer $key
+ * @return string
+ */
+function js_array($array, $name, $key)
+{
+    $return = "new Array(); ";
+    foreach ($array as $value) {
+        $return .= $name . "['" . $value['category_id'] . "'] ='" . $value[$key] . "'; ";
+    }
+    return $return;
 }
 
-function show_form_send_ticket(){
-	global $types, $plugin;
-	$courses_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(),false,true);
-	echo '<div class="divTicket">';
-	echo '<form enctype="multipart/form-data" action="'.api_get_self().'" method="post" name="send_ticket" id="send_ticket"
+/**
+ * 
+ * @global array $types
+ * @global object $plugin
+ */
+function show_form_send_ticket()
+{
+    global $types, $plugin;
+    $courses_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), false, true);
+    echo '<div class="divTicket">';
+    echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket"
  	onsubmit="return validate()" style="width:100%">';
-	$select_types = '<div class="row">
-	<div class="label2">'.get_lang('Category').': </div>
+    $select_types = '<div class="row">
+	<div class="label2">' . get_lang('Category') . ': </div>
        <div class="formw2">';
-	$select_types .= '<select style="width: 95%; "   name = "category_id" id="category_id" onChange="changeType();">';
-	$select_types .= '<option value="0">---'.get_lang('Select').'---</option>';
-	foreach ($types as $type) {
-		$select_types.= "<option value = '".$type['category_id']."'>".$type['name'].":  <br/>".$type['description']."</option>";
-	}
-	$select_types .= "</select>";
-	$select_types .= '</div></div>';
-	echo $select_types;
-	$select_course = '<div class="row" id="divCourse" >
-	<div class="label2"  >'.get_lang('Course').':</div>
+    $select_types .= '<select style="width: 95%; "   name = "category_id" id="category_id" onChange="changeType();">';
+    $select_types .= '<option value="0">---' . get_lang('Select') . '---</option>';
+    foreach ($types as $type) {
+        $select_types.= "<option value = '" . $type['category_id'] . "'>" . $type['name'] . ":  <br/>" . $type['description'] . "</option>";
+    }
+    $select_types .= "</select>";
+    $select_types .= '</div></div>';
+    echo $select_types;
+    $select_course = '<div class="row" id="divCourse" >
+	<div class="label2"  >' . get_lang('Course') . ':</div>
             <div class="formw2">';
-	$select_course .= '<select  class="chzn-select" name = "course_id" id="course_id"  style="width: 40%; display:none;">';
-	$select_course .= '<option value="0">---'.get_lang('Select').'---</option>';
-	foreach ($courses_list as $course) {
-		$select_course.= "<option value = '".$course['course_id']."'>".$course['title']."</option>";
-	}
-	$select_course .= "</select>";
-	$select_course .= '</div></div>';
-	echo $select_course;
-	echo '<div class="row" ><div class ="label2">'.get_lang('Subject').':</div>
+    $select_course .= '<select  class="chzn-select" name = "course_id" id="course_id"  style="width: 40%; display:none;">';
+    $select_course .= '<option value="0">---' . get_lang('Select') . '---</option>';
+    foreach ($courses_list as $course) {
+        $select_course.= "<option value = '" . $course['course_id'] . "'>" . $course['title'] . "</option>";
+    }
+    $select_course .= "</select>";
+    $select_course .= '</div></div>';
+    echo $select_course;
+    echo '<div class="row" ><div class ="label2">' . get_lang('Subject') . ':</div>
        		<div class="formw2"><input type = "text" id ="subject" name="subject" value="" required ="" style="width:94%"/></div>
 		  </div>';
-	echo '<div class="row" id="divEmail" ><div class ="label2">'.$plugin->get_lang('PersonalEmail').':</div>
+    echo '<div class="row" id="divEmail" ><div class ="label2">' . $plugin->get_lang('PersonalEmail') . ':</div>
        		<div class="formw2"><input type = "email" id ="personal_email" name="personal_email" value=""  style="width:94%"/></div>
 		  </div>';
-	echo '<input name="project_id" id="project_id" type="hidden" value="">';
-	echo '<input name="other_area" id="other_area" type="hidden" value="">';
-	echo '<input name="email" id="email" type="hidden" value="">';
-	echo '<div class="row">
-		<div class="label2">'.get_lang('Message').'</div>
+    echo '<input name="project_id" id="project_id" type="hidden" value="">';
+    echo '<input name="other_area" id="other_area" type="hidden" value="">';
+    echo '<input name="email" id="email" type="hidden" value="">';
+    echo '<div class="row">
+		<div class="label2">' . get_lang('Message') . '</div>
 		<div class="formw2">
 			<input type="hidden" id="content" name="content" value="" style="display:none">
-		<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [  [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [  ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS=/main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS=/main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref='.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none">
+		<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [  [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [  ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS=/main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS=/main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none">
 		<iframe id="content___Frame" src="/main/inc/lib/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Messages" width="95%" height="250" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border: 0px; background-color: transparent; background-image: none; width: 95%; height: 250px;">
 		</iframe>
 		</div>
 	</div>';
-	echo '<div class="row" ><div class ="label2">'.get_lang('Phone').' ('.$plugin->get_lang('Optional').'):</div>
-       		<div class="formw2"><input type = "text" id ="phone" name="phone" value="" onkeyup="valid(this,'."'allowspace'".')" onblur="valid(this,'."'allowspace'".')" style="width:94%"/></div>
+    echo '<div class="row" ><div class ="label2">' . get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . '):</div>
+       		<div class="formw2"><input type = "text" id ="phone" name="phone" value="" onkeyup="valid(this,' . "'allowspace'" . ')" onblur="valid(this,' . "'allowspace'" . ')" style="width:94%"/></div>
 		</div>';
-	echo '<div class="row">
-		<div class="label2">'.get_lang('FilesAttachment').'</div>
+    echo '<div class="row">
+		<div class="label2">' . get_lang('FilesAttachment') . '</div>
 		<div class="formw2">
 				<span id="filepaths">
 				<div id="filepath_1">
@@ -208,46 +228,51 @@ function show_form_send_ticket(){
 				</div></span>
 		</div>
 	</div>';
-	echo '<div class="row">
+    echo '<div class="row">
 		<div class="formw2">
 			<span id="link-more-attach">
-				<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;
-					('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')
+				<a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span>&nbsp;
+					(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')
 			</div>
 		</div>';
-	echo '<div class="row">
+    echo '<div class="row">
 		<div class="label2">
 		</div>
-		<div class="formw2"><button class="save" name="compose"  type="submit" id="btnsubmit">'.get_lang('SendMessage').'</button>
+		<div class="formw2"><button class="save" name="compose"  type="submit" id="btnsubmit">' . get_lang('SendMessage') . '</button>
 		</div>
 	</div>';
-	echo '</form></div>';
+    echo '</form></div>';
 }
-
-function save_ticket(){
-	$category_id	=	$_POST['category_id'];
-	$content		=	$_POST['content'];
-	if ($_POST['phone']!="")	$content.=	'<p style="color:red">&nbsp;'.get_lang('Phone').': '.$_POST['phone'].'</p>';
-	$course_id		=	$_POST['course_id'];
-	$project_id		=	$_POST['project_id'];
-	$subject		=	$_POST['subject'];
-	$other_area		=	(int)$_POST['other_area'];
-	$email			=	$_POST['email'];
-	$personal_email	= $_POST['personal_email'];
-	$file_attachments =	$_FILES;
-	if(TicketManager::insert_new_ticket($category_id, $course_id, $project_id, $other_area, $email, $subject, $content,$personal_email, $file_attachments)){
-		header('location:'.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/myticket.php?message=success');
-	}else{
-		Display::display_header(get_lang('ComposeMessage'));
-		Display::display_error_message($plugin->get_lang('ErrorRegisterMessage'));
-	}
+/**
+ * Save ticke function
+ */
+function save_ticket()
+{
+    global $plugin;
+    $category_id = $_POST['category_id'];
+    $content = $_POST['content'];
+    if ($_POST['phone'] != "")
+        $content.= '<p style="color:red">&nbsp;' . get_lang('Phone') . ': ' . $_POST['phone'] . '</p>';
+    $course_id = $_POST['course_id'];
+    $project_id = $_POST['project_id'];
+    $subject = $_POST['subject'];
+    $other_area = (int) $_POST['other_area'];
+    $email = $_POST['email'];
+    $personal_email = $_POST['personal_email'];
+    $file_attachments = $_FILES;
+    if (TicketManager::insert_new_ticket($category_id, $course_id, $project_id, $other_area, $email, $subject, $content, $personal_email, $file_attachments)) {
+        header('location:' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/src/myticket.php?message=success');
+    } else {
+        Display::display_header(get_lang('ComposeMessage'));
+        Display::display_error_message($plugin->get_lang('ErrorRegisterMessage'));
+    }
 }
 
-if(!isset($_POST['compose'])){
-	Display::display_header(get_lang('ComposeMessage'));
-	show_form_send_ticket();
-}else{
-	save_ticket();
+if (!isset($_POST['compose'])) {
+    Display::display_header(get_lang('ComposeMessage'));
+    show_form_send_ticket();
+} else {
+    save_ticket();
 }
 
-Display::display_footer();
+Display::display_footer();

Dosya farkı çok büyük olduğundan ihmal edildi
+ 275 - 256
plugin/ticket/src/ticket.class.php


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

@@ -6,7 +6,7 @@
 /**
  *
  */
-$language_file = array ('registration');
+$language_file = array('registration');
 require_once '../config.php';
 $plugin = TicketPlugin::create();
 
@@ -14,20 +14,20 @@ $ticket_id = intval($_POST['ticket_id']);
 $history = TicketManager::get_assign_log($ticket_id);
 ?>
 <table width="350px" border="0" cellspacing="2" cellpadding="2">
-<?php
-if (count($history)==0) {
-?>
-<tr>
-	<td colspan="2"><?php echo api_ucfirst(('Sin Historial')); ?></td>
-</tr>
-<?php
-}
-?>
-<?php for($k=0;$k<count($history);$k++) { ?>
-    <tr>
-        <td width="125px"><?php echo api_convert_encoding($history[$k]['assignuser'],'UTF-8',$charset);?></td>
-        <td width="100px"><?php echo api_convert_encoding($history[$k]['assigned_date'],'UTF-8',$charset);?></td>
-        <td width="125px"><?php echo api_convert_encoding($history[$k]['insertuser'],'UTF-8',$charset);?></td>
-    </tr>
-<?php }?>
+    <?php
+    if (count($history) == 0) {
+        ?>
+        <tr>
+            <td colspan="2"><?php echo api_ucfirst(('Sin Historial')); ?></td>
+        </tr>
+        <?php
+    }
+    ?>
+    <?php for ($k = 0; $k < count($history); $k++) { ?>
+        <tr>
+            <td width="125px"><?php echo api_convert_encoding($history[$k]['assignuser'], 'UTF-8', $charset); ?></td>
+            <td width="100px"><?php echo api_convert_encoding($history[$k]['assigned_date'], 'UTF-8', $charset); ?></td>
+            <td width="125px"><?php echo api_convert_encoding($history[$k]['insertuser'], 'UTF-8', $charset); ?></td>
+        </tr>
+    <?php } ?>
 </table>

+ 189 - 188
plugin/ticket/src/ticket_details.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  *
@@ -7,15 +8,15 @@
 /**
  *
  */
-$language_file= array('messages','userInfo', 'admin');
-$cidReset	= true;
+$language_file = array('messages', 'userInfo', 'admin');
+$cidReset = true;
 require_once '../config.php';
 $plugin = TicketPlugin::create();
 
 api_block_anonymous_users();
-$interbreadcrumb[]= array ('url' =>'myticket.php','name' => get_lang('MisTickets'));
-$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('TicketDetail'));
-$htmlHeadXtra[]='
+$interbreadcrumb[] = array('url' => 'myticket.php', 'name' => $plugin->get_lang('MyTickets'));
+$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('TicketDetail'));
+$htmlHeadXtra[] = '
 <script src="/pie/PIE_IE678.js"></script>
 <script language="javascript">
 $(document).ready(function(){
@@ -38,34 +39,32 @@ $(document).ready(function(){
 		$( "#dialog-form" ).dialog( "open" );
         
     	});
-		$("input#respuestasi").click(function () {
-			if(!confirm("Confirma que su respuesta es : SI ?. Si est\u00e1 seguro el ticket ser\u00e1 cerrado")){
-				return false;
-			}
-        
+        $("input#responseyes").click(function () {
+            if(!confirm("' . get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('Yes')) . '. Si est\u00e1 seguro el ticket ser\u00e1 cerrado")){
+                return false;
+            }
     	});
-		$("input#respuestano").click(function () {
-			if(!confirm("Confirma que su respuesta es : NO ?")){
-				return false;
-			}
-        
+	$("input#responseno").click(function () {
+            if(!confirm("' . get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('No')) . '")){
+		return false;
+            }
     	});
 	$("#unassign").click(function () {
-        if (!confirm("Estas seguro de Desasignarte")) {
+        if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToUnassignTheTicket') . '")) {
             return false		
-		}
+        }
     });
 	$("#close").click(function () {
-        if (!confirm("Estas seguro de Cerrar el Ticket")) {
+        if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToCloseTheTicket') . '")) {
 			return false		
-		}
+        }
     });
 });
 function validate() {	
 	fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML();	
 	document.getElementById("content").value= fckEditor1val;
-	if(fckEditor1val ==""){
-		alert("Debe escribir un mensaje");
+	if(fckEditor1val == ""){
+		alert("' . $plugin->get_lang('YouMustWriteAMessage') . '");
 		return false;
 	}
 }
@@ -88,7 +87,7 @@ function add_image_form() {
 	filepaths.appendChild(elem1);
 	id_elem1 = "filepath_"+counter_image;
 	id_elem1 = "\'"+id_elem1+"\'";
-	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\"  />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"'.api_get_path(WEB_CODE_PATH).'img/delete.gif\"></a>";
+	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\"  />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif\"></a>";
 	//document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<input type=\"text\" name=\"legend[]\" size=\"20\" />";
 	if (filepaths.childNodes.length == 6) {
 		var link_attach = document.getElementById("link-more-attach");
@@ -144,202 +143,201 @@ div.row div.formw2 {
 $user_id = api_get_user_id();
 $isAdmin = api_is_platform_admin();
 $ticket_id = $_GET['ticket_id'];
-$ticket = TicketManager::get_ticket_detail_by_id($ticket_id,$user_id);
-if(!isset($ticket['ticket'])){
-	api_not_allowed();
+$ticket = TicketManager::get_ticket_detail_by_id($ticket_id, $user_id);
+if (!isset($ticket['ticket'])) {
+    api_not_allowed();
 }
-if(!isset($_GET['ticket_id'])){
-	header('location:myticket.php');
+if (!isset($_GET['ticket_id'])) {
+    header('location:myticket.php');
 }
-if(isset($_POST['respuesta'])){
-	if($user_id == $ticket['ticket']['request_user']){
-		$respuesta = ($_POST['respuesta']=='si')?true:(($_POST['respuesta']=='no'?false:null));
-		if ($respuesta  && $ticket['ticket']['status_id'] == 'XCF' ){
-			TicketManager::close_ticket($_GET['ticket_id'], $user_id);
-				$ticket['ticket']['status_id'] = 'CLS';
-				$ticket['ticket']['status'] = 'CERRADO';
-			}else if(!is_null($respuesta) && $ticket['ticket']['status_id'] == 'XCF'){
-				TicketManager::update_ticket_status('PND',$_GET['ticket_id'], $user_id);
-				$ticket['ticket']['status_id'] = 'PND';
-				$ticket['ticket']['status'] = 'PENDIENTE';
-			}
-	}
-	
+if (isset($_POST['response'])) {
+    if ($user_id == $ticket['ticket']['request_user']) {
+        $response = ($_POST['response'] == get_lang('Yes')) ? true : ($_POST['response'] == get_lang('No') ? false : null);
+        if ($response && $ticket['ticket']['status_id'] == 'XCF') {
+            TicketManager::close_ticket($_GET['ticket_id'], $user_id);
+            $ticket['ticket']['status_id'] = 'CLS';
+            $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';
+            $ticket['ticket']['status'] = $plugin->get_lang('Pending');
+        }
+    }
 }
-if (isset($_REQUEST['action'])){
-	$action = $_REQUEST['action'];
-	switch ($action){
-		case 'assign':
-			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'];
-			break;
-		case 'unassign':
-			if(api_is_platform_admin() && isset($_GET['ticket_id']) )
-				TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
-				$ticket['ticket']['assigned_last_user'] = 0;
-			break;
-		default:
-			break;
-	}
+if (isset($_REQUEST['action'])) {
+    $action = $_REQUEST['action'];
+    switch ($action) {
+        case 'assign':
+            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'];
+            break;
+        case 'unassign':
+            if (api_is_platform_admin() && isset($_GET['ticket_id']))
+                TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
+            $ticket['ticket']['assigned_last_user'] = 0;
+            break;
+        default:
+            break;
+    }
 }
-if(!isset($_POST['compose'])){  
-	if(isset($_POST['close'])){
-		$_GET['ticket_id'] = $_POST['ticket_id'] ;
-		TicketManager::close_ticket($_GET['ticket_id'], $user_id);
-		$ticket['ticket']['status_id'] = 'CLS';
-		$ticket['ticket']['status'] = 'CERRADO';
-	}
-	$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' AND $ticket['ticket']['status_id'] != 'CLS' AND $isAdmin ){
-			if(intval($ticket['ticket']['assigned_last_user']) == $user_id){
-				if($ticket['ticket']['status_id']!='CLS'){
-					$form_close_ticket.= '<form enctype="multipart/form-data" action="'.api_get_self().'?ticket_id='.$ticket['ticket']['ticket_id'].'" method="post" name="close_ticket" id="close_ticket" >';
-					$form_close_ticket.= '<input type="hidden" name="ticket_id" value="'.$ticket['ticket']['ticket_id'].'"/>
-							<button class="minus" name="close" type="submit" id="close" >Cerrar</button>';
-					$form_close_ticket.= '</form>';
-				}
-			}
-		
-	}
-	$titulo = '<center><h1>Ticket #'.$ticket['ticket']['ticket_code'].'</h1></center>';
-	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 href="'.api_get_self().'?ticket_id='.$ticket['ticket']['ticket_id'].'&amp;action=unassign" id="unassign"><img src="../../../main/img/admin_star.png" border="0" title="Desasignarme" align="center"/></a>';					
-		}else{	
-			$img_assing .= '<a href="#" id="assign"><img src="../../../main/img/admin_star_na.png" border="0" title="Asignar" align="center"/></a>';				
-		}
-	}
-	$negrita = ($ticket['ticket']['status_id'] == 'CLS')?'style = "font-weight: bold;"':'';
-	$cadena = ($ticket['ticket']['status_id'] != 'CLS')?"sas":"";
-	echo '<div style="margin-left:20%;margin-right:20%;">
+if (!isset($_POST['compose'])) {
+    if (isset($_POST['close'])) {
+        $_GET['ticket_id'] = $_POST['ticket_id'];
+        TicketManager::close_ticket($_GET['ticket_id'], $user_id);
+        $ticket['ticket']['status_id'] = 'CLS';
+        $ticket['ticket']['status'] = $plugin->get_lang('Closed');
+    }
+    $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) {
+        if (intval($ticket['ticket']['assigned_last_user']) == $user_id) {
+            if ($ticket['ticket']['status_id'] != 'CLS') {
+                $form_close_ticket.= '<form enctype="multipart/form-data" action="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '" method="post" name="close_ticket" id="close_ticket" >';
+                $form_close_ticket.= '<input type="hidden" name="ticket_id" value="' . $ticket['ticket']['ticket_id'] . '"/>
+                                        <button class="minus" name="close" type="submit" id="close" >' . get_lang('Close') . '</button>';
+                $form_close_ticket.= '</form>';
+            }
+        }
+    }
+    $titulo = '<center><h1>Ticket #' . $ticket['ticket']['ticket_code'] . '</h1></center>';
+    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 href="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '&amp;action=unassign" id="unassign">
+                            <img src="' . api_get_path(WEB_CODE_PATH) . 'img/admin_star.png"  style="height: 32px; width: 32px;" border="0" title="Unassign" align="center"/>
+                           </a>';
+        } else {
+            $img_assing .= '<a href="#" id="assign"><img src="' . api_get_path(WEB_CODE_PATH) . 'img/admin_star_na.png" style="height: 32px; width: 32px;" title="Assign" align="center"/></a>';
+        }
+    }
+    $bold = ($ticket['ticket']['status_id'] == 'CLS') ? 'style = "font-weight: bold;"' : '';
+    echo '<div style="margin-left:20%;margin-right:20%;">
 			<table width="100%" >
 				<tr>
-	              <td colspan="3" style="width:65%">'.$titulo.'</td>
-	              <td >'.$img_assing.'</td>
-	              <td>'.$form_close_ticket.'</td>
+	              <td colspan="3" style="width:65%">' . $titulo . '</td>
+	              <td style="width: 15%">' . $img_assing . '</td>
+	              <td style="width: 15%">' . $form_close_ticket . '</td>
 	            </tr>
 	         	<tr>
-	              <td style="width:45%;" ><p>Enviado  : '.$ticket['ticket']['start_date'].'</p></td>
+	              <td style="width:45%;" ><p>' . get_lang('Sent') . ': ' . $ticket['ticket']['start_date'] . '</p></td>
 	              <td style="width:50px;"></td>
-	              <td style="width:45%;" ><p>Ultima Respuesta  : '.$ticket['ticket']['sys_lastedit_datetime'].'</p></td>
+	              <td style="width:45%;" ><p>' . $plugin->get_lang('LastResponse') . ': ' . $ticket['ticket']['sys_lastedit_datetime'] . '</p></td>
 	              <td colspan="2"></td>
 	            </tr>
 	            <tr>
-	               <td><p>Asunto  : '.$ticket['messages'][0]['subject'].'</p></td>
+	               <td><p>' . get_lang('Subject') . ': ' . $ticket['messages'][0]['subject'] . '</p></td>
 	               <td></td>
-	               <td><p '.$negrita.'>Estado : '.$ticket['ticket']['status'].'</p></td>
+	               <td><p ' . $bold . '>' . get_lang('Status') . ': ' . $ticket['ticket']['status'] . '</p></td>
 	               <td colspan="2"></td>
 	            </tr>
 	            <tr>
-	                <td><p>Categoria  : '.$ticket['ticket']['name'].'</p></td>
+	                <td><p>' . get_lang('Category') . ': ' . $ticket['ticket']['name'] . '</p></td>
 	                <td></td>
-	                <td ><p>Prioridad :'.$ticket['ticket']['priority'].'<p></td>
+	                <td ><p>' . get_lang('Priority') . ':' . $ticket['ticket']['priority'] . '<p></td>
 	                <td colspan="2"></td>
 	            </tr>';
-	if($ticket['ticket']['course_url']!=null){
-		echo '<tr>
-				<td><p>Curso:</p></td>
+    if ($ticket['ticket']['course_url'] != null) {
+        echo '<tr>
+				<td><p>' . get_lang('Course') . ':</p></td>
 	            <td></td>
-			    <td>'.$ticket['ticket']['course_url'].'</td>
+			    <td>' . $ticket['ticket']['course_url'] . '</td>
 	            <td colspan="2"></td>
 	          </tr>';
-	}
-	if ($isAdmin){
-		echo '<tr>
-				<td><p>Usuario:</p></td>
-	            <td></td>
-			    <td>'.$user_info = $ticket['ticket']['user_url'].' ('.$ticket['usuario']['username'].')</td>
-	            <td colspan="2"></td>
-			 </tr>';
-	}
-	//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);
-	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 .= "</select>";
-	echo '<div id="dialog-form" title="Asignar Ticket" >';
-	echo '<form id="genesis" method="POST" action="ticket_details.php?ticket_id='.$ticket['ticket']['ticket_id'].'">
+    }
+    if ($isAdmin) {
+        echo '<tr>
+		<td><p>' . get_lang('User') . ': &nbsp;' . $user_info = $ticket['ticket']['user_url'] . ' (' . $ticket['usuario']['username'] . ')</p></td>
+ 	      </tr>';
+    }
+    //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);
+    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 .= "</select>";
+    echo '<div id="dialog-form" title="' . get_lang('AssignTicket') . '" >';
+    echo '<form id="genesis" method="POST" action="ticket_details.php?ticket_id=' . $ticket['ticket']['ticket_id'] . '">
 			<input type="hidden" name ="action" id="action" value="assign"/>
-			<div  class="row">
-				<div class="label">Responsable:</div>
-				<div class="formw">'.$select_admins.'</div>
+			<div>
+				<div class="label">' . get_lang('Responsable') . ':</div>
+				<div class="formw">' . $select_admins . '</div>
 			</div>			
 		  </form>';
-	echo '</div>';
-	echo '</table></div>';
-	    $messages = $ticket['messages'];
-	    foreach($messages as $message){
-	        $class ="messageuser";
-	        if($message['admin']){
-	        	$class ="messagesupport";
-	        	if($isAdmin)$message['message'].="<br/><b>Atendido por: ".$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'].="<b>Enviado: ".api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG,_api_get_timezone())."</b>";
-	        }
-	        echo '<div class="'.$class.'" ><b>Asunto: </b> '.$message['subject'].'<br/> <b> Mensaje:</b>'.$message['message'].'<br/>';
-	        if(isset($message['atachments'])){
-		        foreach($message['atachments'] as $attach){
-		                echo $attach['attachment_link'];
-		       }
-		    }
-	        echo '</div>';
-    	}
-    	$asunto = "RE: ".$message['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();
-    		}else{
-    			if(intval($ticket['ticket']['assigned_last_user']) == $user_id){
-    				show_form_send_message();
-    				$cheked ="";
-    	
-    			}
-    		}
-    	}
-    	
-}else{
-    $ticket_id	= $_POST['ticket_id'];
-    $content	=	$_POST['content'];
-    $subject	=	$_POST['subject'];
-    $mensajeconfirmacion = isset($_POST['confirmation'])?true:false ;
-    $file_attachments   =	$_FILES;
+    echo '</div>';
+    echo '</table></div>';
+    $messages = $ticket['messages'];
+    foreach ($messages as $message) {
+        $class = "messageuser";
+        if ($message['admin']) {
+            $class = "messagesupport";
+            if ($isAdmin) {
+                $message['message'].='<br/><b>' . 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'].='<b>' . get_lang('Sent') . ': ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
+        }
+        echo '<div class="' . $class . '" ><b>' . get_lang('Subject') . ': </b> ' . $message['subject'] . '<br/> <b>' . get_lang('Message') . ':</b>' . $message['message'] . '<br/>';
+        if (isset($message['atachments'])) {
+            foreach ($message['atachments'] as $attach) {
+                echo $attach['attachment_link'];
+            }
+        }
+        echo '</div>';
+    }
+    $asunto = "RE: " . $message['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();
+        } else {
+            if (intval($ticket['ticket']['assigned_last_user']) == $user_id) {
+                show_form_send_message();
+                $cheked = "";
+            }
+        }
+    }
+} else {
+    $ticket_id = $_POST['ticket_id'];
+    $content = $_POST['content'];
+    $subject = $_POST['subject'];
+    $mensajeconfirmacion = 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', $mensajeconfirmacion);
+    header("location:" . api_get_self() . "?ticket_id=" . $ticket_id);
 }
-function show_form_send_message(){
-	global $isAdmin;
-	global $ticket;
-	global $asunto;
-    echo '<form enctype="multipart/form-data" action="'.api_get_self().'?ticket_id='.$ticket['ticket']['ticket_id'].'" method="post" name="send_ticket" id="send_ticket"
+
+function show_form_send_message()
+{
+    global $isAdmin;
+    global $ticket;
+    global $asunto;
+    echo '<form enctype="multipart/form-data" action="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '" method="post" name="send_ticket" id="send_ticket"
  	onsubmit="return validate()" style="width:100%">';
-	echo '<div class="row" ><div class ="label">Asunto:</div>
-       		<div class="formw"><input type = "text" id ="subject" name="subject" value="'.$asunto.'" required ="" style="width:60%"/></div>
+    echo '<div class="row" ><div class ="label">Asunto:</div>
+       		<div class="formw"><input type = "text" id ="subject" name="subject" value="' . $asunto . '" required ="" style="width:60%"/></div>
 		  </div>';
-	echo '<div class="row">
-		<div class="label2">mensaje
+    echo '<div class="row">
+		<div class="label2">
+                    ' . get_lang('Message') . '
 		</div>
 		<div class="formw2">
 			<input type="hidden" id="content" name="content" value="" style="display:none">
-		<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [  [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [  ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS=/main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS=/main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref='.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none">
+		<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [  [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [  ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath=/main/inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS=/main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS=/main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none">
 		<iframe id="content___Frame" src="/main/inc/lib/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Messages" width="95%" height="250" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border: 0px; background-color: transparent; background-image: none; width: 95%; height: 250px;">
 		</iframe>
 		</div>
 	</div>
 ';
-    echo '<input type="hidden" id="ticket_id" name="ticket_id" value="'.$_GET['ticket_id'].'">';
-	echo '<div class="row">
-		<div class="label">'.get_lang('FilesAttachment').'</div>
+    echo '<input type="hidden" id="ticket_id" name="ticket_id" value="' . $_GET['ticket_id'] . '">';
+    echo '<div class="row">
+		<div class="label">' . get_lang('FilesAttachment') . '</div>
 		<div class="formw">
 				<span id="filepaths">
 				<div id="filepath_1">
@@ -347,19 +345,22 @@ function show_form_send_message(){
 				</div></span>
 		</div>
 	</div>';
-	echo '<div class="row">
+    echo '<div class="row">
 		<div class="formw">
 			<span id="link-more-attach">
-				<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;
-					('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')
+				<a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span>&nbsp;
+					(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')
 			</div>
 		</div>';
-	echo '<div class="row">
+    echo '<div class="row">
 		<div class="label"></div>
-		<div class="formw">	<button class="save" name="compose" type="submit">Enviar mensaje</button>'.($isAdmin?'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="confirmation"/>Solicitar confirmaci&oacute;n':"").
-		'</div>
+		<div class="formw">
+                <button class="save" name="compose" type="submit">' . get_lang('SendMessage') . '</button>' . 
+            ($isAdmin ? '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="confirmation"/>Solicitar confirmaci&oacute;n' : "") .
+    '</div>
 	</div>';
-        echo '</form>';
+    echo '</form>';
 }
+
 Display::display_footer();
 ?>

+ 19 - 46
plugin/ticket/lib/ticket_plugin.class.php → plugin/ticket/src/ticket_plugin.class.php

@@ -9,64 +9,33 @@
  */
 class TicketPlugin extends Plugin
 {
+    /**
+     * Set the result
+     * @staticvar null $result
+     * @return type
+     */
     static function create()
     {
         static $result = null;
         return $result ? $result : $result = new self();
     }
-
     protected function __construct()
     {
         parent::__construct('1.0', 'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier', array('tool_enable' => 'boolean'));
     }
 
+    /**
+     * Install the ticket plugin
+     */
     public function install()
     {
-        // Create database tables
-        require_once api_get_path(SYS_PLUGIN_PATH).PLUGIN_NAME.'/database.php';
-
-        // Create link tab
-//        $homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
-//        $menutabs = 'home_tabs'; //menutabs for tabs Menu
-//        $menuf = $menutabs;
-//        $ext = '.html'; //ext for HTML Extension - when used frequently, variables are faster than hardcoded strings
-//        $lang = ''; //el for "Edit Language"
-//        if (!empty($_SESSION['user_language_choice'])) {
-//            $lang = $_SESSION['user_language_choice'];
-//        } elseif (!empty($_SESSION['_user']['language'])) {
-//            $lang = $_SESSION['_user']['language'];
-//        } else {
-//            $lang = api_get_setting('platformLanguage');
-//        }
-//        $link_url = api_get_path(WEB_PLUGIN_PATH).'ticket/s/myticket.php';
-//
-//        $home_menu = '<li class="show_menu"><a href="'.$link_url.'" target="_self"><span>Ticket</span></a></li>';
-//
-//        // Write
-//        if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
-//            if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
-//                $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
-//                fputs($fp, $home_menu);
-//                fclose($fp);
-//                if (file_exists($homep.$menuf.$ext)) {
-//                    if (is_writable($homep.$menuf.$ext)) {
-//                        $fpo = fopen($homep.$menuf.$ext, 'w');
-//                        fputs($fpo, $home_menu);
-//                        fclose($fpo);
-//                    }
-//                }
-//            } else {
-//                $errorMsg = get_lang('HomePageFilesNotWritable');
-//            }
-//        } else {
-//            //File does not exist
-//            $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
-//            fputs($fp, $home_menu);
-//            fclose($fp);
-//        }
+        // Create database tables and insert a Tab
+        require_once api_get_path(SYS_PLUGIN_PATH) . PLUGIN_NAME . '/database.php';
 
     }
-
+    /**
+     * Uninstall the ticket plugin
+     */
     public function uninstall()
     {
         $tblSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
@@ -80,12 +49,13 @@ class TicketPlugin extends Plugin
         $tblTicketMessage = Database::get_main_table(TABLE_TICKET_MESSAGE);
         $tblTicketCategory = Database::get_main_table(TABLE_TICKET_CATEGORY);
         $tblTicketAssgLog = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
-
+        $settings = $this->get_settings();
+        $plugSetting = current($settings);
+        
         //Delete settings
         $sql = "DELETE FROM $tblSettings WHERE variable = 'ticket_tool_enable'";
         Database::query($sql);
         
-        
         $sql = "DROP TABLE IF EXISTS $tblTicketTicket";
         Database::query($sql);
         $sql = "DROP TABLE IF EXISTS $tblTicketStatus";
@@ -104,5 +74,8 @@ class TicketPlugin extends Plugin
         Database::query($sql);
         $sql = "DROP TABLE IF EXISTS $tblTicketTicket";
         Database::query($sql);
+        
+        $this->deleteTab($plugSetting['comment']);
+        $this->deleteExtraSettings();
     }
 }

+ 15 - 14
plugin/ticket/src/tutor.php

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  *
@@ -19,7 +20,7 @@ $(document).ready(function (){
             var url     = this.href;
             var dialog  = $("#dialog");
             if ($("#dialog").length == 0) {
-                    dialog  = $("'.'<div id="dialog" style="display:hidden"></div>'.'").appendTo("body");
+                    dialog  = $("' . '<div id="dialog" style="display:hidden"></div>' . '").appendTo("body");
             }
 
             // load remote content
@@ -57,7 +58,7 @@ function save() {
 	 $.ajax({
 		contentType: "application/x-www-form-urlencoded",
 		beforeSend: function(objeto) {
-		$("div#confirmation").html("<img src=\"'.api_get_path(WEB_LIBRARY_PATH).'javascript/indicator.gif\" />"); },
+		$("div#confirmation").html("<img src=\"' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/indicator.gif\" />"); },
 		type: "POST",
 		url: "update_report.php",
 		data: "work_id="+work_id+"&forum_id="+forum_id+"&rs_id="+rs_id,
@@ -81,10 +82,10 @@ function save() {
 .blackboard_hide {
 	display: none;
 }
-.reportes{
+.reports{
 	border:1px ;	
 }
-.reportes th {
+.reports th {
     border-bottom: 1px solid #DDDDDD;
     line-height: normal;
     text-align: center;
@@ -95,15 +96,15 @@ function save() {
 
 $course_code = api_get_course_id();
 $results = initializeReport($course_code);
-if(isset($_GET['action'])){
-	Export::export_table_xls($results['export'],"COURSE_USER_REPORT".$course_code);
-}else{
-	Display::display_header();
-	api_protect_course_script();
-	if (!api_is_allowed_to_edit()){
-		api_not_allowed();
-	}
-	echo $results['show'];
-	Display::display_footer();
+if (isset($_GET['action'])) {
+    Export::export_table_xls($results['export'], "COURSE_USER_REPORT" . $course_code);
+} else {
+    Display::display_header();
+    api_protect_course_script();
+    if (!api_is_allowed_to_edit()) {
+        api_not_allowed();
+    }
+    echo $results['show'];
+    Display::display_footer();
 }
 ?>

+ 81 - 91
plugin/ticket/src/tutor_report.lib.php

@@ -1,66 +1,67 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  * Helper library for weekly reports
  * @package chamilo.plugin.ticket
  */
+
 /**
  * @param $course_code
  * @return array|bool
  */
 function initializeReport($course_code)
 {
-	$course_info = api_get_course_info($course_code);
-	$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
-	$table_students_report = Database::get_main_table('rp_students_report');
-	$table_semanas_curso = Database::get_main_table('rp_semanas_curso');
-	$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-	$table_post = Database::get_course_table(TABLE_FORUM_POST, $course_info['dbName']);
-	$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']);
-	$res = Database::query("SELECT COUNT(*) as cant FROM $table_reporte_semanas WHERE course_code = '".$course_code."'");
-	$sqlWeeks = "SELECT semanas FROM $table_semanas_curso WHERE course_code = '$course_code'";
-	$resWeeks = Database::query($sqlWeeks);
-	$weeks = Database::fetch_object($resWeeks);
-	$obj = Database::fetch_object($res);
-	$weeksCount = (!isset($_POST['numerosemanas']))?(($weeks->semanas==0)?7:$weeks->semanas):$_POST['numerosemanas'];
-	Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$weeksCount')");
-	if (intval($obj->cant) != $weeksCount) {
-		
-		if (intval($obj->cant) > $weeksCount) {
-			 $sql ="DELETE FROM $table_reporte_semanas WHERE  week_id > $weeksCount AND course_code = '$course_code'";
-			 Database::query("DELETE FROM $table_reporte_semanas WHERE  week_id > $weeksCount AND course_code = '$course_code'");
-		} else {
-			for ($i = $obj->cant+1 ; $i <= $weeksCount ; $i++){
-				if (!Database::query("INSERT INTO $table_reporte_semanas (week_id, course_code, forum_id, work_id, quiz_id, pc_id)
+    $course_info = api_get_course_info($course_code);
+    $table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
+    $table_students_report = Database::get_main_table('rp_students_report');
+    $table_semanas_curso = Database::get_main_table('rp_semanas_curso');
+    $table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+    $table_post = Database::get_course_table(TABLE_FORUM_POST, $course_info['dbName']);
+    $table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']);
+    $res = Database::query("SELECT COUNT(*) as cant FROM $table_reporte_semanas WHERE course_code = '" . $course_code . "'");
+    $sqlWeeks = "SELECT semanas FROM $table_semanas_curso WHERE course_code = '$course_code'";
+    $resWeeks = Database::query($sqlWeeks);
+    $weeks = Database::fetch_object($resWeeks);
+    $obj = Database::fetch_object($res);
+    $weeksCount = (!isset($_POST['weeksNumber'])) ? (($weeks->semanas == 0) ? 7 : $weeks->semanas) : $_POST['weeksNumber'];
+    Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$weeksCount')");
+    if (intval($obj->cant) != $weeksCount) {
+
+        if (intval($obj->cant) > $weeksCount) {
+            $sql = "DELETE FROM $table_reporte_semanas WHERE  week_id > $weeksCount AND course_code = '$course_code'";
+            Database::query("DELETE FROM $table_reporte_semanas WHERE  week_id > $weeksCount AND course_code = '$course_code'");
+        } else {
+            for ($i = $obj->cant + 1; $i <= $weeksCount; $i++) {
+                if (!Database::query("INSERT INTO $table_reporte_semanas (week_id, course_code, forum_id, work_id, quiz_id, pc_id)
 						VALUES ($i, '$course_code', '0', '0', '0', '0' )")) {
-						return false;
-				}
-			}
-		}		
-	}
-	
-	$sql = "REPLACE INTO $table_students_report (user_id, week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)
+                    return false;
+                }
+            }
+        }
+    }
+
+    $sql = "REPLACE INTO $table_students_report (user_id, week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)
 			SELECT cu.user_id, rs.id, 0, 0, 0, 0
 			FROM $table_course_rel_user cu
 			LEFT JOIN $table_reporte_semanas rs ON cu.course_code = rs.course_code
 			WHERE cu.status = 5 AND rs.course_code = '$course_code'
 			ORDER BY cu.user_id, rs.id";
-	if (!Database::query($sql)) {
-		return false;
-	} else {
-		$page = (!isset($_GET['page']))?1:$_GET['page'];
-		Database::query("UPDATE $table_students_report sr SET sr.work_ok = 1
+    if (!Database::query($sql)) {
+        return false;
+    } else {
+        $page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
+        Database::query("UPDATE $table_students_report sr SET sr.work_ok = 1
 		WHERE CONCAT (sr.user_id,',',sr.week_report_id)
 		IN (SELECT DISTINCT CONCAT(w.user_id,',',rs.id)
 		FROM $table_work w  JOIN $table_reporte_semanas rs ON w.parent_id = rs.work_id)");
-		Database::query("UPDATE $table_students_report sr SET sr.thread_ok = 1
+        Database::query("UPDATE $table_students_report sr SET sr.thread_ok = 1
 		WHERE CONCAT (sr.user_id,',',sr.week_report_id)
 		IN (SELECT DISTINCT CONCAT(f.poster_id,',',rs.id)
 		FROM $table_post f  JOIN $table_reporte_semanas rs ON f.thread_id = rs.forum_id)");
 
-		return showResults($course_info,$weeksCount,$page);
-	}
-	
+        return showResults($course_info, $weeksCount, $page);
+    }
 }
 
 /**
@@ -69,13 +70,13 @@ function initializeReport($course_code)
  * @param $page
  * @return array
  */
-function showResults($courseInfo,$weeksCount, $page)
+function showResults($courseInfo, $weeksCount, $page)
 {
     $course_code = $courseInfo['code'];
     $tableWeeklyReport = Database::get_main_table('rp_reporte_semanas');
     $tableStudentsReport = Database::get_main_table('rp_students_report');
     //$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
-    $tableUser = Database::get_main_table(TABLE_MAIN_USER );
+    $tableUser = Database::get_main_table(TABLE_MAIN_USER);
     $tableThread = Database::get_course_table(TABLE_FORUM_THREAD, $courseInfo['dbName']);
     $tableWork = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $courseInfo['dbName']);
 
@@ -87,72 +88,61 @@ function showResults($courseInfo,$weeksCount, $page)
                         LEFT JOIN $tableWork w ON w.id = rs.work_id
                         WHERE rs.course_code = '$course_code'
                         ORDER BY rs.week_id";
-    $resultHeader = Database::query($sqlHeader) ;
+    $resultHeader = Database::query($sqlHeader);
     $ids = array();
     $line = '<tr>
         <th ></th>';
-    $lineHeaderExport = array(null,null);
-    $lineHeaderExport2 = array(null,ull);
-    while ($rowe = Database::fetch_assoc($resultHeader)){
-        $lineHeaderExport[] =  utf8_decode('Work'.$rowe['week_id']);
-        $lineHeaderExport[] =  utf8_decode('Forum'.$rowe['week_id']);
+    $lineHeaderExport = array(null, null);
+    $lineHeaderExport2 = array(null, ull);
+    while ($rowe = Database::fetch_assoc($resultHeader)) {
+        $lineHeaderExport[] = utf8_decode('Work' . $rowe['week_id']);
+        $lineHeaderExport[] = utf8_decode('Forum' . $rowe['week_id']);
         //$fila_export_encabezado[] =  utf8_decode('Eval'.$rowe['week_id']);
         //$fila_export_encabezado[] =  utf8_decode('PC'.$rowe['week_id']);
         $lineHeaderExport2[] = utf8_decode($rowe['work_title']);
         $lineHeaderExport2[] = utf8_decode($rowe['thread_title']);
         //$fila_export_encabezado2[] = utf8_decode($rowe['eval_title']);
         //$fila_export_encabezado2[] = utf8_decode($rowe['pc_title']);
-        $fila_export = array('Work'.$rowe['week_id'],'Forum'.$rowe['week_id'],'Eval'.$rowe['week_id'],'PC'.$rowe['week_id']);
-        if ($rowe['week_id'] > (($page-1)*7) &&  $rowe['week_id'] <= (7*$page)){
+        $fila_export = array('Work' . $rowe['week_id'], 'Forum' . $rowe['week_id'], 'Eval' . $rowe['week_id'], 'PC' . $rowe['week_id']);
+        if ($rowe['week_id'] > (($page - 1) * 7) && $rowe['week_id'] <= (7 * $page)) {
             $ids[$rowe['week_id']] = $rowe['id'];
             $line.='<th>
-                <a href="#" onClick="showContent('."'tarea".$rowe['week_id']."'".');">Work'.$rowe['week_id'].'
-                        <div class="blackboard_hide" id="tarea'.$rowe['week_id'].'">'.$rowe['work_title'].'</div>
+                <a href="#" onClick="showContent(' . "'tarea" . $rowe['week_id'] . "'" . ');">Work' . $rowe['week_id'] . '
+                        <div class="blackboard_hide" id="tarea' . $rowe['week_id'] . '">' . $rowe['work_title'] . '</div>
                 </a></th>';
             $line.= '<th>
-                <a href="#" onClick="showContent('."'foro".$rowe['week_id']."'".');">Forum'.$rowe['week_id'].'
-                        <div class="blackboard_hide" id="foro'.$rowe['week_id'].'">'.$rowe['thread_title'].'</div>
-                </a>
-                </th>';
-            /*$fila.= '<th>
-                <a href="#" onClick="showContent('."'eval".$rowe['week_id']."'".');">Eval'.$rowe['week_id'].'
-                    <div class="blackboard_hide" id="eval'.$rowe['week_id'].'">'.$rowe['eval_title'].'</div>
+                <a href="#" onClick="showContent(' . "'foro" . $rowe['week_id'] . "'" . ');">Forum' . $rowe['week_id'] . '
+                        <div class="blackboard_hide" id="foro' . $rowe['week_id'] . '">' . $rowe['thread_title'] . '</div>
                 </a>
                 </th>';
-            $fila.= '<th>
-                <a href="#" onClick="showContent('."'pc".$rowe['week_id']."'".');">PC'.$rowe['week_id'].'
-                    <div class="blackboard_hide" id="pc'.$rowe['week_id'].'">'.$rowe['pc_title'].'</div>
-                </a>
-                </th>';*/
         }
-
     }
     $tableExport[] = $lineHeaderExport;
     $tableExport[] = $lineHeaderExport2;
-    $line.=  '</tr>';
+    $line.= '</tr>';
 
     $html = '<form action="tutor.php" name="semanas" id="semanas" method="POST">
             <div class="row">
-            '.get_lang('SelectWeeksSpan').'
-            <select name="numerosemanas" id="numerosemanas" onChange="submit();">
-            <option value="7" '.(($weeksCount ==7)?'selected="selected"':"").'>7 weeks</option>
-            <option value="14" '.(($weeksCount ==14)?'selected="selected"':"").'>14 weeks</option>
+            ' . get_lang('SelectWeeksSpan') . '
+            <select name="weeksNumber" id="weeksNumber" onChange="submit();">
+            <option value="7" ' . (($weeksCount == 7) ? 'selected="selected"' : "") . '>7 weeks</option>
+            <option value="14" ' . (($weeksCount == 14) ? 'selected="selected"' : "") . '>14 weeks</option>
             </select>';
 
 
     if ($weeksCount == 14) {
-        $html .= '<span style="float:right;"><a href="tutor.php?page='.(($page == 1)?2:1).'">'.(($page == 1)?"Siguiente":"Anterior").'</a></span>';
+        $html .= '<span style="float:right;"><a href="tutor.php?page=' . (($page == 1) ? 2 : 1) . '">' . (($page == 1) ? "Siguiente" : "Anterior") . '</a></span>';
     }
-    $html .= '<span style="float:right;"><a href="'.api_get_self().'?action=export'.$get_parameter.$get_parameter2.'">'.Display::return_icon('import_excel.png',get_lang('Export'),'','32').'</a></span>';
+    $html .= '<span style="float:right;"><a href="' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '">' . Display::return_icon('import_excel.png', get_lang('Export'), '', '32') . '</a></span>';
 
-    $html .=    '</form>';
-    $html .= '<table class="reportes">';
+    $html .= '</form>';
+    $html .= '<table class="reports">';
     $html .= '<tr>
             <th ></th>';
-    for ($i=(7*$page-6); $i <= $page*7;$i++) {
-        $html .= '<th colspan="2">Week '.$i.'<a href="assign_tickets.php?id='.$ids[$i].'" class="ajax">'.Display::return_icon('edit.png', get_lang('Edit'),  array('width'=>'16','height'=>'16'), 22).'</a></th>';
+    for ($i = (7 * $page - 6); $i <= $page * 7; $i++) {
+        $html .= '<th colspan="2">Week ' . $i . '<a href="assign_tickets.php?id=' . $ids[$i] . '" class="ajax">' . Display::return_icon('edit.png', get_lang('Edit'), array('width' => '16', 'height' => '16'), 22) . '</a></th>';
     }
-    $html .=  '</tr>';
+    $html .= '</tr>';
     $html .= $line;
     $sql = "SELECT u.username , u.user_id , CONCAT(u.lastname,' ', u.firstname ) as fullname , rs.week_id , sr.work_ok ,sr.thread_ok , sr.quiz_ok , sr.pc_ok , rs.course_code
             FROM $tableStudentsReport sr
@@ -164,20 +154,20 @@ function showResults($courseInfo,$weeksCount, $page)
     $result = Database::query($sql);
     while ($row = Database::fetch_assoc($result)) {
         $resultadose[$row['username']][$row['week_id']] = $row;
-        if ($row['week_id'] > (($page-1)*7) &&  $row['week_id'] <= (7*$page) ) {
+        if ($row['week_id'] > (($page - 1) * 7) && $row['week_id'] <= (7 * $page)) {
             $results[$row['username']][$row['week_id']] = $row;
-            if (count($results[$row['username']]) == 7 ) {
-                $html.= showStudentResult($results[$row['username']],$page);
+            if (count($results[$row['username']]) == 7) {
+                $html.= showStudentResult($results[$row['username']], $page);
             }
         }
-        if (count($resultadose[$row['username']]) == $weeksCount ) {
-                $tableExport[] = showStudentResultExport($resultadose[$row['username']],$weeksCount);
+        if (count($resultadose[$row['username']]) == $weeksCount) {
+            $tableExport[] = showStudentResultExport($resultadose[$row['username']], $weeksCount);
         }
     }
     $html .= '
           </table>';
 
-    return array('show'=>$html,'export'=>$tableExport);
+    return array('show' => $html, 'export' => $tableExport);
 }
 
 /**
@@ -185,15 +175,15 @@ function showResults($courseInfo,$weeksCount, $page)
  * @param $pagina
  * @return string
  */
-function showStudentResult($datos,$pagina)
+function showStudentResult($datos, $pagina)
 {
-    $inicio = (7*$pagina-6);
+    $inicio = (7 * $pagina - 6);
     $fila = '<tr>';
 
-    $fila.= '<td><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&uInfo='.$datos[$inicio]['user_id'].'">'.$datos[$inicio]['username'].'</a></td>';
-    foreach ($datos as $dato){
-        $fila.= '<td align="center">'.(($dato['work_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
-        $fila.= '<td align="center">'.(($dato['thread_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
+    $fila.= '<td><a href="' . api_get_path(WEB_CODE_PATH) . 'user/userInfo.php?' . api_get_cidreq() . '&uInfo=' . $datos[$inicio]['user_id'] . '">' . $datos[$inicio]['username'] . '</a></td>';
+    foreach ($datos as $dato) {
+        $fila.= '<td align="center">' . (($dato['work_ok'] == 1) ? Display::return_icon('check.png') : Display::return_icon('aspa.png')) . '</td>';
+        $fila.= '<td align="center">' . (($dato['thread_ok'] == 1) ? Display::return_icon('check.png') : Display::return_icon('aspa.png')) . '</td>';
     }
     $fila.= '</tr>';
     return $fila;
@@ -204,14 +194,14 @@ function showStudentResult($datos,$pagina)
  * @param $numero_semanas
  * @return array
  */
-function showStudentResultExport($data ,$numero_semanas)
+function showStudentResultExport($data, $numero_semanas)
 {
     $fila = array();
     $fila[] = utf8_decode($data[1]['username']);
-    $fila[]=  utf8_decode($data[1]['fullname']);
+    $fila[] = utf8_decode($data[1]['fullname']);
     foreach ($data as $line) {
-        $fila[]= ($line['work_ok']==1)?get_lang('Yes'):get_lang('No');
-        $fila[]= ($line['thread_ok']==1)?get_lang('Yes'):get_lang('No');
+        $fila[] = ($line['work_ok'] == 1) ? get_lang('Yes') : get_lang('No');
+        $fila[] = ($line['thread_ok'] == 1) ? get_lang('Yes') : get_lang('No');
     }
 
     return $fila;

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

@@ -1,4 +1,5 @@
 <?php
+
 /* For licensing terms, see /license.txt */
 /**
  * @package chamilo.plugin.ticket
@@ -17,7 +18,7 @@ api_protect_course_script();
 if (!api_is_allowed_to_edit()) {
     Display::display_error_message($plugin->get_lang("DeniedAccess"));
 } else {
-    $sql ="UPDATE ".Database::get_main_table('rp_reporte_semanas')."
+    $sql = "UPDATE " . Database::get_main_table('rp_reporte_semanas') . "
         SET work_id = '$work_id', forum_id = '$forum_id'
         WHERE  id ='$rs_id'";
     Database::query($sql);

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor