diff --git a/plugin/add_cas_login_button/index.php b/plugin/add_cas_login_button/index.php index 4445aafcb8..98e7d19253 100644 --- a/plugin/add_cas_login_button/index.php +++ b/plugin/add_cas_login_button/index.php @@ -1,23 +1,27 @@ addElement('text', 'cas_button_label', 'CAS connexion title', ''); $form->addElement('text', 'cas_button_comment', 'CAS connexion description', ''); $form->addElement('text', 'cas_image_url', 'Logo URL if any (image, 50px height)'); -$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); +$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); //get default value for form $tab_default_add_cas_login_button_cas_button_label = api_get_setting('add_cas_login_button_cas_button_label'); $tab_default_add_cas_login_button_cas_button_comment = api_get_setting('add_cas_login_button_cas_button_comment'); diff --git a/plugin/add_cas_logout_button/index.php b/plugin/add_cas_logout_button/index.php index ab7db2f142..610330c7b4 100644 --- a/plugin/add_cas_logout_button/index.php +++ b/plugin/add_cas_logout_button/index.php @@ -3,7 +3,10 @@ global $_user; $_template['show_message'] = false; -if (!api_is_anonymous() && api_get_setting('cas_activate') == 'true' && $_user['auth_source'] == CAS_AUTH_SOURCE) { +if (!api_is_anonymous() && + api_get_setting('cas_activate') == 'true' && + $_user['auth_source'] == CAS_AUTH_SOURCE +) { $_template['show_message'] = true; // the default title $logout_label = "Deconnexion de CAS"; @@ -14,8 +17,8 @@ if (!api_is_anonymous() && api_get_setting('cas_activate') == 'true' && $_user[' $logout_comment = api_htmlentities($plugin_info['settings']['add_cas_logout_button_cas_logout_comment']);; // URL of the image $logout_image_url = $plugin_info['settings']['add_cas_logout_button_cas_logout_image_url']; - + $_template['logout_label'] = $logout_label; $_template['logout_comment'] = $logout_comment; $_template['logout_image_url'] = $logout_image_url; -} \ No newline at end of file +} diff --git a/plugin/add_cas_logout_button/plugin.php b/plugin/add_cas_logout_button/plugin.php index 56481044fc..9f3d7fa80d 100644 --- a/plugin/add_cas_logout_button/plugin.php +++ b/plugin/add_cas_logout_button/plugin.php @@ -9,8 +9,6 @@ * Plugin details (must be present) */ - - //the plugin title $plugin_info['title'] = 'Add a button to logout from CAS'; @@ -25,7 +23,7 @@ $form = new FormValidator('add_cas_button_form'); $form->addElement('text', 'cas_logout_label', 'CAS logout title', ''); $form->addElement('text', 'cas_logout_comment', 'CAS logout description', ''); $form->addElement('text', 'cas_logout_image_url', 'Logo URL if any (image, 50px height)'); -$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); +$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); //get default value for form $tab_default_add_cas_logout_button_cas_logout_label = api_get_setting('add_cas_logout_button_cas_logout_label'); $tab_default_add_cas_logout_button_cas_logout_comment = api_get_setting('add_cas_logout_button_cas_logout_comment'); @@ -37,5 +35,5 @@ $form->setDefaults($defaults); //display form $plugin_info['settings_form'] = $form; -//set the smarty templates that are going to be used +// Set the templates that are going to be used $plugin_info['templates'] = array('template.tpl'); diff --git a/plugin/add_facebook_login_button/plugin.php b/plugin/add_facebook_login_button/plugin.php index 3e11af3b48..07d7bb3d0a 100644 --- a/plugin/add_facebook_login_button/plugin.php +++ b/plugin/add_facebook_login_button/plugin.php @@ -9,27 +9,32 @@ * Plugin details (must be present) */ - - //the plugin title -$plugin_info['title'] = 'Add a button to login using FACEBOOK account'; +$plugin_info['title'] = 'Add a button to login using FACEBOOK account'; //the comments that go with the plugin -$plugin_info['comment'] = "If Facebook authntification is activated, this plugin add a button Facebook Connexion on the login page. Configure plugin to add title, comment and logo. Should be place in login_top region"; +$plugin_info['comment'] = "If Facebook authntification is activated, this plugin add a button Facebook Connexion on the login page. Configure plugin to add title, comment and logo. Should be place in login_top region"; //the plugin version -$plugin_info['version'] = '1.0'; +$plugin_info['version'] = '1.0'; //the plugin author -$plugin_info['author'] = 'Hubert Borderiou'; +$plugin_info['author'] = 'Hubert Borderiou'; //the plugin configuration $form = new FormValidator('add_facebook_button_form'); -$form->addElement('text', 'facebook_button_url', 'Facebook connexion image URL', ''); -$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); +$form->addElement( + 'text', + 'facebook_button_url', + 'Facebook connexion image URL', + '' +); +$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); //get default value for form -$tab_default_add_facebook_login_button_facebook_button_url = api_get_setting('add_facebook_login_button_facebook_button_url'); +$tab_default_add_facebook_login_button_facebook_button_url = api_get_setting( + 'add_facebook_login_button_facebook_button_url' +); $defaults['facebook_button_url'] = $tab_default_add_facebook_login_button_facebook_button_url['add_facebook_login_button']; $form->setDefaults($defaults); //display form $plugin_info['settings_form'] = $form; -//set the smarty templates that are going to be used -$plugin_info['templates'] = array('template.tpl'); +// Set the templates that are going to be used +$plugin_info['templates'] = array('template.tpl'); diff --git a/plugin/add_shibboleth_login_button/plugin.php b/plugin/add_shibboleth_login_button/plugin.php index 0cd70fadd6..92f1246051 100644 --- a/plugin/add_shibboleth_login_button/plugin.php +++ b/plugin/add_shibboleth_login_button/plugin.php @@ -9,28 +9,46 @@ * Plugin details (must be present) */ - - //the plugin title -$plugin_info['title'] = 'Add a button to login using Shibboleth'; +$plugin_info['title'] = 'Add a button to login using Shibboleth'; //the comments that go with the plugin -$plugin_info['comment'] = "If Shibboleth is configured, this plugin add a text and a button on the login page to login with Shibboleth. Configure plugin to add title, comment and logo."; +$plugin_info['comment'] = "If Shibboleth is configured, this plugin add a text and a button on the login page to login with Shibboleth. Configure plugin to add title, comment and logo."; //the plugin version -$plugin_info['version'] = '1.0'; +$plugin_info['version'] = '1.0'; //the plugin author -$plugin_info['author'] = 'Hubert Borderiou'; +$plugin_info['author'] = 'Hubert Borderiou'; //the plugin configuration $form = new FormValidator('add_shibboleth_button_form'); -$form->addElement('text', 'shibboleth_button_label', 'shibboleth connexion title', ''); -$form->addElement('text', 'shibboleth_button_comment', 'shibboleth connexion description', ''); -$form->addElement('text', 'shibboleth_image_url', 'Logo URL if any (image, 50px height)'); -$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); +$form->addElement( + 'text', + 'shibboleth_button_label', + 'shibboleth connexion title', + '' +); +$form->addElement( + 'text', + 'shibboleth_button_comment', + 'shibboleth connexion description', + '' +); +$form->addElement( + 'text', + 'shibboleth_image_url', + 'Logo URL if any (image, 50px height)' +); +$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); //get default value for form -$tab_default_add_shibboleth_login_button_shibboleth_button_label = api_get_setting('add_shibboleth_login_button_shibboleth_button_label'); -$tab_default_add_shibboleth_login_button_shibboleth_button_comment = api_get_setting('add_shibboleth_login_button_shibboleth_button_comment'); -$tab_default_add_shibboleth_login_button_shibboleth_image_url = api_get_setting('add_shibboleth_login_button_shibboleth_image_url'); +$tab_default_add_shibboleth_login_button_shibboleth_button_label = api_get_setting( + 'add_shibboleth_login_button_shibboleth_button_label' +); +$tab_default_add_shibboleth_login_button_shibboleth_button_comment = api_get_setting( + 'add_shibboleth_login_button_shibboleth_button_comment' +); +$tab_default_add_shibboleth_login_button_shibboleth_image_url = api_get_setting( + 'add_shibboleth_login_button_shibboleth_image_url' +); $defaults = array(); $defaults['shibboleth_button_label'] = $tab_default_add_shibboleth_login_button_shibboleth_button_label['add_shibboleth_login_button']; $defaults['shibboleth_button_comment'] = $tab_default_add_shibboleth_login_button_shibboleth_button_comment['add_shibboleth_login_button']; @@ -40,4 +58,4 @@ $form->setDefaults($defaults); $plugin_info['settings_form'] = $form; //set the templates that are going to be used -$plugin_info['templates'] = array('template.tpl'); +$plugin_info['templates'] = array('template.tpl'); diff --git a/plugin/bbb/config.php b/plugin/bbb/config.php index 1b6eb83ddb..fda6f94043 100644 --- a/plugin/bbb/config.php +++ b/plugin/bbb/config.php @@ -3,7 +3,9 @@ /* bbb parameters that will be registered in the course settings */ -require_once __DIR__.'/../../main/inc/global.inc.php'; +require_once '../../main/inc/global.inc.php'; +require_once api_get_path(LIBRARY_PATH).'plugin.class.php'; + require_once 'lib/bbb.lib.php'; require_once 'lib/bbb_api.php'; -require_once 'lib/bbb_plugin.class.php'; +require_once 'lib/bbb_plugin.class.php'; \ No newline at end of file diff --git a/plugin/bbb/lib/bbb.lib.php b/plugin/bbb/lib/bbb.lib.php index b04448f85b..945ae62cf3 100644 --- a/plugin/bbb/lib/bbb.lib.php +++ b/plugin/bbb/lib/bbb.lib.php @@ -1,6 +1,6 @@ get_meeting_info(array('meetingId' => $meeting_db['id'], 'password' => $pass)); - $meeting_bbb['end_url'] = api_get_self().'?action=end&id='.$meeting_db['id']; + $meeting_bbb['end_url'] = api_get_self().'?'.api_get_cidreq().'&action=end&id='.$meeting_db['id']; if ((string)$meeting_bbb['returncode'] == 'FAILED') { if ($meeting_db['status'] == 1 && $this->is_teacher()) { $this->end_meeting($meeting_db['id']); } } else { - $meeting_bbb['add_to_calendar_url'] = api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']); + $meeting_bbb['add_to_calendar_url'] = api_get_self().'?'.api_get_cidreq().'&action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']); } $record_array = array(); @@ -278,9 +278,9 @@ class bbb { if (is_array($record) && isset($record['recordId'])) { $url = Display::url(get_lang('ViewRecord'), $record['playbackFormatUrl'], array('target' => '_blank')); if ($this->is_teacher()) { - $url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?action=copy_record_to_link_tool&id='.$meeting_db['id'].'&record_id='.$record['recordId']); - $url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']).'&url='.$record['playbackFormatUrl']); - $url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?action=delete_record&id='.$record['recordId']); + $url .= Display::url(Display::return_icon('link.gif',get_lang('CopyToLinkTool')), api_get_self().'?'.api_get_cidreq().'&action=copy_record_to_link_tool&id='.$meeting_db['id'].'&record_id='.$record['recordId']); + $url .= Display::url(Display::return_icon('agenda.png',get_lang('AddToCalendar')), api_get_self().'?'.api_get_cidreq().'&action=add_to_calendar&id='.$meeting_db['id'].'&start='.api_strtotime($meeting_db['created_at']).'&url='.$record['playbackFormatUrl']); + $url .= Display::url(Display::return_icon('delete.png',get_lang('Delete')), api_get_self().'?'.api_get_cidreq().'&action=delete_record&id='.$record['recordId']); } //$url .= api_get_self().'?action=publish&id='.$record['recordID']; $count++; @@ -309,14 +309,15 @@ class bbb { } } } + //var_dump($record_array); $item['show_links'] = implode('
', $record_array); } $item['created_at'] = api_convert_and_format_date($meeting_db['created_at']); //created_at - $item['publish_url'] = api_get_self().'?action=publish&id='.$meeting_db['id']; - $item['unpublish_url'] = api_get_self().'?action=unpublish&id='.$meeting_db['id']; + $item['publish_url'] = api_get_self().'?'.api_get_cidreq().'&action=publish&id='.$meeting_db['id']; + $item['unpublish_url'] = api_get_self().'?'.api_get_cidreq().'&action=unpublish&id='.$meeting_db['id']; if ($meeting_db['status'] == 1) { $joinParams = array( @@ -413,8 +414,8 @@ class bbb { if (empty($ids) or (is_array($ids) && count($ids)==0)) { return false; } $recordingParams = array( /* - * NOTE: Set the recordId below to a valid id after you have - * created a recorded meeting, and received a real recordID + * NOTE: Set the recordId below to a valid id after you have + * created a recorded meeting, and received a real recordID * back from your BBB server using the * getRecordingsWithXmlResponseArray method. */ @@ -437,10 +438,10 @@ class bbb { if (empty($id) or empty($record_id)) { return false; } + require_once api_get_path(LIBRARY_PATH).'link.lib.php'; $records = BigBlueButtonBN::getRecordingsArray($id, $this->url, $this->salt); if (!empty($records)) { foreach ($records as $record) { - //error_log($record['recordID']); if ($record['recordID'] == $record_id) { if (is_array($record) && isset($record['recordID']) && isset($record['playbacks'])) { foreach ($record['playbacks'] as $item) { diff --git a/plugin/bbb/lib/bbb_plugin.class.php b/plugin/bbb/lib/bbb_plugin.class.php index c95ba20c8f..fc4284671c 100644 --- a/plugin/bbb/lib/bbb_plugin.class.php +++ b/plugin/bbb/lib/bbb_plugin.class.php @@ -70,7 +70,7 @@ class BBBPlugin extends Plugin Database::query($sql); //hack to get rid of Database::query warning (please add c_id...) - $sql = "DELETE FROM $t_tool WHERE name = 'videoconference' AND c_id = c_id"; + $sql = "DELETE FROM $t_tool WHERE name = 'bbb' AND c_id = c_id"; Database::query($sql); $sql = "DROP TABLE IF EXISTS plugin_bbb_meeting"; @@ -79,4 +79,4 @@ class BBBPlugin extends Plugin //Deleting course settings $this->uninstall_course_fields_in_all_courses(); } -} \ No newline at end of file +} diff --git a/plugin/bbb/listing.php b/plugin/bbb/listing.php index 8c3836adcc..265d06786e 100644 --- a/plugin/bbb/listing.php +++ b/plugin/bbb/listing.php @@ -11,8 +11,7 @@ $course_plugin = 'bbb'; //needed in order to load the plugin lang variables require_once dirname(__FILE__).'/config.php'; $plugin = BBBPlugin::create(); $tool_name = $plugin->get_lang('Videoconference'); - -$tpl = $app['template']; +$tpl = new Template($tool_name); $bbb = new bbb(); $action = isset($_GET['action']) ? $_GET['action'] : null; @@ -91,6 +90,7 @@ $tpl->assign('users_online', $users_online); $tpl->assign('bbb_status', $status); $tpl->assign('show_join_button', $show_join_button); +//$tpl->assign('actions', $actions); $tpl->assign('message', $message); $listing_tpl = 'bbb/listing.tpl'; $content = $tpl->fetch($listing_tpl); diff --git a/plugin/bbb/start.php b/plugin/bbb/start.php index b7ad8c0c9a..96afc2949e 100644 --- a/plugin/bbb/start.php +++ b/plugin/bbb/start.php @@ -10,9 +10,7 @@ $course_plugin = 'bbb'; //needed in order to load the plugin lang variables require_once dirname(__FILE__).'/config.php'; $tool_name = get_lang('Videoconference'); -$app['title'] = $tool_name; -$tpl = $app['template']; - +$tpl = new Template($tool_name); $bbb = new bbb(); if ($bbb->plugin_enabled) { diff --git a/plugin/before_login/index.php b/plugin/before_login/index.php new file mode 100644 index 0000000000..58b8ddcbb7 --- /dev/null +++ b/plugin/before_login/index.php @@ -0,0 +1,78 @@ +defaultRenderer(); + $renderer->setFormTemplate('{content}
'); + $renderer->setElementTemplate('{element}'); + + $form->addElement('html', $option1); + $form->addElement('checkbox', 'left', null, get_lang('Yes')); + $form->addElement('button', 'submit', get_lang('Confirm'), array('class' => 'btn btn-primary')); + $formHtml = $form->return_form(); + if ($form->validate()) { + $result = $form->getSubmitValues(); + if (isset($result['left']) && $result['left']) { + $_SESSION['before_login_accepted'] = 1; + header('Location: '.$urlOption1); + exit; + } + } + + $form2 = new FormValidator('form'); + + if (!empty($option2) && !empty($urlOption2)) { + $renderer =& $form2->defaultRenderer(); + $renderer->setHeaderTemplate(''); + $renderer->setFormTemplate('{content}
'); + $renderer->setElementTemplate('{element}'); + + $form2->addElement('html', $option2); + $form2->addElement('checkbox', 'right', null, get_lang('Yes')); + $form2->addElement('button', 'submit', get_lang('Send')); + $formHtml2 = $form2->return_form(); + + if ($form2->validate()) { + $result = $form2->getSubmitValues(); + if (isset($result['right']) && $result['right']) { + header('Location: '.$urlOption2); + exit; + } + } + } + + $_template['form_option1'] = $formHtml; + $_template['form_option2'] = $formHtml2; +} diff --git a/plugin/before_login/plugin.php b/plugin/before_login/plugin.php new file mode 100644 index 0000000000..290584e74e --- /dev/null +++ b/plugin/before_login/plugin.php @@ -0,0 +1,51 @@ +Plugins) + * @package chamilo.plugin + * @author Julio Montoya + */ + +/* Plugin config */ + +// The plugin title. +$plugin_info['title'] = 'Show HTML before login'; +// The comments that go with the plugin. +$plugin_info['comment'] = "Show a content before loading the login page."; +// The plugin version. +$plugin_info['version'] = '1.0'; +// The plugin author. +$plugin_info['author'] = 'Julio Montoya'; + +// The plugin configuration. +$form = new FormValidator('form'); +$form->addElement('select', 'language', get_lang('Language'), api_get_languages_to_array()); + +$form->addElement('header', 'Option 1'); +$form->addElement('textarea', 'option1', get_lang('Description'), array('rows' => 10, 'class' => 'span6')); +$form->addElement('text', 'option1_url', get_lang('RedirectTo')); + +$form->addElement('header', 'Option 2'); +$form->addElement('textarea', 'option2', get_lang('Description'), array('rows' => 10, 'class' => 'span6')); +$form->addElement('text', 'option2_url', get_lang('RedirectTo')); +$form->addElement('button', 'submit_button', get_lang('Save')); + +// Get default value for form + +$defaults = array(); +$defaults['language'] = api_get_plugin_setting('before_login', 'language'); +$defaults['option1'] = api_get_plugin_setting('before_login', 'option1'); +$defaults['option2'] = api_get_plugin_setting('before_login', 'option2'); + +$defaults['option1_url'] = api_get_plugin_setting('before_login', 'option1_url'); +$defaults['option2_url'] = api_get_plugin_setting('before_login', 'option2_url'); + +$plugin_info['templates'] = array('template.tpl'); +if (file_exists(__DIR__.'/custom.template.tpl')) { + $plugin_info['templates'] = array( 'custom.template.tpl'); +} +$form->setDefaults($defaults); + +// Display form +$plugin_info['settings_form'] = $form; diff --git a/plugin/before_login/readme.txt b/plugin/before_login/readme.txt new file mode 100644 index 0000000000..72946833c4 --- /dev/null +++ b/plugin/before_login/readme.txt @@ -0,0 +1,10 @@ +README +

