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 */
 }
Beispiel #2
0
    function echoMyReports($option, $Itemid)
    {
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $user = JLMSFactory::getUser();
        $my_id = $user->get('id');
        $db =& JFactory::getDbo();
        $JLMS_ACL =& JLMSFactory::getACL();
        ?>
		<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
        echo JLMSCSS::_('jlmslist', 'jlms_homepage_list');
        ?>
" style="margin-top:0; margin-bottom:0;">
		<tr>
<?php 
        $reports_heading = _JLMS_REPORTS_MODULE;
        $add_text = '';
        if ($JLMS_CONFIG->get('is_trial', false) && $JLMS_CONFIG->get('trial_reports_module_heading', '')) {
            $reports_heading .= $JLMS_CONFIG->get('trial_reports_module_heading', '');
        }
        if ($JLMS_CONFIG->get('is_trial', false) && $JLMS_CONFIG->get('trial_reports_module_text', '')) {
            $add_text = $JLMS_CONFIG->get('trial_reports_module_text', '');
        }
        ?>
			<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" colspan="2" align="center" style="text-align:center"><?php 
        echo $reports_heading;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
		</tr>
		<?php 
        if ($add_text) {
            echo '<tr><td colspan="2"><div class="joomlalms_sys_message">' . $add_text . '</div></td></tr>';
        }
        if ($JLMS_ACL->isTeacher()) {
            $link = sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=report_access");
            echo "<tr class='" . JLMSCSS::_('sectiontableentry1') . "'>";
            echo "<td valign='middle' width='16'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/toolbar/tlb_attendance.png\" width='16' height='16' border='0' alt='agenda' /></td>";
            echo "<td><a href='" . $link . "' >" . _JLMS_REPORTS_ACCESS . "</a></td></tr>";
            $link = sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=report_certif");
            echo "<tr class='" . JLMSCSS::_('sectiontableentry2') . "'>";
            echo "<td valign='middle' width='16'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/toolbar/tlb_attendance.png\" width='16' height='16' border='0' alt='agenda' /></td>";
            echo "<td><a href='" . $link . "' >" . _JLMS_REPORTS_CONCLUSION . "</a></td></tr>";
            $link = sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=report_grade");
            echo "<tr class='" . JLMSCSS::_('sectiontableentry1') . "'>";
            echo "<td valign='middle' width='16'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/toolbar/tlb_attendance.png\" width='16' height='16' border='0' alt='agenda' /></td>";
            echo "<td><a href='" . $link . "' >" . _JLMS_REPORTS_USER . "</a></td></tr>";
        }
        if (($JLMS_ACL->isTeacher() || $JLMS_ACL->isStaff()) && $JLMS_CONFIG->get('show_scorm_report_link', false)) {
            $link = sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=report_scorm");
            echo "<tr class='" . JLMSCSS::_('sectiontableentry2') . "'>";
            echo "<td valign='middle' width='16'><img class='JLMS_png' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/toolbar/tlb_attendance.png\" width='16' height='16' border='0' alt='agenda' /></td>";
            echo "<td><a href='" . $link . "' >" . _JLMS_REPORTS_SCORM . "</a></td></tr>";
        }
        ?>
	</table>
<?php 
    }
Beispiel #3
0
function JLMS_Populate_lpath_forums($course_id, &$user_forums, &$all_forums, &$type)
{
    global $my, $JLMS_DB;
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($JLMS_ACL->isTeacher()) {
        $query = "SELECT a.*" . "\n FROM #__lms_learn_paths as a" . "\n WHERE a.course_id = '" . $course_id . "' AND a.lp_params like '%add_forum=1%'" . "\n ORDER BY a.ordering";
        $JLMS_DB->SetQuery($query);
        $user_lpaths = $JLMS_DB->LoadObjectList();
        $user_lpaths_ids = array();
        foreach ($user_lpaths as $ul) {
            $user_lpaths_ids[] = $ul->id;
        }
    } else {
        /* Get list of Published LPaths and check access rights to them (i.e. access is restricted by prerequisites) */
        $query = "SELECT a.*, '' as r_status, '' as r_start, '' as r_end" . "\n FROM #__lms_learn_paths as a" . "\n WHERE a.course_id = '" . $course_id . "'" . "\n ORDER BY a.ordering";
        $JLMS_DB->SetQuery($query);
        $lpaths = $JLMS_DB->LoadObjectList();
        require_once _JOOMLMS_FRONT_HOME . "/includes/lms_grades.lib.php";
        $user_ids = array();
        $user_ids[] = $my->id;
        JLMS_LP_populate_results($course_id, $lpaths, $user_ids);
        // 13 August 2007 (DEN) Check for prerequisites.
        // 1. get the list of lpath_ids.
        $lpath_ids = array();
        foreach ($lpaths as $lpath) {
            $lpath_ids[] = $lpath->id;
        }
        if (!empty($lpath_ids)) {
            $lpath_ids_str = implode(',', $lpath_ids);
            // 2. get the list of prerequisites
            // SELECT from two tables (+ #__lms_learn_paths) - because the prereq lpath could be deleted...
            $query = "SELECT a.* FROM #__lms_learn_path_prerequisites as a, #__lms_learn_paths as b" . "\n WHERE a.lpath_id IN ({$lpath_ids_str}) AND a.req_id = b.id";
            $JLMS_DB->SetQuery($query);
            $prereqs = $JLMS_DB->LoadObjectList();
            if (!empty($prereqs)) {
                // 3. compare lists of prereqs to the lists of lpaths.
                $i = 0;
                while ($i < count($lpaths)) {
                    $is_hidden = false;
                    $o = 0;
                    while ($o < count($prereqs)) {
                        if ($prereqs[$o]->lpath_id == $lpaths[$i]->id) {
                            $j = 0;
                            while ($j < count($lpaths)) {
                                if ($lpaths[$j]->id == $prereqs[$o]->req_id) {
                                    if (!$lpaths[$j]->item_id) {
                                        if (empty($lpaths[$j]->r_status)) {
                                            $is_hidden = true;
                                            break;
                                        } else {
                                            $end_time = strtotime($lpaths[$j]->r_end);
                                            $current_time = strtotime(date("Y-m-d H:i:s"));
                                            if ($current_time > $end_time && $current_time - $end_time < $prereqs[$o]->time_minutes * 60) {
                                                $is_hidden = true;
                                                break;
                                            }
                                        }
                                    } else {
                                        if (empty($lpaths[$j]->s_status)) {
                                            $is_hidden = true;
                                            break;
                                        } else {
                                            $end_time = strtotime($lpaths[$j]->r_end);
                                            $current_time = strtotime(date("Y-m-d H:i:s"));
                                            if ($current_time > $end_time && $current_time - $end_time < $prereqs[$o]->time_minutes * 60) {
                                                $is_hidden = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                                $j++;
                            }
                        }
                        $o++;
                    }
                    if ($is_hidden) {
                        $lpaths[$i]->published = 0;
                    }
                    $i++;
                }
            }
        }
        $user_lpaths = array();
        $user_lpaths_ids = array();
        foreach ($lpaths as $lp) {
            if ($lp->published) {
                $pos = strpos($lp->lp_params, 'add_forum=1');
                if ($pos === false) {
                } else {
                    // forum is allowed for this lpath
                    $rrr = new stdClass();
                    $rrr = clone $lp;
                    $user_lpaths[] = $rrr;
                    $user_lpaths_ids[] = $rrr->id;
                }
            }
        }
    }
    $groups_ex = array();
    if (count($user_lpaths)) {
        foreach ($all_forums as $af) {
            if ($af->board_type == $type->id) {
                if ($af->is_active && in_array($af->group_id, $user_lpaths_ids)) {
                    $user_forums[] = clone $af;
                    $groups_ex[] = $af->group_id;
                }
            }
        }
    }
    // we need to create missing lpaths forums
    if (count($groups_ex) < count($user_lpaths)) {
        foreach ($user_lpaths as $ul) {
            if (!in_array($ul->id, $groups_ex)) {
                $new_forum = clone $type;
                $new_forum->id = 0;
                $new_forum->group_id = $ul->id;
                $new_forum->board_type = $type->id;
                $new_forum->item_title = $ul->lpath_name;
                $new_forum->id_cat = 0;
                $new_forum->id_group = 0;
                $new_forum->id_board = 0;
                $user_forums[] = $new_forum;
            }
        }
    }
}
 function JQ_ImgsList_save($option)
 {
     // Axtung!: vse tablicy nabora question options (like 't_choice', 't_matching') are stores imgs_id instead of id from #__lms_quiz_images
     global $my, $JLMS_DB, $Itemid, $JLMS_CONFIG;
     $JLMS_ACL =& JLMSFactory::getACL();
     $course_id = $JLMS_CONFIG->get('course_id');
     $c_id = intval(mosGetParam($_REQUEST, 'c_id', 0));
     $imgs_name_post = isset($_REQUEST['imgs_name']) ? strval($_REQUEST['imgs_name']) : 'imgs_name';
     $imgs_name_post = get_magic_quotes_gpc() ? stripslashes($imgs_name_post) : $imgs_name_post;
     $imgs_name_post = ampReplace(strip_tags($imgs_name_post));
     if (!$c_id) {
         $file_id = 0;
         if (isset($_FILES['imgs']) && !empty($_FILES['imgs']['name'])) {
             $file_id = JLMS_uploadFile($course_id, 'imgs');
         }
         if ($file_id) {
             $query = "INSERT #__lms_quiz_images (imgs_name, imgs_id, course_id)" . "\n VALUES ('" . $imgs_name_post . "', '" . $file_id . "', '" . $course_id . "' )";
             $JLMS_DB->SetQuery($query);
             $JLMS_DB->query();
         }
     } else {
         $query = "UPDATE #__lms_quiz_images SET imgs_name = '" . $imgs_name_post . "' WHERE c_id = '" . $c_id . "'";
         $JLMS_DB->SetQuery($query);
         $JLMS_DB->query();
     }
     JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=quizzes&page=imgs&id={$course_id}"));
 }
    function JQ_showQuizList(&$rows, &$lists, &$pageNav, $option, $page, $id)
    {
        global $Itemid, $JLMS_CONFIG;
        $JLMS_ACL =& JLMSFactory::getACL();
        $toolbar = array();
        if ($JLMS_ACL->CheckPermissions('quizzes', 'view_stats')) {
            $toolbar[] = array('btn_type' => 'bar', 'btn_txt' => _JLMS_QUIZ_VIEW_STATS, 'btn_js' => "javascript:submitbutton('quiz_bars');");
        }
        if ($JLMS_ACL->CheckPermissions('quizzes', 'manage')) {
            if ($JLMS_ACL->CheckPermissions('quizzes', 'view_stats')) {
                $toolbar[] = array('btn_type' => 'spacer', 'btn_txt' => 'spacer', 'btn_js' => 'spacer');
            }
            $toolbar[] = array('btn_type' => 'edit', 'btn_txt' => _JLMS_QUIZ_EDIT_QUIZ_BTN, 'btn_js' => "javascript:submitbutton('edit_quiz');");
            $toolbar[] = array('btn_type' => 'del', 'btn_txt' => _JLMS_QUIZ_DEL_QUIZ_BTN, 'btn_js' => "javascript:submitbutton('del_quiz');");
            $toolbar[] = array('btn_type' => 'copy', 'btn_txt' => _JLMS_QUIZ_COPY_QUIZ_BTN, 'btn_js' => "javascript:submitbutton('copy_quiz_sel');");
            $toolbar[] = array('btn_type' => 'move', 'btn_txt' => _JLMS_QUIZ_MOVE_QUIZ_BTN, 'btn_js' => "javascript:submitbutton('move_quiz_sel');");
            $toolbar[] = array('btn_type' => 'spacer', 'btn_txt' => 'spacer', 'btn_js' => 'spacer');
            $toolbar[] = array('btn_type' => 'new', 'btn_txt' => _JLMS_QUIZ_NEW_QUIZ_BTN, 'btn_js' => JRoute::_("index.php?option={$option}&Itemid={$Itemid}&id={$id}&task=quizzes&page=add_quiz"));
        }
        JLMS_quiz_admin_html_class::showQuizHead($id, $option, _JLMS_QUIZ_TITLE, true, $toolbar);
        ?>

<script language="javascript" type="text/javascript">
<!--
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if ( ((pressbutton == 'edit_quiz') || (pressbutton == 'del_quiz') || (pressbutton == 'copy_quiz_sel') || (pressbutton == 'move_quiz_sel')) && (form.boxchecked.value == "0")) {
		alert('<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
');
	} else {
		form.page.value = pressbutton;
		form.submit();
	}
}
//-->
</script>
		<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">
			<tr>
				<td>
				<table width="100%" cellpadding="0" cellspacing="0" border="0" class="jlms_table_no_borders">
					<tr>
						<td align="right" style="text-align:left ">
							<div align="right" style="white-space:nowrap ">
							<?php 
        echo _JLMS_QUIZ_FILTER_BY_CAT . '&nbsp;' . $lists['category'];
        ?>
							</div>
						</td>
					</tr>
				</table>
				</td>
			</tr>
			<tr>
				<td width="100%">
				<?php 
        $quizzes_colspan = 9;
        ?>
				<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
        echo JLMSCSS::_('jlmslist');
        ?>
" style="margin-top: 0px; padding-top:0px; margin-bottom:0px; padding-bottom: 0px;">
					<tr>
						<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 width="20" class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center">#</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						<<?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 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_QUIZ_TBL_Q_NAME;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						<?php 
        if ($JLMS_ACL->CheckPermissions('quizzes', 'publish')) {
            $quizzes_colspan++;
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_QUIZ_TBL_Q_ACTIVE;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						<?php 
        }
        ?>
						<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_QUIZ_TBL_Q_CAT;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_QUIZ_TBL_Q_T_SCORE;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_QUIZ_TBL_Q_P_SCORE;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_QUIZ_TBL_Q_T_LIMIT;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
"><?php 
        echo _JLMS_QUIZ_TBL_Q_CREATED;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" width="20">ID</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					</tr>
					<?php 
        if ($JLMS_ACL->CheckPermissions('quizzes', 'manage_pool')) {
            ?>
					<tr class="<?php 
            echo JLMSCSS::_('sectiontableentry1');
            ?>
">
						<td align="center" valign="middle">-</td>
						<td align="center" valign="middle">-</td>
						<td align="left" valign="middle">
						<?php 
            $link = sefRelToAbs('index.php?option=' . $option . '&amp;Itemid=' . $Itemid . '&amp;task=quizzes&amp;id=' . $id . '&amp;page=setup_quest&amp;quiz_id=-1');
            ?>
							<a href="<?php 
            echo $link;
            ?>
">
							<?php 
            echo _JLMS_QUIZ_QUEST_POOL;
            ?>
							</a>
						</td>
						<td align="center" valign="middle">
							&nbsp;
						</td>
						<td align="left" valign="middle" colspan="6"><b><?php 
            echo _JLMS_QUIZ_POOL_QUEST_NUM . ' ' . $lists['pool_count'];
            ?>
</b></td>
					</tr>
					<?php 
        }
        ?>
				<?php 
        $k = 2;
        $quiz_task_page = 'setup_quest';
        $quiz_task = 'quizzes';
        if (!$JLMS_ACL->CheckPermissions('quizzes', 'manage')) {
            $quiz_task_page = 'quiz_bars';
            if (!$JLMS_ACL->CheckPermissions('quizzes', 'view_stats')) {
                $quiz_task_page = '';
                $quiz_task = 'show_quiz';
            }
        }
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row = $rows[$i];
            $link = sefRelToAbs('index.php?option=' . $option . '&amp;Itemid=' . $Itemid . ($quiz_task ? '&amp;task=' . $quiz_task : '') . '&amp;id=' . $id . ($quiz_task_page ? '&amp;page=' . $quiz_task_page : '') . '&amp;quiz_id=' . $row->c_id);
            $img_published = $row->published ? 'btn_accept.png' : 'btn_cancel.png';
            $task_published = $row->published ? 'unpublish_quiz' : 'publish_quiz';
            $alt_published = $row->published ? _JLMS_STATUS_PUB : _JLMS_STATUS_UNPUB;
            $state = $row->published ? 0 : 1;
            $checked = mosHTML::idBox($i, $row->c_id);
            ?>
					<tr class="<?php 
            echo JLMSCSS::_('sectiontableentry' . $k);
            ?>
">
						<td align="center" valign="middle"><?php 
            echo $pageNav->limitstart + $i + 1;
            ?>
</td>
						<td align="center" valign="middle"><?php 
            echo $checked;
            ?>
</td>
						<td align="left" valign="middle">
						<?php 
            if ($JLMS_ACL->CheckPermissions('quizzes', 'manage')) {
                ?>
						<?php 
                $txt_for_tip = '<table width="100%" cellpadding=0 cellspacing=0>';
                $txt_for_tip .= '<tr><td>' . _JLMS_QUIZ_RANDOMIZE_OPTION . '</td><td align="center" width="25%"><img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . ($row->c_random ? 'btn_accept.png' : 'btn_cancel.png') . '" width="16" height="16" border="0"/></td></tr>';
                $txt_for_tip .= '<tr><td>' . _JLMS_QUIZ_REVIEW_OPTION_W . '</td><td align="center" width="25%"><img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . ($row->c_enable_review ? 'btn_accept.png' : 'btn_cancel.png') . '" width="16" height="16" border="0"/></td></tr>';
                $txt_for_tip .= '<tr><td>' . _JLMS_QUIZ_EMAIL_OPTION_W . '</td><td align="center" width="25%"><img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . ($row->c_email_to ? 'btn_accept.png' : 'btn_cancel.png') . '" width="16" height="16" border="0"/></td></tr>';
                $txt_for_tip .= '<tr><td>' . _JLMS_QUIZ_PRINT_OPTION_W . '</td><td align="center" width="25%"><img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . ($row->c_enable_print ? 'btn_accept.png' : 'btn_cancel.png') . '" width="16" height="16" border="0"/></td></tr>';
                $txt_for_tip .= '<tr><td>' . _JLMS_QUIZ_WITH_CRTF_OPTION_W . '</td><td align="center" width="25%"><img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . ($row->c_certificate ? 'btn_accept.png' : 'btn_cancel.png') . '" width="16" height="16" border="0"/></td></tr>';
                $txt_for_tip .= '<tr><td>' . _JLMS_SHOW_IN_GRADEBOOK_OPTION . '</td><td align="center" width="25%"><img src="' . $JLMS_CONFIG->get('live_site') . '/components/com_joomla_lms/lms_images/toolbar/' . ($row->c_gradebook ? 'btn_accept.png' : 'btn_cancel.png') . '" width="16" height="16" border="0"/></td></tr>';
                $txt_for_tip .= '</table>';
                ?>
						<?php 
                echo JLMS_toolTip($row->c_title, $txt_for_tip, '', $link, 1, 36, 'true', 'jlms_ttip');
                ?>
						<?php 
            } else {
                ?>
							<a href="<?php 
                echo $link;
                ?>
">
							<?php 
                echo $row->c_title;
                ?>
							</a>
						<?php 
            }
            ?>
						<?php 
            if ($JLMS_CONFIG->get('show_quizzes_authors', 0)) {
                ?>
						<br />
						<span class="small"><?php 
                echo _JLMS_HOME_AUTHOR . "&nbsp;" . $row->author_name;
                ?>
</span>
						<?php 
            }
            ?>
						</td>
						<?php 
            if ($JLMS_ACL->CheckPermissions('quizzes', 'publish')) {
                ?>
						<td align="center" valign="middle">
						<?php 
                if ($row->is_time_related) {
                    if ($row->published) {
                        $img_published = 'btn_publish_wait.png';
                    }
                    $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;
                    }
                    echo JLMS_quiz_admin_html_class::QuizPublishIconTT($row->c_id, $id, $state, $task_published, $alt_published, $img_published, $option, 0, $tooltip_txt);
                } else {
                    echo JLMS_quiz_admin_html_class::QuizPublishIcon($row->c_id, $id, $state, $task_published, $alt_published, $img_published, $option);
                }
                ?>
						</td>
						<?php 
            }
            ?>
						<td align="left" valign="middle">
							<?php 
            echo $row->c_category ? $row->c_category : '&nbsp;';
            ?>
						</td>
						<td align="left" valign="middle">
							<?php 
            echo $row->c_full_score . ($row->quests_from_pool ? '+' : '');
            ?>
						</td>
						<td align="left" valign="middle">
							<?php 
            echo $row->c_passing_score . '%';
            ?>
						</td>
						<td align="left" valign="middle">
							<?php 
            echo $row->c_time_limit;
            ?>
						</td>
						<td align="left" valign="middle">
							<?php 
            echo JLMS_dateToDisplay($row->c_created_time);
            ?>
						</td>
						<td><?php 
            echo $row->c_id;
            ?>
</td>
					</tr>
					<?php 
            $k = 3 - $k;
        }
        ?>
				<tr>
					<td colspan="<?php 
        echo $quizzes_colspan;
        ?>
" 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=quizzes&amp;id={$id}" . ($page ? "&amp;page={$page}" : '');
        echo _JLMS_PN_DISPLAY_NUM . '&nbsp;' . $pageNav->getLimitBox($link) . '&nbsp;' . $pageNav->getPagesCounter();
        echo '<br />';
        echo $pageNav->writePagesLinks($link);
        ?>
 
						</div>
					</td>
				</tr>
				</table>
				</td>
			</tr>
		</table>
		<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
		<input type="hidden" name="page" value="<?php 
        echo $page;
        ?>
" />
		<input type="hidden" name="task" value="quizzes" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
		</form>
		<?php 
        JLMS_quiz_admin_html_class::showQuizFooter();
        ?>
		<?php 
    }
Beispiel #6
0
function JLMS_getChatXML($course_id, $group_id, $option, $checked = false)
{
    global $JLMS_DB, $my, $JLMS_CONFIG;
    $do_chat = $checked;
    if (!$do_chat) {
        $JLMS_ACL =& JLMSFactory::getACL();
        if ($JLMS_ACL->CheckPermissions('chat', 'view')) {
            if ($JLMS_ACL->CheckPermissions('chat', 'manage')) {
                if ($group_id) {
                    if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                        $query = "SELECT group_chat FROM #__lms_usergroups WHERE course_id = 0 AND id = {$group_id}";
                        $JLMS_DB->SetQuery($query);
                        if ($JLMS_DB->LoadResult()) {
                            $do_chat = true;
                        }
                    } else {
                        $query = "SELECT group_chat FROM #__lms_usergroups WHERE course_id = {$course_id} AND id = {$group_id}";
                        $JLMS_DB->SetQuery($query);
                        if ($JLMS_DB->LoadResult()) {
                            $do_chat = true;
                        }
                    }
                } else {
                    $do_chat = true;
                }
            } else {
                if ($group_id) {
                    if ($JLMS_CONFIG->get('use_global_groups', 1)) {
                        $query = "SELECT group_chat FROM #__lms_users_in_global_groups AS uigg, #__lms_usergroups AS ug WHERE uigg.user_id = {$my->id} AND uigg.group_id = {$group_id} AND ug.id = uigg.group_id";
                        $JLMS_DB->setQuery($query);
                        if ($JLMS_DB->LoadResult()) {
                            $do_chat = true;
                        }
                    } else {
                        $query = "SELECT b.group_chat FROM #__lms_users_in_groups as a, #__lms_usergroups as b" . "\n WHERE a.course_id = {$course_id} AND a.group_id = {$group_id} AND a.user_id = '" . $my->id . "' AND a.group_id = b.id AND b.id = {$group_id} AND b.course_id = {$course_id}";
                        $JLMS_DB->SetQuery($query);
                        if ($JLMS_DB->LoadResult()) {
                            $do_chat = true;
                        }
                    }
                } else {
                    $do_chat = true;
                }
            }
        }
    }
    if ($do_chat) {
        $last_msg = intval(mosGetParam($_REQUEST, 'last_msg', 0));
        //query (Drop users)
        $tim_minus_15 = time() - date('Z') - 15 * 60;
        $query = "DELETE FROM #__lms_chat_users WHERE time_post < '" . date('Y-m-d H:i:s', $tim_minus_15) . "'";
        $JLMS_DB->SetQuery($query);
        $JLMS_DB->query();
        $query = "SELECT time_enter, time_post FROM #__lms_chat_users" . "\n WHERE user_id = '" . $my->id . "' AND course_id = '" . $course_id . "' AND group_id = '" . $group_id . "'";
        $JLMS_DB->SetQuery($query);
        $XML_data = '';
        $user_time_obj = $JLMS_DB->LoadObject();
        if (is_object($user_time_obj) && isset($user_time_obj->time_enter)) {
            $time_online = $user_time_obj->time_enter;
            $time_prev_post = $user_time_obj->time_post;
            if ($time_online) {
                //query (Update time)
                $query = "UPDATE #__lms_chat_users SET time_post = '" . gmdate('Y-m-d H:i:s') . "'" . "\n WHERE user_id = '" . $my->id . "' AND course_id = '" . $course_id . "' AND group_id = '" . $group_id . "'";
                $JLMS_DB->SetQuery($query);
                $JLMS_DB->query();
                $query = "SELECT a.username FROM #__users as a, #__lms_chat_users as b" . "\n WHERE a.id = b.user_id AND b.course_id = '" . $course_id . "' AND b.group_id = '" . $group_id . "'" . "\n ORDER BY a.username";
                $JLMS_DB->SetQuery($query);
                $chat_users = $JLMS_DB->LoadObjectList();
                $query = "SELECT a.username, b.user_message, b.mes_time, b.id FROM #__users as a, #__lms_chat_history as b" . "\n WHERE a.id = b.user_id AND b.course_id = '" . $course_id . "' AND b.mes_time > '" . $time_online . "'" . "\n AND b.group_id = '" . $group_id . "' AND (b.recv_id = '0' OR b.recv_id = '" . $my->id . "')" . "\n ORDER BY b.mes_time DESC, b.id DESC LIMIT 0, 100";
                $JLMS_DB->SetQuery($query);
                $chat_history = $JLMS_DB->LoadObjectList();
                $new_chat_history = array();
                $time_prev_post_time = strtotime($time_prev_post);
                $do_scroll_chat = false;
                $new_last_id = 0;
                $i = count($chat_history) - 1;
                if (isset($chat_history[0]->mes_time)) {
                    $time_last_post_time = strtotime($chat_history[0]->mes_time);
                    if ($time_last_post_time >= $time_prev_post_time) {
                        $do_scroll_chat = true;
                    }
                }
                while ($i >= 0) {
                    $new_chat_history[] = $chat_history[$i];
                    $i--;
                }
                /* 29.05.2008 - changes by DEN */
                $show_chat_history = array();
                for ($i = 0; $i < count($new_chat_history); $i++) {
                    if ($new_chat_history[$i]->id > $last_msg) {
                        $show_chat_history[] = $new_chat_history[$i];
                        if ($new_chat_history[$i]->id > $new_last_id) {
                            $new_last_id = $new_chat_history[$i]->id;
                        }
                    }
                }
                $count_mes = count($show_chat_history);
                $XML_data .= "\t" . '<task>chat_xml</task>' . "\n";
                $XML_data .= "\t" . '<count_new_msgs>' . $count_mes . '</count_new_msgs>' . "\n";
                $XML_data .= "\t" . '<chat_last_id>' . $new_last_id . '</chat_last_id>' . "\n";
                $XML_data .= "\t" . '<chat_users><![CDATA[' . JLMS_chat_html::prepareUserList($chat_users) . ']]></chat_users>' . "\n";
                //$XML_data .= "\t" . '<chat_history><![CDATA['.JLMS_chat_html::prepareChatHistory($new_chat_history).']]></chat_history>' . "\n";
                $i = 1;
                foreach ($show_chat_history as $data) {
                    $CDATA = '<b>' . $data->username . ': </b><br />';
                    $CDATA .= JLMS_nl2br($data->user_message);
                    $XML_data .= "\t" . '<chat_message_' . $i . '><![CDATA[' . $CDATA . ']]></chat_message_' . $i . '>' . "\n";
                    $i++;
                }
            }
        }
        $iso = explode('=', _ISO);
        echo "\n" . "some notices :)";
        $debug_str = ob_get_contents();
        $debug_str = "no debug info";
        ob_end_clean();
        header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
        if (class_exists('JFactory')) {
            $document =& JFactory::getDocument();
            $charset_xml = $document->getCharset();
            header('Content-Type: text/xml; charset=' . $charset_xml);
        } else {
            header('Content-Type: text/xml');
        }
        if ($XML_data != "") {
            echo '<?xml version="1.0" encoding="' . $iso[1] . '" standalone="yes"?>';
            echo '<response>' . "\n";
            echo $XML_data;
            echo "\t" . '<debug><![CDATA[' . $debug_str . ']]></debug>' . "\n";
            echo '</response>' . "\n";
        } else {
            echo '<?xml version="1.0" encoding="' . $iso[1] . '" standalone="yes"?>';
            echo '<response>' . "\n";
            echo "\t" . '<task>failed</task>' . "\n";
            echo "\t" . '<info>boom</info>' . "\n";
            echo "\t" . '<debug><![CDATA[' . $debug_str . ']]></debug>' . "\n";
            echo '</response>' . "\n";
        }
    }
    exit;
}
    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();
    }
    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();
    }
