$task = mosGetParam($_REQUEST, 'task', '');
$mode = mosGetParam($_REQUEST, 'mode', '');
$cid = josGetArrayInts('cid', $_POST);
if (!is_array($cid)) {
    $cid = array(0);
}
require_once _JOOMLMS_FRONT_HOME . "/joomla_lms.conference.html.php";
//otrisovivaem head menu
if ($mode != 'conference_room' && $mode != 'upload_popup' && $mode != 'conference_playback' && $mode != 'params' && $mode != 'save_period' && $mode != 'display_file') {
    global $JLMS_CONFIG;
    $course_id = $JLMS_CONFIG->get('course_id', 0);
    $pathway = array();
    $pathway[] = array('name' => _JLMS_PATHWAY_HOME, 'link' => sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"), 'is_home' => true);
    $pathway[] = array('name' => $JLMS_CONFIG->get('course_name'), 'link' => sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=details_course&id={$course_id}"), 'is_course' => true);
    $pathway[] = array('name' => _JLMS_TOOLBAR_CONF, 'link' => sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=conference&id={$course_id}"));
    JLMSAppendPathWay($pathway);
    JLMS_ShowHeading();
}
switch ($task) {
    case 'conference':
        JLMS_show_conference($course_id, $option, $mode);
        break;
}
//sdelat vivod po datam
function JLMS_show_conference($course_id, $option, $mode)
{
    global $my, $JLMS_DB, $JLMS_CONFIG;
    //select date (if no, select current date)
    $user_id = $my->id;
    $cid = mosGetParam($_POST, 'cid', array(0));
    if (!is_array($cid)) {
Example #2
0
function JLMS_showMainPage_front($option)
{
    global $my, $JLMS_DB, $JLMS_CONFIG, $Itemid;
    $JLMS_ACL =& JLMSFactory::getACL();
    $assigned_groups_only = $JLMS_ACL->CheckPermissions('advanced', 'assigned_groups_only');
    $pathway = array();
    $pathway[] = array('name' => _JLMS_PATHWAY_HOME, 'link' => sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"), 'is_home' => true);
    JLMSAppendPathWay($pathway);
    $hp_items = $JLMS_CONFIG->get('homepage_items');
    $lists = array();
    //courses
    $cidsf = $JLMS_CONFIG->get('student_in_future_courses');
    $course_data_sf = array();
    $cidtxt = '0';
    if (!empty($cidsf)) {
        $cidsfxt = implode(',', $cidsf);
        $query = "SELECT a.*, '0' as user_course_role FROM #__lms_courses as a WHERE a.id IN ({$cidsfxt}) AND a.id NOT IN ({$cidtxt})" . "\n ORDER BY " . ($JLMS_CONFIG->get('lms_courses_sortby', 0) ? "a.ordering, a.course_name, a.id" : "a.course_name, a.ordering, a.id");
        $JLMS_DB->SetQuery($query);
        $course_data_sf = $JLMS_DB->LoadObjectList();
    }
    $my_courses_r = my_courses_r();
    if (count($my_courses_r) || count($cidsf)) {
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=courses"));
    }
    $c_ids = array();
    foreach ($my_courses_r as $mcr) {
        $c_ids[] = $mcr->id;
    }
    $my_courses_r = array_merge($my_courses_r, $course_data_sf);
    if ($JLMS_CONFIG->get('frontpage_courses_tree', 0)) {
        $hp_items = 999999999;
    }
    $my_courses = array();
    $i = 0;
    while ($i < $hp_items && $i < count($my_courses_r)) {
        $my_courses[] = $my_courses_r[$i];
        $i++;
    }
    if (!is_array($c_ids)) {
        $c_ids = array(0);
    }
    $c_str = implode(',', $c_ids);
    if ($JLMS_CONFIG->get('frontpage_courses_tree', 0)) {
        //My_courses_tree
        $levellimit = 20;
        $query = "SELECT id, c_category as name, parent, 0 as is_course" . "\n FROM #__lms_course_cats ORDER BY c_category";
        $JLMS_DB->setQuery($query);
        $cats = $JLMS_DB->loadObjectList();
        $query = "SELECT a.id as user_certificate, b.course_id" . "\n FROM #__lms_certificate_users as a, #__lms_users_in_groups as b" . "\n WHERE 1" . "\n AND a.user_id = '" . $my->id . "'" . "\n AND a.crt_option = '1'" . "\n AND b.user_id = a.user_id AND a.course_id = b.course_id";
        $JLMS_DB->setQuery($query);
        $crtfs = $JLMS_DB->loadObjectList();
        $i = 0;
        foreach ($my_courses as $course) {
            $my_courses[$i]->certificate = 0;
            foreach ($crtfs as $crtf) {
                if ($course->id == $crtf->course_id && $crtf->user_certificate) {
                    $my_courses[$i]->certificate = 1;
                    break;
                }
            }
            $i++;
        }
        $children = array();
        foreach ($cats as $v) {
            $pt = $v->parent;
            /** Joomla 1.6 compability { */
            $v->parent_id = $v->parent;
            $v->title = $v->name;
            /** } Joomla 1.6 compability*/
            $list = @$children[$pt] ? $children[$pt] : array();
            array_push($list, $v);
            $children[$pt] = $list;
        }
        $cats = mosTreeRecurse(0, '', array(), $children, max(0, $levellimit - 1));
        $i = 0;
        $tmp_cats = array();
        foreach ($cats as $data) {
            $tmp_cats[$i] = $data;
            $i++;
        }
        $cats = array();
        $cats = $tmp_cats;
        //NEW
        $tmp = array();
        $last_catid = 0;
        foreach ($my_courses as $data) {
            if ($last_catid == 0 || $last_catid != $data->cat_id) {
                $last_catid = $data->cat_id;
            }
            $tmp[$last_catid][] = $data->id;
        }
        $for_not_empty = $tmp;
        //NEW
        $flms_course = array();
        if ($JLMS_CONFIG->get('flms_integration', 0)) {
            $query = "SELECT * FROM #__lmsf_courses";
            $JLMS_DB->setQuery($query);
            $flms_course = $JLMS_DB->loadObjectList();
        }
        $result_tree = array();
        $i = 0;
        while ($i < count($my_courses)) {
            $my_courses[$i]->c_id = $my_courses[$i]->id;
            $my_courses[$i]->id = -$my_courses[$i]->id;
            $i++;
        }
        foreach ($my_courses as $course) {
            $result_tree = new stdClass();
            $result_tree->c_id = $course->c_id;
            $result_tree->id = $course->id;
            $result_tree->parent = 0;
            $result_tree->name = $course->course_name;
            $result_tree->children = 0;
            $result_tree->is_course = 1;
            $result_tree->certificate = $course->certificate;
            $result_tree->ordering = $course->ordering;
            $position = 0;
            $i = 0;
            $level = 0;
            foreach ($cats as $cat) {
                if ($course->cat_id == $cat->id && $cat->parent == 0) {
                    $position = $i;
                    $result_tree->parent = $cat->id;
                }
                //				if ($cat->parent && isset($tmp_courses_cats[$course->c_id]) && count($tmp_courses_cats[$course->c_id]) && in_array($cat->id, $tmp_courses_cats[$course->c_id])) {
                if ($cat->parent && isset($for_not_empty[$cat->id]) && count($for_not_empty[$cat->id]) && in_array($course->c_id, $for_not_empty[$cat->id])) {
                    $position = $i;
                    $result_tree->parent = $cat->id;
                }
                $i++;
            }
            if ($position) {
                $new_cats = array();
                foreach ($cats as $cat) {
                    $new_cats[] = $cat;
                    if (count($new_cats) == $position + 1) {
                        //+1
                        $new_cats[] = $result_tree;
                    }
                }
                $cats = $new_cats;
            } else {
                $cats[] = $result_tree;
            }
        }
        $i = 0;
        while ($i < count($cats)) {
            $j = $i + 1;
            if ($cats[$i]->is_course) {
                while ($j < count($cats)) {
                    if (!$cats[$j]->is_course && $cats[$i]->parent == $cats[$j]->parent) {
                        $temp = new stdClass();
                        $temp = $cats[$j];
                        $cats[$j] = $cats[$i];
                        $cats[$i] = $temp;
                        break;
                    }
                    $j++;
                }
            }
            $i++;
        }
        $i = 0;
        while ($i < count($cats)) {
            $j = $i + 1;
            if ($cats[$i]->is_course) {
                while ($j < count($cats)) {
                    if ($cats[$j]->is_course && $cats[$i]->parent == $cats[$j]->parent) {
                        if ($JLMS_CONFIG->get('lms_courses_sortby', 0)) {
                            if ($cats[$j]->ordering < $cats[$i]->ordering) {
                                $temp = new stdClass();
                                $temp = $cats[$j];
                                $cats[$j] = $cats[$i];
                                $cats[$i] = $temp;
                            }
                        } else {
                            if (strcasecmp($cats[$j]->name, $cats[$i]->name) < 0) {
                                $temp = new stdClass();
                                $temp = $cats[$j];
                                $cats[$j] = $cats[$i];
                                $cats[$i] = $temp;
                            }
                        }
                    }
                    $j++;
                }
            }
            $i++;
        }
        $children = array();
        foreach ($cats as $v) {
            $pt = $v->parent;
            /** Joomla 1.6 compability { */
            $v->parent_id = $v->parent;
            $v->title = $v->name;
            /** } Joomla 1.6 compability*/
            $list = @$children[$pt] ? $children[$pt] : array();
            array_push($list, $v);
            $children[$pt] = $list;
        }
        $cats = mosTreeRecurse(0, '', array(), $children, max(0, $levellimit - 1));
        $tmp_cats_tmp = array();
        $i = 0;
        foreach ($cats as $cat) {
            $tmp_cats_tmp[$i] = $cat;
            $i++;
        }
        $cats = $tmp_cats_tmp;
        foreach ($cats as $key => $data) {
            $cats[$key]->exist_courses = 0;
            if ($data->is_course) {
                $catid = $data->parent;
                $i = $key;
                while ($i >= 0) {
                    if ($cats[$i]->id == $catid) {
                        $cats[$i]->exist_courses = 1;
                        $catid = $cats[$i]->parent;
                    }
                    $i--;
                }
            }
        }
        $tmp_cats = array();
        $i = 0;
        $lists['keep_flesson'] = 0;
        $tmp_data = array();
        foreach ($cats as $key => $data) {
            $tmp_data[$key] = $data;
            unset($tmp_data[$key]->treename);
            $tmp_data[$key]->folder_flag = 0;
            if ($data->children) {
                $tmp_data[$key]->folder_flag = 1;
            }
            $tmp_data[$key]->parent_id = $data->parent;
            $tmp_data[$key]->doc_name = $data->name;
            $tmp_data[$key]->ordering = $i;
            foreach ($flms_course as $f_course) {
                if ($data->is_course && abs($data->id) == $f_course->course_id && $f_course->type_lesson == 2) {
                    if ($f_course->like_theory) {
                        $f_course->pf_time = 0;
                        $f_course->pm_time = $f_course->theory_duration_time;
                    }
                    $pf_time_h = str_pad(floor($f_course->pf_time / 60), 2, "0", STR_PAD_LEFT);
                    $pf_time_m = str_pad($f_course->pf_time - $pf_time_h * 60, 2, "0", STR_PAD_LEFT);
                    $pf_time = $pf_time_h . ':' . $pf_time_m;
                    $pm_time_h = str_pad(floor($f_course->pm_time / 60), 2, "0", STR_PAD_LEFT);
                    $pm_time_m = str_pad($f_course->pm_time - $pm_time_h * 60, 2, "0", STR_PAD_LEFT);
                    $pm_time = $pm_time_h . ':' . $pm_time_m;
                    $pre_total_time = $f_course->pf_time + $f_course->pm_time;
                    $total_time_h = str_pad(floor($pre_total_time / 60), 2, "0", STR_PAD_LEFT);
                    $total_time_m = str_pad($pre_total_time - $total_time_h * 60, 2, "0", STR_PAD_LEFT);
                    $total_time = $total_time_h . ':' . $total_time_m;
                    $tmp_data[$key]->lesson_type = $f_course->type_lesson;
                    $tmp_data[$key]->pf_time = $pf_time;
                    $tmp_data[$key]->pm_time = $pm_time;
                    $tmp_data[$key]->total_time = $total_time;
                    $lists['keep_flesson'] = 1;
                } else {
                    if ($data->is_course && abs($data->id) == $f_course->course_id) {
                        $tmp_data[$key]->lesson_type = $f_course->type_lesson;
                    }
                }
            }
            if ($JLMS_CONFIG->get('multicat_no_display_empty', 1)) {
                //				if($data->is_course == 0 && $data->children && isset($tmp_cats_courses[$data->id]) && count($tmp_cats_courses[$data->id]) ){
                //				if($data->is_course == 0 && $data->children && $data->exist_courses ){
                if ($data->is_course == 0 && $data->children && $data->exist_courses) {
                    $tmp_cats[$i] = $tmp_data[$key];
                    $i++;
                } else {
                    if ($data->is_course && $data->children == 0) {
                        $tmp_cats[$i] = $tmp_data[$key];
                        $i++;
                    }
                }
            } else {
                $tmp_cats[$i] = $tmp_data[$key];
                $i++;
            }
        }
        $cats = $tmp_cats;
        $cats = JLMS_GetTreeStructure($cats);
        $my_courses = $cats;
        $hp_items = $JLMS_CONFIG->get('homepage_items');
    }
    //notices teacher
    if ($JLMS_CONFIG->get('frontpage_notices_teacher')) {
        $lists['my_notices'] = array();
        $hp_items = $JLMS_CONFIG->get('homepage_items');
        $query = "SELECT * " . "\n FROM #__lms_page_notices" . "\n WHERE usr_id = '" . $my->id . "'" . "\n ORDER BY data DESC" . "\n LIMIT 0,{$hp_items}";
        $JLMS_DB->setQuery($query);
        $lists['my_notices'] = $JLMS_DB->loadObjectList();
    }
    //dropbox
    $my_dropbox = array();
    if ($JLMS_CONFIG->get('frontpage_dropbox')) {
        $my_dropbox = my_dropboxes($c_str, $hp_items, $my->id);
    }
    $lists['dropbox_total'] = my_dropboxes_total($c_str, $my->id);
    $lists['dropbox_total_new'] = my_dropboxes_total_new($c_str, $my->id);
    //homework
    $my_hw = array();
    if ($JLMS_CONFIG->get('frontpage_homework')) {
        $my_hw = my_homeworks($c_str, $hp_items, $my->id);
        //		$members = "'0'";
        //		$where = '';
        //		if($JLMS_ACL->_role_type == 2 || $JLMS_ACL->_role_type == 3 || $JLMS_ACL->_role_type == 4) {
        //			if($assigned_groups_only) {
        //				$groups_where_admin_manager = JLMS_ACL_HELPER::GetAssignedGroups($my->id);
        //				$groups_where_isset_user = JLMS_ACL_HELPER::GetUserGlobalGroup($my->id);
        //
        //				$groups_where_admin_manager = array_merge($groups_where_admin_manager,$groups_where_isset_user);
        //
        //				if (count($groups_where_admin_manager)) {
        //					$where .= "\n AND ( `groups` LIKE '%|$groups_where_admin_manager[0]|%'";
        //					for($i=1;$i<count($groups_where_admin_manager);$i++) {
        //						$where .= "\n OR `groups` like '%|$groups_where_admin_manager[$i]|%'";
        //					}
        //					$where .=  "\n )";
        //				}
        //			}
        //		}
        //		elseif($JLMS_ACL->_role_type < 2) {
        //				$query = "select a.group_id FROM #__lms_users_in_global_groups as a WHERE a.user_id = '".$my->id."' AND a.subgroup1_id = 0";
        //				$JLMS_DB->setQuery($query);
        //				$temp1 = $JLMS_DB->loadResultArray();
        //
        //				$query = "select subgroup1_id FROM #__lms_users_in_global_groups WHERE user_id = '".$my->id."'";
        //				$JLMS_DB->setQuery($query);
        //				$temp2 = $JLMS_DB->loadResultArray();
        //
        //				$group_where_isset_user = array_merge($temp1,$temp2);
        //
        //				if (count($group_where_isset_user)) {
        //					$where .= "\n AND (( `groups` <> '' AND `groups` IS NOT NULL AND (`groups` LIKE '%|$group_where_isset_user[0]|%'";
        //					for($i=1;$i<count($group_where_isset_user);$i++) {
        //						$where .= "\n OR `groups` like '%|$group_where_isset_user[$i]|%'";
        //					}
        //					$where .=  "\n )) OR (`groups` = '' OR `groups` IS NULL))";
        //				}
        //		}
        //
        //
        //		$query = "SELECT a.*, b.course_name, d.hw_status, c.user_id as stu_id, e.user_id as teach_id"
        //		. "\n FROM (#__lms_homework as a, #__lms_courses as b)"
        //		. "\n LEFT JOIN #__lms_users_in_groups as c ON c.user_id = '".$my->id."' AND c.course_id = b.id"
        //		. "\n LEFT JOIN #__lms_homework_results as d ON d.course_id = b.id AND d.user_id = c.user_id AND d.hw_id = a.id"
        //		. "\n LEFT JOIN #__lms_user_courses as e ON e.course_id = b.id AND e.user_id = '".$my->id."'"
        //		. "\n WHERE a.course_id IN ($c_str) AND a.course_id = b.id AND a.end_date >= '".date('Y-m-d',time())."'"
        //		.$where
        //		. "\n LIMIT 0, $hp_items"
        //		;
        //		$JLMS_DB->SetQuery( $query );
        //		$my_hw = $JLMS_DB->LoadObjectList();
    }
    //announcements
    $my_announcements = array();
    if ($JLMS_CONFIG->get('frontpage_announcements')) {
        $my_announcements = my_announcements($c_str, $hp_items, $my->id);
    }
    //mailbox
    $my_mailbox = array();
    if ($JLMS_CONFIG->get('frontpage_mailbox')) {
        $my_mailbox = my_mailbox($c_str, $hp_items, $my->id);
    }
    //certificates
    $my_certificates = array();
    if ($JLMS_CONFIG->get('frontpage_certificates')) {
        $my_certificates = my_certificates($c_str, $hp_items, $my->id);
    }
    //latest forum posts
    $latest_forum_posts = array();
    if ($JLMS_CONFIG->get('frontpage_latest_forum_posts')) {
        $latest_forum_posts = latest_forum_posts($c_str, $hp_items, $my->id);
    }
    $lists['homepage_text'] = $JLMS_CONFIG->get('frontpage_text');
    //end
    JLMS_ShowHeading($JLMS_CONFIG->get('jlms_heading'), false);
    joomla_lms_html::showMainPage_front($option, $lists, $my_courses, $my_dropbox, $my_hw, $my_announcements, $my_mailbox, $my_certificates, $latest_forum_posts);
}
Example #3
0
function JLMS_playerSCORM($id, $option)
{
    global $JLMS_DB, $my, $JLMS_CONFIG, $Itemid, $JLMS_SESSION;
    $course_id = $JLMS_CONFIG->get('course_id');
    $usertype = $JLMS_CONFIG->get('current_usertype', 0);
    $lpath_id = intval(mosGetParam($_REQUEST, 'lpath_id', 0));
    $int_skip_resume = intval(mosGetParam($_REQUEST, 'int_skip_resume', 0));
    $scorm = null;
    //new stdClass();
    if ($course_id && ($usertype == 1 || $usertype == 2) && JLMS_CheckSCORM($id, $lpath_id, $course_id, $scorm, $usertype)) {
        if (!empty($scorm)) {
            // 11.04.2007 (parameter 'redirect_to_learnpath' used to avoid redirect cycles from course home to LP and back
            $JLMS_SESSION->clear('redirect_to_learnpath');
            // sleep one second. SCORM could send some requests on onCloasPage event. We need wait for these requests to be processed.
            #sleep(2);
            $scoid = intval(mosGetParam($_REQUEST, 'scoid', 0));
            $mode = 'normal';
            //strval(mosGetParam($_REQUEST, 'mode','normal'));//optional_param('mode', 'normal', PARAM_ALPHA);
            $currentorg = strval(mosGetParam($_REQUEST, 'currentorg', ''));
            //, PARAM_RAW);
            $newattempt = strval(mosGetParam($_REQUEST, 'newattempt', 'on'));
            require_once _JOOMLMS_FRONT_HOME . "/includes/n_scorm/lms_scorm.play.php";
            $query = "SELECT * FROM #__lms_learn_paths WHERE id = '" . $lpath_id . "' AND course_id = '" . $course_id . "'";
            $JLMS_DB->SetQuery($query);
            $lpath_data = $JLMS_DB->LoadObjectList();
            $box_view = false;
            if (count($lpath_data) == 1) {
                $pathway = array();
                $pathway[] = array('name' => $lpath_data[0]->lpath_name, 'link' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=player_scorm&amp;id={$id}&amp;course_id={$course_id}&amp;lpath_id=" . $lpath_data[0]->id));
                JLMSAppendPathWay($pathway);
            }
            if (isset($scorm->params)) {
                $params = new JLMSParameters($scorm->params);
                if ($params->get('scorm_layout', 0) && $params->get('scorm_layout', 0) == 1) {
                    $box_view = true;
                }
            }
            if ($box_view) {
                // SqueezeBox view - don't show Heading.
                echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
                echo '<html xmlns="http://www.w3.org/1999/xhtml" style="margin:0;padding:0"><head>';
                $iso_site = 'charset=utf-8';
                if (defined('_ISO')) {
                    $iso_site = _ISO;
                    if (!$iso_site) {
                        $iso_site = 'charset=utf-8';
                    }
                }
                echo '<meta http-equiv="Content-Type" content="text/html; ' . $iso_site . '" />';
                echo '</head><body style="margin:0;padding:0">';
            } else {
                JLMS_ShowHeading();
            }
            /*JLMS_TMPL::OpenMT();
            
            			$hparams = array();
            			JLMS_TMPL::ShowHeader('scorm', $scorm->scorm_name, $hparams);
            */
            $skip_resume = $int_skip_resume ? true : false;
            JLMS_SCORM_PLAY_MAIN($scorm, $option, $course_id, $lpath_id, $scoid, $mode, $currentorg, $newattempt, false, false, $box_view, $skip_resume);
            if ($box_view) {
                echo '</body></html>';
                JLMS_die();
            }
            //JLMS_TMPL::CloseMT();
        } else {
            JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=learnpaths&id={$course_id}"));
        }
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=learnpaths&id={$course_id}"));
    }
}
Example #4
0
function JLMS_showChat($course_id, $option)
{
    global $JLMS_DB, $my, $Itemid, $JLMS_CONFIG;
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($JLMS_ACL->CheckPermissions('chat', 'view')) {
        global $JLMS_CONFIG;
        $pathway = array();
        $pathway[] = array('name' => _JLMS_PATHWAY_HOME, 'link' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}"), 'is_home' => true);
        $pathway[] = array('name' => $JLMS_CONFIG->get('course_name'), 'link' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=details_course&amp;id={$course_id}"), 'is_course' => true);
        $pathway[] = array('name' => _JLMS_TOOLBAR_CHAT, 'link' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=chat&amp;id={$course_id}"));
        JLMSAppendPathWay($pathway);
        JLMS_ShowHeading();
        $group_id = intval(mosGetParam($_REQUEST, 'group_id', 0));
        if ($JLMS_ACL->CheckPermissions('chat', 'manage')) {
            if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                $query = "SELECT group_chat FROM #__lms_usergroups WHERE course_id = 0 AND id = {$group_id}";
                $JLMS_DB->SetQuery($query);
                $gr_c = $JLMS_DB->LoadResult();
                if (!$gr_c) {
                    $group_id = 0;
                }
            } else {
                $query = "SELECT group_chat FROM #__lms_usergroups WHERE course_id = {$course_id} AND id = {$group_id}";
                $JLMS_DB->SetQuery($query);
                $gr_c = $JLMS_DB->LoadResult();
                if (!$gr_c) {
                    $group_id = 0;
                }
            }
        } else {
            if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                if ($group_id) {
                    $query = "SELECT group_chat FROM #__lms_users_in_global_groups AS uigg, #__lms_usergroups AS ug WHERE uigg.user_id = {$my->id} AND uigg.group_id = {$group_id} AND ug.id = uigg.group_id";
                    $JLMS_DB->setQuery($query);
                    if (!$JLMS_DB->loadResult()) {
                        $group_id = 0;
                    }
                }
            } else {
                if ($group_id) {
                    $query = "SELECT a.group_id FROM #__lms_users_in_groups as a, #__lms_usergroups as b WHERE a.course_id = {$course_id} AND a.user_id = '" . $my->id . "' AND a.group_id = b.id AND b.course_id = {$course_id} AND b.group_chat = 1";
                    $JLMS_DB->SetQuery($query);
                    $group_id = $JLMS_DB->LoadResult();
                    if (!$group_id) {
                        $group_id = 0;
                    }
                }
            }
        }
        $query = "SHOW COLUMNS FROM `#__lms_chat_history` WHERE Field = 'user_message'";
        $JLMS_DB->SetQuery($query);
        $chat_table = $JLMS_DB->LoadObject();
        if (is_object($chat_table) && isset($chat_table->Type)) {
            if ($chat_table->Type != 'text') {
                $query = "ALTER TABLE `#__lms_chat_history` CHANGE `user_message` `user_message` TEXT";
                $JLMS_DB->SetQuery($query);
                $JLMS_DB->query();
            }
        }
        //query (Drop users)
        $query = "DELETE FROM #__lms_chat_users WHERE user_id = '" . $my->id . "'";
        $JLMS_DB->SetQuery($query);
        $JLMS_DB->query();
        $tim_minus_15 = time() - date('Z') - 15 * 60;
        $query = "DELETE FROM #__lms_chat_users WHERE time_post < '" . date('Y-m-d H:i:s', $tim_minus_15) . "'";
        $JLMS_DB->SetQuery($query);
        $JLMS_DB->query();
        //query (Entering chat)
        $query = "INSERT INTO #__lms_chat_users (course_id, group_id, user_id, time_enter, time_post, chat_option)" . "\n VALUES ('" . $course_id . "', '" . $group_id . "', '" . $my->id . "', '" . gmdate('Y-m-d H:i:s') . "', '" . gmdate('Y-m-d H:i:s') . "', '0')";
        $JLMS_DB->SetQuery($query);
        $JLMS_DB->query();
        //tracking
        global $Track_Object;
        $Track_Object->UserEnterChat($my->id, $course_id);
        $query = "SELECT a.username FROM #__users as a, #__lms_chat_users as b" . "\n WHERE a.id = b.user_id AND b.course_id = '" . $course_id . "' AND b.group_id = '" . $group_id . "'" . "\n ORDER BY a.username";
        $JLMS_DB->SetQuery($query);
        $chat_users = $JLMS_DB->LoadObjectList();
        $course_chats = array();
        $course_chats[] = mosHTML::makeOption(0, _JLMS_CHAT_COURSE_CHAT);
        if ($JLMS_ACL->CheckPermissions('chat', 'manage')) {
            if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                $query = "SELECT ug.id AS value, ug.ug_name AS text" . "\n FROM #__lms_usergroups AS ug, #__lms_users_in_groups AS uig, #__lms_users_in_global_groups AS uigg" . "\n WHERE ug.group_chat = 1 AND uig.course_id = {$course_id} AND uigg.user_id = uig.user_id AND ug.id = uigg.group_id";
                $JLMS_DB->setQuery($query);
                $group_chats = $JLMS_DB->loadObjectList();
                for ($i = 0; $i < count($group_chats); $i++) {
                    $group_chats[$i]->text = $group_chats[$i]->text . " (" . _JLMS_CHAT_GROUP_CHAT . ")";
                }
                $course_chats = array_merge($course_chats, $group_chats);
            } else {
                $query = "SELECT id as value, ug_name as text FROM #__lms_usergroups WHERE course_id = {$course_id} AND group_chat = 1";
                $JLMS_DB->SetQuery($query);
                $group_chats = $JLMS_DB->loadObjectList();
                for ($i = 0; $i < count($group_chats); $i++) {
                    $group_chats[$i]->text = $group_chats[$i]->text . " (" . _JLMS_CHAT_GROUP_CHAT . ")";
                }
                $course_chats = array_merge($course_chats, $group_chats);
            }
        } else {
            if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                $query = "SELECT ug.id AS value, ug.ug_name AS text" . "\n FROM #__lms_usergroups AS ug, #__lms_users_in_groups AS uig, #__lms_users_in_global_groups AS uigg" . "\n WHERE uig.course_id = {$course_id} AND uigg.user_id = uig.user_id AND ug.id = uigg.group_id AND ug.group_chat = 1 AND uig.user_id = {$my->id}";
                $JLMS_DB->setQuery($query);
                $group_chats = $JLMS_DB->loadObjectList();
                for ($i = 0; $i < count($group_chats); $i++) {
                    $group_chats[$i]->text = $group_chats[$i]->text . " (" . _JLMS_CHAT_GROUP_CHAT . ")";
                }
                $course_chats = array_merge($course_chats, $group_chats);
            } else {
                $query = "SELECT b.id as value, b.ug_name as text FROM #__lms_users_in_groups as a, #__lms_usergroups as b WHERE a.course_id = {$course_id} AND a.user_id = '" . $my->id . "' AND a.group_id = b.id AND b.course_id = {$course_id} AND b.group_chat = 1";
                $JLMS_DB->SetQuery($query);
                $group_chats = $JLMS_DB->loadObjectList();
                for ($i = 0; $i < count($group_chats); $i++) {
                    $group_chats[$i]->text = _JLMS_CHAT_GROUP_CHAT . " (" . $group_chats[$i]->text . ")";
                }
                $course_chats = array_merge($course_chats, $group_chats);
            }
        }
        /*if (JLMS_GetUserType_simple($my->id) == 1) {
        		$query = "SELECT distinct b.* FROM #__lms_courses as b, #__lms_user_courses as a"
        		. "\n WHERE a.course_id = b.id AND a.user_id = '".$my->id."'";
        		} elseif (JLMS_GetUserType_simple($my->id) == 2) {
        		$query = "SELECT distinct a.* FROM #__lms_courses as a, #__lms_usergroups as b, #__lms_users_in_groups as c"
        		. "\n WHERE a.id = b.course_id AND b.id = c.group_id AND c.user_id = '".$my->id."'";
        		}
        		$JLMS_DB->SetQuery( $query );
        		$rows = $JLMS_DB->LoadObjectList();*/
        $lists = array();
        $javascript = 'onchange="document.chatForm.submit();"';
        $lists['course_chats'] = mosHTML::selectList($course_chats, 'group_id', 'class="inputbox" size="1" ' . $javascript, 'value', 'text', $group_id);
        JLMS_chat_html::showChat($course_id, $group_id, $option, $lists, $chat_users);
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"));
    }
}