Пример #1
2
 function JLMS_GB_getUserCertificates($id, $user_id, &$lists)
 {
     /**
      * Certificates MOD - 04.10.2007 (DEN)
      * We will show the list of all achieved certificates in the User Gradebook
      */
     global $JLMS_DB;
     $JLMS_ACL =& JLMSFactory::getACL();
     $query = "SELECT * FROM #__lms_quiz_t_quiz WHERE course_id = '" . $id . "' AND c_certificate <> 0 ORDER BY c_title";
     $JLMS_DB->SetQuery($query);
     $quiz_rows = $JLMS_DB->LoadObjectList();
     $p = array();
     foreach ($quiz_rows as $qrow) {
         $pp = new stdClass();
         $pp->gbi_id = $qrow->c_id;
         $pp->user_pts = 0;
         $pp->user_status = -1;
         $pp->quiz_name = '';
         $pp->crtf_id = '';
         $p[] = $pp;
     }
     $certificates = array();
     $quiz_ans = array();
     if (count($quiz_rows)) {
         $query = "SELECT a.*, b.c_full_score, b.c_title, b.c_certificate FROM #__lms_quiz_results as a, #__lms_quiz_t_quiz as b WHERE a.course_id = '" . $id . "'" . "\n AND a.quiz_id = b.c_id AND a.user_id = {$user_id} ORDER BY a.user_id, a.quiz_id";
         $JLMS_DB->SetQuery($query);
         $quiz_ans = $JLMS_DB->LoadObjectList();
         $j = 0;
         while ($j < count($quiz_ans)) {
             if ($quiz_ans[$j]->user_id == $user_id) {
                 $k = 0;
                 while ($k < count($p)) {
                     if ($p[$k]->gbi_id == $quiz_ans[$j]->quiz_id) {
                         $p[$k]->user_pts = $quiz_ans[$j]->user_score;
                         $p[$k]->user_status = $quiz_ans[$j]->user_passed;
                         $p[$k]->quiz_name = $quiz_ans[$j]->c_title;
                         $p[$k]->crtf_id = $quiz_ans[$j]->c_certificate;
                         $p[$k]->user_score = $quiz_ans[$j]->user_score;
                         $p[$k]->quiz_max_score = $quiz_ans[$j]->quiz_max_score;
                     }
                     $k++;
                 }
             }
             $j++;
         }
         $certificates = array();
         foreach ($p as $pp) {
             if ($pp->user_status == 1) {
                 $query = "SELECT * FROM #__lms_quiz_r_student_quiz WHERE c_quiz_id = {$pp->gbi_id} AND c_student_id = {$user_id} AND c_total_score = {$pp->user_pts} AND c_passed = 1 LIMIT 0,1";
                 $JLMS_DB->SetQuery($query);
                 $u_res = $JLMS_DB->LoadObject();
                 if (is_object($u_res)) {
                     $role = $JLMS_ACL->UserRole($JLMS_DB, $user_id, 1);
                     $query = "SELECT crtf_date FROM #__lms_certificate_prints WHERE user_id = {$user_id} AND (role_id = '" . $role . "' OR role_id = 0)  AND course_id = {$id} AND quiz_id = {$pp->gbi_id} AND crtf_id = {$pp->crtf_id}" . "\n ORDER BY role_id DESC LIMIT 0,1";
                     /* !!!!!!!! Bring from DB date of printing by user role or by default role (only if userrole not found) - imenno dlya etogo tut sidit ORDER i LIMIT*/
                     $JLMS_DB->SetQuery($query);
                     $crtf_date = $JLMS_DB->LoadResult();
                     if (!$crtf_date) {
                         $crtf_date = $u_res->c_date_time;
                     }
                     $ppp = new stdClass();
                     $ppp->user_id = $user_id;
                     $ppp->stu_quiz_id = $u_res->c_id;
                     $ppp->user_unique_id = $u_res->unique_id;
                     $ppp->quiz_name = $pp->quiz_name;
                     $ppp->crtf_date = $crtf_date;
                     $ppp->c_quiz_id = $u_res->c_quiz_id;
                     $ppp->user_score = $pp->user_score;
                     $ppp->quiz_max_score = $pp->quiz_max_score;
                     $certificates[] = $ppp;
                 }
             }
         }
     }
     $lists['user_quiz_certificates'] =& $certificates;
     /* END of Certificates MOD */
 }
Пример #2
0
function JLMS_checkCourseGID($user_id, $course_gid)
{
    global $JLMS_DB, $JLMS_CONFIG;
    $acl =& JLMSFactory::getJoomlaACL();
    //Cache functions (save data about user gid, course gid and access results in JLMS_CONFIG)
    $cache_user_gids = $JLMS_CONFIG->get('cache_user_gids', array());
    $user_item = 'user_' . $user_id;
    if (isset($cache_user_gids[$user_item]) && $cache_user_gids[$user_item]) {
        $userGids = $cache_user_gids[$user_item];
    } else {
        if ($user_id) {
            if (JLMS_J16version()) {
                $userGids = $acl->getGroupsByUser($user_id);
            } else {
                $query = "SELECT gid FROM #__users WHERE id = " . $user_id;
                $JLMS_DB->SetQuery($query);
                $userGids[] = $JLMS_DB->LoadResult();
            }
        } else {
            $userGids = array();
        }
        $cache_user_gids[$user_item] = $userGids;
        $JLMS_CONFIG->set('cache_user_gids', $cache_user_gids);
    }
    $result = false;
    $ac_groups = array(0);
    if ($course_gid) {
        $ac_groups = explode(",", $course_gid);
    }
    if (in_array(0, $ac_groups)) {
        $result = true;
    } elseif ($user_id && is_array($ac_groups)) {
        $adminGroups = JLMS_getAdminGroups();
        $ac_groups = array_unique(array_merge($ac_groups, $adminGroups));
        foreach ($ac_groups as $ag) {
            $cache_gid_checked = $JLMS_CONFIG->get('cache_gid_checked', array());
            foreach ($userGids as $userGid) {
                $cg_item = 'check_gid_' . $userGid . '_' . $ag;
                if (isset($cache_gid_checked[$cg_item])) {
                    if ($cache_gid_checked[$cg_item]) {
                        $result = true;
                        break;
                    }
                } else {
                    if ($userGid == $ag) {
                        $result = true;
                        break;
                    }
                    if ($acl->is_group_child_of(intval($userGid), intval($ag), 'ARO')) {
                        $result = true;
                        break;
                    }
                }
                $cache_gid_checked[$cg_item] = $result;
                $JLMS_CONFIG->set('cache_gid_checked', $cache_gid_checked);
            }
        }
    }
    return $result;
}
Пример #3
0
 function jlms_install_plugins()
 {
     // installation of JoomlaLMS plugins (plugins were added in 1.0.5)
     $absolutePath = JPATH_SITE;
     $liveSite = substr_replace(JURI::root(), '', -1, 1);
     $database =& JFactory::getDBO();
     $plugins_dir = $absolutePath . '/components/com_joomla_lms/includes/plugins';
     $files = array();
     $handle = opendir($plugins_dir);
     while (false !== ($dir_name = readdir($handle))) {
         if (is_dir($plugins_dir . '/' . $dir_name) && $dir_name != "." && $dir_name != "..") {
             $dir = opendir($plugins_dir . '/' . $dir_name);
             while (false !== ($file = readdir($dir))) {
                 if ($file != "." && $file != ".." && preg_match('/\\.xml$/', $file)) {
                     $tmp = array('dir' => $dir_name, 'file' => $file);
                     $files[] = $tmp;
                 }
             }
         }
     }
     closedir($handle);
     //require_once($absolutePath.'/components/com_joomla_lms/joomla_lms.class.php');
     // TODO: replace class to the simple database INSERT
     for ($i = 0; $i < count($files); $i++) {
         // check if new
         $query = "SELECT COUNT(*) FROM #__lms_plugins WHERE element = '" . str_replace('.xml', '', $files[$i]['file']) . "' AND folder = '" . $files[$i]['dir'] . "'";
         $database->setQuery($query);
         $total = $database->loadResult();
         $phpfile = $absolutePath . '/components/com_joomla_lms/includes/plugins/' . $files[$i]['dir'] . '/' . str_replace('.xml', '.php', $files[$i]['file']);
         $xmlfile = $absolutePath . '/components/com_joomla_lms/includes/plugins/' . $files[$i]['dir'] . '/' . $files[$i]['file'];
         if ($total == 0 && file_exists($xmlfile)) {
             $row = new stdClass();
             $row->name = '';
             $row->short_description = '';
             $row->element = '';
             $row->folder = '';
             // xml file for module
             $xmlDoc =& JLMSFactory::getXMLParser();
             if ($xmlDoc->loadFile($xmlfile)) {
                 $root =& $xmlDoc->document;
                 if ($root->name() == 'jlmsplugin') {
                     $element =& $root->getElementByPath('name');
                     $row->name = $element ? trim($element->data()) : '';
                     $element =& $root->getElementByPath('short_description');
                     $row->short_description = $element ? trim($element->data()) : '';
                 }
             }
             $row->element = str_replace('.xml', '', $files[$i]['file']);
             $row->folder = $files[$i]['dir'];
             $query = "INSERT INTO #__lms_plugins (`name`, `element`, `folder`, `short_description`) VALUES(" . $database->Quote($row->name) . ", " . $database->Quote($row->element) . ", " . $database->Quote($row->folder) . ", " . $database->Quote($row->short_description) . ")";
             $database->setQuery($query);
             $database->query();
         }
     }
 }