function show_agenda_items($id, $option, $rows, $date, $sort)
{
    global $Itemid;
    $selected = strval(mosGetParam($_REQUEST, 'jlms_agenda_order', ''));
    $selected_filter = strval(mosGetParam($_REQUEST, 'jlms_agenda_filter', ''));
    $JLMS_ACL =& JLMSFactory::getACL();
    if ($JLMS_ACL->CheckPermissions('announce', 'view')) {
        $lists = array();
        $order = array();
        //formiruem spisok Ordering
        $order[] = mosHTML::makeOption('desc', _JLMS_AGENDA_DESC);
        $order[] = mosHTML::makeOption('asc', _JLMS_AGENDA_ASC);
        $lists['order'] = mosHTML::selectList($order, 'jlms_agenda_order', 'class="inputbox" size="1" ', 'value', 'text', $selected);
        //formiruem spisok Filter
        $filter[] = mosHTML::makeOption('0', _JLMS_SB_FILTER_NONE);
        $filter[] = mosHTML::makeOption('current', _JLMS_AGENDA_TODAY);
        $filter[] = mosHTML::makeOption('upcoming', _JLMS_AGENDA_UPCOMING);
        $lists['filter'] = mosHTML::selectList($filter, 'jlms_agenda_filter', 'class="inputbox" size="1" ', 'value', 'text', $selected_filter);
        function add_to_agenda(&$agenda, $d)
        {
            $do_add = true;
            for ($i = 0, $n = count($agenda); $i < $n; $i++) {
                if ($agenda[$i]->a_y . '-' . $agenda[$i]->a_m == substr($d, 0, 7)) {
                    $do_add = false;
                }
            }
            if ($do_add) {
                $ff = new stdClass();
                $ff->a_y = substr($d, 0, 4);
                $ff->a_m = substr($d, 5, 2);
                $ff->items = array();
                $agenda[] = $ff;
            }
        }
        function fill_my(&$agenda, &$st, &$en)
        {
            $i = 0;
            $do = true;
            while ($do) {
                $d = date("Y-m-1", strtotime("+{$i} month", strtotime($st)));
                if (strtotime($d) <= strtotime($en)) {
                    add_to_agenda($agenda, $d);
                } else {
                    $do = false;
                }
                $i++;
            }
        }
        $agenda = array();
        foreach ($rows as $row) {
            $tmp_date = $row->start_date;
            fill_my($agenda, $row->start_date, $row->end_date);
        }
        for ($i = 0, $n = count($agenda) - 1; $i < $n; $i++) {
            for ($j = $i, $m = count($agenda); $j < $m; $j++) {
                if ($sort == 'asc') {
                    if ($agenda[$j]->a_y < $agenda[$i]->a_y || $agenda[$j]->a_y == $agenda[$i]->a_y && $agenda[$j]->a_m < $agenda[$i]->a_m) {
                        $k = $agenda[$j];
                        $agenda[$j] = $agenda[$i];
                        $agenda[$i] = $k;
                    }
                } else {
                    if ($agenda[$j]->a_y > $agenda[$i]->a_y || $agenda[$j]->a_y == $agenda[$i]->a_y && $agenda[$j]->a_m > $agenda[$i]->a_m) {
                        $k = $agenda[$j];
                        $agenda[$j] = $agenda[$i];
                        $agenda[$i] = $k;
                    }
                }
            }
        }
        //		print_r($agenda);die;
        foreach ($rows as $row) {
            for ($i = 0, $n = count($agenda); $i < $n; $i++) {
                if ($agenda[$i]->a_y . '-' . $agenda[$i]->a_m == substr($row->start_date, 0, 7) || $agenda[$i]->a_y . '-' . $agenda[$i]->a_m == substr($row->end_date, 0, 7) || strtotime($agenda[$i]->a_y . '-' . $agenda[$i]->a_m . '-1') >= strtotime($row->start_date) && strtotime($agenda[$i]->a_y . '-' . $agenda[$i]->a_m . '-1') <= strtotime($row->end_date)) {
                    $agenda[$i]->items[] = $row;
                }
            }
        }
        JLMS_agenda_html::show_agenda_items($id, $option, $rows, $date, $lists, $agenda);
    } else {
        JLMSRedirect(sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}"));
    }
}
function JLMS_DelOp_deleteCourseAssistants($course_id, &$cid)
{
    global $JLMS_DB, $JLMS_CONFIG;
    $JLMS_ACL =& JLMSFactory::getACL();
    $ass_roles = $JLMS_ACL->GetSystemRolesIds(5);
    if (!count($ass_roles)) {
        return false;
    }
    $ass_roles_str = implode(',', $ass_roles);
    $cids = implode(',', $cid);
    $query = "DELETE FROM #__lms_user_courses WHERE course_id = '" . $course_id . "' AND user_id IN ({$cids}) AND role_id In ({$ass_roles_str})";
    $JLMS_DB->SetQuery($query);
    $JLMS_DB->query();
    if ($JLMS_CONFIG->get('plugin_forum')) {
        $forum =& JLMS_SMF::getInstance();
        if (!is_object($forum)) {
            $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 WHERE course_id = {$course_id}";
            $JLMS_DB->SetQuery($query);
            $forum_det = $JLMS_DB->LoadObjectList();
            if (count($forum_det)) {
                $query = "SELECT username FROM #__users WHERE user_id IN ({$cids})";
                $JLMS_DB->SetQuery($query);
                $assist_usernames = $JLMS_DB->LoadResultArray();
                $boards = array();
                foreach ($forum_det as $fd) {
                    $boards[] = $fd->id_board;
                }
                foreach ($assist_usernames as $au) {
                    $forum->deleteModerators($boards, $au);
                }
            }
        }
    }
}
    function showCourseDocuments($id, $option, &$rows, &$lists, &$possibilities)
    {
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $Itemid = $JLMS_CONFIG->get('Itemid');
        $db =& JFactory::getDbo();
        $user = JLMSFactory::getUser();
        $JLMS_ACL =& JLMSFactory::getACL();
        $lms_img_path = $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('lms_path_to_images', 'components/com_joomla_lms/lms_images');
        $rows_c = $lists['collapsed_folders'];
        ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if ((pressbutton == 'doc_delete') && (form.boxchecked.value == '0')) {
		alert( "<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
" );
	} else if((pressbutton == 'doc_delete')){
		if(confirm('<?php 
        echo _JLMS_OUTDOCS_JS_CONFIRM_DELETE;
        ?>
')){
			form.task.value = pressbutton;
			form.submit();
		}	
	} else if ((pressbutton == 'edit_doc') && (form.boxchecked.value == '0')) {
		alert( "<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
" );
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}
function submitbutton_change(pressbutton, state) {
	var form = document.adminForm;
	if (pressbutton == 'change_doc'){
		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_doc'){
		form.task.value = pressbutton;
		form.state.value = state;
		form.cid2.value = cid_id;
		form.submit();
	}
}
function submitbutton_order(pressbutton, item_id) {
	var form = document.adminForm;
	if ((pressbutton == 'doc_orderup') || (pressbutton == 'doc_orderdown')){
		if (item_id) {
		form.task.value = pressbutton;
		form.row_id.value = item_id;
		form.submit();
		}
	}
}
function cf_saveorder(){
	var form = document.adminForm;	
	form.task.value = 'doc_saveorder';
	form.submit();
}

var TreeArray1 = new Array();
var TreeArray2 = new Array();
var Is_ex_Array = new Array();
<?php 
        $i = 1;
        foreach ($rows as $row) {
            if ($row->p_view) {
                echo "TreeArray1[" . $i . "] = " . $row->parent_id . ";";
                echo "TreeArray2[" . $i . "] = " . $row->id . ";";
                if (in_array($row->id, $rows_c)) {
                    echo "Is_ex_Array[" . $i . "] = 0;";
                } else {
                    echo "Is_ex_Array[" . $i . "] = 1;";
                }
                $i++;
            }
        }
        ?>
function Hide_Folder(fid) {
	var vis_style = 'hidden';
	var dis_style = 'none';
	var i = 1;
	while (i < TreeArray1.length) {
		if (TreeArray1[i] == fid) {
			getObj('tree_row_'+TreeArray2[i]).style.visibility = vis_style;
			getObj('tree_row_'+TreeArray2[i]).style.display = dis_style;
			Hide_Folder(TreeArray2[i])
		}
		i ++;
	}
}
function Show_Folder(fid) {
	var vis_style = 'visible';
	var dis_style = '';
	var i = 1;
	while (i < TreeArray1.length) {
		if (TreeArray1[i] == fid) {
			if (getObj('tree_row_'+TreeArray2[i])) {
				getObj('tree_row_'+TreeArray2[i]).style.display = dis_style;
				getObj('tree_row_'+TreeArray2[i]).style.visibility = vis_style;
			}
			NoChange_Folder(TreeArray2[i])
		}
		i ++;
	}
}
function NoChange_Folder(fid) {
	var vis_style = 'hidden';var dis_style = 'none';var i = 1;var j = 0;
	while (i < TreeArray2.length) {
		if ( (TreeArray2[i] == fid) && (Is_ex_Array[i] == 1) ) {
			vis_style = 'visible';
			dis_style = '';
			j = 1;
		}
		i ++;
	}
	i = 1;
	while (i < TreeArray1.length) {
		if (TreeArray1[i] == fid) {
			getObj('tree_row_'+TreeArray2[i]).style.visibility = vis_style;
			getObj('tree_row_'+TreeArray2[i]).style.display = dis_style;
			if (j == 1) { NoChange_Folder(TreeArray2[i]);
			} else { Hide_Folder(TreeArray2[i]); }
		}
		i ++;
	}
}
function Ex_Folder(fid) {
	var i = 1;
	var j = 1;
	while (i < TreeArray2.length) {
		if ( (TreeArray2[i] == fid) && (Is_ex_Array[i] == 1) ) { j = 0; }
		i ++;
	}
	if (j == 1) {
		Show_Folder(fid);
		if (getObj('tree_img_' + fid).runtimeStyle) {
			var StStr = getObj('tree_img_' + fid).runtimeStyle.filter;
			var imgStr = getObj('tree_img_' + fid).outerHTML;
			imgStr = imgStr.replace('expandall.png','collapseall.png').replace('<?php 
        echo _JLMS_DOCS_EXP_FOLDER;
        ?>
', '<?php 
        echo _JLMS_DOCS_COLL_FOLDER;
        ?>
');
			StStr = StStr.replace('expandall.png','collapseall.png');
			getObj('tree_img_' + fid).outerHTML = imgStr;
			getObj('tree_img_' + fid).runtimeStyle.filter = StStr;
		} else {
			getObj('tree_img_' + fid).src = '<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/docs/collapseall.png';
			getObj('tree_img_' + fid).alt = '<?php 
        echo _JLMS_DOCS_COLLAPSE;
        ?>
';
			getObj('tree_img_' + fid).title = '<?php 
        echo _JLMS_DOCS_COLL_FOLDER;
        ?>
';
		}
	} else {
		Hide_Folder(fid);
		if (getObj('tree_img_' + fid).runtimeStyle) {
			var StStr = getObj('tree_img_' + fid).runtimeStyle.filter;
			var imgStr = getObj('tree_img_' + fid).outerHTML;
			imgStr = imgStr.replace('collapseall.png','expandall.png').replace('<?php 
        echo _JLMS_DOCS_COLL_FOLDER;
        ?>
', '<?php 
        echo _JLMS_DOCS_EXP_FOLDER;
        ?>
');
			StStr = StStr.replace('collapseall.png','expandall.png');
			getObj('tree_img_' + fid).outerHTML = imgStr;
			getObj('tree_img_' + fid).runtimeStyle.filter = StStr;
		} else {
			getObj('tree_img_' + fid).src = '<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/docs/expandall.png';
			getObj('tree_img_' + fid).alt = '<?php 
        echo _JLMS_DOCS_EXPAND;
        ?>
';
			getObj('tree_img_' + fid).title = '<?php 
        echo _JLMS_DOCS_EXP_FOLDER;
        ?>
';
		}
	}
	i = 1;
	while (i < TreeArray2.length) {
		if ( (TreeArray2[i] == fid) ) {
			if (Is_ex_Array[i] == 1) { Is_ex_Array[i] = 0;
			} else { Is_ex_Array[i] = 1; }
		}
		i ++;
	}
}
<?php 
        if ($possibilities->manage && count($rows)) {
            ?>
var docs_save_blocked = false;
function Docs_WriteSysMsg(mes) {
	if (jlms_writetxt('joomlalms_sys_message', mes)) {
		getObj('joomlalms_sys_message_container').style.display = '';
		getObj('joomlalms_sys_message_container').style.visibility = 'visible';
	}
}
function Docs_save_view() {
	if (!docs_save_blocked) {
		var prepare_str = '';
		Docs_WriteSysMsg("<img src='<?php 
            echo $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator');
            ?>
' />");
		i = 1;
		var ps_pref = '';
		while (i < TreeArray2.length) {
			if (Is_ex_Array[i] == 0) {
				prepare_str = ''+ prepare_str + ps_pref + TreeArray2[i];
				ps_pref = '-';
			}
			i ++;
		}
		Docs_MakeRequest(prepare_str);
	}
}
function Docs_analize_req(http_request) {
	if (http_request.readyState == 4) {
		if ((http_request.status == 200)) {
			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 mes = response.getElementsByTagName('message')[0].firstChild.data
		} else {
			var mes = "Request failed";
		}
		Docs_WriteSysMsg(mes);
		docs_save_blocked = false;
	}
}

function Docs_MakeRequest(req_str) {
	docs_save_blocked = true;
	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() { Docs_analize_req(http_request); };
	var lp_url_prefix2 = '';
	var post_target = '<?php 
            echo $JLMS_CONFIG->get('ajax_settings_request_safe_path');
            ?>
';
	var url = 'task=documents_view_save&id=<?php 
            echo $id;
            ?>
&folders='+req_str;
	http_request.open("POST", post_target, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", url.length);
	//http_request.setRequestHeader("Connection", "close");
	http_request.send(url);
}
<?php 
        }
        ?>
JLMS_preloadImages('<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/docs/expandall.png','<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/docs/collapseall.png'<?php 
        echo ", '" . $JLMS_CONFIG->get('live_site') . '/' . $JLMS_CONFIG->get('ajax_settings_small_indicator') . "'";
        ?>
);
//--><!]]>
</script>
<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        $toolbar = array();
        if ($JLMS_ACL->CheckPermissions('docs', 'manage') && count($rows)) {
            // this feature is available only for users who has 'documents' manage permission (for entire tool)
            $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:Docs_save_view();", 'btn_title' => _JLMS_DOCS_SAVE_VIEW_TITLE);
        }
        JLMS_TMPL::ShowHeader('docs', _JLMS_DOCS_COURSE_DOCS, $hparams, $toolbar);
        $max_tree_width = 0;
        if (isset($rows[0])) {
            $max_tree_width = $rows[0]->tree_max_width;
        }
        JLMS_TMPL::OpenTS();
        ?>
			<form action="<?php 
        echo $JLMS_CONFIG->get('live_site') . "/index.php?option=" . $option . "&amp;Itemid=" . $Itemid;
        ?>
" method="post" name="adminForm" enctype="multipart/form-data">
<?php 
        if (!empty($rows)) {
            ?>
				<table width="100%" cellpadding="0" cellspacing="0" border="0" id="jlms_doc_non_scr" 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 ($possibilities->manage || $possibilities->publish) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 width="20" class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
"><input type="checkbox" value="0" name="fake_checkbox" style="visibility:hidden" /></<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
					<?php 
            for ($th_i = 0; $th_i < $max_tree_width + 1; $th_i++) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 width="16" class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
">&nbsp;</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<?php 
            }
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="45%"><span style="display:block; width:150px; text-align:left;"><?php 
            echo _JLMS_DOCS_TBL_DOCNAME;
            ?>
</span></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
            if ($possibilities->order) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" colspan="2" width="1">
						<?php 
                echo JText::_(_JLMS_REORDER);
                ?>
						</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">
							<?php 
                echo _JLMS_ORDER;
                ?>
						</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">
						<a href="javascript:saveorder(<?php 
                echo count($rows) - 1;
                ?>
, 'doc_saveorder');">
							<img src="<?php 
                echo $lms_img_path;
                ?>
/toolbar/tlb_filesave.png" border="0" width="16" height="16" alt="<?php 
                echo _JLMS_SAVEORDER;
                ?>
" title="<?php 
                echo _JLMS_SAVEORDER;
                ?>
" />
						</a>
						</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
					<?php 
            if ($possibilities->manage || $possibilities->publish) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">&nbsp;</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
"><?php 
                echo _JLMS_DOCS_TBL_STARTING;
                ?>
</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
"><?php 
                echo _JLMS_DOCS_TBL_ENDING;
                ?>
</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="60%"><span style="display:block; width:110px;"><?php 
            echo _JLMS_DOCS_TBL_DESCR;
            ?>
</span></<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					</tr>
				<?php 
            $k = 1;
            $tree_modes = array();
            $visible_folder = true;
            //$next_row_is_visible = true;
            $vis_mode = 0;
            $doc_number = 1;
            for ($i = 0, $n = count($rows); $i < $n; $i++) {
                $row = $rows[$i];
                if ($row->p_view) {
                    // if user can view this item
                    $max_tree_width = $row->tree_max_width;
                    $link = '';
                    $link_title = '';
                    if ($row->folder_flag == 2) {
                        $link = sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=docs_view_zip&amp;course_id=" . $id . "&amp;id=" . $row->id);
                        $link_title = _JLMS_T_A_VIEW_ZIP_PACK;
                    } elseif ((!$row->folder_flag || $row->folder_flag == 3) && $row->file_id) {
                        $link = sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=get_document&amp;course_id=" . $id . "&amp;id=" . $row->id);
                        $link_title = _JLMS_DOCS_LINK_DOWNLOAD;
                    } elseif ((!$row->folder_flag || $row->folder_flag == 3) && !$row->file_id) {
                        $link = sefRelToAbs("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=docs_view_content&amp;course_id=" . $id . "&amp;id=" . $row->id);
                        $link_title = _JLMS_T_A_VIEW_CONTENT;
                    }
                    $time_p = $row->publish_start || $row->publish_end;
                    $alt = $row->published ? $time_p ? _JLMS_STATUS_PUB2 : _JLMS_STATUS_PUB : _JLMS_STATUS_UNPUB;
                    $image = $row->published ? $time_p ? 'btn_publish_wait.png' : 'btn_accept.png' : 'btn_cancel.png';
                    //($time_p?'btn_unpublish_wait.png':'btn_cancel.png');
                    $start_date_txt = '';
                    $end_date_txt = '';
                    $released_info_txt = '';
                    if ($row->is_time_related) {
                        $released_info_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;
                        $released_info_time = false;
                        if ($sp_days) {
                            $released_info_txt .= ' ' . $sp_days . ' ' . _JLMS_RELEASED_IN_DAYS;
                            $released_info_time = true;
                        }
                        if ($sp_hours) {
                            $released_info_txt .= ' ' . $sp_hours . ' ' . _JLMS_RELEASED_IN_HOURS;
                            $released_info_time = true;
                        }
                        if ($sp_mins) {
                            $released_info_txt .= ' ' . $sp_mins . ' ' . _JLMS_RELEASED_IN_MINUTES;
                            $released_info_time = true;
                        }
                        if ($released_info_time) {
                            $released_info_txt .= ' ' . _JLMS_RELEASED_AFTER_ENROLLMENT;
                        }
                    }
                    if ($time_p) {
                        $is_expired = false;
                        if ($row->publish_end) {
                            $end_date_txt = _JLMS_COURSES_END_DATE . ': ' . $row->end_date;
                            $e_date = strtotime($row->end_date);
                            if ($e_date < time()) {
                                $is_expired = true;
                            }
                        }
                        if ($row->publish_start) {
                            $start_date_txt = _JLMS_COURSES_ST_DATE . ': ' . $row->start_date;
                        }
                        if ($is_expired) {
                            $alt = _JLMS_STATUS_EXPIRED;
                            $image = 'btn_expired.png';
                        } elseif ($row->publish_start && !$is_expired) {
                            $s_date = strtotime($row->start_date);
                            if ($s_date > time()) {
                                $alt = _JLMS_STATUS_UPCOMING;
                                $image = 'btn_expired.png';
                            }
                        }
                    }
                    $state = $row->published ? 0 : 1;
                    $checked = mosHTML::idBox($i, $row->id);
                    $manage_item = false;
                    $publish_item = false;
                    if ($row->p_manage) {
                        //JLMS_ACL->CheckPermissions('docs', 'manage')) {
                        $manage_item = true;
                    }
                    if ($row->p_publish) {
                        //$JLMS_ACL->CheckPermissions('docs', 'publish')) {
                        $publish_item = true;
                    }
                    if ($JLMS_ACL->CheckPermissions('docs', 'only_own_items') && $row->owner_id != $user->get('id')) {
                        $manage_item = false;
                        $publish_item = false;
                    } elseif ($JLMS_ACL->CheckPermissions('docs', 'only_own_role') && $JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($db, $row->owner_id)) {
                        $manage_item = false;
                        $publish_item = false;
                    }
                    if (!$publish_item && !$manage_item) {
                        $checked = '&nbsp;';
                    }
                    // Collapsed/Expanded view
                    $tree_row_style = '';
                    $visible_folder = true;
                    //$next_row_is_visible;
                    //$next_row_is_visible = true;
                    if ($vis_mode) {
                        if ($row->tree_mode_num < $vis_mode) {
                            $vis_mode = 0;
                        }
                    }
                    if (in_array($row->id, $rows_c)) {
                        //$next_row_is_visible = false;
                        if ($vis_mode) {
                            if ($row->tree_mode_num < $vis_mode) {
                                $vis_mode = $row->tree_mode_num;
                            } else {
                                $visible_folder = false;
                            }
                        } else {
                            $vis_mode = $row->tree_mode_num + 1;
                        }
                    } elseif ($vis_mode) {
                        if ($row->tree_mode_num >= $vis_mode) {
                            $visible_folder = false;
                        } else {
                            $vis_mode = 0;
                        }
                    }
                    if (!$visible_folder) {
                        $tree_row_style = ' style="visibility:hidden;display:none"';
                    }
                    ?>
					<tr id="tree_row_<?php 
                    echo $row->id;
                    ?>
" class="<?php 
                    echo JLMSCSS::_('sectiontableentry' . $k);
                    ?>
"<?php 
                    echo $tree_row_style;
                    ?>
>
						<td align="center" valign="middle"><?php 
                    echo $doc_number;
                    ?>
</td>
					<?php 
                    if ($possibilities->manage || $possibilities->publish) {
                        ?>
						<td valign="middle"><?php 
                        echo $row->p_manage || $row->p_publish ? $checked : '<input type="checkbox" value="0" name="fake_checkbox' . $row->id . '" style="visibility:hidden" />';
                        ?>
</td>
					<?php 
                    }
                    ?>
						<?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 src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/treeview/" . $pref . "line.png\" width='16' height='16' alt='" . $pref . "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->tree_mode . ".png\" width='16' height='16' alt='sub" . $row->tree_mode . "' /></td>";
                        $max_tree_width = $max_tree_width - $g - 1;
                    }
                    echo $add_img;
                    ?>
						<td align="center" valign="middle" width='16'>
						<?php 
                    if ($row->folder_flag == 1) {
                        $collapse_img = 'collapseall.png';
                        $collapse_alt = _JLMS_DOCS_COLL_FOLDER;
                        if (in_array($row->id, $rows_c)) {
                            $collapse_img = 'expandall.png';
                            $collapse_alt = _JLMS_DOCS_EXP_FOLDER;
                        }
                        echo "<a class='jlms_img_link' id='tree_div_" . $row->id . "' style='alignment:center; width:16px; font-weight:bold; cursor:pointer; vertical-align:middle;' onclick='Ex_Folder(" . $row->id . "," . $row->id . ",true)' href='javascript:void(0);'><img class='JLMS_png' id='tree_img_" . $row->id . "' src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/docs/{$collapse_img}\" width='13' height='13' border='0' alt='" . $collapse_alt . "' title='" . $collapse_alt . "' /></a>";
                    } else {
                        echo "<span style='alignment:center; width:16px; 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='{$row->file_icon}' /></span>";
                    }
                    ?>
						</td>
						<td align="left" valign="middle" <?php 
                    if ($max_tree_width > 0) {
                        echo "colspan='" . ($max_tree_width + 1) . "'";
                    }
                    ?>
 width="<?php 
                    echo $row->tree_mode_num == $row->tree_max_width ? '85' : '45';
                    ?>
%">
						<span style='font-weight:bold; vertical-align:middle;'>
						<?php 
                    if ($row->folder_flag == 1) {
                        echo '&nbsp;<strong>' . $row->doc_name . '</strong>';
                    } else {
                        if (!isset($row->is_link)) {
                            ?>
							<a href="<?php 
                            echo $link;
                            ?>
" title="<?php 
                            echo str_replace('"', '&quot;', $row->doc_name);
                            ?>
">
								&nbsp;<?php 
                            echo $row->doc_name;
                            ?>
							</a>
						<?php 
                        } else {
                            echo $row->doc_name;
                        }
                    }
                    ?>
						</span>
						<?php 
                    if ($JLMS_CONFIG->get('show_docs_authors', 0) && $row->author_name) {
                        ?>
						<br />
						<span class="small"><?php 
                        echo _JLMS_HOME_AUTHOR . "&nbsp;" . $row->author_name;
                        ?>
</span>
						<?php 
                    }
                    ?>
						</td>
					<?php 
                    if ($possibilities->order) {
                        ?>
						<td valign="middle" style="vertical-align:middle "><?php 
                        if ($row->allow_up == 1 && $row->p_order) {
                            echo JLMS_orderUpIcon(1, $row->id, true, 'doc_orderup');
                        } else {
                            echo '&nbsp;';
                        }
                        ?>
</td>
						<td valign="middle" style="vertical-align:middle "><?php 
                        if ($row->allow_down == 1 && $row->p_order) {
                            echo JLMS_orderDownIcon(1, 3, $row->id, true, 'doc_orderdown');
                        } else {
                            echo '&nbsp;';
                        }
                        ?>
</td>
						<td valign="middle" align="center" style="vertical-align:middle; text-align: center; " colspan="2">
							<input type="text" name="order[]" size="5" value="<?php 
                        echo $row->ordering;
                        ?>
" class="inputbox" style="text-align: center;" />
						</td>
					<?php 
                    }
                    ?>
					<?php 
                    if ($possibilities->manage || $possibilities->publish) {
                        ?>
						<td valign="middle">
						<?php 
                        if ($publish_item) {
                            $title = $alt;
                            $content = '';
                            if ($start_date_txt) {
                                $content .= $start_date_txt . '<br />';
                            }
                            if ($end_date_txt) {
                                $content .= $end_date_txt . '<br />';
                            }
                            if ($released_info_txt) {
                                $content .= $released_info_txt . '<br />';
                            }
                            if ($row->is_time_related) {
                                if ($image == 'btn_accept.png') {
                                    $image = 'btn_publish_wait.png';
                                }
                            }
                            $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 . '" />';
                            $link = 'javascript:submitbutton_change2(\'change_doc\',' . $state . ',' . $row->id . ')';
                            echo JLMS_toolTip($title, $content, $name, $link);
                        } else {
                            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 . '" />';
                        }
                        ?>
						</td>
						<td align="center" nowrap='nowrap' valign="middle"><?php 
                        echo $row->publish_start ? JLMS_dateToDisplay($row->start_date) : '-';
                        ?>
</td>
						<td align="center" nowrap='nowrap' valign="middle"><?php 
                        echo $row->publish_end ? JLMS_dateToDisplay($row->end_date) : '-';
                        ?>
</td>
					<?php 
                    }
                    ?>
						<td><?php 
                    $doc_descr = strip_tags($row->doc_description);
                    $doc_descr = trim($doc_descr);
                    if (!$row->folder_flag && !$row->file_id) {
                        if (strlen($doc_descr) > 75) {
                            $doc_descr = substr($doc_descr, 0, 75) . "...";
                        }
                    }
                    echo $doc_descr ? $doc_descr : '&nbsp;';
                    ?>
						</td>
					</tr>
					<?php 
                    $k = 3 - $k;
                    $doc_number++;
                }
                // end "if ($row->p_view)"
            }
            ?>
				</table>
<?php 
        } 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="" />
				<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>
			<noscript>
			<style type="text/css">
			 #jlms_doc_non_scr tr.sectiontableentry1, #jlms_doc_non_scr tr.sectiontableentry2 {
			 display: table-row !important;
			 visibility:visible !important;
			 }
			</style>
			<!--[if IE]>
			<style type="text/css">
			 #jlms_doc_non_scr tr.sectiontableentry1, #jlms_doc_non_scr tr.sectiontableentry2 {
				 display: block !important;
				 visibility:visible !important;
			 }
			</style>
			<![endif]-->
			</noscript>
<?php 
        JLMS_TMPL::CloseTS();
        $controls = array();
        if ($possibilities->publish) {
            $controls[] = array('href' => "javascript:submitbutton_change('change_doc',1);", 'title' => _JLMS_SET_PUB, 'img' => 'publish');
            $controls[] = array('href' => "javascript:submitbutton_change('change_doc',0);", 'title' => _JLMS_SET_UNPUB, 'img' => 'unpublish');
            if ($possibilities->manage) {
                $controls[] = array('href' => 'spacer');
            }
        }
        if ($possibilities->create) {
            $link_foldernew = ampReplace(sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=new_folder&amp;id={$id}"));
            $link_filenew = ampReplace(sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=new_document&amp;id={$id}"));
            $controls[] = array('href' => $link_foldernew, 'title' => _JLMS_DOCS_LNK_NEW_FOLDER, 'img' => 'foldernew');
            $controls[] = array('href' => $link_filenew, 'title' => _JLMS_DOCS_LNK_NEW_DOC, 'img' => 'filenew');
        }
        if ($possibilities->manage) {
            $controls[] = array('href' => "javascript:submitbutton('doc_delete');", 'title' => _JLMS_DELETE, 'img' => 'delete');
            $controls[] = array('href' => "javascript:submitbutton('edit_doc');", 'title' => _JLMS_EDIT, 'img' => 'edit');
        }
        if ($JLMS_ACL->CheckPermissions('docs', 'manage')) {
            $controls[] = array('href' => "javascript:submitbutton('add_doclink');", 'title' => _JLMS_DOCS_ADD_FROM_LIBRARY, 'img' => 'add_library');
        }
        if (count($controls)) {
            JLMS_TMPL::ShowControlsFooter($controls);
        }
        JLMS_TMPL::CloseMT();
    }
    function showHomeWorks($id, $option, &$rows, &$pageNav, $usertype = 1)
    {
        global $JLMS_CONFIG;
        $Itemid = $JLMS_CONFIG->get('Itemid');
        $JLMS_ACL =& JLMSFactory::getACL();
        if ($JLMS_ACL->CheckPermissions('homework', 'manage')) {
            ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if ( ((pressbutton == 'hw_delete') || (pressbutton == 'hw_edit')) && (form.boxchecked.value == "0")){
		alert("<?php 
            echo _JLMS_ALERT_SELECT_ITEM;
            ?>
");
	} else {
		form.task.value = pressbutton;
		form.submit();
	}
}

function submitbutton_change2(pressbutton, state, cid_id) {
	var form = document.adminForm;
	if (pressbutton == 'hw_publish'){
		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('homework', _JLMS_HW_TITLE_HW, $hparams);
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}");
        ?>
" method="post" name="adminForm">
<?php 
        if (!empty($rows)) {
            ?>
				<?php 
            $hw_colspan = 5;
            ?>
				<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 ($usertype == 1) {
            if ($JLMS_ACL->CheckPermissions('homework', 'manage')) {
                $hw_colspan++;
                ?>
						<<?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');
            ?>
" width="30%"><?php 
            echo _JLMS_HW_TBL_HEAD_HW;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" nowrap='nowrap' style="white-space:nowrap"><?php 
            echo _JLMS_HW_TBL_HEAD_DATE;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" nowrap='nowrap' style="white-space:nowrap"><?php 
            echo _JLMS_HW_TBL_HEAD_ENDDATE;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					<?php 
            if ($JLMS_ACL->CheckPermissions('homework', 'manage')) {
                $hw_colspan++;
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" nowrap='nowrap' style="white-space:nowrap">&nbsp;</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
" width="50%"><?php 
            echo _JLMS_HW_TBL_HEAD_DESCR;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					</tr>
				<?php 
            $k = 1;
            for ($i = 0, $n = count($rows); $i < $n; $i++) {
                $row = $rows[$i];
                $link = "index.php?option={$option}&Itemid={$Itemid}&task=hw_stats&course_id={$id}&id={$row->id}";
                $alt = $row->published ? _JLMS_STATUS_PUB : _JLMS_STATUS_UNPUB;
                $image = $row->published ? 'btn_accept.png' : 'btn_cancel.png';
                $state = $row->published ? 0 : 1;
                $tooltip_txt = '';
                $tooltip_title = '';
                if ($row->is_time_related) {
                    if ($row->published) {
                        $image = 'btn_publish_wait.png';
                        $tooltip_title = _JLMS_STATUS_PUB;
                    } else {
                        $image = 'btn_unpublish_wait.png';
                        $tooltip_title = _JLMS_STATUS_UNPUB;
                    }
                    $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 = '';
                if ($JLMS_ACL->CheckPermissions('homework', 'manage')) {
                    $checked = mosHTML::idBox($i, $row->id, $row->checkedout);
                }
                ?>
					<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
						<td align="center"><?php 
                echo $pageNav->limitstart + $i + 1;
                ?>
</td>
						<?php 
                if ($JLMS_ACL->CheckPermissions('homework', 'manage')) {
                    echo '<td>' . $checked . '</td>';
                }
                ?>
						<td align="left" valign="middle" style="vertical-align:middle ">
							<a href="<?php 
                echo sefRelToAbs($link);
                ?>
" title="<?php 
                echo str_replace('"', '&nbsp;', $row->hw_name);
                ?>
">
								<?php 
                echo $row->hw_name;
                ?>
							</a>
						</td>
						<td valign="middle" style="vertical-align:middle" nowrap="nowrap">
							<?php 
                echo JLMS_dateToDisplay($row->post_date);
                ?>
						</td>
						<td valign="middle" style="vertical-align:middle" nowrap="nowrap">
							<?php 
                echo JLMS_dateToDisplay($row->end_date);
                ?>
						</td>
					<?php 
                if ($JLMS_ACL->CheckPermissions('homework', 'manage')) {
                    ?>
						<td valign="middle">
						<?php 
                    if ($row->is_time_related) {
                        $tooltip_link = 'javascript:submitbutton_change2(\'hw_publish\',' . $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($tooltip_title, $tooltip_txt, $tooltip_name, $tooltip_link);
                    } else {
                        echo '<a class="jlms_img_link" href="javascript:submitbutton_change2(\'hw_publish\',' . $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 
                }
                ?>
						<td valign="middle" style="vertical-align:middle "><?php 
                echo $row->hw_shortdescription ? $row->hw_shortdescription : '&nbsp;';
                ?>
</td>
					</tr>
					<?php 
                $k = 3 - $k;
            }
            ?>
				
				<tr>
					<td align="center" class="<?php 
            echo JLMSCSS::_('jlmslist-footer_td');
            ?>
" colspan="<?php 
            echo $hw_colspan;
            ?>
"><div align="center" style="white-space:nowrap;">
					<?php 
            $link = "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=homework&amp;id={$id}";
            echo _JLMS_PN_DISPLAY_NUM . $pageNav->getLimitBox($link) . '&nbsp;' . $pageNav->getPagesCounter();
            echo '<br />';
            echo $pageNav->writePagesLinks($link);
            ?>
 
					</div></td>
				</tr>
				</table>
<?php 
        } 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="homework" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
		<input type="hidden" name="state" value="0" />
		<input type="hidden" name="cid2" value="0" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        if ($id && $JLMS_ACL->CheckPermissions('homework', 'manage')) {
            $link_new = sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=hw_create&id={$id}");
            $controls = array();
            $controls[] = array('href' => $link_new, 'onclick' => "", 'title' => _JLMS_HW_IMG_NEW_HW, 'img' => 'add');
            $controls[] = array('href' => "javascript:submitbutton('hw_delete');", 'title' => _JLMS_HW_IMG_DEL_HW, 'img' => 'delete');
            $controls[] = array('href' => "javascript:submitbutton('hw_edit');", 'title' => _JLMS_HW_IMG_EDIT_HW, 'img' => 'edit');
            JLMS_TMPL::ShowControlsFooter($controls);
        }
        JLMS_TMPL::CloseMT();
    }
    function editDropBox(&$row, &$lists, $option, $course_id)
    {
        global $Itemid, $my;
        ?>
<script language="javascript" type="text/javascript">
<!--//--><![CDATA[//><!--
function setgood() {
	return true;
}
function submitbutton(pressbutton) {
	var form=document.adminForm;
	try {
		form.onsubmit();
	} catch(e) {
		//alert(e);
	}
	if ((pressbutton=='save_dropbox') && ((form.userfile.value=="") && (form.dropbox_name.value==""))){
			alert("<?php 
        echo _JLMS_SELECT_FILE_ENTER_NAME;
        ?>
");
	}
	 else {form.task.value = pressbutton;form.submit();}
}
//--><!]]>
</script>
<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        $toolbar = array();
        $toolbar[] = array('btn_type' => 'save', 'btn_js' => "javascript:submitbutton('save_dropbox');");
        $toolbar[] = array('btn_type' => 'cancel', 'btn_js' => "javascript:submitbutton('cancel_dropbox');");
        JLMS_TMPL::ShowHeader('dropbox', _JLMS_DROP_ADD_ITEM, $hparams, $toolbar);
        JLMS_TMPL::OpenTS();
        ?>
		<form action="<?php 
        echo sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}");
        ?>
" method="post" name="adminForm" enctype="multipart/form-data" onsubmit="setgood();">
			<table width="100%" cellpadding="0" cellspacing="0" border="0" id="jlms_item_properties">
				<tr>
					<td width="30%" valign="top" style="vertical-align:top"><?php 
        echo _JLMS_DROP_SEND_TO;
        ?>
</td>
					<td>
						<?php 
        echo $lists['course_users'];
        ?>
					</td>
				</tr>
				
				<tr>
					<td height="15"></td>
					<td></td>
				</tr>
				<tr>
					<td valign="middle" style="vertical-align:middle">
						<?php 
        echo _JLMS_DROP_NAME;
        ?>
					</td>
					<td>
						<input type="text" class="inputbox" name="dropbox_name" size="52" value="<?php 
        echo $row->drp_name;
        ?>
">
					</td>				
				</tr>
				<?php 
        $detect = false;
        $path_detect = JPATH_SITE . DS . 'components' . DS . 'com_jlms_profile' . DS . 'jlms_profile_detect.php';
        if (file_exists($path_detect)) {
            include_once $path_detect;
            $detect = COMPONENT_Profile_Detect();
        }
        if ($detect) {
            $params = array();
            $params['width'] = 800;
            $params['height'] = 600;
            echo showChooseFiles($params);
        } else {
            ?>
				<tr>
					<td valign="middle" style="vertical-align:middle"><br /><?php 
            echo _JLMS_CHOOSE_FILE;
            ?>
</td>
					<td>
						<br />
						<input class="inputbox" size="40" type="file" name="userfile">
					</td>
				</tr>
				<?php 
        }
        ?>
				<?php 
        //				if (JLMS_GetUserType($my->id, $course_id) == 1) {
        $JLMS_ACL =& JLMSFactory::getACL();
        if ($JLMS_ACL->CheckPermissions('dropbox', 'mark_as_corrected')) {
            ?>
				<tr>
					<td valign="middle" style="vertical-align:middle"><br /><?php 
            echo _JLMS_DROP_MARK_AS_CORRECTED;
            ?>
</td>
					<td>
						<br /><?php 
            echo mosHTML::yesnoRadioList('drp_corrected', 'class="inputbox" ', 0);
            ?>
					</td>
				</tr>
				<?php 
        }
        ?>
				<tr>
					<td colspan="2"><br /><?php 
        echo _JLMS_COMMENT;
        ?>
</td>
				</tr>
				<tr>
					<td colspan="2">
					<?php 
        JLMS_editorArea('editor1', $row->drp_description, 'drp_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="save_dropbox" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="id" value="<?php 
        echo $row->id;
        ?>
" />
			<input type="hidden" name="course_id" value="<?php 
        echo $course_id;
        ?>
" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        JLMS_TMPL::CloseMT();
    }
 function JQ_doQuiz($option, $quiz_id, $course_id)
 {
     global $Itemid, $JLMS_DB, $my, $JLMS_LANGUAGE, $JLMS_CONFIG;
     JLMS_require_lang($JLMS_LANGUAGE, 'quiz.lang', $JLMS_CONFIG->get('default_language'));
     require _JOOMLMS_FRONT_HOME . '/includes/quiz/quiz_language.php';
     global $jq_language;
     $JLMS_ACL =& JLMSFactory::getACL();
     $query = "SELECT a.*, 'joomlaquiz_lms_template' as template_name FROM #__lms_quiz_t_quiz as a WHERE a.c_id = " . $quiz_id . " and a.course_id = " . $course_id;
     $JLMS_DB->SetQuery($query);
     $quiz_params = $JLMS_DB->LoadObjectList();
     if ($quiz_params[0]->c_resume) {
         $query = "SELECT c_id, unique_id, c_total_time, c_passed FROM #__lms_quiz_r_student_quiz WHERE c_quiz_id = " . $quiz_id . " AND c_student_id = '" . $my->id . "' ORDER BY `c_id` DESC LIMIT 1";
         $JLMS_DB->SetQuery($query);
         $resume_quiz = $JLMS_DB->LoadObject();
         if (isset($resume_quiz->c_id) && $resume_quiz->c_passed == 0 && !$resume_quiz->c_total_time) {
             $query = "SELECT c_question_id FROM #__lms_quiz_r_student_question WHERE c_stu_quiz_id = " . $resume_quiz->c_id . " ORDER BY c_id desc LIMIT 1";
             $JLMS_DB->SetQuery($query);
             $last_question = $JLMS_DB->LoadResult();
             if (!$last_question) {
                 $last_question = -1;
             }
             $quiz_params[0]->resume_quiz = $resume_quiz->c_id;
             $quiz_params[0]->unique_id = $resume_quiz->unique_id;
             $quiz_params[0]->last_question = $last_question;
             $quiz_params[0]->last_question = $last_question;
             $quiz_params[0]->c_total_time = $resume_quiz->c_total_time;
         }
     }
     $query = "SELECT count(c_id) FROM #__lms_quiz_r_student_quiz WHERE c_quiz_id = " . $quiz_id . " AND c_student_id = '" . $my->id . "'";
     $JLMS_DB->SetQuery($query);
     $count = $JLMS_DB->LoadResult();
     $quiz_params[0]->attempts_of_this_quiz = $count;
     $quiz_params[0]->attempts_of_this_quiz = intval($quiz_params[0]->attempts_of_this_quiz);
     $quiz_params[0]->c_max_numb_attempts = intval($quiz_params[0]->c_max_numb_attempts);
     $doing_quiz = 1;
     if (count($quiz_params) == 1 && $quiz_params[0]->published == 1) {
         $q_skin = $quiz_params[0]->c_skin;
         $q_random = $quiz_params[0]->c_random;
         $q_time_limit = $quiz_params[0]->c_min_after * 60;
         $q_allow_guest = $quiz_params[0]->c_guest;
         if ($my->id) {
             $q_user_id = $my->id;
             if ($q_time_limit) {
                 //				$query = "SELECT max(c_date_time) as time_last_access FROM #__lms_quiz_r_student_quiz WHERE c_quiz_id = '".$quiz_id."' and c_student_id = '".$q_user_id."'";
                 $query = "SELECT MAX(FROM_UNIXTIME(UNIX_TIMESTAMP(c_date_time) + c_total_time)) as time_last_access" . "\n FROM #__lms_quiz_r_student_quiz" . "\n WHERE 1" . "\n AND c_quiz_id = '" . $quiz_id . "'" . "\n AND c_student_id = '" . $q_user_id . "'" . "\n ORDER BY (UNIX_TIMESTAMP(c_date_time) + c_total_time)";
                 $JLMS_DB->SetQuery($query);
                 $q_last_access = $JLMS_DB->LoadResult();
                 if ($q_last_access) {
                     //'STRTOTIME with an empty parameter' bug fixed (02.10.2006)
                     $q_last_access_t = strtotime($q_last_access);
                     $time_goes = time() - date('Z') - $q_last_access_t;
                     if ($time_goes > 1) {
                         //esli proshla 1 minuta (changed to 10 secs)
                         if ($time_goes < $q_time_limit) {
                             if (isset($quiz_params[0]->resume_quiz) && $quiz_params[0]->resume_quiz && !$quiz_params[0]->c_total_time) {
                                 //resume is possible and latest attempt is nor finished (c_total_time == 0)
                                 // we need to restrict 'start button' here.... only resume is possible !!!!
                                 $quiz_params[0]->attempts_of_this_quiz = $quiz_params[0]->c_max_numb_attempts;
                             } elseif ($quiz_params[0]->attempts_of_this_quiz >= $quiz_params[0]->c_max_numb_attempts && (!isset($quiz_params[0]->resume_quiz) && !isset($quiz_params[0]->last_question)) && $quiz_params[0]->c_max_numb_attempts > 0) {
                                 // all attempast are finished.... user will scree 'final quiz page' screen.... there is no necessity in delay here
                             } else {
                                 $message = str_replace("{text}", $q_time_limit - $time_goes > 60 ? floor(($q_time_limit - $time_goes) / 60) . ' minute(s)' : $q_time_limit - $time_goes . ' seconds', $jq_language['quiz_comeback_later']);
                                 echo '<div class="joomlalms_sys_message">' . $message . '</div>';
                                 $doing_quiz = -2;
                             }
                         }
                     }
                 }
                 if ($doing_quiz == 1) {
                     /*$query = "INSERT INTO #__quiz_r_student_quiz SET c_quiz_id = '".$quiz_id."', c_student_id = '".$q_user_id."', c_date_time = now()";
                     		$JLMS_DB->SetQuery($query);
                     		$JLMS_DB->query();
                     		$sid = $JLMS_DB->insertid();*/
                 }
             }
         } else {
             //if guest
             $doing_quiz = -3;
             if ($q_allow_guest == 1) {
                 //$sid = '0';
                 $doing_quiz = 1;
             } else {
                 echo '<p align="left">' . $jq_language['quiz_reg_only'] . '</p>';
             }
         }
         if (!$q_random) {
             $q_random = 0;
         }
     } elseif ($JLMS_ACL->CheckPermissions('quizzes', 'view_all') && count($quiz_params) == 1) {
     } else {
         $doing_quiz = -1;
     }
     // 30.01.08 Max Self-verification
     $lists = array();
     $query = "SELECT a.*, b.items_number FROM #__lms_quiz_t_category as a LEFT JOIN #__lms_quiz_t_quiz_pool as b" . "\n ON a.c_id = b.qcat_id AND b.quiz_id = {$quiz_id}" . "\n WHERE a.course_id = '" . $course_id . "' AND a.is_quiz_cat = 0 order by a.c_category";
     $JLMS_DB->setQuery($query);
     $pool_cats = $JLMS_DB->loadObjectList();
     $lists['jq_pool_categories'] = $pool_cats;
     $query = "SELECT items_number FROM #__lms_quiz_t_quiz_pool WHERE quiz_id = {$quiz_id} AND qcat_id = 0";
     $JLMS_DB->setQuery($query);
     $pool_quest_num = intval($JLMS_DB->loadResult());
     $lists['pool_quest_num'] = $pool_quest_num;
     $query = "SELECT count(*) FROM #__lms_quiz_t_quiz_pool WHERE quiz_id = {$quiz_id} AND qcat_id <> 0";
     $JLMS_DB->setQuery($query);
     $pool_is_quest_mode = intval($JLMS_DB->loadResult());
     $lists['pool_quest_mode'] = $pool_is_quest_mode ? false : true;
     if (!$lists['pool_quest_mode']) {
         $lists['pool_quest_num'] = 0;
     }
     $self_verification = '';
     $quiz_params_self = new JLMSParameters($quiz_params[0]->params);
     if ($quiz_params_self->get('sh_self_verification', 0) == 1) {
         $pool_quest_mode = $lists['pool_quest_mode'] ? 1 : 0;
         $pool_quest_mode2 = !$lists['pool_quest_mode'] ? 2 : 0;
         $pool_quest_num = $lists['pool_quest_num'] ? $lists['pool_quest_num'] : 0;
         $self_verification = "<fieldset style='border: 1px solid #dddddd;'><legend align='left'>" . _JLMS_QUIZ_STU_QUESTS_FROM_SELF . "</legend>";
         $self_verification .= "<div style='padding: 5px;'><table width='100%' cellpadding='0' cellspacing='0' border='0'><tr>";
         $self_verification .= "<td>";
         $self_verification .= "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";
         if ($pool_quest_mode) {
             $self_verification .= "<tr class='sectiontableentry1'>";
             $self_verification .= "<td><input type='hidden' id='pool_quest_type' name='c_pool_type' value='" . $pool_quest_mode . "'><input type='text' name='pool_qtype_number' size='3' value='" . $pool_quest_num . "' />";
             $self_verification .= "</td>";
             $self_verification .= "</tr>";
         }
         if ($pool_quest_mode2) {
             $self_verification .= "<tr class='sectiontableentry1'>";
             $self_verification .= "<td colspan='2' align='left' style='text-align:left'>";
             $self_verification .= "<input type='hidden' id='pool_cat_type' name='c_pool_type' value='" . $pool_quest_mode2 . "' />";
             //<label for='pool_cat_type'>"._JLMS_QUIZ_ADD_POOL_MODE_CAT.":</label>
             $self_verification .= "</td>";
             $self_verification .= "</tr>";
             $k = 1;
             for ($i = 0, $n = count($lists['jq_pool_categories']); $i < $n; $i++) {
                 $plc = $lists['jq_pool_categories'][$i];
                 $self_verification .= "<tr class='sectiontableentry{$k}'>";
                 $self_verification .= "<td width='30%' align='left'>" . $plc->c_category . "</td>";
                 $self_verification .= "<td>";
                 $self_verification .= "<input type='hidden' name='pool_cat_id[]' value='" . $plc->c_id . "' />";
                 $self_verification .= "<input type='text' name='pool_cat_number[]' size='3' value='" . ($plc->items_number ? $plc->items_number : 0) . "' />";
                 $self_verification .= "</td></tr>";
             }
         }
         $self_verification .= "</table>";
         $self_verification .= "</td>";
         $self_verification .= "</tr>";
         $self_verification .= "</table></div>";
         $self_verification .= "</fieldset>";
     }
     if ($doing_quiz == 1) {
         // !!! 14 June 2007 - we should always load D'n'D code - beacuase D'n'D questions could became randomly from the pool.
         $quiz_params[0]->if_dragdrop_exist = true;
         if ($quiz_params[0]->attempts_of_this_quiz >= $quiz_params[0]->c_max_numb_attempts && (!isset($quiz_params[0]->resume_quiz) && !isset($quiz_params[0]->last_question)) && $quiz_params[0]->c_max_numb_attempts > 0) {
             $query = "SELECT a.c_id, a.unique_id, b.course_id FROM #__lms_quiz_r_student_quiz AS a, #__lms_quiz_t_quiz AS b WHERE a.c_quiz_id = b.c_id AND a.c_quiz_id = " . $quiz_id . " AND a.c_student_id = " . $my->id . " ORDER BY a.c_id desc LIMIT 1";
             $JLMS_DB->SetQuery($query);
             $resume_quiz1 = $JLMS_DB->LoadObject();
             $quiz_params[0]->stu_quiz_id = $resume_quiz1->c_id;
             $quiz_params[0]->user_uniquie_id = $resume_quiz1->unique_id;
             $quiz_params[0]->course_id = $resume_quiz1->course_id;
             echo JLMS_quiz_front_class::JQ_FinishQuiz($quiz_params[0]->c_id, $quiz_params[0]->stu_quiz_id, $quiz_params[0]->user_uniquie_id, $quiz_params[0]->course_id);
         } else {
             JLMS_quiz_front_html_class::JQ_ShowQuiz($option, $course_id, $quiz_params[0], $jq_language, $self_verification);
         }
         //JLMS_quiz_front_html_class::JQ_ShowQuiz( $option, $course_id, $quiz_params[0], $jq_language, $self_verification);
     } elseif ($doing_quiz == -1) {
         echo '<div class="joomlalms_sys_message">' . $jq_language['quiz_not_available'] . '</div>';
     }
 }
Beispiel #15
0
function JLMS_GB_getUsersGrades($id, $uids, &$rows, &$lists, $cycle = 0)
{
    $db =& JFactory::getDbo();
    $JLMS_ACL =& JLMSFactory::getACL();
    $is_teacher = $JLMS_ACL->isTeacher();
    $uids_str = implode(',', $uids);
    if (count($uids)) {
        $query = "SELECT a.*, b.scale_name FROM #__lms_gradebook as a LEFT JOIN #__lms_gradebook_scale as b ON a.gb_points=b.id AND b.course_id = {$id} WHERE a.course_id = '" . $id . "' AND a.user_id IN ({$uids_str})";
        $db->SetQuery($query);
        $gb_rows = $db->LoadObjectList();
        $query = "SELECT * FROM #__lms_certificate_users WHERE course_id = '" . $id . "' AND user_id IN ({$uids_str})";
        $db->SetQuery($query);
        $crt_rows = $db->LoadObjectList();
    } else {
        $crt_rows = array();
        $gb_rows = array();
    }
    $query = "SELECT * FROM #__lms_gradebook_scale WHERE course_id = {$id} ORDER BY ordering, scale_name";
    $db->SetQuery($query);
    $scale_rows = $db->LoadObjectList();
    if (count($uids) == 1) {
        if (count($crt_rows) > 1) {
            $del_ids_tmp = array();
            $del_ids = array();
            foreach ($crt_rows as $crt_row) {
                if ($crt_row->crt_date == '0000-00-00 00:00:00') {
                    $del_ids_tmp[] = $crt_row->id;
                }
            }
            if (count($del_ids) == count($crt_rows)) {
                $del_ii = 1;
                while ($del_ii < count($del_ids_tmp)) {
                    $del_ids[] = $del_ids_tmp[$del_ii];
                    $del_ii++;
                }
            } else {
                $del_ids = $del_ids_tmp;
            }
            $del_ids_str = implode(',', $del_ids);
            $query = "DELETE FROM #__lms_certificate_users WHERE id IN ({$del_ids_str}) AND course_id = '" . $id . "' AND user_id IN ({$uids_str}) AND crt_date = '0000-00-00 00:00:00'";
            $db->SetQuery($query);
            $db->query();
        }
    }
    $query = "SELECT * FROM #__lms_gradebook_items WHERE course_id = '" . $id . "' ORDER BY ordering, gbi_name";
    $db->SetQuery($query);
    $irows = $db->LoadObjectList();
    $query = "SELECT * FROM #__lms_learn_paths WHERE course_id = '" . $id . "' AND item_id <> '0' AND item_id <> '' AND published = '1' ORDER BY ordering";
    $db->SetQuery($query);
    $scorm_rows = $db->LoadObjectList();
    $scorm_ans = array();
    $scorm_n_ans = array();
    if (count($scorm_rows)) {
        $scids = array();
        $scn_ids = array();
        $scrows_i = 0;
        foreach ($scorm_rows as $scorm_row) {
            $tmp_params = new JLMSParameters($scorm_row->lp_params);
            if ($tmp_params->get('show_in_gradebook', 1)) {
                if ($scorm_row->lp_type == 1 || $scorm_row->lp_type == 2) {
                    $scn_ids[] = $scorm_row->item_id;
                } else {
                    $scids[] = $scorm_row->item_id;
                }
            }
            $scorm_rows[$scrows_i]->show_in_gradebook = $tmp_params->get('show_in_gradebook', 1);
            $scrows_i++;
        }
        if ($cycle) {
            $query = "SELECT params FROM #__lms_courses WHERE id = '" . $id . "'";
            //Atention!
            $db->setQuery($query);
            //Atention!
            $course_params = $db->loadResult();
            //Atention!
        } else {
            global $JLMS_CONFIG;
            $course_params = $JLMS_CONFIG->get('course_params');
        }
        $params = new JLMSParameters($course_params);
        if (count($scids) || count($scn_ids)) {
            require_once _JOOMLMS_FRONT_HOME . "/includes/lms_scorm.lib.php";
            if (count($scids)) {
                //nothing here
                $scorm_ans =& JLMS_GetSCORM_userResults($uids, $scids);
            }
            if (count($scn_ids)) {
                $scorm_n_ans = array();
                $uids_groups = array();
                $uids_group = array();
                //group user IDs by 5
                $uid_i = 1;
                foreach ($uids as $uid) {
                    $uids_group[] = $uid;
                    $uid_i++;
                    if ($uid_i > 5) {
                        $uids_groups[] = $uids_group;
                        $uids_group = array();
                        $uid_i = 1;
                    }
                }
                if (count($uids_group)) {
                    $uids_groups[] = $uids_group;
                }
                foreach ($uids_groups as $uids5) {
                    foreach ($scn_ids as $scn_id) {
                        $scn_ids_new_array = array();
                        $scn_ids_new_array[] = $scn_id;
                        $scorm_n_ans1 =& JLMS_Get_N_SCORM_userResults($uids5, $scn_ids_new_array, $params->get('track_type', 0));
                        $scorm_n_ans = array_merge($scorm_n_ans, $scorm_n_ans1);
                    }
                }
            }
        }
    }
    $query = "SELECT * FROM #__lms_quiz_t_quiz WHERE course_id = '" . $id . "' AND c_gradebook = 1 ORDER BY c_title";
    $db->SetQuery($query);
    $quiz_rows = $db->LoadObjectList();
    $quiz_ans = array();
    if (count($quiz_rows)) {
        if (count($uids)) {
            $query = "SELECT a.*, b.c_full_score 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 IN ( {$uids_str} ) ORDER BY a.user_id, a.quiz_id";
            $db->SetQuery($query);
            $quiz_ans = $db->LoadObjectList();
        } else {
            $quiz_ans = array();
        }
    }
    $i = 0;
    while ($i < count($rows)) {
        $p = array();
        foreach ($irows as $irow) {
            $pp = new stdClass();
            $pp->gbi_id = $irow->id;
            $pp->gbi_type = 1;
            // 1 - gb_item, 2 - scorm; 3 - quiz;
            $pp->user_grade = '-';
            $pp->scale_id = 0;
            $p[] = $pp;
        }
        $j = 0;
        while ($j < count($gb_rows)) {
            if ($gb_rows[$j]->user_id == $rows[$i]->user_id) {
                $k = 0;
                while ($k < count($p)) {
                    if ($p[$k]->gbi_id == $gb_rows[$j]->gbi_id && $p[$k]->gbi_type == 1) {
                        $p[$k]->user_grade = $gb_rows[$j]->scale_name ? $gb_rows[$j]->scale_name : '-';
                        //$gb_rows[$j]->gb_points;
                        $p[$k]->scale_id = $gb_rows[$j]->gb_points ? $gb_rows[$j]->gb_points : '-';
                    }
                    $k++;
                }
            }
            $j++;
        }
        $rows[$i]->user_certificate = 0;
        $rows[$i]->user_certificate_date = '';
        $j = 0;
        while ($j < count($crt_rows)) {
            if ($crt_rows[$j]->user_id == $rows[$i]->user_id) {
                $rows[$i]->user_certificate = $crt_rows[$j]->crt_option;
                $rows[$i]->user_certificate_date = $crt_rows[$j]->crt_date;
            }
            $j++;
        }
        $rows[$i]->grade_info = $p;
        //scorm
        $p = array();
        foreach ($scorm_rows as $srow) {
            $pp = new stdClass();
            $pp->gbi_id = $srow->item_id;
            $pp->lp_type = $srow->lp_type;
            $pp->gbi_type = 2;
            // 1 - gb_item, 2 - scorm; 3 - quiz;
            $pp->user_grade = '-';
            $pp->user_pts = 0;
            $pp->user_status = -1;
            $p[] = $pp;
        }
        $j = 0;
        while ($j < count($scorm_ans)) {
            if ($scorm_ans[$j]->user_id == $rows[$i]->user_id) {
                $k = 0;
                while ($k < count($p)) {
                    if ($p[$k]->gbi_id == $scorm_ans[$j]->content_id && $p[$k]->gbi_type == 2 && !$p[$k]->lp_type) {
                        /*$p[$k]->user_grade = $scorm_ans[$j]->score;
                        		$p[$k]->user_status = $scorm_ans[$j]->status;*/
                        $user_per = $scorm_ans[$j]->score > 100 ? 100 : $scorm_ans[$j]->score;
                        $sc_i = count($scale_rows) - 1;
                        while ($sc_i >= 0) {
                            if ($scale_rows[$sc_i]->min_val <= $user_per && $scale_rows[$sc_i]->max_val >= $user_per) {
                                $p[$k]->user_grade = $scale_rows[$sc_i]->scale_name;
                                break;
                            }
                            $sc_i--;
                        }
                        $p[$k]->user_pts = $scorm_ans[$j]->score;
                        $p[$k]->user_status = $scorm_ans[$j]->status;
                    }
                    $k++;
                }
            }
            $j++;
        }
        $j = 0;
        while ($j < count($scorm_n_ans)) {
            if ($scorm_n_ans[$j]->user_id == $rows[$i]->user_id) {
                $k = 0;
                while ($k < count($p)) {
                    if ($p[$k]->gbi_id == $scorm_n_ans[$j]->content_id && $p[$k]->gbi_type == 2 && ($p[$k]->lp_type == 1 || $p[$k]->lp_type == 2)) {
                        /*$p[$k]->user_grade = $scorm_n_ans[$j]->score;
                        		$p[$k]->user_status = $scorm_n_ans[$j]->status;*/
                        $user_per = $scorm_n_ans[$j]->score > 100 ? 100 : $scorm_n_ans[$j]->score;
                        //$user_per = intval($quiz_ans[$j]->user_score * 100 / $quiz_ans[$j]->c_full_score);
                        $sc_i = count($scale_rows) - 1;
                        while ($sc_i >= 0) {
                            if ($scale_rows[$sc_i]->min_val <= $user_per && $scale_rows[$sc_i]->max_val >= $user_per) {
                                $p[$k]->user_grade = $scale_rows[$sc_i]->scale_name;
                                break;
                            }
                            $sc_i--;
                        }
                        $p[$k]->user_pts = $scorm_n_ans[$j]->score;
                        $p[$k]->user_status = $scorm_n_ans[$j]->status;
                    }
                    $k++;
                }
            }
            $j++;
        }
        $rows[$i]->scorm_info = $p;
        //quizzes
        $p = array();
        foreach ($quiz_rows as $qrow) {
            $pp = new stdClass();
            $pp->gbi_id = $qrow->c_id;
            $pp->allow_user_pdf_print = $qrow->c_enable_print;
            $pp->gbi_type = 3;
            // 1 - gb_item, 2 - scorm; 3 - quiz;
            $pp->user_grade = '-';
            $pp->user_pts = 0;
            $pp->user_pts_full = '0';
            $pp->user_status = -1;
            $pp->user_passed = -1;
            $pp->user_score = 0;
            $pp->quiz_max_score = 0;
            /*Integration Plugin Percentiles*/
            $_JLMS_PLUGINS =& JLMSFactory::getPlugins();
            $_JLMS_PLUGINS->loadBotGroup('system');
            $data_plugin = new stdClass();
            $data_plugin->course_id = $rows[$i]->course_id;
            $data_plugin->quiz_id = $qrow->c_id;
            $data_plugin->user_id = $rows[$i]->user_id;
            if ($out_plugin = $_JLMS_PLUGINS->trigger('onQuizFinish', array($data_plugin))) {
                if (count($out_plugin)) {
                    $percentiles = $out_plugin[0];
                    if ($percentiles->percent >= 0) {
                        $percent = $percentiles->percent . '%';
                        $pp->user_percentile = $percent;
                    }
                }
            }
            /*Integration Plugin Percentiles*/
            $p[] = $pp;
        }
        $j = 0;
        while ($j < count($quiz_ans)) {
            if ($quiz_ans[$j]->user_id == $rows[$i]->user_id) {
                $k = 0;
                while ($k < count($p)) {
                    if ($p[$k]->gbi_id == $quiz_ans[$j]->quiz_id && $p[$k]->gbi_type == 3) {
                        if ($quiz_ans[$j]->quiz_max_score) {
                            $user_per = intval($quiz_ans[$j]->user_score * 100 / $quiz_ans[$j]->quiz_max_score);
                        } elseif ($quiz_ans[$j]->c_full_score) {
                            $user_per = intval($quiz_ans[$j]->user_score * 100 / $quiz_ans[$j]->c_full_score);
                        } else {
                            if ($quiz_ans[$j]->user_score) {
                                // ...strange ... HOW?
                                $user_per = 100;
                            } else {
                                $user_per = 0;
                            }
                        }
                        $sc_i = count($scale_rows) - 1;
                        while ($sc_i >= 0) {
                            if ($scale_rows[$sc_i]->min_val <= $user_per && $scale_rows[$sc_i]->max_val >= $user_per) {
                                $p[$k]->user_grade = $scale_rows[$sc_i]->scale_name;
                                break;
                            }
                            $sc_i--;
                        }
                        $p[$k]->user_pts = $quiz_ans[$j]->user_score;
                        $p[$k]->user_pts_full = $quiz_ans[$j]->user_score . '/' . $quiz_ans[$j]->quiz_max_score;
                        $p[$k]->user_status = $quiz_ans[$j]->user_passed;
                        $p[$k]->user_passed = $quiz_ans[$j]->user_passed;
                        $p[$k]->user_score = $quiz_ans[$j]->user_score;
                        $p[$k]->quiz_max_score = $quiz_ans[$j]->quiz_max_score;
                    }
                    $k++;
                }
            }
            $j++;
        }
        $rows[$i]->quiz_info = $p;
        $i++;
    }
    global $my;
    //--------------------------
    for ($i = 0; $i < count($scorm_rows); $i++) {
        if ($scorm_rows[$i]->lp_type == 2) {
            $query = "SELECT scorm_package FROM #__lms_n_scorm WHERE id = '" . $scorm_rows[$i]->item_id . "'";
            $db->SetQuery($query);
            $scorm_package = $db->LoadResult();
            $query = "SELECT id FROM #__lms_n_scorm WHERE scorm_package = '" . $scorm_package . "' AND course_id = 0";
            $db->SetQuery($query);
            $scorm_lib_id = $db->LoadResult();
            $outer_doc = null;
            $query = "SELECT outdoc_share, owner_id, allow_link FROM #__lms_outer_documents WHERE file_id = '" . $scorm_lib_id . "' AND folder_flag = 3";
            $db->SetQuery($query);
            $outer_doc = $db->LoadObject();
            if (is_object($outer_doc) && isset($outer_doc->allow_link) && $outer_doc->allow_link == 1) {
            } else {
                unset($scorm_rows[$i]);
            }
        }
    }
    $mas = array();
    foreach ($scorm_rows as $k => $v) {
        $mas[] = $scorm_rows[$k];
    }
    unset($scorm_rows);
    $scorm_rows = $mas;
    //---------------------------------
    if ($cycle) {
        $lists['gb_rows'][] = $irows;
        $lists['sc_rows'][] = $scorm_rows;
        $lists['quiz_rows'][] = $quiz_rows;
    } else {
        $lists['gb_rows'] = $irows;
        $lists['sc_rows'] = $scorm_rows;
        $lists['quiz_rows'] = $quiz_rows;
    }
}
    function showCourseLPaths($course_id, $option, &$lpaths)
    {
        global $Itemid, $my, $JLMS_DB, $JLMS_CONFIG;
        $JLMS_ACL =& JLMSFactory::getACL();
        ?>
<script language="javascript" type="text/javascript">
<!--
function submitbutton(pressbutton) {
	var form = document.adminForm;
		
			if ( ((pressbutton == 'edit_lpath') || (pressbutton == 'lpath_delete') ) && (form.boxchecked.value == "0")) {
				alert('<?php 
        echo _JLMS_ALERT_SELECT_ITEM;
        ?>
');
			} else {
				if( pressbutton == 'lpath_delete' ) {
					if (confirm('<?php 
        echo _JLMS_ALERT_DELETE_ITEM;
        ?>
')) {
						form.task.value = pressbutton;
						form.submit();
					}
				}
				else {	
						form.task.value = pressbutton;
						form.submit();
				}
			}	
}
	
function submitbutton_order(pressbutton, item_id) {
	var form = document.adminForm;
	if ((pressbutton == 'lpath_orderup') || (pressbutton == 'lpath_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_lpath'){
		if (form.boxchecked.value == 0 || 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_lpath'){
		form.task.value = pressbutton;
		form.state.value = state;
		form.cid2.value = cid_id;
		form.submit();
	}
}
function submitbutton_allorder(n) {
	var form = document.adminForm;

	for ( var j = 0; j <= n; j++ ) {
		box = eval( "document.adminForm.cb" + j );
		if ( box ) {
			if ( box.checked == false ) {
				box.checked = true;
			}
		}
	}
	form.task.value = 'lpath_saveorederall';
	form.submit();
}
//-->
</script>
<?php 
        JLMS_TMPL::OpenMT();
        $hparams = array();
        JLMS_TMPL::ShowHeader('lpath', _JLMS_LPATH_TITLE, $hparams);
        JLMS_TMPL::OpenTS();
        //temporary check for number of items
        $num_items = 0;
        $there_were_squeezeboxes = false;
        for ($i = 0, $n = count($lpaths); $i < $n; $i++) {
            $row_path = $lpaths[$i];
            $is_hidden = false;
            if ($row_path->item_id) {
                $tmp_params = new JLMSParameters($row_path->lp_params);
                if ($tmp_params->get('hide_in_list', 0) == 1) {
                    $is_hidden = true;
                }
            }
            if ($JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                $task = 'compose_lpath';
                $title = _JLMS_LPATH_LINK_TITLE_COMPOSE;
            } elseif ($JLMS_ACL->CheckPermissions('lpaths', 'view')) {
                $task = 'show_lpath';
                $title = _JLMS_LPATH_LINK_TITLE_VIEW;
                if ($is_hidden) {
                    continue;
                }
            }
            if (isset($row_path->is_hidden) && $row_path->is_hidden && !$JLMS_ACL->CheckPermissions('lpaths', 'view_all')) {
                continue;
            }
            $num_items++;
        }
        ?>
			<form action="<?php 
        echo $JLMS_CONFIG->getCfg('live_site') . "/index.php?option={$option}&amp;Itemid={$Itemid}";
        ?>
" method="post" name="adminForm">
<?php 
        if ($num_items) {
            ?>
				<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('lpaths', 'manage') || $JLMS_ACL->CheckPermissions('lpaths', 'publish')) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 width="25" class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" align="center"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php 
                echo count($lpaths);
                ?>
);" /></<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 width="20" 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 
            if ($JLMS_ACL->CheckPermissions('lpaths', 'publish')) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">&nbsp;</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
					<?php 
            if ($JLMS_ACL->CheckPermissions('lpaths', 'order')) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">&nbsp;</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">&nbsp;</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1"><?php 
                echo _JLMS_REORDER;
                ?>
</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1"><a class="jlms_img_link" href="javascript:submitbutton_allorder(<?php 
                echo count($lpaths) - 1;
                ?>
)"><img width="16" height="16" border="0" title="<?php 
                echo _JLMS_SAVEORDER;
                ?>
" alt="<?php 
                echo _JLMS_SAVEORDER;
                ?>
" src="<?php 
                echo $JLMS_CONFIG->get('live_site');
                ?>
/components/com_joomla_lms/lms_images/filesave.png"/></a></<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
					<?php 
            if ($JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">&nbsp;</<?php 
                echo JLMSCSS::tableheadertag();
                ?>
>
					<?php 
            }
            ?>
					<?php 
            if (!$JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                ?>
						<<?php 
                echo JLMSCSS::tableheadertag();
                ?>
 class="<?php 
                echo JLMSCSS::_('sectiontableheader');
                ?>
" width="1">&nbsp;</<?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();
                ?>
>
					<?php 
            }
            ?>
						<<?php 
            echo JLMSCSS::tableheadertag();
            ?>
 class="<?php 
            echo JLMSCSS::_('sectiontableheader');
            ?>
"><?php 
            echo _JLMS_LPATH_TBL_HEAD_DESCR;
            ?>
</<?php 
            echo JLMSCSS::tableheadertag();
            ?>
>
					</tr>
				<?php 
            $k = 1;
            $i_counter = 0;
            for ($i = 0, $n = count($lpaths); $i < $n; $i++) {
                $row_path = $lpaths[$i];
                $is_hidden = false;
                $is_squeezebox = false;
                if ($row_path->item_id) {
                    $tmp_params = new JLMSParameters($row_path->lp_params);
                    if ($tmp_params->get('hide_in_list', 0) == 1) {
                        $is_hidden = true;
                    }
                    if (isset($row_path->scorm_params)) {
                        $tmp_params2 = new JLMSParameters($row_path->scorm_params);
                        if ($tmp_params2->get('scorm_layout', 0) == 1) {
                            $is_squeezebox = true;
                            $there_were_squeezeboxes = true;
                        }
                    }
                }
                $manage_item = false;
                if ($JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                    $manage_item = true;
                }
                if ($JLMS_ACL->CheckPermissions('lpaths', 'only_own_items') && $row_path->owner_id != $my->id) {
                    $manage_item = false;
                } elseif ($JLMS_ACL->CheckPermissions('lpaths', 'only_own_role') && $JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($JLMS_DB, $row_path->owner_id)) {
                    $manage_item = false;
                }
                if ($manage_item) {
                    $task = 'compose_lpath';
                    $title = _JLMS_LPATH_LINK_TITLE_COMPOSE;
                } elseif ($JLMS_ACL->CheckPermissions('lpaths', 'view')) {
                    $task = 'show_lpath';
                    $title = _JLMS_LPATH_LINK_TITLE_VIEW;
                    if ($is_hidden && !$JLMS_ACL->CheckPermissions('lpaths', 'view_all')) {
                        continue;
                    }
                }
                if (isset($row_path->is_hidden) && $row_path->is_hidden && !$JLMS_ACL->CheckPermissions('lpaths', 'view_all')) {
                    continue;
                }
                $link = "index.php?option=" . $option . "&Itemid=" . $Itemid . "&task=" . $task . "&course_id=" . $course_id . "&id=" . $row_path->id;
                // sefRelToAbs() - est' nige
                $icon_img = "toolbar/tlb_lpath";
                $icon_alt = "learnpath";
                if ($row_path->item_id) {
                    $title = _JLMS_LPATH_LINK_TITLE_SCORM;
                    //$link = "index.php?option=".$option."&Itemid=".$Itemid."&task=player_scorm&course_id=".$course_id."&id=".$row_path->item_id."&lp_type=".$row_path->lp_type;
                    $link = "index.php?option=" . $option . "&Itemid=" . $Itemid . "&task=show_lpath&course_id=" . $course_id . "&id=" . $row_path->id;
                    //."&lp_type=".$row_path->lp_type;
                    $icon_img = "toolbar/tlb_scorm";
                    $icon_alt = "scorm";
                }
                $checked = mosHTML::idBox($i_counter, $row_path->id);
                $alt = $row_path->published ? $is_hidden ? _JLMS_STATUS_PUBLISHED_AND_HIDDEN : _JLMS_LPATH_STATUS_PUB : _JLMS_LPATH_STATUS_UNPUB;
                $image = $row_path->published ? $is_hidden ? 'btn_publish_hidden.png' : 'btn_accept.png' : 'btn_cancel.png';
                $state = $row_path->published ? 0 : 1;
                $released_info_txt = '';
                if ($row_path->is_time_related) {
                    $released_info_txt = _JLMS_WILL_BE_RELEASED_IN;
                    $showperiod = $row_path->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) {
                        $released_info_txt .= ' ' . $sp_days . ' ' . _JLMS_RELEASED_IN_DAYS;
                        $release_time_info = true;
                    }
                    if ($sp_hours) {
                        $released_info_txt .= ' ' . $sp_hours . ' ' . _JLMS_RELEASED_IN_HOURS;
                        $release_time_info = true;
                    }
                    if ($sp_mins) {
                        $released_info_txt .= ' ' . $sp_mins . ' ' . _JLMS_RELEASED_IN_MINUTES;
                        $release_time_info = true;
                    }
                    if ($release_time_info) {
                        $released_info_txt .= ' ' . _JLMS_RELEASED_AFTER_ENROLLMENT;
                    }
                    if ($image == 'btn_accept.png') {
                        $image = 'btn_publish_wait.png';
                    }
                }
                $publish_icon = '&nbsp;';
                if ($JLMS_ACL->CheckPermissions('lpaths', 'publish')) {
                    /*$publish_icon = '<a href="javascript:submitbutton_change2(\'change_lpath\','.$state.','.$row_path->id.')" title="'.$alt.'">';
                    		$publish_icon .= '<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.'" />';
                    		$publish_icon .= '</a>';*/
                    $title_tt = $alt;
                    $content_tt = $released_info_txt;
                    if (isset($row_path->is_prereqs) && $row_path->is_prereqs) {
                        if ($content_tt) {
                            $content_tt .= '<br />';
                        }
                        $content_tt .= _JLMS_STATUS_CONFIGURED_PREREQUISITES;
                    }
                    $name_tt = '<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 . '" />';
                    $link_tt = 'javascript:submitbutton_change2(\'change_lpath\',' . $state . ',' . $row_path->id . ')';
                    $publish_icon = JLMS_toolTip($title_tt, $content_tt, $name_tt, $link_tt);
                }
                if ($JLMS_ACL->CheckPermissions('lpaths', 'only_own_items') && $row_path->owner_id != $my->id) {
                    $checked = '&nbsp;';
                    $publish_icon = '&nbsp;';
                } elseif ($JLMS_ACL->CheckPermissions('lpaths', 'only_own_role') && $JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($JLMS_DB, $row_path->owner_id)) {
                    $checked = '&nbsp;';
                    $publish_icon = '&nbsp;';
                }
                ?>
					<tr class="<?php 
                echo JLMSCSS::_('sectiontableentry' . $k);
                ?>
">
						<td valign="middle" align="center"><?php 
                echo $i_counter + 1;
                ?>
</td>
					<?php 
                if ($JLMS_ACL->CheckPermissions('lpaths', 'manage') || $JLMS_ACL->CheckPermissions('lpaths', 'publish')) {
                    ?>
						<td valign="middle" align="center"><?php 
                    if (!isset($row_path->is_link)) {
                        echo $checked;
                    }
                    ?>
</td>
					<?php 
                }
                ?>
						<td valign="middle" align="center">
							<span style="vertical-align:middle; text-align:center">
								<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 
                if (isset($row_path->is_link) && $row_path->is_link) {
                    echo $row_path->lpath_name;
                } elseif ($is_squeezebox) {
                    $x_size = 0;
                    $y_size = 0;
                    if (isset($row_path->scorm_width)) {
                        $x_size = $row_path->scorm_width;
                        if ($x_size == 100) {
                            //settings from 1.0.6 version (means 100% width)
                            $x_size = 0;
                        }
                    }
                    if (isset($row_path->scorm_height)) {
                        $y_size = $row_path->scorm_height;
                    }
                    ?>
									<a href="<?php 
                    echo sefRelToAbs($link);
                    ?>
" class="scorm_modal" rel="{handler:'iframe', size:{x:<?php 
                    echo $x_size;
                    ?>
,y:<?php 
                    echo $y_size;
                    ?>
}}" title="<?php 
                    echo str_replace('"', '&quot;', $row_path->lpath_name);
                    ?>
">
										<?php 
                    echo $row_path->lpath_name;
                    ?>
									</a>
							<?php 
                } else {
                    ?>
									<a href="<?php 
                    echo sefRelToAbs($link);
                    ?>
" title="<?php 
                    echo str_replace('"', '&quot;', $row_path->lpath_name);
                    ?>
">
										<?php 
                    echo $row_path->lpath_name;
                    ?>
									</a>
							<?php 
                }
                ?>
							
							<?php 
                if ($JLMS_CONFIG->get('show_lpaths_authors', 0)) {
                    ?>
							<br />
							<span class="small"><?php 
                    echo _JLMS_HOME_AUTHOR . "&nbsp;" . $row_path->author_name;
                    ?>
</span>
							<?php 
                }
                ?>
						</td>
					<?php 
                if ($JLMS_ACL->CheckPermissions('lpaths', 'publish')) {
                    ?>
						<td valign="middle">
							<?php 
                    echo $publish_icon;
                    ?>
						</td>
					<?php 
                }
                ?>
					<?php 
                if ($JLMS_ACL->CheckPermissions('lpaths', 'order')) {
                    ?>
						<td valign="middle"><?php 
                    echo JLMS_orderUpIcon($i_counter, $row_path->id, true, 'lpath_orderup');
                    ?>
</td>
						<td valign="middle"><?php 
                    echo JLMS_orderDownIcon($i_counter, $n, $row_path->id, true, 'lpath_orderdown');
                    ?>
</td>
						<td colspan="2">
							<input type="text" name="order[]" size="5" value="<?php 
                    echo $row_path->ordering;
                    ?>
" class="inputbox" style="text-align: center" />
						</td>
					<?php 
                }
                ?>
					<?php 
                if ($JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                    ?>
						<td valign="middle">
						<?php 
                    if ($manage_item && ($row_path->item_id && $row_path->lp_type != 2 || !$row_path->item_id)) {
                        $download_message = _JLMS_LPATH_LINK_TITLE_DOWN_SCORM;
                        if (!$row_path->item_id) {
                            $download_message = _JLMS_LPATH_EXPORT_LP;
                        }
                        ?>
						<a class="jlms_img_link" href="<?php 
                        echo sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=download_scorm&amp;course_id={$course_id}&amp;id={$row_path->id}");
                        ?>
" title="<?php 
                        echo $download_message;
                        ?>
"><img class='JLMS_png' src="<?php 
                        echo $JLMS_CONFIG->get('live_site');
                        ?>
/components/com_joomla_lms/lms_images/toolbar/btn_export.png" border="0" width="16" height="16" alt="<?php 
                        echo $download_message;
                        ?>
" title="<?php 
                        echo $download_message;
                        ?>
" /></a>
						<?php 
                    } else {
                        echo '&nbsp;';
                    }
                    ?>
						</td>
					<?php 
                }
                ?>
					<?php 
                if (!$JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                    $r_img = 'btn_cancel';
                    $r_sta = _JLMS_LPATH_STU_LPSTATUS_NOTCOMPLETED;
                    $r_start = '-';
                    $r_end = '-';
                    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;
                            if ($row_path->r_start) {
                                $r_start = JLMS_dateToDisplay($row_path->r_start, false, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s');
                            }
                            if ($row_path->r_end) {
                                $r_end = 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';
                            if ($row_path->r_start) {
                                $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 = '-';
                        }
                        if ($row_path->lp_type == 1 || $row_path->lp_type == 2) {
                            if (isset($row_path->r_end) && $row_path->r_end) {
                                $r_end = JLMS_dateToDisplay($row_path->r_end, true, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s');
                            }
                            if (isset($row_path->r_start) && $row_path->r_start) {
                                $r_start = JLMS_dateToDisplay($row_path->r_start, true, $JLMS_CONFIG->get('offset') * 60 * 60, '\\<\\b\\r \\/>H:i:s');
                            }
                        }
                    }
                    ?>
						<td valign="middle" align="center" width="16">
							<?php 
                    //Show Status Lapths/Scorms //by Max - 25.02.2011
                    joomla_lms_html::ShowStatusAs($row_path);
                    ?>
	
						</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>
					<?php 
                }
                ?>
						<td valign="middle"><?php 
                echo $row_path->lpath_shortdescription ? $row_path->lpath_shortdescription : '&nbsp;';
                ?>
</td>
					</tr>
					<?php 
                $k = 3 - $k;
                $i_counter++;
            }
            ?>
				</table>
<?php 
        } else {
            echo '<div class="joomlalms_user_message">' . _JLMS_NO_ITEMS_HERE . '</div>';
        }
        if ($there_were_squeezeboxes) {
            JLMS_initialize_SqueezeBox();
        }
        ?>
				<input type="hidden" name="option" value="<?php 
        echo $option;
        ?>
" />
				<input type="hidden" name="Itemid" value="<?php 
        echo $Itemid;
        ?>
" />
				<input type="hidden" name="task" value="learnpaths" />
				<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="cid2" value="0" />
			</form>
<?php 
        JLMS_TMPL::CloseTS();
        if ($JLMS_ACL->CheckPermissions('lpaths', 'manage') || $JLMS_ACL->CheckPermissions('lpaths', 'publish')) {
            $link_new = JLMSRoute::_("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=new_lpath&amp;id=" . $course_id);
            $link_new_scorm = JLMSRoute::_("index.php?option=" . $option . "&amp;Itemid=" . $Itemid . "&amp;task=new_lpath_scorm&amp;id=" . $course_id);
            $link_new_scormlib = JLMSRoute::_("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=new_scorm_from_library&amp;id=" . $course_id);
            $controls = array();
            if ($JLMS_ACL->CheckPermissions('lpaths', 'publish')) {
                $controls[] = array('href' => "javascript:submitbutton_change('change_lpath',1);", 'title' => _JLMS_LPATH_SET_PUB, 'img' => 'publish');
                $controls[] = array('href' => "javascript:submitbutton_change('change_lpath',0);", 'title' => _JLMS_LPATH_SET_UNPUB, 'img' => 'unpublish');
                if ($JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                    $controls[] = array('href' => 'spacer');
                }
            }
            if ($JLMS_ACL->CheckPermissions('lpaths', 'manage')) {
                $controls[] = array('href' => ampReplace($link_new), 'onclick' => "", 'title' => _JLMS_LPATH_DO_NEW_LP, 'img' => 'add_lpath');
                //TODO: translate 'Import SCORM package'
                $controls[] = array('href' => ampReplace($link_new_scorm), 'onclick' => "", 'title' => _JLMS_LPATH_IMPORT_SCORM, 'img' => 'add_scorm');
                $controls[] = array('href' => $link_new_scormlib, 'title' => _JLMS_SCORM_ADD_A_SCORM_PACKAGE_FROM_THE_LIBRARY, 'img' => 'add_library');
                $controls[] = array('href' => 'spacer');
                $controls[] = array('href' => "javascript:submitbutton('lpath_delete');", 'title' => _JLMS_LPATH_DO_DEL_LP, 'img' => 'delete');
                $controls[] = array('href' => "javascript:submitbutton('edit_lpath');", 'title' => _JLMS_LPATH_DO_EDIT_LP, 'img' => 'edit');
            }
            JLMS_TMPL::ShowControlsFooter($controls);
        }
        JLMS_TMPL::CloseMT();
    }
Beispiel #17
0
 function getButtons($editor, $buttons = true)
 {
     $result = array();
     if (is_bool($buttons) && !$buttons) {
         return $result;
     }
     // Get plugins
     $plugins = JPluginHelper::getPlugin('editors-xtd');
     //The buttons are not displayed
     if (isset($plugins) && count($plugins)) {
         $JLMS_ACL =& JLMSFactory::getACL();
         $notavailable_plugins = array();
         $notavailable_plugins[] = 'pagebreak';
         $notavailable_plugins[] = 'readmore';
         if (!in_array($JLMS_ACL->_role_type, array(1))) {
             $tmp_plugins = array();
             $i = 0;
             foreach ($plugins as $plugin) {
                 if (!in_array($plugin->name, $notavailable_plugins)) {
                     $tmp_plugins[$i] = $plugin;
                     $i++;
                 }
             }
             if (isset($tmp_plugins) && count($tmp_plugins)) {
                 $plugins = array();
                 $plugins = $tmp_plugins;
             }
         } else {
             if (isset($plugins) && count($plugins)) {
                 $plugins = array();
             }
         }
     }
     //The buttons are not displayed
     foreach ($plugins as $plugin) {
         if (is_array($buttons) && in_array($plugin->name, $buttons)) {
             continue;
         }
         $isLoaded = JPluginHelper::importPlugin('editors-xtd', $plugin->name, false);
         $className = 'plgButton' . $plugin->name;
         if (class_exists($className)) {
             $plugin = new $className($this, (array) $plugin);
         }
         // Try to authenticate -- only add to array if authentication is successful
         $resultTest = $plugin->onDisplay($editor);
         if ($resultTest) {
             $result[] = $resultTest;
         }
     }
     /**
      * JLMS hack. 
      * add button read more for special function JLMS
      */
     $doc =& JFactory::getDocument();
     // button is not active in specific content components
     $getContent = $this->getContent($editor);
     $present = JText::_('ALREADY EXISTS', true);
     $css = "";
     $css .= "\n\t\t\t\tp.system-jlmsreadmore{\n\t\t\t\t\tborder: 1px dashed #0000ff;\n\t\t\t\t\tpadding: 5px;\n\t\t\t\t}\n\t\t\t";
     $js = "";
     $js .= "\n\t\t\t\tfunction insertReadmoreBlock(editor) {\n\t\t\t\t\tvar content = {$getContent}\n\t\t\t\t\tjInsertEditorText('{readmore}   {/readmore}', editor);\n\t\t\t\t}\n\t\t\t";
     $js .= "\n\t\t\t\tfunction insertJLMSReadmore_begin(editor) {\n\t\t\t\t\tvar content = {$getContent}\n\t\t\t\t\tjInsertEditorText('{readmore}', editor);\n\t\t\t\t}\n\t\t\t";
     $js .= "\n\t\t\t\tfunction insertJLMSReadmore_end(editor) {\n\t\t\t\t\tvar content = {$getContent}\n\t\t\t\t\tjInsertEditorText('{/readmore}', editor);\n\t\t\t\t}\n\t\t\t";
     //			$doc->addStyleDeclaration($css);
     $doc->addScriptDeclaration($js);
     $button_x = new JObject();
     $button_x->set('modal', false);
     $button_x->set('onclick', 'insertReadmoreBlock(\'' . $editor . '\');return false;');
     $button_x->set('text', JText::_('Readmore (block)'));
     $button_x->set('name', 'blank');
     $button_x->set('link', '#');
     $button_begin = new JObject();
     $button_begin->set('modal', false);
     $button_begin->set('onclick', 'insertJLMSReadmore_begin(\'' . $editor . '\');return false;');
     $button_begin->set('text', JText::_('Readmore (start)'));
     $button_begin->set('name', 'blank');
     $button_begin->set('link', '#');
     $button_end = new JObject();
     $button_end->set('modal', false);
     $button_end->set('onclick', 'insertJLMSReadmore_end(\'' . $editor . '\');return false;');
     $button_end->set('text', JText::_('Readmore (end)'));
     $button_end->set('name', 'blank');
     $button_end->set('link', '#');
     //			$result[] = $button_x;
     $result[] = $button_begin;
     $result[] = $button_end;
     /**
      * JLMS hack.
      */
     return $result;
 }
 function listElements($topic_id)
 {
     global $my, $JLMS_DB;
     $JLMS_ACL =& JLMSFactory::getACL();
     $is_teacher = $JLMS_ACL->isTeacher();
     //create list of elements already linked to topic
     if (@count($this->links[$topic_id])) {
         foreach ($this->links[$topic_id] as $topic_link) {
             $linked_elements[$topic_link->item_type][] = $topic_link->item_id;
         }
     } else {
         $linked_elements = array();
     }
     foreach ($this->elements as $k => $v) {
         if ($k == 7) {
             foreach ($v as $n => $m) {
                 if ($m->lp_type == 2) {
                     $lib_link_is_found = false;
                     if (isset($m->item_id) && $m->item_id) {
                         $learn_path_id = $m->item_id;
                         $query = "SELECT scorm_package FROM #__lms_n_scorm WHERE id = '" . $learn_path_id . "'";
                         $JLMS_DB->SetQuery($query);
                         $scorm_package = $JLMS_DB->LoadResult();
                         if ($scorm_package) {
                             $query = "SELECT id FROM #__lms_n_scorm WHERE scorm_package = '" . $scorm_package . "' AND course_id = 0";
                             $JLMS_DB->SetQuery($query);
                             $scorm_lib_id = $JLMS_DB->LoadResult();
                             if ($scorm_lib_id) {
                                 $query = "SELECT outdoc_share, owner_id, allow_link FROM #__lms_outer_documents WHERE file_id = '" . $scorm_lib_id . "' AND folder_flag = 3";
                                 $JLMS_DB->SetQuery($query);
                                 $outer_doc = $JLMS_DB->LoadObject();
                                 if (is_object($outer_doc)) {
                                     $lib_link_is_found = true;
                                     if (isset($outer_doc->allow_link) && $outer_doc->allow_link == 1) {
                                         // 01May2009: new library policy: if 'allow_link' is enabled - we can view already added resource !
                                     } else {
                                         unset($m);
                                     }
                                 }
                             }
                         }
                     }
                     if (!$lib_link_is_found) {
                         unset($m);
                     }
                 }
             }
         }
     }
     //call output method
     JLMS_topic_html::showElementsList($this->course_id, $topic_id, $this->elements, $linked_elements);
 }
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;
}
Beispiel #20
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 &GetItemPermissions(&$rows, $id)
 {
     global $my;
     $permissions = new stdClass();
     $permissions->view = 0;
     $permissions->viewall = 0;
     $permissions->publish = 0;
     $permissions->published = 0;
     $permissions->order = 0;
     $permissions->manage = 0;
     $permissions->create = 0;
     $permissions->publish_childs = 0;
     $JLMS_ACL =& JLMSFactory::getACL();
     if (!$id) {
         // create fake item to emulate 'docs root'
         $row = new stdClass();
         $row->published = 1;
         $row->publish_start = 0;
         $row->publish_end = 0;
         $row->start_date = date('Y-m-d');
         $row->end_date = date('Y-m-d');
         $row->owner_id = $my->id;
     } else {
         $row =& JLMSDocs::GetItembyID($rows, $id);
     }
     if ($JLMS_ACL->CheckPermissions('docs', 'view') && !is_null($row)) {
         $permissions->published = $row->published ? true : false;
         if ($permissions->published) {
             $permissions->published = $row->publish_start && strtotime($row->start_date) <= strtotime(date('Y-m-d')) || !$row->publish_start ? true : false;
         }
         if ($permissions->published) {
             $permissions->published = $row->publish_end && strtotime($row->end_date) >= strtotime(date('Y-m-d')) || !$row->publish_end ? true : false;
         }
         if ($JLMS_ACL->CheckPermissions('docs', 'ignore_permissions') || !$id) {
             // ignore custom permissions or check permissions for the 'root' folder (fake item was created))
             if ($JLMS_ACL->CheckPermissions('docs', 'view_all') || $row->owner_id == $my->id || $permissions->published) {
                 $permissions->view = 1;
                 if ($JLMS_ACL->CheckPermissions('docs', 'manage')) {
                     $permissions->manage = 1;
                     $permissions->create = 1;
                 }
                 if ($JLMS_ACL->CheckPermissions('docs', 'publish')) {
                     $permissions->publish = 1;
                     $permissions->publish_childs = 1;
                 }
                 if ($JLMS_ACL->CheckPermissions('docs', 'order')) {
                     $permissions->order = 1;
                 }
             }
         } else {
             // here we are sure that $row is an element, but not a fake item
             // check element custom permissions
             if (isset($row->p_manage) && $row->p_manage) {
                 $permissions->manage = 1;
             }
             if (isset($row->p_view) && $row->p_view) {
                 $permissions->view = 1;
             }
             if (isset($row->p_order) && $row->p_order) {
                 $permissions->order = 1;
             }
             if (isset($row->p_publish) && $row->p_publish) {
                 $permissions->publish = 1;
             }
             if (isset($row->p_create) && $row->p_create) {
                 $permissions->create = 1;
             }
             if (isset($row->p_publish_childs) && $row->p_publish_childs) {
                 $permissions->publish_childs = 1;
             }
         }
         if ($JLMS_ACL->CheckPermissions('docs', 'only_own_items')) {
             // reset permissions for not owned by me items
             if ($row->owner_id != $my->id) {
                 $permissions->manage = 0;
                 $permissions->create = 0;
                 $permissions->publish = 0;
                 $permissions->order = 0;
             }
         } elseif ($JLMS_ACL->CheckPermissions('docs', 'only_own_role')) {
             // reset permissions for not owned by my colleagues items
             if ($JLMS_ACL->GetRole() != $JLMS_ACL->UserSystemRole($JLMS_DB, $row->owner_id)) {
                 $permissions->manage = 0;
                 $permissions->create = 0;
                 $permissions->publish = 0;
                 $permissions->order = 0;
             }
         }
     }
     return $permissions;
 }
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));
}
    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 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();
    }
    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 showTracking($id, $option, &$rows, &$lists, &$track_images, &$latest_activities, $msg = '')
    {
        global $my;
        $JLMS_ACL =& JLMSFactory::getACL();
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $Itemid = $JLMS_CONFIG->get('Itemid');
        JLMS_TMPL::OpenMT();
        $hparams = array();
        //$hparams['second_tb_header'] = _JLMS_TRACK_TITLE_ACCESS.JLMS_TRACKING_getTitle(null);
        $toolbar = array();
        if ($JLMS_ACL->CheckPermissions('tracking', 'clear_stats')) {
            $toolbar[] = array('btn_type' => 'clear', 'btn_js' => sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=track_clear&amp;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="2" cellspacing="0" border="0" class="jlms_table_no_borders">
			<tr>
				<td width="65%" valign="top">
					<?php 
        echo JLMSCSS::h2(_JLMS_TRACKING_LATEST_COURSE_ACTIVITIES);
        ?>
					<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 
        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 
        $k = 1;
        if (!count($latest_activities)) {
            echo '<tr class="' . JLMSCSS::_('sectiontableentry' . $k) . '"><td colspan="4">' . _JLMS_TRACKING_NO_STATISTICS . '</td></tr>';
        }
        foreach ($latest_activities as $latest_activity) {
            echo '<tr class="' . JLMSCSS::_('sectiontableentry' . $k) . '">';
            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;
        }
        ?>
					</table>
				</td>
				<td valign="top">
					<?php 
        echo JLMSCSS::h2(_JLMS_TRACKING_STATISTICS_REPORTS);
        ?>
					<table width="100%" cellpadding="0" cellspacing="0" border="0" class="<?php 
        echo JLMSCSS::_('jlmslist');
        ?>
">
						<tr>
							<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" colspan="2">
							<?php 
        echo _JLMS_TRACKING_STATISTICS_REPORTS;
        ?>
							</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
						</tr>
						<tr class="<?php 
        echo JLMSCSS::_('sectiontableentry1');
        ?>
">
							<td width="16"><img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/toolbar/tlb_tracking.png" alt="i" width="16" height="16" border="0" /></td>
							<td><a href="<?php 
        echo JLMSRoute::_("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=tracking&amp;id={$id}&amp;page=12");
        ?>
"><?php 
        echo _JLMS_TRACKING_DOCUMENTS_STATISTICS;
        ?>
</a></td>
						</tr>
						<tr class="<?php 
        echo JLMSCSS::_('sectiontableentry2');
        ?>
">
							<td width="16"><img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/toolbar/tlb_tracking.png" alt="i" width="16" height="16" border="0" /></td>
							<td><a href="<?php 
        echo JLMSRoute::_("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=tracking&amp;id={$id}&amp;page=13");
        ?>
"><?php 
        echo _JLMS_TRACKING_LPATHS_STATISTICS;
        ?>
</a></td>
						</tr>
						<tr class="<?php 
        echo JLMSCSS::_('sectiontableentry1');
        ?>
">
							<td width="16"><img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/toolbar/tlb_tracking.png" alt="i" width="16" height="16" border="0" /></td>
							<td><a href="<?php 
        echo JLMSRoute::_("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=tracking&amp;id={$id}&amp;page=14");
        ?>
"><?php 
        echo _JLMS_TRACKING_LATEST_COURSE_ACTIVITIES_REPORT;
        ?>
</a></td>
						</tr>
						<tr class="<?php 
        echo JLMSCSS::_('sectiontableentry2');
        ?>
">
							<td width="16"><img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/toolbar/tlb_quiz.png" alt="i" width="16" height="16" border="0" /></td>
							<td><a href="<?php 
        echo JLMSRoute::_("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=quizzes&amp;id={$id}&amp;page=reports");
        ?>
"><?php 
        echo _JLMS_TRACKING_QUIZZES_REPORT;
        ?>
</a></td>
						</tr>
						<tr class="<?php 
        echo JLMSCSS::_('sectiontableentry1');
        ?>
">
							<td width="16"><img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/toolbar/tlb_quiz.png" alt="i" width="16" height="16" border="0" /></td>
							<td><a href="<?php 
        echo JLMSRoute::_("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=quizzes&amp;id={$id}&amp;page=quiz_bars");
        ?>
"><?php 
        echo _JLMS_TRACKING_QUIZZES_ANSWERS_STATISTICS;
        ?>
</a></td>
						</tr>
					</table>
				</td>
			</tr>
			</table><br />
			<?php 
        echo JLMSCSS::h2(_JLMS_TRACK_TITLE_ACCESS . JLMS_TRACKING_getTitle(null));
        ?>
			<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 
        $lists['filter_month'] = str_replace('<option value="0" selected="selected"></option>', '<option value="0" selected="selected">&nbsp;</option>', $lists['filter_month']);
        $lists['filter_month'] = str_replace('<option value="0"></option>', '<option value="0">&nbsp;</option>', $lists['filter_month']);
        ?>
							<?php 
        echo $lists['filter'];
        ?>
&nbsp;<?php 
        echo $lists['filter_month'] . '<br />';
        if (isset($lists['filter2'])) {
            echo $lists['filter2'] . '<br />';
        }
        if (isset($lists['filter3'])) {
            echo $lists['filter3'] . '<br />';
        }
        echo $lists['filter_stu'];
        ?>
						</div>
					</td>
				</tr>
			</table>
	<?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_DATE;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=1");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_DOCS;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_DOCS;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=2");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_LINKS;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_LINKS;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=3");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_DROP;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_DROP;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=4");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_LPATH;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_LPATH;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=5");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_HW;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_HW;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=6");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_ANNOUNC;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_ANNOUNC;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=7");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_CONF;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_CONF;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=8");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_CHAT;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_CHAT;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=9");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_LPPLAY;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_LPPLAY;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=10");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_FORUM;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_FORUM;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><a href="<?php 
        echo sefRelToAbs($link . "&amp;page=11");
        ?>
" title="<?php 
        echo _JLMS_TRACK_TBL_H_QUIZ;
        ?>
"><?php 
        echo _JLMS_TRACK_TBL_H_QUIZ;
        ?>
</a></<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
					<<?php 
        echo JLMSCSS::tableheadertag();
        ?>
 class="<?php 
        echo JLMSCSS::_('sectiontableheader');
        ?>
" align="center"><?php 
        echo _JLMS_TOTAL;
        ?>
</<?php 
        echo JLMSCSS::tableheadertag();
        ?>
>
				</tr>
			<?php 
        $k = 1;
        $i = 0;
        $total_counts = array();
        for ($j = 0; $j < 11; $j++) {
            $total_counts[$j] = 0;
        }
        while ($i < count($rows)) {
            $row = $rows[$i];
            $subtotal = 0;
            $link = "index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=tracking&amp;id={$id}&amp;filter_month={$row->month}";
            ?>
				<tr class="<?php 
            echo JLMSCSS::_('sectiontableentry' . $k);
            ?>
">
					<td align="left" valign="middle" style="vertical-align:middle ">
					<?php 
            if ($lists['is_month']) {
                echo JLMS_dateToDisplay(mktime(0, 0, 0, $lists['month'], $row->month, $lists['year']), true);
            } else {
                echo '<a href="' . sefRelToAbs($link) . '" title="' . _JLMS_VIEW_DETAILS . '">' . month_lang(strftime("%m", mktime(0, 0, 0, $row->month + 1, 0, 0)), 0, 2) . '</a>';
            }
            ?>
					</td>
					<?php 
            $j = 1;
            $month = $rows[$i]->month;
            $year = $rows[$i]->year;
            do {
                while ($j < $rows[$i]->page_id) {
                    echo '<td align="center">0</td>';
                    $j++;
                }
                if ($rows[$i]->month == $month && $rows[$i]->year == $year) {
                    echo '<td align="center">' . $rows[$i]->count_hits . '</td>';
                    $total_counts[$j - 1] = $total_counts[$j - 1] + $rows[$i]->count_hits;
                    $subtotal = $subtotal + $rows[$i]->count_hits;
                }
                $j++;
                $i++;
            } while ($i < count($rows) && $rows[$i]->month == $month && $rows[$i]->year == $year);
            while ($j <= 11) {
                echo '<td align="center">0</td>';
                $j++;
            }
            echo '<td align="center"><strong>' . $subtotal . '</strong></td>';
            if (isset($rows[$i]->month) && $rows[$i]->month != $month) {
                $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 
        $subtotal = 0;
        for ($j = 0; $j < 11; $j++) {
            echo '<td align="center"><strong>' . $total_counts[$j] . '</strong></td>';
            $subtotal = $subtotal + $total_counts[$j];
        }
        echo '<td align="center"><strong>' . $subtotal . '</strong></td>';
        ?>
				</tr>
			</table><br />
			<?php 
        if (!empty($track_images)) {
            echo "<table cellpadding='0' cellspacing='0' border='0' width='100%' class='jlms_table_no_borders'>";
            $i = 0;
            foreach ($track_images as $ti) {
                if ($i == 0) {
                    echo "<tr><td align='center' valign='top'>";
                } elseif ($i == 2) {
                    echo "</td><td align='center' valign='top'>";
                } elseif ($i == 3) {
                    echo "</td></tr><tr><td colspan='2' align='center' valign='top'>";
                } elseif ($i == 4) {
                    echo "</td></tr><tr><td colspan='2' align='center' valign='top'>";
                }
                ?>
					<?php 
                echo JLMSCSS::h2($ti->title);
                ?>
					<img src="<?php 
                echo $JLMS_CONFIG->get('live_site') . "/" . $JLMS_CONFIG->get('temp_folder', '') . "/{$ti->filename}";
                ?>
" width="<?php 
                echo $ti->width;
                ?>
" height="<?php 
                echo $ti->height;
                ?>
" alt="<?php 
                echo $ti->alt;
                ?>
" title="<?php 
                echo $ti->alt;
                ?>
" border='0' />
				<?php 
                if ($i == 4) {
                    echo "</td></tr>";
                }
                $i++;
            }
            if (count($track_images) == 4) {
                echo "</td></tr>";
            }
            echo "</table>";
        } elseif ($msg) {
            echo '<div class="joomlalms_sys_message">' . $msg . '</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="tracking" />
		<input type="hidden" name="state" value="0" />
		<input type="hidden" name="id" value="<?php 
        echo $id;
        ?>
" />
		</form>
<?php 
        JLMS_TMPL::CloseTS();
        JLMS_TMPL::CloseMT();
    }
    function show_agenda_items($id, $option, $rows, $date, $lists, $agenda)
    {
        $JLMS_CONFIG =& JLMSFactory::getConfig();
        $Itemid = $JLMS_CONFIG->get('Itemid');
        $JLMS_ACL =& JLMSFactory::getACL();
        //JLMS_loadCalendar();
        JLMS_dateLoadJSFrameWork(true);
        $k = $exp = 0;
        $m = count($agenda);
        /*<script type="text/javascript" src="<?php echo $JLMS_CONFIG->get('live_site');?>/includes/js/joomla.javascript.js "></script>*/
        ?>
		
		<script language="javascript" type="text/javascript">
		<!--
		function quick_date(){
			document.forms.jlms_agenda_form_day.submit();
		}
		var test = 'month_num<?php 
        echo $exp;
        ?>
';
		
		function JLMS_expandMonth( monthId ) {
			if (test == monthId){
				getObj(monthId).style.display = 'none';
				test = '';
			}
			else{
				JLMS_collapseAllMonth();
				getObj(monthId).style.display = '';
				test = monthId;
			}
		}		
		function JLMS_collapseAllMonth() {
			for (i=0; i<=<?php 
        echo $m;
        ?>
; i++){
				if (getObj('month_num'+i)){
					getObj('month_num'+i).style.display = 'none';
				}
			}
		}
		//-->
		</script>
		<form name="jlms_filter" action="<?php 
        echo sefRelToAbs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=agenda&amp;id={$id}");
        ?>
" method="post" >
		<table class="jlms_table_no_borders" width='100%' cellpadding="0" cellspacing="0" border="0">
			<tr>
				<td align="right" style="text-align:right; height:30px; " valign="top">
				<?php 
        echo _JLMS_ORDERING . "&nbsp;" . $lists['order'];
        ?>
				&nbsp;&nbsp;
				<?php 
        echo _JLMS_FILTER . "&nbsp;" . $lists['filter'];
        ?>
				<input type="submit" value="<?php 
        echo _JLMS_AGENDA_GO;
        ?>
" class="button" name="<?php 
        echo _JLMS_AGENDA_GO;
        ?>
" />
				</td>
			</tr>
		</table>
		</form>
		<?php 
        if (!empty($agenda)) {
            echo "<table cellpadding='0' cellspacing='0' width='100%' style='width:100%'>";
        } else {
            echo '<div class="joomlalms_user_message">' . _JLMS_AGENDA_NO_ITEMS . '</div>';
        }
        $a_id_date = '';
        $selected_id = 0;
        if (isset($_REQUEST['agenda_id'])) {
            $selected_id = $_REQUEST['agenda_id'];
        }
        $i = 0;
        $k = 0;
        $ste = 2;
        //kolichestvo mesiacev
        $j = 1;
        $new_exp = 0;
        for ($i = 0; $i < count($agenda); $i++) {
            $b_bot = '';
            $border = '';
            $none = "style='display:none'";
            if ($agenda[$i]->a_y . '-' . $agenda[$i]->a_m == date('Y-m') || count($agenda) == 1) {
                $none = '';
                $new_exp = $i;
            }
            if (isset($selected_id) && $agenda[$i]->a_y . '-' . $agenda[$i]->a_m == mosGetParam($_REQUEST, 'cal_date', '')) {
                $none = '';
                $new_exp = $i;
            }
            echo "<tr onclick='JLMS_expandMonth(\"month_num" . $i . "\")' style='cursor:pointer'><td class='month_header' " . $b_bot . " title='" . _JLMS_AGENDA_CLICK_HERE . "'>" . month_lang(strftime('%m %Y', strtotime($agenda[$i]->a_y . '-' . $agenda[$i]->a_m . '-1')), 0, 2) . "</td></tr>";
            echo "<tr {$none} id='month_num" . $i . "'><td valign='top' style='padding:3px;' >";
            if (count($agenda[$i]->items)) {
                echo "<table width='100%' cellpadding='0' cellspacing='0' border='0' class='jlms_table_no_borders'>";
            }
            for ($j = 0; $j < count($agenda[$i]->items); $j++) {
                $border = '';
                if ($selected_id == $agenda[$i]->items[$j]->agenda_id && $agenda[$i]->a_y . '-' . $agenda[$i]->a_m == mosGetParam($_REQUEST, 'cal_date', '')) {
                    $border = 'background:#F2E3D4;';
                }
                echo "<tr><td valign='top' style='{$border};' ><a name='anc" . $agenda[$i]->items[$j]->agenda_id . '-' . $agenda[$i]->a_y . '-' . $agenda[$i]->a_m . "'></a>";
                //print Image v zavisimosti ot tipa (proshedshee sobitie)
                if ($agenda[$i]->items[$j]->start_date > date('Y-m-d')) {
                    echo "<img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/agenda/ag_upcoming.png\" alt='" . _JLMS_AGENDA_UPCOMING . "' title='" . _JLMS_AGENDA_UPCOMING . "' align='left' border='0' width='16' height='16' class='JLMS_png' />&nbsp;";
                } elseif ($agenda[$i]->items[$j]->end_date >= date('Y-m-d') && $agenda[$i]->items[$j]->start_date <= date('Y-m-d')) {
                    echo "<img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/agenda/ag_today.png\" alt='" . _JLMS_AGENDA_TODAY . "' title='" . _JLMS_AGENDA_TODAY . "' align='left' border='0' width='16' height='16' class='JLMS_png' />&nbsp;";
                } else {
                    echo "<img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/agenda/ag_last.png\" alt='" . _JLMS_AGENDATB_THELAST . "' title='" . _JLMS_AGENDATB_THELAST . "' align='left' border='0' width='16' height='16' class='JLMS_png' />&nbsp;";
                }
                //print title + description
                echo "<b>" . $agenda[$i]->items[$j]->title . "</b></td></tr>";
                echo "<tr><td class='createdate' style='{$border};'><font color='#585A5C'>" . _JLMS_START_DATE . "</font>&nbsp;" . day_month_lang(date('w m d, Y', strtotime($agenda[$i]->items[$j]->start_date)), 0, 1, 2, 2) . " &nbsp;&nbsp;&nbsp;<font color='#585A5C'> " . _JLMS_END_DATE . "</font> &nbsp;" . day_month_lang(date('w m d, Y', strtotime($agenda[$i]->items[$j]->end_date)), 0, 1, 2, 2) . "";
                echo "</td></tr>";
                if ($JLMS_ACL->CheckPermissions('announce', 'manage') && isset($agenda[$i]->items[$j]->is_time_related) && $agenda[$i]->items[$j]->is_time_related) {
                    $released_info_txt = _JLMS_WILL_BE_RELEASED_IN;
                    $showperiod = $agenda[$i]->items[$j]->show_period;
                    $ost1 = $showperiod % (24 * 60);
                    $sp_days = ($showperiod - $ost1) / (24 * 60);
                    $ost2 = $showperiod % 60;
                    $sp_hours = ($ost1 - $ost2) / 60;
                    $sp_mins = $ost2;
                    $released_info_time = false;
                    if ($sp_days) {
                        $released_info_txt .= ' ' . $sp_days . ' ' . _JLMS_RELEASED_IN_DAYS;
                        $released_info_time = true;
                    }
                    if ($sp_hours) {
                        $released_info_txt .= ' ' . $sp_hours . ' ' . _JLMS_RELEASED_IN_HOURS;
                        $released_info_time = true;
                    }
                    if ($sp_mins) {
                        $released_info_txt .= ' ' . $sp_mins . ' ' . _JLMS_RELEASED_IN_MINUTES;
                        $released_info_time = true;
                    }
                    if ($released_info_time) {
                        $released_info_txt .= ' ' . _JLMS_RELEASED_AFTER_ENROLLMENT;
                    }
                    echo "<tr><td class='small' style='{$border};'>" . $released_info_txt . "</td></tr>";
                }
                echo "<tr><td width='100%' align='left' style='{$border};'>";
                echo $agenda[$i]->items[$j]->content;
                echo "</td></tr>";
                //redaktirovanie zapisei dlia teachera kotorii ego sozdal ili super admina
                if ($JLMS_ACL->CheckPermissions('announce', 'manage')) {
                    echo "<tr>\n\t\t\t\t\t\t\t<td align='right' style='{$border} text-align:right' >\n\t\t\t\t\t\t\t\t<a href='" . sefRelToabs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=agenda&amp;mode=edit&amp;id={$id}&amp;agenda_id=" . $agenda[$i]->items[$j]->agenda_id) . "' ><img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/toolbar/btn_edit.png\" alt='" . _JLMS_EDIT . "' title='" . _JLMS_EDIT . "' align='top' border='0' width='16' height='16' class='JLMS_png' /></a>\n\t\t\t\t\t\t\t\t&nbsp;&nbsp;\n\t\t\t\t\t\t\t\t<a href='" . sefRelToabs("index.php?option={$option}&amp;Itemid={$Itemid}&amp;task=agenda&amp;mode=delete&amp;id={$id}&amp;agenda_id=" . $agenda[$i]->items[$j]->agenda_id) . "' ><img src=\"" . $JLMS_CONFIG->get('live_site') . "/components/com_joomla_lms/lms_images/toolbar/btn_delete.png\" alt='" . _JLMS_DELETE . "' title='" . _JLMS_DELETE . "' align='top' border='0' width='16' height='16' class='JLMS_png' /></a>&nbsp;\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>";
                }
            }
            if (count($agenda[$i]->items)) {
                echo "</table>";
            }
            echo "</td></tr>";
        }
        if (!empty($agenda)) {
            echo "</table>";
        }
        //zakrivaem <table> po okonchaniu mesiaca
        //echo "</td></tr>";
        ?>
		<?php 
        if (isset($new_exp) && $new_exp) {
            ?>
			<script language="javascript" type="text/javascript">
			<!--
			var test = 'month_num<?php 
            echo $new_exp;
            ?>
';
			//-->
			</script>
		<?php 
        }
        ?>
			<!--tr>
				<td-->
				<div class="joomlalms_info_legend">
				* - <?php 
        echo _JLMS_AGENDA_CLICK_MONTH_TITLE;
        ?>
<br /><br />
				<b><?php 
        echo _JLMS_AGENDA_COMMENT;
        ?>
</b><br /><br />
				<img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/agenda/ag_last.png" align="top" alt='<?php 
        echo _JLMS_AGENDATB_THELAST;
        ?>
' title='<?php 
        echo _JLMS_AGENDATB_THELAST;
        ?>
' border='0' width='16' height='16' class='JLMS_png' /> 
				- <?php 
        echo _JLMS_AGENDA_DESC_LAST;
        ?>
<br />
				<img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/agenda/ag_today.png" align="top" alt='<?php 
        echo _JLMS_AGENDA_TODAY;
        ?>
' title='<?php 
        echo _JLMS_AGENDA_TODAY;
        ?>
' border='0' width='16' height='16' class='JLMS_png' /> 
				- <?php 
        echo _JLMS_AGENDA_DESC_TOD;
        ?>
<br />
				<img src="<?php 
        echo $JLMS_CONFIG->get('live_site');
        ?>
/components/com_joomla_lms/lms_images/agenda/ag_upcoming.png" align="top" alt='<?php 
        echo _JLMS_AGENDA_UPCOMING;
        ?>
' title='<?php 
        echo _JLMS_AGENDA_UPCOMING;
        ?>
' border='0' width='16' height='16' class='JLMS_png' /> 
				- <?php 
        echo _JLMS_AGENDA_DESC_UPC;
        ?>
				</div>
				<!--/td>
			</tr>
		</table-->		
	<?php 
    }
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}"));
}
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}"));
    }
}
Beispiel #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;
}