if (eF_checkParameter($_GET['course'], 'id') == false) { echo "<xml>"; echo "<status>error</status>"; echo "<message>Invalid course id</message>"; echo "</xml>"; exit; } if (eF_checkParameter($_GET['login'], 'login') == false) { echo "<xml>"; echo "<status>error</status>"; echo "<message>Invalid login format</message>"; echo "</xml>"; exit; } try { $course = new EfrontCourse($_GET['course']); if ($course->isStudentInCourse($_GET['login']) === false && $course->isProfessorInCourse($_GET['login']) === false) { echo "<xml>"; echo "<status>error</status>"; echo "<message>User not enrolled into course</message>"; echo "</xml>"; exit; } $course->removeUsers($_GET['login']); echo "<xml>"; echo "<status>ok</status>"; echo "</xml>"; } catch (Exception $e) { if ($e->getCode() == EfrontCourseException::COURSE_NOT_EXISTS) { echo "<xml>"; echo "<status>error</status>";
foreach ($lessons as $key => $lesson) { $content = new EfrontContentTree($lesson); if (sizeof($content->tree) > 0) { $contentTree[$key] = $content->toHTML(false, 'dhtml_content_tree_' . $lesson->lesson['id'], array('noclick' => 1)); } $lessonInfo[$key] = new LearningObjectInformation(unserialize($lesson->lesson['info'])); $additionalInfo[$key] = $lesson->getInformation(); } $smarty->assign("T_ADDITIONAL_LESSON_INFO", $additionalInfo); $smarty->assign("T_COURSE_LESSON_INFO", $lessonInfo); $smarty->assign("T_CONTENT_TREE", $contentTree); $smarty->assign("T_LANGUAGES", EfrontSystem::getLanguages(true)); $smarty->assign("T_COURSE_LESSONS", $lessons); $constraints = array('archive' => false, 'active' => true, 'sort' => 'name', 'condition' => 'show_catalog=1'); if ($course->course['instance_source']) { $parentCourse = new EfrontCourse($course->course['instance_source']); $instances = $parentCourse->getInstances($constraints); $instances[$parentCourse->course['id']] = $parentCourse; } else { $instances = $course->getInstances($constraints); $instances[$course->course['id']] = $course; } $smarty->assign("T_COURSE_INSTANCES", $instances); $courseInfo = new LearningObjectInformation(unserialize($course->course['info'])); $smarty->assign("T_COURSE_INFO", $courseInfo); $additionalInfo = $course->getInformation(); $smarty->assign("T_ADDITIONAL_COURSE_INFO", $additionalInfo); } } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
/** * Get the previous lesson in row, or in the course, if specified * * @param EfrontLesson $lesson The lesson to account * @param mixed $course The course to regard, or false * @return int The id of the previous lesson in row * @since 3.6.3 * @access public */ public function getPreviousLesson($lesson, $course = false) { $previousLesson = false; if ($course) { $course instanceof EfrontCourse or $course = new EfrontCourse($course); $eligibility = new ArrayIterator($course->checkRules($_SESSION['s_login'])); while ($eligibility->valid() && ($key = $eligibility->key()) != $lesson->lesson['id']) { $previous = $key; $eligibility->next(); } if (isset($previous) && $previous) { $previousLesson = $previous; } } else { $directionsTree = new EfrontDirectionsTree(); $userLessons = new ArrayIterator($directionsTree->getLessonsList($this->getUserLessons())); while ($userLessons->valid() && ($key = $userLessons->current()) != $lesson->lesson['id']) { $previous = $key; $userLessons->next(); } if (isset($previous) && $previous) { $previousLesson = $previous; } } return $previousLesson; }
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()); }
echo "<status>error</status>"; echo "<message>Incomplete arguments</message>"; echo "</xml>"; } } else { echo "<xml>"; echo "<status>error</status>"; echo "<message>Invalid token</message>"; echo "</xml>"; } break; case 'course_from_user': if (isset($_GET['token']) && checkToken($_GET['token'])) { if (isset($_GET['login']) && isset($_GET['course'])) { try { $course = new EfrontCourse($_GET['course']); $course->removeUsers($_GET['login']); echo "<xml>"; echo "<status>ok</status>"; echo "</xml>"; } catch (Exception $e) { echo "<xml>"; echo "<status>error</status>"; echo "<message>Invalid course/username or user not enrolled into course</message>"; echo "</xml>"; } } else { echo "<xml>"; echo "<status>error</status>"; echo "<message>Incomplete arguments</message>"; echo "</xml>";
/** * Get group courses * * This function returns the list of courses that are part of this group, including unassigned * * @param array $constraints The constraints for the query * @return array An array of EfrontCourse objects or course arrays * @since 3.6.2 * @access public */ public function getGroupCoursesAggregatingResultsIncludingUnassigned($constraints = array()) { !empty($constraints) or $constraints = array('archive' => false, 'active' => true); list($where, $limit, $orderby) = EfrontCourse::convertCourseConstraintsToSqlParameters($constraints); $select = "c.*, (rr.courses_ID is not null OR r.courses_ID is not null) as has_course,\n \t(select count( * ) from courses l where instance_source=c.id)\n \tas has_instances,\n \t(select count( * ) from lessons_to_courses cl, lessons l where cl.courses_ID=c.id and l.archive=0 and l.id=cl.lessons_ID)\n \tas num_lessons,\n \t(select count( * ) from users_to_courses uc, users u where uc.courses_ID=c.id and c.archive=0 and u.active!=0 and u.archive=0 and uc.archive=0 and u.login=uc.users_LOGIN and uc.user_type IN ('" . implode("','", array_keys(EfrontLessonUser::getStudentRoles())) . "'))\n \tas num_students"; if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE $select .= ",(select count( * ) from module_hcd_course_offers_skill s where courses_ID=c.id)\n \t\tas num_skills"; } #cpp#endif //debug(); $result = eF_getTableData("courses c left outer join (select courses_ID from courses_to_groups where groups_ID=" . $this->group['id'] . ") r on c.id=r.courses_ID left outer join (select courses_ID,name,instance_source from courses c, courses_to_groups cg where c.id=cg.courses_ID and cg.groups_ID={$this->group['id']}) rr on rr.instance_source=c.id", $select, implode(" and ", $where), $orderby, $groupby, $limit); //debug(false); return EfrontCourse::convertDatabaseResultToCourseObjects($result); }
$form->addElement('text', 'max_users', _MAXIMUMUSERS, 'class = "inputText" style = "width:50px"'); $form->addElement('text', 'duration', _AVAILABLEFOR, 'style = "width:50px;"'); $form->addRule('duration', _THEFIELD . ' "' . _AVAILABLEFOR . '" ' . _MUSTBENUMERIC, 'numeric', null, 'client'); if (isset($_GET['edit_course'])) { $editCourse = new EfrontCourse($_GET['edit_course']); $smarty->assign('T_EDIT_COURSE', $editCourse); $editCourse->course['price'] = number_format($editCourse->course['price'], 2, '.', ''); $form->setDefaults($editCourse->options); $form->setDefaults($editCourse->course); $form->setDefaults(array($editCourse->options['recurring'] . '_duration' => $editCourse->options['recurring_duration'])); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD if ($editCourse->course['instance_source']) { $instanceSource = new EfrontCourse($editCourse->course['instance_source']); $courseInstances = $instanceSource->getInstances(); //Instances inherit course code and direction from their source $form->setDefaults(array("directions_ID" => $instanceSource->course['directions_ID'])); $form->freeze(array('directions_ID')); $smarty->assign("T_INSTANCE_SOURCE", $editCourse->course['instance_source']); } else { $courseInstances = $editCourse->getInstances(); $smarty->assign("T_INSTANCE_SOURCE", $editCourse->course['id']); } $smarty->assign("T_COURSE_INSTANCES", $courseInstances); } #cpp#endif } #cpp#endif } else {
$smarty->assign("T_ASSIGNED_COURSES_SIZE", sizeof($courses)); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $courses = array_slice($courses, $offset, $limit); } //foreach ($courses as $key => $course) { //$courses[$key]['languages_NAME'] = $languages[$course['languages_NAME']]; //} $smarty->assign("T_ASSIGNED_COURSES_DATA", $courses); $smarty->display('administrator.tpl'); exit; } if (isset($_GET['ajax']) && $_GET['ajax'] == 'coursesTable') { $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); $courses = EfrontCourse::getCourses(); if ($_SESSION['s_type'] == 'administrator') { $editedUser = EfrontUserFactory::factory($_GET['user']); } else { $editedUser = EfrontUserFactory::factory($_SESSION['s_login']); } $userCourses = $editedUser->getUserCourses(); foreach ($courses as $key => $course) { $courses[$key]['partof'] = 0; $courses[$key]['directions_name'] = $directionPaths[$course['directions_ID']]; $courses[$key]['user_type'] = $editedUser->user['user_types_ID'] ? $editedUser->user['user_types_ID'] : $editedUser->user['user_type']; if (in_array($course['id'], array_keys($userCourses))) { $courses[$key]['from_timestamp'] = $userCourses[$key]->course['active_in_course']; $courses[$key]['partof'] = 1; $courses[$key]['user_type'] = $userCourses[$key]->course['user_type']; $courses[$key]['completed'] = $userCourses[$key]->course['completed'];
echo "<status>error</status>"; echo "<message>Invalid lesson id</message>"; echo "</xml>"; exit; } try { $lessonObject = new EfrontLesson($_GET['lesson']); } catch (Exception $e) { echo "<xml>"; echo "<status>error</status>"; echo "<message>Lesson doesn't exist</message>"; echo "</xml>"; exit; } try { $courseObject = new EfrontCourse($_GET['course']); } catch (Exception $e) { echo "<xml>"; echo "<status>error</status>"; echo "<message>Course doesn't exist</message>"; echo "</xml>"; exit; } if ($courseObject->isCourseLesson($_GET['lesson'])) { $courseObject->removeLessons($_GET['lesson']); echo "<xml>"; echo "<status>ok</status>"; echo "</xml>"; break; } else { echo "<xml>";
} catch (Exception $e) { echo $e->getMessage(); } } else { if (isset($_GET['add_to_new_group'])) { try { $group = EfrontGroup::create(array("name" => $_GET['add_to_new_group'])); $group->addUsers($recipients_array); echo $group->group['id']; } catch (Exception $e) { echo $e->getMessage(); } } else { if (isset($_GET['add_course'])) { try { $course = new EfrontCourse($_GET['add_course']); $course->addUsers($recipients_array); } catch (Exception $e) { header("HTTP/1.0 500"); echo $e->getMessage() . ' (' . $e->getCode() . ')'; } } } } } } exit; } /********************** REPORTS PAGE PRESENTATION - FORM CREATION *********************/ /* Create the link to the search for course user page */ if ($currentUser->getType() == "administrator") {
public function getModule() { $smarty = $this->getSmartyVar(); global $load_editor; $load_editor = true; $current_user = $this->getCurrentUser(); $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType()); $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'"); $form->addElement('hidden', 'recipients', $_GET['rec']); $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"'); $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"'); $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"'); $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"'); $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"'); if ($form->isSubmitted() && $form->validate()) { $values = $form->exportValues(); switch ($values['recipients']) { case "lesson_students": $lesson = new EfrontLesson($_SESSION['s_lessons_ID']); $lessonUsers = $lesson->getUsers("student"); foreach ($lessonUsers as $value) { $mail_recipients[] = $value['login']; } //pr($mail_recipients);return; break; case "lesson_professors": $lesson = new EfrontLesson($_SESSION['s_lessons_ID']); $lessonUsers = $lesson->getUsers("professor"); if (isset($_SESSION['s_courses_ID'])) { $course = new EfrontCourse($_SESSION['s_courses_ID']); $course_users = $course->getCourseUsers(); foreach ($lessonUsers as $key => $value) { if (!isset($course_users[$key])) { unset($lessonUsers[$key]); } } } foreach ($lessonUsers as $value) { $mail_recipients[] = $value['login']; } break; case "admin": $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0"); //not foreach ($result as $value) { $mail_recipients[] = $value['login']; } break; } //$list = implode(",",$mail_recipients); $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']); if ($_FILES['attachment']['name'][0] != "") { $maxFileSize = FileSystemTree::getUploadMaxSize(); if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) { // G_MAXFILESIZE is deprecated $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes"; $message_type = 'failure'; } //Upload user avatar file $pm->sender_attachment_timestamp = time(); $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/'; mkdir($user_dir, 0755); $filesystem = new FileSystemTree($user_dir); $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0); $pm->sender_attachment_fileId = $uploadedFile['id']; $pm->setAttachment($uploadedFile['path']); } if ($pm->send($values['email'], $values)) { $message = _MESSAGEWASSENT; $message_type = 'success'; } else { $message = $pm->errorMessage; $message_type = 'failure'; } } $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty); //Create a smarty renderer $renderer->setRequiredTemplate('{$html}{if $required} <span class = "formRequired">*</span> {/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_MODULE_MAIL_FORM', $renderer->toArray()); $smarty->assign("T_MESSAGE_MAIL", $message); $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type); //pr($renderer -> toArray()); return true; }
$userProgress['completed'] = 1; $userProgress['score'] = $avgScore; $userProgress['comments'] = $timestamp; } else { if ($currentLesson->options['show_percentage']) { $headerOptions[] = array('text' => _YOUHAVEMETCONDITIONS, 'image' => '32x32/semi_success.png', 'href' => basename($_SERVER['PHP_SELF']) . '?ctg=lesson_information&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _LESSONINFORMATION . "', 2)", 'target' => 'POPUP_FRAME'); } } } //Separate if because it might have just been set completed, from the previous if if ($userProgress['completed']) { $smarty->assign("T_LESSON_COMPLETED", $userProgress['completed']); $headerOptions[] = array('text' => _LESSONCOMPLETE, 'image' => '32x32/success.png', 'href' => basename($_SERVER['PHP_SELF']) . '?ctg=progress&popup=1', 'onclick' => "eF_js_showDivPopup(event, '" . _LESSONINFORMATION . "', 2)", 'target' => 'POPUP_FRAME'); } if ($currentLesson->lesson['course_only'] && isset($_SESSION['s_courses_ID'])) { $current_course = new EfrontCourse($_SESSION['s_courses_ID']); $check_completed_course = eF_getTableData("users_to_courses", "completed,from_timestamp as active_in_course", "users_LOGIN='******'s_login'] . "' and courses_ID=" . $_SESSION['s_courses_ID']); if ($current_course->course['start_date'] && $current_course->course['start_date'] > time()) { $current_course->course['remaining'] = null; } elseif ($current_course->course['end_date'] && $current_course->course['end_date'] < time()) { $current_course->course['remaining'] = 0; } else { if ($current_course->options['duration'] && $check_completed_course[0]['active_in_course']) { if ($check_completed_course[0]['active_in_course'] < $current_course->course['start_date']) { $check_completed_course[0]['active_in_course'] = $current_course->course['start_date']; } $current_course->course['remaining'] = $check_completed_course[0]['active_in_course'] + $current_course->options['duration'] * 3600 * 24 - time(); if ($current_course->course['end_date'] && $current_course->course['end_date'] < $check_completed_course[0]['active_in_course'] + $current_course->options['duration'] * 3600 * 24) { $current_course->course['remaining'] = $current_course->course['end_date'] - time(); } } else {
} $lesson->lesson['directions_ID'] = $_GET['directions_ID']; $lesson->persist(); if (isset($updateLessonInstancesCategory) && $updateLessonInstancesCategory) { eF_updateTableData("lessons", array("directions_ID" => $lesson->lesson['directions_ID']), "instance_source=" . $lesson->lesson['id']); } } exit; } catch (Exception $e) { echo $e->getMessage() . ' (' . $e->getCode() . ')'; } } if (isset($_GET['coursesPostAjaxRequest'])) { try { 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() . ')'; } }
if (isset($_GET['filter'])) { $courses = eF_filterData($courses, $_GET['filter']); } $smarty->assign("T_ASSIGNED_COURSES_SIZE", sizeof($courses)); if (isset($_GET['limit']) && eF_checkParameter($_GET['limit'], 'int')) { isset($_GET['offset']) && eF_checkParameter($_GET['offset'], 'int') ? $offset = $_GET['offset'] : ($offset = 0); $courses = array_slice($courses, $offset, $limit); } //foreach ($courses as $key => $course) { //$courses[$key]['languages_NAME'] = $languages[$course['languages_NAME']]; //} foreach ($courses as $key => $course) { if (!$course['partof']) { unset($courses[$key]); } else { $obj = new EfrontCourse($course['id']); $courses[$key]['link'] = $obj->toHTMLTooltipLink(basename($_SERVER['PHP_SELF']) . '?ctg=courses&edit_course=' . $course['id']); } } $smarty->assign("T_ASSIGNED_COURSES_DATA", $courses); //pr($courses); //pr($courses); $smarty->display('administrator.tpl'); exit; } if (isset($_GET['ajax']) && $_GET['ajax'] == 'coursesTable') { $directionsTree = new EfrontDirectionsTree(); $directionPaths = $directionsTree->toPathString(); $courses = EfrontCourse::getCourses(); $editedUser = EfrontUserFactory::factory($_GET['user']); $userCourses = $editedUser->getUserCourses();
} $smarty->assign("T_REFRESH_SIDE", "true"); } else { if ($_GET['new_lessons_ID'] == $_SESSION['s_lessons_ID']) { $smarty->assign("T_SHOW_LOADED_LESSON_OPTIONS", 1); } } } /*This is the first time the professor enters this lesson, so register the lesson id to the session*/ if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) { if (!isset($_SESSION['s_lessons_ID']) || $_GET['lessons_ID'] != $_SESSION['s_lessons_ID'] || isset($_GET['from_course']) && $_GET['from_course'] != $_SESSION['s_courses_ID']) { if (isset($_GET['course']) || isset($_GET['from_course'])) { if ($_GET['course']) { $course = new EfrontCourse($_GET['course']); } else { $course = new EfrontCourse($_GET['from_course']); } $eligibility = $course->checkRules($_SESSION['s_login']); if ($eligibility[$_GET['lessons_ID']] == 0) { unset($_GET['lessons_ID']); $message = _YOUCANNOTACCESSTHISLESSONBECAUSEOFCOURSERULES; eF_redirect("student.php?ctg=lessons&message=" . urlencode($message) . "&message_type=failure"); } $_SESSION['s_courses_ID'] = $course->course['id']; } else { unset($_SESSION['s_courses_ID']); } if (in_array($_GET['lessons_ID'], array_keys($userLessons))) { $newLesson = new EfrontLesson($_GET['lessons_ID']); if (!isset($_GET['course']) && !isset($_GET['from_course']) && $roles[$userLessons[$_GET['lessons_ID']]] == 'student' && ($newLesson->lesson['from_timestamp'] && $newLesson->lesson['from_timestamp'] > time() || $newLesson->lesson['to_timestamp'] && $newLesson->lesson['to_timestamp'] < time())) { eF_redirect("student.php?ctg=lessons&message=" . urlencode(_YOUCANNOTACCESSTHISLESSONORITDOESNOTEXIST));
} if (isset($_GET['ajax']) && ($_GET['ajax'] == 'coursesTable' || $_GET['ajax'] == 'instancesTable')) { $_GET['sort'] != 'null' or $_GET['sort'] = 'has_course'; if ($_GET['ajax'] == 'coursesTable') { $constraints = array('archive' => false, 'instance' => false) + createConstraintsFromSortedTable(); } if ($_GET['ajax'] == 'instancesTable' && eF_checkParameter($_GET['instancesTable_source'], 'id')) { $constraints = array('archive' => false, 'instance' => $_GET['instancesTable_source']) + createConstraintsFromSortedTable(); } if ($_GET['ajax'] == 'coursesTable') { $courses = $currentGroup->getGroupCoursesAggregatingResultsIncludingUnassigned($constraints); } else { $courses = $currentGroup->getGroupCoursesIncludingUnassigned($constraints); } $totalEntries = $currentGroup->countGroupCoursesIncludingUnassigned($constraints); $dataSource = EfrontCourse::convertCourseObjectsToArrays($courses); $smarty->assign("T_DATASOURCE_COLUMNS", array('name', 'num_students', 'num_lessons', 'num_skills', 'has_course')); $smarty->assign("T_TABLE_SIZE", $totalEntries); $alreadySorted = 1; $tableName = $_GET['ajax']; include "sorted_table.php"; } if (isset($_GET['postAjaxRequest'])) { if (isset($_GET['login']) && eF_checkParameter($_GET['login'], 'login')) { $user = EfrontUserFactory::factory($_GET['login']); if ($currentGroup->hasUser($user)) { $currentGroup->removeUsers($user); } else { if ($currentGroup->group['user_types_ID']) { $currentGroup->addUsers($user, $currentGroup->group['user_types_ID']); } else {
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past $path = "../libraries/"; $loadLanguage = false; define("NO_OUTPUT_BUFFERING", true); /** Configuration file.*/ require_once $path . "configuration.php"; if (empty($_SESSION['s_login']) || !eF_checkParameter($_SESSION['s_login'], 'login')) { echo json_encode(array('status' => 0, 'code' => -1)); exit; } try { if ($GLOBALS['configuration']['last_reset_certificate'] + 24 * 60 * 60 < time()) { EfrontCourse::checkCertificateExpire(); EfrontConfiguration::setValue('last_reset_certificate', time()); } $currentTheme = new themes($_SESSION['s_theme']); $newTime = ''; $jsonValues = array(); if ($_SESSION['s_login']) { $entity = getUserTimeTarget($_GET['HTTP_REFERER']); //Update times for this entity if ($_SESSION['s_lesson_user_type'] == 'student' && isset($_POST['user_total_time_in_unit']) && current($entity) == 'unit' && eF_checkParameter(key($entity), 'id')) { $newTime = $_POST['user_total_time_in_unit']; $jsonValues['entity'] = current($entity); $jsonValues['entity_id'] = current($entity); if ($newTime && is_numeric($newTime)) { $result = eF_executeNew("insert into users_to_content (users_LOGIN, content_ID, lessons_ID) values('" . $_SESSION['s_login'] . "', " . key($entity) . ", " . $_SESSION['s_lessons_ID'] . ") on duplicate key update total_time={$newTime}"); $jsonValues['time_in_unit'] = EfrontTimes::formatTimeForReporting($newTime);
public function getUserCourseStatus($course, $user, $options, $courseLessons = false) { if (!$user instanceof EfrontUser) { $user = EfrontUserFactory::factory($user); $user = $user->user; } if (!$course instanceof EfrontCourse) { $course = new EfrontCourse($course); } $roles = EfrontLessonUser::getLessonsRoles(); foreach ($roles as $key => $value) { $value == 'student' ? $studentLessonRoles[] = $key : null; } if ($courseLessons == false) { $courseLessons = $course->getCourseLessons(); } $lessonsStatus = self::getUsersLessonStatus($courseLessons, $user['login'], $options); $result = eF_getTableData("users_to_courses", "*", "courses_ID = " . $course->course['id'] . " and users_LOGIN='******'login'] . "'"); if (sizeof($result) > 0) { if ($course->course['duration'] && $result[0]['from_timestamp']) { $result[0]['remaining'] = $result[0]['from_timestamp'] + $course->course['duration'] * 3600 * 24 - time(); } else { $result[0]['remaining'] = null; } //Check whether the course registration is expired. If so, set $result[0]['from_timestamp'] to false, so that the effect is to appear disabled if ($course->course['duration'] && $result[0]['from_timestamp'] && $course->course['duration'] * 3600 * 24 + $result[0]['from_timestamp'] < time()) { $course->removeUsers($result[0]['users_LOGIN']); } else { $usersCourses[$result[0]['courses_ID']][$result[0]['users_LOGIN']] = $result[0]; $usersCoursesTypes[$result[0]['courses_ID']][$result[0]['users_LOGIN']] = $roles[$result[0]['user_type']]; //Handy since we need to know whether a course has any students } } $courseStatus = array(); //transpose and filter s statistics array, for convenience, from lesson id => login to login => lesson id foreach ($lessonsStatus as $lessonId => $info) { if (in_array($lessonId, array_keys($courseLessons))) { foreach ($info as $login => $stats) { $userLessonStatus[$lessonId] = $stats; } } } if (sizeof($usersCourses[$course->course['id']]) > 0) { foreach ($usersCourses[$course->course['id']] as $login => $value) { $courseStatus = array('login' => $login, 'name' => $user['name'], 'surname' => $user['surname'], 'basic_user_type' => $user['user_type'], 'user_type' => $value['user_type'], 'user_types_ID' => $user['user_types_ID'], 'different_role' => !$users[$login]['user_types_ID'] && $value['user_type'] != $users[$login]['user_type'] || $users[$login]['user_types_ID'] && $value['user_type'] != $users[$login]['user_types_ID'], 'active' => $user['active'], 'course_name' => $course->course['name'], 'from_timestamp' => $value['from_timestamp'], 'remaining' => $value['remaining']); //Student - specific information if ($roles[$value['user_type']] == 'student') { $courseStatus['completed'] = $value['completed']; $courseStatus['score'] = $value['score']; $courseStatus['completion_date'] = $value['to_timestamp']; $courseStatus['comments'] = $value['comments']; $courseStatus['issued_certificate'] = $value['issued_certificate']; $courseStatus['total_lessons'] = sizeof($courseLessons); //Count completed lessons $completedLessons = 0; if (isset($userLessonStatus)) { foreach ($userLessonStatus as $lesson) { if ($lesson['completed']) { $completedLessons++; } } } $courseStatus['completed_lessons'] = $completedLessons; } //Append the course's lessons information $courseStatus['lesson_status'] = $userLessonStatus; } } return $courseStatus; }
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; }
if (isset($_GET['removeAll']) && $_GET['table'] == "lessonsTable") { //isset($_GET['filter']) ? $lessons = eF_filterData($lessons, $_GET['filter']) : null; eF_deleteTableData("lessons_to_groups", "groups_ID=" . $_GET['edit_user_group']); echo "All lessons where deleted from group"; } else { if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) { if ($_GET['insert'] == 1) { $currentGroup->addCourse($_GET['courses_ID']); } else { $currentGroup->removeCourses($_GET['courses_ID']); } } else { if (isset($_GET['addAll']) && $_GET['table'] == "coursesTable") { $constraints = array('archive' => false, 'instance' => false) + createConstraintsFromSortedTable(); $courses = $currentGroup->getGroupCoursesAggregatingResultsIncludingUnassigned($constraints); $courses = EfrontCourse::convertCourseObjectsToArrays($courses); isset($_GET['filter']) ? $courses = eF_filterData($courses, $_GET['filter']) : null; foreach ($courses as $course) { if (!$course['in_group']) { $currentGroup->addCourse($course['id'], 'student'); echo "Added course " . $course['id'] . " to group"; } } } else { if (isset($_GET['removeAll']) && $_GET['table'] == "coursesTable") { //isset($_GET['filter']) ? $lessons = eF_filterData($lessons, $_GET['filter']) : null; eF_deleteTableData("courses_to_groups", "groups_ID=" . $_GET['edit_user_group']); echo "All lessons where deleted from group"; } else { if (isset($_GET['assign_to_all_users']) && $_GET['assign_to_all_users'] == "courses") { $groupUsers = $currentGroup->getGroupUsers();
/** * 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; }
function askInformation() { try { if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) { $lesson = new EfrontLesson($_GET['lessons_ID']); $lessonInformation = $lesson->getInformation(); $languages = EfrontSystem::getLanguages(true); //$lessonInformation['language'] = $languages[$lesson -> lesson['languages_NAME']]; if ($lessonInformation['professors']) { foreach ($lessonInformation['professors'] as $value) { $professorsString[] = $value['name'] . ' ' . $value['surname']; } $lessonInformation['professors'] = implode(", ", $professorsString); } $lesson->lesson['price'] ? $priceString = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true) : ($priceString = false); $lessonInformation['price_string'] = $priceString; // if (!$lessonInformation['price']) { // unset($lessonInformation['price_string']); // } try { if ($_GET['from_course']) { $course = new EfrontCourse($_GET['from_course']); $schedule = $course->getLessonScheduleInCourse($lesson); if ($schedule['start_date'] || $schedule['end_date']) { $lessonInformation['from_timestamp'] = $schedule['start_date']; $lessonInformation['to_timestamp'] = $schedule['end_date']; } else { $lessonInformation['from_timestamp'] = $schedule['active_in_lesson'] + 24 * 60 * 60 * $schedule['start_period']; $lessonInformation['to_timestamp'] = $lessonInformation['from_timestamp'] + 24 * 60 * 60 * $schedule['end_period']; } } } catch (Exception $e) { } foreach ($lessonInformation as $key => $value) { if ($value) { switch ($key) { case 'language': $GLOBALS['configuration']['onelanguage'] or $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>"; break; case 'professors': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>"; break; case 'content': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _CONTENTUNITS . "</span><span>: {$value}</span></div>"; break; case 'tests': EfrontUser::isOptionVisible('tests') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _TESTS . "</span><span>: {$value}</span></div>" : null; break; case 'projects': EfrontUser::isOptionVisible('projects') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROJECTS . "</span><span>: {$value}</span></div>" : null; break; case 'course_dependency': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DEPENDSON . "</span><span>: {$value}</span></div>"; break; case 'from_timestamp': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEFROM . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>"; break; case 'to_timestamp': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEUNTIL . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>"; break; case 'general_description': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>"; break; case 'assessment': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>"; break; case 'objectives': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>"; break; case 'lesson_topics': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONTOPICS . "</span><span>: {$value}</span></div>"; break; case 'resources': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>"; break; case 'other_info': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>"; break; case 'price_string': !$lesson->lesson['course_only'] ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>" : null; break; default: break; } } } if ($string = implode("", $tooltipInfo)) { echo $string; } else { echo _NODATAFOUND; } } if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) { $course = new EfrontCourse($_GET['courses_ID']); $courseInformation = $course->getInformation(); $languages = EfrontSystem::getLanguages(true); if ($courseInformation['professors']) { foreach ($courseInformation['professors'] as $value) { $professorsString[] = $value['name'] . ' ' . $value['surname']; } $courseInformation['professors'] = implode(", ", $professorsString); } $course->course['price'] ? $priceString = formatPrice($course->course['price'], array($course->options['recurring'], $course->options['recurring_duration']), true) : ($priceString = false); $courseInformation['price_string'] = $priceString; foreach ($courseInformation as $key => $value) { if ($value) { switch ($key) { case 'language': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>"; break; case 'professors': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>"; break; case 'lessons_number': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONS . "</span><span>: {$value}</span></div>"; break; case 'instances': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSEINSTANCES . "</span><span>: {$value}</span></div>"; break; case 'general_description': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>"; break; case 'assessment': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>"; break; case 'objectives': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>"; break; case 'lesson_topics': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSETOPICS . "</span><span>: {$value}</span></div>"; break; case 'resources': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>"; break; case 'other_info': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>"; break; case 'price_string': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>"; break; default: break; } } } if ($string = implode("", $tooltipInfo)) { echo $string; } else { echo _NODATAFOUND; } } // For eFront social if (isset($_GET['common_lessons']) && isset($_GET['user1']) && isset($_GET['user2'])) { $user1 = EfrontUserFactory::factory($_GET['user1']); if ($user1->getType() != "administrator") { $common_lessons = $user1->getCommonLessons($_GET['user2']); // pr($common_lessons); foreach ($common_lessons as $id => $lesson) { if (strlen($lesson['name']) > 25) { $lesson['name'] = substr($lesson['name'], 0, 22) . "..."; } $tooltipInfo[] = '<div class = "infoEntry"><span>' . $lesson['name'] . "</span><span></span></div>"; } if ($string = implode("", $tooltipInfo)) { echo $string; } else { echo _NODATAFOUND; } } else { echo _NODATAFOUND; } } } catch (Exception $e) { handleAjaxExceptions($e); } }
protected function getCourseByName($courses_name) { if (!$courseNamesToIds) { $courses = EfrontCourse::getCourses(); foreach ($courses as $course) { if (!isset($courseNamesToIds[$course['name']])) { $courseNamesToIds[$course['name']] = array($course['id']); } else { $courseNamesToIds[$course['name']][] = $course['id']; } } } return $courseNamesToIds[$courses_name]; }
} } if ($string = implode("", $tooltipInfo)) { echo '<html ' . ($GLOBALS['rtl'] ? 'dir = "rtl"' : '') . ' >' . $string . '</html>'; } else { echo _NODATAFOUND; } } if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id') && $_GET['type'] == 'branches') { $result = eF_getTableDataFlat("module_hcd_course_to_branch mb, module_hcd_branch b", "mb.branches_ID, b.name", "b.branch_ID=mb.branches_ID and mb.courses_ID=" . $_GET['courses_ID']); $tooltipInfo = '<div class = "infoEntry"><span>' . implode(", ", $result['name']) . "</span><span></span></div>"; echo $tooltipInfo; exit; } if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) { $course = new EfrontCourse($_GET['courses_ID']); $courseInformation = $course->getInformation(); if ($courseInformation['professors']) { foreach ($courseInformation['professors'] as $value) { $professorsString[] = formatLogin($value['login']); } $courseInformation['professors'] = implode(", ", $professorsString); } $course->course['price'] ? $priceString = formatPrice($course->course['price'], array($course->options['recurring'], $course->options['recurring_duration']), true) : ($priceString = false); $courseInformation['price_string'] = $priceString; if ($course->course['max_users']) { $courseInformation['max_users'] = $course->course['max_users']; $courseInformation['seats_remaining'] = $courseInformation['max_users'] - sizeof($course->getStudentUsers()); $courseInformation['seats_remaining'] >= 0 or $courseInformation['seats_remaining'] = 0; } foreach ($courseInformation as $key => $value) {
/** * Check if a course must be reset because of certificate expiry or 'before expiry' reset * * @param mixed lesson A lesson id or an EfrontLesson object * @since 3.6.3 * @access public */ public static function checkCertificateExpire() { $courses = eF_getTableData("courses", "id,reset_interval,reset", "certificate_expiration !=0"); $notifications = eF_getTableData("event_notifications", "id,event_type,after_time,send_conditions", "event_type=-56 and active=1"); $notifications_on_event = eF_getTableData("event_notifications", "id,event_type,after_time,send_conditions", "event_type=56 and active=1"); foreach ($courses as $value) { $course = new EfrontCourse($value['id']); $constraints = array('archive' => false, 'active' => true, 'condition' => 'issued_certificate != ""'); $users = $course->getStudentUsers(false, $constraints); foreach ($users as $user) { $login = $user['login']; $dateTable = unserialize($user['issued_certificate']); if (eF_checkParameter($dateTable['date'], 'timestamp')) { //new way that issued date saves $expirationArray = convertTimeToDays($course->course['certificate_expiration']); $expirationTimestamp = getCertificateExpirationTimestamp($dateTable['date'], $expirationArray); if ($course->course['reset_interval'] != 0) { $resetArray = convertTimeToDays($value['reset_interval']); $resetTimestamp = getCertificateResetTimestamp($expirationTimestamp, $resetArray); if ($resetTimestamp < time()) { $user = EfrontUserFactory::factory($user); $user->resetProgressInCourse($course, true, true); } } if ($course->course['reset']) { //If student completed again the course with reset_interval, he has a new expire date so he will not be reset,(so it is not elseif) if ($expirationTimestamp < time()) { if (!$user instanceof EfrontUser) { $user = EfrontUserFactory::factory($user); } $user->resetProgressInCourse($course, true); foreach ($notifications_on_event as $notification) { $send_conditions = unserialize($notification['send_conditions']); $courses_ID = $send_conditions['courses_ID']; if ($courses_ID == $value['id'] || $courses_ID == 0) { if ($notification['after_time'] == 0) { EfrontEvent::triggerEvent(array("type" => EfrontEvent::COURSE_CERTIFICATE_EXPIRY, "users_LOGIN" => $user->user['login'], "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name'], 'create_negative' => false)); } } } } } if (!$course->course['reset'] && !$course->course['reset_interval']) { if ($expirationTimestamp < time()) { eF_updateTableData("users_to_courses", array("issued_certificate" => ""), "users_LOGIN='******' and courses_ID = " . $course->course['id']); foreach ($notifications_on_event as $notification) { $send_conditions = unserialize($notification['send_conditions']); $courses_ID = $send_conditions['courses_ID']; if ($courses_ID == $value['id'] || $courses_ID == 0) { if ($notification['after_time'] == 0) { EfrontEvent::triggerEvent(array("type" => EfrontEvent::COURSE_CERTIFICATE_REVOKE, "users_LOGIN" => $login, "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name'], "create_negative" => false)); } } } } } foreach ($notifications as $notification) { $send_conditions = unserialize($notification['send_conditions']); $courses_ID = $send_conditions['courses_ID']; if ($courses_ID == $value['id'] || $courses_ID == 0) { if ($notification['after_time'] < 0) { $resetArray = convertTimeToDays(abs($notification['after_time'])); $resetTimestamp = getCertificateResetTimestamp($expirationTimestamp, $resetArray); // in order notification to be sent one (not every day after $resetTimestamp) if ($GLOBALS['configuration']['last_reset_certificate'] < $resetTimestamp && $resetTimestamp < time() && $expirationTimestamp > time()) { EfrontEvent::triggerEvent(array("type" => -1 * EfrontEvent::COURSE_CERTIFICATE_EXPIRY, "users_LOGIN" => $login, "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name'], "create_negative" => false)); } } } } } } } }
$content = new EfrontContentTree($lesson); if (sizeof($content->tree) > 0) { $contentTree[$key] = $content->toHTML(false, 'dhtml_content_tree_' . $lesson->lesson['id'], array('noclick' => 1)); } $lessonInfo[$key] = new LearningObjectInformation(unserialize($lesson->lesson['info'])); $additionalInfo[$key] = $lesson->getInformation(); $additionalInfo[$key]['start_date'] = $lesson->lesson['start_date']; $additionalInfo[$key]['end_date'] = $lesson->lesson['end_date']; } $smarty->assign("T_ADDITIONAL_LESSON_INFO", $additionalInfo); $smarty->assign("T_COURSE_LESSON_INFO", $lessonInfo); $smarty->assign("T_CONTENT_TREE", $contentTree); $smarty->assign("T_LANGUAGES", EfrontSystem::getLanguages(true)); $smarty->assign("T_COURSE_LESSONS", $lessons); if ($course->course['instance_source']) { $parentCourse = new EfrontCourse($course->course['instance_source']); $instances = $parentCourse->getInstances(); $instances[$parentCourse->course['id']] = $parentCourse; } else { $instances = $course->getInstances(); $instances[$course->course['id']] = $course; } foreach ($instances as $key => $instance) { if (!$instance->course['show_catalog']) { unset($instances[$key]); } } $smarty->assign("T_COURSE_INSTANCES", $instances); $courseInfo = new LearningObjectInformation(unserialize($course->course['info'])); $smarty->assign("T_COURSE_INFO", $courseInfo); $additionalInfo = $course->getInformation();
} } } } } catch (Exception $e) { handleAjaxExceptions($e); } $days_after_enrollment = array(); for ($k = 0; $k <= 360; $k++) { $days_after_enrollment[$k] = $k; if ($k >= 100) { $k += 5; } } $smarty->assign("T_DAYS_AFTER_ENROLLMENT", $days_after_enrollment); $smarty->assign("T_COURSE_LESSONS", EfrontCourse::convertLessonObjectsToArrays($courseLessons)); //pr($courseLessons); } else { if ($_GET['op'] == 'export_course') { if (isset($currentUser->coreAccess['content']) && $currentUser->coreAccess['content'] != 'change') { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); } /* Export part */ $form = new HTML_QuickForm("export_course_form", "post", basename($_SERVER['PHP_SELF']) . '?' . $baseUrl . '&op=export_course', "", null, true); $form->addElement('submit', 'submit_export_course', _EXPORT, 'class = "flatButton"'); try { $currentExportedFile = new EfrontFile($currentUser->user['directory'] . '/temp/' . EfrontFile::encode($currentCourse->course['name']) . '.zip'); $smarty->assign("T_EXPORTED_FILE", $currentExportedFile); } catch (Exception $e) { } if ($form->isSubmitted() && $form->validate()) {
exit; } try { if (!isset($lessons) || !$lessons && !is_array($lessons)) { $lessons = EfrontLesson::getLessons(true); foreach ($lessons as $key => $lesson) { if ($lesson->lesson['archive'] || !$lesson->lesson['active']) { unset($lessons[$key]); } } } if (!isset($courses) || !$courses && !is_array($courses)) { //$courses = EfrontCourse :: getCourses(true); $constraints = array('active' => true, 'archive' => false, 'instance' => false, 'sort' => 'name'); $constraints['required_fields'] = array('has_instances'); $courses = EfrontCourse::getAllCourses($constraints); if ($_SESSION['s_current_branch']) { //filter out courses that don't belong to the current branch url $stats_filters = array(); $branches = array($_SESSION['s_current_branch']); $branchesTree = new EfrontBranchesTree(); $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($branchesTree->getNodeChildren($_SESSION['s_current_branch'])), RecursiveIteratorIterator::SELF_FIRST)); foreach ($iterator as $key => $value) { $branches[] = $key; } $result = eF_getTableDataFlat("module_hcd_course_to_branch", "courses_ID", "branches_ID in (" . implode(",", $branches) . ")"); foreach ($courses as $key => $value) { if (!in_array($key, $result['courses_ID'])) { unset($courses[$key]); } }
$myCoursesOptions[] = array('text' => _SUPERVISORAPPROVAL, 'image' => "32x32/success.png", 'href' => "javascript:void(0)", 'onclick' => "eF_js_showDivPopup(event, '" . _SUPERVISORAPPROVAL . "', 2, 'supervisor_approvals_list')"); $smarty->assign("T_SUPERVISOR_APPROVALS", $pendingCourses); } if (isset($_GET['ajax']) && $_GET['ajax'] == 'approval') { try { $course = new EfrontCourse($_GET['course_id']); $course->confirm($_GET['users_login']); echo json_encode(array('status' => 1)); exit; } catch (Exception $e) { handleAjaxExceptions($e); } } elseif (isset($_GET['ajax']) && $_GET['ajax'] == 'cancel') { try { if (eF_checkParameter($_GET['course_id'], 'id')) { $course = new EfrontCourse($_GET['course_id']); $course->removeUsers($_GET['users_login']); $event = array("type" => EfrontEvent::COURSE_USER_REFUSAL, "users_LOGIN" => $_GET['users_login'], "lessons_ID" => $course->course['id'], "lessons_name" => $course->course['name']); EfrontEvent::triggerEvent($event); echo json_encode(array('status' => 1)); exit; } } catch (Exception $e) { handleAjaxExceptions($e); } } } } #cpp#endif if ($currentUser->coreAccess['dashboard'] != 'hidden') { $myCoursesOptions[] = array('text' => _DASHBOARD, 'image' => "32x32/user.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=personal");
/** * Delete the calendar events related to the specified course * * @param mixed $course A course id or an EfrontCourse object * @since 3.6.7 * @access public * @static */ public static function deleteCourseCalendarEvents($course) { $course = EfrontCourse::convertArgumentToCourseId($course); eF_deleteTableData("calendar", "type = 'course' and foreign_ID=" . $course); }