예제 #1
0
     $result = eF_getTableData("users_to_courses", "*", "users_LOGIN = '******'user'] . "' and courses_ID = '" . $_GET['course'] . "' limit 1");
 } else {
     $result = array();
 }
 if (sizeof($result) == 1 || isset($_GET['preview'])) {
     $course = new EfrontCourse($_GET['course']);
     if (!isset($_GET['preview'])) {
         $certificate_tpl_id = $course->options['certificate_tpl_id'];
         if ($certificate_tpl_id <= 0) {
             $mainTemplate = eF_getTableData("certificate_templates", "id", "certificate_name='" . CERTIFICATES_MAIN_TEMPLATE_NAME . "'");
             // XXX
             $certificate_tpl_id = $mainTemplate[0]['id'];
         }
         $issued_data = unserialize($result[0]['issued_certificate']);
         $templateData = eF_getTableData("certificate_templates", "certificate_xml", "id=" . $certificate_tpl_id);
         foreach (eF_loadAllModules() as $module) {
             $module->onXMLExportCourseCertificate($issued_data, $templateData, $course, $_GET['user']);
         }
         $userName = $issued_data['user_name'];
         $userSurName = $issued_data['user_surname'];
         $courseName = $issued_data['course_name'];
         $courseGrade = $issued_data['grade'];
         $serialNumber = $issued_data['serial_number'];
         if (eF_checkParameter($issued_data['date'], 'timestamp')) {
             $certificateDate = formatTimestamp($issued_data['date']);
         }
         if ($course->course['certificate_expiration'] != 0) {
             $expirationArray = convertTimeToDays($course->course['certificate_expiration']);
             $expire_certificateTimestamp = getCertificateExpirationTimestamp($issued_data['date'], $expirationArray);
             $expireDate = formatTimestamp($expire_certificateTimestamp);
         }
 /**
  * Set seen unit
  *
  * This function is used to set the designated unit as seen or not seen,
  * according to $seen parameter. It also sets current unit to be the seen
  * unit, if we are setting a unit as seen. Otherwise, the current unit is
  * either leaved unchanged, or, if it matches the unset unit, it points
  * to another seen unit.
  * <br/>Example:
  * <code>
  * $user -> setSeenUnit(32, 2, true);						   //Set the unit with id 32 in lesson 2 as seen
  * $user -> setSeenUnit(32, 2, false);						  //Set the unit with id 32 in lesson 2 as not seen
  * </code>
  * From version 3.5.2 and above, this function also sets the lesson as completed, if the conditions are met
  *
  * @param mixed $unit The unit to set status for, can be an id or an EfrontUnit object
  * @param mixed $lesson The lesson that the unit belongs to, can be an id or an EfrontLesson object
  * @param boolean $seen Whether to set the unit as seen or not
  * @return boolean true if the lesson was completed as well
  * @since 3.5.0
  * @access public
  */
 public function setSeenUnit($unit, $lesson, $seen)
 {
     if (isset($this->coreAccess['content']) && $this->coreAccess['content'] != 'change') {
         //If user type is not plain 'student' and is not set to 'change' mode, do nothing
         return true;
     }
     if ($unit instanceof EfrontUnit) {
         //Check validity of $unit
         $unit = $unit['id'];
     } elseif (!eF_checkParameter($unit, 'id')) {
         throw new EfrontContentException(_INVALIDID . ": {$unit}", EfrontContentException::INVALID_ID);
     }
     if ($lesson instanceof EfrontLesson) {
         //Check validity of $lesson
         $lesson = $lesson->lesson['id'];
     } elseif (!eF_checkParameter($lesson, 'id')) {
         throw new EfrontLessonException(_INVALIDID . ": {$lesson}", EfrontLessonException::INVALID_ID);
     }
     $lessons = $this->getLessons();
     if (!in_array($lesson, array_keys($lessons))) {
         //Check if the user is actually registered in this lesson
         throw new EfrontUserException(_USERDOESNOTHAVETHISLESSON . ": " . $lesson, EfrontUserException::USER_NOT_HAVE_LESSON);
     }
     $result = eF_getTableData("users_to_lessons", "done_content, current_unit", "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson);
     sizeof($result) > 0 ? $doneContent = unserialize($result[0]['done_content']) : ($doneContent = array());
     $current_unit = 0;
     if ($seen) {
         $doneContent[$unit] = $unit;
         $current_unit = $unit;
     } else {
         if (isset($doneContent[$unit])) {
             //Because of Fatal error: Cannot unset string offsets error
             unset($doneContent[$unit]);
         }
         if ($unit == $result[0]['current_unit']) {
             sizeof($doneContent) ? $current_unit = end($doneContent) : ($current_unit = 0);
         }
     }
     sizeof($doneContent) ? $doneContent = serialize($doneContent) : ($doneContent = null);
     eF_updateTableData("users_to_lessons", array('done_content' => $doneContent, 'current_unit' => $current_unit), "users_LOGIN='******'login'] . "' and lessons_ID=" . $lesson);
     //		$cacheKey = "user_lesson_status:lesson:".$lesson."user:"******"type" => EfrontEvent::CONTENT_COMPLETION, "users_LOGIN" => $this->user['login'], "lessons_ID" => $lesson, "entity_ID" => $current_unit));
     }
     //Set the lesson as complete, if it can be.
     $completedLesson = false;
     $userProgress = EfrontStats::getUsersLessonStatus($lesson, $this->user['login']);
     $userProgress = $userProgress[$lesson][$this->user['login']];
     //eF_updateTableData("users_to_lessons", array('progress' => $userProgress['overall_progress']), "users_LOGIN='******'login']."' and lessons_ID=".$lesson);
     if ($seen) {
         if ($userProgress['lesson_passed'] && !$userProgress['completed']) {
             $lesson = new EfrontLesson($lesson);
             if ($lesson->options['auto_complete']) {
                 $userProgress['tests_avg_score'] ? $avgScore = $userProgress['tests_avg_score'] : ($avgScore = 100);
                 $timestamp = _AUTOCOMPLETEDAT . ': ' . date("Y/m/d, H:i:s");
                 $this->completeLesson($lesson, $avgScore, $timestamp);
                 $completedLesson = true;
             }
         }
         if (!self::$cached_modules) {
             self::$cached_modules = eF_loadAllModules();
         }
         // Trigger all necessary events. If the function has not been re-defined in the derived module class, nothing will happen
         foreach (self::$cached_modules as $module) {
             $module->onCompleteUnit($unit, $this->user['login']);
         }
     }
     return $completedLesson;
 }
예제 #3
0
파일: index.php 프로젝트: bqq1986/efront
    //cheking a possible issue with search engine robots that overloads server
    if (empty($customBlocks) || in_array($_GET['ctg'], array_keys($customBlocks)) !== true) {
        eF_redirect("HTTP/1.0 404 Not Found");
    }
}
if (isset($_SESSION['s_login']) && $_SESSION['s_login']) {
    //This way, logged in users that stay on index.php are not logged out
    $loadScripts[] = 'sidebar';
}
$smarty->assign("T_MESSAGE", $message);
$smarty->assign("T_MESSAGE_TYPE", $message_type);
if (isset($search_message)) {
    $smarty->assign("T_SEARCH_MESSAGE", $search_message);
}
if (!$smarty->is_cached('index.tpl', $cacheId) || !$GLOBALS['configuration']['smarty_caching']) {
    foreach (eF_loadAllModules(true, true) as $module) {
        $module->onIndexPageLoad();
    }
    $positions = $GLOBALS['currentTheme']->layout['positions'];
    //Main scripts, such as prototype
    $mainScripts = getMainScripts();
    $smarty->assign("T_HEADER_MAIN_SCRIPTS", implode(",", $mainScripts));
    //Operation/file specific scripts
    $loadScripts = array_diff($loadScripts, $mainScripts);
    //Clear out duplicates
    $smarty->assign("T_HEADER_LOAD_SCRIPTS", implode(",", array_unique($loadScripts)));
    //array_unique, so it doesn't send duplicate entries
    if (in_array('news', array_merge($positions['leftList'], $positions['rightList'], $positions['centerList']))) {
        $smarty->assign("T_NEWS", news::getNews(0, true));
    }
    if (G_VERSIONTYPE == 'enterprise') {
예제 #4
0
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#delete()
  */
 public function delete()
 {
     if (!$this->remote) {
         $directory = new EfrontDirectory(G_THEMESPATH . $this->{$this->entity}['path']);
         $directory->delete();
     }
     eF_deleteTableData($this->entity, "id=" . $this->{$this->entity}['id']);
     $modules = eF_loadAllModules();
     foreach ($modules as $key => $module) {
         $module->onDeleteTheme($this->{$this->entity}['id']);
     }
     EfrontCache::getInstance()->deleteCache('themes');
 }
예제 #5
0
         foreach ($result as $avatar) {
             $users_avatars[$avatar['login']] = $avatar['avatar'];
         }
     }
     $myEvents = EfrontEvent::getEvents($all_related_users, true, 1000);
 } else {
     if (isset($_GET['ajax'])) {
         $result = eF_getTableData("users", "login, avatar");
         $users_avatars = array();
         foreach ($result as $avatar) {
             $users_avatars[$avatar['login']] = $avatar['avatar'];
         }
     }
     $myEvents = EfrontEvent::getEventsForAllUsers(true, 1000);
 }
 $allModules = eF_loadAllModules();
 $eventMessages = array();
 foreach ($myEvents as $key => $event) {
     if ($myEvents[$key]->createMessage($allModules)) {
         if (strpos($myEvents[$key]->event['time'], "-") === false) {
             // Added this to prevent events that changed time in the future as project expiration
             $new_event = array("time" => $myEvents[$key]->event['time'], "message" => $myEvents[$key]->event['message']);
             if ($myEvents[$key]->event['editlink']) {
                 $new_event['editlink'] = $myEvents[$key]->event['editlink'];
             }
             if ($myEvents[$key]->event['deletelink']) {
                 $new_event['deletelink'] = $myEvents[$key]->event['deletelink'];
             }
             // Keep that for the avatar searching after the filtering
             $new_event['users_LOGIN'] = $event->event['users_LOGIN'];
             $events[] = $new_event;
예제 #6
0
 private static function notifyModuleListenersForCourseCreation($course)
 {
     //PROTONC
     // Get all modules (NOT only the ones that have to do with the user type)
     $modules = eF_loadAllModules();
     // Trigger all necessary events. If the function has not been re-defined in the derived module class, nothing will happen
     foreach ($modules as $module) {
         $module->onNewCourse($course->course['id']);
     }
 }
 private function getLessonSettings()
 {
     $currentUser = $this->getCurrentUser();
     $lessonSettings['theory'] = array('text' => _THEORY, 'image' => "32x32/theory.png", 'onClick' => 'activate(this, \'theory\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     $lessonSettings['examples'] = array('text' => _EXAMPLES, 'image' => "32x32/examples.png", 'onClick' => 'activate(this, \'examples\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     if (EfrontUser::isOptionVisible('projects')) {
         $lessonSettings['projects'] = array('text' => _PROJECTS, 'image' => "32x32/projects.png", 'onClick' => 'activate(this, \'projects\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     if (EfrontUser::isOptionVisible('tests')) {
         $lessonSettings['tests'] = array('text' => _TESTS, 'image' => "32x32/tests.png", 'onClick' => 'activate(this, \'tests\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (EfrontUser::isOptionVisible('surveys')) {
             $lessonSettings['survey'] = array('text' => _SURVEY, 'image' => "32x32/surveys.png", 'onClick' => 'activate(this, \'survey\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
         }
     }
     #cpp#endif
     if (EfrontUser::isOptionVisible('feedback')) {
         $lessonSettings['feedback'] = array('text' => _FEEDBACK, 'image' => "32x32/feedback.png", 'onClick' => 'activate(this, \'feedback\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     $lessonSettings['rules'] = array('text' => _ACCESSRULES, 'image' => "32x32/rules.png", 'onClick' => 'activate(this, \'rules\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     if (EfrontUser::isOptionVisible('forum')) {
         $lessonSettings['forum'] = array('text' => _FORUM, 'image' => "32x32/forum.png", 'onClick' => 'activate(this, \'forum\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     if (EfrontUser::isOptionVisible('comments')) {
         $lessonSettings['comments'] = array('text' => _COMMENTS, 'image' => "32x32/note.png", 'onClick' => 'activate(this, \'comments\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     if (EfrontUser::isOptionVisible('news')) {
         $lessonSettings['news'] = array('text' => _ANNOUNCEMENTS, 'image' => "32x32/announcements.png", 'onClick' => 'activate(this, \'news\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (EfrontUser::isOptionVisible('lessons_timeline')) {
             $lessonSettings['lessons_timeline'] = array('text' => _LESSONSTIMELINE, 'image' => "32x32/user_timeline.png", 'onClick' => 'activate(this, \'lessons_timeline\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
         }
     }
     #cpp#endif
     $lessonSettings['scorm'] = array('text' => _SCORM, 'image' => "32x32/scorm.png", 'onClick' => 'activate(this, \'scorm\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     $lessonSettings['ims'] = array('text' => _IMS, 'image' => "32x32/autocomplete.png", 'onClick' => 'activate(this, \'ims\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     $lessonSettings['digital_library'] = array('text' => _SHAREDFILES, 'image' => "32x32/file_explorer.png", 'onClick' => 'activate(this, \'digital_library\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     if (EfrontUser::isOptionVisible('calendar')) {
         $lessonSettings['calendar'] = array('text' => _CALENDAR, 'image' => "32x32/calendar.png", 'onClick' => 'activate(this, \'calendar\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     if (EfrontUser::isOptionVisible('glossary')) {
         $lessonSettings['glossary'] = array('text' => _GLOSSARY, 'image' => "32x32/glossary.png", 'onClick' => 'activate(this, \'glossary\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     }
     $lessonSettings['auto_complete'] = array('text' => _AUTOCOMPLETE, 'image' => "32x32/autocomplete.png", 'onClick' => 'activate(this, \'auto_complete\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['content_tree'] = array('text' => _CONTENTTREEFIRSTPAGE, 'image' => "32x32/content_tree.png", 'onClick' => 'activate(this, \'content_tree\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['lesson_info'] = array('text' => _LESSONINFORMATION, 'image' => "32x32/information.png", 'onClick' => 'activate(this, \'lesson_info\')', 'title' => _CLICKTOTOGGLE, 'group' => 2, 'class' => 'inactiveImage');
     if (EfrontUser::isOptionVisible('bookmarks')) {
         $lessonSettings['bookmarking'] = array('text' => _BOOKMARKS, 'image' => "32x32/bookmark.png", 'onClick' => 'activate(this, \'bookmarking\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     }
     $lessonSettings['reports'] = array('text' => _STATISTICS, 'image' => "32x32/reports.png", 'onClick' => 'activate(this, \'reports\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['content_report'] = array('text' => _CONTENTREPORT, 'image' => "32x32/warning.png", 'onClick' => 'activate(this, \'content_report\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['print_content'] = array('text' => _PRINTCONTENT, 'image' => "32x32/printer.png", 'onClick' => 'activate(this, \'print_content\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['start_resume'] = array('text' => _STARTRESUME, 'image' => "32x32/continue.png", 'onClick' => 'activate(this, \'start_resume\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['show_percentage'] = array('text' => _COMPLETIONPERCENTAGEBLOCK, 'image' => "32x32/percent.png", 'onClick' => 'activate(this, \'show_percentage\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['show_content_tools'] = array('text' => _UNITOPTIONSBLOCK, 'image' => "32x32/options.png", 'onClick' => 'activate(this, \'show_content_tools\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['show_right_bar'] = array('text' => _RIGHTBAR, 'image' => "32x32/hide_right.png", 'onClick' => 'activate(this, \'show_right_bar\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['show_left_bar'] = array('text' => _LEFTBAR, 'image' => "32x32/hide_left.png", 'onClick' => 'activate(this, \'show_left_bar\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['show_student_cpanel'] = array('text' => _STUDENTCPANEL, 'image' => "32x32/options.png", 'onClick' => 'activate(this, \'show_student_cpanel\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     $lessonSettings['show_dashboard'] = array('text' => _DASHBOARD, 'image' => "32x32/generic.png", 'onClick' => 'activate(this, \'show_dashboard\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     if ($GLOBALS['currentTheme']->options['sidebar_interface'] == 1 || $GLOBALS['currentTheme']->options['sidebar_interface'] == 2) {
         $lessonSettings['show_horizontal_bar'] = array('text' => _SHOWHORIZONTALBAR, 'image' => "32x32/export.png", 'onClick' => 'activate(this, \'show_horizontal_bar\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
     }
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (G_VERSIONTYPE != 'standard') {
             #cpp#ifndef STANDARD
             $lessonSettings['timers'] = array('text' => _TIMERS, 'image' => "32x32/clock.png", 'onClick' => 'activate(this, \'timers\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => 'inactiveImage');
         }
         #cpp#endif
     }
     #cpp#endif
     foreach (eF_loadAllModules(true) as $module) {
         if ($module->isLessonModule()) {
             // The $setLanguage variable is defined in globals.php
             if (!in_array("administrator", $module->getPermittedRoles())) {
                 $mod_lang_file = $module->getLanguageFile($setLanguage);
                 if (is_file($mod_lang_file)) {
                     require_once $mod_lang_file;
                 }
             }
             // The $setLanguage variable is defined in globals.php
             if (!in_array("administrator", $module->getPermittedRoles())) {
                 $mod_lang_file = $module->getLanguageFile($setLanguage);
                 if (is_file($mod_lang_file)) {
                     require_once $mod_lang_file;
                 }
             }
             $lessonSettings[$module->className] = array('text' => $module->getName(), 'image' => "32x32/addons.png", 'onClick' => 'activate(this, \'' . $module->className . '\')', 'title' => _CLICKTOTOGGLE, 'group' => 3, 'class' => 'inactiveImage');
         }
     }
     $lessonSettings[$key]['onClick'] = 'activate(this, \'' . $key . '\')';
     $lessonSettings[$key]['style'] = 'color:inherit';
     return $lessonSettings;
 }
예제 #8
0
 /**
  * Create lesson instance
  *
  * This function is used to create a lesson instance.
  * <br/>Example:
  * <code>
  * $instance = EfrontLesson :: createInstance(43);
  * </code>
  *
  * @param mixed $instanceSource Either a lesson id or an EfrontLesson object.
  * @return EfrontLesson The new lesson instance
  * @since 3.6.1
  * @access public
  * @static
  */
 public static function createInstance($instanceSource, $originateCourse)
 {
     if (!$instanceSource instanceof EfrontLesson) {
         $instanceSource = new EfrontLesson($instanceSource);
     }
     if (!$originateCourse instanceof EfrontCourse) {
         $originateCourse = new EfrontCourse($originateCourse);
     }
     $result = eF_getTableData("lessons", "*", "id=" . $instanceSource->lesson['id']);
     unset($result[0]['id']);
     //unset($result[0]['directions_ID']);			//Instances don't belong to a category
     if (!$result[0]['share_folder']) {
         $result[0]['share_folder'] = $instanceSource->lesson['id'];
     }
     //$result[0]['name'] .= ' ('._INSTANCE.')';
     $result[0]['originating_course'] = $originateCourse->course['id'];
     $result[0]['instance_source'] = $instanceSource->lesson['id'];
     $file = $instanceSource->export(false, true, false);
     $instance = EfrontLesson::createLesson($result[0]);
     $instance->import($file, true, true, true);
     $instance->course['originating_course'] = $originateCourse->course['id'];
     $instance->course['instance_source'] = $instanceSource->lesson['id'];
     $instance->persist();
     $modules = eF_loadAllModules();
     foreach ($modules as $module) {
         $module->onCreateInstance($instance->lesson['id'], $instanceSource->lesson['id']);
     }
     return $instance;
 }
예제 #9
0
/**
 * Setup themes
 *
 * This function sets up all the required constants and initiates objects
 * accordingly, to initialize the current theme
 *
 * @since 3.6.0
 */
function setupThemes()
{
    /** The default theme path*/
    define("G_DEFAULTTHEMEPATH", G_THEMESPATH . "default/");
    /** The default theme url*/
    define("G_DEFAULTTHEMEURL", "themes/default/");
    try {
        $allThemes = themes::getAll();
        if (isset($_GET['preview_theme'])) {
            try {
                $currentTheme = new themes($_GET['preview_theme']);
            } catch (Exception $e) {
            }
        } elseif (isset($_SESSION['s_theme'])) {
            if (!empty($allThemes[$_SESSION['s_theme']])) {
                $currentTheme = $allThemes[$_SESSION['s_theme']];
            } else {
                $currentTheme = new themes($_SESSION['s_theme']);
            }
        } else {
            if (!empty($allThemes[$GLOBALS['configuration']['theme']])) {
                $currentTheme = $allThemes[$GLOBALS['configuration']['theme']];
            } else {
                $currentTheme = new themes($GLOBALS['configuration']['theme']);
            }
            $browser = detectBrowser();
            foreach ($allThemes as $value) {
                if (isset($value->options['browsers'][$browser])) {
                    try {
                        $browserTheme = $allThemes[$value->themes['id']];
                        $currentTheme = $browserTheme;
                    } catch (Exception $e) {
                    }
                }
            }
            foreach (eF_loadAllModules(true, true) as $module) {
                try {
                    if ($moduleTheme = $module->onSetTheme($currentTheme)) {
                        if (!$moduleTheme instanceof themes) {
                            $currentTheme = new themes($moduleTheme);
                        } else {
                            $currentTheme = $moduleTheme;
                        }
                    }
                } catch (Exception $e) {
                }
            }
            $_SESSION['s_theme'] = $currentTheme->{$currentTheme->entity}['id'];
        }
    } catch (Exception $e) {
        try {
            $result = eF_getTableData("themes", "*", "name = 'default'");
            if (sizeof($result) == 0) {
                throw new Exception();
                //To be caught right below. This way, the catch() code gets executed either if the result is empty or if there is a db error
            }
        } catch (Exception $e) {
            $file = new EfrontFile(G_DEFAULTTHEMEPATH . "theme.xml");
            themes::create(themes::parseFile($file));
        }
        $currentTheme = new themes('default');
    }
    $currentThemeName = $currentTheme->{$currentTheme->entity}['name'];
    /**The current theme*/
    define("G_CURRENTTHEME", $currentThemeName);
    /** The current theme path*/
    define("G_CURRENTTHEMEPATH", !isset($currentTheme->remote) || !$currentTheme->remote ? G_THEMESPATH . $currentTheme->{$currentTheme->entity}['path'] : $currentTheme->{$currentTheme->entity}['path']);
    /** The current theme url*/
    define("G_CURRENTTHEMEURL", !isset($currentTheme->remote) || !$currentTheme->remote ? "themes/" . $currentTheme->themes['path'] : $currentTheme->{$currentTheme->entity}['path']);
    /** The external pages path*/
    define("G_EXTERNALPATH", rtrim(G_CURRENTTHEMEPATH, '/') . "/external/");
    is_dir(G_EXTERNALPATH) or mkdir(G_EXTERNALPATH, 0755);
    /** The external pages link*/
    define("G_EXTERNALURL", rtrim(G_CURRENTTHEMEURL, '/') . "/external/");
    if ($fp = fopen(G_CURRENTTHEMEPATH . "css/css_global.css", 'r')) {
        /** The current theme's css*/
        define("G_CURRENTTHEMECSS", G_CURRENTTHEMEURL . "css/css_global.css?build=" . G_BUILD);
        fclose($fp);
    } else {
        /** The current theme's css*/
        define("G_CURRENTTHEMECSS", G_DEFAULTTHEMEURL . "css/css_global.css?build=" . G_BUILD);
    }
    /** The folder where the template compiled and cached files are kept*/
    define("G_THEMECACHE", G_ROOTPATH . "libraries/smarty/themes_cache/");
    /** The folder of the current theme's compiled files*/
    define("G_CURRENTTHEMECACHE", G_THEMECACHE . $currentThemeName . "/");
    /** The full filesystem path of the images directory*/
    define("G_IMAGESPATH", G_CURRENTTHEMEPATH . "images/");
    /** The full filesystem path of the images directory, in the default theme*/
    define("G_DEFAULTIMAGESPATH", G_DEFAULTTHEMEPATH . "images/");
    /** The users' avatars directory*/
    define("G_AVATARSPATH", G_IMAGESPATH . "avatars/");
    if (is_dir(G_AVATARSPATH . "system_avatars/")) {
        /*system avatars path*/
        define("G_SYSTEMAVATARSPATH", G_AVATARSPATH . "system_avatars/");
        /*system avatars URL*/
        define("G_SYSTEMAVATARSURL", G_CURRENTTHEMEURL . "images/avatars/system_avatars/");
    } else {
        /*system avatars path*/
        define("G_SYSTEMAVATARSPATH", G_DEFAULTTHEMEPATH . "images/avatars/system_avatars/");
        /*system avatars URL*/
        define("G_SYSTEMAVATARSURL", G_DEFAULTTHEMEURL . "images/avatars/system_avatars/");
    }
    /** The logo path*/
    define("G_LOGOPATH", G_DEFAULTIMAGESPATH . "logo/");
    return $currentTheme;
}
예제 #10
0
             $topics = array("0" => _ANYTOPIC);
             foreach ($result as $topic) {
                 $id = $topic['id'];
                 $topics[$id] = $topic['title'];
             }
             $form->addElement('select', 'topic', _SELECTTIMELINETOPIC, $topics, 'class = "inputText"  id="timeline_topic" onchange="javascript:change_topic(\'timeline_topic\')"');
             if (isset($_GET['topics_ID'])) {
                 $form->setDefaults(array('topic' => $_GET['topics_ID']));
                 $smarty->assign("T_TOPIC_TITLE", $topics[$_GET['topics_ID']]);
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             $form->accept($renderer);
             $smarty->assign('T_TIMELINE_FORM', $renderer->toArray());
             $related_events = $currentLesson->getEvents(false, true, 0, 20);
             $timeline_options = array(array('text' => _GOTOLESSONSTIMELINE, 'image' => "16x16/go_into.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=social&op=timeline&lessons_ID=" . $currentLesson->lesson['id'] . "&all=1"));
             $allModules = eF_loadAllModules(true);
             $events = array();
             foreach ($related_events as $key => $event) {
                 if ($related_events[$key]->createMessage($allModules)) {
                     $events[$key] = array("avatar" => $related_events[$key]->event['avatar'], "avatar_width" => $related_events[$key]->event['avatar_width'], "avatar_height" => $related_events[$key]->event['avatar_height'], "time" => $related_events[$key]->event['time'], "message" => $related_events[$key]->event['message']);
                 }
             }
             $smarty->assign("T_TIMELINE_OPTIONS", $timeline_options);
             $smarty->assign("T_TIMELINE_LINK", basename($_SERVER['PHP_SELF']) . "?ctg=social&op=timeline&lessons_ID=" . $currentLesson->lesson['id'] . "&all=1");
             $smarty->assign("T_TIMELINE_EVENTS", $events);
         }
     }
     #cpp#endif
 }
 //Professor specific blocks
 if ($_professor_) {
예제 #11
0
 if ($GLOBALS['currentTheme']->options['sidebar_interface'] == 1 || $GLOBALS['currentTheme']->options['sidebar_interface'] == 2) {
     $lessonSettings['show_horizontal_bar'] = array('text' => _SHOWHORIZONTALBAR, 'image' => "32x32/generic.png", 'onClick' => 'activate(this, \'show_horizontal_bar\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => !isset($currentLesson->options['show_horizontal_bar']) || $currentLesson->options['show_horizontal_bar'] ? null : 'inactiveImage');
 }
 if (G_VERSIONTYPE != 'community') {
     #cpp#ifndef COMMUNITY
     if (G_VERSIONTYPE != 'standard') {
         #cpp#ifndef STANDARD
         $lessonSettings['timers'] = array('text' => _TIMERS, 'image' => "32x32/clock.png", 'onClick' => 'activate(this, \'timers\')', 'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => !isset($currentLesson->options['timers']) || $currentLesson->options['timers'] ? null : 'inactiveImage');
     }
     #cpp#endif
 }
 #cpp#endif
 //$lessonSettings['complete_next_lesson']= array('text' => _MOVETONEXTLESSONONCOMPLETE,'image' => "32x32/options.png", 'onClick' => 'activate(this, \'complete_next_lesson\')',      'title' => _CLICKTOTOGGLE, 'group' => 1, 'class' => isset($currentLesson -> options['complete_next_lesson']) && $currentLesson -> options['complete_next_lesson'] ? null : 'inactiveImage');
 ///MODULES6
 if ($currentUser->getType() == "administrator") {
     $loadedModules = eF_loadAllModules(true);
 }
 foreach ($loadedModules as $module) {
     if ($module->isLessonModule()) {
         // The $setLanguage variable is defined in globals.php
         if (!in_array("administrator", $module->getPermittedRoles())) {
             $mod_lang_file = $module->getLanguageFile($setLanguage);
             if (is_file($mod_lang_file)) {
                 require_once $mod_lang_file;
             }
         }
         // The $setLanguage variable is defined in globals.php
         if (!in_array("administrator", $module->getPermittedRoles())) {
             $mod_lang_file = $module->getLanguageFile($setLanguage);
             if (is_file($mod_lang_file)) {
                 require_once $mod_lang_file;
예제 #12
0
 /**
  * Export lesson
  *
  * This function is used to export the current lesson's data to
  * a file, which can then be imported to other systems. Apart from
  * the lesson content, the user may optinally specify additional
  * information to export, using the $exportEntities array. If
  * $exportEntities is 'all', everything that can be exported, is
  * exported
  *
  * <br/>Example:
  * <code>
  * $exportedFile = $lesson -> export('all');
  * </code>
  *
  * @param array $exportEntities The additional data to export
  * @param boolean $rename Whether to rename the exported file with the same name as the lesson
  * @param boolean $exportFiles Whether to export files as well
  * @return EfrontFile The object of the exported data file
  * @since 3.5.0
  * @access public
  */
 public function export($exportEntities, $rename = true, $exportFiles = true)
 {
     if (!$exportEntities) {
         $exportEntities = array('export_surveys' => 1, 'export_announcements' => 1, 'export_glossary' => 1, 'export_calendar' => 1, 'export_comments' => 1, 'export_rules' => 1);
     }
     $data['lessons'] = $this->lesson;
     unset($data['lessons']['share_folder']);
     unset($data['lessons']['instance_source']);
     unset($data['lessons']['originating_course']);
     $content = eF_getTableData("content", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($content) > 0) {
         $contentIds = array();
         for ($i = 0; $i < sizeof($content); $i++) {
             $content[$i]['data'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $content[$i]['data']);
             $content[$i]['data'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $content[$i]['data']);
             $contentIds[] = $content[$i]['id'];
         }
         $content_list = implode(",", array_values($contentIds));
         $data['content'] = $content;
         $questions = eF_getTableData("questions", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($questions) > 0) {
             for ($i = 0; $i < sizeof($questions); $i++) {
                 $questions[$i]['text'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $questions[$i]['text']);
                 $questions[$i]['text'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $questions[$i]['text']);
             }
             $data['questions'] = $questions;
         }
         $tests = eF_getTableData("tests", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($tests)) {
             $testsIds = array();
             foreach ($tests as $key => $value) {
                 $testsIds[] = $value['id'];
             }
             $tests_list = implode(",", array_values($testsIds));
             $tests_to_questions = eF_getTableData("tests_to_questions", "*", "tests_ID IN ({$tests_list})");
             for ($i = 0; $i < sizeof($tests); $i++) {
                 $tests[$i]['description'] = str_replace(G_SERVERNAME, "##SERVERNAME##", $tests[$i]['description']);
                 $tests[$i]['description'] = str_replace("content/lessons/" . ($this->lesson['share_folder'] ? $this->lesson['share_folder'] : $this->lesson['id']), "##LESSONSLINK##", $tests[$i]['description']);
             }
             $data['tests'] = $tests;
             $data['tests_to_questions'] = $tests_to_questions;
         }
         if (isset($exportEntities['export_rules'])) {
             $rules = eF_getTableData("rules", "*", "lessons_ID=" . $this->lesson['id']);
             if (sizeof($rules) > 0) {
                 $data['rules'] = $rules;
             }
         }
         if (isset($exportEntities['export_comments'])) {
             $comments = eF_getTableData("comments", "*", "content_ID IN ({$content_list})");
             if (sizeof($comments) > 0) {
                 $data['comments'] = $comments;
             }
         }
     }
     if (isset($exportEntities['export_calendar'])) {
         $calendar = calendar::getLessonCalendarEvents($this);
         if (sizeof($calendar) > 0) {
             $data['calendar'] = $calendar;
         }
     }
     if (isset($exportEntities['export_glossary'])) {
         $glossary = eF_getTableData("glossary", "*", "lessons_ID = " . $this->lesson['id']);
         if (sizeof($glossary) > 0) {
             $data['glossary'] = $glossary;
         }
     }
     if (isset($exportEntities['export_announcements'])) {
         $news = eF_getTableData("news", "*", "lessons_ID=" . $this->lesson['id']);
         if (sizeof($news) > 0) {
             $data['news'] = $news;
         }
     }
     if (isset($exportEntities['export_surveys'])) {
         $surveys = eF_getTableData("surveys", "*", "lessons_ID=" . $this->lesson['id']);
         //prepei na ginei to   lesson_ID -> lessons_ID sti basi (ayto isos to parampsoyme eykola)
         if (sizeof($surveys) > 0) {
             $data['surveys'] = $surveys;
             $surveys_ = array();
             foreach ($surveys as $key => $value) {
                 $surveys_[$value['id']] = $value;
             }
             $surveys_list = implode(",", array_keys($surveys_));
             $questions_to_surveys = eF_getTableData("questions_to_surveys", "*", "surveys_ID IN ({$surveys_list})");
             // oposipote omos to survey_ID -> surveys_ID sti basi
             if (sizeof($questions_to_surveys) > 0) {
                 $data['questions_to_surveys'] = $questions_to_surveys;
             }
         }
     }
     $lesson_conditions = eF_getTableData("lesson_conditions", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($lesson_conditions) > 0) {
         $data['lesson_conditions'] = $lesson_conditions;
     }
     $projects = eF_getTableData("projects", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($projects) > 0) {
         $data['projects'] = $projects;
     }
     $lesson_files = eF_getTableData("files", "*", "path like '" . str_replace(G_ROOTPATH, '', EfrontDirectory::normalize($this->getDirectory())) . "%'");
     if (sizeof($lesson_files) > 0) {
         $data['files'] = $lesson_files;
     }
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (G_VERSIONTYPE != 'standard') {
             #cpp#ifndef STANDARD
             //Export scorm tables from here over
             $scormLessonTables = array('scorm_sequencing_adlseq_map_info', 'scorm_sequencing_content_to_organization', 'scorm_sequencing_maps_info', 'scorm_sequencing_organizations');
             foreach ($scormLessonTables as $table) {
                 $scorm_data = eF_getTableData($table, "*", "lessons_ID=" . $this->lesson['id']);
                 if (sizeof($scorm_data) > 0) {
                     $data[$table] = $scorm_data;
                 }
             }
             $scormContentTables = array('scorm_sequencing_completion_threshold', 'scorm_sequencing_constrained_choice', 'scorm_sequencing_control_mode', 'scorm_sequencing_delivery_controls', 'scorm_sequencing_hide_lms_ui', 'scorm_sequencing_limit_conditions', 'scorm_sequencing_maps', 'scorm_sequencing_map_info', 'scorm_sequencing_objectives', 'scorm_sequencing_rollup_considerations', 'scorm_sequencing_rollup_controls', 'scorm_sequencing_rollup_rules', 'scorm_sequencing_rules');
             if ($content_list) {
                 foreach ($scormContentTables as $table) {
                     $scorm_data = eF_getTableData($table, "*", "content_ID IN ({$content_list})");
                     if (sizeof($scorm_data) > 0) {
                         $data[$table] = $scorm_data;
                     }
                     if ($table == 'scorm_sequencing_rollup_rules' && sizeof($scorm_data) > 0) {
                         $ids = array();
                         foreach ($scorm_data as $value) {
                             $ids[] = $value['id'];
                         }
                         $result = eF_getTableData('scorm_sequencing_rollup_rule', "*", "scorm_sequencing_rollup_rules_ID IN (" . implode(",", $ids) . ")");
                         $data['scorm_sequencing_rollup_rule'] = $result;
                     }
                     if ($table == 'scorm_sequencing_rules' && sizeof($scorm_data) > 0) {
                         $ids = array();
                         foreach ($scorm_data as $value) {
                             $ids[] = $value['id'];
                         }
                         $result = eF_getTableData('scorm_sequencing_rule', "*", "scorm_sequencing_rules_ID IN (" . implode(",", $ids) . ")");
                         $data['scorm_sequencing_rule'] = $result;
                     }
                 }
             }
         }
         #cpp#endif
     }
     #cpp#endif
     //'scorm_sequencing_rollup_rule', 'scorm_sequencing_rule',
     // MODULES - Export module data
     // Get all modules (NOT only the ones that have to do with the user type)
     $modules = eF_loadAllModules();
     foreach ($modules as $module) {
         if ($moduleData = $module->onExportLesson($this->lesson['id'])) {
             $data[$module->className] = $moduleData;
         }
     }
     file_put_contents($this->directory . '/' . "data.dat", serialize($data));
     //Create database dump file
     if ($exportFiles) {
         $lessonDirectory = new EfrontDirectory($this->directory);
         $file = $lessonDirectory->compress($this->lesson['id'] . '_exported.zip', false);
         //Compress the lesson files
     } else {
         $dataFile = new EfrontFile($this->directory . '/' . "data.dat");
         $file = $dataFile->compress($this->lesson['id'] . '_exported.zip');
     }
     $newList = FileSystemTree::importFiles($file['path']);
     //Import the file to the database, so we can download it
     $file = new EfrontFile(current($newList));
     $userTempDir = $GLOBALS['currentUser']->user['directory'] . '/temp';
     //The compressed file will be moved to the user's temp directory
     if (!is_dir($userTempDir)) {
         //If the user's temp directory does not exist, create it
         $userTempDir = EfrontDirectory::createDirectory($userTempDir, false);
         $userTempDir = $userTempDir['path'];
     }
     try {
         $existingFile = new EfrontFile($userTempDir . '/' . EfrontFile::encode($this->lesson['name']) . '.zip');
         //Delete any previous exported files
         $existingFile->delete();
     } catch (Exception $e) {
     }
     if ($rename) {
         $newName = str_replace(array('"', '>', '<', '*', '?', ':'), array('&quot;', '&gt;', '&lt;', '&#42;', '&#63;', '&#58;'), $this->lesson['name']);
         $file->rename($userTempDir . '/' . EfrontFile::encode($newName) . '.zip', true);
     }
     unlink($this->directory . '/' . "data.dat");
     //Delete database dump file
     return $file;
 }
예제 #13
0
파일: tools.php 프로젝트: bqq1986/efront
function loginRedirect($user_type, $message = '', $message_type = '')
{
    foreach (eF_loadAllModules(true, true) as $module) {
        $module->onUserLogin($user_type, $message, $message_type);
    }
    $redirectPage = $GLOBALS['configuration']['login_redirect_page'];
    if ($redirectPage == "user_dashboard" && $user_type != "administrator") {
        $location = "userpage.php?ctg=personal" . ($message ? "&message={$message}&message_type={$message_type}" : '');
    } elseif (strpos($redirectPage, "module") !== false) {
        $location = "userpage.php?ctg=landing_page" . ($message ? "&message={$message}&message_type={$message_type}" : '');
    } else {
        $location = "userpage.php" . ($message ? "?message={$message}&message_type={$message_type}" : '');
    }
    eF_redirect($location);
}