try { if ($_SESSION['s_type'] != 'administrator' && $_SESSION['s_current_branch']) { //this applies to supervisors only $currentBranch = new EfrontBranch($_SESSION['s_current_branch']); } if (!EfrontUser::isOptionVisible('forum')) { eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } $loadScripts[] = 'includes/forum'; $roles = EfrontUser::getRoles(true); $smarty->assign("T_USERROLES", $roles); $forums = f_forums::getAll("f_forums"); foreach ($forums as $value) { $forums_to_lessons[$value['lessons_ID']] = $value['id']; } $lessons = EFrontLesson::getLessons(false, true); $res = eF_getTableData("lessons", "id,options"); foreach ($res as $value) { $options = unserialize($value['options']); if (!empty($options) && !$options['forum']) { unset($forums[$forums_to_lessons[$value['id']]]); } } //pr($forums); if (!$_admin_) { $userLessons = $currentUser->getEligibleLessons(); foreach ($forums as $key => $value) { //This takes the forum that belongs to this lesson, as well as general forums if ($value['lessons_ID'] && (!in_array($value['lessons_ID'], array_keys($userLessons)) || $lessons[$value['lessons_ID']]['active'] == 0 || $lessons[$value['lessons_ID']]['archive'] > 0)) { //if forum of lesson deactivated by professor not display it in list unset($forums[$key]);
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/if}'); $renderer->setErrorTemplate('{$html}{if $error} <div class = "formError">{$error}</div> {/if}'); $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); //Set javascript error messages $form->setRequiredNote(_REQUIREDNOTE); $form->accept($renderer); //Assign this form to the renderer, so that corresponding template code is created $smarty->assign('T_IMPORT_LESSON_FORM', $renderer->toArray()); //Assign the form to the template $lessons = EFrontLesson::getLessons(); $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); if (G_VERSIONTYPE == 'enterprise') { $result = eF_getTableDataFlat("lessons LEFT OUTER JOIN module_hcd_lesson_offers_skill ON module_hcd_lesson_offers_skill.lesson_ID = lessons.id", "lessons.id, count(skill_ID) as skills_offered", "lessons.archive=0", "", "id"); foreach ($result['id'] as $key => $lesson_id) { if (isset($lessons[$lesson_id])) { $lessons[$lesson_id]['skills_offered'] = $result['skills_offered'][$key]; } } } //Perform a query to get all the 'student' and 'student-like' users of every lesson $result = eF_getTableDataFlat("lessons l,users_to_lessons ul left outer join user_types ut on ul.user_type=ut.id", "l.id,count(*)", "ul.archive=0 and l.id=ul.lessons_ID and (ul.user_type='student' or (ul.user_type = ut.id and ut.basic_user_type = 'student'))", "", "l.id"); if (sizeof($result) > 0) { $lessonUsers = array_combine($result['id'], $result['count(*)']); }