Пример #4
0
function JLMSEmailRoute($url)
{
    $JLMS_CONFIG =& JLMSFactory::getConfig();
    $url = JRoute::_($url, false);
    $pos = strpos($url, 'http');
    if ($pos !== 0) {
        $del_part = JURI::root(true);
        $live_site_part = $JLMS_CONFIG->get('live_site');
        if (strlen($del_part)) {
            $live_site_part = str_replace(JURI::root(true) . '/', '', JURI::root(false));
        }
        $url = $live_site_part . $url;
    }
    return $url;
}
Пример #5
0
function botAssociateCEO($users_info)
{
    $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
    $dbo =& JFactory::GetDbo();
    //---->get bot info
    if (!isset($_JLMS_PLUGINS->_user_bot_params['ceoassoc'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__lms_plugins" . "\n WHERE element = 'ceoassoc'" . "\n AND folder = 'user'";
        $dbo->setQuery($query);
        $bot = $dbo->loadObject();
        // save query to class variable
        $_JLMS_PLUGINS->_user_bot_params['ceoassoc'] = $bot;
    }
    // pull query data from class variable
    $bot = $_JLMS_PLUGINS->_user_bot_params['ceoassoc'];
    $botParams = new jlmsPluginParameters($bot->params);
    $botParams->def('ceo_user_id', 0);
    //<----
    if ($parent_id = $botParams->get('ceo_user_id', 0)) {
        if (is_array($users_info)) {
            foreach ($users_info as $user_info) {
                //---->check if user already associated to CEO and add associate if not
                $query = "SELECT COUNT(*) FROM #__lms_user_parents WHERE parent_id = {$parent_id} AND user_id = {$user_info->user_id}";
                $dbo->setQuery($query);
                if (!$dbo->loadResult()) {
                    $query = "INSERT INTO #__lms_user_parents (`parent_id`, `user_id`) VALUES ({$parent_id}, {$user_info->user_id})";
                    $dbo->setQuery($query);
                    $dbo->query();
                }
                //<----
            }
        } else {
            $user_info = $users_info;
            //---->check if user already associated to CEO and add associate if not
            $query = "SELECT COUNT(*) FROM #__lms_user_parents WHERE parent_id = {$parent_id} AND user_id = {$user_info->user_id}";
            $dbo->setQuery($query);
            if (!$dbo->loadResult()) {
                $query = "INSERT INTO #__lms_user_parents (`parent_id`, `user_id`) VALUES ({$parent_id}, {$user_info->user_id})";
                $dbo->setQuery($query);
                $dbo->query();
            }
            //<----
        }
    }
    return;
}
Пример #6
0
function JLMS_pluginaction()
{
    $folder = JRequest::getVar('folder', '');
    $plugin = JRequest::getVar('plugin', '');
    $db =& JFactory::getDBO();
    $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
    $query = "SELECT element, folder" . "\n FROM #__lms_plugins" . "\n WHERE 1" . "\n AND folder = '" . $folder . "'" . "\n AND element = '" . $plugin . "'" . "\n AND published = '1'";
    $db->setQuery($query);
    $plugin_in_db = $db->loadObject();
    $exist_in_db = isset($plugin_in_db->element) ? 1 : 0;
    $exist_in_dir = 0;
    if ($exist_in_db && file_exists(JPATH_SITE . DS . 'components' . DS . 'com_joomla_lms' . DS . 'includes' . DS . 'plugins' . DS . $plugin_in_db->folder . DS . $plugin_in_db->element . '.php') && file_exists(JPATH_SITE . DS . 'components' . DS . 'com_joomla_lms' . DS . 'includes' . DS . 'plugins' . DS . $plugin_in_db->folder . DS . $plugin_in_db->element . '.xml')) {
        $exist_in_dir = 1;
    }
    require_once JPATH_SITE . DS . 'components' . DS . 'com_joomla_lms' . DS . 'includes' . DS . 'plugins' . DS . $plugin_in_db->folder . DS . $plugin_in_db->element . '.php';
    $_JLMS_PLUGINS->trigger('onPluginAction');
    exit;
}
Пример #7
0
 function getJReviews_Form($listing_id, $tmpl_suffix = '')
 {
     $JLMS_CONFIG =& JLMSFactory::getConfig();
     # Populate $params array with module settings
     $JreParams['data']['extension'] = 'com_joomla_lms';
     $JreParams['data']['tmpl_suffix'] = $tmpl_suffix;
     $JreParams['data']['controller'] = 'everywhere';
     $JreParams['data']['action'] = 'index';
     $JreParams['data']['listing_id'] = $listing_id;
     $JreParams['data']['limit_special'] = $JLMS_CONFIG->getCfg('list_limit', 15);
     // Load dispatch class
     $Dispatcher = new S2Dispatcher('jreviews', true);
     $jreDetail = $Dispatcher->dispatch($JreParams);
     $form = false;
     if ($jreDetail) {
         $form = $jreDetail['output'];
     }
     return $form;
 }
Пример #8
0
function addToWaitingList($user_info, $course_info)
{
    $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
    $dbo =& JFactory::GetDbo();
    //---->get bot info
    if (!isset($_JLMS_PLUGINS->_course_bot_params['waitinglist'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__lms_plugins" . "\n WHERE element = 'waitinglist'" . "\n AND folder = 'course'";
        $dbo->setQuery($query);
        $bot = $dbo->loadObject();
        // save query to class variable
        $_JLMS_PLUGINS->_course_bot_params['waitinglist'] = $bot;
    }
    // pull query data from class variable
    $bot = $_JLMS_PLUGINS->_course_bot_params['waitinglist'];
    $botParams = new jlmsPluginParameters($bot->params);
    //count users in course
    $query = "SELECT COUNT(DISTINCT(user_id)) FROM `#__lms_users_in_groups` WHERE course_id = {$course_info->course_id}";
    // AND role_id = 2";
    $dbo->setQuery($query);
    $current_attendees = $dbo->loadResult();
    $max_attendees = $course_info->max_attendees;
    //course not full - return true
    if (!$max_attendees || $max_attendees > $current_attendees) {
        return true;
    }
    //check if user is already in waiting list (just in case)
    $query = "SELECT COUNT(*) FROM #__lms_waiting_lists WHERE course_id = {$course_info->course_id} AND user_id = {$user_info->user_id}";
    $dbo->setQuery($query);
    if ($dbo->loadResult()) {
        return false;
    }
    //get max ordering of needed list
    $query = "SELECT MAX(ordering) FROM #__lms_waiting_lists WHERE course_id = {$course_info->course_id}";
    $dbo->setQuery($query);
    $ordering = $dbo->loadResult();
    $ordering++;
    //add user to waiting list
    $query = "INSERT INTO #__lms_waiting_lists (course_id, user_id, ordering) VALUES ({$course_info->course_id}, {$user_info->user_id}, {$ordering})";
    $dbo->setQuery($query);
    $dbo->query();
    return false;
}
Пример #9
0
function Joomla_lmsParseRoute($segments)
{
    //Get the active menu item
    $component = JComponentHelper::getComponent('com_joomla_lms');
    $app = JFactory::getApplication();
    $menu = $app->getMenu();
    $item = $menu->getActive();
    $itemid = isset($item->id) ? $item->id : 0;
    if (!$itemid) {
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $itemid = $JLMS_CONFIG->get('Itemid');
    }
    $JLMSSefObject = getJLMSSefObject();
    $segments = str_replace(':', '-', $segments);
    $JLMSSefObject->setData($segments);
    $JLMSSefObject->calledFromRouterPHP();
    $vars = $JLMSSefObject->parseSefSegments();
    $vars['Itemid'] = $itemid;
    return $vars;
}
Пример #10
0
function notifyCourseJoined($users_info)
{
    $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
    $JLMS_CONFIG =& JLMSFactory::getConfig();
    //---->get bot info
    $dbo =& JFactory::GetDbo();
    if (!isset($_JLMS_PLUGINS->_nontify_bot_params['coursejoinnotify'])) {
        // load mambot params info
        $query = "SELECT params" . "\n FROM #__lms_plugins" . "\n WHERE element = 'coursejoinnotify'" . "\n AND folder = 'notifications'";
        $dbo->setQuery($query);
        $bot = $dbo->loadObject();
        // save query to class variable
        $_JLMS_PLUGINS->_notify_bot_params['coursejoinnotify'] = $bot;
    }
    // pull query data from class variable
    $bot = $_JLMS_PLUGINS->_notify_bot_params['coursejoinnotify'];
    $botParams = new jlmsPluginParameters($bot->params);
    $botParams->def('mail_template', 'Hello {user_name}, You have just been added to the course {course_name} attendees list.');
    $botParams->def('mail_subject', 'Course joining notification');
    //<----
    foreach ($users_info as $info_ids) {
        $query = "SELECT c.course_name AS course_name, u.name AS user_name, u.email AS mail_address FROM #__lms_courses AS c, #__users AS u" . "\n WHERE c.id={$info_ids->course_id} AND u.id={$info_ids->user_id}";
        $dbo->setQuery($query);
        $info_text = $dbo->loadObject();
        $mail_address = $dbo->getEscaped($info_text->mail_address);
        $mail_subject = $dbo->getEscaped($botParams->get('mail_subject'));
        $mail_text = $botParams->get('mail_template');
        $mail_text = str_replace('{user_name}', $info_text->user_name, $mail_text);
        $mail_text = str_replace('{course_name}', $info_text->course_name, $mail_text);
        $mail_text = str_replace('{site_URL}', $JLMS_CONFIG->get('live_site'), $mail_text);
        $mail_text = $dbo->getEscaped($mail_text);
        $query = "INSERT INTO #__lms_notifications (assigned, mail_address, mail_subject, mail_body, sent) VALUES" . "\n ({$info_ids->teacher_id}, '{$mail_address}', '{$mail_subject}', '{$mail_text}', 0)";
        $dbo->setQuery($query);
        $dbo->query();
    }
}
Пример #11
0
function JLMS_LoadSCOSCORM($option)
{
    global $JLMS_DB, $my, $Itemid;
    $JLMS_CONFIG =& JLMSFactory::getConfig();
    $id = intval(mosGetParam($_REQUEST, 'id', 0));
    $delayseconds = 20;
    // Delay time before sco launch, used to give time to browser to define API
    $delayseconds_nojs = 2;
    // if API were defined earlier than timer is passed - SCO will be launched
    if ($id) {
        $query = "SELECT * FROM #__lms_n_scorm WHERE id = {$id}";
        $JLMS_DB->SetQuery($query);
        $scorm = $JLMS_DB->LoadObject();
        if (is_object($scorm)) {
            $scoid = intval(mosGetParam($_REQUEST, 'scoid', 0));
            if (!empty($scoid)) {
                //
                // Direct SCO request
                //
                if ($sco = scorm_get_sco($scoid)) {
                    // (DEN) check if this $scoid from our SCORM !!!!
                    if ($sco->launch == '') {
                        // Search for the next launchable sco
                        $query = "SELECT * FROM #__lms_n_scorm_scoes WHERE scorm = {$scorm->id} AND launch <> '' AND id > {$sco->id} ORDER BY id ASC";
                        $JLMS_DB->SetQuery($query);
                        $scoes = $JLMS_DB->LoadObjectList();
                        //if ($scoes = get_records_select('scorm_scoes','scorm='.$scorm->id." AND launch<>'' AND id>".$sco->id,'id ASC')) {
                        if (!empty($scoes)) {
                            $sco = current($scoes);
                        }
                    }
                }
            }
            //
            // If no sco was found get the first of SCORM package
            //
            if (!isset($sco)) {
                $query = "SELECT * FROM #__lms_n_scorm_scoes WHERE scorm = {$scorm->id} AND launch <> '' ORDER BY id ASC";
                $JLMS_DB->SetQuery($query);
                $scoes = $JLMS_DB->LoadObjectList();
                //$scoes = get_records_select('scorm_scoes','scorm='.$scorm->id." AND launch<>''",'id ASC');
                $sco = current($scoes);
            }
            if (!empty($sco)) {
                if ($sco->scormtype == 'asset') {
                    $attempt = scorm_get_last_attempt($scorm->id, $my->id);
                    $element = $scorm->version == 'scorm_13' ? 'cmi.completion_status' : 'cmi.core.lesson_status';
                    $value = 'completed';
                    $result = scorm_insert_track($my->id, $scorm->id, $sco->id, $attempt, $element, $value);
                }
            }
            //
            // Forge SCO URL
            //
            $connector = '';
            $version = substr($scorm->version, 0, 4);
            if (isset($sco->parameters) && !empty($sco->parameters) || $version == 'AICC') {
                /**
                 * 06.10.2007 (DEN) "''." - is added for compatibility with Joomla compatibility :)) library compat.php50x.php (on line 105 in PHP 4.4.7 there was a notice)
                 */
                if (stripos('' . $sco->launch, '?') !== false) {
                    $connector = '&';
                } else {
                    $connector = '?';
                }
                if (isset($sco->parameters) && !empty($sco->parameters) && $sco->parameters[0] == '?') {
                    $sco->parameters = substr($sco->parameters, 1);
                }
            }
            if ($version == 'AICC') {
                if (isset($sco->parameters) && !empty($sco->parameters)) {
                    $sco->parameters = '&' . $sco->parameters;
                }
                //$launcher = $sco->launch.$connector.'aicc_sid='.$my->id.'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco->parameters;
                $launcher = $sco->launch . $connector . 'aicc_sid=' . $my->id . '&aicc_url=' . $JLMS_CONFIG->get('live_site') . "/index.php?option={$option}&Itemid={$Itemid}&task=aicc_task&course_id={$course_id}" . $sco->parameters;
                // (DEN) check this URL /\ !!!!!!!!!
            } else {
                if (isset($sco->parameters) && !empty($sco->parameters)) {
                    $launcher = $sco->launch . $connector . $sco->parameters;
                } else {
                    $launcher = $sco->launch;
                }
            }
            $query = "SELECT * FROM #__lms_scorm_packages WHERE id = {$scorm->scorm_package}";
            $JLMS_DB->SetQuery($query);
            $scorm_ref = $JLMS_DB->LoadObject();
            //$reference = $CFG->dataroot.'/'.$courseid.'/'.$reference;
            //$row->reference = _JOOMLMS_SCORM_FOLDER_PATH . "/" . $scorm_ref->package_srv_name;
            $reference_folder = $JLMS_CONFIG->get('live_site') . "/" . _JOOMLMS_SCORM_PLAYER . "/" . $scorm_ref->folder_srv_name;
            //$reference_folder = _JOOMLMS_SCORM_FOLDER_PATH . "/" . $scorm_ref->folder_srv_name;
            // (DEN) we don't use external links nor repositry (but maybe...maybe...)
            /*if (scorm_external_link($sco->launch)) {
            			// Remote learning activity
            			$result = $launcher;
            		} else if ($scorm->reference[0] == '#') {
            			// Repository
            			require_once($repositoryconfigfile);
            			$result = $CFG->repositorywebroot.substr($scorm->reference,1).'/'.$sco->launch;
            		} else {*/
            if (true) {
                // (DEN) we don't use external packages
                /*if ((basename($scorm->reference) == 'imsmanifest.xml') && scorm_external_link($scorm->reference)) {
                			// Remote manifest
                			$result = dirname($scorm->reference).'/'.$launcher;
                		} else {*/
                if (true) {
                    // Moodle internal package/manifest or remote (auto-imported) package
                    //if (basename($scorm->reference) == 'imsmanifest.xml') {
                    if (basename($reference_folder) == 'imsmanifest.xml') {
                        //$basedir = dirname($scorm->reference);
                        $basedir = dirname($reference_folder);
                    } else {
                        $basedir = $reference_folder;
                        //$CFG->moddata.'/scorm/'.$scorm->id;
                    }
                    /*if ($CFG->slasharguments) {
                    			$result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/'.$basedir.'/'.$launcher;
                    		} else {
                    			$result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/'.$basedir.'/'.$launcher;
                    		}*/
                    $result = $reference_folder . '/' . $launcher;
                    // determine the name of the API variable, which are we looking for
                    $LMS_api = $scorm->version == 'scorm_12' || $scorm->version == 'SCORM_1.2' || empty($scorm->version) ? 'API' : 'API_1484_11';
                    if (isset($sco->scormtype) && strtolower($sco->scormtype) == 'asset') {
                        $delayseconds = 2;
                        // if resource is 'asset' - we don't need SCORM API
                    }
                    ?>
<html>
    <head>
        <title>LoadSCO</title>
        <script type="text/javascript">
        //<![CDATA[
		var delaySeconds = <?php 
                    echo $delayseconds;
                    ?>

		function findscormAPI(win) {
			var findAPITries = 0;
			while ((win.<?php 
                    echo $LMS_api;
                    ?>
 == null) && (win.parent != null) && (win.parent != win)) {
				findAPITries++;
				if (findAPITries > 7) { // we don't have more than 7 nested window objects....
					return null;
				}
				win = win.parent;
			}
			return win.<?php 
                    echo $LMS_api;
                    ?>
;
		}

		function getscormAPI() {
			var theAPI = findscormAPI(window);
			if ((theAPI == null) && (window.opener != null) && (typeof(window.opener) != "undefined")) {
				theAPI = findscormAPI(window.opener);
			}
			if (theAPI == null) {
				return null;
			}
			return theAPI;
		}

		function try_redirect() {
			if (getscormAPI() == null) {
				delaySeconds = delaySeconds - 1;
				if (delaySeconds < 0) {
					setTimeout('do_window_redirect();',1000);
				} else {
					setTimeout('try_redirect();',1000);
				}
			} else {
				setTimeout('do_window_redirect();',1000);
			}
		}
		function do_window_redirect() {
			document.location = "<?php 
                    echo $result;
                    ?>
";
		}
        //]]>
        </script>
        <noscript>
            <meta http-equiv="refresh" content="<?php 
                    echo $delayseconds_nojs;
                    ?>
;url=<?php 
                    echo $result;
                    ?>
" />
        </noscript> 
    </head>
    <body onload="try_redirect();">
        <br /><br /><center><img src="<?php 
                    echo $JLMS_CONFIG->get('live_site');
                    ?>
/components/com_joomla_lms/lms_images/loading.gif" height="32" width="32" border="0" alt="loading" /></center>
    </body>
</html>
<?php 
                }
            }
        }
    }
    die;
}
Пример #12
0
 function show($object_id, $object_group = 'com_content', $object_title = '', $search_text = '')
 {
     $object_id = (int) $object_id;
     $object_group = trim($object_group);
     $object_title = trim($object_title);
     $acl =& JCommentsFactory::getACL();
     $config =& JCommentsFactory::getConfig();
     $JLMS_CONFIG =& JLMSFactory::getConfig();
     $app =& JFactory::getApplication();
     $tmpl =& JCommentsFactory::getTemplate($object_id, $object_group);
     $tmpl->load('tpl_index');
     if ($config->getInt('object_locked', 0) == 1) {
         $config->set('enable_rss', 0);
         $tmpl->addVar('tpl_index', 'comments-form-locked', 1);
     }
     if (JCOMMENTS_JVERSION == '1.5') {
         $document =& JFactory::getDocument();
     }
     if (!defined('JCOMMENTS_CSS')) {
         include_once JCOMMENTS_HELPERS . DS . 'system.php';
         if ($app->isAdmin()) {
             $tmpl->addVar('tpl_index', 'comments-css', 1);
         } else {
             $link = JCommentsSystemPluginHelper::getCSS();
             $document->addStyleSheet($link);
         }
     }
     if (!defined('JCOMMENTS_JS')) {
         include_once JCOMMENTS_HELPERS . DS . 'system.php';
         if ($config->getInt('gzip_js') == 1) {
             $document->addScript(JCommentsSystemPluginHelper::getCompressedJS());
         } else {
             $document->addScript(JCommentsSystemPluginHelper::getCoreJS());
             if (!defined('JOOMLATUNE_AJAX_JS')) {
                 $document->addScript(JCommentsSystemPluginHelper::getAjaxJS());
                 define('JOOMLATUNE_AJAX_JS', 1);
             }
         }
     }
     $tmpl->addVar('tpl_index', 'comments-form-captcha', $acl->check('enable_captcha'));
     $tmpl->addVar('tpl_index', 'comments-form-link', $config->getInt('form_show') ? 0 : 1);
     if ($config->getInt('enable_rss') == 1) {
         $link = JCommentsFactory::getLink('rss', $object_id, $object_group);
         $attribs = array('type' => 'application/rss+xml', 'title' => strip_tags($object_title));
         $document->addHeadLink($link, 'alternate', 'rel', $attribs);
     }
     $cacheEnabled = intval($JLMS_CONFIG->get('caching')) == 1;
     if ($cacheEnabled == 0) {
         $jrecache = $JLMS_CONFIG->get('absolute_path') . DS . 'components' . DS . 'com_jrecache' . DS . 'jrecache.config.php';
         if (is_file($jrecache)) {
             $cfg = new _JRECache_Config();
             $cacheEnabled = $cacheEnabled && $cfg->enable_cache;
         }
     }
     $load_cached_comments = $config->getInt('load_cached_comments', 0);
     if ($cacheEnabled) {
         $tmpl->addVar('tpl_index', 'comments-anticache', 1);
     }
     if (!$cacheEnabled || $load_cached_comments === 1) {
         if ($config->get('template_view') == 'tree' && !strlen($search_text)) {
             $tmpl->addVar('tpl_index', 'comments-list', JLMS_JComments::getCommentsTree($object_id, $object_group, $search_text));
         } else {
             $tmpl->addVar('tpl_index', 'comments-list', JLMS_JComments::getCommentsList($object_id, $object_group, $search_text));
         }
     }
     $needScrollToComment = $cacheEnabled || $config->getInt('comments_per_page') > 0;
     $tmpl->addVar('tpl_index', 'comments-gotocomment', (int) $needScrollToComment);
     $tmpl->addVar('tpl_index', 'comments-form', JComments::getCommentsForm($object_id, $object_group, $config->getInt('form_show') == 1));
     $result = $tmpl->renderTemplate('tpl_index');
     $tmpl->freeAllTemplates();
     return $result;
 }
    function showUserAttendance($option, &$rows, &$per_rows, &$date_rows, &$lists)
    {
        global $Itemid, $my, $JLMS_CONFIG;
        $JLMS_ACL =& JLMSFactory::getACL();
        ?>
		
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
function submitbutton_change(pressbutton, period_id, state) {
	var form = document.adminForm;
	if (pressbutton == 'at_dateschange'){
		if (form.boxchecked.value == 0) {
			alert( "<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
" );
		} else {
			form.task.value = pressbutton;
			form.state.value = state;
			form.period_id.value = period_id;
			form.submit();
		}
	}
}
function submitbutton_change_user(pressbutton, period_id, state, cid_id, at_date_value) {
	var form = document.adminForm;
	if (pressbutton == 'at_uchange'){
		form.cid2.value = cid_id;		
		form.task.value = pressbutton;
		form.at_date.value = at_date_value;
		form.state.value = state;
		form.period_id.value = period_id;
		form.submit();
	}
}
function pickup_date(){
	var form = document.adminForm;
	form.at_date.value = form.pick_date.value;
	form.submit();
}
//--><!]]>
</script>
<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        $toolbar = array();
        if ($JLMS_ACL->CheckPermissions('attendance', 'manage')) {
            $hparams['second_tb_header'] = $lists['username'] . ',&nbsp;' . $lists['name'];
            $toolbar[] = array('btn_type' => 'back', 'btn_js' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=attendance&amp;id=" . $lists['course_id']));
        }
        JLMS_TMPL::ShowHeader('attendance', $JLMS_ACL->CheckPermissions('attendance', 'manage') ? _JLMS_ATT_TITLE : _JLMS_ATT_TITLE_STU, $hparams, $toolbar);
        if ($JLMS_ACL->CheckPermissions('attendance', 'manage')) {
            JLMS_TMPL::OpenTS('', ' class="contentheading"');
            //echo $lists['username'].',&nbsp;'.$lists['name'];
            JLMS_TMPL::CloseTS();
        }
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}");
        ?>
" method="post" name="adminForm">
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
				<tr>
					<td align="left" style="text-align:left ">
						<div align="left" style="white-space:nowrap ">
						&nbsp;
						</div>
					</td>
					<td align="right" style="text-align:right ">
						<div align="right" style="white-space:nowrap ">
							<table cellpadding="0" cellspacing="0" border="0" style="height:16px" class="jlms_table_no_borders">
								<tr>
									<td><?php 
        echo $lists['filter'];
        ?>
&nbsp;&nbsp;</td>
									<td valign="middle" align="center" width="16">
										<?php 
        echo JLMS_HTML::_('calendar.calendar', $lists['at_date'], 'pick', 'pick', null, null, 'statictext');
        ?>
				
									</td><td valign="middle" align="center" width="18" style="vertical-align:middle ">
										<a class="jlms_img_link" href="javascript:pickup_date();" title="<?php 
        echo _JLMS_AGENDA_GO_DATE;
        ?>
">
											<img class="JLMS_png" src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/agenda/loopnone.png" alt="<?php 
        echo _JLMS_AGENDA_GO_DATE;
        ?>
" title="<?php 
        echo _JLMS_AGENDA_GO_DATE;
        ?>
" border="0" width="16" height="16" />
										</a>
										<noscript>
											<input type="submit" name="OK" value="OK" />
											<input type="hidden" name="no_script" value="1" />
										</noscript>
									</td>
								</tr>
							</table>	
						</div>
					</td>
				</tr>
			</table>

			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
        echo JLMSCSS::_('jlmslist');
        ?>
">
				<tr>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 width="20" class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center">#</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<?php 
        if ($JLMS_ACL->CheckPermissions('attendance', 'manage')) {
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="20" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php 
            echo count($rows);
            ?>
);" /></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
        }
        ?>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
">date</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<?php 
        foreach ($per_rows as $per_row) {
            echo '<' . JLMSCSS::tableheadertag() . ' align=\'center\' nowrap="nowrap" class="' . JLMSCSS::_('sectiontableheader') . '" style="text-align:center; white-space:nowrap">' . substr($per_row->period_begin, 0, 5) . ' - ' . substr($per_row->period_end, 0, 5) . '</' . JLMSCSS::tableheadertag() . '>';
        }
        ?>
				</tr>
			<?php 
        $k = 1;
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row = $rows[$i];
            #$link = "index.php?option=$option&amp;Itemid=".$Itemid."&amp;task=at_userattend&amp;course_id=".$lists['course_id']."&amp;at_date=".$lists['at_date']."&amp;id={$row->user_id}";
            $checked = JLMS_attendance_html::idBox($i, $row->at_date, $row->is_selected);
            ?>
				<tr class="<?php 
            echo JLMSCSS::_('sectiontableentry' . $k);
            ?>
">
					<td align="center" valign="middle"><?php 
            echo $i + 1;
            ?>
</td>
					<?php 
            if ($JLMS_ACL->CheckPermissions('attendance', 'manage')) {
                ?>
					<td><?php 
                echo $checked;
                ?>
</td>
					<?php 
            }
            ?>
					<td align="left" valign="middle" style="vertical-align:middle ">
						<?php 
            echo JLMS_dateToDisplay($row->at_date);
            ?>
					</td>
					<?php 
            $j = 0;
            while ($j < count($row->at_stats)) {
                $alt = $row->at_stats[$j]->at_status ? _JLMS_ATT_STATUS_ATTENDED : _JLMS_ATT_STATUS_NOTATTENDED;
                $image = $row->at_stats[$j]->at_status ? 'btn_accept.png' : 'btn_cancel.png';
                $state = $row->at_stats[$j]->at_status ? 0 : 1;
                echo '<td align=\'center\' valign="middle" style="vertical-align:middle;text-align:center ">';
                if ($JLMS_ACL->CheckPermissions('attendance', 'manage')) {
                    echo '<a class="jlms_img_link" href="javascript:submitbutton_change_user(\'at_uchange\',' . $row->at_stats[$j]->period_id . ',' . $state . ',' . $lists['user_id'] . ',\'' . $row->at_date . '\');" title="' . $alt . '"><img class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . $image . '" width="16" height="16" border="0" alt="' . $alt . '" /></a>';
                } elseif ($JLMS_ACL->CheckPermissions('attendance', 'view')) {
                    echo '<img class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . $image . '" width="16" height="16" border="0" alt="' . $alt . '" />';
                }
                echo '</td>';
                $j++;
            }
            ?>
				</tr>
				<?php 
            $k = 3 - $k;
        }
        if ($JLMS_ACL->CheckPermissions('attendance', 'manage')) {
            ?>
				<tr class="<?php 
            echo JLMSCSS::_('sectiontableentry' . $k);
            ?>
">
					<td colspan="3"><?php 
            echo _JLMS_ATT_WITH_SELECTED;
            ?>
</td>
					<?php 
            foreach ($per_rows as $per_row) {
                echo '<td align=\'center\' valign="middle" style="text-align:center; vertical-align:middle;">';
                echo '<a class="jlms_img_link" href="javascript:submitbutton_change(\'at_dateschange\',' . $per_row->id . ',1);" title="' . _JLMS_ATT_MARK_ATTENDED . '">';
                echo '<img class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/btn_accept.png" width="16" height="16" border="0" alt="' . _JLMS_ATT_MARK_ATTENDED . '" />';
                echo '</a>&nbsp;';
                echo '<a class="jlms_img_link" href="javascript:submitbutton_change(\'at_dateschange\',' . $per_row->id . ',0);" title="' . _JLMS_ATT_MARK_NOTATTENDED . '">';
                echo '<img class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/btn_cancel.png" width="16" height="16" border="0" alt="' . _JLMS_ATT_MARK_NOTATTENDED . '" />';
                echo '</a>';
                echo '</td>';
            }
            ?>
				</tr>
		<?php 
        }
        ?>
			</table>
			<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
			<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
			<input type="hidden" name="task" value="<?php 
        echo $JLMS_ACL->CheckPermissions('attendance', 'manage') ? 'at_userattend' : 'attendance';
        ?>
" />
			<input type="hidden" name="at_date" value="<?php 
        echo JLMS_dateToDisplay($lists['at_date']);
        ?>
" />
			<input type="hidden" name="period_id" value="0" />
			<input type="hidden" name="state" value="0" />
			<input type="hidden" name="cid2" value="0" />
			<input type="hidden" name="boxchecked" value="<?php 
        echo $lists['box'];
        ?>
" />
			<input type="hidden" name="course_id" value="<?php 
        echo $lists['course_id'];
        ?>
" />
			<input type="hidden" name="id" value="<?php 
        echo $JLMS_ACL->CheckPermissions('attendance', 'manage') ? $lists['user_id'] : $lists['course_id'];
        ?>
" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        JLMS_TMPL::CloseMT();
    }
    function showUsersGlobal($course_id, $group_id, $option, &$rows, &$lists, &$pageNav, $u_search, $view_type = 1)
    {
        global $Itemid, $JLMS_CONFIG;
        $JLMS_ACL =& JLMSFactory::getACL();
        ?>
		<script language="javascript" type="text/javascript">
		<!--
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if ((pressbutton == 'edit_user' || pressbutton == 'delete_user') && (form.boxchecked.value == "0")){
				alert( "<?php 
        echo _JLMS_USER_SELECT_USER;
        ?>
" );
			} else {
				form.task.value = pressbutton;
				form.submit();
			}
		}
		//-->
		</script>
		<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        $toolbar = array();
        $title = '';
        if ($view_type == 1) {
            $title = '&nbsp;' . _JLMS_USERS_TITLE;
        } elseif ($view_type == 2) {
            $title = '&nbsp;' . _JLMS_USERS_ASSISTS_TITLE;
        }
        //		$toolbar[] = array('btn_type' => 'back', 'btn_js' => sefRelToAbs("index.php?option=$option&amp;Itemid=$Itemid&amp;task=course_users&amp;id=$course_id"));
        JLMS_TMPL::ShowHeader('usergroup', $title, $hparams, $toolbar);
        if ($view_type == 1) {
            JLMS_TMPL::OpenTS();
            echo $lists['groups'];
            JLMS_TMPL::CloseTS();
        }
        JLMS_TMPL::OpenTS();
        $colspan = $view_type == 1 ? 9 : 4;
        ?>
		<form action="<?php 
        echo $JLMS_CONFIG->get('live_site') . "/index.php?option=" . $option . "&amp;Itemid=" . $Itemid;
        ?>
" method="post" name="adminForm">
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders" style="margin-top: 2px;">
				<tr>
					<td>
						<input type="text" class="inputbox" name="u_search" value="<?php 
        echo $u_search;
        ?>
" />
						<input type="button" value="Search" onclick="javascript:submitbutton('course_users');" />
					</td>
				</tr>
			</table>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
        echo JLMSCSS::_('jlmslist');
        ?>
" style="margin-top: 2px;">
				<tr>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 width="20" class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center">#</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<?php 
        if ($JLMS_ACL->CheckPermissions('users', 'manage')) {
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="20" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php 
            echo count($rows);
            ?>
);" /></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
        } else {
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="20" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>					
					<?php 
        }
        ?>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_USERS_TBL_HEAD_USERNAME;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_USERS_TBL_HEAD_USER_ADDINFO;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_USERS_TBL_HEAD_GROUP;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_TBL_HEAD_USERS_ROLE;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
				<?php 
        if ($view_type == 1) {
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" colspan="2" align="center"><?php 
            echo _JLMS_USERS_TBL_HEAD_USER_ACC_PERIOD;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_USERS_TBL_HEAD_USER_COMMENT;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				<?php 
        }
        ?>
				</tr>
			<?php 
        $k = 1;
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row = $rows[$i];
            $link = "index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=view_users&amp;course_id=" . $course_id . "&amp;id=" . $row->id;
            $checked = mosHTML::idBox($i, $row->id);
            if (!$JLMS_ACL->CheckPermissions('users', 'manage')) {
                $checked = '&nbsp;';
            }
            ?>
				<tr class="<?php 
            echo JLMSCSS::_('sectiontableentry' . $k);
            ?>
">
					<td align="center"><?php 
            echo $pageNav->limitstart + $i + 1;
            ?>
</td>
					<td><?php 
            echo $checked;
            ?>
</td>
					<td align="left">
					<?php 
            echo $row->username;
            ?>
					</td>
					<td><?php 
            echo $row->name . "(" . $row->email . ")";
            ?>
</td>
					<?php 
            if ($view_type == 1) {
                ?>
					<td align="center"><?php 
                echo $row->ug_name;
                ?>
</td>
					<td align="center"><?php 
                echo $row->lms_usertype;
                ?>
</td>
					<td align="center"><?php 
                echo $row->publish_start ? JLMS_dateToDisplay($row->start_date) : '-';
                ?>
</td>
					<td align="center"><?php 
                echo $row->publish_end ? JLMS_dateToDisplay($row->end_date) : '-';
                ?>
</td>
					<td><?php 
                echo $row->user_add_comment ? $row->user_add_comment : '&nbsp;';
                ?>
</td>
					<?php 
            }
            ?>
				</tr>
				<?php 
            $k = 3 - $k;
        }
        ?>
				<tr>
					<td colspan="<?php 
        echo $view_type == 1 ? '9' : '4';
        ?>
" align="center" class="<?php 
        echo JLMSCSS::_('jlmslist-footer_td');
        ?>
">
					<div align="center" style="white-space: nowrap;">
					<?php 
        $link = "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=course_users&amp;id={$course_id}&amp;group_id={$group_id}";
        if ($u_search != '') {
            $link .= '&amp;u_search=' . $u_search;
        }
        echo _PN_DISPLAY_NR . $pageNav->getLimitBox($link) . ' ' . $pageNav->getPagesCounter();
        echo '<br />';
        echo $pageNav->writePagesLinks($link);
        ?>
					</div>
					</td>
				</tr>
			</table>
			<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
			<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
			<input type="hidden" name="task" value="course_users" />
			<input type="hidden" name="group_id" value="<?php 
        echo $group_id;
        ?>
" />
			<input type="hidden" name="id" value="<?php 
        echo $course_id;
        ?>
" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="row_id" value="0" />
			<input type="hidden" name="state" value="0" />
			<input type="hidden" name="utype" value="<?php 
        echo $view_type;
        ?>
" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        $link_add = $JLMS_CONFIG->get('live_site') . "/index.php?option=" . $option . "&amp;task=add_user&amp;course_id=" . $course_id . "&amp;id=0&amp;Itemid=" . $Itemid . "";
        $link_import = $JLMS_CONFIG->get('live_site') . "/index.php?option=" . $option . "&amp;task=import_users_csv&amp;course_id=" . $course_id . "&amp;id=0&amp;Itemid=" . $Itemid . "";
        if ($view_type == 2) {
            $link_add .= '&amp;utype=2';
        }
        $controls = array();
        if ($JLMS_ACL->CheckPermissions('users', 'manage_teachers')) {
            $controls[] = array('href' => "javascript:submitbutton('view_assistants');", 'title' => _JLMS_USER_ASSIST_GROUP_NAME, 'img' => 'editusergroup');
            $controls[] = array('href' => 'spacer');
        }
        if ($JLMS_ACL->CheckPermissions('users', 'manage')) {
            $controls[] = array('href' => $link_add, 'title' => _JLMS_USER_ALT_ADDUSER, 'img' => 'adduser');
            $controls[] = array('href' => "javascript:submitbutton('delete_user');", 'title' => _JLMS_USER_ALT_DELUSER, 'img' => 'deluser');
            if ($view_type == 1) {
                $controls[] = array('href' => "javascript:submitbutton('edit_user');", 'title' => _JLMS_USER_ALT_EDITUSER, 'img' => 'edituser');
            }
            if ($JLMS_ACL->CheckPermissions('users', 'import_users')) {
                $controls[] = array('href' => 'spacer');
                $controls[] = array('href' => $link_import, 'title' => _JLMS_USER_IMPORT_TITLE, 'img' => 'csv_import');
            }
        }
        JLMS_TMPL::ShowControlsFooter($controls, '');
        JLMS_TMPL::CloseMT();
    }
Пример #15
0
function mail_notification($subscription)
{
    if (in_array(15, $subscription->courses)) {
        jimport('joomla.mail.helper');
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $SiteName = $JLMS_CONFIG->get('sitename');
        $MailFrom = $JLMS_CONFIG->get('mailfrom');
        $FromName = $JLMS_CONFIG->get('fromname');
        JLoader::import('autoresponder_spu', JPATH_SITE, '');
        $subject = AutoResponder::getSubject();
        $body = AutoResponder::getBody();
        $body = sprintf($body);
        $subject = JMailHelper::cleanSubject($subject);
        $body = JMailHelper::cleanBody($body);
        $from = $SiteName . ' ' . $FromName;
        $sender = JMailHelper::cleanAddress($MailFrom);
        $email = JMailHelper::cleanAddress(JRequest::getVar('x_email', ''));
        $user =& JFactory::getUser();
        $name = explode(' ', $user->name);
        $firstname = isset($name[0]) && $name[0] ? $name[0] : $user->name;
        $body = str_replace('{firstname}', $firstname, $body);
        if (JUtility::sendMail($from, $sender, $email, $subject, $body, true) !== true) {
            JError::raiseNotice(500, JText::_('EMAIL_NOT_SENT'));
        }
    }
}
    function showpageTracking($id, $option, &$rows, &$lists)
    {
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $JLMS_SESSION =& JLMSFactory::getSession();
        $Itemid = $JLMS_CONFIG->get('Itemid');
        global $my;
        JLMS_TMPL::OpenMT();
        $hparams = array();
        $page_13_stats_shown = false;
        $page_12_stats_shown = false;
        $page_14_stats_shown = false;
        if ($lists['page'] == 12) {
            $hparams['second_tb_header'] = _JLMS_TRACKING_DOCUMENTS_STATISTICS;
        } elseif ($lists['page'] == 13) {
            $hparams['second_tb_header'] = _JLMS_TRACKING_LPATHS_STATISTICS;
        } elseif ($lists['page'] == 14) {
            $hparams['second_tb_header'] = _JLMS_TRACKING_LATEST_COURSE_ACTIVITIES_REPORT;
        } else {
            $hparams['second_tb_header'] = _JLMS_TRACK_TITLE_ACCESS . JLMS_TRACKING_getTitle($lists['page']);
        }
        $toolbar = array();
        $toolbar[] = array('btn_type' => 'back', 'btn_js' => sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=tracking&id={$id}"));
        JLMS_TMPL::ShowHeader('tracking', _JLMS_TRACK_TITLE, $hparams, $toolbar);
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}");
        ?>
" method="post" name="adminForm">
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
				<tr>
					<td align="right" style="text-align:right ">
						<div align="right" style="white-space:nowrap ">
						<?php 
        if ($lists['page'] == 12 || $lists['page'] == 13 || $lists['page'] == 14) {
            //only group and user filters
            if (isset($lists['filter_lpath']) && $lists['page'] == 13) {
                echo $lists['filter_lpath'] . '<br />';
            }
            if (isset($lists['filter2'])) {
                echo $lists['filter2'] . '<br />';
            }
            if (isset($lists['filter3'])) {
                echo $lists['filter3'] . '<br />';
            }
            echo $lists['filter_stu'] . '<br />';
        } else {
            echo $lists['filter_pages'] . $lists['filter'] . $lists['filter_month'] . $lists['filter_day'];
            ?>
<br />
							<?php 
            /*if(isset($lists['filter_lpath'])){
            			echo $lists['filter_lpath'].'<br />';
            		}*/
            if (isset($lists['filter2'])) {
                echo $lists['filter2'] . '<br />';
            }
            if (isset($lists['filter3'])) {
                echo $lists['filter3'] . '<br />';
            }
            echo $lists['filter_stu'] . '<br />';
        }
        ?>
						</div>
					</td>
				</tr>
			</table>
<?php 
        if ($lists['page'] == 12 || $lists['page'] == 13 || $lists['page'] == 14) {
            //do nothing
        } else {
            //show hits statistics
            ?>
	<?php 
            $link = "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=tracking&amp;id={$id}";
            ?>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_TRACK_TBL_H_STU;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
            $rr = array();
            if ($lists['is_day']) {
                foreach ($lists['months'] as $ma) {
                    echo '<' . JLMSCSS::tableheadertag() . ' class="' . JLMSCSS::_('sectiontableheader') . '" align="center">' . JLMS_dateToDisplay(mktime(0, 0, 0, $ma->month, $ma->day, $ma->year), true) . '</' . JLMSCSS::tableheadertag() . '>';
                    $rr[] = $ma->month;
                }
            } else {
                foreach ($lists['months'] as $ma) {
                    echo '<' . JLMSCSS::tableheadertag() . ' class="' . JLMSCSS::_('sectiontableheader') . '" align="center">' . month_lang(strftime('%m', mktime(0, 0, 0, $ma->month + 1, 0, 0)), 0, 2) . ', ' . $ma->year . '</' . JLMSCSS::tableheadertag() . '>';
                    $rr[] = $ma->month;
                }
            }
            ?>
				</tr>
			<?php 
            $k = 1;
            $i = 0;
            $total_counts = array();
            for ($j = 0; $j < count($lists['months']); $j++) {
                $total_counts[$j] = 0;
            }
            while ($i < count($rows)) {
                $row = $rows[$i];
                $link = '';
                $link = "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=tracking&amp;id={$id}&amp;filter_stu=" . $row->user_id . "&amp;page=" . $lists['page'];
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td align="left" valign="middle" style="vertical-align:middle ">
						<a href="<?php 
                echo sefRelToAbs($link);
                ?>
" title="<?php 
                echo _JLMS_VIEW_DETAILS;
                ?>
">
							<?php 
                echo $row->username;
                ?>
						</a>
					</td>
					<?php 
                #$j = $lists['month']-1;
                $e = 0;
                $user = $rows[$i]->user_id;
                #$month = $rows[$i]->month;
                #$year = $rows[$i]->year;
                do {
                    if ($lists['is_day']) {
                        while (($lists['months'][$e]->day != $rows[$i]->day || $lists['months'][$e]->month != $rows[$i]->month || $lists['months'][$e]->year != $rows[$i]->year) && $e < count($lists['months'])) {
                            echo '<td align="center">0</td>';
                            $e++;
                        }
                        if ($rows[$i]->user_id == $user && $rows[$i]->day == $lists['months'][$e]->day && $rows[$i]->month == $lists['months'][$e]->month && $rows[$i]->year == $lists['months'][$e]->year) {
                            echo '<td align="center">' . $rows[$i]->count_hits . '</td>';
                            $total_counts[$e] = $total_counts[$e] + $rows[$i]->count_hits;
                        }
                    } else {
                        while (($lists['months'][$e]->month != $rows[$i]->month || $lists['months'][$e]->year != $rows[$i]->year) && $e < count($lists['months'])) {
                            echo '<td align="center">0</td>';
                            $e++;
                        }
                        if ($rows[$i]->user_id == $user && $rows[$i]->month == $lists['months'][$e]->month && $rows[$i]->year == $lists['months'][$e]->year) {
                            echo '<td align="center">' . $rows[$i]->count_hits . '</td>';
                            $total_counts[$e] = $total_counts[$e] + $rows[$i]->count_hits;
                        }
                    }
                    #$j ++;
                    $e++;
                    $i++;
                } while ($i < count($rows) && $rows[$i]->user_id == $user);
                while ($e < count($lists['months'])) {
                    echo '<td align="center">0</td>';
                    $e++;
                }
                if (isset($rows[$i]->user_id) && $rows[$i]->user_id != $user) {
                    $i--;
                }
                ?>
				</tr>
				<?php 
                $k = 3 - $k;
                $i++;
            }
            ?>
				<tr class="<?php 
            echo JLMSCSS::_('sectiontableentry' . $k);
            ?>
">
					<td align="left" valign="middle" style="vertical-align:middle "><?php 
            echo _JLMS_TOTAL;
            ?>
</td>
					<?php 
            for ($j = 0; $j < count($lists['months']); $j++) {
                echo '<td align="center"><strong>' . $total_counts[$j] . '</strong></td>';
            }
            ?>
				</tr>
			</table>
			<br /><br />
<?php 
        }
        ?>
		<?php 
        if ($lists['page'] == 14 && isset($lists['page14_stats']) && !empty($lists['page14_stats'])) {
            $page_14_stats_shown = true;
            ?>
		
			<script type="text/javascript">
				function submitbutton(pressbutton){
					var form = document.adminForm;
					form.view.value = pressbutton;
					form.submit();
				}
			</script>
		
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="20">#</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">
					<?php 
            echo _JLMS_TRACK_TBL_H_STU;
            ?>
					</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">
					&nbsp;
					</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">
					<?php 
            echo _JLMS_TRACK_TBL_H_ACTIVITY;
            ?>
					</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">
					<?php 
            echo _JLMS_TRACK_TBL_H_TIME;
            ?>
					</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				</tr>
			<?php 
            $limit = intval(mosGetParam($_GET, 'limit', $JLMS_SESSION->get('list_limit', $JLMS_CONFIG->getCfg('list_limit'))));
            $JLMS_SESSION->set('list_limit', $limit);
            $limitstart = intval(mosGetParam($_GET, 'limitstart', 0));
            $total = count($lists['page14_stats']);
            require_once _JOOMLMS_FRONT_HOME . DS . "includes" . DS . "classes" . DS . "lms.pagination.php";
            $pageNav = new JLMSPageNav($total, $limitstart, $limit);
            $k = 1;
            $count_activities = 0;
            $items_counter = 0;
            foreach ($lists['page14_stats'] as $latest_activity) {
                if ($count_activities >= $pageNav->limitstart && $count_activities < $pageNav->limitstart + $pageNav->limit) {
                    echo '<tr class="' . JLMSCSS::_('sectiontableentry' . $k) . '">';
                    echo '<td>';
                    echo $pageNav->limitstart + $items_counter + 1;
                    echo '</td>';
                    echo '<td>' . $latest_activity->user . '</td>';
                    echo '<td width="16"><img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/' . $latest_activity->icon . '" alt="i" width="16" height="16" border="0" /></td>';
                    echo '<td>' . $latest_activity->activity . '</td>';
                    echo '<td>' . JLMS_dateToDisplay($latest_activity->time, true, $JLMS_CONFIG->get('offset') * 60 * 60, ' H:i:s') . '</td>';
                    echo '</tr>';
                    $k = 3 - $k;
                    $items_counter++;
                }
                $count_activities++;
            }
            ?>
			<tr>
				<td colspan="5" align="center"class="<?php 
            echo JLMSCSS::_('jlmslist-footer_td');
            ?>
">
					<div align="center">
					<?php 
            $link = "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=tracking&amp;id={$id}&amp;page=14";
            echo $pageNav->writePagesLinks($link);
            ?>
					</div>
				</td>
			</tr>
			</table>
			<table width="100%" cellpadding="0" cellspacing="0" class="jlms_table_no_borders">
			<tr>
				<td align="center">
					<?php 
            $controls = array();
            $controls[] = array('href' => "javascript:submitbutton('csv');", 'title' => 'CSV', 'img' => 'csv');
            $controls[] = array('href' => "javascript:submitbutton('xls');", 'title' => 'XLS', 'img' => 'xls');
            JLMS_TMPL::ShowControlsFooterC($controls, '', false, false, _JLMS_EXPORT_TO . ':');
            ?>
	
				</td>
			</tr>
			</table>
		<?php 
        } elseif ($lists['page'] == 14 && !$page_14_stats_shown) {
            echo '<div class="joomlalms_user_message">' . _JLMS_TRACKING_NO_STATISTICS . '</div>';
        } elseif ($lists['page'] == 12 && $lists['filter_stu_val'] && isset($lists['page12_stats']) && !empty($lists['page12_stats'])) {
            $page_12_stats_shown = true;
            $max_tree_width = 0;
            if (isset($lists['page12_stats'][0])) {
                $max_tree_width = $lists['page12_stats'][0]->tree_max_width;
            }
            ?>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="<?php 
            echo 16 * ($max_tree_width + 1);
            ?>
" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" colspan="<?php 
            echo $max_tree_width + 1;
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="45%"><?php 
            echo _JLMS_TRACK_TBL_DOC_NAME;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center"><?php 
            echo _JLMS_TRACK_TBL_DOC_DOWNS;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center"><?php 
            echo _JLMS_TRACK_TBL_DOC_LAST;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				</tr>
			<?php 
            $k = 1;
            $tree_modes = array();
            for ($i = 0, $n = count($lists['page12_stats']); $i < $n; $i++) {
                $row_doc = $lists['page12_stats'][$i];
                $max_tree_width = $row_doc->tree_max_width;
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<?php 
                $add_img = '';
                if ($row_doc->tree_mode_num) {
                    $g = 0;
                    $tree_modes[$row_doc->tree_mode_num - 1] = $row_doc->tree_mode;
                    while ($g < $row_doc->tree_mode_num - 1) {
                        $pref = '';
                        if (isset($tree_modes[$g]) && $tree_modes[$g] == 2) {
                            $pref = 'empty_';
                        }
                        $add_img .= "<td width='16' valign='middle'><img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/treeview/" . $pref . "line.png\" width='16' height='16' /></td>";
                        $g++;
                    }
                    $add_img .= "<td width='16' valign='middle'><img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/treeview/sub" . $row_doc->tree_mode . ".png\" width='16' height='16' /></td>";
                    $max_tree_width = $max_tree_width - $g - 1;
                }
                echo $add_img;
                ?>
					<td align="center" valign="middle" style="vertical-align:middle " width='16'>
					<?php 
                if ($row_doc->folder_flag == 1) {
                    echo "<span style='alignment:center; font-weight:bold; vertical-align:middle;'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/folder.png\" width='16' height='16' alt='Folder' /></span>";
                } else {
                    echo "<span style='alignment:center; font-weight:bold; vertical-align:middle;'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/files/" . $row_doc->file_icon . ".png\" width='16' height='16' alt='File' /></span>";
                }
                ?>
					</td>
					<td align="left" valign="middle" <?php 
                if ($max_tree_width > 0) {
                    echo "colspan='" . ($max_tree_width + 1) . "'";
                }
                ?>
 width="35%">
					<?php 
                if ($row_doc->folder_flag || !$row_doc->folder_flag && !$row_doc->file_id) {
                    echo '<strong>' . $row_doc->doc_name . '</strong>';
                } else {
                    echo $row_doc->doc_name;
                }
                ?>
					</td>
					<td valign="middle" align="center">
						<?php 
                echo $row_doc->downloads;
                ?>
					</td>
					<td valign="middle" align="center">
						<?php 
                echo JLMS_dateToDisplay($row_doc->last_access, false, $JLMS_CONFIG->get('offset') * 60 * 60, ' H:i:s');
                ?>
					</td>
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
		<?php 
        } elseif ($lists['page'] == 12 && !$lists['filter_stu_val'] && isset($lists['page12_stats']) && !empty($lists['page12_stats'])) {
            $page_12_stats_shown = true;
            $max_tree_width = 0;
            if (isset($lists['page12_stats'][0])) {
                $max_tree_width = $lists['page12_stats'][0]->tree_max_width;
            }
            ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
var block_stats = 0;
var tID = '';
var url_prefix = '<?php 
            echo $JLMS_CONFIG->get('live_site') . "/index.php?tmpl=component&option={$option}&Itemid={$Itemid}&id={$id}";
            ?>
';
function jlms_MakeRequest(url) {
	var http_request = false;
	if (window.ActiveXObject) { // IE
		try { http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try { http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	} else if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	}
	if (!http_request) {
		return false;
	}
	http_request.onreadystatechange = function() { jlms_AnalizeRequest(http_request); };
	http_request.open('GET', url_prefix + url, true);
	http_request.send(null);
}
function jlms_AnalizeRequest(http_request) {
	if (http_request.readyState == 4) {
		if ((http_request.status == 200)) {
			block_stats = 0;
			if(http_request.responseXML.documentElement == null){
				try {
					http_request.responseXML.loadXML(http_request.responseText)
				} catch (e) {
					/*alert("Can't load");*/
				}
			}
			response  = http_request.responseXML.documentElement;
			var task = response.getElementsByTagName('task')[0].firstChild.data;
			switch (task) {
				case 'doc_xml':
					var response_data = response.getElementsByTagName('stats_table')[0].firstChild.data;
					var sec_indx = gl_el.parentNode.sectionRowIndex;
					var table = gl_el.parentNode.parentNode;
					var row = table.insertRow(sec_indx + 1);
					var cell1 = document.createElement("td");
					cell1.align = 'left';
					cell1.colSpan = "<?php 
            echo $max_tree_width + 5;
            ?>
";
					cell1.style.padding = '0px';
					cell1.style.margin = '0px';
					cell1.innerHTML = response_data;
					row.appendChild(cell1);
					gl_el.innerHTML = "<img class='JLMS_png' src='<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png' width='16' height='16' alt=\"done\" title=\"done\" />";
				break;
			}
		} else {
		}
	}
}
var gl_el = '';
function jlms_RequestDOCS_stats( doc_id, element ) {
	if (block_stats == 0) {
		block_stats = 1;
		gl_el = element.parentNode;
		jlms_MakeRequest('&task=get_docs_stats&doc_id='+doc_id+'&colspan=<?php 
            echo $max_tree_width + 2;
            ?>
');
		gl_el.innerHTML = "<img src='<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
' width='16' height='16' alt=\"loading\" title=\"loading\" />";
	}
}
JLMS_preloadImages('<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
', '<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png');
//--><!]]> 
</script>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="16" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="<?php 
            echo 16 * ($max_tree_width + 1);
            ?>
" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" colspan="<?php 
            echo $max_tree_width + 1;
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="45%"><?php 
            echo _JLMS_TRACK_TBL_DOC_NAME;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="100" align="center"><?php 
            echo _JLMS_TRACK_TBL_DOC_DOWNS;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="100" align="center"><?php 
            echo _JLMS_TRACK_TBL_DOC_LAST;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				</tr>
			<?php 
            $k = 1;
            $tree_modes = array();
            for ($i = 0, $n = count($lists['page12_stats']); $i < $n; $i++) {
                $row_doc = $lists['page12_stats'][$i];
                $max_tree_width = $row_doc->tree_max_width;
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td valign="middle" align="center">
					<?php 
                if ($row_doc->folder_flag != 1) {
                    ?>
						<span style="alignment:center; vertical-align:middle; cursor:pointer" onclick="jlms_RequestDOCS_stats(<?php 
                    echo $row_doc->id;
                    ?>
, this);">
							<img class='JLMS_png' src="<?php 
                    echo $JLMS_CONFIG->get('live_site');
                    ?>
/components/com_joomla_lms/lms_images/toolbar/btn_pending_cur.png" width='16' height='16' alt="<?php 
                    echo _JLMS_TRACK_VIEW_DETAILS;
                    ?>
" title="<?php 
                    echo _JLMS_TRACK_VIEW_DETAILS;
                    ?>
" />
						</span>
					<?php 
                } else {
                    echo '&nbsp;';
                }
                ?>
					</td>
					<?php 
                $add_img = '';
                if ($row_doc->tree_mode_num) {
                    $g = 0;
                    $tree_modes[$row_doc->tree_mode_num - 1] = $row_doc->tree_mode;
                    while ($g < $row_doc->tree_mode_num - 1) {
                        $pref = '';
                        if (isset($tree_modes[$g]) && $tree_modes[$g] == 2) {
                            $pref = 'empty_';
                        }
                        $add_img .= "<td width='16' valign='middle'><img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/treeview/" . $pref . "line.png\" width='16' height='16' alt='line' /></td>";
                        $g++;
                    }
                    $add_img .= "<td width='16' valign='middle'><img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/treeview/sub" . $row_doc->tree_mode . ".png\" width='16' height='16' alt='sub' /></td>";
                    $max_tree_width = $max_tree_width - $g - 1;
                }
                echo $add_img;
                ?>
					<td align="center" valign="middle" style="vertical-align:middle " width='16'>
					<?php 
                if ($row_doc->folder_flag == 1) {
                    echo "<span style='alignment:center; font-weight:bold; vertical-align:middle;'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/folder.png\" width='16' height='16' alt='Folder' /></span>";
                } else {
                    echo "<span style='alignment:center; font-weight:bold; vertical-align:middle;'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/files/" . $row_doc->file_icon . ".png\" width='16' height='16' alt='File' /></span>";
                }
                ?>
					</td>
					<td align="left" valign="middle" <?php 
                if ($max_tree_width > 0) {
                    echo "colspan='" . ($max_tree_width + 1) . "'";
                }
                ?>
 width="35%">
					<?php 
                if ($row_doc->folder_flag || !$row_doc->folder_flag && !$row_doc->file_id) {
                    echo '<strong>' . $row_doc->doc_name . '</strong>';
                } else {
                    echo $row_doc->doc_name;
                }
                ?>
					</td>
					<td valign="middle" align="center">
						<?php 
                echo $row_doc->downloads;
                ?>
					</td>
					<td valign="middle" align="center">
						<?php 
                echo JLMS_dateToDisplay($row_doc->last_access, false, $JLMS_CONFIG->get('offset') * 60 * 60, ' H:i:s');
                ?>
					</td>
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
		<?php 
        } elseif ($lists['page'] == 12 && !$page_12_stats_shown) {
            echo '<div class="joomlalms_user_message">' . _JLMS_TRACKING_NO_STATISTICS . '</div>';
        } elseif ($lists['page'] == 13 && $lists['filter_stu_val'] && isset($lists['page13_stats']) && !empty($lists['page13_stats'])) {
            $page_13_stats_shown = true;
            ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--

function submitbutton(pressbutton){
	var form = document.adminForm;
	form.view.value = pressbutton;
	form.submit();
}

var block_stats = 0;
var tID = '';
var url_prefix = '<?php 
            echo $JLMS_CONFIG->get('live_site') . "/index.php?tmpl=component&option={$option}&Itemid={$Itemid}&id={$id}";
            ?>
';
function jlms_MakeRequest(url) {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try { http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try { http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		return false;
	}
	http_request.onreadystatechange = function() { jlms_AnalizeRequest(http_request); };
	http_request.open('GET', url_prefix + url, true);
	http_request.send(null);
}
function jlms_AnalizeRequest(http_request) {
	if (http_request.readyState == 4) {
		if ((http_request.status == 200)) {
			block_stats = 0;
			if(http_request.responseXML.documentElement == null){
				try {
					http_request.responseXML.loadXML(http_request.responseText)
				} catch (e) {
					/*alert("Can't load");*/
				}
			}
			response  = http_request.responseXML.documentElement;
			var task = response.getElementsByTagName('task')[0].firstChild.data;
			switch (task) {
				case 'lpath_xml':
					var response_data = response.getElementsByTagName('stats_table')[0].firstChild.data;
					if (response_data && response_data != '' && response_data != ' ') {
						var sec_indx = gl_el.parentNode.sectionRowIndex;
						var table = gl_el.parentNode.parentNode;
						var row = table.insertRow(sec_indx + 1);
						var cell1 = document.createElement("td");
						cell1.align = 'left';
						cell1.colSpan = "3";
						cell1.style.padding = '0px';
						cell1.style.margin = '0px';
						cell1.innerHTML = response_data;
						row.appendChild(cell1);
					}
					gl_el.innerHTML = "<img class='JLMS_png' src='<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png' width='16' height='16' alt=\"done\" title=\"done\" />";
				break;
				case 'scorm_progress_xml':
					var response_data = response.getElementsByTagName('stats_table')[0].firstChild.data;
					var res_user = response.getElementsByTagName('user_id')[0].firstChild.data;
					var res_lpsc = response.getElementsByTagName('lpath_id')[0].firstChild.data;
					if (response_data && response_data != '' && response_data != ' ') {
						gl_el_res = document.getElementById('sc_progress_td_'+res_user+'_'+res_lpsc);
						if (gl_el_res) {
							gl_el_res.innerHTML = response_data;
						}
					}
				break;
			}
		} else {
		}
	}
}
var gl_el = '';
function jlms_RequestLP_stats( lp_id, element ) {
	if (block_stats == 0) {
		block_stats = 1;
		gl_el = element.parentNode;
		jlms_MakeRequest('&task=get_lp_stats&lpath_id='+lp_id);
		gl_el.innerHTML = "<img src='<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
' width='16' height='16' alt=\"loading\" title=\"loading\" />";
	}
}
function ChangeScormProgress( user_id, sc_id, new_stat, element) {
	if (block_stats == 0) {
		block_stats = 1;
		gl_el = document.getElementById('sc_progress_td_'+user_id+'_'+sc_id);
		jlms_MakeRequest('&task=get_lp_stats&mode=scormstatus&user_id='+user_id+'&nstat='+new_stat+'&lpath_id='+sc_id);
		gl_el.innerHTML = "<img src='<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
' width='16' height='16' alt=\"loading\" title=\"loading\" />";
	}
}
JLMS_preloadImages('<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
', '<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png', '<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_cancel.png');
//--><!]]> 
</script>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="16" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_LPATH_TBL_HEAD_NAME;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="1" colspan="3">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center"><?php 
            echo _JLMS_LPATH_TBL_TIME_SPENT;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center"><?php 
            echo _JLMS_LPATH_TBL_STARTING;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center"><?php 
            echo _JLMS_LPATH_TBL_ENDING;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				</tr>
			<?php 
            $k = 1;
            for ($i = 0, $n = count($lists['page13_stats']); $i < $n; $i++) {
                $row_path = $lists['page13_stats'][$i];
                $icon_img = "toolbar/tlb_lpath";
                $icon_alt = "learnpath";
                if ($row_path->item_id) {
                    $icon_img = "toolbar/tlb_scorm";
                    $icon_alt = "scorm";
                }
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td valign="middle" align="center">
						&nbsp;
					</td>
					<td valign="middle" align="left">
						<?php 
                if ($lists['f_lpath']) {
                    echo JLMS_tracking_html::Echo_userinfo($row_path->u_name, $row_path->username, $row_path->email, 'javascript:void(0);');
                } else {
                    echo $row_path->lpath_name;
                }
                ?>
					</td>
					<?php 
                if ($lists['f_lpath']) {
                    ?>
						<td width="1%" style="white-space: nowrap;"><?php 
                    echo JLMS_getLpathProgress($row_path, $row_path->user_id ? $row_path->user_id : 0);
                    ?>
</td>
					<?php 
                } else {
                    ?>
						<td width="1%" style="white-space: nowrap;"><?php 
                    echo JLMS_getLpathProgress($row_path, $lists['filter_stu_val']);
                    ?>
</td>
					<?php 
                }
                ?>
				<?php 
                $r_img = 'btn_cancel';
                $r_sta = _JLMS_LPATH_STU_LPSTATUS_NOTCOMPLETED;
                $time_spent = $row_path->time_spent;
                $r_start = '-';
                $r_end = '-';
                $new_s_status = '1';
                if (!$row_path->item_id) {
                    if (isset($row_path->r_status) && $row_path->r_status == 1) {
                        $r_img = 'btn_accept';
                        $r_sta = _JLMS_LPATH_STU_LPSTATUS_COMPLETED;
                        $r_start = isset($row_path->r_start) && $row_path->r_start ? JLMS_dateToDisplay($row_path->r_start, false, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                        $r_end = isset($row_path->r_start) && $row_path->r_start ? JLMS_dateToDisplay($row_path->r_end, false, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                    } elseif (isset($row_path->r_status) && $row_path->r_status == 0) {
                        $r_img = 'btn_pending_cur';
                        $r_start = isset($row_path->r_start) && $row_path->r_start ? JLMS_dateToDisplay($row_path->r_start, false, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                    }
                } else {
                    if (isset($row_path->s_status) && $row_path->s_status == 1) {
                        $r_img = 'btn_accept';
                        $r_sta = _JLMS_LPATH_STU_LPSTATUS_COMPLETED;
                        $r_start = '-';
                        $r_end = '-';
                        $new_s_status = '0';
                    }
                    if ($row_path->lp_type == 1 || $row_path->lp_type == 2) {
                        $r_end = isset($row_path->r_end) && $row_path->r_end ? JLMS_dateToDisplay($row_path->r_end, true, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                        $r_start = isset($row_path->r_start) && $row_path->r_start ? JLMS_dateToDisplay($row_path->r_start, true, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                    }
                }
                ?>
					<?php 
                if ($row_path->item_id) {
                    ?>
					<td valign="middle" align="center" width="16" id="sc_progress_td_<?php 
                    echo $lists['filter_stu_val'] . "_" . $row_path->item_id;
                    ?>
">
						<a class="jlms_img_link" id="sc_progress_a_<?php 
                    echo $lists['filter_stu_val'] . "_" . $row_path->item_id;
                    ?>
" href="javascript:ChangeScormProgress(<?php 
                    echo $lists['filter_stu_val'];
                    ?>
,<?php 
                    echo $row_path->item_id;
                    ?>
,<?php 
                    echo $new_s_status;
                    ?>
,this);"><img id="sc_progress_img_<?php 
                    echo $lists['filter_stu_val'] . "_" . $row_path->item_id;
                    ?>
" align="absmiddle" class="JLMS_png" src="<?php 
                    echo $JLMS_CONFIG->get('live_site');
                    ?>
/components/com_joomla_lms/lms_images/toolbar/<?php 
                    echo $r_img;
                    ?>
.png" width="16" height="16" border="0" alt="<?php 
                    echo $r_sta;
                    ?>
" title="<?php 
                    echo $r_sta;
                    ?>
" /></a>
					<?php 
                } else {
                    ?>
					<td valign="middle" align="center" width="16">
						<img class='JLMS_png' src='<?php 
                    echo $JLMS_CONFIG->get('live_site');
                    ?>
/components/com_joomla_lms/lms_images/toolbar/<?php 
                    echo $r_img;
                    ?>
.png' width='16' height='16' alt="<?php 
                    echo $r_sta;
                    ?>
" title="<?php 
                    echo $r_sta;
                    ?>
" />
					<?php 
                }
                ?>
					</td>
					<td valign="middle" align="center" nowrap="nowrap">
						<?php 
                echo $row_path->item_id ? isset($row_path->s_score) ? $row_path->s_score . _JLMS_GB_POINTS : '&nbsp;' : '&nbsp;';
                ?>
					</td>
					<td valign="middle" align="center" nowrap="nowrap"><?php 
                echo $time_spent;
                ?>
</td>
					<td valign="middle" align="center" nowrap="nowrap"><?php 
                echo $r_start;
                ?>
</td>
					<td valign="middle" align="center" nowrap="nowrap"><?php 
                echo $r_end;
                ?>
</td>
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
			<table width="100%" cellpadding="0" cellspacing="0" class="jlms_table_no_borders">
				<tr>
					<td align="center">
						<?php 
            $controls = array();
            $controls[] = array('href' => "javascript:submitbutton('csv');", 'title' => 'CSV', 'img' => 'csv');
            $controls[] = array('href' => "javascript:submitbutton('xls');", 'title' => 'XLS', 'img' => 'xls');
            JLMS_TMPL::ShowControlsFooterC($controls, '', false, false, _JLMS_EXPORT_TO . ':');
            ?>
	
					</td>
				</tr>
			</table>
		<?php 
        } elseif ($lists['page'] == 13 && !$lists['filter_stu_val'] && isset($lists['page13_stats']) && !empty($lists['page13_stats'])) {
            $page_13_stats_shown = true;
            ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
var block_stats = 0;
var tID = '';
var url_prefix = '<?php 
            echo $JLMS_CONFIG->get('live_site') . "/index.php?tmpl=component&option={$option}&Itemid={$Itemid}&id={$id}";
            ?>
';
function jlms_MakeRequest(url) {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try { http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try { http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		return false;
	}
	http_request.onreadystatechange = function() { jlms_AnalizeRequest(http_request); };
	http_request.open('GET', url_prefix + url, true);
	http_request.send(null);
}
function jlms_AnalizeRequest(http_request) {
	if (http_request.readyState == 4) {
		if ((http_request.status == 200)) {
			block_stats = 0;
			if(http_request.responseXML.documentElement == null){
				try {
					http_request.responseXML.loadXML(http_request.responseText)
				} catch (e) {
					/*alert("Can't load");*/
				}
			}
			response  = http_request.responseXML.documentElement;
			var task = response.getElementsByTagName('task')[0].firstChild.data;
			switch (task) {
				case 'lpath_xml':
					var response_data = response.getElementsByTagName('stats_table')[0].firstChild.data;
					if (response_data && response_data != '' && response_data != ' ') {
						var sec_indx = gl_el.parentNode.sectionRowIndex;
						var table = gl_el.parentNode.parentNode;
						var row = table.insertRow(sec_indx + 1);
						var cell1 = document.createElement("td");
						cell1.align = 'left';
						cell1.colSpan = "3";
						cell1.style.padding = '0px';
						cell1.style.margin = '0px';
						cell1.innerHTML = response_data;
						row.appendChild(cell1);
					}
					gl_el.innerHTML = "<img class='JLMS_png' src='<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png' width='16' height='16' alt=\"done\" title=\"done\" />";
				break;
				case 'scorm_progress_xml':
					var response_data = response.getElementsByTagName('stats_table')[0].firstChild.data;
					var res_user = response.getElementsByTagName('user_id')[0].firstChild.data;
					var res_lpsc = response.getElementsByTagName('lpath_id')[0].firstChild.data;
					if (response_data && response_data != '' && response_data != ' ') {
						gl_el_res = document.getElementById('sc_progress_td_'+res_user+'_'+res_lpsc);
						if (gl_el_res) {
							gl_el_res.innerHTML = response_data;
						}
					}
				break;
			}
		} else {
		}
	}
}
var gl_el = '';
function jlms_RequestLP_stats( lp_id, element ) {
	if (block_stats == 0) {
		block_stats = 1;
		gl_el = element.parentNode;
		jlms_MakeRequest('&task=get_lp_stats&lpath_id='+lp_id);
		gl_el.innerHTML = "<img src='<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
' width='16' height='16' alt=\"loading\" title=\"loading\" />";
	}
}
function ChangeScormProgress( user_id, sc_id, new_stat, element) {
	if (block_stats == 0) {
		block_stats = 1;
		gl_el = document.getElementById('sc_progress_td_'+user_id+'_'+sc_id);
		jlms_MakeRequest('&task=get_lp_stats&mode=scormstatus&user_id='+user_id+'&nstat='+new_stat+'&lpath_id='+sc_id);
		gl_el.innerHTML = "<img src='<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
' width='16' height='16' alt=\"loading\" title=\"loading\" />";
	}
}
JLMS_preloadImages('<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
', '<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png');
//--><!]]> 
</script>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="16" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="16" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="100%"><?php 
            echo _JLMS_LPATH_TBL_HEAD_NAME;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				</tr>
			<?php 
            $k = 1;
            for ($i = 0, $n = count($lists['page13_stats']); $i < $n; $i++) {
                $row_path = $lists['page13_stats'][$i];
                $icon_img = "toolbar/tlb_lpath";
                $icon_alt = "learnpath";
                if ($row_path->item_id) {
                    $icon_img = "toolbar/tlb_scorm";
                    $icon_alt = "scorm";
                }
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td valign="middle" align="center">
					<?php 
                if (!isset($row_path->is_link)) {
                    ?>
						<span style="alignment:center; vertical-align:middle; cursor:pointer" onclick="jlms_RequestLP_stats(<?php 
                    echo $row_path->id;
                    ?>
, this);">
							<img class='JLMS_png' src="<?php 
                    echo $JLMS_CONFIG->get('live_site');
                    ?>
/components/com_joomla_lms/lms_images/toolbar/btn_pending_cur.png" width='16' height='16' alt="<?php 
                    echo _JLMS_TRACK_VIEW_DETAILS;
                    ?>
" title="<?php 
                    echo _JLMS_TRACK_VIEW_DETAILS;
                    ?>
" />
						</span>	
					<?php 
                }
                ?>
	
					</td>
					<td valign="middle" align="center">
						<span style="alignment:center; vertical-align:middle">
							<img class='JLMS_png' src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/<?php 
                echo $icon_img;
                ?>
.png" width='16' height='16' alt="<?php 
                echo $icon_alt;
                ?>
" />
						</span>
					</td>
					<td valign="middle" align="left">
						<?php 
                echo $row_path->lpath_name;
                ?>
					</td>
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
		<?php 
        } elseif ($lists['page'] == 13 && !$page_13_stats_shown) {
            echo '<div class="joomlalms_user_message">' . _JLMS_TRACKING_NO_STATISTICS . '</div>';
        } elseif ($lists['page'] == 5 && $lists['filter_stu_val'] && isset($lists['page5_stats'])) {
            ?>
			<br /><br />
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="20" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">#</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="30%"><?php 
            echo _JLMS_HW_TBL_HEAD_HW;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_HW_TBL_HEAD_DATE;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_HW_TBL_HEAD_ENDDATE;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="1">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				</tr>
			<?php 
            $k = 1;
            for ($i = 0, $n = count($lists['page5_stats']); $i < $n; $i++) {
                $row_hw = $lists['page5_stats'][$i];
                $alt = $row_hw->hw_status ? _JLMS_HW_STATUS_COMPLETED : _JLMS_HW_STATUS_INCOMPLETED;
                $image = $row_hw->hw_status ? 'btn_accept.png' : 'btn_cancel.png';
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td align="center"><?php 
                echo $i + 1;
                ?>
</td>
					<td align="left" valign="middle" style="vertical-align:middle ">
						<?php 
                echo $row_hw->hw_name;
                ?>
					</td>
					<td valign="middle" style="vertical-align:middle ">
						<?php 
                echo $row_hw->post_date;
                ?>
					</td>
					<td valign="middle" style="vertical-align:middle ">
						<?php 
                echo $row_hw->end_date;
                ?>
					</td>
					<td align="left" valign="middle" style="vertical-align:middle; text-align:left; white-space:nowrap " nowrap="nowrap">
						<?php 
                echo '<img align="absmiddle" class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . $image . '" width="16" height="16" border="0" alt="' . $alt . '" />';
                if ($row_hw->hw_status) {
                    echo '&nbsp;&nbsp;' . JLMS_dateToDisplay($row_hw->hw_date, false, $JLMS_CONFIG->get('offset') * 60 * 60, ' H:i:s');
                }
                ?>
					</td>
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
		<?php 
        } elseif ($lists['page'] == 11 && $lists['filter_stu_val'] && isset($lists['page11_stats']) && !empty($lists['page11_stats'])) {
            ?>
			<br /><br />
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="16" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_LPATH_TBL_HEAD_NAME;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="1" colspan="2">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					
				</tr>
			<?php 
            $k = 1;
            for ($i = 0, $n = count($lists['page11_stats']); $i < $n; $i++) {
                $row_path = $lists['page11_stats'][$i];
                $icon_img = "toolbar/tlb_lpath";
                $icon_alt = "learnpath";
                if ($row_path->c_id) {
                    $icon_img = "toolbar/tlb_scorm";
                    $icon_alt = "scorm";
                }
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td valign="middle" align="center">
						<span style="alignment:center; vertical-align:middle">
							<img class='JLMS_png' src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/<?php 
                echo $icon_img;
                ?>
.png" width='16' height='16' alt="<?php 
                echo $icon_alt;
                ?>
" />
						</span>
					</td>
					<td valign="middle" align="left">
							<?php 
                echo $row_path->c_title;
                ?>
					</td>
					
				<?php 
                $r_img = 'btn_cancel';
                $r_sta = _JLMS_LPATH_STU_LPSTATUS_NOTCOMPLETED;
                $r_start = '-';
                $r_end = '-';
                if (!$row_path->c_id) {
                    if (isset($row_path->published) && $row_path->published == 1) {
                        $r_img = 'btn_accept';
                        $r_sta = _JLMS_LPATH_STU_LPSTATUS_COMPLETED;
                        $r_start = $row_path->r_start ? JLMS_dateToDisplay($row_path->r_start, false, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                        $r_end = $row_path->r_start ? JLMS_dateToDisplay($row_path->r_end, false, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                    } elseif (isset($row_path->published) && $row_path->published == 0) {
                        $r_img = 'btn_pending_cur';
                        $r_start = $row_path->r_start ? JLMS_dateToDisplay($row_path->r_start, false, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s') : '-';
                    }
                } else {
                    if (isset($row_path->published) && $row_path->published == 1) {
                        $r_img = 'btn_accept';
                        $r_sta = _JLMS_LPATH_STU_LPSTATUS_COMPLETED;
                        $r_start = '-';
                        $r_end = '-';
                    }
                }
                ?>
					<td valign="middle" align="center">
					<a style="border:0px;" href="<?php 
                echo sefRelToAbs("index.php?option=" . $option . "&task=quizzes&id=" . $id . "&page=reports&quiz_id=" . $row_path->c_id . "");
                ?>
"><img class='JLMS_png' src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/toolbar/btn_pending_cur.png" width='16' height='16' alt="<?php 
                echo 'Report';
                ?>
" title="<?php 
                echo 'Report';
                ?>
" border="0" /></a>
					</td>
					<td valign="middle" align="center" width="16">
						<img class='JLMS_png' src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/toolbar/<?php 
                echo $r_img;
                ?>
.png" width='16' height='16' alt="<?php 
                echo $r_sta;
                ?>
" title="<?php 
                echo $r_sta;
                ?>
" />
					</td>
					<td valign="middle" align="center" nowrap="nowrap">
						<?php 
                echo $row_path->c_id ? isset($row_path->s_score) ? $row_path->s_score . _JLMS_GB_POINTS : '&nbsp;' : '&nbsp;';
                ?>
					</td>
					
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
		<?php 
        } elseif ($lists['page'] == 11 && !$lists['filter_stu_val'] && isset($lists['page11_stats']) && !empty($lists['page11_stats'])) {
            ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
var block_stats = 0;
var tID = '';
var url_prefix = '<?php 
            echo $JLMS_CONFIG->get('live_site') . "/index.php?tmpl=component&option={$option}&Itemid={$Itemid}&id={$id}";
            ?>
';
function jlms_MakeRequest(url) {
	var http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try { http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try { http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!http_request) {
		return false;
	}
	http_request.onreadystatechange = function() { jlms_AnalizeRequest(http_request); };
	http_request.open('GET', url_prefix + url, true);
	http_request.send(null);
}
function jlms_AnalizeRequest(http_request) {
	if (http_request.readyState == 4) {
		if ((http_request.status == 200)) {
			block_stats = 0;
			if(http_request.responseXML.documentElement == null){
				try {
					http_request.responseXML.loadXML(http_request.responseText)
				} catch (e) {
					/*alert("Can't load");*/
				}
			}
			response  = http_request.responseXML.documentElement;
			var task = response.getElementsByTagName('task')[0].firstChild.data;
			switch (task) {
				case 'lpath_xml':
					var response_data = response.getElementsByTagName('stats_table')[0].firstChild.data;
					if (response_data && response_data != '' && response_data != ' ') {
						var sec_indx = gl_el.parentNode.sectionRowIndex;
						var table = gl_el.parentNode.parentNode;
						var row = table.insertRow(sec_indx + 1);
						var cell1 = document.createElement("td");
						cell1.align = 'left';
						cell1.colSpan = "4";
						cell1.style.padding = '0px';
						cell1.style.margin = '0px';
						cell1.innerHTML = response_data;
						row.appendChild(cell1);
					}
					gl_el.innerHTML = "<img class='JLMS_png' src='<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png' width='16' height='16' alt=\"done\" title=\"done\" />";
				break;
				case 'scorm_progress_xml':
					var response_data = response.getElementsByTagName('stats_table')[0].firstChild.data;
					var res_user = response.getElementsByTagName('user_id')[0].firstChild.data;
					var res_lpsc = response.getElementsByTagName('quiz_id')[0].firstChild.data;
					if (response_data && response_data != '' && response_data != ' ') {
						gl_el_res = document.getElementById('quizid_'+res_lpsc);
						if (gl_el_res) {
							gl_el_res.innerHTML = response_data;
						}
					}
				break;
			}
		} else {
		}
	}
}
var gl_el = '';
function jlms_RequestQuiz_stats( lp_id, element ) {
	if (block_stats == 0) {
		block_stats = 1;
		gl_el = element.parentNode;
		jlms_MakeRequest('&task=get_quiz_stats&quiz_id='+lp_id);
		gl_el.innerHTML = "<img src='<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
' width='16' height='16' alt=\"loading\" title=\"loading\" />";
	}
}

JLMS_preloadImages('<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
', '<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_accept.png', 'components/com_joomla_lms/lms_images/toolbar/btn_cancel.png');
//--><!]]> 
</script>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="16" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="16" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" ><?php 
            echo _JLMS_LPATH_TBL_HEAD_NAME;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
				</tr>
			<?php 
            $k = 1;
            for ($i = 0, $n = count($lists['page11_stats']); $i < $n; $i++) {
                $row_path = $lists['page11_stats'][$i];
                $icon_img = "toolbar/tlb_lpath";
                $icon_alt = "learnpath";
                if ($row_path->c_id) {
                    $icon_img = "toolbar/tlb_quiz";
                    $icon_alt = "scorm";
                }
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td valign="middle" align="center">
						<span style="alignment:center; vertical-align:middle; cursor:pointer" onclick="jlms_RequestQuiz_stats(<?php 
                echo $row_path->c_id;
                ?>
, this);">
							<img class='JLMS_png' src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/toolbar/btn_pending_cur.png" width='16' height='16' alt="<?php 
                echo _JLMS_TRACK_VIEW_DETAILS;
                ?>
" title="<?php 
                echo _JLMS_TRACK_VIEW_DETAILS;
                ?>
" />
						</span>	
					</td>
					<td valign="middle" align="center">
						<span style="alignment:center; vertical-align:middle">
							<img class='JLMS_png' src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/<?php 
                echo $icon_img;
                ?>
.png" width='16' height='16' alt="<?php 
                echo $icon_alt;
                ?>
" />
						</span>
					</td>
					<td valign="middle" align="left">
						<?php 
                echo $row_path->c_title;
                ?>
					</td>
					<td valign="middle" align="center">
					<a class="jlms_img_link" style="border:0px;" href="<?php 
                echo sefRelToAbs("index.php?option=" . $option . "&task=quizzes&id=" . $id . "&page=reports&quiz_id=" . $row_path->c_id . "");
                ?>
"><img class='JLMS_png' src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/toolbar/btn_pending_cur.png" width='16' height='16' alt="<?php 
                echo 'Report';
                ?>
" title="<?php 
                echo 'Report';
                ?>
" border="0" /></a>
					</td>
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
		<?php 
        }
        ?>
			<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
			<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
			<input type="hidden" name="task" value="tracking" />
			<input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
			
			<input type="hidden" name="page" value="<?php 
        echo $lists['page'];
        ?>
" />
			<input type="hidden" name="view" value="" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        JLMS_TMPL::CloseMT();
    }
Пример #17
0
function JLMS_show_course_forum($id, $option)
{
    /*
    board_type = 1 - Public/Group course board
    board_type = 2 - LearningPath public course board
    board_type = 3 - Board for users from 'Global group'
    board_type = 4 - Private (teachers-only) boards
    board_type = 5 - Private (teachers-only) LearningPath boards
    */
    global $my, $JLMS_DB, $Itemid, $JLMS_CONFIG;
    $doc =& JFactory::getDocument();
    $usertype = JLMS_GetUserType($my->id, $id);
    if (!$usertype) {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=details_course&id={$id}"));
    }
    $JLMS_ACL =& JLMSFactory::getACL();
    $forum =& JLMS_SMF::getInstance();
    if (!$forum) {
        return false;
    }
    $id_cat = 0;
    $course_name = '';
    $owner_name = '';
    $private_forums_tobe_created = array();
    // list of private forums to be created
    $msg = '';
    //error message - prompt to login if not blank
    $query = "SELECT * FROM #__lms_forums WHERE published = 1";
    $JLMS_DB->setQuery($query);
    $lms_forum_types = $JLMS_DB->loadObjectList('id');
    //[TODO] - check all types of the forums and create/remove necessary forum boards in the SMF - i.e. if they wasn't be created/removed previously
    // Note, autocreation is necessary only for 'global groups' forums and private forums (`access` is 1)
    $give_course_forums = array();
    $need_to_create = false;
    $need_to_update = false;
    if (count($lms_forum_types)) {
        // check all forum types for access.
        $allowed_forum_types = array();
        // allowed forum types
        $lms_forum_types_ids = array();
        foreach ($lms_forum_types as $lft) {
            $do_proceeed = true;
            // firstly - check `access` and `permissions`
            switch (intval($lft->forum_access)) {
                case 0:
                    // any user
                    break;
                case 1:
                    // check user role
                    if ($lft->forum_permissions) {
                        $allowed_roles = explode(',', $lft->forum_permissions);
                        if ($JLMS_ACL->GetRole() && in_array($JLMS_ACL->GetRole(), $allowed_roles)) {
                            // allow access
                        } else {
                            // restrict access if this forum is not permissioned.
                            $do_proceeed = false;
                        }
                    } else {
                        // if this is a restricted area but there is no roles configured
                        $do_proceeed = false;
                    }
                    break;
            }
            if (!$do_proceeed) {
                continue;
            }
            // secondly - check `user_level` permissions
            switch (intval($lft->user_level)) {
                case 0:
                    // any user
                    break;
                case 1:
                    // local usergroup forum
                // local usergroup forum
                case 2:
                    // global usergroup forum
                    if ($lft->user_level == 1 && $JLMS_CONFIG->get('use_global_groups', 1)) {
                        $do_proceeed = false;
                        // restrict access to the local-group forum, if we are in the global mode
                    } elseif ($lft->user_level == 2 && !$JLMS_CONFIG->get('use_global_groups', 1)) {
                        $do_proceeed = false;
                        // restrict access to the global-group forum, if we are in the local mode
                    }
                    break;
            }
            if (!$do_proceeed) {
                continue;
            }
            $allowed_forum_types[$lft->id] = $lft;
            // we have a list of allowed forum types here.
            $lms_forum_types_ids[] = $lft->id;
        }
        if (count($lms_forum_types_ids)) {
            $query = "SELECT id, course_id, board_type, group_id, ID_GROUP AS id_group, ID_CAT AS id_cat, ID_BOARD AS id_board, is_active, need_update FROM #__lms_forum_details" . "\n WHERE course_id = {$id}" . "\n AND board_type IN (" . implode(',', $lms_forum_types_ids) . ")";
            $JLMS_DB->setQuery($query);
            $active_course_forums = $JLMS_DB->loadObjectList();
            for ($i = 0; $i < count($active_course_forums); $i++) {
                $active_course_forums[$i]->forum_level = $lms_forum_types[$active_course_forums[$i]->board_type]->forum_level;
                $active_course_forums[$i]->user_level = $lms_forum_types[$active_course_forums[$i]->board_type]->user_level;
                $active_course_forums[$i]->forum_access = $lms_forum_types[$active_course_forums[$i]->board_type]->forum_access;
                $active_course_forums[$i]->forum_permissions = $lms_forum_types[$active_course_forums[$i]->board_type]->forum_permissions;
                $active_course_forums[$i]->parent_forum = $lms_forum_types[$active_course_forums[$i]->board_type]->parent_forum;
                $active_course_forums[$i]->forum_moderators = $lms_forum_types[$active_course_forums[$i]->board_type]->forum_moderators;
                $active_course_forums[$i]->forum_name = $lms_forum_types[$active_course_forums[$i]->board_type]->forum_name;
                $active_course_forums[$i]->forum_desc = $lms_forum_types[$active_course_forums[$i]->board_type]->forum_desc;
                $active_course_forums[$i]->moderated = $lms_forum_types[$active_course_forums[$i]->board_type]->moderated;
                // !!!! ATTENTION, `need_update` field was moved to the `lms_forum_details` table //$active_course_forums[$i]->need_update = $lms_forum_types[$active_course_forums[$i]->board_type]->need_update;
            }
            // [TODO] - inspect each forum type and populate list of necessary forums (to be created or already created)
            $give_course_forums = array();
            foreach ($allowed_forum_types as $aft) {
                switch (intval($aft->forum_level)) {
                    case 0:
                        switch (intval($aft->user_level)) {
                            case 0:
                                //one forum should be created for course.
                                $forum->populateCourseForums($id, $give_course_forums, $active_course_forums, $aft);
                                break;
                            case 1:
                                $forum->populateLgroupForums($id, $give_course_forums, $active_course_forums, $aft);
                                break;
                            case 2:
                                $forum->populateGgroupForums($id, $give_course_forums, $active_course_forums, $aft);
                                break;
                        }
                        break;
                    case 1:
                        if (intval($aft->user_level) == 0) {
                            $forum->populateLpathForums($id, $give_course_forums, $active_course_forums, $aft);
                        } else {
                            //ignore any other forums - currently there is no posibility to have such difficult structure
                        }
                        break;
                }
            }
            if (count($give_course_forums)) {
                $need_to_create = false;
                for ($i = 0; $i < count($give_course_forums); $i++) {
                    if ($give_course_forums[$i]->id == 0) {
                        $need_to_create = true;
                    }
                    if (isset($give_course_forums[$i]->need_update) && $give_course_forums[$i]->need_update) {
                        $need_to_update = true;
                    }
                    if ($need_to_create && $need_to_update) {
                        break;
                    }
                }
            }
        }
    }
    $was_created = array();
    $was_updated = array();
    $newcat_wascreated = false;
    if (count($give_course_forums)) {
        //echo '<pre>';var_dump($give_course_forums);die;
        if ($need_to_create || $need_to_update) {
            $query = "SELECT a.course_name, a.owner_id, b.username as owner_name FROM #__lms_courses as a LEFT JOIN #__users as b ON a.owner_id = b.id WHERE a.id = {$id}";
            $JLMS_DB->setQuery($query);
            $course_info = $JLMS_DB->loadObject();
            if (is_object($course_info)) {
                $course_name = $course_info->course_name;
                // - we need it to create boards
                $owner_name = $course_info->owner_name;
            }
        }
        $query = "SELECT ID_CAT AS id_cat FROM #__lms_forum_details WHERE course_id = {$id} LIMIT 0,1";
        $JLMS_DB->setQuery($query);
        $id_cat = $JLMS_DB->loadResult();
        // ID of the Course CATEGORY (in which all course boards are placed) - we need it to create boards
        // TODO:
        // check if SMF boards was removed and create new ones if necessary!
        $query = "SELECT distinct ID_GROUP AS id_group FROM `#__lms_forum_details` ";
        $JLMS_DB->setQuery($query);
        $all_lms_groups = $JLMS_DB->loadResultArray();
        $all_moderator_ids = array();
        $all_moderators = array();
        for ($i = 0; $i < count($give_course_forums); $i++) {
            if (($need_to_create && $give_course_forums[$i]->id == 0 || $give_course_forums[$i]->need_update) && $give_course_forums[$i]->forum_moderators) {
                $new_moderators = explode(',', $give_course_forums[$i]->forum_moderators);
                $all_moderator_ids = array_merge($all_moderator_ids, $new_moderators);
            }
        }
        if (count($all_moderator_ids)) {
            for ($i = 0; $i < count($all_moderator_ids); $i++) {
                $all_moderator_ids[$i] = intval($all_moderator_ids[$i]);
            }
            $all_moderator_ids = array_unique($all_moderator_ids);
            if (!empty($all_moderator_ids)) {
                $all_moderator_ids_str = implode(',', $all_moderator_ids);
                $query = "SELECT id, username FROM #__users WHERE id IN ({$all_moderator_ids_str})";
                $JLMS_DB->setQuery($query);
                $all_moderators = $JLMS_DB->LoadObjectList('id');
            }
        }
        if (!$id_cat) {
            // CATEGORY for this course doesn't exists - we need to create new one
            $storeData = array();
            $storeData['name'] = $course_name;
            $storeData['can_collapse'] = 1;
            $id_cat = $forum->storeCategory($storeData);
            $newcat_wascreated = true;
            // TODO:
            // if instead CAT_ID #__forum_details was populated with 0 - we need to update #__forum_details table and boards in SMF db
            // all updates to Joola db are 100 - 150 lines below
        }
        $user_exists = false;
        $is_forum_category = 0;
        $boardurl = $forum->getBoardURL();
        $link = $boardurl . '/index.php#' . $id_cat;
        $smf_user_details = $forum->loadMemberByName($my->username);
        if ($smf_user_details) {
            $user_exists = true;
            $all_current_smf_groups = array();
            // create all parent forums
            for ($i = 0; $i < count($give_course_forums); $i++) {
                if ($need_to_create && $give_course_forums[$i]->id == 0 && !$give_course_forums[$i]->parent_forum) {
                    if ($give_course_forums[$i]->forum_level == 1 && $give_course_forums[$i]->user_level == 0 || $give_course_forums[$i]->forum_level == 0 && $give_course_forums[$i]->user_level == 2 || $give_course_forums[$i]->forum_level == 0 && $give_course_forums[$i]->user_level == 0) {
                        $tmp = $forum->create($give_course_forums, $i, $course_name, $owner_name, $all_moderators, $id_cat);
                        $was_created[] = $tmp;
                        $all_current_smf_groups[] = $tmp->id_group;
                    }
                } elseif ($give_course_forums[$i]->id && $give_course_forums[$i]->need_update && !$give_course_forums[$i]->parent_forum) {
                    $tmp = $forum->update($give_course_forums, $i, $course_name, $owner_name, $all_moderators, $id_cat);
                    $was_updated[] = $tmp;
                    $all_current_smf_groups[] = $give_course_forums[$i]->id_group;
                } elseif ($give_course_forums[$i]->id && !$give_course_forums[$i]->need_update) {
                    $all_current_smf_groups[] = $give_course_forums[$i]->id_group;
                }
            }
            //crate all nested forums
            for ($i = 0; $i < count($give_course_forums); $i++) {
                if ($need_to_create && $give_course_forums[$i]->id == 0 && $give_course_forums[$i]->parent_forum) {
                    if ($give_course_forums[$i]->forum_level == 1 && $give_course_forums[$i]->user_level == 0 || $give_course_forums[$i]->forum_level == 0 && $give_course_forums[$i]->user_level == 2 || $give_course_forums[$i]->forum_level == 0 && $give_course_forums[$i]->user_level == 0) {
                        $tmp = $forum->create($give_course_forums, $i, $course_name, $owner_name, $all_moderators, $id_cat);
                        $was_created[] = $tmp;
                        $all_current_smf_groups[] = $tmp->id_group;
                    }
                } elseif ($give_course_forums[$i]->id && $give_course_forums[$i]->need_update && $give_course_forums[$i]->parent_forum) {
                    $tmp = $forum->update($give_course_forums, $i, $course_name, $owner_name, $all_moderators, $id_cat);
                    $was_updated[] = $tmp;
                    $all_current_smf_groups[] = $give_course_forums[$i]->id_group;
                }
            }
            $mem_id = $smf_user_details->id_member;
            $mem_real_name = $smf_user_details->real_name;
            $primary_group = $smf_user_details->id_group;
            $old_groups = explode(',', $smf_user_details->additional_groups);
            $old_groups_save = array();
            foreach ($old_groups as $group) {
                if (!in_array($group, $all_lms_groups)) {
                    $old_groups_save[] = $group;
                }
            }
            $forum_groups = array_unique(array_merge($all_current_smf_groups, $old_groups_save));
            $new_forum_groups = array();
            foreach ($forum_groups as $fg) {
                if ($fg) {
                    $new_forum_groups[] = $fg;
                }
            }
            $groups = implode(',', $new_forum_groups);
            if (!$mem_real_name && isset($my->name) && $my->name) {
                // update real_name of user, if it is missed
                $storeData = array();
                $storeData['id_member'] = $mem_id;
                $storeData['id_group'] = $primary_group;
                $storeData['additional_groups'] = $groups;
                $storeData['real_name'] = $my->name;
            } else {
                $storeData = array();
                $storeData['id_member'] = $mem_id;
                $storeData['id_group'] = $primary_group;
                $storeData['additional_groups'] = $groups;
            }
            $forum->storeMember($storeData);
            if (count($give_course_forums) == 1) {
                $is_forum_category = 0;
                $link = $boardurl . '/index.php?board=' . $give_course_forums[0]->id_board . '.0';
            } elseif (count($give_course_forums) > 1) {
                $is_forum_category = 1;
                $link = $boardurl . '/index.php#' . $id_cat;
            }
            $topic_id = JRequest::getVar('topic_id', 0);
            $message_id = JRequest::getVar('message_id', 0);
            if ($topic_id && $message_id) {
                $link = $boardurl . '/index.php';
                $link .= '?topic=' . $topic_id;
                $link .= '.msg' . $message_id;
                $link .= '#msg' . $message_id;
            }
            if (true) {
                //($is_forum_category) {
                $forum_tree = $forum->selectBoards();
                $user_cats = array();
                foreach ($forum_tree as $ft) {
                    $ar = $ft->member_groups;
                    $ar = explode(',', $ar);
                    $is_cat = false;
                    foreach ($new_forum_groups as $gia) {
                        if (in_array($gia, $ar)) {
                            $is_cat = true;
                            break;
                        }
                    }
                    if ($is_cat) {
                        $user_cats[] = $ft->id_cat;
                    }
                }
                $user_cats = array_unique($user_cats);
                if (count($user_cats)) {
                    $forum->deleteCollapsedCategories($mem_id, $user_cats);
                    $new_ar = array($id_cat);
                    $rrr = array_diff($user_cats, $new_ar);
                    $forum->insertCollapsedCategories($mem_id, $rrr);
                }
            }
        }
        $mem_id_cookies = 0;
        if ($user_exists) {
            $mem_id_cookies = JLMS_checkSMF_cookies(false);
        }
        if ($need_to_create) {
            if (count($was_created)) {
                $query = "INSERT INTO #__lms_forum_details (course_id, board_type, group_id, ID_GROUP, ID_CAT, ID_BOARD, is_active) VALUES";
                $first = 1;
                foreach ($was_created as $obj) {
                    $query .= $first ? '' : ',';
                    $query .= "\n({$id}, {$obj->board_type}, {$obj->group_id}, {$obj->id_group}, {$obj->id_cat}, {$obj->id_board}, 1)";
                    $first = 0;
                }
                $JLMS_DB->setQuery($query);
                $JLMS_DB->query();
            }
        }
        if (isset($was_updated) && count($was_updated)) {
            $was_updated = array_unique($was_updated);
            if (!empty($was_updated)) {
                $was_updated_str = implode(',', $was_updated);
                $query = "UPDATE #__lms_forum_details SET need_update = 0 WHERE id IN ({$was_updated_str}) AND need_update = 1";
                $JLMS_DB->setQuery($query);
                $JLMS_DB->query();
            }
        }
        if ($user_exists) {
            if ($mem_id && $mem_id_cookies && $mem_id_cookies == $mem_id) {
                $mbname = $forum->getMbname();
                $doc->setTitle($mbname);
                //[TODO] - what is it - $mbname and $boardurl - from the Settings.php?
            } else {
                $msg = JLMS_FORUM_NOT_MEMBER;
            }
        } else {
            $msg = JLMS_FORUM_NOT_MEMBER;
        }
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=details_course&id={$id}"));
    }
    JLMS_course_forum_html::wrapper_course_forum($link, $option, $id, $msg);
    return true;
}
Пример #18
0
<?php

// no direct access
defined('_JEXEC') or die('Restricted access');
define('_JLMS_PLUGIN_TC', 'read or write comments');
$_JLMS_PLUGINS =& JLMSFactory::getPlugins();
$_JLMS_PLUGINS->registerFunction('onBelowCourseDetailsPage', 'TopicCollapsible');
$_JLMS_PLUGINS->registerFunction('onPluginAction', 'TopicCollapsible_Action');
//ALTER TABLE `jos_lms_topics` ADD `collapsible` INT NOT NULL ;
function TopicCollapsible($course_id)
{
    $db =& JFactory::getDBO();
    $user =& JFactory::getUser();
    $document =& JFactory::getDocument();
    $cookie_name = 'u' . $user->id . 'c' . $course_id . 'topics_exp';
    $cookie_value = isset($_COOKIE[$cookie_name]) ? $_COOKIE[$cookie_name] : '';
    $topics_expand = explode(',', $cookie_value);
    $tec = $topics_expand;
    $query = "SELECT *" . "\n FROM #__lms_topics_collapsible" . "\n WHERE 1" . "\n AND user_id = '" . $user->id . "'" . "\n AND course_id = '" . $course_id . "'";
    $db->setQuery($query);
    $data = $db->loadObject();
    $data->value = isset($data->value) ? $data->value : '';
    $topics_expand = explode(',', $data->value);
    $tedb = $topics_expand;
    $topics_expand = array_merge($tec, $tedb);
    setcookie($cookie_name, '');
    ob_start();
    ?>
		<style type="text/css">
			div.btn_collapse{
				display: block;
Пример #19
0
    function show_add_event($course_id, $option, &$agenda_item, $lists)
    {
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $Itemid = $JLMS_CONFIG->get('Itemid');
        $content = $title = '';
        $start_date = $end_date = date('Y-m-d');
        if ($agenda_item) {
            $content = $agenda_item->content;
            $title = $agenda_item->title;
            $start_date = $agenda_item->start_date;
            $end_date = $agenda_item->end_date;
            $is_time_related = $agenda_item->is_time_related;
            $show_period = $agenda_item->show_period;
        }
        ?>

<script language="javascript" type="text/javascript">
<!--
var start_date = '';
function setgood() {
	return true;
}
function submitbutton(task){
	elem = document.forms.adminForm;
	try {
		elem.onsubmit();
	} catch(e) {
		//alert(e);
	}
	if (task == 'save_agenda'){
		if (elem.jlms_agenda_title.value.length < 1){
			alert ('<?php 
        echo _JLMS_AGENDA_TITLE_INCORRECT;
        ?>
');
			elem.jlms_agenda_title.focus();
		}
		else {
			elem.submit();
		}
	}
	else{
		elem.mode.value = task;
		elem.submit();
	}	
}
//-->
</script>
		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}");
        ?>
" method="post" name="adminForm" onsubmit="setgood();">
		<table width="100%" cellpadding="2" cellspacing="0" border="0" id="jlms_item_properties">
			<tr>
				<td colspan="2">
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
						<tr>
							<td width="100%" valign="middle" style="vertical-align:middle " rowspan="2" class="contentheading">
								<?php 
        echo _JLMS_AGENDA_ADD_ITEM;
        ?>
							</td>
							<td align="right" valign="top" style="vertical-align:top ">
								<?php 
        $toolbar = array();
        $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton('save_agenda');");
        $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton('cancel_agenda');");
        echo JLMS_ShowToolbar($toolbar);
        ?>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td valign="middle"><br /><?php 
        echo _JLMS_START_DATE;
        ?>
</td>
				<td valign="middle" style="vertical-align:middle "><br />
					<table cellpadding="0" cellspacing="0" border="0" class="jlms_date_outer"><tr>
					<td valign="middle" style="vertical-align:middle ">
					<?php 
        echo JLMS_HTML::_('calendar.calendar', $start_date, 'start', 'start');
        ?>
					</td></tr></table>
				</td>
			</tr>
			<tr>
				<td><br /><?php 
        echo _JLMS_END_DATE;
        ?>
</td>
				<td valign="middle" style="vertical-align:middle "><br />
					<table cellpadding="0" cellspacing="0" border="0" class="jlms_date_outer"><tr>
					<td valign="middle" style="vertical-align:middle ">
					<?php 
        echo JLMS_HTML::_('calendar.calendar', $end_date, 'end', 'end');
        ?>
					</td></tr></table>
				</td>
			</tr>
			<tr>
					<td valign="top" style="vertical-align:top "><br /><?php 
        echo _JLMS_IS_TIME_RELATED;
        ?>
</td>
					<td><br />
						<?php 
        if (isset($is_time_related)) {
            JLMS_HTML::_('showperiod.field', $is_time_related, $show_period);
        } else {
            JLMS_HTML::_('showperiod.field');
        }
        ?>
					</td>
				</tr>
			<tr>
				<td colspan="2" height="20"></td>
			</tr>
			
			<tr>
				<td>
				<?php 
        echo _JLMS_LIMIT_RESOURCE_TO_GROUPS;
        ?>
				</td>
				<td>
					<?php 
        echo $lists['is_limited'];
        ?>
				</td>
			</tr>

			<tr>
				<td colspan="2" height="20"></td>
			</tr>

			<tr>
				<td valign="top">
				<?php 
        echo _JLMS_LIMIT_RESOURCE_USERGROUPS;
        ?>
				</td>
				<td>
				<?php 
        echo $lists['groups'];
        ?>
				</td>
			</tr>
			<tr>
				<td valign="top" align="left"  width="20%" colspan="2">
				<?php 
        echo _JLMS_AGENDA_TITLE;
        ?>
				</td>
			</tr>	
			<tr>	
				<td colspan="2">
				<input  type="text" name="jlms_agenda_title"  size="60" value="<?php 
        echo $title;
        ?>
"  class="inputbox" />
				</td>
			</tr>
			<tr>
				<td colspan="2">
				<?php 
        echo _JLMS_DESCRIPTION;
        ?>
				</td>
			</tr>	
			<tr>
				<td  colspan="2">
				<?php 
        echo jlms_editorArea('editor1', $content, 'jlms_agenda_detail', '100%;', '250', '40', '20');
        ?>
				</td>
			</tr>
		</table>
		<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
		<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
		<input type="hidden" name="task" value="agenda" />
		<input type="hidden" name="mode" value="event_save" />
		<?php 
        if (isset($agenda_item->agenda_id)) {
            echo "<input type='hidden' name='edit' value='yes' />";
            echo "<input type='hidden' name='agenda_id' value='" . $agenda_item->agenda_id . "' />";
        }
        ?>
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="id" value="<?php 
        echo $course_id;
        ?>
" />
		</form>
	<?php 
    }
    function addItemToLPath($lpath_id, $course_id, $option, &$my_documents, &$my_links, &$my_quizzes, &$my_scorms, &$lists, $parent)
    {
        global $Itemid, $JLMS_CONFIG;
        ?>
<script language="javascript" type="text/javascript">
<!--
function jlms_get_kol_selected(fff) {
	var kol_sel=0;
	selItem=fff['cid[]'];
	var rrr='';
	if (selItem) {
		if (selItem.length) { var i;
			for (i = 0; i<selItem.length; i++) {
				if (selItem[i].checked) { kol_sel++; }
			}
		} else if (selItem.checked) { kol_sel++; }
	}
	return kol_sel;
}
function submitbutton_doc(pressbutton) {
	var form = document.docForm;
	var kol_docs = jlms_get_kol_selected(form);
	if ( (pressbutton == 'lpath_add_doc') && (kol_docs == 0) ) {
		alert( "<?php 
        echo _JLMS_LPATH_SELECT_DOCS;
        ?>
" );
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
function submitbutton_link(pressbutton) {
	var form = document.linkForm;
	var kol_links = jlms_get_kol_selected(form);
	if ( (pressbutton == 'lpath_add_link') && (kol_links == 0) ) {
		alert( "<?php 
        echo _JLMS_LPATH_SELECT_LINKS;
        ?>
" );
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
function submitbutton_quiz(pressbutton) {
	var form = document.quizForm;
	var kol_quizzes = jlms_get_kol_selected(form);
	if ( (pressbutton == 'lpath_add_quiz') && (kol_quizzes == 0) ) {
		alert( "<?php 
        echo _JLMS_LPATH_SELECT_QUIZZES;
        ?>
" );
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
function submitbutton_scorm(pressbutton) {
	var form = document.scormForm;
	var kol_scorms = jlms_get_kol_selected(form);
	if ( (pressbutton == 'lpath_add_scorm') && (kol_scorms == 0) ) {
		alert( "<?php 
        echo _JLMS_LPATH_SELECT_SCORMS;
        ?>
" );
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}

function submitbutton_chap(pressbutton) {
	var form = document.chapForm;
	if ( (pressbutton == 'lpath_add_chapter') && (form.step_name.value == '') ) {
		alert( "<?php 
        echo _JLMS_LPATH_ENTER_CHAP_NAME;
        ?>
" );
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
function submitbutton_content(pressbutton) {
	var form = document.contentForm;
	try {
		form.onsubmit();
	} catch(e) {
		//alert(e);
	}
	if ( (pressbutton == 'lpath_add_content') && (form.step_name.value == '') ) {
		alert( "<?php 
        echo _JLMS_LPATH_ENTER_CONTENT_NAME;
        ?>
" );
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
//-->
</script>
<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        JLMS_TMPL::ShowHeader('lpath', '', $hparams);
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid);
        ?>
" method="post" name="swapParent">
			<input name="parent" type="hidden" value="<?php 
        echo $parent;
        ?>
" />
			<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
			<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
			<input type="hidden" name="task" value="add_lpath_step" />
			<input type="hidden" name="id" value="<?php 
        echo $lpath_id;
        ?>
" />
			<input type="hidden" name="lpath_id" value="<?php 
        echo $lpath_id;
        ?>
" />
			<input type="hidden" name="course_id" value="<?php 
        echo $course_id;
        ?>
" />
		</form>
	<?php 
        echo JLMSCSS::h2(_JLMS_LPATH_TITLE_ADD_ITEMS);
        $tabs = new JLMSTabs(0);
        echo $tabs->startPane("JLMS");
        echo $tabs->startTab(_JLMS_LPATH_CONTENT, "jlmstab6");
        echo JLMSCSS::h2(_JLMS_LPATH_TITLE_ADD_CONTENT);
        ?>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
		<tr>
			<td align="right">
			<?php 
        $toolbar = array();
        $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton_content('lpath_add_content');");
        $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton_content('cancel_lpath_step');");
        echo JLMS_ShowToolbar($toolbar);
        ?>
			</td>
		</tr>
	</table>
				<form action="<?php 
        echo sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid);
        ?>
" method="post" name="contentForm" onsubmit="setgood();">
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_item_properties">
						<tr>
							<td width="15%"><br /><?php 
        echo _JLMS_ENTER_NAME;
        ?>
</td>
							<td>
								<br /><input type="text" name="step_name" style="width:260px" value="" />
							</td>
						</tr>
						<tr>
							<td width="15%"><br /><?php 
        echo _JLMS_PLACE_IN;
        ?>
</td>
							<td><br /><?php 
        echo $lists['lpath_chaps1'];
        ?>
</td>
						</tr>
						<tr>
							<td><br /><?php 
        echo _JLMS_ORDERING;
        ?>
</td>
							<td colspan="2"><br /><?php 
        echo $lists['lpath_order'];
        ?>
</td>
						</tr>
						<tr>
							<td align="left" valign="top" style="vertical-align:top "><br /><?php 
        echo _JLMS_SHORT_DESCRIPTION;
        ?>
</td>
							<td colspan="2"><br /><textarea class="inputbox" name="step_shortdescription" cols="50" rows="3"></textarea></td>
						</tr>
						<tr>
							<td colspan="3" align="left" style="text-align:left "><br /><?php 
        echo _JLMS_DESCRIPTION;
        ?>
</td>
						</tr>
						<tr>
							<td colspan="3">
							<?php 
        JLMS_editorArea('editor1', '', 'step_description', '100%', '250', '40', '20');
        ?>
							</td>
						</tr>
					</table>
					<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
					<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
					<input type="hidden" name="task" value="lpath_add_content" />
					<input type="hidden" name="id" value="<?php 
        echo $lpath_id;
        ?>
" />
					<input type="hidden" name="lpath_id" value="<?php 
        echo $lpath_id;
        ?>
" />
					<input type="hidden" name="course_id" value="<?php 
        echo $course_id;
        ?>
" />
					</form>
<?php 
        echo $tabs->endTab();
        echo $tabs->startTab(_JLMS_LPATH_CHAPTER, "jlmstab5");
        echo JLMSCSS::h2(_JLMS_LPATH_TITLE_ADD_CHAP);
        ?>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
		<tr>
			<td align="right">
			<?php 
        $toolbar = array();
        $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton_chap('lpath_add_chapter');");
        $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton_chap('cancel_lpath_step');");
        echo JLMS_ShowToolbar($toolbar);
        ?>
			</td>
		</tr>
	</table>
					<form action="<?php 
        echo sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid);
        ?>
" method="post" name="chapForm">
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_item_properties">
						<tr>
							<td width="15%"><br /><?php 
        echo _JLMS_ENTER_NAME;
        ?>
</td>
							<td>
								<br /><input type="text" name="step_name" style="width:260px" value="" />
							</td>
						</tr>
						<tr>
							<td width="15%"><br /><?php 
        echo _JLMS_PLACE_IN;
        ?>
</td>
							<td><br /><?php 
        echo $lists['lpath_chaps1'];
        ?>
</td>
						</tr>
						<tr>
							<td><br /><?php 
        echo _JLMS_ORDERING;
        ?>
</td>
							<td><br /><?php 
        echo $lists['lpath_order'];
        ?>
</td>
						</tr>
					</table>
					<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
					<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
					<input type="hidden" name="task" value="lpath_add_chapter" />
					<input type="hidden" name="id" value="<?php 
        echo $lpath_id;
        ?>
" />
					<input type="hidden" name="lpath_id" value="<?php 
        echo $lpath_id;
        ?>
" />
					<input type="hidden" name="course_id" value="<?php 
        echo $course_id;
        ?>
" />
					</form>
<?php 
        echo $tabs->endTab();
        if (!empty($my_documents)) {
            echo $tabs->startTab(_JLMS_HEAD_DOCS_STR, "jlmstab1");
            echo JLMSCSS::h2(_JLMS_LPATH_TITLE_ADD_DOCS);
            ?>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
		<tr>
			<td align="right">
			<?php 
            $toolbar = array();
            $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton_doc('lpath_add_doc');");
            $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton_doc('cancel_lpath_step');");
            echo JLMS_ShowToolbar($toolbar);
            ?>
			</td>
		</tr>
	</table>
				<form action="<?php 
            echo sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid);
            ?>
" method="post" name="docForm">
					<?php 
            $max_tree_width = 0;
            $max_tree_width1 = 0;
            if (isset($my_documents[0])) {
                $max_tree_width = $my_documents[0]->tree_max_width;
            }
            $max_tree_width1 = $max_tree_width;
            ?>
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
						<tr>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">#</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="<?php 
            echo $max_tree_width + 1;
            ?>
%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" colspan="<?php 
            echo $max_tree_width + 1;
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="50%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_LPATH_TBL_HEAD_NAME_DOCS;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="<?php 
            echo 48 - ($max_tree_width + 1);
            ?>
%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><span style="display:block; width:150px"><?php 
            echo _JLMS_LPATH_TBL_HEAD_DESCR_DOCS;
            ?>
</span></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						</tr>
					<?php 
            $k = 1;
            $tree_modes = array();
            for ($i = 0, $n = count($my_documents); $i < $n; $i++) {
                $row = $my_documents[$i];
                $max_tree_width = $row->tree_max_width;
                $link = "index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=get_document&amp;course_id=" . $course_id . "&amp;id=" . $row->id;
                $checked = '<input type="checkbox" name="cid[]" value="' . $row->id . '" />';
                ?>
						<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
							<td align="center"><?php 
                echo $i + 1;
                ?>
</td>
							<td align="center" valign="middle"><?php 
                if (!$row->folder_flag || $row->folder_flag == 2 || $row->folder_flag == 3) {
                    echo $checked;
                } else {
                    echo '&nbsp;';
                }
                ?>
</td>
							<?php 
                $add_img = '';
                if ($row->tree_mode_num) {
                    $g = 0;
                    $tree_modes[$row->tree_mode_num - 1] = $row->tree_mode;
                    while ($g < $row->tree_mode_num - 1) {
                        $pref = '';
                        if (isset($tree_modes[$g]) && $tree_modes[$g] == 2) {
                            $pref = 'empty_';
                        }
                        $add_img .= "<td width='16' valign='middle'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/treeview/" . $pref . "line.png\" width='16' height='16' /></td>";
                        $g++;
                    }
                    $add_img .= "<td width='16' valign='middle'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/treeview/sub" . $row->tree_mode . ".png\" width='16' height='16' /></td>";
                    $max_tree_width = $max_tree_width - $g - 1;
                }
                echo $add_img;
                ?>
							<td align="center" valign="middle" style="vertical-align:middle " width='16'>
							<?php 
                if ($row->folder_flag == 1) {
                    echo "<span style='text-align:center; font-weight:bold; vertical-align:middle;'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/folder.png\" width='16' height='16' alt='" . _JLMS_LPATH_DOC_ALT_FOLDER . "' /></span>";
                } else {
                    echo "<span style='text-align:center;font-weight:bold; vertical-align:middle;'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/files/" . $row->file_icon . ".png\" width='16' height='16' alt='" . _JLMS_LPATH_DOC_ALT_FILE . "' /></span>";
                }
                ?>
							</td>
							<td align="left" valign="middle" <?php 
                if ($max_tree_width > 0) {
                    echo "colspan='" . ($max_tree_width + 1) . "'";
                }
                ?>
 width="35%">
							<?php 
                if ($row->folder_flag || !$row->folder_flag && !$row->file_id) {
                    echo '<strong>' . $row->doc_name . '</strong>';
                } else {
                    ?>
								<?php 
                    /*<a href="<?php echo sefRelToAbs($link);?>" title="<?php echo _JLMS_LPATH_LINK_DOC_DOWNLOAD;?>"> */
                    echo $row->doc_name;
                    /* </a> */
                }
                ?>
							</td>
							<td><?php 
                $doc_descr = trim(strip_tags($row->doc_description));
                if (strlen($doc_descr) > 75) {
                    $doc_descr = substr($doc_descr, 0, 75) . "...";
                }
                echo $doc_descr ? $doc_descr : '&nbsp;';
                ?>
							</td>
						</tr>
						<?php 
                $k = 3 - $k;
            }
            ?>
					</table>
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_item_properties">
						<tr>
							<td width="15%"><?php 
            echo _JLMS_PLACE_IN;
            ?>
</td>
							<td><?php 
            echo $lists['lpath_chaps1'];
            ?>
</td>
						</tr>
						<tr>
							<td><br /><?php 
            echo _JLMS_ORDERING;
            ?>
</td>
							<td><br /><?php 
            echo $lists['lpath_order'];
            ?>
</td>
						</tr>
					</table>
					<input type="hidden" name="option" value="<?php 
            echo $option;
            ?>
" />
					<input type="hidden" name="Itemid" value="<?php 
            echo $Itemid;
            ?>
" />
					<input type="hidden" name="task" value="lpath_add_doc" />
					<input type="hidden" name="id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="lpath_id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="course_id" value="<?php 
            echo $course_id;
            ?>
" />
					</form>
<?php 
            echo $tabs->endTab();
        }
        if (!empty($my_links)) {
            echo $tabs->startTab(_JLMS_HEAD_LINK_STR, "jlmstab2");
            echo JLMSCSS::h2(_JLMS_LPATH_TITLE_ADD_LINKS);
            ?>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
		<tr>
			<td align="right">
			<?php 
            $toolbar = array();
            $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton_link('lpath_add_link');");
            $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton_link('cancel_lpath_step');");
            echo JLMS_ShowToolbar($toolbar);
            ?>
			</td>
		</tr>
	</table>
					<form action="<?php 
            echo sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid);
            ?>
" method="post" name="linkForm">
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
						<tr>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">#</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="50%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_LPATH_TBL_HEAD_NAME_LINKS;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="48%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><span style="display:block; width:150px"><?php 
            echo _JLMS_LPATH_TBL_HEAD_DESCR_LINKS;
            ?>
</span></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						</tr>
					<?php 
            $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
            $_JLMS_PLUGINS->loadBotGroup('content');
            for ($i = 0, $n = count($my_links); $i < $n; $i++) {
                $plugin_result_array = $_JLMS_PLUGINS->trigger('onContentProcess', array(&$my_links[$i]->link_href));
                $plugin_result_array = $_JLMS_PLUGINS->trigger('onContentProcess', array(&$my_links[$i]->link_name));
            }
            $k = 1;
            for ($i = 0, $n = count($my_links); $i < $n; $i++) {
                $row = $my_links[$i];
                $link = $row->link_href;
                //'javascript:void(0);';//"index.php?option=".$option."&Itemid=".$Itemid."&task=get_file&id=".$row->file_id;
                $checked = '<input type="checkbox" name="cid[]" value="' . $row->id . '" />';
                ?>
						<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
							<td align="center"><?php 
                echo $i + 1;
                ?>
</td>
							<td><?php 
                echo $checked;
                ?>
</td>
							<td>
								<a target="_blank" href="<?php 
                echo sefRelToAbs($link);
                ?>
" title="<?php 
                echo _JLMS_LPATH_VIEW_LINK;
                ?>
">
									<?php 
                echo $row->link_name;
                ?>
								</a>
							</td>
							<td><?php 
                echo trim($row->link_description) ? $row->link_description : '&nbsp;';
                ?>
</td>
						</tr>
						<?php 
                $k = 3 - $k;
            }
            ?>
					</table>
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_item_properties">
						<tr>
							<td width="15%"><?php 
            echo _JLMS_PLACE_IN;
            ?>
</td>
							<td><?php 
            echo $lists['lpath_chaps1'];
            ?>
</td>
						</tr>
						<tr>
							<td><br /><?php 
            echo _JLMS_ORDERING;
            ?>
</td>
							<td><br /><?php 
            echo $lists['lpath_order'];
            ?>
</td>
						</tr>
					</table>
					<input type="hidden" name="option" value="<?php 
            echo $option;
            ?>
" />
					<input type="hidden" name="Itemid" value="<?php 
            echo $Itemid;
            ?>
" />
					<input type="hidden" name="task" value="lpath_add_link" />
					<input type="hidden" name="id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="lpath_id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="course_id" value="<?php 
            echo $course_id;
            ?>
" />
					</form>
<?php 
            echo $tabs->endTab();
        }
        if (!empty($my_quizzes)) {
            echo $tabs->startTab(_JLMS_HEAD_QUIZ_STR, "jlmstab3");
            echo JLMSCSS::h2(_JLMS_LPATH_TITLE_ADD_QUIZZES);
            ?>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
		<tr>
			<td align="right">
			<?php 
            $toolbar = array();
            $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton_quiz('lpath_add_quiz');");
            $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton_quiz('cancel_lpath_step');");
            echo JLMS_ShowToolbar($toolbar);
            ?>
			</td>
		</tr>
	</table>
					<form action="<?php 
            echo sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid);
            ?>
" method="post" name="quizForm">
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
						<tr>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">#</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="50%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_LPATH_TBL_HEAD_NAME_QUIZ;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="48%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><span style="display:block; width:150px"><?php 
            echo _JLMS_LPATH_TBL_HEAD_CAT_QUIZ;
            ?>
</span></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						</tr>
					<?php 
            $k = 1;
            for ($i = 0, $n = count($my_quizzes); $i < $n; $i++) {
                $row = $my_quizzes[$i];
                // (WARNING) if link will be changed, don't forgot to change target of <a> element
                $link = 'javascript:void(0);';
                //$row->link_href;//"index.php?option=".$option."&Itemid=".$Itemid."&task=get_file&id=".$row->file_id;
                $checked = '<input type="checkbox" name="cid[]" value="' . $row->c_id . '" />';
                ?>
						<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
							<td align="center"><?php 
                echo $i + 1;
                ?>
</td>
							<td><?php 
                echo $checked;
                ?>
</td>
							<td>
								<a href="<?php 
                echo sefRelToAbs($link);
                ?>
">
									<?php 
                echo $row->c_title;
                ?>
								</a>
							</td>
							<td><?php 
                echo trim($row->c_category) ? $row->c_category : '&nbsp;';
                ?>
</td>
						</tr>
						<?php 
                $k = 3 - $k;
            }
            ?>
					</table>
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_item_properties">
						<tr>
							<td width="15%"><?php 
            echo _JLMS_PLACE_IN;
            ?>
</td>
							<td><?php 
            echo $lists['lpath_chaps1'];
            ?>
</td>
						</tr>
						<tr>
							<td><br /><?php 
            echo _JLMS_ORDERING;
            ?>
</td>
							<td><br /><?php 
            echo $lists['lpath_order'];
            ?>
</td>
						</tr>
					</table>
					<input type="hidden" name="option" value="<?php 
            echo $option;
            ?>
" />
					<input type="hidden" name="Itemid" value="<?php 
            echo $Itemid;
            ?>
" />
					<input type="hidden" name="task" value="lpath_add_quiz" />
					<input type="hidden" name="id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="lpath_id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="course_id" value="<?php 
            echo $course_id;
            ?>
" />
					</form>
<?php 
            echo $tabs->endTab();
        }
        if (!empty($my_scorms)) {
            echo $tabs->startTab(_JLMS_LPATH_SCORM_OBJECTS, "jlmstab4");
            echo JLMSCSS::h2(_JLMS_LPATH_TITLE_ADD_SCORMS);
            ?>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
		<tr>
			<td align="right">
			<?php 
            $toolbar = array();
            $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton_scorm('lpath_add_scorm');");
            $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton_scorm('cancel_lpath_step');");
            echo JLMS_ShowToolbar($toolbar);
            ?>
			</td>
		</tr>
	</table>
					<form action="<?php 
            echo sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid);
            ?>
" method="post" name="scormForm">
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
						<tr>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">#</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="1%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
							<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="98%" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_LPATH_SCORM_OBJECT;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						</tr>
					<?php 
            $k = 1;
            for ($i = 0, $n = count($my_scorms); $i < $n; $i++) {
                $row = $my_scorms[$i];
                // (WARNING) if link will be changed, don't forgot to change target of <a> element
                $link = 'javascript:void(0);';
                //$row->link_href;//"index.php?option=".$option."&Itemid=".$Itemid."&task=get_file&id=".$row->file_id;
                $checked = '<input type="checkbox" name="cid[]" value="' . $row->id . '" />';
                ?>
						<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
							<td align="center"><?php 
                echo $i + 1;
                ?>
</td>
							<td><?php 
                if (!isset($row->is_link)) {
                    echo $checked;
                }
                ?>
</td>
							<td>
							
							<?php 
                if (!isset($row->is_link)) {
                    ?>
								<a href="<?php 
                    echo sefRelToAbs($link);
                    ?>
">
							<?php 
                }
                ?>
	
									<?php 
                echo $row->lpath_name;
                ?>
									
							<?php 
                if (!isset($row->is_link)) {
                    ?>
		
								</a>
							<?php 
                }
                ?>
	
							</td>
						</tr>
						<?php 
                $k = 3 - $k;
            }
            ?>
					</table>
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_item_properties">
						<tr>
							<td width="15%"><?php 
            echo _JLMS_PLACE_IN;
            ?>
</td>
							<td><?php 
            echo $lists['lpath_chaps1'];
            ?>
</td>
						</tr>
						<tr>
							<td><br /><?php 
            echo _JLMS_ORDERING;
            ?>
</td>
							<td><br /><?php 
            echo $lists['lpath_order'];
            ?>
</td>
						</tr>
					</table>
					<input type="hidden" name="option" value="<?php 
            echo $option;
            ?>
" />
					<input type="hidden" name="Itemid" value="<?php 
            echo $Itemid;
            ?>
" />
					<input type="hidden" name="task" value="lpath_add_scorm" />
					<input type="hidden" name="id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="lpath_id" value="<?php 
            echo $lpath_id;
            ?>
" />
					<input type="hidden" name="course_id" value="<?php 
            echo $course_id;
            ?>
" />
					</form>
<?php 
            echo $tabs->endTab();
        }
        echo $tabs->endPane();
        JLMS_TMPL::CloseTS();
        JLMS_TMPL::CloseMT();
    }
Пример #21
0
function JLMS_changeLink($option)
{
    global $JLMS_DB, $my, $Itemid, $JLMS_CONFIG;
    $course_id = $JLMS_CONFIG->get('course_id');
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($course_id && $JLMS_ACL->CheckPermissions('links', 'publish')) {
        $state = intval(mosGetParam($_REQUEST, 'state', 0));
        if ($state != 1) {
            $state = 0;
        }
        $cid = mosGetParam($_REQUEST, 'cid', array(0));
        $cid2 = intval(mosGetParam($_REQUEST, 'cid2', 0));
        if ($cid2) {
            $cid = array();
            $cid[] = $cid2;
        }
        if (!is_array($cid)) {
            $cid = array(0);
        }
        if (!is_array($cid) || count($cid) < 1) {
            $action = 1 ? 'Publish' : 'Unpublish';
            echo "<script> alert('Select an item to {$action}'); window.history.go(-1);</script>\n";
            exit;
        }
        $cids = implode(',', $cid);
        $query = "UPDATE #__lms_links" . "\n SET published = {$state}" . "\n WHERE id IN ( {$cids} ) AND course_id = {$course_id}" . ($JLMS_ACL->CheckPermissions('links', 'only_own_items') ? " AND owner_id = '" . $my->id . "'" : '');
        $JLMS_DB->setQuery($query);
        if (!$JLMS_DB->query()) {
            echo "<script> alert('" . $JLMS_DB->getErrorMsg() . "'); window.history.go(-1); </script>\n";
            exit;
        }
    }
    JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=links&id={$course_id}"));
}
Пример #22
0
 /**
 	* Convert BB export course file to JLMS export course file and upload it to database
 	* @param String Name of form field with bb filename
 	* @return Array  ['lmsfile'] - Name of JLMS export course file (file placed in \media) (null if error)
 					 ['msg']	 - Message
 */
 function processBBfile($course_id = 0, $def_course_name = 'BB course', $do_lms_archive = true, $upload_to_db = true)
 {
     global $JLMS_DB, $JLMS_CONFIG, $my;
     if (!$this->is_prepared) {
         return array('lmsfile' => null, 'msg' => "Error! Invalid parameters passed");
     }
     if (!$do_lms_archive && !$upload_to_db || !$this->bb_file_media_name && !$this->bb_file_tmp_name) {
         return array('lmsfile' => null, 'msg' => "Error! Invalid parameters passed");
     }
     require_once $JLMS_CONFIG->get('absolute_path') . "/components/com_joomla_lms/includes/jlms_dir_operation.php";
     require_once $JLMS_CONFIG->get('absolute_path') . "/components/com_joomla_lms/includes/jlms_zip_operation.php";
     // for function "JLMS_parse_XML_elements()"
     require_once $JLMS_CONFIG->get('absolute_path') . "/components/com_joomla_lms/includes/jlms_course_import.php";
     @set_time_limit('3000');
     // Check that the zlib is available
     if (!extension_loaded('zlib')) {
         return array('lmsfile' => null, 'msg' => "Error! zlib library unavailable");
     }
     if (!$this->bb_file_media_name && !$this->bb_file_tmp_name) {
         return array('lmsfile' => null, 'msg' => _JLMS_EM_SELECT_FILE);
     }
     $config =& JFactory::getConfig();
     $extract_dir = $config->get('tmp_path') . DS . "bb_course_export_" . uniqid(rand()) . DS;
     if ($this->bb_file_tmp_name) {
         $archive = $this->bb_file_tmp_name;
     } else {
         $archive = $JLMS_CONFIG->get('absolute_path') . "/media/" . $this->bb_file_media_name;
     }
     //exstract archive in uniqfolder media
     extractBackupArchive($archive, $extract_dir);
     $xmlFile = $extract_dir . "imsmanifest.xml";
     if ($fp1 = fopen($xmlFile, "r")) {
         $fline = fgets($fp1);
         $match = array();
         preg_match('/encoding="([0-9a-zA-Z-]*)"/i', $fline, $match);
         //find quoted encoding
         if (isset($match[1]) && $match[1] != "ISO-8859-1") {
             $this->charset_lang = $match[1];
         }
         fclose($fp1);
     }
     $xmlDoc =& JLMSFactory::getXMLParser();
     if (!$xmlDoc->loadFile($xmlFile)) {
         return array('lmsfile' => null, 'msg' => 'Error during reading xml file');
     }
     $root =& $xmlDoc->document;
     if ($root->name() != 'manifest') {
         return array('lmsfile' => null, 'msg' => 'Not a Course installation file');
     }
     // ****************************************************************************************************
     //get config values
     $query = "SELECT * FROM `#__lms_config`";
     $JLMS_DB->SetQuery($query);
     $lms_cfg = $JLMS_DB->LoadObjectList();
     $lms_cfg_doc_folder = '';
     $lms_cfg_scorm = '';
     $lms_cfg_backup_folder = '';
     $lms_cfg_quiz_enabled = 0;
     foreach ($lms_cfg as $lcf) {
         if ($lcf->lms_config_var == 'plugin_quiz') {
             $lms_cfg_quiz_enabled = $lcf->lms_config_value;
         } elseif ($lcf->lms_config_var == 'jlms_doc_folder') {
             $lms_cfg_doc_folder = $lcf->lms_config_value;
         } elseif ($lcf->lms_config_var == 'scorm_folder') {
             $lms_cfg_scorm = $lcf->lms_config_value;
         } elseif ($lcf->lms_config_var == 'jlms_backup_folder') {
             $lms_cfg_backup_folder = $lcf->lms_config_value;
         }
     }
     // ***************************************************************************************************
     $course = new stdClass();
     $course->course_name = $def_course_name;
     $course->course_description = '';
     $course->metadesc = '';
     $course->metakeys = '';
     $course->self_reg = '';
     $course->paid = 0;
     $course->add_forum = 0;
     $course->add_chat = 0;
     $course->owner_id = $my->id;
     $course->published = 0;
     $course->publish_start = 0;
     $course->publish_end = 0;
     $course->start_date = '0000-00-00';
     $course->end_date = '0000-00-00';
     $course->spec_reg = 0;
     $course->cat_id = 0;
     // 02.03.2007 1.0.1 support
     $course->params = '';
     $course->gid = 0;
     $course->language = 0;
     //get resources
     $element =& $root->getElementByPath('resources');
     $resources = JLMS_parse_XML_elements($element->children(), array('identifier', 'type'), array());
     foreach ($resources as $resource) {
         if ($resource->type == 'course/x-bb-coursesetting') {
             $resourceFile = $extract_dir . $resource->identifier . ".dat";
             $resourceXmlDoc =& JLMSFactory::getXMLParser();
             ////$resourceXmlDoc->resolveErrors( true );
             if ($resourceXmlDoc->loadFile($resourceFile)) {
                 $resourceRoot =& $resourceXmlDoc->document;
                 $resourceElement =& $resourceRoot->getElementByPath('title');
                 $course->course_name = $this->attributes($resourceElement, 'value');
                 if ($def_course_name != 'BB course') {
                     $course->course_name = $def_course_name;
                 }
                 $resourceElement =& $resourceRoot->getElementByPath('description');
                 $course->course_description = $this->data($resourceElement);
             }
         }
     }
     //save course
     if ($upload_to_db) {
         if (!$course_id) {
             $JLMS_DB->insertObject("#__lms_courses", $course, "id");
             //get new Course_id
             $course_id = $JLMS_DB->insertid();
             // create teacher for imported course
             $default_teacher_role = 0;
             $query = "SELECT id FROM #__lms_usertypes WHERE roletype_id = 2 AND default_role = 1 LIMIT 0,1";
             $JLMS_DB->setQuery($query);
             $default_teacher_role = intval($JLMS_DB->LoadResult());
             if (!$default_teacher_role) {
                 $query = "SELECT id FROM #__lms_usertypes WHERE roletype_id = 2 LIMIT 0,1";
                 $JLMS_DB->setQuery($query);
                 $default_teacher_role = intval($JLMS_DB->LoadResult());
                 if (!$default_teacher_role) {
                     $default_teacher_role = 1;
                 }
             }
             $query = "INSERT INTO `#__lms_user_courses` (user_id, course_id, role_id) VALUES ('" . $my->id . "','" . $course_id . "','" . $default_teacher_role . "')";
             $JLMS_DB->setQuery($query);
             $JLMS_DB->query();
         }
     }
     // ******************************************************************************************************************
     // process resourses
     $i = 0;
     //get data from resource files
     while ($i < count($resources)) {
         //$resources[$i]->identifier .= ".dat";
         $resourceFile = $extract_dir . $resources[$i]->identifier . ".dat";
         //echo $resourceFile.'<br />';
         $resourceXmlDoc =& JLMSFactory::getXMLParser();
         //$resourceXmlDoc->resolveErrors( true );
         if ($resourceXmlDoc->loadFile($resourceFile)) {
             $resourceRoot =& $resourceXmlDoc->document;
             //file, folder, link or content
             $resources[$i]->resource_type = '';
             if ($resources[$i]->type == 'resource/x-bb-document') {
                 $resourceElement =& $resourceRoot->getElementByPath('contenthandler');
                 // resource/x-bb-document - content may be with file
                 // resource/x-bb-folder - foder
                 // resource/x-bb-externallink - link
                 $resources[$i]->resource_type = $this->attributes($resourceElement, 'value');
                 if ($resources[$i]->resource_type == 'resource/x-bb-document' || $resources[$i]->resource_type == 'resource/x-bb-folder' || $resources[$i]->resource_type == 'resource/x-bb-externallink') {
                     //save files
                     $resourceElement =& $resourceRoot->getElementByPath('files');
                     $files = JLMS_parse_XML_elements($resourceElement->children(), array('id'), array('name'));
                     if (count($files) > 0) {
                         $resources[$i]->files = $files;
                     }
                     //$resourceElement = &$resourceRoot->getElementByPath('CONTENT', 1);
                     $resources[$i]->id = $this->attributes($resourceRoot, 'id');
                     //save URLs
                     $resourceElement =& $resourceRoot->getElementByPath('url');
                     if ($this->attributes($resourceElement, 'value')) {
                         $resources[$i]->url = $this->attributes($resourceElement, 'value');
                     }
                     //save name and description
                     $resourceElement =& $resourceRoot->getElementByPath('title');
                     if ($this->attributes($resourceElement, 'value')) {
                         $resources[$i]->title = $this->attributes($resourceElement, 'value');
                     } else {
                         $resources[$i]->title = '';
                     }
                     $resourceElement =& $resourceRoot->getElementByPath('body');
                     $text =& $resourceElement->getElementByPath('text');
                     if ($text) {
                         $resources[$i]->text = $this->data($text);
                     } else {
                         $resources[$i]->text = '';
                     }
                     //save START and END date
                     $resourceElement =& $resourceRoot->getElementByPath('dates');
                     $tmp = $resourceElement->getElementByPath('start');
                     if ($this->attributes($tmp, 'value')) {
                         $resources[$i]->start = $this->attributes($tmp, 'value');
                     }
                     $tmp = $resourceElement->getElementByPath('end');
                     if ($this->attributes($tmp, 'value')) {
                         $resources[$i]->end = $this->attributes($tmp, 'value');
                     }
                 }
             } elseif ($resources[$i]->type == 'resource/x-bb-announcement') {
                 //save name and description
                 $resourceElement =& $resourceRoot->getElementByPath('title');
                 if ($this->attributes($resourceElement, 'value')) {
                     $resources[$i]->title = $this->attributes($resourceElement, 'value');
                 }
                 $resourceElement =& $resourceRoot->getElementByPath('description');
                 $text =& $resourceElement->getElementByPath('text');
                 if ($text) {
                     $resources[$i]->text = $this->data($text);
                 } else {
                     $resources[$i]->text = '';
                 }
                 //save START and END date
                 $resourceElement =& $resourceRoot->getElementByPath('dates');
                 $tmp = $resourceElement->getElementByPath('RESTRICTSTART');
                 if ($this->attributes($tmp, 'value')) {
                     $resources[$i]->restrictstart = $this->attributes($tmp, 'value');
                 }
                 $tmp = $resourceElement->getElementByPath('RESTRICTEND');
                 if ($this->attributes($tmp, 'value')) {
                     $resources[$i]->restrictend = $this->attributes($tmp, 'value');
                 }
             } elseif ($resources[$i]->type == 'resource/x-bb-task') {
                 //save name and description
                 $resourceElement =& $resourceRoot->getElementByPath('title');
                 if ($this->attributes($resourceElement, 'value')) {
                     $resources[$i]->title = $this->attributes($resourceElement, 'value');
                 }
                 $resourceElement =& $resourceRoot->getElementByPath('description');
                 $text =& $resourceElement->getElementByPath('text');
                 if ($text) {
                     $resources[$i]->text = $this->data($text);
                 } else {
                     $resources[$i]->text = '';
                 }
                 //save DUE date
                 $resourceElement =& $resourceRoot->getElementByPath('dates');
                 $tmp = $resourceElement->getElementByPath('due');
                 if ($this->attributes($tmp, 'value')) {
                     $resources[$i]->due = $this->attributes($tmp, 'value');
                 }
             } elseif ($resources[$i]->type == 'assessment/x-bb-qti-test' || $resources[$i]->type == 'assessment/x-bb-qti-pool' || $resources[$i]->type == 'assessment/x-bb-qti-survey') {
                 //save name and description
                 $resourceElement =& $resourceRoot->getElementByPath('assessment');
                 $resourceElement =& $resourceElement->getElementByPath('section');
                 $resourceElement =& $resourceElement->getElementByPath('sectionmetadata');
                 $resourceElement =& $resourceElement->getElementByPath('bbmd_assessmenttype');
                 $assess_type = $this->data($resourceElement);
                 $resources[$i]->assess_type = $assess_type;
                 if ($assess_type != 'Survey') {
                     $resourceElement =& $resourceRoot->getElementByPath('assessment');
                     if ($this->attributes($resourceElement, 'title')) {
                         $resources[$i]->title = $this->attributes($resourceElement, 'title');
                     }
                     $resourceElement =& $resourceElement->getElementByPath('presentation_material');
                     $resourceElement =& $resourceElement->getElementByPath('flow_mat');
                     $resourceElement =& $resourceElement->getElementByPath('material');
                     $resourceElement =& $resourceElement->getElementByPath('mat_extension');
                     $resourceElement =& $resourceElement->getElementByPath('mat_formattedtext');
                     $resources[$i]->text = $this->data($resourceElement);
                     //save max score
                     $resourceElement =& $resourceRoot->getElementByPath('assessment');
                     $resourceElement =& $resourceElement->getElementByPath('section');
                     $resourceElement =& $resourceElement->getElementByPath('sectionmetadata');
                     $tmp =& $resourceElement->getElementByPath('bbmd_asi_object_id');
                     $resources[$i]->q_id = $this->data($tmp);
                     $resourceElement =& $resourceElement->getElementByPath('qmd_absolutescore_max');
                     $resources[$i]->score_max = $this->data($resourceElement);
                     //save questions
                     $resourceElement =& $resourceRoot->getElementByPath('assessment');
                     $resourceElement =& $resourceElement->getElementByPath('section');
                     $resources[$i]->questions = $this->getQuestions($resourceElement->children(), $resources[$i]->q_id, $resources[$i]->identifier);
                     $resources[$i]->answers = $this->getAnswers($resourceElement->children(), $resources[$i]->q_id);
                 }
             } elseif ($resources[$i]->type == 'course/x-bb-gradebook') {
                 //get name and descriptoin
                 $resourceElement =& $resourceRoot->getElementByPath('outcomedefinitions');
                 $gb = array();
                 foreach ($resourceElement->children() as $item) {
                     $title = $item->getElementByPath('title');
                     $description = $item->getElementByPath('description');
                     if ($this->attributes($title, 'value') == 'OutcomeDefinition.Total.title' || $this->attributes($title, 'value') == 'OutcomeDefinition.WeightedTotal.title') {
                         continue;
                     }
                     $identifier = $item->getElementByPath('asidataid');
                     $identifier = $this->attributes($identifier, 'value');
                     if (!$identifier) {
                         $insert = new stdClass();
                         $insert->title = $this->attributes($title, 'value');
                         $insert->description = $this->data($description);
                         $gb[] = $insert;
                     }
                 }
                 $resources[$i]->gradebook = $gb;
             } elseif ($resources[$i]->type == 'course/x-bb-coursesetting') {
                 $resourceElement =& $resourceRoot->getElementByPath('title');
                 $course->course_name = $this->attributes($resourceElement, 'value');
                 $resourceElement =& $resourceRoot->getElementByPath('description');
                 $course->course_description = $this->data($resourceElement);
             }
             ##elseif ( $resources[$i]->type == 'course/x-bb-coursesetting' ) ....
         }
         ## if ($resourceXmlDoc->loadXML( $resourceFile, false, true )) ....
         $i++;
     }
     ## while( $i < count($resources) ) ....
     // *******************************************************************************************************************
     $i = 0;
     $announcements = array();
     $homeworks = array();
     $links = array();
     $files = array();
     $gradebook = array();
     $quizzes_no = array();
     $quizzes = array();
     $questions = array();
     $answers = array();
     //prepare data to save
     while ($i < count($resources)) {
         if (($resources[$i]->type == 'assessment/x-bb-qti-test' || $resources[$i]->type == 'assessment/x-bb-qti-pool' || $resources[$i]->type == 'assessment/x-bb-qti-survey') && $resources[$i]->assess_type != 'Survey') {
             $insert = new stdClass();
             $insert->_c_id = $resources[$i]->q_id;
             $insert->c_category_id = null;
             $insert->c_user_id = $my->id;
             $insert->c_full_score = abs($resources[$i]->score_max);
             // 17.12.2007 (DEN) - negative values bug - needed another solution - BB courses have negative points values !
             $insert->c_title = $resources[$i]->title;
             $insert->c_description = $resources[$i]->text;
             $insert->c_time_limit = 5;
             $insert->c_min_after = 5;
             $insert->c_passing_score = 1;
             $insert->c_created_time = date('Y-m-d');
             $insert->published = 0;
             $insert->c_right_message = 'correct';
             $insert->c_wrong_message = 'incorrect';
             $insert->c_pass_message = 'pass';
             $insert->c_unpass_message = 'fail';
             $insert->c_enable_review = null;
             $insert->c_email_to = 0;
             $insert->c_enable_print = null;
             $insert->c_enable_sertif = null;
             $insert->c_skin = 3;
             $insert->c_random = 0;
             $insert->c_guest = 0;
             $insert->c_slide = 1;
             $insert->c_language = 1;
             $insert->c_certificate = 0;
             $insert->c_gradebook = 1;
             $insert->course_id = $course_id;
             $quizzes[] = $insert;
             $quizzes_no[] = $i;
             $questions[] = $resources[$i]->questions;
             $answers[] = $resources[$i]->answers;
         }
         if (isset($resources[$i]->url)) {
             $insert = new stdClass();
             $insert->course_id = $course_id;
             $insert->owner_id = $my->id;
             $insert->link_name = $resources[$i]->title;
             $insert->link_href = $resources[$i]->url;
             $insert->link_description = $resources[$i]->text;
             $insert->link_type = 0;
             $insert->ordering = 0;
             $insert->published = 0;
             $insert->_id = $resources[$i]->id;
             $links[] = $insert;
         }
         if ($resources[$i]->type == 'resource/x-bb-announcement') {
             $insert = new stdClass();
             $insert->course_id = $course_id;
             $insert->owner_id = $my->id;
             $insert->title = $resources[$i]->title;
             $insert->content = $resources[$i]->text;
             $insert->start_date = $resources[$i]->restrictstart;
             $insert->end_date = isset($resources[$i]->restrictend) ? $resources[$i]->restrictend : $resources[$i]->restrictstart;
             $announcements[] = $insert;
         }
         if ($resources[$i]->type == 'resource/x-bb-task') {
             $insert = new stdClass();
             $insert->course_id = $course_id;
             $insert->hw_name = $resources[$i]->title;
             $insert->hw_description = $resources[$i]->text;
             $insert->hw_shortdescription = $resources[$i]->text;
             $insert->post_date = date("Y-m-d");
             $insert->end_date = $resources[$i]->due;
             $homeworks[] = $insert;
         }
         if ($resources[$i]->type == 'course/x-bb-gradebook') {
             foreach ($resources[$i]->gradebook as $item) {
                 $insert = new stdClass();
                 $insert->course_id = $course_id;
                 $insert->gbc_id = 0;
                 $insert->gbi_name = $item->title;
                 $insert->gbi_description = $item->description;
                 $insert->gbi_points = 0;
                 $insert->gbi_option = 0;
                 $insert->ordering = 0;
                 $gradebook[] = $insert;
             }
         }
         if (isset($resources[$i]->files)) {
             $file = $resources[$i]->files[0];
             if ($this->charset_lang != 'ISO-8859-1') {
                 $file->name = htmlentities($file->name, ENT_QUOTES, $this->charset_lang);
                 $file->name = str_replace('&lt;', '<', $file->name);
                 $file->name = str_replace('&gt;', '>', $file->name);
                 $file->name = str_replace('&amp;', '&', $file->name);
             }
             $fromDir = $extract_dir . $resources[$i]->identifier . "/";
             $toDir = $lms_cfg_doc_folder . "/";
             $insert_file = new stdClass();
             $insert_file->_fromDir = $extract_dir . $resources[$i]->identifier . "/";
             $insert_file->_toDir = $lms_cfg_doc_folder . "/";
             $insert_file->file_name = $file->name;
             $file_unique_name = str_pad($course_id, 4, '0', STR_PAD_LEFT) . '_' . md5(uniqid(rand(), true)) . '.' . substr($file->name, -3);
             $insert_file->file_srv_name = $file_unique_name;
             $insert_file->owner_id = $my->id;
             if (!file_exists($insert_file->_fromDir . $insert_file->file_name)) {
                 $res_dir = opendir($insert_file->_fromDir);
                 while (false !== ($res_file = readdir($res_dir))) {
                     if ($res_file != "." && $res_file != "..") {
                         rename($insert_file->_fromDir . $res_file, $insert_file->_fromDir . $insert_file->file_srv_name);
                         break;
                     }
                 }
                 closedir($res_dir);
             } else {
                 rename($insert_file->_fromDir . $insert_file->file_name, $insert_file->_fromDir . $insert_file->file_srv_name);
             }
             $insert_file->_id = $file->id;
             $file->file_srv_name = $insert_file->file_srv_name;
             $resources[$i]->files[0] = $file;
             $files[] = $insert_file;
         }
         $i++;
     }
     $element =& $root->getElementByPath('organizations');
     $element = $element->getElementByPath('organization');
     //$items = JLMS_parse_XML_elements($element->children(), array('identifierref'), array());
     $i = 0;
     $documents1 = array();
     while ($i < count($element->children())) {
         $nodes = $element->children();
         $node = $nodes[$i];
         $title = $node->getElementByPath('title');
         $title = substr($this->data($title), 15);
         $title = substr($title, 0, strpos($title, "."));
         foreach ($node->children() as $item) {
             if ($item->name() == 'item') {
                 $this->Process_Item($item, $documents1, $resources);
             }
         }
         $i++;
     }
     $documents1 = array_reverse($documents1);
     // insert data to database
     if ($upload_to_db) {
         if (in_array('links', $this->options)) {
             for ($i = 0, $n = count($links); $i < $n; $i++) {
                 $JLMS_DB->insertObject("#__lms_links", $links[$i], "id");
                 $links[$i]->_id = $JLMS_DB->insertid();
             }
         }
         if (in_array('announcements', $this->options)) {
             for ($i = 0, $n = count($announcements); $i < $n; $i++) {
                 $JLMS_DB->insertObject("#__lms_agenda", $announcements[$i], "id");
             }
         }
         if (in_array('homework', $this->options)) {
             for ($i = 0, $n = count($homeworks); $i < $n; $i++) {
                 $JLMS_DB->insertObject("#__lms_homework", $homeworks[$i], "id");
             }
         }
         if (in_array('gradebook_items', $this->options)) {
             for ($i = 0, $n = count($gradebook); $i < $n; $i++) {
                 $JLMS_DB->insertObject("#__lms_gradebook_items", $gradebook[$i], "id");
             }
         }
         if (in_array('documents', $this->options)) {
             for ($i = 0, $n = count($files); $i < $n; $i++) {
                 $JLMS_DB->insertObject("#__lms_files", $files[$i], "id");
                 $files[$i]->new_file_id = $JLMS_DB->insertid();
             }
         }
         if (in_array('quizzes', $this->options)) {
             $i = 0;
             while ($i < count($quizzes)) {
                 $JLMS_DB->insertObject("#__lms_quiz_t_quiz", $quizzes[$i], "c_id");
                 $new_quiz_id = $JLMS_DB->insertid();
                 $quizzes[$i]->new_quiz_id = $new_quiz_id;
                 $quizzes[$i]->_c_id = $new_quiz_id;
                 //questions processing
                 $j = 0;
                 while ($j < count($questions[$i])) {
                     $questions[$i][$j]->course_id = $course_id;
                     $questions[$i][$j]->c_quiz_id = $new_quiz_id;
                     $JLMS_DB->insertObject("#__lms_quiz_t_question", $questions[$i][$j], "c_id");
                     $questions[$i][$j]->new_id = $JLMS_DB->insertid();
                     $j++;
                 }
                 //choices processing
                 $j = 0;
                 while ($j < count($answers[$i]['choice_data'])) {
                     for ($k = 0; $k < count($questions[$i]); $k++) {
                         if ($questions[$i][$k]->_c_id == $answers[$i]['choice_data'][$j]->c_question_id) {
                             $answers[$i]['choice_data'][$j]->c_question_id = isset($questions[$i][$k]->new_id) ? $questions[$i][$k]->new_id : 0;
                             break;
                         }
                     }
                     if ($answers[$i]['choice_data'][$j]->c_question_id > 0) {
                         $JLMS_DB->insertObject("#__lms_quiz_t_choice", $answers[$i]['choice_data'][$j], "c_id");
                     }
                     $j++;
                 }
                 //matching processing
                 $j = 0;
                 while ($j < count($answers[$i]['match_data'])) {
                     for ($k = 0; $k < count($questions[$i]); $k++) {
                         if ($questions[$i][$k]->_c_id == $answers[$i]['match_data'][$j]->c_question_id) {
                             $answers[$i]['match_data'][$j]->c_question_id = isset($questions[$i][$k]->new_id) ? $questions[$i][$k]->new_id : 0;
                             break;
                         }
                     }
                     if ($answers[$i]['match_data'][$j]->c_question_id > 0) {
                         $JLMS_DB->insertObject("#__lms_quiz_t_matching", $answers[$i]['match_data'][$j], "c_id");
                     }
                     $j++;
                 }
                 //hotspot processing
                 $j = 0;
                 while ($j < count($answers[$i]['hotspot_data'])) {
                     for ($k = 0; $k < count($questions[$i]); $k++) {
                         if ($questions[$i][$k]->_c_id == $answers[$i]['hotspot_data'][$j]->c_question_id) {
                             $answers[$i]['hotspot_data'][$j]->c_question_id = isset($questions[$i][$k]->new_id) ? $questions[$i][$k]->new_id : 0;
                             break;
                         }
                     }
                     if ($answers[$i]['hotspot_data'][$j]->c_question_id > 0) {
                         $JLMS_DB->insertObject("#__lms_quiz_t_hotspot", $answers[$i]['hotspot_data'][$j], "c_id");
                     }
                     $j++;
                 }
                 //blank quests processing
                 $j = 0;
                 while ($j < count($answers[$i]['blank_data'])) {
                     for ($k = 0; $k < count($questions[$i]); $k++) {
                         if ($questions[$i][$k]->_c_id == $answers[$i]['blank_data'][$j]['obj']->c_question_id) {
                             $answers[$i]['blank_data'][$j]['obj']->c_question_id = isset($questions[$i][$k]->new_id) ? $questions[$i][$k]->new_id : 0;
                             break;
                         }
                     }
                     if ($answers[$i]['blank_data'][$j]['obj']->c_question_id > 0) {
                         $JLMS_DB->insertObject("#__lms_quiz_t_blank", $answers[$i]['blank_data'][$j]['obj'], "c_id");
                         $new_blank_id = $JLMS_DB->insertid();
                         foreach ($answers[$i]['blank_data'][$j]['ans'] as $ans) {
                             $q_blank_text = new stdClass();
                             $q_blank_text->c_blank_id = $new_blank_id;
                             $q_blank_text->c_text = $ans;
                             $q_blank_text->ordering = 0;
                             if ($q_blank_text->c_blank_id > 0) {
                                 $JLMS_DB->insertObject("#__lms_quiz_t_text", $q_blank_text, "c_id");
                             }
                         }
                     }
                     $j++;
                 }
                 $i++;
             }
         }
         if (in_array('documents', $this->options)) {
             $i = 0;
             while ($i < count($documents1)) {
                 $insert = new stdClass();
                 $insert->course_id = $course_id;
                 $insert->owner_id = $my->id;
                 $insert->file_id = 0;
                 if ($documents1[$i]->file_id) {
                     // search $files for new file_id
                     for ($j = 0; $j < count($files); $j++) {
                         if ($files[$j]->_id == $documents1[$i]->file_id) {
                             $insert->file_id = $files[$j]->new_file_id;
                             break;
                         }
                     }
                 }
                 $insert->folder_flag = $documents1[$i]->folder_flag;
                 $insert->doc_name = $documents1[$i]->doc_name;
                 $insert->doc_description = $documents1[$i]->doc_description;
                 $insert->ordering = $documents1[$i]->ordering;
                 $insert->published = $documents1[$i]->published;
                 $insert->publish_start = $documents1[$i]->publish_start;
                 $insert->start_date = $documents1[$i]->start_date;
                 $insert->publish_end = $documents1[$i]->publish_end;
                 $insert->end_date = $documents1[$i]->end_date;
                 // search processed $documents for parent_id
                 $parent = $documents1[$i]->parent_id;
                 if ($parent) {
                     $a = 0;
                     while ($a < $i) {
                         if ($documents1[$a]->id == $parent) {
                             $parent = $documents1[$a]->new_doc_id;
                             break;
                         }
                         $a++;
                     }
                 }
                 $insert->parent_id = $parent;
                 $JLMS_DB->insertObject("#__lms_documents", $insert, "id");
                 $documents1[$i]->new_doc_id = $JLMS_DB->insertid();
                 $i++;
             }
         }
         if (in_array('quizzes', $this->options)) {
             $toDir = $JLMS_CONFIG->get('absolute_path') . "/images/joomlaquiz/images/";
             foreach ($questions as $question) {
                 foreach ($question as $quest) {
                     if (isset($quest->_c_image)) {
                         $filename = $extract_dir . $quest->_identifier . "/" . $quest->_c_image;
                         //$pz->add($filename,'quiz_images', $extract_dir.$quest->identifier."/".substr($quest->_c_image, 0, strpos($quest->_c_image, '\\'))."/");
                         @copy($filename, $toDir . $quest->c_image);
                     }
                 }
             }
         }
         if (in_array('documents', $this->options)) {
             $toDir = $lms_cfg_doc_folder . "/";
             foreach ($files as $file) {
                 $filename = $file->_fromDir . $file->file_srv_name;
                 //$pz->add($filename,'files', $file->_fromDir);
                 copy($filename, $toDir . $file->file_srv_name);
             }
         }
     }
     if ($do_lms_archive) {
         $export_xml = "";
         $export_xml .= "<?xml version=\"1.0\" ?>\r\n";
         $export_xml .= "\t<course_backup lms_version=\"1.0.0\">\r\n";
         $export_xml .= "\t\t<name><![CDATA[" . $course->course_name . "]]></name>\r\n";
         $export_xml .= "\t\t<description><![CDATA[" . $course->course_description . "]]></description>\r\n";
         $export_xml .= "\t\t<course_category><![CDATA[]]></course_category>\r\n";
         $export_xml .= "\t\t<metadesc><![CDATA[" . $course->metadesc . "]]></metadesc>\r\n";
         $export_xml .= "\t\t<metakeys><![CDATA[" . $course->metakeys . "]]></metakeys>\r\n";
         $export_xml .= "\t\t<language_name><![CDATA[english]]></language_name>\r\n";
         $export_xml .= "\t\t<course_paid><![CDATA[" . $course->paid . "]]></course_paid>\r\n";
         $export_xml .= "\t\t<self_registration>" . $course->self_reg . "</self_registration>\r\n";
         $export_xml .= "\t\t<forum_enabled>" . $course->add_forum . "</forum_enabled>\r\n";
         $export_xml .= "\t\t<chat_enabled>" . $course->add_chat . "</chat_enabled>\r\n";
         $export_xml .= "\t\t<publish_start>" . $course->publish_start . "</publish_start>\r\n";
         $export_xml .= "\t\t<publish_start_date><![CDATA[" . $course->start_date . "]]></publish_start_date>\r\n";
         $export_xml .= "\t\t<publish_end>" . $course->publish_end . "</publish_end>\r\n";
         $export_xml .= "\t\t<publish_end_date><![CDATA[" . $course->end_date . "]]></publish_end_date>\r\n";
         $export_xml .= "\t\t<spec_reg>" . $course->spec_reg . "</spec_reg>\r\n";
         $export_xml .= "\t\t<course_question><![CDATA[]]></course_question>\r\n";
         $export_xml .= "\t\t<course_params><![CDATA[" . $course->params . "]]></course_params>\r\n";
         $export_xml .= "\t\t<hidden_menu_items></hidden_menu_items>\n";
         $export_xml .= "\t\t<certificates></certificates>\n";
         $export_xml .= "\t\t<scorms></scorms>\n";
         $export_xml .= "\t\t<zipped_documents></zipped_documents>\n";
         $export_xml .= "\t\t<learn_paths></learn_paths>\n";
         $export_xml .= "\t\t<gradebook_scale></gradebook_scale>\n";
         //GradeBook Items:
         $export_xml .= "\t\t<gradebook_items>\n";
         if (in_array('gradebook_items', $this->options)) {
             foreach ($gradebook as $gb_item) {
                 $export_xml .= "\t\t\t<gb_item gbi_option=\"" . $gb_item->gbi_option . "\" ordering=\"" . $gb_item->ordering . "\" >\n";
                 $export_xml .= "\t\t\t\t<gbi_name><![CDATA[" . $gb_item->gbi_name . "]]></gbi_name>\r\n";
                 $export_xml .= "\t\t\t\t<gbi_description><![CDATA[" . $gb_item->gbi_description . "]]></gbi_description>\r\n";
                 $export_xml .= "\t\t\t\t<gb_category><![CDATA[]]></gb_category>\r\n";
                 $export_xml .= "\t\t\t</gb_item>\n";
             }
         }
         $export_xml .= "\t\t</gradebook_items>\n";
         //links section
         $export_xml .= "\t\t<links>\n";
         if (in_array('links', $this->options)) {
             foreach ($links as $link) {
                 $export_xml .= "\t\t\t<link id=\"" . $link->_id . "\" link_type=\"" . $link->link_type . "\" ordering=\"" . $link->ordering . "\" published=\"" . $link->published . "\">\n";
                 $export_xml .= "\t\t\t\t<linkname><![CDATA[" . $link->link_name . "]]></linkname>\r\n";
                 $export_xml .= "\t\t\t\t<linkhref><![CDATA[" . $link->link_href . "]]></linkhref>\r\n";
                 $export_xml .= "\t\t\t\t<description><![CDATA[" . $link->link_description . "]]></description>\r\n";
                 $export_xml .= "\t\t\t</link>\n";
             }
         }
         $export_xml .= "\t\t</links>\n";
         //files section
         $export_xml .= "\t\t<files>\n";
         if (in_array('documents', $this->options)) {
             foreach ($files as $ff) {
                 $export_xml .= "\t\t\t<file id=\"" . $ff->_id . "\">\n";
                 $export_xml .= "\t\t\t\t<filename><![CDATA[" . $ff->file_name . "]]></filename>\r\n";
                 $export_xml .= "\t\t\t\t<servername><![CDATA[" . $ff->file_srv_name . "]]></servername>\r\n";
                 $export_xml .= "\t\t\t</file>\n";
             }
         }
         $export_xml .= "\t\t</files>\n";
         //documents section
         $export_xml .= "\t\t<documents>\n";
         if (in_array('documents', $this->options)) {
             foreach ($documents1 as $document) {
                 $export_xml .= "\t\t\t<document id=\"" . $document->id . "\" file_id=\"" . $document->file_id . "\" folder_flag=\"" . $document->folder_flag . "\" parent_id=\"" . $document->parent_id . "\" ordering=\"" . $document->ordering . "\" published=\"" . $document->published . "\" publish_start=\"" . $document->publish_start . "\" start_date=\"" . $document->start_date . "\" publish_end=\"" . $document->publish_end . "\" end_date=\"" . $document->end_date . "\" >\r\n";
                 $export_xml .= "\t\t\t\t<doc_name><![CDATA[" . $document->doc_name . "]]></doc_name>\n";
                 $export_xml .= "\t\t\t\t<doc_description><![CDATA[" . $document->doc_description . "]]></doc_description>\n";
                 $export_xml .= "\t\t\t</document>\n";
             }
         }
         $export_xml .= "\t\t</documents>\n";
         $export_xml .= "\t\t<quizzes>\n";
         if (in_array('quizzes', $this->options)) {
             for ($i = 0, $n = count($quizzes); $i < $n; $i++) {
                 $quiz = $quizzes[$i];
                 $question = $questions[$i];
                 $answer = $answers[$i];
                 $export_xml .= "\t\t\t<quiz c_id=\"" . $quiz->_c_id . "\" published=\"" . $quiz->published . "\" >\r\n";
                 $export_xml .= "\t\t\t\t<quiz_title><![CDATA[" . $quiz->c_title . "]]></quiz_title>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_description><![CDATA[" . $quiz->c_description . "]]></quiz_description>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_category><![CDATA[" . $quiz->c_category_id . "]]></quiz_category>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_full_score><![CDATA[" . $quiz->c_full_score . "]]></quiz_full_score>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_time_limit><![CDATA[" . $quiz->c_time_limit . "]]></quiz_time_limit>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_min_after><![CDATA[" . $quiz->c_min_after . "]]></quiz_min_after>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_passing_score><![CDATA[" . $quiz->c_passing_score . "]]></quiz_passing_score>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_right_message><![CDATA[" . $quiz->c_right_message . "]]></quiz_right_message>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_wrong_message><![CDATA[" . $quiz->c_wrong_message . "]]></quiz_wrong_message>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_pass_message><![CDATA[" . $quiz->c_pass_message . "]]></quiz_pass_message>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_unpass_message><![CDATA[" . $quiz->c_unpass_message . "]]></quiz_unpass_message>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_review>" . $quiz->c_enable_review . "</quiz_review>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_email>" . $quiz->c_email_to . "</quiz_email>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_print>" . $quiz->c_enable_print . "</quiz_print>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_certif>" . $quiz->c_enable_sertif . "</quiz_certif>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_skin>" . $quiz->c_skin . "</quiz_skin>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_random>" . $quiz->c_random . "</quiz_random>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_guest>" . $quiz->c_guest . "</quiz_guest>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_slide>" . $quiz->c_slide . "</quiz_slide>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_language>" . $quiz->c_language . "</quiz_language>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_certificate>" . $quiz->c_certificate . "</quiz_certificate>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_gradebook>" . $quiz->c_gradebook . "</quiz_gradebook>\r\n";
                 $export_xml .= "\t\t\t\t<quiz_questions>\n";
                 if (count($question)) {
                     foreach ($question as $quest) {
                         $export_xml .= "\t\t\t\t\t<quiz_question c_id=\"" . $quest->_c_id . "\" c_point=\"" . $quest->c_point . "\" c_attempts=\"" . $quest->c_attempts . "\" c_type=\"" . $quest->c_type . "\" ordering=\"" . $quest->ordering . "\">\n";
                         $export_xml .= "\t\t\t\t\t\t<question_text><![CDATA[" . $quest->c_question . "]]></question_text>\r\n";
                         $export_xml .= "\t\t\t\t\t\t<question_image><![CDATA[" . $quest->c_image . "]]></question_image>\r\n";
                         $export_xml .= "\t\t\t\t\t</quiz_question>\n";
                     }
                 }
                 $export_xml .= "\t\t\t\t</quiz_questions>\n";
                 $export_xml .= "\t\t\t\t<choice_data>\n";
                 if (count($answer['choice_data'])) {
                     foreach ($answer['choice_data'] as $qc_one) {
                         $export_xml .= "\t\t\t\t\t<quest_choice c_question_id=\"" . $qc_one->c_question_id . "\" c_right=\"" . $qc_one->c_right . "\" ordering=\"" . $qc_one->ordering . "\">\r\n";
                         $export_xml .= "\t\t\t\t\t\t<choice_text><![CDATA[" . $qc_one->c_choice . "]]></choice_text>\r\n";
                         $export_xml .= "\t\t\t\t\t</quest_choice>\n";
                     }
                 }
                 $export_xml .= "\t\t\t\t</choice_data>\n";
                 $export_xml .= "\t\t\t\t<match_data>\n";
                 if (count($answer['match_data'])) {
                     foreach ($answer['match_data'] as $qm_one) {
                         $export_xml .= "\t\t\t\t\t<quest_match c_question_id=\"" . $qm_one->c_question_id . "\" ordering=\"" . $qm_one->ordering . "\">\r\n";
                         $export_xml .= "\t\t\t\t\t\t<match_text_left><![CDATA[" . $qm_one->c_left_text . "]]></match_text_left>\r\n";
                         $export_xml .= "\t\t\t\t\t\t<match_text_right><![CDATA[" . $qm_one->c_right_text . "]]></match_text_right>\r\n";
                         $export_xml .= "\t\t\t\t\t</quest_match>\n";
                     }
                 }
                 $export_xml .= "\t\t\t\t</match_data>\n";
                 $export_xml .= "\t\t\t\t<blank_data>\n";
                 if (count($answer['blank_data'])) {
                     foreach ($answer['blank_data'] as $qb_one) {
                         $export_xml .= "\t\t\t\t\t<quest_blank c_question_id=\"" . $qb_one['obj']->c_question_id . "\" ordering=\"" . $qb_one['obj']->_ordering . "\">\r\n";
                         foreach ($qb_one['ans'] as $ans) {
                             $export_xml .= "\t\t\t\t\t\t<blank_text><![CDATA[" . $ans . "]]></blank_text>\r\n";
                         }
                         $export_xml .= "\t\t\t\t\t</quest_blank>\n";
                     }
                 }
                 $export_xml .= "\t\t\t\t</blank_data>\n";
                 $export_xml .= "\t\t\t\t<hotspot_data>\n";
                 if (count($answer['hotspot_data'])) {
                     foreach ($answer['hotspot_data'] as $qh_one) {
                         $export_xml .= "\t\t\t\t\t<quest_hotspot c_question_id=\"" . $qh_one->c_question_id . "\">\r\n";
                         $export_xml .= "\t\t\t\t\t\t<hs_start_x><![CDATA[" . $qh_one->c_start_x . "]]></hs_start_x>\r\n";
                         $export_xml .= "\t\t\t\t\t\t\t<hs_start_y><![CDATA[" . $qh_one->c_start_y . "]]></hs_start_y>\r\n";
                         $export_xml .= "\t\t\t\t\t\t<hs_width><![CDATA[" . $qh_one->c_width . "]]></hs_width>\r\n";
                         $export_xml .= "\t\t\t\t\t\t<hs_height><![CDATA[" . $qh_one->c_height . "]]></hs_height>\r\n";
                         $export_xml .= "\t\t\t\t\t</quest_hotspot>\n";
                     }
                 }
                 $export_xml .= "\t\t\t\t</hotspot_data>\n";
                 $export_xml .= "\t\t\t</quiz>\n";
             }
         }
         $export_xml .= "\t\t</quizzes>\n";
         //end of course backup
         $export_xml .= "\t</course_backup>";
         //end xml file
         $filename_xml = $JLMS_CONFIG->get('absolute_path') . '/media/export.xml';
         $handle = fopen($filename_xml, 'w');
         // try to write in XML file our xml-contents.
         if (fwrite($handle, $export_xml) === FALSE) {
             return array('lmsfile' => null, 'msg' => "Could not create writable XML file");
         }
         fclose($handle);
         $uniq = mktime();
         $dir = $lms_cfg_backup_folder . "/";
         //chmod($dir, '777');
         $backup_zip = $dir . 'course_backup_' . $course_id . '_' . $uniq . '.zip';
         $pz = new PclZip($backup_zip);
         //add _lms_course_files_ catalog
         $pz->create($filename_xml, '', $filename_xml = $JLMS_CONFIG->get('absolute_path') . '/media/');
         if (in_array('documents', $this->options)) {
             foreach ($files as $file) {
                 $filename = $file->_fromDir . $file->file_srv_name;
                 $pz->add($filename, 'files', $file->_fromDir);
             }
         }
         if (in_array('quizzes', $this->options)) {
             foreach ($questions as $question) {
                 foreach ($question as $quest) {
                     if (isset($quest->_c_image)) {
                         $filename = $extract_dir . $quest->_identifier . "/" . $quest->_c_image;
                         $pz->add($filename, 'quiz_images', $extract_dir . $quest->_identifier . "/" . substr($quest->_c_image, 0, strpos($quest->_c_image, '\\')) . "/");
                     }
                 }
             }
         }
     }
     // delete temporary files
     deldir($extract_dir);
     @unlink($archive);
     if (!$do_lms_archive) {
         return array('lmsfile' => 'none', 'msg' => _JLMS_COURSE_IMPORT_SUCCESS);
     }
     return array('lmsfile' => 'course_backup_' . $course_id . '_' . $uniq . '.zip', 'msg' => _JLMS_COURSE_IMPORT_SUCCESS);
 }
Пример #23
0
function jlms_booking_save($course_id, $option)
{
    global $my, $JLMS_DB, $Itemid, $JLMS_SESSION, $JLMS_CONFIG;
    $cid = intval(mosgetparam($_POST, 'p_id', 0));
    //$usertype = $JLMS_CONFIG->get('current_usertype', 0);
    $sel_option = intval(mosgetparam($_POST, "sel_option", 0));
    $from_time = mosgetparam($_POST, 'from_time', 0);
    $to_time = mosgetparam($_POST, 'to_time', 0);
    $from_minutes = mosgetparam($_POST, 'from_min', 0);
    $to_minutes = mosgetparam($_POST, 'to_min', 0);
    $teacher_id = intval(mosgetparam($_POST, 'teacher_id', 0));
    $c_public = intval(mosgetparam($_POST, 'c_public', 0));
    $p_name = strval(mosgetparam($_POST, 'p_name', ''));
    $p_description = strval(mosgetparam($_POST, 'p_description', ''));
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($course_id && $JLMS_ACL->CheckPermissions('conference', 'manage')) {
        //	if ( $course_id && ($usertype == 1)) {
        if (!defined('_JLMS_CONF_BOOK_EXISTS')) {
            define('_JLMS_CONF_BOOK_EXISTS', 'Conference with the same time period is already exists');
        }
        if ($cid) {
            $save_date = JLMS_dateToDB(mosGetParam($_REQUEST, 'start_date', date('Y-m-d')));
            $daytime_from = mktime($from_time, $from_minutes, 0, substr($save_date, 5, 2), substr($save_date, 8, 2), substr($save_date, 0, 4));
            $daytime_to = mktime($to_time, $to_minutes, 0, substr($save_date, 5, 2), substr($save_date, 8, 2), substr($save_date, 0, 4));
            if ($teacher_id) {
                $query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE teacher_id = {$teacher_id} AND ((from_time > " . $daytime_from . " AND from_time < " . $daytime_to . ") OR (to_time > " . $daytime_from . " AND to_time < " . $daytime_to . ") OR (from_time < " . $daytime_from . " AND to_time > " . $daytime_from . ") OR (from_time < " . $daytime_to . " AND to_time > " . $daytime_to . ") OR (from_time = " . $daytime_from . " AND to_time = " . $daytime_to . ")) AND p_id <> {$cid}";
            } else {
                $query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE course_id='" . $course_id . "' AND teacher_id = {$teacher_id} AND ((from_time > " . $daytime_from . " AND from_time < " . $daytime_to . ") OR (to_time > " . $daytime_from . " AND to_time < " . $daytime_to . ") OR (from_time < " . $daytime_from . " AND to_time > " . $daytime_from . ") OR (from_time < " . $daytime_to . " AND to_time > " . $daytime_to . ") OR (from_time = " . $daytime_from . " AND to_time = " . $daytime_to . ")) AND p_id <> {$cid}";
            }
            $JLMS_DB->setQuery($query);
            if ($JLMS_DB->LoadResult()) {
                echo "<script> alert('" . _JLMS_CONF_BOOK_EXISTS . "'); window.history.go(-1); </script>\n";
                exit;
            }
            if ($c_public) {
                $query = "SELECT count(*) FROM #__lms_conference_usr WHERE p_id = {$cid}";
                $JLMS_DB->setQuery($query);
                $is_subscribers = $JLMS_DB->LoadResult();
                if ($is_subscribers) {
                    $c_public = 0;
                }
            }
            $query = "UPDATE #__lms_conference_period SET teacher_id = {$teacher_id}, from_time = '" . $daytime_from . "',to_time= '" . $daytime_to . "',public = '" . $c_public . "',p_name = " . $JLMS_DB->Quote($p_name) . ", p_description = " . $JLMS_DB->Quote($p_description);
            $query .= "\n WHERE p_id = {$cid}";
            $JLMS_DB->setQuery($query);
            $JLMS_DB->query();
        } else {
            if ($sel_option) {
                $all_dates = array();
                if (count($_POST['weekday']) && count($_POST['monthday'])) {
                    foreach ($_POST['monthday'] as $month_year) {
                        $month = substr($month_year, 0, 2);
                        $year = substr($month_year, 3, 4);
                        $all_dates = Daysforweeks($_POST['weekday'], $month, $year);
                        if (count($all_dates)) {
                            foreach ($all_dates as $adata) {
                                $daytime_from = mktime($from_time, $from_minutes, 0, substr($adata, 5, 2), substr($adata, 8, 2), substr($adata, 0, 4));
                                $daytime_to = mktime($to_time, $to_minutes, 0, substr($adata, 5, 2), substr($adata, 8, 2), substr($adata, 0, 4));
                                //$query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE course_id='".$course_id."' AND teacher_id = $teacher_id AND ((from_time < ".$daytime_from." AND to_time > ".$daytime_from.") OR (from_time < ".$daytime_to." AND to_time > ".$daytime_to."))";
                                if ($teacher_id) {
                                    $query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE teacher_id = {$teacher_id} AND ((from_time > " . $daytime_from . " AND from_time < " . $daytime_to . ") OR (to_time > " . $daytime_from . " AND to_time < " . $daytime_to . ") OR (from_time < " . $daytime_from . " AND to_time > " . $daytime_from . ") OR (from_time < " . $daytime_to . " AND to_time > " . $daytime_to . ") OR (from_time = " . $daytime_from . " AND to_time = " . $daytime_to . "))";
                                } else {
                                    $query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE course_id='" . $course_id . "' AND teacher_id = {$teacher_id} AND ((from_time > " . $daytime_from . " AND from_time < " . $daytime_to . ") OR (to_time > " . $daytime_from . " AND to_time < " . $daytime_to . ") OR (from_time < " . $daytime_from . " AND to_time > " . $daytime_from . ") OR (from_time < " . $daytime_to . " AND to_time > " . $daytime_to . ") OR (from_time = " . $daytime_from . " AND to_time = " . $daytime_to . "))";
                                }
                                $JLMS_DB->setQuery($query);
                                if ($JLMS_DB->LoadResult()) {
                                    echo "<script> alert('" . _JLMS_CONF_BOOK_EXISTS . "'); window.history.go(-1); </script>\n";
                                    exit;
                                }
                                $query = "INSERT INTO #__lms_conference_period(course_id, teacher_id, from_time, to_time,public, p_name, p_description)";
                                $query .= "\n VALUES ('" . $course_id . "', {$teacher_id}, '" . $daytime_from . "','" . $daytime_to . "', {$c_public}, " . $JLMS_DB->Quote($p_name) . ", " . $JLMS_DB->Quote($p_description) . ")";
                                $JLMS_DB->setQuery($query);
                                $JLMS_DB->query();
                            }
                        }
                    }
                }
            } else {
                $save_date = JLMS_dateToDB(mosGetParam($_REQUEST, 'start_date', date('Y-m-d')));
                $daytime_from = mktime($from_time, $from_minutes, 0, substr($save_date, 5, 2), substr($save_date, 8, 2), substr($save_date, 0, 4));
                $daytime_to = mktime($to_time, $to_minutes, 0, substr($save_date, 5, 2), substr($save_date, 8, 2), substr($save_date, 0, 4));
                //$query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE course_id='".$course_id."' AND teacher_id = $teacher_id AND ((from_time < ".$daytime_from." AND to_time > ".$daytime_from.") OR (from_time < ".$daytime_to." AND to_time > ".$daytime_to."))";
                if ($teacher_id) {
                    $query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE teacher_id = {$teacher_id} AND ((from_time > " . $daytime_from . " AND from_time < " . $daytime_to . ") OR (to_time > " . $daytime_from . " AND to_time < " . $daytime_to . ") OR (from_time < " . $daytime_from . " AND to_time > " . $daytime_from . ") OR (from_time < " . $daytime_to . " AND to_time > " . $daytime_to . ") OR (from_time = " . $daytime_from . " AND to_time = " . $daytime_to . "))";
                } else {
                    $query = "SELECT COUNT(*) FROM #__lms_conference_period WHERE course_id='" . $course_id . "' AND teacher_id = {$teacher_id} AND ((from_time > " . $daytime_from . " AND from_time < " . $daytime_to . ") OR (to_time > " . $daytime_from . " AND to_time < " . $daytime_to . ") OR (from_time < " . $daytime_from . " AND to_time > " . $daytime_from . ") OR (from_time < " . $daytime_to . " AND to_time > " . $daytime_to . ") OR (from_time = " . $daytime_from . " AND to_time = " . $daytime_to . "))";
                }
                $JLMS_DB->setQuery($query);
                if ($JLMS_DB->LoadResult()) {
                    echo "<script> alert('" . _JLMS_CONF_BOOK_EXISTS . "'); window.history.go(-1); </script>\n";
                    exit;
                }
                $query = "INSERT INTO #__lms_conference_period(course_id, teacher_id, from_time,to_time,public,p_name,p_description)";
                $query .= "\n VALUES ('" . $course_id . "', {$teacher_id}, '" . $daytime_from . "','" . $daytime_to . "', {$c_public}, " . $JLMS_DB->Quote($p_name) . ", " . $JLMS_DB->Quote($p_description) . ")";
                $JLMS_DB->setQuery($query);
                $JLMS_DB->query();
            }
        }
    }
    JLMSRedirect(sefRelToAbs('index.php?option=' . $option . '&amp;task=conference&amp;mode=booking&amp;id=' . $course_id));
}
Пример #24
0
    function showCourseDetails($id, &$row, &$params, $option, &$lists, $view_type = 'view')
    {
        $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
        global $Itemid, $my, $JLMS_CONFIG, $JLMS_SESSION;
        $count_modules = 0;
        $JLMS_ACL =& JLMSFactory::getACL();
        if ($JLMS_ACL->GetRole() && !$JLMS_ACL->isStaff()) {
            if ($params->get('homework_view') && $JLMS_CONFIG->get('course_homework')) {
                $count_modules++;
            }
            if ($params->get('agenda_view')) {
                $count_modules++;
            }
            if ($params->get('dropbox_view')) {
                $count_modules++;
            }
            if ($params->get('mailbox_view')) {
                $count_modules++;
            }
            if ($params->get('certificates_view')) {
                $count_modules++;
            }
            if ($params->get('latest_forum_posts_view')) {
                $count_modules++;
            }
            if ($count_modules) {
                ?>
		
		<?php 
            }
        }
        JLMS_TMPL::OpenMT();
        $hparams = array();
        if ($view_type == 'view') {
            $hparams['simple_menu'] = true;
            $hparams['sys_msg'] = _JLMS_MESSAGE_SHORT_COURSE_INFO;
        }
        if ($view_type == 'offerWL') {
            $hparams['sys_msg'] = _JLMS_MESSAGE_OFFER_JOIN_WAITING_LIST;
        } elseif ($view_type == 'inWL') {
            $hparams['sys_msg'] = _JLMS_MESSAGE_ALREADY_IN_WATING_LIST;
            $JLMS_CONFIG->set('enableterms', 0);
        }
        if ($JLMS_SESSION->get('joomlalms_just_joined', 0)) {
            if (isset($hparams['sys_msg'])) {
                $hparams['sys_msg'] = $JLMS_SESSION->get('joomlalms_sys_message', '') . '<br />' . $hparams['sys_msg'];
            } else {
                $hparams['sys_msg'] = $JLMS_SESSION->get('joomlalms_sys_message', '');
            }
            $JLMS_SESSION->clear('joomlalms_just_joined');
        }
        $toolbar = array();
        $JLMS_ACL =& JLMSFactory::getACL();
        if ($JLMS_ACL->CheckPermissions('course', 'manage_settings')) {
            $toolbar[] = array('btn_type' => 'newtopic', 'btn_js' => "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=add_topic&amp;id={$id}", 'btn_str' => _JLMS_TOPIC_T_ADD);
            $toolbar[] = array('btn_type' => 'settings', 'btn_js' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=settings&amp;id={$id}"));
            $toolbar[] = array('btn_type' => 'edit', 'btn_js' => ampReplace(sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=edit_course&amp;id={$id}&amp;is_inside=1")));
        } elseif ($view_type == 'view' || $view_type == 'offerWL' || $view_type == 'inWL') {
            $hparams['simple_menu'] = true;
            if ($my->id && $row->self_reg && JLMS_checkCourseGID($my->id, $row->gid)) {
                //check that enrollment is available and user gid is allowed
                if ($row->paid) {
                    if ($view_type != 'inWL') {
                        $toolbar[] = array('btn_type' => 'yes', 'btn_str' => _JLMS_SUBSCRIBE, 'btn_js' => "javascript:submitbutton('subscription','');");
                    }
                } else {
                    if ($view_type != 'inWL') {
                        $toolbar[] = array('btn_type' => 'yes', 'btn_str' => _JLMS_SUBSCRIBE, 'btn_js' => "javascript:submitbutton('course_subscribe','');");
                    }
                }
                if ($view_type != 'inWL') {
                    $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=courses"));
                } else {
                    $toolbar[] = array('btn_type' => 'back', 'btn_js' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=courses"));
                }
                $hparams['toolbar_position'] = 'center';
                $html_code_before_toolbar = "\n\t\t\t\t<form action='" . sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}") . "' method='post' name='adminForm_enroll'>\n\t\t\t\t<script language='javascript' type='text/javascript'>\n\t\t\t\t\t<!--\n\n\t\t\t\t\tfunction submitbutton(pressbutton) {\n\t\t\t\t\t\tvar form = document.adminForm_enroll;";
                if ($JLMS_CONFIG->get('enableterms') && !$row->paid) {
                    $html_code_before_toolbar .= "\n\t\t\t\t\t\tif( (pressbutton == 'course_subscribe') && (document.getElementById('jlms_agreement').checked == false) ){\n\t\t\t\t\t\t\talert( '" . addslashes(_JLMS_AGREEMENT) . "' );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse{\n\t\t\t\t\t\t\tform.task.value = pressbutton;\n\t\t\t\t\t\t\tform.submit();\n\t\t\t\t\t\t}\n\t\t\t\t\t\t";
                } else {
                    $html_code_before_toolbar .= "\n\t\t\t\t\t\t\tform.task.value = pressbutton;\n\t\t\t\t\t\t\tform.submit();\n\t\t\t\t\t";
                }
                $html_code_before_toolbar .= "\n\t\t\t\t\t\t\t}\n\t\t\t\t\t//-->\n\t\t\t\t\t</script>\n\t\t\t\t\t";
                if ($JLMS_CONFIG->get('enableterms') && !$row->paid) {
                    $html_code_before_toolbar .= "\n\t\t\t\t\t<table align='center' class='jlms_table_no_borders'><tr><td width='20'>\n\t\t\t\t\t\t<input type='checkbox' name='agreement' id='jlms_agreement' />\n\t\t\t\t\t</td><td style='text-align:left'>\n\t\t\t\t\t\t<label for='jlms_agreement'>" . $JLMS_CONFIG->get('jlms_terms') . "</label>\n\t\t\t\t\t</td></tr></table>\n\t\t\t\t\t";
                }
                if ($row->paid) {
                    $html_code_before_toolbar .= "\n\t\t\t\t\t\t<input type='hidden' name='option' value='" . $option . "' />\n\t\t\t\t\t\t<input type='hidden' name='Itemid' value='" . $Itemid . "' />\n\t\t\t\t\t\t<input type='hidden' name='task' value='subscription' />\n\t\t\t\t\t\t<input type='hidden' name='cid[]' value='" . $row->id . "' />\n\t\t\t\t\t\t<input type='hidden' name='state' value='0' />\n\t\t\t\t\t\t</form>\n\t\t\t\t\t";
                } else {
                    $html_code_before_toolbar .= "\n\t\t\t\t\t\t<input type='hidden' name='option' value='" . $option . "' />\n\t\t\t\t\t\t<input type='hidden' name='Itemid' value='" . $Itemid . "' />\n\t\t\t\t\t\t<input type='hidden' name='task' value='courses' />\n\t\t\t\t\t\t<input type='hidden' name='id' value='" . $row->id . "' />\n\t\t\t\t\t\t<input type='hidden' name='state' value='0' />\n\t\t\t\t\t\t</form>\n\t\t\t\t\t";
                }
                $hparams['html_code_before_toolbar'] = $html_code_before_toolbar;
            } else {
                $toolbar[] = array('btn_type' => 'back', 'btn_js' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=courses"));
            }
        } elseif ($view_type == 'future_course') {
            $hparams['simple_menu'] = true;
            if ($row->publish_start) {
                $hparams['sys_msg'] = str_replace('{date}', JLMS_dateToDisplay($row->start_date), _JLMS_COURSE_IS_PENDING_MSG);
            } else {
                $query = "SELECT start_date FROM #__lms_users_in_groups WHERE course_id = " . $row->id . " AND user_id = " . $my->id;
                global $JLMS_DB;
                $JLMS_DB->SetQuery($query);
                $user_start = $JLMS_DB->LoadResult();
                $hparams['sys_msg'] = str_replace('{date}', JLMS_dateToDisplay($user_start), _JLMS_COURSE_USER_IS_PENDING);
            }
        }
        JLMS_TMPL::ShowHeader('course', _JLMS_COURSES_DETAILS, $hparams, $toolbar);
        $_JLMS_PLUGINS->loadBotGroup('system');
        $plugin_args = array();
        $plugin_args[] = $id;
        $_JLMS_PLUGINS->trigger('onAboveCourseDetailsPage', $plugin_args);
        if ($JLMS_ACL->GetRole() && !$JLMS_ACL->isStaff() && $count_modules) {
            $custom_sections = array();
            if ($JLMS_CONFIG->get('course_homework') && $params->get('homework_view')) {
                $txt = JLMS_showMyHomeWork($option, $Itemid, $lists['my_hw']);
                $custom_sections[] = array('text' => $txt, 'attrib' => ' valign="top"');
            }
            if ($params->get('agenda_view')) {
                $txt = JLMS_showMyAgenda($option, $Itemid, $lists['my_announcements']);
                $custom_sections[] = array('text' => $txt, 'attrib' => ' valign="top"');
            }
            if ($params->get('dropbox_view')) {
                $txt = JLMS_showMyDropBox($option, $Itemid, $lists['my_dropbox'], $lists);
                $custom_sections[] = array('text' => $txt, 'attrib' => ' valign="top"');
            }
            if ($params->get('mailbox_view')) {
                $txt = JLMS_showMyMailBox($option, $Itemid, $lists['my_mailbox'], $lists);
                $custom_sections[] = array('text' => $txt, 'attrib' => ' valign="top"');
            }
            if ($params->get('certificates_view')) {
                $txt = JLMS_showMyCertificates($option, $Itemid, $lists['my_certificates'], $lists);
                $custom_sections[] = array('text' => $txt, 'attrib' => ' valign="top"');
            }
            if ($JLMS_CONFIG->get('plugin_forum') && $params->get('latest_forum_posts_view')) {
                $txt = JLMS_showLatestForumPosts($option, $Itemid, $lists['latest_forum_posts'], $lists);
                $custom_sections[] = array('text' => $txt, 'attrib' => ' valign="top"');
            }
            JLMS_TMPL::ShowCustomSection($custom_sections, 1, 1);
        }
        $show_description = true;
        if ($JLMS_ACL->GetRole() && !$JLMS_ACL->isStaff()) {
            if (!$params->get('show_description', 1)) {
                $show_description = false;
            }
        }
        if ($show_description) {
            $text = JLMS_ShowText_WithFeatures($row->course_description);
            JLMS_TMPL::ShowSection($text);
        }
        //$_JLMS_PLUGINS->loadBotGroup('system');
        $plugin_args = array();
        $plugin_args[] = $id;
        $_JLMS_PLUGINS->trigger('onBelowCourseDescription', $plugin_args);
        /*Fix short course description + all comments*/
        if (isset($lists['short']) && !$lists['short']) {
            if ($JLMS_ACL->GetRole() && !$JLMS_ACL->isStaff()) {
                //show topics of the course
                global $JLMS_DB;
                $query = "SELECT count(*) FROM #__lms_topics WHERE course_id = {$id}";
                $JLMS_DB->SetQuery($query);
                $is_any_topic = $JLMS_DB->LoadResult();
                if ($is_any_topic) {
                    JLMS_TMPL::OpenTS();
                    $course = new JLMS_Course_HomePage($id);
                    $course->listTopics();
                    JLMS_TMPL::CloseTS();
                }
            }
        }
        //$_JLMS_PLUGINS->loadBotGroup('system');
        $plugin_args = array();
        $plugin_args[] = $id;
        $_JLMS_PLUGINS->trigger('onBelowCourseDetailsPage', $plugin_args);
        JLMS_TMPL::CloseMT();
    }
Пример #25
0
 function &_createACL($user_id)
 {
     require_once JPATH_SITE . DS . 'components' . DS . 'com_joomla_lms' . DS . 'includes' . DS . 'classes' . DS . 'lms.acl.php';
     $JLMS_DB = JLMSFactory::getDB();
     $JLMS_ACL = new JLMS_ACL($user_id, $JLMS_DB);
     return $JLMS_ACL;
 }
    function showCourseLinks($id, $option, &$rows)
    {
        $user = JLMSFactory::getUser();
        $db =& JFactory::getDbo();
        $JLMS_ACL =& JLMSFactory::getACL();
        $JLMS_CONFIG = JLMSFactory::getConfig();
        $Itemid = $JLMS_CONFIG->get('Itemid');
        ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if ( ((pressbutton == 'link_delete') || (pressbutton == 'pre_link_edit')) && (form.boxchecked.value == "0")){
		alert("<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
");
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
function submitbutton_order(pressbutton, item_id) {
	var form = document.adminForm;
	if ((pressbutton == 'link_orderup') || (pressbutton == 'link_orderdown')){
		if (item_id) {
		form.task.value = pressbutton;
		form.row_id.value = item_id;
		form.submit();
		}
	}
}
function submitbutton_change(pressbutton, state) {
	var form = document.adminForm;
	if (pressbutton == 'change_link'){
		if (form.boxchecked.value == "0") {
			alert("<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
");
		} else {
			form.task.value = pressbutton;
			form.state.value = state;
			form.submit();
		}
	}
}
function submitbutton_change2(pressbutton, state, cid_id) {
	var form = document.adminForm;
	if (pressbutton == 'change_link'){
		form.task.value = pressbutton;
		form.state.value = state;
		form.cid2.value = cid_id;
		form.submit();
	}
}
//--><!]]>
</script>
<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        JLMS_TMPL::ShowHeader('link', _JLMS_LINKS_COURSE_LINKS, $hparams);
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo $JLMS_CONFIG->get('live_site') . "/index.php?option={$option}&amp;Itemid={$Itemid}";
        ?>
" method="post" name="adminForm">
<?php 
        if (!empty($rows)) {
            ?>
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
            echo JLMSCSS::_('jlmslist');
            ?>
">
				<tr>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="20" class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="center">#</<?php 
            echo $JLMS_CONFIG->get('tableheader_tag', 'td');
            ?>
>
				<?php 
            if ($JLMS_ACL->CheckPermissions('links', 'manage') || $JLMS_ACL->CheckPermissions('links', 'publish')) {
                ?>
					<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 width="20" class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" align="center"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php 
                echo count($rows);
                ?>
);" /></<?php 
                echo $JLMS_CONFIG->get('tableheader_tag', 'td');
                ?>
>
				<?php 
            }
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="40%"><?php 
            echo _JLMS_LINKS_TBL_HEAD_LINK;
            ?>
</<?php 
            echo $JLMS_CONFIG->get('tableheader_tag', 'td');
            ?>
>
				<?php 
            if ($JLMS_ACL->CheckPermissions('links', 'publish')) {
                ?>
					<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">&nbsp;</<?php 
                echo $JLMS_CONFIG->get('tableheader_tag', 'td');
                ?>
>
				<?php 
            }
            if ($JLMS_ACL->CheckPermissions('links', 'order')) {
                ?>
					<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" colspan="2" width="1">&nbsp;</<?php 
                echo $JLMS_CONFIG->get('tableheader_tag', 'td');
                ?>
>
				<?php 
            }
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="60%"><?php 
            echo _JLMS_LINKS_TBL_HEAD_DESCR;
            ?>
</<?php 
            echo $JLMS_CONFIG->get('tableheader_tag', 'td');
            ?>
>
				</tr>
			<?php 
            $there_were_squeezeboxes = false;
            $k = 1;
            for ($i = 0, $n = count($rows); $i < $n; $i++) {
                $is_squeezebox = false;
                $row = $rows[$i];
                $link = $row->link_href;
                if ($row->link_type == 2) {
                    $link = sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=view_inline_link&course_id={$id}&id={$row->id}");
                }
                if ($row->link_type == 3) {
                    $is_squeezebox = true;
                    $there_were_squeezeboxes = true;
                }
                $alt = $row->published ? _JLMS_STATUS_PUB : _JLMS_STATUS_UNPUB;
                $image = $row->published ? 'btn_accept.png' : 'btn_cancel.png';
                $state = $row->published ? 0 : 1;
                if ($row->is_time_related) {
                    $tooltip_txt = _JLMS_WILL_BE_RELEASED_IN;
                    $showperiod = $row->show_period;
                    $ost1 = $showperiod % (24 * 60);
                    $sp_days = ($showperiod - $ost1) / (24 * 60);
                    $ost2 = $showperiod % 60;
                    $sp_hours = ($ost1 - $ost2) / 60;
                    $sp_mins = $ost2;
                    $release_time_info = false;
                    if ($sp_days) {
                        $tooltip_txt .= ' ' . $sp_days . ' ' . _JLMS_RELEASED_IN_DAYS;
                        $release_time_info = true;
                    }
                    if ($sp_hours) {
                        $tooltip_txt .= ' ' . $sp_hours . ' ' . _JLMS_RELEASED_IN_HOURS;
                        $release_time_info = true;
                    }
                    if ($sp_mins) {
                        $tooltip_txt .= ' ' . $sp_mins . ' ' . _JLMS_RELEASED_IN_MINUTES;
                        $release_time_info = true;
                    }
                    if ($release_time_info) {
                        $tooltip_txt .= ' ' . _JLMS_RELEASED_AFTER_ENROLLMENT;
                    }
                }
                $checked = mosHTML::idBox($i, $row->id);
                ?>
				<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
					<td align="center"><?php 
                echo $i + 1;
                ?>
</td>
				<?php 
                if ($JLMS_ACL->CheckPermissions('links', 'manage') || $JLMS_ACL->CheckPermissions('links', 'publish')) {
                    $show_check = true;
                    if ($JLMS_ACL->CheckPermissions('links', 'only_own_items') && $row->owner_id != $user->get('id')) {
                        $show_check = false;
                    } elseif ($JLMS_ACL->CheckPermissions('links', 'only_own_role') && $JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($db, $row->owner_id)) {
                        $show_check = false;
                    }
                    ?>
					<td>
					<?php 
                    echo $show_check ? $checked : '&nbsp;';
                    ?>
					</td>
				<?php 
                }
                ?>
					<td align="left">
						<?php 
                if ($is_squeezebox) {
                    $tmp_params = new JLMSParameters($row->params);
                    $x_size = 0;
                    $y_size = 0;
                    if (is_object($tmp_params) && $tmp_params->get('display_width')) {
                        $x_size = intval($tmp_params->get('display_width'));
                    } elseif (isset($tmp_params->display_width)) {
                        $x_size = intval($tmp_params->display_width);
                    }
                    if (is_object($tmp_params) && $tmp_params->get('display_height')) {
                        $y_size = intval($tmp_params->get('display_height'));
                    } elseif (isset($tmp_params->display_height)) {
                        $y_size = intval($tmp_params->display_height);
                    }
                    ?>
							<a class="jlms_modal" rel="{handler:'iframe', size:{x:<?php 
                    echo $x_size;
                    ?>
,y:<?php 
                    echo $y_size;
                    ?>
}}" href="<?php 
                    echo $link;
                    ?>
" title="<?php 
                    echo str_replace('"', '&quot;', $row->link_name);
                    ?>
">
								<?php 
                    echo $row->link_name;
                    ?>
							</a>
						<?php 
                } else {
                    ?>
							<?php 
                    if ($link) {
                        ?>
							<a <?php 
                        echo !$row->link_type ? 'target="_blank" ' : ' ';
                        ?>
href="<?php 
                        echo $link;
                        ?>
" title="<?php 
                        echo str_replace('"', '&quot;', $row->link_name);
                        ?>
">
								<?php 
                        echo $row->link_name;
                        ?>
							</a>
							<?php 
                    } else {
                        echo $row->link_name;
                    }
                    ?>
						<?php 
                }
                ?>
						<?php 
                if ($JLMS_CONFIG->get('show_links_authors', 0)) {
                    ?>
						<br />
						<span class="small"><?php 
                    echo _JLMS_HOME_AUTHOR . "&nbsp;" . $row->author_name;
                    ?>
</span>
						<?php 
                }
                ?>
					</td>
				<?php 
                if ($JLMS_ACL->CheckPermissions('links', 'publish')) {
                    ?>
					<td valign="middle">
					<?php 
                    if ($JLMS_ACL->CheckPermissions('links', 'only_own_items') && $row->owner_id != $user->get('id')) {
                        ?>
						<img class="JLMS_png" src="<?php 
                        echo $JLMS_CONFIG->get('live_site');
                        ?>
/components/com_joomla_lms/lms_images/toolbar/<?php 
                        echo $image;
                        ?>
" width="16" height="16" border="0" alt="<?php 
                        echo $alt;
                        ?>
" />
					<?php 
                    } elseif ($JLMS_ACL->CheckPermissions('links', 'only_own_role') && $JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($db, $row->owner_id)) {
                        ?>
						<img class="JLMS_png" src="<?php 
                        echo $JLMS_CONFIG->get('live_site');
                        ?>
/components/com_joomla_lms/lms_images/toolbar/<?php 
                        echo $image;
                        ?>
" width="16" height="16" border="0" alt="<?php 
                        echo $alt;
                        ?>
" />
					<?php 
                    } else {
                        if ($row->is_time_related) {
                            if ($row->published) {
                                $image = 'btn_publish_wait.png';
                            }
                            $tooltip_link = 'javascript:submitbutton_change2(\'change_link\',' . $state . ',' . $row->id . ')';
                            $tooltip_name = '<img class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . $image . '" width="16" height="16" border="0" alt="' . $alt . '" />';
                            echo JLMS_toolTip($alt, $tooltip_txt, $tooltip_name, $tooltip_link);
                        } else {
                            echo '<a href="javascript:submitbutton_change2(\'change_link\',' . $state . ',' . $row->id . ')" title="' . $alt . '">';
                            echo '<img class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . $image . '" width="16" height="16" border="0" alt="' . $alt . '" />';
                            echo '</a>';
                        }
                    }
                    ?>
					</td>
				<?php 
                }
                if ($JLMS_ACL->CheckPermissions('links', 'order')) {
                    ?>
					<td><?php 
                    echo JLMS_orderUpIcon($i, $row->id, true, 'link_orderup');
                    ?>
</td>
					<td><?php 
                    echo JLMS_orderDownIcon($i, $n, $row->id, true, 'link_orderdown');
                    ?>
</td>
				<?php 
                }
                ?>
					<td><?php 
                echo $row->link_description ? $row->link_description : '&nbsp;';
                ?>
</td>
				</tr>
				<?php 
                $k = 3 - $k;
            }
            ?>
			</table>
<?php 
            if ($there_were_squeezeboxes) {
                JLMS_initialize_SqueezeBox(false);
            }
        } else {
            echo '<div class="joomlalms_user_message">' . _JLMS_NO_ITEMS_HERE . '</div>';
        }
        ?>
			<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
			<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
			<input type="hidden" name="task" value="setup_category" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
			<input type="hidden" name="row_id" value="0" />
			<input type="hidden" name="state" value="0" />
			<input type="hidden" name="cid2" value="0" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        if ($id && ($JLMS_ACL->CheckPermissions('links', 'manage') || $JLMS_ACL->CheckPermissions('links', 'publish'))) {
            $link_new = JLMSRoute::_("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=pre_create_link&amp;id={$id}");
            $controls = array();
            if ($JLMS_ACL->CheckPermissions('links', 'publish')) {
                $controls[] = array('href' => "javascript:submitbutton_change('change_link',1);", 'title' => _JLMS_SET_PUB, 'img' => 'publish');
                $controls[] = array('href' => "javascript:submitbutton_change('change_link',0);", 'title' => _JLMS_SET_UNPUB, 'img' => 'unpublish');
                if ($JLMS_ACL->CheckPermissions('links', 'manage')) {
                    $controls[] = array('href' => 'spacer');
                }
            }
            if ($JLMS_ACL->CheckPermissions('links', 'manage')) {
                $controls[] = array('href' => $link_new, 'onclick' => "", 'title' => _JLMS_LINKS_IMG_NEW_LINK, 'img' => 'add');
                $controls[] = array('href' => "javascript:submitbutton('link_delete');", 'title' => _JLMS_LINKS_IMG_DEL_LINK, 'img' => 'delete');
                $controls[] = array('href' => "javascript:submitbutton('pre_link_edit');", 'title' => _JLMS_LINKS_IMG_EDIT_LINK, 'img' => 'edit');
            }
            JLMS_TMPL::ShowControlsFooter($controls);
        }
        JLMS_TMPL::CloseMT();
    }
Пример #27
0
function JLMS_showTopMenu($id, $option, $with_back = false, $back_link = '', $help_task = '', $gqp = false)
{
    global $my, $Itemid, $JLMS_SESSION, $JLMS_CONFIG, $JLMS_LANGUAGE;
    $back_status = $JLMS_SESSION->has('jlms_section') ? $JLMS_SESSION->get('jlms_section') : '&nbsp;';
    //$back_status = $gqp?(_JLMS_TOOLBAR_GQP_PARENT):$back_status;
    if (!$help_task) {
        $help_task = $JLMS_SESSION->get('jlms_task');
    }
    $user_access = $JLMS_CONFIG->get('current_usertype');
    if ($user_access == 2) {
        $help_task = "stu_" . $help_task;
    } elseif ($user_access == 6) {
        $help_task = "ceo_" . $help_task;
    }
    $menus = $JLMS_CONFIG->get('jlms_menu');
    JLMS_require_lang($JLMS_LANGUAGE, 'main.lang', $JLMS_CONFIG->get('default_language'));
    if ($JLMS_CONFIG->get('lofe_show_course_box', true) && $JLMS_CONFIG->get('lofe_box_type', 1) || $JLMS_CONFIG->get('lofe_show_head', true) && $JLMS_CONFIG->get('lofe_show_top', true)) {
        ?>
	<script language="JavaScript" type="text/javascript">
	<!--//--><![CDATA[//><!--
	<?php 
        $add_js = '';
        if ($JLMS_CONFIG->get('lofe_show_head', true) && $JLMS_CONFIG->get('lofe_show_top', true)) {
            $add_js = "\n\t\t\tfunction jlms_ShowTBToolTip(txt_tooltip) {\n\t\t\t\t\t\$('JLMS_toolbar_tooltip').innerHTML = txt_tooltip;\n\t\t\t}\n\t\t";
        }
        if ($JLMS_CONFIG->get('lofe_show_course_box', true) && $JLMS_CONFIG->get('lofe_box_type', 1)) {
            $add_js .= "\n\t\t\tfunction jlms_redirect(redirect_url) {\n\t\t\t\ttop.location.href = redirect_url;\n\t\t\t}\n\t\t\tfunction jlms_tr_over(td) {\n\t\t\t\ttd.style['background'] = '#FFFFFF';\t\t\t\n\t\t\t}\n\t\t\tfunction jlms_tr_out(td) {\n\t\t\t\ttd.style['background'] = '#EEEEEE';\t\t\t\n\t\t\t}\n\t\t\tJLMS_preloadImages('" . $JLMS_CONFIG->getCfg('live_site') . "/components/com_joomla_lms/lms_images/front_menu/menu_bg3.png');\n\t\t\t";
        }
        if ($add_js) {
            $JLMS_CONFIG->set('jlms_aditional_js_code', $JLMS_CONFIG->get('jlms_aditional_js_code', '') . $add_js);
        }
        ?>
	//--><!]]>
	</script>
<?php 
    }
    if ($JLMS_CONFIG->get('lofe_show_top', true) || $JLMS_CONFIG->get('lofe_show_course_box', true)) {
        ?>
	<table cellpadding="0" cellspacing="0" border="0" align="right" class="jlms_top_menu_outer">
	<?php 
        if ($JLMS_CONFIG->get('lofe_show_head', true) && $JLMS_CONFIG->get('lofe_show_top', true)) {
            ?>
	<tr><td align="center" style="text-align:center ">
		<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="jlms_top_menu_tooltips">
		<tr>
			<td align="center" width="100%" style="text-align:center ">
				<span id="JLMS_toolbar_tooltip"><?php 
            echo $back_status;
            ?>
</span>
			</td>
			<?php 
            //if ($JLMS_CONFIG->get('current_usertype') == 1) {
            /*if (false) { ?>
            		<td align="right" nowrap="nowrap" style="white-space:nowrap ">
            		<?php $u = JLMS_getOnlineUsers( $id );?>
            			<a href="<?php echo sefRelToAbs("index.php?option=$option&amp;Itemid=$Itemid&amp;task=online_users&amp;course_id=$id");?>"><?php echo (_JLMS_ONLINE_USERS.' '.count($u));?></a>
            		</td>
            		<?php }*/
            ?>
		</tr>
		</table>
	</td></tr>
	<?php 
        }
        if ($JLMS_CONFIG->get('lofe_show_top', true)) {
            ?>
	<tr><td nowrap="nowrap" style="white-space:nowrap; text-align:right " align="right">
	<?php 
            $script = 0;
            $imh = '16';
            //$JLMS_CONFIG->get('top_menu_type');
            $imp = 'toolbar';
            if (!$JLMS_CONFIG->get('lofe_menu_style', 1)) {
                $imp = 'toolbar';
                $imh = '16';
            } elseif ($JLMS_CONFIG->get('lofe_menu_style', 1) == 1) {
                $imp = 'toolbar_24';
                $imh = '24';
            } elseif ($JLMS_CONFIG->get('lofe_menu_style', 1) == 2) {
                $imp = 'toolbar_32';
                $imh = '32';
            }
            /*if ($imh == 32) {
            		$imp = 'toolbar_32';
            	} elseif ($imh == 22) {
            		$imp = 'toolbar_22';
            	} elseif ($imh == 24) {
            		$imp = 'toolbar_24';
            	}*/
            $help_link = $JLMS_CONFIG->get('jlms_help_link', "http://www.joomlalms.com/index.php?option=com_lms_help&Itemid=40&task=view_by_task&key={toolname}");
            $was_separator = false;
            $JLMS_ACL =& JLMSFactory::getACL();
            //	echo '<pre>';
            //	print_r($menus);
            //	echo '</pre>';
            foreach ($menus as $menu) {
                $disabled = 0;
                if (isset($menu->disabled) && $menu->disabled) {
                } else {
                    $is_shown = true;
                    if ($menu->is_separator) {
                        if (!$was_separator) {
                            echo '<img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/spacer.png" border="0" width="2" height="' . $imh . '" style="background-color:#666666 " alt=" " />';
                        }
                        $was_separator = true;
                    } else {
                        if ($menu->task == 'view_all_notices' && !$JLMS_CONFIG->get('flms_integration', 0)) {
                        } else {
                            // check user permissions (14.09.2008 - DEN)
                            /*if (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_DOCS') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('docs');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_QUIZZES') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('quizzes');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_LINKS') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('links');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_LPATH') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('lpaths');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_AGENDA') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('announce');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_ATTEND') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('attendance');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_CHAT') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('chat');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_CONF') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('conference');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_GRADEBOOK') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('gradebook');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_TRACK') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('tracking');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_MAILBOX') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('mailbox');
                            		} elseif (isset($menu->lang_var) && $menu->lang_var == '_JLMS_TOOLBAR_USERS') {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('users');
                            		} elseif (isset($menu->user_options) && $menu->user_options) {
                            			$is_shown = $JLMS_ACL->CheckToolPermissions('user_settings');
                            		}*/
                            if ($is_shown) {
                                $was_separator = false;
                                if (isset($menu->help_task) && $menu->help_task) {
                                    $help_link = ampReplace(str_replace('{toolname}', $help_task, $help_link));
                                    $menu->menulink = $help_link;
                                }
                                if (isset($menu->user_options) && $menu->user_options) {
                                } else {
                                    $lang_var_menu = '';
                                    if ($menu->lang_var && defined($menu->lang_var)) {
                                        $lang_var_menu = constant($menu->lang_var);
                                    } elseif (isset($JLMS_LANGUAGE[$menu->lang_var]) && $JLMS_LANGUAGE[$menu->lang_var]) {
                                        $lang_var_menu = $JLMS_LANGUAGE[$menu->lang_var];
                                    }
                                    $add = '';
                                    if ($JLMS_CONFIG->get('lofe_show_head', true)) {
                                        $add = "onmouseover='javascript:jlms_ShowTBToolTip(\"" . $lang_var_menu . "\");jlms_WStatus(\"" . $lang_var_menu . "\");return true;' " . $menu->target . " onmouseout='javascript:jlms_ShowTBToolTip(\"" . $back_status . "\");jlms_WStatus(\"\");return true;'";
                                    }
                                    ?>
							<a <?php 
                                    echo $add;
                                    ?>
 class="jlms_menu_control" href="<?php 
                                    echo $menu->menulink;
                                    ?>
" title="<?php 
                                    echo $lang_var_menu;
                                    ?>
"><img class='JLMS_png' src="<?php 
                                    echo $JLMS_CONFIG->get('live_site');
                                    ?>
/components/com_joomla_lms/lms_images/<?php 
                                    echo $imp . "/" . $menu->image;
                                    ?>
" border="0" width="<?php 
                                    echo $imh;
                                    ?>
" height="<?php 
                                    echo $imh;
                                    ?>
" alt="<?php 
                                    echo $lang_var_menu;
                                    ?>
" title="<?php 
                                    echo $lang_var_menu;
                                    ?>
" /></a>
							<?php 
                                }
                            }
                        }
                    }
                    if (isset($menu->user_options) && $menu->user_options && $is_shown) {
                        $script = 1;
                        $add = '';
                        if ($JLMS_CONFIG->get('lofe_show_head', true)) {
                            $add = " onmouseover='javascript:jlms_ShowTBToolTip(\"" . _JLMS_TOOLBAR_USER_OPTIONS . "\");jlms_WStatus(\"" . _JLMS_TOOLBAR_USER_OPTIONS . "\");return true;' onmouseout='javascript:jlms_ShowTBToolTip(\"" . $back_status . "\");jlms_WStatus(\"\");return true;'";
                        }
                        ?>
				<a id="jlms_plugins_run"<?php 
                        echo $add;
                        ?>
 class="jlms_menu_control" href="javascript:void(0);" title="<?php 
                        echo _JLMS_TOOLBAR_TO_TEACH;
                        ?>
"><img class='JLMS_png' src="<?php 
                        echo $JLMS_CONFIG->get('live_site');
                        ?>
/components/com_joomla_lms/lms_images/<?php 
                        echo $imp . "/" . $menu->image;
                        ?>
" border="0" width="<?php 
                        echo $imh;
                        ?>
" height="<?php 
                        echo $imh;
                        ?>
" alt="<?php 
                        echo _JLMS_TOOLBAR_USER_OPTIONS;
                        ?>
" title="<?php 
                        echo _JLMS_TOOLBAR_USER_OPTIONS;
                        ?>
" /></a>
			<?php 
                    }
                }
            }
            echo "<br />";
            echo "</td></tr>";
        }
        if (!$gqp) {
            if ($JLMS_CONFIG->get('lofe_show_course_box', true)) {
                $cid = $JLMS_CONFIG->get('teacher_in_courses', array());
                $cid = array_merge($cid, $JLMS_CONFIG->get('student_in_courses', array()));
                $cid = array_merge($cid, $JLMS_CONFIG->get('parent_in_courses', array()));
                $cid = array_unique($cid);
                $courses = JLMS_CoursesNames($cid);
                $cur_course = 'undefined';
                foreach ($courses as $course) {
                    if ($id == $course->id) {
                        $cur_course = $course->course_name;
                    }
                    //substr($course->course_name,0,15);}
                }
                ?>
	<tr>
	<td align="right" style="text-align:right ">
		<?php 
                if (false) {
                    ?>
		<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<tr>
				<td align="right" nowrap="nowrap" style="text-align:right; font-size:10px; line-height:1.5">
					<?php 
                    echo _JLMS_CURRENT_COURSE;
                    ?>
				</td>
				<td width="120">
					<table width="120" cellpadding="0" cellspacing="0" border="0" align="right">
					<tr>
						<td colspan="2" align="left" style="text-align:left; background:url(<?php 
                    echo $JLMS_CONFIG->getCfg('live_site');
                    ?>
/components/com_joomla_lms/lms_images/front_menu/menu_bg.png) no-repeat; ">

						<table style="cursor:pointer; border-bottom:1px solid #666666; width:220px;" id="demo1run1" width="220" cellpadding="0" cellspacing="0" border="0"><tr><td align="left">
							<div style="cursor:pointer; overflow:hidden; white-space:nowrap; width:200px;" >&nbsp;&nbsp;<?php 
                    echo $cur_course;
                    ?>
</div>
						</td><td align="right" width="20"><img class="JLMS_png" src="<?php 
                    echo $JLMS_CONFIG->get('live_site');
                    ?>
/components/com_joomla_lms/lms_images/course_select_arrow.png" alt="select_arrow" title="select_arrow" border="0" width="10" height="10" />&nbsp;&nbsp;</td></tr></table>
						<div align="right" id="course_menu_cont" style="position: absolute; visibility: hidden; width: 220px; font-size:10px; line-height:1.5">
						<div>
							<div id="demo1">
							<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_top_menu_items_table" id="jlms_top_menu_items_table_id">
								<?php 
                    $i = 0;
                    foreach ($courses as $course) {
                        $link = ampReplace(sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=" . $JLMS_SESSION->get('jlms_task') . "&amp;id={$course->id}"));
                        echo "<tr id='cmenu_" . $i . "' onmouseover=\"jlms_tr_over(this);\" onmouseout=\"jlms_tr_out(this);\" onclick=\"jlms_redirect('" . $link . "');\"><td align='left'><div>&nbsp;" . ($id == $course->id ? '<b>' . $course->course_name . '</b>' : $course->course_name) . "</div></td></tr>";
                        $i++;
                    }
                    ?>
									<tr style='cursor:pointer; background:url(<?php 
                    echo $JLMS_CONFIG->getCfg('live_site');
                    ?>
/components/com_joomla_lms/lms_images/front_menu/menu_bg2.png) no-repeat; background-position: bottom;'><td style="height:4px; border:0px"></td></tr>
							</table>
							</div>
						</div>
						<?php 
                    if ($JLMS_CONFIG->get('web20_effects', true)) {
                        $domready = '
					var demo1effect = new Fx.Slide(\'demo1\');
					demo1effect.hide();
					$(\'course_menu_cont\').setStyle(\'visibility\', \'visible\');
					$(\'demo1run1\').addEvent(\'click\', function(e){
						e = new Event(e);
						demo1effect.toggle();
						e.stop();
					});
							';
                        $JLMS_CONFIG->set('web20_domready_code', $JLMS_CONFIG->get('web20_domready_code', '') . $domready);
                    } else {
                        $domready = '
					var course_menu_hidden = true;
					$(\'demo1run1\').addEvent(\'click\', function(e){
						e = new Event(e);
						if (course_menu_hidden) {
							$(\'course_menu_cont\').setStyle(\'visibility\', \'visible\');
							course_menu_hidden = false;
						} else {
							$(\'course_menu_cont\').setStyle(\'visibility\', \'hidden\');
							course_menu_hidden = true;
						}
						e.stop();
					});
							';
                        $JLMS_CONFIG->set('web20_domready_code', $JLMS_CONFIG->get('web20_domready_code', '') . $domready);
                    }
                    ?>
						</div>
						</td>
					</tr>
					</table>
				</td>
			</tr>
		</table>
		<?php 
                } else {
                    $add_js = "\n\t\tfunction jlms_redirect_form(sel_element) {\n\t\t\tvar id = sel_element.options[sel_element.selectedIndex].value;\n\t\t\tvar redirect_url = '';\n\t\t\tswitch (id) {\n";
                    foreach ($courses as $course) {
                        $add_js .= "\n\t\t\t\tcase '{$course->id}':\n\t\t\t\t\tredirect_url = '" . str_replace('&amp;', '&', sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=" . $JLMS_SESSION->get('jlms_task') . "&id=" . $course->id)) . "'\n\t\t\t\tbreak;\n";
                    }
                    $add_js .= "\n\t\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (redirect_url) {\n\t\t\t\ttop.location.href = redirect_url;\n\t\t\t}\n\t\t}\n\t\t";
                    $JLMS_CONFIG->set('jlms_aditional_js_code', $JLMS_CONFIG->get('jlms_aditional_js_code', '') . $add_js);
                    ?>
		<table cellpadding="0" cellspacing="0" border="0" style="float:right" class="jlms_coursebox_cont">
			<tr>
				<td align="right" nowrap="nowrap">
					<?php 
                    echo _JLMS_CURRENT_COURSE;
                    ?>
				</td>
				<td width="120" nowrap="nowrap">
					<form name="jlms_change_course" action="<?php 
                    echo sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}");
                    ?>
" method="post">
				<noscript>
					<input type="hidden" name="option" value="<?php 
                    echo $option;
                    ?>
" />
					<input type="hidden" name="Itemid" value="<?php 
                    echo $Itemid;
                    ?>
" />
					<input type="hidden" name="task" value="<?php 
                    echo $JLMS_SESSION->get('jlms_task');
                    ?>
" />
				</noscript>
					<table cellpadding="0" cellspacing="0" border="0" class="jlms_coursebox"><tr><td>
					<select name="id" style="width:200px; border:1px solid #666666;" onchange="jlms_redirect_form(this)">
					<?php 
                    $i = 0;
                    foreach ($courses as $course) {
                        echo '<option value="' . $course->id . '"' . ($id == $course->id ? ' selected="selected"' : '') . '>' . $course->course_name . '</option>';
                        $i++;
                    }
                    ?>
					</select>
					</td><td>
					<noscript>
						<input type="submit" name="OK" value="OK" />
					</noscript>
				</td></tr></table>
					</form>
				</td>
			</tr>
		</table>
		<?php 
                }
                ?>
	</td>
	</tr>
<?php 
            }
        }
        ?>
	</table>
<?php 
    }
}
    function jlms_conference_archive($course_id, $option, $records, $pageNav)
    {
        global $my, $Itemid, $JLMS_CONFIG, $JLMS_SESSION;
        //$usertype = $JLMS_CONFIG->get('current_usertype') ;
        $JLMS_ACL =& JLMSFactory::getACL();
        ?>
	
	
	<script type="text/javascript" language="javascript">
	<!--//--><![CDATA[//><!--
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if ( form.boxchecked.value == "0" ){
			alert("<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
");
		} else {
			if (pressbutton == 'record_delete'){
				if (confirm("<?php 
        echo 'Are you sure?';
        ?>
") == true){
					form.mode.value = pressbutton;
					form.submit();
				}
			}else{
				form.mode.value = pressbutton;
				form.submit();
			}
		}
	}
	function startAppPlayback(path)
	{
		var y= (screen.height/2) - 359;
		var x= (screen.width/2) - 510 ;
		window.open(path,'Conference_playback','top='+y+', left='+x+',width=995, height=640, scrollbars=no, status=0, toolbar=no, resizable=yes');
	}
	function submitbutton_change(pressbutton, state) {
		var form = document.adminForm;
		if (pressbutton == 'change_record'){
			if (form.boxchecked.value == "0") {
				alert("<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
");
			} else {
				form.mode.value = pressbutton;
				form.state.value = state;
				form.submit();
			}
		}
	}
	function submitbutton_change_record(pressbutton, state, cid_id) {
		var form = document.adminForm;
		if (pressbutton == 'change_record'){
			form.mode.value = pressbutton;
			form.state.value = state;
			form.cid2.value = cid_id;
			form.submit();
		}
	}
	//--><!]]>
	</script>
	<?php 
        JLMS_TMPL::OpenMT();
        $params = array('show_menu' => true);
        JLMS_TMPL::ShowHeader('conference', _JLMS_HEAD_CONF_STR, $params);
        JLMS_TMPL::OpenTS();
        //'', ' align="right" style="text-align:right " width="100%"');
        ?>
		<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
			<tr>
				<td colspan="2">
					&nbsp;
				</td>
				<td style="text-align:right;"><br />
					<?php 
        $toolbar = array();
        //$toolbar[] = array('btn_type' => 'edit', 'btn_js' => sefRelToAbs("index.php?option=$option&amp;Itemid=$Itemid&amp;task=conference&amp;id=$course_id&amp;mode=archive") );
        $toolbar[] = array('btn_type' => 'back', 'btn_js' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=conference&amp;id={$course_id}"));
        echo JLMS_ShowToolbar($toolbar);
        ?>
				</td>
			</tr>
		</table>
<?php 
        JLMS_TMPL::CloseTS();
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}");
        ?>
" method="post" name="adminForm">
			<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
        echo JLMSCSS::_('jlmslist');
        ?>
">
				<tr>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="left" width="15">#</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<?php 
        if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" align="left" width="10"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php 
            echo count($records);
            ?>
);" /></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
        }
        ?>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" width="25%" align="left"><?php 
        echo _JLMS_CONFERENCE_RECORD;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<?php 
        if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="140" align="left"><?php 
            echo _JLMS_CONFERENCE_SESSION;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
        }
        ?>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" width="110" align="left"><?php 
        echo _JLMS_CONFERENCE_RECORD_START;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<?php 
        if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
            ?>
					<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="50" align="center">&nbsp;</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
        }
        ?>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
">&nbsp;</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" width="100" align="center" style="text-align:center;"><?php 
        echo _JLMS_CONFERENCE_RECORD_PB;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					
				</tr>
			<?php 
        $k = 1;
        for ($i = 0, $n = count($records); $i < $n; $i++) {
            $row = $records[$i];
            $link = sefRelToAbs("index.php?option=" . $option . "&Itemid=" . $Itemid . "&task=details_course&id=" . $row->id);
            $checked = mosHTML::idBox($i, $row->id);
            $overlib_descr = JLMS_txt2overlib($row->description);
            $overlib_title = "Description";
            ?>
				<tr valign="middle" style="vertical-align:middle" class="<?php 
            echo JLMSCSS::_('sectiontableentry' . $k);
            ?>
">
					<td align="left"><?php 
            echo $pageNav->limitstart + $i + 1;
            ?>
</td>
					<?php 
            if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
                ?>
					<td align="left"><?php 
                echo $checked;
                ?>
</td>
					<?php 
            }
            ?>
					<td align="left">
						<?php 
            $inside_tag = $row->record_name ? $row->record_name : "Record";
            $link_href = "javascript:startAppPlayback('" . $JLMS_CONFIG->get('live_site') . '/index.php?tmpl=component&option=com_joomla_lms&amp;task=conference&amp;mode=conference_playback&amp;Itemid=' . $Itemid . '&amp;id=' . $course_id . '&amp;name=' . $row->session_name . "');";
            echo JLMS_toolTip($overlib_title, $overlib_descr, $inside_tag, $link_href);
            ?>
						<br />
						<span class="small"><?php 
            echo _JLMS_HOME_AUTHOR . "&nbsp;" . $row->username;
            ?>
</span>
					</td>
					<?php 
            if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
                ?>
					<td align="left">
					<?php 
                echo $row->session_name;
                /*
                	<a href="javascript:startAppPlayback('<?php echo sefRelToAbs('index.php?tmpl=component&option=com_joomla_lms&task=conference&mode=conference_playback&Itemid='.$Itemid.'&id='.$course_id.'&name='.$row->record_name );?>');" title="View details">
                		<?php echo $row->session_name;?>
                	</a>
                */
                ?>
	
					</td>
					<?php 
            }
            ?>
					<td align="left"><?php 
            echo JLMS_dateToDisplay($row->start_date);
            ?>
</td>
					<?php 
            if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
                ?>
					<td align="center" valign="middle">
						<?php 
                if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
                    $alt = $row->published ? _JLMS_STATUS_PUB : _JLMS_STATUS_UNPUB;
                    $image = $row->published ? 'btn_accept.png' : 'btn_cancel.png';
                    $state = $row->published ? 0 : 1;
                    echo '<a href="javascript:submitbutton_change_record(\'change_record\', ' . $state . ', ' . $row->id . ')" title="' . $alt . '"><img class="JLMS_png" src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . $image . '" width="16" height="16" border="0" alt="' . $alt . '" /></a>';
                }
                ?>
					</td>
					<?php 
            }
            ?>
					<td>&nbsp;</td>
					<td align="center" valign="middle">
						<a href="javascript:startAppPlayback('<?php 
            echo $JLMS_CONFIG->get('live_site') . '/index.php?tmpl=component&option=com_joomla_lms&amp;task=conference&amp;mode=conference_playback&amp;Itemid=' . $Itemid . '&amp;id=' . $course_id . '&amp;name=' . $row->session_name;
            ?>
');" title="<?php 
            echo _JLMS_CONFERENCE_RECORD_PB;
            ?>
" >
							<img class="JLMS_png" src="<?php 
            echo $JLMS_CONFIG->get('live_site');
            ?>
/components/com_joomla_lms/lms_images/toolbar/btn_playback.png" width="16" height="16" border="0" alt="<?php 
            echo _JLMS_CONFERENCE_RECORD_PB;
            ?>
" title="<?php 
            echo _JLMS_CONFERENCE_RECORD_PB;
            ?>
" />
						</a>
					</td>
				</tr>
				<?php 
            $k = 3 - $k;
        }
        ?>
				<tr>
					<td class="<?php 
        echo JLMSCSS::_('jlmslist-footer_td');
        ?>
" colspan="<?php 
        echo $JLMS_ACL->CheckPermissions('conference', 'manage') ? 8 : 5;
        ?>
" align="center"><div align="center">
					<?php 
        if (count($records) == 0) {
            echo _JLMS_CONFERENCE_NO_RECORD;
        } else {
            $link_PN = "index.php?option={$option}&Itemid={$Itemid}&task=conference&mode=archive&course_id=" . $course_id;
            echo _JLMS_PN_DISPLAY_NUM . $pageNav->getLimitBox($link_PN) . "&nbsp;" . $pageNav->getPagesCounter($link_PN) . '<br />';
            echo $pageNav->writePagesLinks($link_PN);
        }
        ?>
					</div></td>
				</tr>
			</table>
			<input type="hidden" name="task" value="conference" />
			<input type="hidden" name="mode" value="" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="id" value="<?php 
        echo $course_id;
        ?>
" />
			<input type="hidden" name="state" value="0" />
			<input type="hidden" name="cid2" value="0" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        if ($JLMS_ACL->CheckPermissions('conference', 'manage')) {
            $controls = array();
            $controls[] = array('href' => "javascript:submitbutton_change('change_record',1);", 'title' => _JLMS_SET_PUB, 'img' => 'publish');
            $controls[] = array('href' => "javascript:submitbutton_change('change_record',0);", 'title' => _JLMS_SET_UNPUB, 'img' => 'unpublish');
            $controls[] = array('href' => 'spacer');
            $controls[] = array('href' => "javascript:submitbutton('record_delete');", 'title' => _JLMS_DELETE, 'img' => 'delete');
            $controls[] = array('href' => "javascript:submitbutton('edit_record');", 'title' => _JLMS_EDIT, 'img' => 'edit');
            JLMS_TMPL::ShowControlsFooter($controls, sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=conference&amp;id={$course_id}"));
        }
        JLMS_TMPL::CloseMT();
    }
function JLMS_viewDRPDescription($id, $option)
{
    global $my, $JLMS_DB, $Itemid;
    $course_id = intval(mosGetParam($_REQUEST, 'course_id', 0));
    //	if ($my->id && $course_id && JLMS_GetUserType($my->id, $course_id) ) {
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($my->id && $course_id && $JLMS_ACL->CheckPermissions('dropbox', 'view')) {
        $query = "SELECT a.*, b.name as owner_username, c.name as recv_username FROM #__lms_dropbox as a, #__users as b, #__users as c" . "\n WHERE a.id = '" . $id . "'" . "\n AND a.course_id = '" . $course_id . "'" . "\n AND a.owner_id = b.id AND a.recv_id = c.id AND (a.owner_id = '" . $my->id . "' OR a.recv_id = '" . $my->id . "')";
        $JLMS_DB->SetQuery($query);
        $dropbox = $JLMS_DB->LoadObjectList();
        if (count($dropbox)) {
            $drop = $dropbox[0];
            $lists = array();
            JLMS_course_dropbox_html::viewDRPDescription($course_id, $option, $drop, $lists);
        } else {
            JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}"));
        }
    } elseif ($course_id) {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=details_course&id={$course_id}"));
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}"));
    }
}
Пример #30
-1
function my_certificates($course_id, $hp_items, $user_id)
{
    $db =& JFactory::getDbo();
    $user = JLMSFactory::getUser();
    $my_courses = array();
    $my_certificates = array();
    if ($user_id) {
        $query = "SELECT a.id, a.course_name" . "\n FROM #__lms_courses as a" . "\n, #__lms_users_in_groups as b" . "\n WHERE 1" . "\n AND a.id = b.course_id" . "\n AND b.user_id = '" . $user_id . "'";
        $db->setQuery($query);
        $my_courses = $db->loadObjectList();
        $query = "SELECT cc.* FROM (\n\t\t\tSELECT a.*, c.course_name, d.uniq_id, d.crtf_id, d.quiz_id, d.role_id\n\t\t\tFROM #__lms_certificate_users as a\n\t\t\tLEFT JOIN #__lms_certificate_prints as d ON a.course_id = d.course_id AND a.user_id = d.user_id AND crtf_id \n\t\t\t,#__lms_users_in_groups as b\n\t\t\t,#__lms_courses as c\n\t\t\tWHERE 1\n\t\t\tAND a.user_id = {$user_id}\n\t\t\tAND a.user_id = b.user_id\n\t\t\tAND a.course_id = b.course_id\n\t\t\tAND b.course_id = c.id\n\t\t\tORDER BY d.role_id DESC\n\t\t) AS cc\n\t\tGROUP BY cc.user_id, cc.course_id, cc.crtf_id, cc.quiz_id\n\t\tORDER BY cc.crt_date DESC\n\t\t";
        $db->setQuery($query);
        $my_certificates = $db->loadObjectList();
    }
    $lists = array();
    $JLMS_ACL =& JLMSFactory::getACL();
    if (count($my_courses)) {
        foreach ($my_courses as $course) {
            //JLMS_GB_getUserCertificates($course->id, $user_id, $lists);
            /**
             * Certificates MOD - 04.10.2007 (DEN)
             * We will show the list of all achieved certificates in the User Gradebook
             */
            $query = "SELECT * FROM #__lms_quiz_t_quiz WHERE course_id = '" . $course->id . "' AND c_certificate <> 0 ORDER BY c_title";
            $db->SetQuery($query);
            $quiz_rows = $db->LoadObjectList();
            $p = array();
            foreach ($quiz_rows as $qrow) {
                $pp = new stdClass();
                $pp->gbi_id = $qrow->c_id;
                $pp->user_pts = 0;
                $pp->user_status = -1;
                $pp->quiz_name = '';
                $pp->crtf_id = '';
                $p[] = $pp;
            }
            $certificates = array();
            $quiz_ans = array();
            if (count($quiz_rows)) {
                $query = "SELECT a.*, b.c_full_score, b.c_title, b.c_certificate FROM #__lms_quiz_results as a, #__lms_quiz_t_quiz as b WHERE a.course_id = '" . $course->id . "'" . "\n AND a.quiz_id = b.c_id AND a.user_id = {$user_id} ORDER BY a.user_id, a.quiz_id";
                $db->SetQuery($query);
                $quiz_ans = $db->LoadObjectList();
                $j = 0;
                while ($j < count($quiz_ans)) {
                    if ($quiz_ans[$j]->user_id == $user_id) {
                        $k = 0;
                        while ($k < count($p)) {
                            if ($p[$k]->gbi_id == $quiz_ans[$j]->quiz_id) {
                                $p[$k]->user_pts = $quiz_ans[$j]->user_score;
                                $p[$k]->user_status = $quiz_ans[$j]->user_passed;
                                $p[$k]->quiz_name = $quiz_ans[$j]->c_title;
                                $p[$k]->crtf_id = $quiz_ans[$j]->c_certificate;
                            }
                            $k++;
                        }
                    }
                    $j++;
                }
                $certificates = array();
                foreach ($p as $pp) {
                    if ($pp->user_status == 1) {
                        $query = "SELECT * FROM #__lms_quiz_r_student_quiz WHERE c_quiz_id = {$pp->gbi_id} AND c_student_id = {$user_id} AND c_total_score = {$pp->user_pts} AND c_passed = 1 ORDER BY c_date_time DESC LIMIT 0,1";
                        $db->SetQuery($query);
                        $u_res = $db->LoadObject();
                        if (is_object($u_res)) {
                            $role = $JLMS_ACL->UserRole($db, $user_id, 1);
                            $query = "SELECT crtf_date as crt_date FROM #__lms_certificate_prints WHERE user_id = {$user_id} AND (role_id = {$role} OR role_id = 0)  AND course_id = {$course->id} AND quiz_id = {$pp->gbi_id} AND crtf_id = {$pp->crtf_id}" . "\n ORDER BY role_id DESC LIMIT 0,1";
                            /* !!!!!!!! Bring from DB date of printing by user role or by default role (only if userrole not found) - imenno dlya etogo tut sidit ORDER i LIMIT*/
                            $db->SetQuery($query);
                            $crtf_date = $db->LoadResult();
                            if (!$crtf_date) {
                                $crtf_date = $u_res->c_date_time;
                            }
                            $ppp = new stdClass();
                            $ppp->user_id = $user_id;
                            $ppp->stu_quiz_id = $u_res->c_id;
                            $ppp->quiz_id = $u_res->c_quiz_id;
                            $ppp->user_unique_id = $u_res->unique_id;
                            $ppp->quiz_name = $pp->quiz_name;
                            $ppp->crt_date = $crtf_date;
                            $certificates[] = $ppp;
                        }
                    }
                }
            }
            $lists['user_quiz_certificates'] =& $certificates;
            /* END of Certificates MOD */
            if (isset($lists['user_quiz_certificates']) && count($lists['user_quiz_certificates'])) {
                for ($i = 0; $i < count($lists['user_quiz_certificates']); $i++) {
                    $lists['user_quiz_certificates'][$i]->course_id = $course->id;
                    $lists['user_quiz_certificates'][$i]->course_name = $course->course_name;
                }
            }
            $my_certificates = array_merge($my_certificates, $lists['user_quiz_certificates']);
        }
    }
    //sort
    $sort_date = array();
    for ($i = 0; $i < count($my_certificates); $i++) {
        $sort_date[] = strtotime($my_certificates[$i]->crt_date);
    }
    arsort($sort_date);
    $tmp = array();
    foreach ($sort_date as $n => $item) {
        foreach ($my_certificates as $m => $crt) {
            if ($n == $m) {
                $tmp[] = $crt;
            }
        }
    }
    if (isset($tmp) && count($tmp)) {
        $my_certificates = array();
        $my_certificates = $tmp;
    }
    return $my_certificates;
}