+This plugins shows page before showing the login page. +This is useful if you want a question before a user has the opportunity to login. +
+Example: +You're old enough to enter this site? If you accept the "option 1" then +you can enter to the campus (the login will appeared). + +If you select "option 2" then you're redirected to another page. \ No newline at end of file diff --git a/plugin/before_login/template.tpl b/plugin/before_login/template.tpl new file mode 100644 index 0000000000..77fa85e4ba --- /dev/null +++ b/plugin/before_login/template.tpl @@ -0,0 +1,14 @@ +{% if before_login.form_option1 %} +
+
+
+ {{ before_login.form_option1 }} +
+
+ {{ before_login.form_option2 }} +
+
+
+{% else %} + +{% endif %} \ No newline at end of file diff --git a/plugin/dashboard/block_course/block_course.class.php b/plugin/dashboard/block_course/block_course.class.php index db412b4e46..1a45c4b8c4 100644 --- a/plugin/dashboard/block_course/block_course.class.php +++ b/plugin/dashboard/block_course/block_course.class.php @@ -9,189 +9,200 @@ /** * required files for getting data */ +require_once api_get_path(LIBRARY_PATH) . 'thematic.lib.php'; /** * This class is used like controller for this course block plugin, * the class name must be registered inside path.info file (e.g: controller = "BlockCourse"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockCourse extends Block { - - private $user_id; - private $courses; - private $path; - private $permission = array(DRH); - - /** - * Constructor - */ - public function __construct ($user_id) { - $this->user_id = $user_id; - $this->path = 'block_course'; - if ($this->is_block_visible_for_user($user_id)) { - /*if (api_is_platform_admin()) { - $this->courses = CourseManager::get_real_course_list(); - } else {*/ - $this->courses = CourseManager::get_courses_followed_by_drh($user_id); - //} - } - } +class BlockCourse extends Block +{ + + private $user_id; + private $courses; + private $path; + private $permission = array(DRH); - /** - * This method check if a user is allowed to see the block inside dashboard interface - * @param int User id - * @return bool Is block visible for user - */ - public function is_block_visible_for_user($user_id) { - $user_info = api_get_user_info($user_id); - $user_status = $user_info['status']; - $is_block_visible_for_user = false; - if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { - $is_block_visible_for_user = true; - } - return $is_block_visible_for_user; + /** + * Constructor + */ + public function __construct($user_id) + { + $this->user_id = $user_id; + $this->path = 'block_course'; + if ($this->is_block_visible_for_user($user_id)) { + $this->courses = CourseManager::get_courses_followed_by_drh($user_id); + } } + /** + * This method check if a user is allowed to see the block inside dashboard interface + * @param int User id + * @return bool Is block visible for user + */ + public function is_block_visible_for_user($user_id) + { + $user_info = api_get_user_info($user_id); + $user_status = $user_info['status']; + $is_block_visible_for_user = false; + if (UserManager::is_admin($user_id) || in_array( + $user_status, + $this->permission + ) + ) { + $is_block_visible_for_user = true; + } + return $is_block_visible_for_user; + } /** * This method return content html containing information about courses and its position for showing it inside dashboard interface * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { - - global $charset; - - $column = 2; - $data = array(); - $content = ''; - $data_table = ''; - $content = $this->get_content_html(); - $html = ' + public function get_block() + { + global $charset; + $column = 2; + $data = array(); + $content = $this->get_content_html(); + $html = '
  • -

    '.get_lang('CoursesInformation').'

    - +

    ' . get_lang('CoursesInformation') . '

    +
    - '.$content.' + ' . $content . '
  • '; - $data['column'] = $column; - $data['content_html'] = $html; + $data['column'] = $column; + $data['content_html'] = $html; - return $data; + return $data; } - /** - * This method return a content html, it's used inside get_block method for showing it inside dashboard interface - * @return string content html - */ - public function get_content_html() { - - $course_data = $this->get_course_information_data(); - $content = '
    '; - $content .= '

    '.get_lang('YourCourseList').'

    '; + /** + * This method return a content html, it's used inside get_block method for showing it inside dashboard interface + * @return string content html + */ + public function get_content_html() + { + $course_data = $this->get_course_information_data(); + $content = '
    '; + $content .= '

    ' . get_lang( + 'YourCourseList' + ) . '

    '; $data_table = null; - if (!empty($course_data)) { - $data_table .= ''; - $data_table .= ' - - - - + if (!empty($course_data)) { + $data_table .= '
    '.get_lang('CourseTitle').''.get_lang('NbStudents').''.get_lang('AvgTimeSpentInTheCourse').''.get_lang('ThematicAdvance').'
    '; + $data_table .= ' + + + + '; - $i = 1; - foreach ($course_data as $course) { - if ($i%2 == 0) { - $class_tr = 'row_odd'; - } else { - $class_tr = 'row_even'; - } - $data_table .= ''; - if (!isset($course[2])) { - $course[2] = '0:00:00'; - } - foreach ($course as $cell) { - $data_table .= ''; - } - $data_table .= ''; - $i++; - } - $data_table .= '
    ' . get_lang('CourseTitle') . '' . get_lang('NbStudents') . '' . get_lang('AvgTimeSpentInTheCourse') . '' . get_lang('ThematicAdvance') . '
    '.$cell.'
    '; - } else { - $data_table .= get_lang('ThereIsNoInformationAboutYourCourses'); - } - $content .= $data_table; - if (!empty($course_data)) { - $content .= ''; - } - $content .= '
    '; - - return $content; - } + $i = 1; + foreach ($course_data as $course) { + if ($i % 2 == 0) { + $class_tr = 'row_odd'; + } else { + $class_tr = 'row_even'; + } + $data_table .= ''; + if (!isset($course[2])) { + $course[2] = '0:00:00'; + } + foreach ($course as $cell) { + $data_table .= '' . $cell . ''; + } + $data_table .= ''; + $i++; + } + $data_table .= ''; + } else { + $data_table .= get_lang('ThereIsNoInformationAboutYourCourses'); + } + $content .= $data_table; + if (!empty($course_data)) { + $content .= '
    ' . get_lang('SeeMore') . '
    '; + } + $content .= '
    '; + + return $content; + } /** - * Get number of courses - * @return int - */ - function get_number_of_courses() { - return count($this->courses); - } - - /** - * Get course information data - * @return array - */ - function get_course_information_data() + * Get number of courses + * @return int + */ + function get_number_of_courses() { - $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); - $course_data = array(); - $courses = $this->courses; - - foreach ($courses as $row_course) { - $thematic = new Thematic($row_course); - $course_code = $row_course['code']; - $courseId = $row_course['real_id']; - - $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0; - - // students directly subscribed to the course - $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user - WHERE course_rel_user.status=".STUDENT." AND course_rel_user.c_id = $courseId"; - $rs = Database::query($sql); - $users = array(); - while ($row = Database::fetch_array($rs)) { - $users[] = $row['user_id']; - } - if (count($users) > 0) { - $nb_students_in_course = count($users); - $avg_time_spent_in_course = api_time_to_hms(Tracking::get_time_spent_on_the_course($users, $courseId)/$nb_students_in_course); - } else { - $avg_time_spent_in_course = null; - } - - $tematic_advance_progress = 0; - - $tematic_advance = $thematic->get_total_average_of_thematic_advances($course_code, 0); - - if (!empty($tematic_advance)) { - $tematic_advance_progress = ''.$tematic_advance.'%'; - } else { - $tematic_advance_progress = '0%'; - } - - $table_row = array(); - $table_row[] = $row_course['title']; - $table_row[] = $nb_students_in_course; - $table_row[] = $avg_time_spent_in_course; - $table_row[] = $tematic_advance_progress; - $course_data[] = $table_row; - } - - return $course_data; - } + return count($this->courses); + } + /** + * Get course information data + * @return array + */ + function get_course_information_data() + { + $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $course_data = array(); + $courses = $this->courses; + + $thematic = new Thematic(); + + foreach ($courses as $row_course) { + + $course_code = $row_course['code']; + $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0; + + // students directly subscribed to the course + $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user + WHERE course_rel_user.status=" . STUDENT . " AND course_rel_user.course_code='$course_code'"; + $rs = Database::query($sql); + $users = array(); + while ($row = Database::fetch_array($rs)) { + $users[] = $row['user_id']; + } + if (count($users) > 0) { + $nb_students_in_course = count($users); + $avg_time_spent_in_course = api_time_to_hms( + Tracking::get_time_spent_on_the_course($users, $course_code ) / $nb_students_in_course); + } else { + $avg_time_spent_in_course = null; + } + $tematic_advance = $thematic->get_total_average_of_thematic_advances( + $course_code, + 0 + ); + + if (!empty($tematic_advance)) { + $tematic_advance_progress = '' . $tematic_advance . '%'; + } else { + $tematic_advance_progress = '0%'; + } + + $table_row = array(); + $table_row[] = $row_course['title']; + $table_row[] = $nb_students_in_course; + $table_row[] = $avg_time_spent_in_course; + $table_row[] = $tematic_advance_progress; + $course_data[] = $table_row; + } + + return $course_data; + } } -?> diff --git a/plugin/dashboard/block_daily/block_daily.class.php b/plugin/dashboard/block_daily/block_daily.class.php index e3631b3cb8..895e754a73 100644 --- a/plugin/dashboard/block_daily/block_daily.class.php +++ b/plugin/dashboard/block_daily/block_daily.class.php @@ -5,156 +5,170 @@ * @package chamilo.dashboard * @author Marco Sousa original code * @author Julio Montoya class named was changed of name, and some minor changes - */ /** * required files for getting data */ -require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php'; +require_once api_get_path(LIBRARY_PATH) . 'thematic.lib.php'; +require_once api_get_path(LIBRARY_PATH) . 'attendance.lib.php'; +require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be.inc.php'; /** * This class is used like controller for this course block plugin, * the class name must be registered inside path.info file (e.g: controller = "BlockDiario"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockDaily extends Block { - - private $user_id; - private $courses; - private $path; - private $permission = array(DRH); - - /** - * Constructor - */ - public function __construct ($user_id) { - $this->user_id = $user_id; - $this->path = 'block_daily'; - if ($this->is_block_visible_for_user($user_id)) { - /*if (api_is_platform_admin()) { - $this->courses = CourseManager::get_real_course_list(); - } else {*/ - $this->courses = CourseManager::get_courses_followed_by_drh($user_id); - //} - } - } +class BlockDaily extends Block +{ + + private $user_id; + private $courses; + private $path; + private $permission = array(DRH); - /** - * This method check if a user is allowed to see the block inside dashboard interface - * @param int User id - * @return bool Is block visible for user - */ - public function is_block_visible_for_user($user_id) { - $user_info = api_get_user_info($user_id); - $user_status = $user_info['status']; - $is_block_visible_for_user = false; - if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { - $is_block_visible_for_user = true; - } - return $is_block_visible_for_user; + /** + * Constructor + */ + public function __construct($user_id) + { + $this->user_id = $user_id; + $this->path = 'block_daily'; + if ($this->is_block_visible_for_user($user_id)) { + $this->courses = CourseManager::get_courses_followed_by_drh( + $user_id + ); + } } + /** + * This method check if a user is allowed to see the block inside dashboard interface + * @param int User id + * @return bool Is block visible for user + */ + public function is_block_visible_for_user($user_id) + { + $user_info = api_get_user_info($user_id); + $user_status = $user_info['status']; + $is_block_visible_for_user = false; + if (UserManager::is_admin($user_id) || in_array( + $user_status, + $this->permission + ) + ) { + $is_block_visible_for_user = true; + } + return $is_block_visible_for_user; + } /** * This method return content html containing information about courses and its position for showing it inside dashboard interface * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { - - global $charset; + public function get_block() + { - $column = 2; - $data = array(); - $content = ''; - $data_table = ''; - $content = $this->get_content_html(); - $html = '
  • + global $charset; + $column = 2; + $data = array(); + $content = $this->get_content_html(); + $html = '
  • -

    '.get_lang('GradebookAndAttendances').'

    - +

    ' . get_lang('GradebookAndAttendances') . '

    +
    - '.$content.' + ' . $content . '
  • '; - $data['column'] = $column; - $data['content_html'] = $html; + $data['column'] = $column; + $data['content_html'] = $html; - return $data; + return $data; } - /** - * This method return a content html, it's used inside get_block method for showing it inside dashboard interface - * @return string content html - */ - public function get_content_html() { - - $course_data = $this->get_course_information_data(); - $content = '
    '; - $content .= '

    '.get_lang('YourCourseList').'

    '; + /** + * This method return a content html, it's used inside get_block method for showing it inside dashboard interface + * @return string content html + */ + public function get_content_html() + { + $course_data = $this->get_course_information_data(); + $content = '
    '; + $content .= '

    ' . get_lang( + 'YourCourseList' + ) . '

    '; $data_table = null; - if (!empty($course_data)) { - $data_table .= ''; - $data_table .= ' - - - - + if (!empty($course_data)) { + $data_table .= '
    '.get_lang('CourseTitle').''.get_lang('NbStudents').''.get_lang('Evaluation').''.get_lang('ToolAttendance').'
    '; + $data_table .= ' + + + + '; - $i = 1; - foreach ($course_data as $course) { - if ($i%2 == 0) { - $class_tr = 'row_odd'; - } else { - $class_tr = 'row_even'; - } - $data_table .= ''; - if (!isset($course[3])) { - $course[3] = get_lang('NotAvailable'); - } - foreach ($course as $cell) { - $data_table .= ''; - } - $data_table .= ''; - $i++; - } - $data_table .= '
    ' . get_lang('CourseTitle') . '' . get_lang('NbStudents') . '' . get_lang('Evaluation') . '' . get_lang('ToolAttendance') . '
    '.$cell.'
    '; - } else { - $data_table .= get_lang('ThereIsNoInformationAboutYourCourses'); - } - $content .= $data_table; - if (!empty($course_data)) { - $content .= ''; - } - $content .= '
    '; - return $content; - } + $i = 1; + foreach ($course_data as $course) { + if ($i % 2 == 0) { + $class_tr = 'row_odd'; + } else { + $class_tr = 'row_even'; + } + $data_table .= ''; + if (!isset($course[3])) { + $course[3] = get_lang('NotAvailable'); + } + foreach ($course as $cell) { + $data_table .= '' . $cell . ''; + } + $data_table .= ''; + $i++; + } + $data_table .= ''; + } else { + $data_table .= get_lang('ThereIsNoInformationAboutYourCourses'); + } + $content .= $data_table; + if (!empty($course_data)) { + $content .= '
    + ' . get_lang('SeeMore') . '
    '; + } + $content .= '
    '; + return $content; + } /** - * Get number of courses - * @return int - */ - function get_number_of_courses() { - return count($this->courses); - } - - /** - * Get course information data - * @return array - */ - function get_course_information_data() { - $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); - $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); - - $a_course_students = array(); - $course_data = array(); - $courses = $this->courses; - - foreach ($courses as $row_course) { + * Get number of courses + * @return int + */ + function get_number_of_courses() + { + return count($this->courses); + } + + /** + * Get course information data + * @return array + */ + function get_course_information_data() + { + $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $course_data = array(); + $courses = $this->courses; + + foreach ($courses as $row_course) { $score = null; $course_code = $row_course['code']; $course_info = api_get_course_info($course_code); @@ -165,62 +179,73 @@ class BlockDaily extends Block { // Attendance table $table_course = Database::get_course_table(TABLE_ATTENDANCE); - $sql = "SELECT id, name, attendance_qualify_max FROM $table_course WHERE c_id = ".$course_info['real_id']." AND active = 1 AND session_id = 0"; - $rs = Database::query($sql); - $attendance = array(); + $sql = "SELECT id, name, attendance_qualify_max FROM $table_course + WHERE c_id = " . $course_info['real_id'] . " AND active = 1 AND session_id = 0"; + $rs = Database::query($sql); + $attendance = array(); $attendances = array(); $param_gradebook = ''; if (isset($_SESSION['gradebook'])) { - $param_gradebook = '&gradebook='.$_SESSION['gradebook']; + $param_gradebook = '&gradebook=' . $_SESSION['gradebook']; } - while ($row = Database::fetch_array($rs,'ASSOC')) { + while ($row = Database::fetch_array($rs, 'ASSOC')) { $attendance['done'] = $row['attendance_qualify_max']; $attendance['id'] = $row['id']; //$attendance['name'] = $row['name']; $attendance['course_code'] = $course_code; - if ($attendance['done'] != '0') - $attendances[] = ''.Display::return_icon('printmgr.gif',get_lang('Print')).''; - else + if ($attendance['done'] != '0') { + $attendances[] = '' . Display::return_icon('printmgr.gif', get_lang('Print')).''; + } else { $attendances[] = get_lang("NotAvailable"); - } - - $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user - WHERE course_rel_user.status=".STUDENT." AND course_rel_user.c_id = ".$course_info['real_id']; - $rs = Database::query($sql); - $users = array(); - while ($row = Database::fetch_array($rs)) { - $users[] = $row['user_id']; - } - if (count($users) > 0) { - $nb_students_in_course = count($users); - } - - if (!empty($tematic_advance)) { - $tematic_advance_progress = ''.$tematic_advance.'%'; - } else { - $tematic_advance_progress = '0%'; - } + } + } + + // quantidade de alunos + + $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user + WHERE course_rel_user.status=" . STUDENT . " AND course_rel_user.course_code='$course_code'"; + $rs = Database::query($sql); + $users = array(); + while ($row = Database::fetch_array($rs)) { + $users[] = $row['user_id']; + } + if (count($users) > 0) { + $nb_students_in_course = count($users); + } + + if (!empty($tematic_advance)) { + $tematic_advance_progress = '' . $tematic_advance . '%'; + } else { + $tematic_advance_progress = '0%'; + } // Score - $tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); - $sql = "SELECT id from " . $tbl_grade_categories ." WHERE course_code ='".$course_code."'"; - $rs = Database::query($sql); - $category = null; - while ($row = Database::fetch_array($rs)) { - $category = $row['id']; - } - - if (!empty($category)) { + $tbl_grade_categories = Database :: get_main_table( + TABLE_MAIN_GRADEBOOK_CATEGORY + ); + $sql = "SELECT id from " . $tbl_grade_categories . " + WHERE course_code ='" . $course_code . "'"; + $rs = Database::query($sql); + $category = null; + while ($row = Database::fetch_array($rs)) { + $category = $row['id']; + } + + if (!empty($category)) { $cat = Category::load($category); $eval = $cat[0]->get_evaluations(); - if (count($eval) > 0){ + if (count($eval) > 0) { $i = 0; foreach ($eval as $item) { - $score .= ''.$item->get_name().''; - if (count($eval)-1 != $i) { + $score .= '' . $item->get_name() . ''; + if (count($eval) - 1 != $i) { $score .= ', '; } $i++; @@ -228,17 +253,17 @@ class BlockDaily extends Block { } else { $score = get_lang("NotAvailable"); } - } else { + } else { $score = get_lang("NotAvailable"); } - $table_row = array(); - $table_row[] = $row_course['title']; - $table_row[] = $nb_students_in_course; - $table_row[] = $score; - $table_row[] = $attendances[0]; - $course_data[] = $table_row; - } - return $course_data; - } -} \ No newline at end of file + $table_row = array(); + $table_row[] = $row_course['title']; + $table_row[] = $nb_students_in_course; + $table_row[] = $score; + $table_row[] = $attendances[0]; + $course_data[] = $table_row; + } + return $course_data; + } +} diff --git a/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php b/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php index d0fc17cd97..c9c23edf95 100644 --- a/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php +++ b/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php @@ -11,6 +11,9 @@ /** * required files for getting data */ +require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php'; @@ -24,8 +27,8 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php'; * the class name must be registered inside path.info file (e.g: controller = "BlockEvaluationGraph"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockEvaluationGraph extends Block { - +class BlockEvaluationGraph extends Block +{ private $user_id; private $courses; private $sessions; @@ -35,25 +38,18 @@ class BlockEvaluationGraph extends Block { /** * Constructor */ - public function __construct ($user_id) { + public function __construct($user_id) + { $this->path = 'block_evaluation_graph'; $this->user_id = $user_id; $this->bg_width = 450; $this->bg_height = 350; if ($this->is_block_visible_for_user($user_id)) { - //$this->courses = CourseManager::get_real_course_list(); - /*if (api_is_platform_admin()) { - $this->courses = CourseManager::get_real_course_list(); - $this->sessions = SessionManager::get_sessions_list(); - } else {*/ - if (!api_is_session_admin()) { - $this->courses = CourseManager::get_courses_followed_by_drh($user_id); - } - $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id); - //} + if (!api_is_session_admin()) { + $this->courses = CourseManager::get_courses_followed_by_drh($user_id); + } + $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id); } - - } /** @@ -61,7 +57,8 @@ class BlockEvaluationGraph extends Block { * @param int User id * @return bool Is block visible for user */ - public function is_block_visible_for_user($user_id) { + public function is_block_visible_for_user($user_id) + { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; @@ -76,47 +73,46 @@ class BlockEvaluationGraph extends Block { * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { + public function get_block() + { global $charset; - $column = 1; $data = array(); $evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph(); - $evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph(); $html = '
  • -
    -

    '.get_lang('EvaluationsGraph').'

    - -
    -
    '; - if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) { - $html .= '

    '.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'

    '; - } else { - // display evaluations base courses graph - if (!empty($evaluations_base_courses_graph)) { - foreach ($evaluations_base_courses_graph as $course_code => $img_html) { - $html .= '
    '.$course_code.'
    '; - $html .= $img_html; - } - } - // display evaluations base courses graph - if (!empty($evaluations_courses_in_sessions_graph)) { - foreach ($evaluations_courses_in_sessions_graph as $session_id => $courses) { - $session_name = api_get_session_name($session_id); - $html .= '
    '.$session_name.':'.get_lang('Evaluations').'
    '; - foreach ($courses as $course_code => $img_html) { - $html .= '
    '.$course_code.'
    '; - $html .= $img_html; - } - } - } - } - $html .= '
    -
  • '; +
    +

    '.get_lang('EvaluationsGraph').'

    + +
    +
    '; + if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) { + $html .= '

    '.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'

    '; + } else { + // display evaluations base courses graph + if (!empty($evaluations_base_courses_graph)) { + foreach ($evaluations_base_courses_graph as $course_code => $img_html) { + $html .= '
    '.$course_code.'
    '; + $html .= $img_html; + } + } + // display evaluations base courses graph + if (!empty($evaluations_courses_in_sessions_graph)) { + foreach ($evaluations_courses_in_sessions_graph as $session_id => $courses) { + $session_name = api_get_session_name($session_id); + $html .= '
    '.$session_name.':'.get_lang('Evaluations').'
    '; + foreach ($courses as $course_code => $img_html) { + $html .= '
    '.$course_code.'
    '; + $html .= $img_html; + } + } + } + } + $html .= '
    + '; $data['column'] = $column; $data['content_html'] = $html; @@ -124,10 +120,13 @@ class BlockEvaluationGraph extends Block { } /** - * This method return a graph containing informations about evaluations inside base courses, it's used inside get_block method for showing it inside dashboard interface + * This method return a graph containing informations about evaluations + * inside base courses, it's used inside get_block method for showing + * it inside dashboard interface * @return string img html */ - public function get_evaluations_base_courses_graph() { + public function get_evaluations_base_courses_graph() + { $graphs = array(); if (!empty($this->courses)) { $courses_code = array_keys($this->courses); @@ -160,7 +159,7 @@ class BlockEvaluationGraph extends Block { $data_set->RemoveSerie("Items"); $data_set->SetAbsciseLabelSerie("Items"); $graph_id = $this->user_id.'StudentEvaluationGraph'; - $cache = new pCache(api_get_path(SYS_ARCHIVE_PATH)); + $cache = new pCache(); // the graph id $data = $data_set->GetData(); if ($cache->IsInCache($graph_id, $data)) { @@ -211,19 +210,20 @@ class BlockEvaluationGraph extends Block { } /** - * This method return a graph containing informations about evaluations inside courses in sessions, it's used inside get_block method for showing it inside dashboard interface + * This method return a graph containing information about evaluations + * inside courses in sessions, it's used inside get_block method for + * showing it inside dashboard interface * @return string img html */ - public function get_evaluations_courses_in_sessions_graph() { + public function get_evaluations_courses_in_sessions_graph() + { $graphs = array(); if (!empty($this->sessions)) { $session_ids = array_keys($this->sessions); foreach ($session_ids as $session_id) { $courses_code = array_keys(Tracking::get_courses_list_from_session($session_id)); $courses_graph = array(); - foreach ($courses_code as $courseId) { - $courseInfo = api_get_course_info_by_id($courseId); - $course_code = $courseInfo['code']; + foreach ($courses_code as $course_code) { $cats = Category::load(null, null, $course_code, null, null, $session_id); if (isset($cats) && isset($cats[0])) { $alleval = $cats[0]->get_evaluations(null, true, $course_code); @@ -251,7 +251,7 @@ class BlockEvaluationGraph extends Block { $data_set->RemoveSerie("Items"); $data_set->SetAbsciseLabelSerie("Items"); $graph_id = $this->user_id.'StudentEvaluationGraph'; - $cache = new pCache(api_get_path(SYS_ARCHIVE_PATH)); + $cache = new pCache(); // the graph id $data = $data_set->GetData(); if ($cache->IsInCache($graph_id, $data)) { @@ -303,4 +303,4 @@ class BlockEvaluationGraph extends Block { } return $graphs; } -} \ No newline at end of file +} diff --git a/plugin/dashboard/block_global_info/block_global_info.class.php b/plugin/dashboard/block_global_info/block_global_info.class.php index 67448f0e50..240b73355c 100644 --- a/plugin/dashboard/block_global_info/block_global_info.class.php +++ b/plugin/dashboard/block_global_info/block_global_info.class.php @@ -10,6 +10,8 @@ /** * required files for getting data */ +require_once api_get_path(SYS_CODE_PATH).'admin/statistics/statistics.lib.php'; + /** * This class is used like controller for this global info block plugin * the class name must be registered inside path.info file @@ -59,15 +61,12 @@ class BlockGlobalInfo extends Block * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { - + public function get_block() + { global $charset; - $column = 2; $data = array(); - $content = ''; - $data_table = ''; - $content = $this->get_content_html(); + $content = $this->get_content_html(); $html = '
  • @@ -89,8 +88,8 @@ class BlockGlobalInfo extends Block * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ - public function get_content_html() { - + public function get_content_html() + { $global_data = $this->get_global_information_data(); $content = '
    '; $content .= '

    '.get_lang('GlobalPlatformInformation').'

    '; @@ -139,7 +138,7 @@ class BlockGlobalInfo extends Block array(get_lang('NumberOfCoursesPublic'), ''.Statistics::count_courses_by_visibility(COURSE_VISIBILITY_OPEN_WORLD).''), array(get_lang('NumberOfCoursesOpen'), ''.Statistics::count_courses_by_visibility(COURSE_VISIBILITY_OPEN_PLATFORM).''), array(get_lang('NumberOfCoursesPrivate'), ''.Statistics::count_courses_by_visibility(COURSE_VISIBILITY_REGISTERED).''), - array(get_lang('NumberOfCoursesClosed'), ''.Statistics::count_courses_by_visibility(COURSE_VISIBILITY_CLOSED).'') + array(get_lang('NumberOfCoursesClosed'), ''.Statistics::count_courses_by_visibility(COURSE_VISIBILITY_CLOSED).''), array(get_lang('NumberOfCoursesHidden'), ''.Statistics::count_courses_by_visibility(COURSE_VISIBILITY_HIDDEN).'') ); return $global_info; diff --git a/plugin/dashboard/block_session/block_session.class.php b/plugin/dashboard/block_session/block_session.class.php index a582fb6486..fc12b55f64 100644 --- a/plugin/dashboard/block_session/block_session.class.php +++ b/plugin/dashboard/block_session/block_session.class.php @@ -9,13 +9,16 @@ /** * required files for getting data */ +require_once api_get_path(LIBRARY_PATH).'course_description.lib.php'; /** * This class is used like controller for this session block plugin, - * the class name must be registered inside path.info file (e.g: controller = "BlockSession"), so dashboard controller will be instantiate it + * the class name must be registered inside path.info file + * (e.g: controller = "BlockSession"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockSession extends Block { +class BlockSession extends Block +{ private $user_id; private $sessions; @@ -25,15 +28,12 @@ class BlockSession extends Block { /** * Constructor */ - public function __construct ($user_id) { + public function __construct ($user_id) + { $this->user_id = $user_id; $this->path = 'block_session'; if ($this->is_block_visible_for_user($user_id)) { - /*if (api_is_platform_admin()) { - $this->sessions = SessionManager::get_sessions_list(); - } else {*/ - $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id); - //} + $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id); } } @@ -42,7 +42,8 @@ class BlockSession extends Block { * @param int User id * @return bool Is block visible for user */ - public function is_block_visible_for_user($user_id) { + public function is_block_visible_for_user($user_id) + { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; @@ -57,7 +58,8 @@ class BlockSession extends Block { * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { + public function get_block() + { global $charset; @@ -88,7 +90,8 @@ class BlockSession extends Block { * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ - public function get_content_html() { + public function get_content_html() + { $content = ''; $sessions = $this->sessions; @@ -108,7 +111,12 @@ class BlockSession extends Block { $session_id = intval($session['id']); $title = $session['name']; - $date_string = SessionManager::parse_session_dates($session); + + if ($session['date_start'] != '0000-00-00' && $session['date_end'] != '0000-00-00') { + $date = get_lang('From').' '.api_convert_and_format_date($session['date_start'], DATE_FORMAT_SHORT, date_default_timezone_get()).' '.get_lang('To').' '.api_convert_and_format_date($session['date_end'], DATE_FORMAT_SHORT, date_default_timezone_get()); + } else { + $date = ' - '; + } $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id)); @@ -117,7 +125,7 @@ class BlockSession extends Block { $sessions_table .= ' '.$title.' - '.$date_string.' + '.$date.' '.$count_courses_in_session.' '; $i++; @@ -141,8 +149,9 @@ class BlockSession extends Block { * Get number of sessions * @return int */ - function get_number_of_sessions() { + function get_number_of_sessions() + { return count($this->sessions); } -} \ No newline at end of file +} diff --git a/plugin/dashboard/block_student/block_student.class.php b/plugin/dashboard/block_student/block_student.class.php index 290b9546bf..fcbe118c10 100644 --- a/plugin/dashboard/block_student/block_student.class.php +++ b/plugin/dashboard/block_student/block_student.class.php @@ -9,6 +9,7 @@ /** * required files for getting data */ +require_once api_get_path(LIBRARY_PATH).'attendance.lib.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php'; @@ -20,7 +21,8 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php'; * the class name must be registered inside path.info file (e.g: controller = "BlockStudent"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockStudent extends Block { +class BlockStudent extends Block +{ private $user_id; private $students; @@ -30,16 +32,12 @@ class BlockStudent extends Block { /** * Constructor */ - public function __construct ($user_id) { + public function __construct ($user_id) + { $this->user_id = $user_id; $this->path = 'block_student'; if ($this->is_block_visible_for_user($user_id)) { - /*if (api_is_platform_admin()) { - $this->students = UserManager::get_user_list(array('status' => STUDENT)); - } else {*/ - $this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT); - //} } } @@ -48,7 +46,8 @@ class BlockStudent extends Block { * @param int User id * @return bool Is block visible for user */ - public function is_block_visible_for_user($user_id) { + public function is_block_visible_for_user($user_id) + { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; @@ -63,7 +62,8 @@ class BlockStudent extends Block { * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { + public function get_block() + { global $charset; $column = 1; $data = array(); @@ -89,7 +89,8 @@ class BlockStudent extends Block { * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ - public function get_students_content_html_for_platform_admin() { + public function get_students_content_html_for_platform_admin() + { $students = $this->students; $content = '
    '; $content .= '

    '.get_lang('YourStudents').'

    '; @@ -129,7 +130,7 @@ class BlockStudent extends Block { foreach ($courses_by_user as $course) { $course_code = $course['code']; $course_title = $course['title']; - $time = api_time_to_hms(Tracking :: get_time_spent_on_the_course($student['user_id'], $course['real_id'])); + $time = api_time_to_hms(Tracking :: get_time_spent_on_the_course($student['user_id'], $course_code)); $students_table .= ' '.$course_title.' '.$time.' @@ -157,8 +158,7 @@ class BlockStudent extends Block { return $content; } - public function get_students_content_html_for_drh() - { + public function get_students_content_html_for_drh() { $attendance = new Attendance(); $students = $this->students; $content = '
    '; @@ -235,6 +235,7 @@ class BlockStudent extends Block {
    '; } $content .= '
    '; + return $content; } @@ -242,7 +243,8 @@ class BlockStudent extends Block { * Get number of students * @return int */ - function get_number_of_students() { + function get_number_of_students() + { return count($this->students); } -} \ No newline at end of file +} diff --git a/plugin/dashboard/block_student_graph/block_student_graph.class.php b/plugin/dashboard/block_student_graph/block_student_graph.class.php index e88f532865..0314b060b9 100644 --- a/plugin/dashboard/block_student_graph/block_student_graph.class.php +++ b/plugin/dashboard/block_student_graph/block_student_graph.class.php @@ -13,6 +13,11 @@ * required files for getting data */ +require_once api_get_path(LIBRARY_PATH).'attendance.lib.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/MyHorBar.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php'; @@ -24,7 +29,8 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php'; * the class name must be registered inside path.info file (e.g: controller = "BlockStudentGraph"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockStudentGraph extends Block { +class BlockStudentGraph extends Block +{ private $user_id; private $students; @@ -34,7 +40,8 @@ class BlockStudentGraph extends Block { /** * Constructor */ - public function __construct ($user_id) { + public function __construct ($user_id) + { $this->user_id = $user_id; $this->path = 'block_student_graph'; if ($this->is_block_visible_for_user($user_id)) { @@ -51,7 +58,8 @@ class BlockStudentGraph extends Block { * @param int User id * @return bool Is block visible for user */ - public function is_block_visible_for_user($user_id) { + public function is_block_visible_for_user($user_id) + { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; @@ -62,14 +70,15 @@ class BlockStudentGraph extends Block { } /** - * This method return content html containing information about students and its position for showing it inside dashboard interface - * it's important to use the name 'get_block' for beeing used from dashboard controller + * This method return content html containing information about students + * and its position for showing it inside dashboard interface + * it's important to use the name 'get_block' for being used from dashboard controller * @return array column and content html */ - public function get_block() { + public function get_block() + { global $charset; - $column = 1; $data = array(); $students_attendance_graph = $this->get_students_attendance_graph(); @@ -90,10 +99,12 @@ class BlockStudentGraph extends Block { } /** - * This method return a graph containing informations about students evaluation, it's used inside get_block method for showing it inside dashboard interface + * This method return a graph containing information about students evaluation, + * it's used inside get_block method for showing it inside dashboard interface * @return string img html */ - public function get_students_attendance_graph() { + public function get_students_attendance_graph() + { $students = $this->students; $attendance = new Attendance(); @@ -138,7 +149,7 @@ class BlockStudentGraph extends Block { // prepare cache for saving image $graph_id = $this->user_id.'StudentEvaluationGraph'; // the graph id - $cache = new pCache(api_get_path(SYS_ARCHIVE_PATH)); + $cache = new pCache(); $data = $data_set->GetData(); // return $this->DataDescription @@ -198,7 +209,8 @@ class BlockStudentGraph extends Block { * Get number of students * @return int */ - function get_number_of_students() { + function get_number_of_students() + { return count($this->students); } -} \ No newline at end of file +} diff --git a/plugin/dashboard/block_teacher/block_teacher.class.php b/plugin/dashboard/block_teacher/block_teacher.class.php index 8ea2b24c5d..5e30feb30f 100644 --- a/plugin/dashboard/block_teacher/block_teacher.class.php +++ b/plugin/dashboard/block_teacher/block_teacher.class.php @@ -12,10 +12,12 @@ /** * This class is used like controller for teacher block plugin, - * the class name must be registered inside path.info file (e.g: controller = "BlockTeacher"), so dashboard controller will be instantiate it + * the class name must be registered inside path.info file + * (e.g: controller = "BlockTeacher"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockTeacher extends Block { +class BlockTeacher extends Block +{ private $user_id; private $teachers; @@ -25,15 +27,12 @@ class BlockTeacher extends Block { /** * Controller */ - public function __construct ($user_id) { + public function __construct ($user_id) + { $this->user_id = $user_id; $this->path = 'block_teacher'; if ($this->is_block_visible_for_user($user_id)) { - /*if (api_is_platform_admin()) { - $this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER)); - } else {*/ - $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); - //} + $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); } } @@ -42,7 +41,8 @@ class BlockTeacher extends Block { * @param int User id * @return bool Is block visible for user */ - public function is_block_visible_for_user($user_id) { + public function is_block_visible_for_user($user_id) + { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; @@ -57,20 +57,16 @@ class BlockTeacher extends Block { * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { + public function get_block() + { global $charset; - $column = 1; - $data = array(); - - /*if (api_is_platform_admin()) { - $teacher_content_html = $this->get_teachers_content_html_for_platform_admin(); - } else if (api_is_drh()) {*/ - $teacher_content_html = $this->get_teachers_content_html_for_drh(); - //} + $data = array(); + $teacher_content_html = $this->get_teachers_content_html_for_drh(); - $html = '
  • + $html = ' +
  • '.get_lang('TeachersInformationsList').'

    @@ -78,29 +74,39 @@ class BlockTeacher extends Block {
    '.$teacher_content_html.'
    -
  • '; + + '; $data['column'] = $column; $data['content_html'] = $html; + return $data; + } /** * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ - public function get_teachers_content_html_for_platform_admin() { + public function get_teachers_content_html_for_platform_admin() + { + $teachers = $this->teachers; $content = '
    '; $content .= '

    '.get_lang('YourTeachers').'

    '; - if (count($this->teachers) > 0) { - $teachers_table = ''; - $teachers_table .= ' + + $teachers_table = null; + if (count($teachers) > 0) { + $teachers_table .= '
    '; + $teachers_table .= ' + - '; + + '; + $i = 1; - foreach ($this->teachers as $teacher) { + foreach ($teachers as $teacher) { $teacher_id = $teacher['user_id']; $firstname = $teacher['firstname']; @@ -110,62 +116,69 @@ class BlockTeacher extends Block { $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id)); $last_connection = Tracking :: get_last_connection_date($teacher_id); - if ($i%2 == 0) { - $class_tr = 'row_odd'; - } else { - $class_tr = 'row_even'; - } - $teachers_table .= ' + if ($i%2 == 0) $class_tr = 'row_odd'; + else $class_tr = 'row_even'; + + $teachers_table .= ' + - '; + + '; $i++; } $teachers_table .= '
    '.get_lang('User').' '.get_lang('TimeSpentOnThePlatform').' '.get_lang('LastConnexion').'
    '.api_get_person_name($firstname,$lastname).' ('.$username.') '.$time_on_platform.' '.$last_connection.'
    '; } else { $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); } + $content .= $teachers_table; - if (count($this->teachers) > 0) { - $content .= '
    '.get_lang('SeeMore').'
    '; + if (count($teachers) > 0) { + $content .= '
    + '.get_lang('SeeMore').'
    '; } + $content .= '
    '; + return $content; } - public function get_teachers_content_html_for_drh() { + public function get_teachers_content_html_for_drh() + { + $teachers = $this->teachers; $content = '
    '; $content .= '

    '.get_lang('YourTeachers').'

    '; - - if (count($this->teachers) > 0) { - $a_last_week = Text::get_last_week(); - $last_week = api_convert_and_format_date($a_last_week[0], DATE_FORMAT_SHORT).' '.get_lang('Until').'
    '.api_convert_and_format_date($a_last_week[6], DATE_FORMAT_SHORT); - - $teachers_table = ''; - $teachers_table .= ' + $teachers_table = null; + if (count($teachers) > 0) { + $a_last_week = get_last_week(); + $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); + + $teachers_table .= '
    '; + $teachers_table .= ' + - '; + + '; + $i = 1; - foreach ($this->teachers as $teacher) { + foreach ($teachers as $teacher) { $teacher_id = $teacher['user_id']; $firstname = $teacher['firstname']; $lastname = $teacher['lastname']; $username = $teacher['username']; - $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id, 'custom', api_get_utc_datetime($a_last_week[0]), api_get_utc_datetime($a_last_week[6]))); + $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id,true)); - if ($i%2 == 0) { - $class_tr = 'row_odd'; - } else { - $class_tr = 'row_even'; - } + if ($i%2 == 0) $class_tr = 'row_odd'; + else $class_tr = 'row_even'; $teachers_table .= ''; + $i++; } $teachers_table .= '
    '.get_lang('User').' '.get_lang('TimeSpentLastWeek').'
    '.$last_week.'
    '.api_get_person_name($firstname,$lastname).' ('.$username.') '.$time_on_platform.'
    '; @@ -175,10 +188,11 @@ class BlockTeacher extends Block { $content .= $teachers_table; - if (count($this->teachers) > 0) { + if (count($teachers) > 0) { $content .= '
    '.get_lang('SeeMore').'
    '; } $content .= '
    '; + return $content; } @@ -186,7 +200,8 @@ class BlockTeacher extends Block { * Get number of teachers * @return int */ - function get_number_of_teachers() { + function get_number_of_teachers() + { return count($this->teachers); } -} \ No newline at end of file +} diff --git a/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php b/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php index 7022937845..bd81c97a7d 100644 --- a/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php +++ b/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php @@ -9,14 +9,20 @@ /** * required files for getting data */ +require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'course.lib.php'; +require_once api_get_path(LIBRARY_PATH).'tracking.lib.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php'; +require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; /** * This class is used like controller for teacher graph block plugin, * the class name must be registered inside path.info file (e.g: controller = "BlockTeacherGraph"), so dashboard controller will be instantiate it * @package chamilo.dashboard */ -class BlockTeacherGraph extends Block { - +class BlockTeacherGraph extends Block +{ private $user_id; private $teachers; private $path; @@ -25,15 +31,12 @@ class BlockTeacherGraph extends Block { /** * Controller */ - public function __construct ($user_id) { + public function __construct ($user_id) + { $this->user_id = $user_id; $this->path = 'block_teacher_graph'; if ($this->is_block_visible_for_user($user_id)) { - /*if (api_is_platform_admin()) { - $this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER)); - } else {*/ - $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); - //} + $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); } } @@ -42,7 +45,8 @@ class BlockTeacherGraph extends Block { * @param int User id * @return bool Is block visible for user */ - public function is_block_visible_for_user($user_id) { + public function is_block_visible_for_user($user_id) + { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; @@ -57,41 +61,43 @@ class BlockTeacherGraph extends Block { * it's important to use the name 'get_block' for beeing used from dashboard controller * @return array column and content html */ - public function get_block() { + public function get_block() + { global $charset; $column = 1; $data = array(); + $teacher_information_graph = $this->get_teachers_information_graph(); + $html = ' +
  • +
    +

    '.get_lang('TeachersInformationsGraph').'

    + +
    +
    +
    '.get_lang('TimeSpentOnThePlatformLastWeekByDay').'
    + '.$teacher_information_graph.' +
    +
  • + '; - /*if (api_is_platform_admin()) { - $teacher_content_html = $this->get_teachers_content_html_for_platform_admin(); - } else if (api_is_drh()) {*/ - $teacher_information_graph = $this->get_teachers_information_graph(); - //} - - $html = '
  • -
    -

    '.get_lang('TeachersInformationsGraph').'

    - -
    -
    -
    '.get_lang('TimeSpentOnThePlatformLastWeekByDay').'
    - '.$teacher_information_graph.' -
    -
  • '; $data['column'] = $column; $data['content_html'] = $html; + return $data; + } /** * This method return a content html, it's used inside get_block method for showing it inside dashboard interface * @return string content html */ - public function get_teachers_information_graph() { + public function get_teachers_information_graph() + { $teachers = $this->teachers; $graph = ''; + $user_ids = array_keys($teachers); - $a_last_week = Text::get_last_week(); + $a_last_week = get_last_week(); if (is_array($user_ids) && count($user_ids) > 0) { $data_set = new pData; @@ -100,18 +106,20 @@ class BlockTeacherGraph extends Block { $username = $teacher_info['username']; $time_by_days = array(); foreach ($a_last_week as $day) { + // day is received as y-m-d 12:00:00 $start_date = api_get_utc_datetime($day); $end_date = api_get_utc_datetime($day+(3600*24-1)); + $time_on_platform_by_day = Tracking::get_time_spent_on_the_platform($user_id, 'custom', $start_date, $end_date); $hours = floor($time_on_platform_by_day / 3600); $min = floor(($time_on_platform_by_day - ($hours * 3600)) / 60); $time_by_days[] = $min; } - $data_set->AddPoint($time_by_days, $username); + $data_set->AddPoint($time_by_days,$username); $data_set->AddSerie($username); } - $last_week = date('Y-m-d', $a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); + $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); $days_on_week = array(); foreach ($a_last_week as $weekday) { $days_on_week[] = date('d/m',$weekday); @@ -124,7 +132,7 @@ class BlockTeacherGraph extends Block { $data_set->SetAbsciseLabelSerie("Days"); $graph_id = $this->user_id.'TeacherConnectionsGraph'; - $cache = new pCache(api_get_path(SYS_ARCHIVE_PATH)); + $cache = new pCache(); // the graph id $data = $data_set->GetData(); @@ -169,6 +177,7 @@ class BlockTeacherGraph extends Block { } else { $graph = '

    '.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'

    '; } + return $graph; } @@ -176,7 +185,9 @@ class BlockTeacherGraph extends Block { * Get number of teachers * @return int */ - function get_number_of_teachers() { + function get_number_of_teachers() + { return count($this->teachers); } -} \ No newline at end of file + +} diff --git a/plugin/date/plugin.php b/plugin/date/plugin.php index 2f0db43ca4..2822ac1cc6 100644 --- a/plugin/date/plugin.php +++ b/plugin/date/plugin.php @@ -1,4 +1,4 @@ -Plugins) @@ -15,4 +15,4 @@ $plugin_info['comment']="Multinational date display"; //the plugin version $plugin_info['version']='1.0'; //the plugin author -$plugin_info['author']='Yannick Warnier'; \ No newline at end of file +$plugin_info['author']='Yannick Warnier'; diff --git a/plugin/ext_auth_chamilo_logout_button_behaviour/index.php b/plugin/ext_auth_chamilo_logout_button_behaviour/index.php index 5da0e9b154..a4749fe7f0 100755 --- a/plugin/ext_auth_chamilo_logout_button_behaviour/index.php +++ b/plugin/ext_auth_chamilo_logout_button_behaviour/index.php @@ -1,9 +1,12 @@ addElement('style_submit_button', 'submit_button', get_lang('Save')); //get default value for form $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url'); $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_infobulle = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_infobulle'); -$tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_image = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_image'); +$Tab_Default_Ext_Auth_Chamilo_Logout_Button_Behaviour_Eaclbb_Form_Link_Image = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_image'); $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_onoff = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_onoff'); $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_text = api_get_setting('ext_auth_chamilo_logout_button_behaviour_eaclbb_form_alert_text'); $defaults['eaclbb_form_link_url'] = $tab_default_ext_auth_chamilo_logout_button_behaviour_eaclbb_form_link_url['eaclbb_form_link_url']; @@ -44,5 +43,5 @@ $form->setDefaults($defaults); //display form $plugin_info['settings_form'] = $form; -//set the smarty templates that are going to be used +// Set the templates that are going to be used $plugin_info['templates'] = array('template.tpl'); diff --git a/plugin/formLogin_hide_unhide/plugin.php b/plugin/formLogin_hide_unhide/plugin.php index a9dc57ec72..b7180590bc 100644 --- a/plugin/formLogin_hide_unhide/plugin.php +++ b/plugin/formLogin_hide_unhide/plugin.php @@ -9,8 +9,6 @@ * Plugin details (must be present) */ - - //the plugin title $plugin_info['title'] = 'Hide/Unhide the Login/Password default form'; diff --git a/plugin/hello_world/index.php b/plugin/hello_world/index.php index 3d74c3029f..4b1f02967a 100644 --- a/plugin/hello_world/index.php +++ b/plugin/hello_world/index.php @@ -3,13 +3,13 @@ * @package chamilo.plugin.hello_world */ -// See also the share_user_info plugin +// See also the share_user_info plugin echo '
    '; if (!empty($plugin_info['settings']['hello_world_show_type'])) { echo "

    ".$plugin_info['settings']['hello_world_show_type']."

    "; } else { - echo "

    Hello world

    "; + echo "

    Hello world

    "; } //Using get_lang inside a plugin diff --git a/plugin/hello_world/plugin.php b/plugin/hello_world/plugin.php index cb7851b019..57bd19f160 100644 --- a/plugin/hello_world/plugin.php +++ b/plugin/hello_world/plugin.php @@ -1,6 +1,7 @@ Plugins) * @package chamilo.plugin * @author Julio Montoya @@ -20,11 +21,10 @@ $plugin_info['version'] = '1.0'; //the plugin author $plugin_info['author'] = 'Julio Montoya'; +/* Plugin optional settings */ -/* Plugin optional settings */ - -/* - * This form will be showed in the plugin settings once the plugin was installed +/* + * This form will be showed in the plugin settings once the plugin was installed * in the plugin/hello_world/index.php you can have access to the value: $plugin_info['settings']['hello_world_show_type'] */ @@ -33,6 +33,6 @@ $form = new FormValidator('hello_world_form'); //A simple select $options = array('hello_world' => 'Hello World', 'hello' =>'Hello', 'hi' =>'Hi!'); $form->addElement('select', 'show_type', 'Hello world types', $options); -$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); +$form->addElement('style_submit_button', 'submit_button', get_lang('Save')); -$plugin_info['settings_form'] = $form; \ No newline at end of file +$plugin_info['settings_form'] = $form; diff --git a/plugin/olpc_peru_filter/config.php b/plugin/olpc_peru_filter/config.php index 296aea80b5..8e2e055145 100644 --- a/plugin/olpc_peru_filter/config.php +++ b/plugin/olpc_peru_filter/config.php @@ -3,7 +3,7 @@ /* OLPCPeruFilter parameters that will be registered in the course settings */ -require_once __DIR__.'/../../main/inc/global.inc.php'; +require_once '../../main/inc/global.inc.php'; require_once 'lib/olpc_peru_filter_plugin.class.php'; /** diff --git a/plugin/openmeetings/config.php b/plugin/openmeetings/config.php new file mode 100644 index 0000000000..9cc0fba19e --- /dev/null +++ b/plugin/openmeetings/config.php @@ -0,0 +1,12 @@ +install(); diff --git a/plugin/openmeetings/lang/english.php b/plugin/openmeetings/lang/english.php new file mode 100644 index 0000000000..c40460a28e --- /dev/null +++ b/plugin/openmeetings/lang/english.php @@ -0,0 +1,57 @@ + + */ + +//Needed in order to show the plugin title +$strings['plugin_title'] = "OpenMeetings"; +$strings['plugin_comment'] = "Add a videoconference room in a Chamilo course using OpenMeetings"; + +$strings['Videoconference'] = "Videoconference"; +$strings['MeetingOpened'] = "Meeting opened"; +$strings['MeetingClosed'] = "Meeting closed"; +$strings['MeetingClosedComment'] = "If you have asked for your sessions to be recorded, the recording will be available in the list below when it has been completely generated."; +$strings['CloseMeeting'] = "Close meeting"; + +$strings['MeetingDeleted'] = "Delete meeting"; +$strings['MeetingDeletedComment'] = ""; + +$strings['VideoConferenceXCourseX'] = "Videoconference #%s course %s"; +$strings['VideoConferenceAddedToTheCalendar'] = "Videoconference added to the calendar"; +$strings['VideoConferenceAddedToTheLinkTool'] = "Videoconference added to the link tool"; + +$strings['GoToTheVideoConference'] = "Go to the videoconference"; + +$strings['Records'] = "Recording"; +$strings['Meeting'] = "Meeting"; + +$strings['ViewRecord'] = "View recording"; +$strings['CopyToLinkTool'] = "Copy to link tool"; + +$strings['EnterConference'] = "Enter the videoconference"; +$strings['RecordList'] = "Recording list"; +$strings['ServerIsNotRunning'] = "Videoconference server is not running"; +$strings['ServerIsNotConfigured'] = "Videoconference server is not configured"; + +$strings['XUsersOnLine'] = "%s user(s) online"; + +$strings['host'] = 'OpenMeetings host'; +$strings['host_help'] = 'This is the full address of your OpenMeeetings server interface. Might be http://localhost:5080/openmeetings, an IP address (e.g. http://192.168.13.54:5080/openmeetings) or a domain name (e.g. http://my.video.com:5080/openmeetings).'; + +$strings['salt'] = 'OpenMeetings salt'; +$strings['salt_help'] = 'This is the security key of your OpenMeetings server, which will allow your server to authentify the Chamilo installation. Refer to the OpenMeetings documentation to locate it.'; + +$strings['tool_enable'] = 'OpenMeetings videoconference tool enabled'; +$strings['tool_enable_help'] = 'Choose whether you want to enable the OpenMeetings videoconference tool. Once enabled, it will show as an additional course tool in all courses homepage, and teachers will be able to launch a conference at any time. Students will not be able to launch a conference, only join one. If you don\'t have an OpenMeetings server, please set one up or ask the Chamilo official providers for a quote. OpenMeetings is a free (as in freedom *and* beer), but its installation requires a set of technical skills that might not be immediately available to all. You can install it on your own or seek professional help to assist you or do it for you. This help, however, will generate a certain cost. In the pure logic of the free software, we offer you the tools to make your work easier and recommend professionals (the Chamilo Official Providers) that will be able to help you if this were too difficult.
    '; + +$strings['openmeetings_welcome_message'] = 'Welcome message'; +$strings['openmeetings_record_and_store'] = 'Record and store sessions'; + +$strings['plugin_tool_openmeetings'] = 'Video'; + +$strings['ThereAreNotRecordingsForTheMeetings'] = 'There are not recording for the meeting sessions'; +$strings['NoRecording'] = 'No recording'; + diff --git a/plugin/openmeetings/lang/french.php b/plugin/openmeetings/lang/french.php new file mode 100644 index 0000000000..21f8fd140d --- /dev/null +++ b/plugin/openmeetings/lang/french.php @@ -0,0 +1,50 @@ +en installer un avant de poursuivre, ou demander un devis à l'un des fournisseurs officiels de Chamilo. OpenMeetings est un outil de logiciel libre (et gratuit), mais son installation pourrait présenter une certaine complexité et demander des compétences qui ne sont peut-être pas à la portée de tous. Vous pouvez l'installer vous-même à partir de la documentation (disponible publiquement) de OpenMeetings, ou recherchez un soutien professionnel. Ce soutien pourrait générer certains coûts (au moins le temps de la personne qui vous assiste dans l'opération). Dans le plus pur esprit du logiciel libre, nous vous fournissons les outils pour simplifier votre travail dans la mesure de nos possibilités, et nous vous recommandons des professionnels (les fournisseurs officiels de Chamilo) pour vous venir en aide au cas où ceux-ci seraient insuffisants.
    "; + +$strings['openmeetings_welcome_message'] = 'Message de bienvenue de OpenMeetings'; +$strings['openmeetings_record_and_store'] = 'Enregistrer les sessions de vidéoconférence'; + +$strings['plugin_tool_openmeetings'] = 'Vidéo'; + +$strings['ThereAreNotRecordingsForTheMeetings'] = 'Aucun enregistrement disponible'; +$strings['NoRecording'] = "Pas d'enregistrement"; + diff --git a/plugin/openmeetings/lang/spanish.php b/plugin/openmeetings/lang/spanish.php new file mode 100644 index 0000000000..4195abb3d5 --- /dev/null +++ b/plugin/openmeetings/lang/spanish.php @@ -0,0 +1,53 @@ +configure uno antes de seguir, o pida una cotización a uno de los proveedores oficiales de Chamilo. OpenMeetings es una herramienta de software libre (y gratuita), pero su instalación requiere de competencias que quizás no sean inmediatamente disponibles para todos. Puede instalarla usted mismo o buscar ayuda profesional. Esta ayuda podría no obstante generar algunos costos (por lo menos el tiempo de la persona quien lo ayude). En el puro espíritu del software libre, le ofrecemos las herramientas para hacer su trabajo más simple, en la medida de nuestras posibilidades, y le recomendamos profesionales (los proveedores oficiales de Chamilo) para ayudarlo en caso esto fuera demasiado complicado.
    '; + +$strings['openmeetings_welcome_message'] = 'Mensaje de bienvenida de '; +$strings['openmeetings_record_and_store'] = 'Grabar las sesiones de videoconferencia'; + +$strings['plugin_tool_openmeetings'] = 'Video'; + +$strings['ThereAreNotRecordingsForTheMeetings'] = 'No hay grabaciones de sesiones de videoconferencia'; +$strings['NoRecording'] = 'No hay grabación'; + diff --git a/plugin/openmeetings/lib/openmeetings.class.php b/plugin/openmeetings/lib/openmeetings.class.php new file mode 100644 index 0000000000..3d1e24e7ca --- /dev/null +++ b/plugin/openmeetings/lib/openmeetings.class.php @@ -0,0 +1,631 @@ +get('tool_enable'); + $om_host = $plugin->get('host'); + $om_user = $plugin->get('user'); + $om_pass = $plugin->get('pass'); + $accessUrl = api_get_access_url($_configuration['access_url']); + $this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://')+3, -1); + if (strcmp($this->externalType, 'localhost') == 0) { + $this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://')+3, -1); + } + $this->externalType = 'chamilolms.'.$this->externalType; + $this->table = \Database::get_main_table('plugin_openmeetings'); + + if ($om_plugin) { + $user_info = api_get_user_info(); + $this->user_complete_name = $user_info['complete_name']; + $this->user = $om_user; + $this->pass = $om_pass; + $this->url = $om_host; + + // Setting OM api + define('CONFIG_OPENMEETINGS_USER', $this->user); + define('CONFIG_OPENMEETINGS_PASS', $this->pass); + define('CONFIG_OPENMEETINGS_SERVER_URL', $this->url); + + $this->gateway = new \OpenMeetingsGateway($this->url, $this->user, $this->pass); + $this->plugin_enabled = $om_plugin; + // The room has a name composed of C + course ID + '-' + session ID + $this->chamiloCourseId = api_get_course_int_id(); + $this->chamiloSessionId = api_get_session_id(); + $this->roomName = 'C'.$this->chamiloCourseId.'-'.$this->chamiloSessionId; + $return = $this->gateway->loginUser(); + if ($return == 0) { + $msg = 'Could not initiate session with server through OpenMeetingsGateway::loginUser()'; + error_log(__FILE__.'+'.__LINE__.': '.$msg); + die($msg); + } + $this->sessionId = $this->gateway->sessionId; + } + } + + /** + * 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 + */ + public function isTeacher() + { + return api_is_course_admin() || api_is_coach() || api_is_platform_admin(); + } + + /** + * Login the user with OM Server. This generates a session ID that is + * specific to the current user, but that does not require specific user data + * + * It is similar to opening a PHP session. In fact, the session ID is kept + * inside the $_SESSION['openmeetings_session'] session variable + * @return bool True if the user is correct and false when is incorrect + * @deprecated loginUser now called at object instanciation + */ + /** + function loginUser() + { + try { + //Verifying if there is already an active session + if (empty($_SESSION['openmeetings_session'])) { + // Login user returns either 0 or >0, depending on the results + // Technically, as long as the SOAP user has been configured in OpenMeetings and OpenMeetings is on, this should always succeed. + if ($this->gateway->loginUser()) { + $this->sessionId = $_SESSION['openmeetings_session'] = $this->gateway->session_id; + return true; + } else { + error_log('loginUser did not succeed'); + return false; + } + } else { + $this->sessionId = $_SESSION['openmeetings_session']; + return true; + } + } catch (SoapFault $e) { + error_log(__FILE__.'+'.__LINE__.' Warning: We have detected some problems. Fault: '.$e->faultstring); + return false; + } + } + */ + + /* + * Creating a Room for the meeting + * @return bool True if the user is correct and false when is incorrect + */ + public function createMeeting($params) + { + global $_configuration; + // First, try to see if there is an active room for this course and session. + $roomId = null; + + $meetingData = \Database::select( + '*', + $this->table, + array( + 'where' => + array( + 'c_id = ?' => $this->chamiloCourseId, + ' AND session_id = ? ' => $this->chamiloSessionId, + ' AND status <> ? ' => 2, + + ) + ), + 'first' + ); + + if ($meetingData != false && count($meetingData) > 0) { + //error_log(print_r($meetingData,1)); + //error_log('Found previous room reference - reusing'); + // There has been a room in the past for this course. It should + // still be on the server, so update (instead of creating a new one) + // This fills the following attributes: status, name, comment, chamiloCourseId, chamiloSessionId + $room = new Room(); + $room->loadRoomId($meetingData['room_id']); + $roomArray = (array)$room; + $roomArray['SID'] = $this->sessionId; + $roomId = $this->gateway->updateRoomWithModeration($room); + if ($roomId != $meetingData['room_id']) { + $msg = 'Something went wrong: the updated room ID ('.$roomId.') is not the same as the one we had ('.$meetingData['room_id'].')'; + error_log($msg); + die($msg); + } + + } else { + //error_log('Found no previous room - creating'); + $room = new Room(); + $room->SID = $this->sessionId; + $room->name = $this->roomName; + //$room->roomtypes_id = $room->roomtypes_id; + $room->comment = urlencode(get_lang('Course').': ' . $params['meeting_name'] . ' - '.$_configuration['software_name']); + //$room->numberOfPartizipants = $room->numberOfPartizipants; + $room->ispublic = $room->getString('isPublic', 'false'); + //$room->appointment = $room->getString('appointment'); + //$room->isDemoRoom = $room->getString('isDemoRoom'); + //$room->demoTime = $room->demoTime; + //$room->isModeratedRoom = $room->getString('isModeratedRoom'); + $roomId = $this->gateway->createRoomWithModAndType($room); + } + + if (!empty($roomId)) { + /* + // Find the biggest room_id so far, and create a new one + if (empty($roomId)) { + $roomData = \Database::select('MAX(room_id) as room_id', $this->table, array(), 'first'); + $roomId = $roomData['room_id'] + 1; + }*/ + + $params['status'] = '1'; + $params['meeting_name'] = $room->name; + $params['created_at'] = api_get_utc_datetime(); + $params['room_id'] = $roomId; + $params['c_id'] = api_get_course_int_id(); + $params['session_id'] = api_get_session_id(); + $params['record'] = ($room->allowRecording?1:0); + + $id = \Database::insert($this->table, $params); + + $this->joinMeeting($id); + } else { + return -1; + } + } + + /** + * Returns a meeting "join" URL + * @param string The name of the meeting (usually the course code) + * @return mixed The URL to join the meeting, or false on error + * @todo implement moderator pass + * @assert ('') === false + * @assert ('abcdefghijklmnopqrstuvwxyzabcdefghijklmno') === false + */ + public function joinMeeting($meetingId) + { + if (empty($meetingId)) { + return false; + } + $meetingData = \Database::select( + '*', + $this->table, + array('where' => array('id = ? AND status = 1 ' => $meetingId)), + 'first' + ); + + if (empty($meetingData)) { + if ($this->debug) { + error_log("meeting does not exist: $meetingId "); + } + return false; + } + $params = array('room_id' => $meetingData['room_id']); + $returnVal = $this->setUserObjectAndGenerateRoomHashByURLAndRecFlag($params); + $iframe = $this->url . "/?" ."secureHash=" . $returnVal; + printf(" +
    + '; + + // Phone + echo '
    '.get_lang('Phone').' ('.$plugin->get_lang('Optional').'):
    +
    +
    '; + + // Priority + $select_priority = '
    +
    '.$plugin->get_lang('Priority').':
    +
    '; + + $priority = array(); + $priority[NORMAL] = $plugin->get_lang('PriorityNormal'); + $priority[HIGH] = $plugin->get_lang('PriorityHigh'); + $priority[LOW] = $plugin->get_lang('PriorityLow'); + + $select_priority .= '"; + $select_priority .= '
    '; + echo $select_priority; + + // Input file attach + echo '
    +
    '.get_lang('FilesAttachment').'
    +
    + +
    + +
    +
    +
    '; + echo '
    +
    + + '.get_lang('AddOneMoreFile').'  + ('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).') +
    +
    '; + echo '
    +
    +
    +
    +
    +
    '; + echo ''; +} +function save_ticket(){ + global $plugin; + $category_id = $_POST['category_id']; + $content = $_POST['content']; + if ($_POST['phone']!="") $content.= '

     '.get_lang('Phone').': '.$_POST['phone'].'

    '; + $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')); + } +} +/** + * 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"; + 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)"; + } + 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 + * @param int Number of users to get + * @param int Column to sort on + * @param string Order (ASC,DESC) + * @see SortableTable#get_table_data($from) + */ +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 "; + + 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); + $number_of_items = intval($number_of_items); + + $sql .= " ORDER BY col$column $direction "; + $sql .= " LIMIT $from,$number_of_items"; + + $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 = '
    '.api_get_person_name($user[2],$user[3]).'
    '; + } else { + $photo = '
    '.api_get_person_name($user[2], $user[3]).'
    '; + } + $user_id= $user[0]; + $button = ''.Display::return_icon('view_more_stats.gif', get_lang('Info')).''; + $button= ' + '.get_lang('Courses').' +   '; + $users[] = array($photo,$user[1],$user[2],$user[3],$user[4],$user[5],$button); + } + return $users; +} + + + + if(!isset($_POST['compose'])){ + Display::display_header(get_lang('ComposeMessage')); + echo ' +
    +   + +
    '; + 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(); + } + //if(isset($_GET['user_request'])) + show_form_send_ticket(); + }else{ + save_ticket(); + } + + + +Display::display_footer(); +?> \ No newline at end of file diff --git a/plugin/ticket/s/report.php b/plugin/ticket/s/report.php new file mode 100644 index 0000000000..72a91e1d8e --- /dev/null +++ b/plugin/ticket/s/report.php @@ -0,0 +1,289 @@ + +$(document).ready(function(){ + $( "#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; + } + } +} +function load_course_list (div_course,my_user_id) { + $.ajax({ + contentType: "application/x-www-form-urlencoded", + type: "GET", + url: "course_user_list.php", + data: "user_id="+my_user_id, + success: function(datos) { + $("div#user_request").html(datos); + $("#btnsubmit").attr("disabled", false); + } + }); +} + + +'; +$types = TicketManager::get_all_tickets_categories(); +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; +$tools = array(); +$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\"\\").'"'; +} + +function show_form(){ + global $types; + global $tools; + echo '
    '; + echo '
    '; + + $courses_list = CourseManager::get_courses_list_by_user_id($user_id,false,true); + $select_course = '
    +
    '; + echo $select_course; + //select status + $select_tool = '
    +
    Herramienta:
    +
    '; + $select_tool .= '"; + $select_tool .= '
    '; + echo $select_tool; + echo '
    +
    Desde:
    +
    +
    +
    +
    Hasta
    +
    +
    '; + echo '
    '; + echo '
    +
    +
    +
    + +
    +
    '; + +} +/** + * 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"; + 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)"; + } + 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 + * @param int Number of users to get + * @param int Column to sort on + * @param string Order (ASC,DESC) + * @see SortableTable#get_table_data($from) + */ +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 "; + + 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); + $number_of_items = intval($number_of_items); + + $sql .= " ORDER BY col$column $direction "; + $sql .= " LIMIT $from,$number_of_items"; + + $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 = '
    '.api_get_person_name($user[2],$user[3]).'
    '; + } else { + $photo = '
    '.api_get_person_name($user[2], $user[3]).'
    '; + } + $user_id= $user[0]; + $button = ''.Display::return_icon('view_more_stats.gif', get_lang('Info')).''; + $button= ' + '.get_lang('Courses').' +   '; + $users[] = array($photo,$user[1],$user[2],$user[3],$user[4],$user[5],$button); + } + return $users; +} + + + +Display::display_header('Reportes'); + echo '
    + + + + +
     
    +
    '; + 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(); + } + //if(isset($_GET['user_request'])) + + 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' "; + $start_date = $_POST['keyword_start_date_start']; + $end_date = $_POST['keyword_start_date_end']; + if ($start_date != '' || $end_date != ''){ + $sql .= " HAVING "; + if ($start_date != '') $sql .= " access_date >= '$start_date' "; + if ($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->addRow($row); + } + $table_result->display(); + + + }else{ + show_form(); + } + + + +Display::display_footer(); + +?> \ No newline at end of file diff --git a/plugin/ticket/s/send_ticket.php b/plugin/ticket/s/send_ticket.php new file mode 100644 index 0000000000..1718a6abdc --- /dev/null +++ b/plugin/ticket/s/send_ticket.php @@ -0,0 +1,246 @@ + +$(document).ready(function(){ + if(document.getElementById("divEmail")){ + document.getElementById("divEmail").style.display="none"; + } +}); +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"; + 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; + }else{ + document.getElementById("divCourse").style.display = ""; + document.getElementById("course_id").disabled=false; + document.getElementById("course_id").value=0; + document.getElementById("personal_email").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( 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; +function remove_image_form(id_elem1) { + var elem1 = document.getElementById(id_elem1); + elem1.parentNode.removeChild(elem1); + counter_image = counter_image - 1; +} +function add_image_form() { + // Multiple filepaths for image form + var filepaths = document.getElementById("filepaths"); + if (document.getElementById("filepath_"+counter_image)) { + counter_image = counter_image + 1; + } else { + counter_image = counter_image; + } + var elem1 = document.createElement("div"); + elem1.setAttribute("id","filepath_"+counter_image); + filepaths.appendChild(elem1); + id_elem1 = "filepath_"+counter_image; + id_elem1 = "\'"+id_elem1+"\'"; + document.getElementById("filepath_"+counter_image).innerHTML = " "; + //document.getElementById("filepath_"+counter_image).innerHTML = " "; + if (filepaths.childNodes.length == 6) { + var link_attach = document.getElementById("link-more-attach"); + if (link_attach) { + link_attach.innerHTML=""; + } + } +} +function show_question(questionid){ + if(document.getElementById("C"+questionid)){ + if(document.getElementById("A"+questionid).style.display == "none"){ + document.getElementById("A"+questionid).style.display = ""; + } + else if(document.getElementById("A"+questionid).style.display == ""){ + document.getElementById("A"+questionid).style.display = "none"; + } + } +} + + +'; +$types = TicketManager::get_all_tickets_categories(); +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; +$htmlHeadXtra[] = ''; + +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; +} + +function show_form_send_ticket(){ + global $types, $plugin; + $courses_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(),false,true); + echo '
    '; + echo '
    '; + $select_types = '
    +
    '.get_lang('Category').':
    +
    '; + $select_types .= '"; + $select_types .= '
    '; + echo $select_types; + $select_course = '
    +
    '.get_lang('Course').':
    +
    '; + $select_course .= '"; + $select_course .= '
    '; + echo $select_course; + echo '
    '.get_lang('Subject').':
    +
    +
    '; + echo '
    '.$plugin->get_lang('PersonalEmail').':
    +
    +
    '; + echo ''; + echo ''; + echo ''; + echo '
    +
    '.get_lang('Message').'
    +
    + + + +
    +
    '; + echo '
    '.get_lang('Phone').' ('.$plugin->get_lang('Optional').'):
    +
    +
    '; + echo '
    +
    '.get_lang('FilesAttachment').'
    +
    + +
    + +
    +
    +
    '; + echo '
    +
    + + '.get_lang('AddOneMoreFile').'  + ('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).') +
    +
    '; + echo '
    +
    +
    +
    +
    +
    '; + echo '
    '; +} + +function save_ticket(){ + $category_id = $_POST['category_id']; + $content = $_POST['content']; + if ($_POST['phone']!="") $content.= '

     '.get_lang('Phone').': '.$_POST['phone'].'

    '; + $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')); + } +} + +if(!isset($_POST['compose'])){ + Display::display_header(get_lang('ComposeMessage')); + show_form_send_ticket(); +}else{ + save_ticket(); +} + +Display::display_footer(); \ No newline at end of file diff --git a/plugin/ticket/s/test.html b/plugin/ticket/s/test.html new file mode 100644 index 0000000000..57b286727c --- /dev/null +++ b/plugin/ticket/s/test.html @@ -0,0 +1,15 @@ +
    + + Añadir usuarios + + +
    \ No newline at end of file diff --git a/plugin/ticket/s/ticket.class.php b/plugin/ticket/s/ticket.class.php new file mode 100644 index 0000000000..64e285ec28 --- /dev/null +++ b/plugin/ticket/s/ticket.class.php @@ -0,0 +1,673 @@ + 0){ + $status = REENVIADO; + } + } + + if($request_user == ''&& $source == 'VRT'){ + $request_user = $user_id; + } + $course_id = intval($course_id); + $sql_insert_ticket= "INSERT INTO ".$table_support_tickets." (project_id,category_id,priority_id,course_id, request_user, personal_email ,status_id, start_date,sys_insert_user_id,sys_insert_datetime,sys_lastedit_user_id,sys_lastedit_datetime,source) + VALUES ('$project_id','$category_id','$priority','$course_id','$request_user','$personalemail','$status','".$now."',$user_id,'".$now."','$user_id','".$now."','$source')"; + $result = Database::query($sql_insert_ticket); + $ticket_id = Database::insert_id(); + if ( $assigned_user!= 0){ + self::assign_ticket_user($ticket_id, $assigned_user); + } + if($ticket_id != 0){ + $ticket_code ="A".str_pad((int) $ticket_id,11,"0",STR_PAD_LEFT); + $sql_update_code = "UPDATE ".$table_support_tickets." SET ticket_code = '$ticket_code' WHERE ticket_id = '$ticket_id'"; + Database::query($sql_update_code); + $data_files = array(); + $sql_update_total = "UPDATE ".$table_support_category." SET total_tickets = total_tickets +1 WHERE category_id = '$category_id';"; + Database::query($sql_update_total); + if(self::insert_message($ticket_id, $subject, $content,$file_attachments, $request_user)){ + global $data_files; + if($other_area){ + $user = UserManager::get_user_info_by_id($request_user); + $mensaje_helpdesk = ' + + + + + + + + + + + + + + + + + + + + +
    Cliente:'.$user['firstname'].' '.$user['lastname'].'
    Usuario:'.$user['username'].'
    Fecha:'.api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG).'
    Asunto:'.$subject.'
    Descripción:'.$content.'
    '; + api_mail_html('Soporte virtual', $email, "[SOPORTE] Incidente Reenviado de Soporte Virtual", $mensaje_helpdesk,$user['firstname'].' '.$user['lastname'], $personalemail, array('cc'=>'soportevirtual@usil.edu.pe'), $data_files); + $mensaje_alumno ='

    Su consulta fue reenviada al area responsable : '.$email.'

    '; + $mensaje_alumno .='

    La respuesta a su consulta será enviada al correo : '.$personalemail.'

    '; + self::insert_message($ticket_id, "Mensaje Reenviado", $mensaje_alumno, null, 1); + } + return true; + }else{ + return false; + } + }else{ + return false; + } + } + public static function insert_message($ticket_id,$subject,$content,$file_attachments,$user_id,$status='NOL',$envioconfirmacion=false){ + global $data_files; + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_message_attachments = Database::get_main_table(TABLE_SUPPORT_MESSAGE_ATTACHMENTS); + if ($envioconfirmacion){ + $formulario = '
    +

    Esta respuesta le resultó satisfactoria

    + + +
    '; + $content.=$formulario; + Database::query("UPDATE $table_support_tickets SET status_id='XCF' WHERE ticket_id = '$ticket_id'"); + } + $sql_message_id = "SELECT COUNT(*) as total_messages FROM ".$table_support_messages." WHERE ticket_id ='$ticket_id'"; + $result = Database::query($sql_message_id); + $obj = Database::fetch_object($result); + $message_id = $obj->total_messages+1; + $now = api_get_utc_datetime(); + $sql_insert_message = "INSERT INTO ".$table_support_messages." (ticket_id,message_id,subject, message,ip_address,sys_insert_user_id,sys_insert_datetime,sys_lastedit_user_id,sys_lastedit_datetime,status) + VALUES ('$ticket_id','$message_id','$subject','$content','".$_SERVER['REMOTE_ADDR']."','$user_id','".$now."','$user_id','".$now."','$status');"; + Database::query($sql_insert_message); + $sql_update_total_message ="UPDATE ".$table_support_tickets." SET sys_lastedit_user_id ='$user_id' , sys_lastedit_datetime ='".$now."' , total_messages = ("."SELECT COUNT(*) as total_messages FROM ".$table_support_messages." WHERE ticket_id ='$ticket_id'".") WHERE ticket_id ='$ticket_id' "; + Database::query($sql_update_total_message); + $sql_message_att_id = "SELECT COUNT(*) as total_attach FROM ".$table_support_message_attachments." WHERE ticket_id ='$ticket_id' AND message_id = '$message_id'"; + $result = Database::query($sql_message_att_id); + $obj = Database::fetch_object($result); + $message_attch_id = $obj->total_attach+1; + if (is_array($file_attachments)) { + foreach ($file_attachments as $file_attach) { + if ($file_attach['error'] == 0) { + $data_files[] = self::save_message_attachment_file($file_attach,$ticket_id,$message_id,$message_attch_id); + $message_attch_id++; + }else{ + if($file_attach['error']!=UPLOAD_ERR_NO_FILE )return false; + } + } + } + return true; + + + } + public static function save_message_attachment_file($file_attach,$ticket_id,$message_id,$message_attch_id) { + $now = api_get_ut; + $user_id = api_get_user_id(); + $new_file_name = add_ext_on_mime(stripslashes($file_attach['name']), $file_attach['type']); + $file_name =$file_attach['name']; + $table_support_message_attachments = Database::get_main_table(TABLE_SUPPORT_MESSAGE_ATTACHMENTS); + if (!filter_extension($new_file_name)) { + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); + } else { + $new_file_name = uniqid(''); + $path_attachment = api_get_path(SYS_PATH); + $path_message_attach =$path_attachment.'tck_messageattch/'; + if (!file_exists($path_message_attach)) { + @mkdir($path_message_attach, api_get_permissions_for_new_directories(), true); + } + $new_path=$path_message_attach.$new_file_name; + if (is_uploaded_file($file_attach['tmp_name'])) { + $result= @copy($file_attach['tmp_name'], $new_path); + } + $safe_file_comment= Database::escape_string($file_comment); + $safe_file_name = Database::escape_string($file_name); + $safe_new_file_name = Database::escape_string($new_file_name); + $sql="INSERT INTO ".$table_support_message_attachments."(filename, path,ticket_id,message_id,message_attch_id,size,sys_insert_user_id,sys_insert_datetime,sys_lastedit_user_id,sys_lastedit_datetime) + VALUES ( '$safe_file_name', '$safe_new_file_name' , '$ticket_id','$message_id', '$message_attch_id','".$file_attach['size']."','$user_id','".$now."','$user_id','".$now."' )"; + $result=Database::query($sql); + return array('path' => $path_message_attach.$safe_new_file_name,'filename' => $safe_file_name); + } + } + public static function get_tickets_by_user_id($from, $number_of_items, $column, $direction ,$user_id=null){ + $table_support_category = Database::get_main_table(TABLE_SUPPORT_CATEGORY); + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_priority = Database::get_main_table(TABLE_SUPPORT_PRIORITY); + $table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS); + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $table_main_user = Database::get_main_table(TABLE_MAIN_USER); + $table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN); + if(is_null($direction)) $direction ="DESC"; + if(is_null($user_id) || $user_id==0){ + $user_id = api_get_user_id(); + } + + $isAdmin = UserManager::is_admin($user_id); + $sql = "SELECT ticket.*, ticket.ticket_id AS col0,ticket.start_date AS col1, ticket.sys_lastedit_datetime AS col2 ,cat.name AS col3,user.username AS col4, priority.priority AS col5 , + priority.priority AS col6, status.name AS col7 , ticket.total_messages AS col8, msg.message AS col9, ticket.request_user AS user_id , ticket.assigned_last_user AS responsable + FROM ".$table_support_tickets." ticket ,".$table_support_category." cat , ".$table_support_priority ." priority, ".$table_support_status ." status , ".Database::get_main_table(TABLE_MAIN_USER)." user, tck_message msg + WHERE cat.category_id = ticket.category_id AND ticket.priority_id = priority.priority_id AND ticket.status_id = status.status_id AND user.user_id = ticket.request_user + AND ticket.ticket_id= msg.ticket_id AND message_id=1 "; + if(!$isAdmin){ + $sql.=" AND request_user = '$user_id' "; + } + $keyword_unread = Database::escape_string(trim($_GET['keyword_unread'])); + //Search simple + if(isset($_GET['submit_simple'])){ + if($_GET['keyword']!=''){ + $keyword = Database::escape_string(trim($_GET['keyword'])); + $sql.=" AND (ticket.ticket_code = '".$keyword."' OR ticket.ticket_id = '".$keyword."' OR user.firstname LIKE '%".$keyword."%' OR user.lastname LIKE '%".$keyword."%' OR concat(user.firstname,' ',user.lastname) LIKE '%".$keyword."%' OR concat(user.lastname,' ',user.firstname) LIKE '%".$keyword."%' OR user.username LIKE '%".$keyword."%') "; + } + } + //Search advanced + if(isset($_GET['submit_advanced'])){ + $keyword_category = Database::escape_string(trim($_GET['keyword_category'])); + $keyword_request_user = Database::escape_string(trim($_GET['keyword_request_user'])); + $keyword_admin = Database::escape_string(trim($_GET['keyword_admin'])); + $keyword_start_date_start = Database::escape_string(trim($_GET['keyword_start_date_start'])); + $keyword_start_date_end = Database::escape_string(trim($_GET['keyword_start_date_end'])); + $keyword_status = Database::escape_string(trim($_GET['keyword_status'])); + $keyword_source = Database::escape_string(trim($_GET['keyword_source'])); + $keyword_priority = Database::escape_string(trim($_GET['keyword_priority'])); + $keyword_range = Database::escape_string(trim($_GET['keyword_dates'])); + $keyword_course = Database::escape_string(trim($_GET['keyword_course'])); + + if($keyword_category !=''){ + $sql.=" AND ticket.category_id = '$keyword_category' "; + } + if($keyword_request_user !=''){ + $sql.=" AND (ticket.request_user = '$keyword_request_user' OR user.firstname LIKE '%".$keyword_request_user."%' OR user.official_code LIKE '%".$keyword_request_user."%' OR user.lastname LIKE '%".$keyword_request_user."%' OR concat(user.firstname,' ',user.lastname) LIKE '%".$keyword_request_user."%' OR concat(user.lastname,' ',user.firstname) LIKE '%".$keyword_request_user."%' OR user.username LIKE '%".$keyword_request_user."%') "; + } + if($keyword_admin !=''){ + $sql.=" AND ticket.assigned_last_user = '$keyword_admin' "; + } + if($keyword_status !=''){ + $sql.=" AND ticket.status_id = '$keyword_status' "; + } + if($keyword_range == '' && $keyword_start_date_start!=''){ + $sql.= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' "; + } + if ($keyword_range == '1' && $keyword_start_date_start!='' && $keyword_start_date_end !=''){ + $sql.= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start' AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'"; + } + if ($keyword_priority != ''){ + $sql.=" AND ticket.priority_id = '$keyword_priority' "; + } + if($keyword_source != ''){ + $sql.= " AND ticket.source = '$keyword_source' "; + } + if($keyword_priority != ''){ + $sql.= " AND ticket.priority_id = '$keyword_priority' "; + } + if ($keyword_course != ''){ + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); + $sql .= " AND ticket.course_id IN ( "; + $sql .= "SELECT id FROM $course_table WHERE (title LIKE '%".$keyword_course."%' OR code LIKE '%".$keyword_course."%' OR visual_code LIKE '%".$keyword_course."%' )) "; + } + + } + if($keyword_unread == 'yes'){ + $sql.= " AND ticket.ticket_id IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; + }else if($keyword_unread == 'no'){ + $sql.= " AND ticket.ticket_id NOT IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; + } + $sql .= " ORDER BY col$column $direction"; + $sql .= " LIMIT $from,$number_of_items"; + $result = Database::query($sql); + $tickets = array(); + while ($row = Database::fetch_assoc($result)){ + $sql_unread = "SELECT COUNT(DISTINCT message.message_id) AS unread FROM ".$table_support_tickets." ticket, ".$table_support_messages." message, ".$table_main_user." user + WHERE ticket.ticket_id = message.ticket_id AND ticket.ticket_id= '".$row['col0']."' AND message.status='NOL' AND message.sys_insert_user_id = user.user_id "; + if($isAdmin){ + $sql_unread .=" AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' "; + }else{ + $sql_unread .=" AND user.user_id IN (SELECT user_id FROM $table_main_admin) "; + } + $result_unread = Database::query($sql_unread); + $unread = Database::fetch_object($result_unread)->unread; + $userinfo = UserManager::get_user_info_by_id($row['user_id']); + $name = ''.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).''; + $actions = ""; + /*if($row['status_id']!='CLS' && $row['status_id']!='REE'){ + if( $row['responsable'] != 0 && $row['responsable'] == $user_id ){ + $actions = ''; + }else{ + $actions = ''; + } + }*/ + if( $row['responsable'] != 0){ + $row['responsable']= api_get_user_info($row['responsable']); + $row['responsable']= ''.$row['responsable']['firstname'].' '.$row['responsable']['lastname'].''; + }else if($row['status_id']!='REE'){ + $row['responsable'] = 'Por Asignar'; + }else{ + $row['responsable'] = 'REENVIADO'; + } + switch ($row['source']){ + case 'PRE': + $img_source = '../img/icons/32/user.png'; + break; + case 'MAI': + $img_source = '../img/icons/32/mail.png'; + break; + case 'TEL': + $img_source = '../img/icons/32/event.png'; + break; + default: + $img_source = '../img/icons/32/course_home.png'; + break; + } + $row['col1'] = api_get_local_time($row['col1']); + $row['col2'] = api_get_local_time($row['col2']); + if($isAdmin){ + $actions .= ''.Display::return_icon('synthese_view.gif', get_lang('Info')).'  '; + if($row['priority_id']=='ALT' && $row['status_id']!='CLS') $actions .= ''; + $row['col0'] = Display::return_icon($img_source, get_lang('Info')).''.$row['ticket_code'].''; + if($row['col7']=='PENDIENTE'){ + $row['col7'] = ''.$row['col7'].''; + } + //programa: $userinfo['extra']['programa'] + $ticket=array($row['col0'],api_format_date($row['col1'],'%d/%m/%y - %I:%M:%S %p'),api_format_date($row['col2'],'%d/%m/%y - %I:%M:%S %p'),$row['col3'],$name,$row['responsable'],$row['col7'],$row['col8'],$actions, eregi_replace("[\n|\r|\n\r|\r\n]", ' ', strip_tags($row['col9'])) ); + }else{ + $actions =""; + $actions .= ''.Display::return_icon('synthese_view.gif', get_lang('Info')).'  '; + $row['col0'] =Display::return_icon($img_source, get_lang('Info')).''.$row['ticket_code'].''; + $now = api_strtotime(api_get_utc_datetime()); + $last_edit_date = api_strtotime($row['sys_lastedit_datetime']); + $dif = $now - $last_edit_date ; + + if($dif > 172800 && $row['priority_id'] == 'NRM' && $row['status_id']!='CLS'){ + $actions .= ''; + } + if($row['priority_id']=='ALT') $actions .= ''; + $ticket=array($row['col0'],api_format_date($row['col1'],'%d/%m/%y - %I:%M:%S %p'),api_format_date($row['col2'],'%d/%m/%y - %I:%M:%S %p'),$row['col3'],$row['col7'],$actions); + } + if($unread > 0){ + + $ticket['0']=$ticket['0'].'  ('.$unread.')'; + + } + if ($isAdmin) + $ticket['0'].= '   + '.get_lang('Historial').' +
      
    +
      '; + $tickets[] = $ticket; + } + return $tickets; + } + public static function get_total_tickets_by_user_id($user_id=null){ + $table_support_category = Database::get_main_table(TABLE_SUPPORT_CATEGORY); + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_priority = Database::get_main_table(TABLE_SUPPORT_PRIORITY); + $table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS); + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $table_main_user = Database::get_main_table(TABLE_MAIN_USER); + $table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN); + if(is_null($user_id) || $user_id==0){ + $user_id = api_get_user_id(); + } + $sql = "SELECT COUNT(ticket.ticket_id) AS total FROM ".$table_support_tickets." ticket ,".$table_support_category." cat , ".$table_support_priority ." priority, ".$table_support_status ." status , ".Database::get_main_table(TABLE_MAIN_USER)." user + WHERE cat.category_id = ticket.category_id AND ticket.priority_id = priority.priority_id AND ticket.status_id = status.status_id AND user.user_id = ticket.request_user "; + if(!api_is_platform_admin()){ + $sql.=" AND request_user = '$user_id' "; + } + + //Search simple + if(isset($_GET['submit_simple'])){ + if($_GET['keyword']!=''){ + $keyword = Database::escape_string(trim($_GET['keyword'])); + $sql.=" AND (ticket.ticket_code = '".$keyword."' OR user.firstname LIKE '%".$keyword."%' OR user.lastname LIKE '%".$keyword."%' OR concat(user.firstname,' ',user.lastname) LIKE '%".$keyword."%' OR concat(user.lastname,' ',user.firstname) LIKE '%".$keyword."%' OR user.username LIKE '%".$keyword."%') "; + } + } + $keyword_unread = Database::escape_string(trim($_GET['keyword_unread'])); + //Search advanced + if(isset($_GET['submit_advanced'])){ + $keyword_category = Database::escape_string(trim($_GET['keyword_category'])); + $keyword_request_user = Database::escape_string(trim($_GET['keyword_request_user'])); + $keyword_admin = Database::escape_string(trim($_GET['keyword_admin'])); + $keyword_start_date_start = Database::escape_string(trim($_GET['keyword_start_date_start'])); + $keyword_start_date_end = Database::escape_string(trim($_GET['keyword_start_date_end'])); + $keyword_status = Database::escape_string(trim($_GET['keyword_status'])); + $keyword_source = Database::escape_string(trim($_GET['keyword_source'])); + $keyword_priority = Database::escape_string(trim($_GET['keyword_priority'])); + $keyword_range = Database::escape_string(trim($_GET['keyword_dates'])); + $keyword_course = Database::escape_string(trim($_GET['keyword_course'])); + + if($keyword_category !=''){ + $sql.=" AND ticket.category_id = '$keyword_category' "; + } + if($keyword_request_user !=''){ + $sql.=" AND (ticket.request_user = '$keyword_request_user' OR user.firstname LIKE '%".$keyword_request_user."%' OR user.official_code LIKE '%".$keyword_request_user."%' OR user.lastname LIKE '%".$keyword_request_user."%' OR concat(user.firstname,' ',user.lastname) LIKE '%".$keyword_request_user."%' OR concat(user.lastname,' ',user.firstname) LIKE '%".$keyword_request_user."%' OR user.username LIKE '%".$keyword_request_user."%') "; + } + if($keyword_admin !=''){ + $sql.=" AND ticket.assigned_last_user = '$keyword_admin' "; + } + if($keyword_status !=''){ + $sql.=" AND ticket.status_id = '$keyword_status' "; + } + if($keyword_range == '' && $keyword_start_date_start!=''){ + $sql.= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' "; + } + if ($keyword_range == '1' && $keyword_start_date_start!='' && $keyword_start_date_end !=''){ + $sql.= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start' AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'"; + } + if ($keyword_priority != ''){ + $sql.=" AND ticket.priority_id = '$keyword_priority' "; + } + if($keyword_source != ''){ + $sql.= " AND ticket.source = '$keyword_source' "; + } + if($keyword_priority != ''){ + $sql.= " AND ticket.priority_id = '$keyword_priority' "; + } + if ($keyword_course != ''){ + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); + $sql .= " AND ticket.course_id IN ( "; + $sql .= "SELECT id FROM $course_table WHERE (title LIKE '%".$keyword_course."%' OR code LIKE '%".$keyword_course."%' OR visual_code LIKE '%".$keyword_course."%' )) "; + } + + } + if($keyword_unread == 'yes'){ + $sql.= " AND ticket.ticket_id IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; + }else if($keyword_unread == 'no'){ + $sql.= " AND ticket.ticket_id NOT IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; + } + $res = Database::query($sql); + $obj = Database::fetch_object($res); + return $obj->total; + } + public static function get_ticket_detail_by_id($ticket_id,$user_id){ + $table_support_category = Database::get_main_table(TABLE_SUPPORT_CATEGORY); + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_priority = Database::get_main_table(TABLE_SUPPORT_PRIORITY); + $table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS); + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $table_support_message_attachments = Database::get_main_table(TABLE_SUPPORT_MESSAGE_ATTACHMENTS); + + $sql = "SELECT ticket.* ,cat.name , status.name as status, priority.priority FROM ".$table_support_tickets." ticket, ".$table_support_category." cat ,".$table_support_priority." priority , ".$table_support_status." status + WHERE ticket.ticket_id = '$ticket_id' AND cat.category_id = ticket.category_id AND priority.priority_id = ticket.priority_id AND status.status_id = ticket.status_id "; + if(!UserManager::is_admin($user_id)){ + $sql.= "AND ticket.request_user = '$user_id'"; + } + $result = Database::query($sql); + $ticket = array(); + if(Database::num_rows($result)>0){ + while ($row = Database::fetch_assoc($result)){ + $row['course'] = null; + $row['start_date'] = api_convert_and_format_date(api_get_local_time($row['start_date']), DATE_TIME_FORMAT_LONG,_api_get_timezone()); + $row['end_date'] = api_convert_and_format_date(api_get_local_time($row['end_date']), DATE_TIME_FORMAT_LONG,_api_get_timezone()); + $row['sys_lastedit_datetime'] = api_convert_and_format_date(api_get_local_time($row['sys_lastedit_datetime']), DATE_TIME_FORMAT_LONG,_api_get_timezone()); + $row['course_url'] = null; + if($row['course_id']!=0){ + $course = api_get_course_info_by_id($row['course_id']); + $row['course_url'] = ''.$course['name'].''; + } + $userinfo = api_get_user_info($row['request_user']); + $row['user_url'] = ''.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).''; + $ticket['usuario'] = $userinfo; + $ticket['ticket']= $row; + } + $sql = "SELECT * FROM ".$table_support_messages." message, ".Database::get_main_table(TABLE_MAIN_USER)." user WHERE message.ticket_id = '$ticket_id' AND message.sys_insert_user_id = user.user_id "; + $result = Database::query($sql); + $ticket['messages']= array(); + $attach_icon = Display::return_icon('attachment.gif', ''); + $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); + while ($row = Database::fetch_assoc($result)){ + $message = $row; + //Check if user is an admin + $sql_admin = "SELECT user_id FROM $admin_table + WHERE user_id = '".intval($message['user_id'])."' LIMIT 1"; + $result_admin = Database::query($sql_admin); + $message['admin'] = false; + if (Database::num_rows($result_admin) > 0) { + $message['admin'] = true; + } + $message['user_created']= ''.$row['firstname'].' '.$row['lastname'].''; + $sql_atachment ="SELECT * FROM ".TABLE_SUPPORT_MESSAGE_ATTACHMENTS." WHERE message_id = ".$row['message_id']." AND ticket_id= '$ticket_id' "; + $result_attach = Database::query($sql_atachment); + while ($row2 = Database::fetch_assoc($result_attach)){ + $archiveURL =$archiveURL=api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/download.php?ticket_id='.$ticket_id.'&file='; + $row2['attachment_link']= $attach_icon.' '.$row2['filename'].' ('.$row2['size'].')'; + $message['atachments'][]= $row2; + } + $ticket['messages'][] = $message; + } + } + return $ticket; + } + public static function assign_ticket_user($ticket_id, $user_id){ + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_assigned_log = Database::get_main_table(TABLE_SUPPORT_ASSIGNED_LOG); + $now = api_get_utc_datetime(); + $sql_update = "UPDATE ".$table_support_tickets." SET assigned_last_user = '$user_id' WHERE ticket_id = '$ticket_id' "; + Database::query($sql_update); + if(Database::affected_rows()>0){ + $insert_id = api_get_user_id(); + $sql ="INSERT INTO ".$table_support_assigned_log." (ticket_id , user_id , assigned_date , sys_insert_user_id) VALUES ('$ticket_id','$user_id','".$now."','$insert_id');"; + Database::query($sql); + if ($insert_id != $user_id){ + $info = api_get_user_info($user_id); + $mensaje = '

    Estimado(a):

    '.$info['firstname']." ".$info['lastname']."

    +

    Te asignaron el ticket $ticket_id ".'Ticket

    +

    Centro de Educación Virtual

    '; + api_mail_html($info['firstname']." ".$info['lastname'], $info['mail'], "[TICKETS] Asignacion de Ticket #$ticket_id ", $mensaje,'Plataforma Virtual', 'plataformavirtual@usil.edu.pe', array('cc'=>'plataformavirtual@usil.edu.pe')); + } + } + } + public static function update_message_status($ticket_id,$user_id){ + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $sql = "UPDATE ".$table_support_messages." SET status = 'LEI' , sys_lastedit_user_id ='".api_get_user_id()."' ,sys_lastedit_datetime ='".$now."' WHERE ticket_id ='$ticket_id' "; + + if(api_is_platform_admin()){ + $sql .= " AND sys_insert_user_id = '$user_id'"; + }else{ + + $sql .= " AND sys_insert_user_id != '$user_id'"; + } + Database::query($sql); + if(Database::affected_rows()>0){ + Database::query("UPDATE ".Database::get_main_table(TABLE_SUPPORT_TICKET)." SET status_id = 'PND' WHERE ticket_id ='$ticket_id' AND status_id = 'NAT'"); + return true; + }else{ + return false; + } + } + public static function update_ticket_status($status_id,$ticket_id, $user_id){ + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $now = api_get_utc_datetime(); + $sql = "UPDATE ".$table_support_tickets." SET status_id = '$status_id' , sys_lastedit_user_id ='$user_id' ,sys_lastedit_datetime ='".$now."' WHERE ticket_id ='$ticket_id'"; + Database::query($sql); + if(Database::affected_rows()>0){ + return true; + }else{ + return false; + } + } + public static function get_number_of_messages(){ + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $table_main_user = Database::get_main_table(TABLE_MAIN_USER); + $table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN); + $user_info = api_get_user_info(); + $user_id = $user_info['user_id']; + $sql ="SELECT COUNT( DISTINCT ticket.ticket_id) AS unread FROM ".$table_support_tickets." ticket, ".$table_support_messages." message , ".$table_main_user." user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND user.user_id = message.sys_insert_user_id "; + if(!api_is_platform_admin()){ + $sql .=" AND ticket.request_user = '$user_id' AND user_id IN (SELECT user_id FROM $table_main_admin) "; + }else{ + $sql .=" AND user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE'"; + } + $sql .= " AND ticket.project_id != '' "; + $res = Database::query($sql); + $obj = Database::fetch_object($res); + return $obj->unread; + + } + public static function send_alert($ticket_id,$user_id){ + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $now = api_get_utc_datetime(); + $sql = "UPDATE ".$table_support_tickets." SET priority_id = 'ALT', sys_lastedit_user_id ='$user_id' ,sys_lastedit_datetime ='".$now."' WHERE ticket_id = '$ticket_id'"; + Database::query($sql); + } + public static function close_ticket($ticket_id, $user_id){ + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $now = api_get_utc_datetime(); + $sql = "UPDATE ".$table_support_tickets." SET status_id = 'CLS' , sys_lastedit_user_id ='$user_id' ,sys_lastedit_datetime ='".$now."' ,end_date ='".$now."' WHERE ticket_id ='$ticket_id'"; + Database::query($sql); + } + public static function close_old_tickets(){ + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $now = api_get_utc_datetime(); + $sql = "UPDATE ".$table_support_tickets." SET status_id = 'CLS' , sys_lastedit_user_id ='".api_get_user_id()."' ,sys_lastedit_datetime ='".$now."',end_date ='".$now."' WHERE DATEDIFF('$now',sys_lastedit_datetime) > 7 AND status_id != 'CLS' AND status_id != 'NAT' AND status_id != 'REE'"; + Database::query($sql); + } + public static function get_assign_log($ticket_id){ + $table_support_assigned_log = Database::get_main_table(TABLE_SUPPORT_ASSIGNED_LOG); + $sql = "SELECT log.* FROM ".TABLE_SUPPORT_ASSIGNED_LOG." log WHERE log.ticket_id = '$ticket_id' ORDER BY log.assigned_date"; + $result = Database::query($sql); + $history = array(); + while ($row = Database::fetch_assoc($result)){ + if ($row['user_id'] != 0) $assignuser = api_get_user_info($row['user_id']); + $insertuser = api_get_user_info($row['sys_insert_user_id']); + $row['assigned_date'] = api_convert_and_format_date(api_get_local_time($row['assigned_date']), '%d/%m/%y-%H:%M:%S',_api_get_timezone()); + $row['assignuser']= ($row['user_id'] != 0)?(''.$assignuser['username'].'') : get_lang('Unassign'); + $row['insertuser']= ''.$insertuser['username'].''; + $history[]=$row; + } + return $history; + } + public static function export_tickets_by_user_id($from, $number_of_items, $column, $direction ,$user_id=null){ + $table_support_category = Database::get_main_table(TABLE_SUPPORT_CATEGORY); + $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); + $table_support_priority = Database::get_main_table(TABLE_SUPPORT_PRIORITY); + $table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS); + $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); + $table_main_user = Database::get_main_table(TABLE_MAIN_USER); + if(is_null($direction)) $direction ="DESC"; + if(is_null($user_id) || $user_id==0){ + $user_id = api_get_user_id(); + } + + $sql = "SELECT ticket.ticket_code, ticket.sys_insert_datetime , ticket.sys_lastedit_datetime , cat.name as category , CONCAT(user.lastname,' ', user.firstname) AS fullname , status.name as status , ticket.total_messages as messages , ticket.assigned_last_user as responsable + FROM ".$table_support_tickets." ticket ,".$table_support_category." cat , ".$table_support_priority ." priority, ".$table_support_status ." status , ".Database::get_main_table(TABLE_MAIN_USER)." user + WHERE cat.category_id = ticket.category_id AND ticket.priority_id = priority.priority_id AND ticket.status_id = status.status_id AND user.user_id = ticket.request_user "; + //Search simple + if(isset($_GET['submit_simple'])){ + if($_GET['keyword']!=''){ + $keyword = Database::escape_string(trim($_GET['keyword'])); + $sql.=" AND (ticket.ticket_code = '".$keyword."' OR user.firstname LIKE '%".$keyword."%' OR user.lastname LIKE '%".$keyword."%' OR concat(user.firstname,' ',user.lastname) LIKE '%".$keyword."%' OR concat(user.lastname,' ',user.firstname) LIKE '%".$keyword."%' OR user.username LIKE '%".$keyword."%') "; + } + } + //Search advanced + if(isset($_GET['submit_advanced'])){ + $keyword_category = Database::escape_string(trim($_GET['keyword_category'])); + $keyword_request_user = Database::escape_string(trim($_GET['keyword_request_user'])); + $keyword_admin = Database::escape_string(trim($_GET['keyword_admin'])); + $keyword_start_date_start = Database::escape_string(trim($_GET['keyword_start_date_start'])); + $keyword_start_date_end = Database::escape_string(trim($_GET['keyword_start_date_end'])); + $keyword_status = Database::escape_string(trim($_GET['keyword_status'])); + $keyword_source = Database::escape_string(trim($_GET['keyword_source'])); + $keyword_priority = Database::escape_string(trim($_GET['keyword_priority'])); + $keyword_range = Database::escape_string(trim($_GET['keyword_dates'])); + $keyword_unread = Database::escape_string(trim($_GET['keyword_unread'])); + $keyword_course = Database::escape_string(trim($_GET['keyword_course'])); + + if($keyword_category !=''){ + $sql.=" AND ticket.category_id = '$keyword_category' "; + } + if($keyword_request_user !=''){ + $sql.=" AND (ticket.request_user = '$keyword_request_user' OR user.firstname LIKE '%".$keyword_request_user."%' OR user.official_code LIKE '%".$keyword_request_user."%' OR user.lastname LIKE '%".$keyword_request_user."%' OR concat(user.firstname,' ',user.lastname) LIKE '%".$keyword_request_user."%' OR concat(user.lastname,' ',user.firstname) LIKE '%".$keyword_request_user."%' OR user.username LIKE '%".$keyword_request_user."%') "; + } + if($keyword_admin !=''){ + $sql.=" AND ticket.assigned_last_user = '$keyword_admin' "; + } + if($keyword_status !=''){ + $sql.=" AND ticket.status_id = '$keyword_status' "; + } + if($keyword_range == '' && $keyword_start_date_start!=''){ + $sql.= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' "; + } + if ($keyword_range == '1' && $keyword_start_date_start!='' && $keyword_start_date_end !=''){ + $sql.= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start' AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'"; + } + if ($keyword_priority != ''){ + $sql.=" AND ticket.priority_id = '$keyword_priority' "; + } + if($keyword_source != ''){ + $sql.= " AND ticket.source = '$keyword_source' "; + } + if($keyword_priority != ''){ + $sql.= " AND ticket.priority_id = '$keyword_priority' "; + } + if ($keyword_course != ''){ + $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); + $sql .= " AND ticket.course_id IN ( "; + $sql .= "SELECT id FROM $course_table WHERE (title LIKE '%".$keyword_course."%' OR code LIKE '%".$keyword_course."%' OR visual_code LIKE '%".$keyword_course."%' )) "; + } + if($keyword_unread == 'yes'){ + $sql.= " AND ticket.ticket_id IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.status != 1 AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; + }else if($keyword_unread == 'no'){ + $sql.= " AND ticket.ticket_id NOT IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.status != 1 AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; + } + + } + + + //$sql .= " ORDER BY col$column $direction"; + $sql .= " LIMIT $from,$number_of_items"; + + $result = Database::query($sql); + $tickets[0] = array(utf8_decode('Ticket#'), utf8_decode('Fecha'), utf8_decode('Fecha Edicion'), utf8_decode('Categoria'), utf8_decode('Usuario'), utf8_decode('Estado'), utf8_decode('Mensajes'), utf8_decode('Responsable') , utf8_decode('Programa') ) ; + + while ($row = Database::fetch_assoc($result)){ + if( $row['responsable'] != 0){ + $row['responsable']= api_get_user_info($row['responsable']); + $row['responsable']= $row['responsable']['firstname'].' '.$row['responsable']['lastname']; + } + $row['sys_insert_datetime'] = api_format_date($row['sys_insert_datetime'],'%d/%m/%y - %I:%M:%S %p'); + $row['sys_lastedit_datetime'] = api_format_date($row['sys_lastedit_datetime'],'%d/%m/%y - %I:%M:%S %p'); + $row['category'] = utf8_decode($row['category']); + $row['programa'] = utf8_decode($row['fullname']); + $row['fullname'] = utf8_decode($row['fullname']); + $row['responsable'] = utf8_decode($row['responsable']); + $tickets[] = $row; + } + return $tickets; + } +} +?> \ No newline at end of file diff --git a/plugin/ticket/s/ticket_assign_log.php b/plugin/ticket/s/ticket_assign_log.php new file mode 100644 index 0000000000..c254570989 --- /dev/null +++ b/plugin/ticket/s/ticket_assign_log.php @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + +
    \ No newline at end of file diff --git a/plugin/ticket/s/ticket_details.php b/plugin/ticket/s/ticket_details.php new file mode 100644 index 0000000000..837e68594d --- /dev/null +++ b/plugin/ticket/s/ticket_details.php @@ -0,0 +1,357 @@ +'myticket.php','name' => get_lang('MisTickets')); +$interbreadcrumb[]= array ('url' =>'#','name' => get_lang('TicketDetail')); +$htmlHeadXtra[]=' + +'; +$htmlHeadXtra[] = ' +'; + +$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(); +} +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($_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_close_ticket.= ' + '; + $form_close_ticket.= '
    '; + } + } + + } + $titulo = '

    Ticket #'.$ticket['ticket']['ticket_code'].'

    '; + 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 = ''; + }else{ + $img_assing .= ''; + } + } + $negrita = ($ticket['ticket']['status_id'] == 'CLS')?'style = "font-weight: bold;"':''; + $cadena = ($ticket['ticket']['status_id'] != 'CLS')?"sas":""; + echo '
    + + + + + + + + + + + + + + + + + + + + + + + + '; + if($ticket['ticket']['course_url']!=null){ + echo ' + + + + + '; + } + if ($isAdmin){ + echo ' + + + + + '; + } + //select admins + $select_admins .= '"; + echo '
    '; + echo '
    + +
    +
    Responsable:
    +
    '.$select_admins.'
    +
    + '; + echo '
    '; + echo '
    '.$titulo.''.$img_assing.''.$form_close_ticket.'

    Enviado : '.$ticket['ticket']['start_date'].'

    Ultima Respuesta : '.$ticket['ticket']['sys_lastedit_datetime'].'

    Asunto : '.$ticket['messages'][0]['subject'].'

    Estado : '.$ticket['ticket']['status'].'

    Categoria : '.$ticket['ticket']['name'].'

    Prioridad :'.$ticket['ticket']['priority'].'

    Curso:

    '.$ticket['ticket']['course_url'].'

    Usuario:

    '.$user_info = $ticket['ticket']['user_url'].' ('.$ticket['usuario']['username'].')
    '; + $messages = $ticket['messages']; + foreach($messages as $message){ + $class ="messageuser"; + if($message['admin']){ + $class ="messagesupport"; + if($isAdmin)$message['message'].="
    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()).""; + }else{ + $message['message'].="Enviado: ".api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG,_api_get_timezone()).""; + } + echo '
    Asunto: '.$message['subject'].'
    Mensaje:'.$message['message'].'
    '; + if(isset($message['atachments'])){ + foreach($message['atachments'] as $attach){ + echo $attach['attachment_link']; + } + } + echo '
    '; + } + $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['confirmacion'])?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); +} +function show_form_send_message(){ + global $isAdmin; + global $ticket; + global $asunto; + echo '
    '; + echo '
    Asunto:
    +
    +
    '; + echo '
    +
    mensaje +
    +
    + + + +
    +
    +'; + echo ''; + echo '
    +
    '.get_lang('FilesAttachment').'
    +
    + +
    + +
    +
    +
    '; + echo '
    +
    + + '.get_lang('AddOneMoreFile').'  + ('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).') +
    +
    '; + echo '
    +
    +
    '.($isAdmin?'      Solicitar confirmación':""). + '
    +
    '; + echo '
    '; +} +Display::display_footer(); +?> \ No newline at end of file diff --git a/plugin/ticket/s/tutor.php b/plugin/ticket/s/tutor.php new file mode 100644 index 0000000000..50e6ca7831 --- /dev/null +++ b/plugin/ticket/s/tutor.php @@ -0,0 +1,101 @@ + +$(document).ready(function (){ + $(".ajax").live("click", function() { + var url = this.href; + var dialog = $("#dialog"); + if ($("#dialog").length == 0) { + dialog = $("
    ").appendTo("body"); + } + + // load remote content + dialog.load( + url, + {}, + function(responseText, textStatus, XMLHttpRequest) { + dialog.dialog({ + modal : true, + width : 540, + height : 400 + }); + }); + //prevent the browser to follow the link + return false; + }); +}); + + +function mostrarContenido(div){ + if($("div#"+div).attr("class")=="blackboard_hide"){ + $("div#"+div).attr("class","blackboard_show"); + $("div#"+div).attr("style",""); + }else{ + $("div#"+div).attr("class","blackboard_hide"); + $("div#"+div).attr("style",""); + } + +} + +function save() { + work_id = $("#work_id").val(); + forum_id = $("#forum_id").val(); + rs_id = $("#rs_id").val(); + $.ajax({ + contentType: "application/x-www-form-urlencoded", + beforeSend: function(objeto) { + $("div#confirmacion").html(""); }, + type: "POST", + url: "update_report.php", + data: "work_id="+work_id+"&forum_id="+forum_id+"&rs_id="+rs_id, + success: function(datos) { + $("div#confirmacion").html(datos); + location.reload(); + } + }); +} + +'; + +$course_code = api_get_course_id(); +$resultado = inicializarReporte($course_code); +if(isset($_GET['action'])){ + Export::export_table_xls($resultado['exportar'],"REPORTE ALUMNOS CURSO".$course_code); +}else{ + Display::display_header(); + api_protect_course_script(); + if (!api_is_allowed_to_edit()){ + api_not_allowed(); + } + echo $resultado['mostrar']; + Display::display_footer(); +} +?> \ No newline at end of file diff --git a/plugin/ticket/s/tutor_report.lib.php b/plugin/ticket/s/tutor_report.lib.php new file mode 100644 index 0000000000..7d3bae2786 --- /dev/null +++ b/plugin/ticket/s/tutor_report.lib.php @@ -0,0 +1,190 @@ +semanas==0)?7:$semanas->semanas):$_POST['numerosemanas']; + Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$numero_semanas')"); + if(intval($obj->cant) != $numero_semanas){ + + if(intval($obj->cant) > $numero_semanas){ + $sql ="DELETE FROM $table_reporte_semanas WHERE week_id > $numero_semanas AND course_code = '$course_code'"; + Database::query("DELETE FROM $table_reporte_semanas WHERE week_id > $numero_semanas AND course_code = '$course_code'"); + }else{ + for ($i = $obj->cant+1 ; $i <= $numero_semanas ; $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) + 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{ + $pagina = (!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 + 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 mostrarResultados($course_info,$numero_semanas,$pagina); + } + +} +function mostrarResultados($course_info,$numero_semanas, $pagina){ + $course_code = $course_info['code']; + $table_reporte_semanas = Database::get_main_table('rp_reporte_semanas'); + $table_students_report = Database::get_main_table('rp_students_report'); + $table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); + $table_user = Database::get_main_table(TABLE_MAIN_USER ); + $table_thread = Database::get_course_table(TABLE_FORUM_THREAD, $course_info['dbName']); + $table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']); + + $resultados = array(); + $table_export = array(); + $sql_encabezado = "SELECT rs.id as id,rs.week_id, w.title AS work_title, t.thread_title ,'EVALUACION' as eval_title ,'QUIZ' as pc_title + FROM $table_reporte_semanas rs + LEFT JOIN $table_thread t ON t.thread_id = rs.forum_id + LEFT JOIN $table_work w ON w.id = rs.work_id + WHERE rs.course_code = '$course_code' + ORDER BY rs.week_id"; + $result_encabezado = Database::query($sql_encabezado) ; + $ids = array(); + $fila = ' + '; + $fila_export_encabezado = array(null,null); + $fila_export_encabezado2 = array(null,ull); + while ($rowe = Database::fetch_assoc($result_encabezado)){ + $fila_export_encabezado[] = utf8_decode('Tarea'.$rowe['week_id']); + $fila_export_encabezado[] = utf8_decode('Foro'.$rowe['week_id']); + //$fila_export_encabezado[] = utf8_decode('Eval'.$rowe['week_id']); + //$fila_export_encabezado[] = utf8_decode('PC'.$rowe['week_id']); + $fila_export_encabezado2[] = utf8_decode($rowe['work_title']); + $fila_export_encabezado2[] = utf8_decode($rowe['thread_title']); + //$fila_export_encabezado2[] = utf8_decode($rowe['eval_title']); + //$fila_export_encabezado2[] = utf8_decode($rowe['pc_title']); + $fila_export = array('Tarea'.$rowe['week_id'],'Foro'.$rowe['week_id'],'Eval'.$rowe['week_id'],'PC'.$rowe['week_id']); + if ($rowe['week_id'] > (($pagina-1)*7) && $rowe['week_id'] <= (7*$pagina)){ + $ids[$rowe['week_id']] = $rowe['id']; + $fila.=' + Tarea'.$rowe['week_id'].' +
    '.$rowe['work_title'].'
    +
    '; + $fila.= ' + Foro'.$rowe['week_id'].' +
    '.$rowe['thread_title'].'
    +
    + '; + /*$fila.= ' + Eval'.$rowe['week_id'].' +
    '.$rowe['eval_title'].'
    +
    + '; + $fila.= ' + PC'.$rowe['week_id'].' +
    '.$rowe['pc_title'].'
    +
    + ';*/ + } + + } + $table_export[] = $fila_export_encabezado; + $table_export[] = $fila_export_encabezado2; + $fila.= ''; + + $html = '
    +
    + Seleccione cantidad de semanas: + '; + + + if($numero_semanas == 14) { + $html .= ''.(($pagina == 1)?"Siguiente":"Anterior").''; + } + $html .= ''.Display::return_icon('import_excel.png',get_lang('Export'),'','32').''; + + $html .= ''; + $html .= ''; + $html .= ' + '; + for ($i=(7*$pagina-6); $i <= $pagina*7;$i++){ + $html .= ''; + } + $html .= ''; + $html .= $fila; + $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 $table_students_report sr + JOIN $table_reporte_semanas rs ON sr.week_report_id = rs.id + JOIN $table_user u ON u.user_id = sr.user_id + WHERE rs.course_code = '$course_code' + ORDER BY u.lastname , u.username , rs.week_id + "; + $result = Database::query($sql); + while ($row = Database::fetch_assoc($result)){ + $resultadose[$row['username']][$row['week_id']] = $row; + if ($row['week_id'] > (($pagina-1)*7) && $row['week_id'] <= (7*$pagina) ){ + $resultados[$row['username']][$row['week_id']] = $row; + if(count($resultados[$row['username']]) == 7 ){ + $html.= mostrarResultadoAlumno($resultados[$row['username']],$pagina); + } + } + if(count($resultadose[$row['username']]) == $numero_semanas ){ + $table_export[] = mostrarResultadoAlumnoExportar($resultadose[$row['username']],$numero_semanas); + } + } + $html .= ' +
    Semana '.$i.''.Display::return_icon('edit.png', get_lang('Edit'), array('width'=>'16','height'=>'16'), 22).'
    '; + return array('mostrar'=>$html,'exportar'=>$table_export); +} +function mostrarResultadoAlumno($datos,$pagina){ + $inicio = (7*$pagina-6); + $fila = ''; + + $fila.= ''.$datos[$inicio]['username'].''; + foreach ($datos as $dato){ + $fila.= ''.(($dato['work_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).''; + $fila.= ''.(($dato['thread_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).''; + //$fila.= ''.(($dato['quiz_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).''; + //$fila.= ''.(($dato['pc_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).''; + } + $fila.= ''; + return $fila; +} +function mostrarResultadoAlumnoExportar($datos ,$numero_semanas){ + $fila = array(); + $fila[] = utf8_decode($datos[1]['username']); + $fila[]= utf8_decode($datos[1]['fullname']); + foreach ($datos as $dato){ + //if ($datos['week_id'] < $numero_semanas){ + $fila[]= ($dato['work_ok']==1)?"SI":"NO"; + $fila[]= ($dato['thread_ok']==1)?"SI":"NO"; + //$fila[]= ($dato['quiz_ok']==1)?"SI":"NO"; + //$fila[]= ($dato['pc_ok']==1)?"SI":"NO"; + //} + } + return $fila; +} +?> \ No newline at end of file diff --git a/plugin/ticket/s/update_report.php b/plugin/ticket/s/update_report.php new file mode 100644 index 0000000000..2d2cab12dc --- /dev/null +++ b/plugin/ticket/s/update_report.php @@ -0,0 +1,16 @@ +get_lang("DeniedAccess")); +}else{ + $sql ="UPDATE ".Database::get_main_table('rp_reporte_semanas')." SET work_id = '$work_id' , forum_id = '$forum_id' WHERE id ='$rs_id'"; + Database::query($sql); + Display::display_confirmation_message("Se actualizo con exito"); +} +?> \ No newline at end of file diff --git a/plugin/ticket/start.php b/plugin/ticket/start.php new file mode 100755 index 0000000000..bd308f8405 --- /dev/null +++ b/plugin/ticket/start.php @@ -0,0 +1,55 @@ +plugin_enabled) { + if ($bbb->is_server_running()) { + if (isset($_GET['launch']) && $_GET['launch'] == 1) { + $meeting_params = array(); + $meeting_params['meeting_name'] = api_get_course_id(); + + if ($bbb->meeting_exists($meeting_params['meeting_name'])) { + $url = $bbb->join_meeting($meeting_params['meeting_name']); + if ($url) { + header('location: '.$url); + exit; + } else { + $url = $bbb->create_meeting($meeting_params); + header('location: '.$url); + exit; + } + } else { + if ($bbb->is_teacher()) { + $url = $bbb->create_meeting($meeting_params); + header('location: '.$url); + exit; + } else { + $url = 'listing.php'; + header('location: '.$url); + exit; + } + } + } else { + $url = 'listing.php'; + header('location: '.$url); + exit; + } + } else { + $message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning'); + } +} else { + $message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning'); +} +$tpl->assign('message', $message); +$tpl->display_one_col_template(); diff --git a/plugin/ticket/uninstall.php b/plugin/ticket/uninstall.php new file mode 100755 index 0000000000..23a8798b5d --- /dev/null +++ b/plugin/ticket/uninstall.php @@ -0,0 +1,13 @@ +uninstall(); \ No newline at end of file