$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 if (isset($_GET['ajax']) && $_GET['ajax'] == 'lessonsTable') { $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); $smarty->assign("T_DIRECTIONS_PATHS", $directionPaths); $constraints = array('archive' => false) + createConstraintsFromSortedTable(); $dataSource = EfrontLesson::getAllLessons($constraints); $totalEntries = EfrontLesson::countAllLessons($constraints); $tableName = $_GET['ajax']; $alreadySorted = 1; $smarty->assign("T_TABLE_SIZE", $totalEntries); include "sorted_table.php"; /* $lessons = EFrontLesson :: getLessons(); 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])) {
$editLesson = new EfrontLesson($_GET['id']); if ($editLesson->isUserActiveInLesson($editedUser)) { $editLesson->unConfirm($editedUser); $response['access'] = 0; } else { $editLesson->confirm($editedUser); $response['access'] = 1; } echo json_encode($response); exit; } else { if (isset($_GET['ajax']) && in_array($_GET['ajax'], array('lessonsTable'))) { $roles = EfrontLessonUser::getLessonsRoles(true); $smarty->assign("T_ROLES_ARRAY", $roles); $directionsTree = new EfrontDirectionsTree(); $smarty->assign("T_DIRECTION_PATHS", $directionsTree->toPathString()); $rolesBasic = EfrontLessonUser::getLessonsRoles(); $smarty->assign("T_BASIC_ROLES_ARRAY", $rolesBasic); $smarty->assign("T_EDITED_USER_TYPE", $editedUser->user['user_types_ID'] ? $editedUser->user['user_types_ID'] : $editedUser->user['user_type']); if (isset($_GET['ajax']) && $_GET['ajax'] == 'lessonsTable') { $smarty->assign("T_DATASOURCE_COLUMNS", array('name', 'directions_ID', 'completed', 'active_in_lesson', 'user_type', 'score', 'has_lesson')); if ($_change_lessons_) { $nonLessons = array(); foreach ($editedUser->getNonLessons(true) as $key => $lesson) { if (!$lesson->lesson['course_only']) { $nonLessons[$key] = $lesson; } } if ($independentLessons = $editedUser->getUserStatusInIndependentLessons(true)) { $lessons = $independentLessons + $nonLessons; } else {
/** * The main functionality * * (non-PHPdoc) * @see libraries/EfrontModule#getModule() */ public function getModule() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $directionsTree = new EfrontDirectionsTree(); $directionsPaths = $directionsTree->toPathString(); $smarty->assign("T_MODULE_OUTLOOK_INVITATION_DIRECTION_PATHS", $directionsPaths); $temp = eF_getTableData("module_outlook_invitation as m,courses as c", "m.*,c.name,c.directions_ID", "m.courses_ID=c.id"); $events = array(); foreach ($temp as $value) { $events[$value['courses_ID']] = $value; } if (isset($_GET['delete_event']) && eF_checkParameter($_GET['delete_event'], 'id') && in_array($_GET['delete_event'], array_keys($events))) { try { $event = $events[$_GET['delete_event']]; $course = new EfrontCourse($event['courses_ID']); $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false)); $recipients = array(); foreach ($users as $value) { $recipients[] = $value['email']; } $this->cancelInvitation($course->course['id'], $recipients); eF_deleteTableData("module_outlook_invitation", "courses_ID=" . $_GET['delete_event']); } catch (Exception $e) { header("HTTP/1.0 500 "); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } exit; } if ($_SESSION['s_type'] != 'administrator') { $userCourses = $currentUser->getUserCourses(array('archive' => 0, 'active' => true, 'return_objects' => false)); if (G_VERSIONTYPE == 'enterprise') { if ($_SESSION['s_current_branch']) { $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID='{$_SESSION['s_current_branch']}'"); } else { if ($currentUser->aspects['hcd']->isSupervisor()) { $result = eF_getTableData("module_hcd_course_to_branch", "courses_ID", "branches_ID in (select branches_ID from module_hcd_employee_works_at_branch where users_login='******'login']}' and supervisor=1)"); } } $branchCourses = array(); foreach ($result as $value) { $branchCourses[$value['courses_ID']] = $value['courses_ID']; } foreach ($events as $key => $value) { if (!isset($branchCourses[$key]) && !isset($userCourses[$key])) { unset($events[$key]); } } } else { foreach ($events as $key => $value) { if (!isset($userCourses[$key])) { unset($events[$key]); } } } } if (!isset($_GET['course'])) { $dataSource = $events; $tableName = 'outlookInvitationsTable'; isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'uint') ? $limit = $_GET['limit'] : ($limit = G_DEFAULT_TABLE_SIZE); if (isset($_GET['sort']) && eF_checkParameter($_GET['sort'], 'text')) { $sort = $_GET['sort']; isset($_GET['order']) && $_GET['order'] == 'desc' ? $order = 'desc' : ($order = 'asc'); } else { $sort = 'login'; } $dataSource = eF_multiSort($dataSource, $sort, $order); $smarty->assign("T_TABLE_SIZE", sizeof($dataSource)); if (isset($_GET['filter'])) { $dataSource = eF_filterData($dataSource, $_GET['filter']); } if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $dataSource = array_slice($dataSource, $offset, $limit); } $smarty->assign("T_DATA_SOURCE", $dataSource); } else { $course = new EfrontCourse($_GET['course']); $form = new HTML_QuickForm("import_outlook_invitation_form", "post", $this->moduleBaseUrl . "&course={$course->course['id']}&add_event=1" . (isset($_GET['popup']) ? '&popup=1' : ''), "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter $form->addElement('text', 'email', _SENDER, 'class = "inputText"'); $form->addElement('text', 'location', _LOCATION, 'class = "inputText"'); $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText"'); $form->addElement('textarea', 'description', _DESCRIPTION, 'class = "inputTestTextarea" style = "width:80%;height:6em;"'); //$form -> addElement('checkbox', 'calendar', _MODULE_OUTLOOK_INVITATION_CREATE_CALENDAR); //$form -> addElement('static', 'static', _MODULE_OUTLOOK_INVITATION_INFO); $form->addElement('submit', 'submit_event_all', _MODULE_OUTLOOK_INVITATION_SENDALL, 'class=flatButton'); $form->addElement('submit', 'submit_event_new', _MODULE_OUTLOOK_INVITATION_SENDNEW, 'class=flatButton'); if (empty($events[$course->course['id']])) { //new invitation $currentEvent = null; $form->setDefaults(array('email' => $currentUser->user['email'], 'subject' => 'Invitation to attend training: ' . $course->course['name'])); } else { //existing invitation $currentEvent = $events[$course->course['id']]; $form->setDefaults(array('email' => $currentEvent['email'], 'description' => $currentEvent['description'], 'subject' => $currentEvent['subject'], 'location' => $currentEvent['location'])); } if ($form->isSubmitted() && $form->validate()) { try { $message = ""; // Set info to store into database $permanent_info = array("courses_ID" => $course->course['id'], "email" => $form->exportValue('email') ? $form->exportValue('email') : $GLOBALS['configuration']['system_email'], "location" => $form->exportValue('location'), "subject" => $form->exportValue('subject'), "description" => $form->exportValue('description')); if ($currentEvent) { $permanent_info['sequence'] = $currentEvent['sequence'] + 1; eF_updateTableData("module_outlook_invitation", $permanent_info, "courses_ID={$course->course['id']}"); } else { eF_insertTableData("module_outlook_invitation", $permanent_info); } if ($form->exportValue('submit_event_all')) { $users = $course->getCourseUsers(array('active' => true, archive => false, 'return_objects' => false)); $recipients = array(); foreach ($users as $value) { $recipients[] = $value['email']; } $this->sendInvitation($course->course['id'], $recipients); } // $smarty->assign('T_RELOAD', true); if (isset($_GET['popup'])) { $this->setMessageVar(_OPERATIONCOMPLETEDSUCCESSFULLY, 'success'); } else { eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_OPERATIONCOMPLETEDSUCCESSFULLY) . "&message_type=success"); } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $this->setMessageVar($e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>', 'failure'); } } $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR); $form->setRequiredNote(_REQUIREDNOTE); $smarty->assign('T_MODULE_OUTLOOK_INVITATION_FORM', $form->toArray()); } $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir); $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl); return true; }
private function doCategoryReports() { $smarty = $this->getSmartyVar(); $currentUser = $this->getCurrentUser(); $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); $form = new HTML_QuickForm("category_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=module&op=module_administrator_tools&tab=category_reports&do=enterprise", "", null, true); $form->addElement('select', 'category', _CATEGORY, $directionPaths); $form->addElement('checkbox', 'incomplete', _MODULE_ADMINISTRATOR_TOOLS_SHOWINCOMPLETE); $form->addElement('checkbox', 'inactive', _MODULE_ADMINISTRATOR_TOOLS_SHOWINACTIVECOURSES); $form->addElement('date', 'from_timestamp', _MODULE_ADMINISTRATOR_TOOLS_COMPLETEDFROM, array('minYear' => 1970, 'maxYear' => date("Y"))); $form->addElement('date', 'to_timestamp', _MODULE_ADMINISTRATOR_TOOLS_COMPLETEDTO, array('minYear' => 1970, 'maxYear' => date("Y"))); $form->addElement("submit", "submit", _SUBMIT, 'class = "flatButton"'); $form->setDefaults(array("from_timestamp" => mktime(0, 0, 0, date("m") - 1, date("d"), date("Y")), "to_timestamp" => time())); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); $_SESSION['from_timestamp'] = mktime(0, 0, 0, $_POST['from_timestamp']['M'], $_POST['from_timestamp']['d'], $_POST['from_timestamp']['Y']); $_SESSION['to_timestamp'] = mktime(23, 59, 59, $_POST['to_timestamp']['M'], $_POST['to_timestamp']['d'], $_POST['to_timestamp']['Y']); $_SESSION['category'] = $values['category']; $_SESSION['incomplete'] = $values['incomplete']; $_SESSION['inactive'] = $values['inactive']; $smarty->assign("T_SHOW_TABLE", true); } if (isset($_GET['ajax']) && $_GET['ajax'] == 'categoryUsersTable' || $_GET['ajax'] == 'xls' || $_GET['ajax'] == 'show_xls') { $smarty->assign("T_SHOW_TABLE", true); $smarty->assign("T_DIRECTIONS_TREE", $directionPaths); $branchesTree = new EfrontBranchesTree(); $branchesPaths = $branchesTree->toPathString(); $category = new EfrontDirection($_SESSION['category']); $directionsTree = new EfrontDirectionsTree(); $children = $directionsTree->getNodeChildren($_SESSION['category']); foreach (new EfrontAttributeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($children)), array('id')) as $value) { $siblings[] = $value; } $result = eF_getTableDataFlat("courses", "id", "archive = 0 && directions_ID in (" . implode(",", $siblings) . ")"); $categoryCourses = $result['id']; $resultCourses = eF_getTableDataFlat("users_to_courses uc, courses c", "distinct c.id", 'c.id=uc.courses_ID ' . (!$_SESSION['inactive'] ? 'and c.active=1' : '') . ' and uc.archive=0 and uc.completed=1 and uc.to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and uc.to_timestamp <= ' . $_SESSION['to_timestamp']); $resultEvents = eF_getTableDataFlat("events e, courses c", "distinct c.id", 'c.id=e.lessons_ID ' . (!$_SESSION['inactive'] ? 'and c.active=1' : '') . ' and e.type=54 and e.timestamp >= ' . $_SESSION['from_timestamp'] . ' and e.timestamp <= ' . $_SESSION['to_timestamp']); if (empty($resultEvents)) { $resultEvents['id'] = array(); } $result = array_unique(array_merge($resultCourses['id'], $resultEvents['id'])); $categoryCourses = array_intersect(array_unique($categoryCourses), $result); //count only courses that have users completed them if ($_SESSION['incomplete']) { $constraints = array('archive' => false, 'condition' => '(to_timestamp is null OR to_timestamp = 0 OR (to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and to_timestamp <= ' . $_SESSION['to_timestamp'] . '))'); } else { $constraints = array('archive' => false, 'condition' => 'completed=1 and to_timestamp >= ' . $_SESSION['from_timestamp'] . ' and to_timestamp <= ' . $_SESSION['to_timestamp']); } foreach ($categoryCourses as $courseId) { $course = new EfrontCourse($courseId); foreach ($course->getCourseUsers($constraints) as $value) { $userBranches = $value->aspects['hcd']->getBranches(); $userSupervisors = $value->aspects['hcd']->getSupervisors(); $userSupervisor = end($userSupervisors); $value->user['course_active'] = $course->course['active']; $value->user['course_id'] = $course->course['id']; $value->user['category'] = $directionPaths[$course->course['directions_ID']]; $value->user['course'] = $course->course['name']; $value->user['directions_ID'] = $course->course['directions_ID']; $value->user['branch'] = $branchesPaths[current($userBranches['employee'])]; $value->user['branch_ID'] = current($userBranches['employee']); $value->user['supervisor'] = $userSupervisor; $value->user['historic'] = false; $unique = md5($value->user['to_timestamp'] . $value->user['course_id'] . $value->user['login']); $courseUsers[$unique] = $value->user; } $result = eF_getTableData("events", "*", 'type=54 and lessons_ID=' . $courseId . ' and timestamp >= ' . $_SESSION['from_timestamp'] . ' and timestamp <= ' . $_SESSION['to_timestamp']); //exit; foreach ($result as $entry) { try { $value = EfrontUserFactory::factory($entry['users_LOGIN']); if (!$value->user['archive']) { $userBranches = $value->aspects['hcd']->getBranches(); $userSupervisors = $value->aspects['hcd']->getSupervisors(); //pr($entry['users_LOGIN']);pr($userSupervisors);pr(current($userSupervisors)); $userSupervisor = current($userSupervisors); $value->user['course_active'] = $course->course['active']; $value->user['course_id'] = $course->course['id']; $value->user['category'] = $directionPaths[$course->course['directions_ID']]; $value->user['course'] = $course->course['name']; $value->user['directions_ID'] = $course->course['directions_ID']; $value->user['branch'] = $branchesPaths[current($userBranches['employee'])]; $value->user['branch_ID'] = current($userBranches['employee']); $value->user['supervisor'] = $userSupervisor; $value->user['to_timestamp'] = $entry['timestamp']; $value->user['completed'] = 1; $value->user['score'] = ''; $value->user['historic'] = true; $unique = md5($value->user['to_timestamp'] . $value->user['course_id'] . $value->user['login']); if (!isset($courseUsers[$unique])) { $courseUsers[$unique] = $value->user; } } } catch (Exception $e) { /*Bypass non-existing users*/ } } } if ($_GET['ajax'] == 'xls') { $xlsFilePath = $currentUser->getDirectory() . 'category_report.xls'; unlink($xlsFilePath); $_GET['limit'] = sizeof($courseUsers); $_GET['sort'] = 'category'; list($tableSize, $courseUsers) = filterSortPage($courseUsers); $header = array('category' => _CATEGORY, 'course' => _NAME, 'login' => _USER, 'to_timestamp' => _COMPLETED, 'score' => _SCORE, 'supervisor' => _SUPERVISOR, 'branch' => _BRANCH, 'historic' => _MODULE_ADMINISTRATOR_TOOLS_HISTORICENTRY); foreach ($courseUsers as $value) { $rows[] = array(_CATEGORY => str_replace(" → ", " -> ", $value['category']), _COURSE => $value['course'], _USER => formatLogin($value['login']), _COMPLETED => formatTimestamp($value['to_timestamp']), _SCORE => $value['historic'] ? '' : formatScore($value['score']) . '%', _SUPERVISOR => formatLogin($value['supervisor']), _BRANCH => str_replace(" → ", " -> ", $value['branch']), _MODULE_ADMINISTRATOR_TOOLS_HISTORICENTRY => $value['historic'] ? _YES : _NO); } EfrontSystem::exportToXls($rows, $xlsFilePath); exit; } else { if ($_GET['ajax'] == 'show_xls') { $xlsFilePath = $currentUser->getDirectory() . 'category_report.xls'; $file = new EfrontFile($xlsFilePath); $file->sendFile(true); exit; } else { list($tableSize, $courseUsers) = filterSortPage($courseUsers); $smarty->assign("T_SORTED_TABLE", $_GET['ajax']); $smarty->assign("T_TABLE_SIZE", $tableSize); $smarty->assign("T_DATA_SOURCE", $courseUsers); } } } $smarty->assign("T_CATEGORY_FORM", $form->toArray()); }
private function getRssSource($source, $mode, $lesson) { $feeds = $this->getProvidedFeeds(); foreach ($feeds as $value) { if ($value['active'] && $value['mode'] == 'system') { $systemFeeds[$value['type']] = $value; } else { if ($value['active'] && $value['mode'] == 'lesson') { $lessonFeeds[$value['type']] = $value; } } } if ($mode == 'system' && !in_array($source, array_keys($systemFeeds))) { return array(); } elseif ($mode == 'lesson' && !in_array($source, array_keys($lessonFeeds))) { return array(); } $data = array(); switch ($source) { case 'announcements': if ($mode == 'system') { $news = news::getNews(0, true); } elseif ($mode == 'lesson') { if ($lesson) { $news = news::getNews($lesson, true); } else { $lessons = eF_getTableDataFlat("lessons", "id, name"); $lessonNames = array_combine($lessons['id'], $lessons['name']); $news = news::getNews($lessons['id'], true); } } $count = 1; foreach ($news as $value) { if ($mode == 'lesson' && !$lesson) { $value['title'] = $lessonNames[$value['lessons_ID']] . ': ' . $value['title']; $link = G_SERVERNAME . 'userpage.php?lessons_ID=' . $value['lessons_ID'] . '&ctg=news&view=' . $value['id']; } else { $link = G_SERVERNAME . 'userpage.php?ctg=news&view=' . $value['id']; } $data[] = array('title' => $value['title'], 'link' => $link, 'description' => $value['data']); /* if ($count++ == $this -> feedLimit) { break; } */ } break; case 'catalog': $constraints = array("return_objects" => false, 'archive' => false, 'active' => true); $result = EfrontCourse::getAllCourses($constraints); $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); foreach ($result as $value) { $pathString = $directionPaths[$value['directions_ID']] . ' → ' . $value['name']; $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&courses_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info']))); } $result = eF_getTableData("lessons", "id,name,directions_ID, info", "archive=0 and instance_source = 0 and active=1 and course_only=0", "name"); foreach ($result as $value) { $pathString = $directionPaths[$value['directions_ID']] . ' → ' . $value['name']; $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&lessons_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info']))); } $data = array_values(eF_multisort($data, 'title', 'asc')); //Sort results based on path string break; case 'calendar': if ($mode == 'system') { $events = calendar::getGlobalCalendarEvents(); } elseif ($mode == 'lesson') { if ($lesson) { $events = calendar::getLessonCalendarEvents($lesson); } else { $events = calendar::getCalendarEventsForAllLessons(); } } foreach ($events as $value) { $value['name'] ? $title = formatTimestamp($value['timestamp']) . ' (' . $value['name'] . ')' : ($title = formatTimestamp($value['timestamp'])); $data[] = array('title' => $title, 'link' => G_SERVERNAME . 'userpage.php?ctg=calendar&view_calendar=' . $value['timestamp'] . '&type=0', 'description' => $value['data']); } break; /* case 'history': $currentUser = $this -> getCurrentUser(); $eventObjects = array(); $result = eF_getTableData("events", "*", "", "timestamp DESC limit 100"); foreach ($result as $value) { $eventObject = new EfrontEvent($value); $eventObject -> createMessage(); pr($eventObject); } break; */ /* case 'history': $currentUser = $this -> getCurrentUser(); $eventObjects = array(); $result = eF_getTableData("events", "*", "", "timestamp DESC limit 100"); foreach ($result as $value) { $eventObject = new EfrontEvent($value); $eventObject -> createMessage(); pr($eventObject); } break; */ case 'structure': if ($lesson) { $contentTree = new EfrontContentTree($lesson); $contentPath = $contentTree->toPathStrings(); foreach ($contentPath as $key => $value) { $data[] = array('title' => $value, 'link' => G_SERVERNAME . 'userpage.php?lessons_ID=' . $lesson . '&unit=' . $key, 'description' => $value); } } break; case 'forum': if ($mode == 'system') { $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id ", "fm.timestamp desc LIMIT 100"); } elseif ($mode == 'lesson') { if ($lesson) { $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID = '" . $lesson . "'", "fm.timestamp desc LIMIT 100"); } else { $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID != 0", "fm.timestamp desc LIMIT 100"); } } foreach ($result as $value) { $value['title'] = $value['forum_name'] . ' >> ' . $value['topic_title'] . ' >> ' . $value['title']; if ($mode == 'system' && $value['lessons_name'] || $mode == 'lesson' && !$lesson) { $value['title'] = $value['lessons_name'] . ': ' . $value['title']; } $data[] = array('title' => $value['title'], 'link' => G_SERVERNAME . 'userpage.php?ctg=forum&topic=' . $value['topic_id'], 'description' => $value['body']); } break; default: break; } return $data; }
try { $avatar = new EfrontFile($editedUser->user['avatar']); } catch (Exception $e) { $avatar = new EfrontFile(G_SYSTEMAVATARSPATH . "unknown_small.png"); } $smarty->assign("T_AVATAR", $avatar['url_path']); $smarty->assign("T_EMPLOYEE_SKILLS", $skills_sorted); $smarty->assign("T_EMPLOYEE_SKILL_CATEGORIES", $skill_categories); $smarty->assign('T_EVALUATIONS', $evaluations = $editedEmployee->getEvaluations()); $smarty->assign("T_FORM_PLACEMENTS", $jobs = $editedEmployee->getJobs()); } #cpp#endif if ($editedUser->user['user_type'] != 'administrator') { $directionsTree = new EfrontDirectionsTree(); $directionsArray = $directionsTree->getFlatTree(); $smarty->assign("T_DIRECTIONS_TREE", $directionsPathStrings = $directionsTree->toPathString()); $studentRoles = EfrontLessonUser::getRoles(); foreach ($studentRoles as $key => $value) { if ($value != 'student') { unset($studentRoles[$key]); } } $constraints = array('archive' => false); if ($_COOKIE['setUserFormSelectedSort']) { preg_match("/\\d_(\\w+)--(\\w+)/", $_COOKIE['setUserFormSelectedSort'], $matches); in_array($matches[1], array('name', 'directions_ID', 'active_in_course', 'completed', 'score')) ? $constraints['sort'] = $matches[1] : ($constraints['sort'] = 'name'); $matches[2] == 'desc' ? $constraints['order'] = 'asc' : ($constraints['order'] = 'desc'); } $userCourses = $editedUser->getUserCourses($constraints); foreach ($userCourses as $key => $value) { if (!in_array($value->course['user_type'], array_keys($studentRoles))) {
//$smarty -> assign("T_MENU", eF_getMenu()); $smarty->assign("T_QUERIES", $numberOfQueries); if ($_SESSION['s_message']) { $message .= urldecode($_SESSION['s_message']); $message_type = $_SESSION['s_message_type']; unset($_SESSION['s_message']); unset($_SESSION['s_message_type']); } $smarty->assign("T_MESSAGE", $message); $smarty->assign("T_MESSAGE_TYPE", $message_type); $smarty->assign("T_SEARCH_MESSAGE", $search_message); $smarty->assign("T_CURRENT_USER", $currentUser); $smarty->assign("T_CURRENT_LESSON", $currentLesson); if (isset($currentLesson)) { $directions = new EfrontDirectionsTree(); $paths = $directions->toPathString(); $categoryPath = $paths[$currentLesson->lesson["directions_ID"]]; //$categoryPath = str_replace("&rarr", "»", $categoryPath); $smarty->assign("T_CURRENT_CATEGORY_PATH", $categoryPath); if ($currentLesson->lesson['course_only'] == 1 && $_SESSION['s_courses_ID']) { $currentCourse = new EfrontCourse($_SESSION['s_courses_ID']); $smarty->assign("T_CURRENT_COURSE_NAME", htmlspecialchars($currentCourse->course['name'], ENT_QUOTES)); $smarty->assign("T_CURRENT_COURSE_ID", $currentCourse->course['id']); } } if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if ($GLOBALS['configuration']['facebook_api_key'] && $GLOBALS['configuration']['facebook_secret']) { $smarty->assign("T_FACEBOOK_USER", EfrontFacebook::userConnected()); } }
function askCourses() { eF_checkParameter($_POST['preffix'], 'text') ? $preffix = $_POST['preffix'] : ($preffix = '%'); if ($_SESSION['s_type'] == "administrator") { $result = eF_getTableData("courses", "id, name, directions_ID", "active=1 AND archive=0 and name like '%{$preffix}%'"); //$constraints = array("return_objects" => false, 'archive' => false, 'active' => true, 'filter' => $preffix); //$result = EfrontCourse :: getAllCourses($constraints); //$result = EfrontCourse :: convertCourseObjectsToArrays($courses); } else { $result = eF_getTableData("courses c, users_to_courses uc", "c.id, c.name, c.directions_ID", "(uc.user_type = 'professor' or uc.user_type in (select id from user_types where basic_user_type = 'professor')) AND c.active=1 AND c.id = uc.courses_ID AND uc.archive=0 and c.archive=0 AND uc.users_LOGIN='******'s_login'] . "' AND c.name like '%{$preffix}%'"); if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $result = eF_getTableData("courses c, users_to_courses uc", "c.id, c.name, c.directions_ID", "(uc.user_type = 'professor' or uc.user_type in (select id from user_types where basic_user_type = 'professor')) AND c.active=1 AND c.id = uc.courses_ID AND uc.archive=0 and c.archive=0 AND uc.users_LOGIN='******'s_login'] . "' AND c.name like '%{$preffix}%'"); // Add courses from supervised branches $user = EfrontUserFactory::factory($_SESSION['s_login']); if (isset($user->aspects['hcd']) && $user->aspects['hcd']->isSupervisor()) { $employee = $user->aspects['hcd']; //Get the courses assigned to the branches supervised by this user $supervised_courses = $employee->supervisesCourses(); //pr($result); $existing_course_ids = array_keys($supervised_courses); foreach ($result as $course) { if (!in_array($course['id'], $existing_course_ids)) { $supervised_courses[$course['id']] = $course; } } $result = array_values($supervised_courses); foreach ($result as $key => $value) { if (stripos($value['name'], $preffix) === false && $preffix != '%') { unset($result[$key]); } } } } else { #cpp#else $result = eF_getTableData("courses c, users_to_courses uc", "c.id, c.name, c.directions_ID", "(uc.user_type = 'professor' or uc.user_type in (select id from user_types where basic_user_type = 'professor')) AND c.active=1 AND c.id = uc.courses_ID AND uc.archive=0 and c.archive=0 AND uc.users_LOGIN='******'s_login'] . "' AND c.name like '%{$preffix}%'"); } #cpp#endif } $courses = array(); $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); foreach ($result as $value) { //for ($i = 0 ; $i < sizeof($result) ; $i ++) { $hiname = highlightSearch($value['name'], $preffix); $pathString = $directionPaths[$value['directions_ID']] . ' → ' . $hiname; $courses[] = array('id' => $value['id'], 'name' => $value['name'], 'path_string' => $pathString); } $courses = array_values(eF_multisort($courses, 'path_string', 'asc')); //Sort results based on path string $str = '<ul>'; for ($k = 0; $k < sizeof($courses); $k++) { $str = $str . '<li id=' . $courses[$k]['id'] . '>' . $courses[$k]['path_string'] . '</li>'; } $str .= '</ul>'; echo $str; }
if (isset($_GET['id']) && eF_checkParameter($_GET['id'], 'id') && isset($_GET['directions_ID']) && eF_checkParameter($_GET['directions_ID'], 'id')) { $course = new EfrontCourse($_GET['id']); if ($_GET['directions_ID'] != $course->course['directions_ID']) { $updateCourseInstancesCategory = true; //This means we need to update instances to match the course's new category } $course->course['directions_ID'] = $_GET['directions_ID']; $course->persist(); if (isset($updateCourseInstancesCategory) && $updateCourseInstancesCategory) { eF_updateTableData("courses", array("directions_ID" => $course->course['directions_ID']), "instance_source=" . $course->course['id']); } } exit; } catch (Exception $e) { echo $e->getMessage() . ' (' . $e->getCode() . ')'; } } } } else { $directionsTree = new EfrontDirectionsTree(); $directionsPaths = $directionsTree->toPathString(false); $flatTree = $directionsTree->getFlatTree(); foreach ($flatTree as $key => $value) { $flatTree[$key]['pathString'] = $directionsPaths[$value['id']]; $direction = new EfrontDirection($flatTree[$key]); $flatTree[$key]['lessons'] = sizeof($direction->getLessons()); $flatTree[$key]['courses'] = sizeof($direction->getCourses()); } unset($value); $smarty->assign("T_DIRECTIONS_DATA", $flatTree); }