/**
  * Get user information
  *
  * This function returns the user information in an array
  *
  *
  * <br/>Example:
  * <code>
  * $info = $user -> getInformation();		 //Get lesson information
  * </code>
  *
  * @param string $user The user login to customize lesson information for
  * @return array The user information
  * @since 3.5.0
  * @access public
  */
 public function getInformation()
 {
     $languages = EfrontSystem::getLanguages(true);
     $info = array();
     $info['login'] = $this->user['login'];
     $info['name'] = $this->user['name'];
     $info['surname'] = $this->user['surname'];
     $info['fullname'] = $this->user['name'] . " " . $this->user['surname'];
     $info['user_type'] = $this->user['user_type'];
     $info['user_types_ID'] = $this->user['user_types_ID'];
     $info['student_lessons'] = $this->getLessons(true, 'student');
     $info['professor_lessons'] = $this->getLessons(true, 'professor');
     $info['total_lessons'] = sizeof($this->getUserLessons());
     $info['total_courses'] = sizeof($this->getUserCourses(array('active' => true, 'return_objects' => false)));
     $info['total_login_time'] = self::getLoginTime($this->user['login']);
     $info['language'] = $languages[$this->user['languages_NAME']];
     $info['active'] = $this->user['active'];
     $info['active_str'] = $this->user['active'] ? _YES : _NO;
     $info['joined'] = $this->user['timestamp'];
     $info['joined_str'] = formatTimestamp($this->user['timestamp'], 'time');
     $info['avatar'] = $this->user['avatar'];
     return $info;
 }
 /**
  * Create course metadata
  *
  * @param array $fields Course properties
  * @return string Serialized representation of metadata array
  * @since 3.6.1
  * @access private
  */
 private static function createCourseMetadata($fields)
 {
     $languages = EfrontSystem::getLanguages(true);
     $courseMetadata = array('title' => $fields['name'], 'creator' => formatLogin($GLOBALS['currentUser']->user['login']), 'publisher' => formatLogin($GLOBALS['currentUser']->user['login']), 'contributor' => formatLogin($GLOBALS['currentUser']->user['login']), 'date' => date("Y/m/d", time()), 'language' => $languages[$fields['languages_NAME']], 'type' => 'course');
     $metadata = serialize($courseMetadata);
     return $metadata;
 }
Beispiel #3
0
     }
 }
 #cpp#endif
 $lessons = $course->getCourseLessons();
 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);
Beispiel #4
0
 protected function importDataMultiple($type, $data)
 {
     try {
         switch ($type) {
             case "users_to_groups":
                 foreach ($data as $value) {
                     $groups_ID = current($this->getGroupByName($value['groups.name']));
                     $groups[$groups_ID][] = $value['users_login'];
                 }
                 foreach ($groups as $id => $groupUsers) {
                     try {
                         $group = new EfrontGroup($id);
                         $this->log["success"][] = _NEWGROUPASSIGNMENT . " " . $group->group['name'];
                         $group->addUsers($groupUsers);
                     } catch (Exception $e) {
                         $this->log["failure"][] = _LINE . " " . ($key + 2) . ": " . $e->getMessage();
                         // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
                     }
                 }
                 break;
             case "users":
                 $existingUsers = eF_getTableDataFlat("users", "login, active, archive");
                 $roles = EfrontUser::getRoles();
                 foreach (EfrontUser::getRoles(true) as $key => $value) {
                     $rolesTypes[$key] = mb_strtolower($value);
                 }
                 $languages = EfrontSystem::getLanguages();
                 $addedUsers = array();
                 foreach ($data as $key => $value) {
                     try {
                         $newUser = EfrontUser::createUser($value, $existingUsers, false);
                         $existingUsers['login'][] = $newUser->user['login'];
                         $existingUsers['active'][] = $newUser->user['active'];
                         $existingUsers['archive'][] = $newUser->user['archive'];
                         $addedUsers[] = $newUser->user['login'];
                         $this->log["success"][] = _IMPORTEDUSER . " " . $newUser->user['login'];
                     } catch (Exception $e) {
                         if ($this->options['replace_existing']) {
                             if ($this->isAlreadyExistsException($e->getCode(), $type)) {
                                 if (!in_array($value['login'], $existingUsers['login'], true)) {
                                     //For case-insensitive matches
                                     foreach ($existingUsers['login'] as $login) {
                                         if (mb_strtolower($value['login']) == mb_strtolower($login)) {
                                             $value['login'] = $login;
                                         }
                                     }
                                 }
                                 if (!isset($value['user_type'])) {
                                     $value['user_type'] = 'student';
                                 } else {
                                     if (in_array(mb_strtolower($value['user_type']), $roles)) {
                                         $value['user_type'] = mb_strtolower($value['user_type']);
                                     } else {
                                         if ($k = array_search(mb_strtolower($value['user_type']), $rolesTypes)) {
                                             $value['user_types_ID'] = $k;
                                             $value['user_type'] = $roles[$k];
                                         } else {
                                             $value['user_type'] = 'student';
                                         }
                                     }
                                 }
                                 if (!in_array($value['user_type'], EFrontUser::$basicUserTypes)) {
                                     $value['user_type'] = 'student';
                                     $value['user_types_ID'] = 0;
                                 }
                                 if ($value['languages_NAME'] == "") {
                                     unset($value['languages_NAME']);
                                 } elseif (in_array($value['languages_NAME'], array_keys($languages)) === false) {
                                     $value['languages_NAME'] = $GLOBALS['configuration']['default_language'];
                                 }
                                 $this->updateExistingData($key + 2, $type, $value);
                             } else {
                                 $this->log["failure"][] = _LINE . " " . ($key + 2) . ": " . $e->getMessage();
                                 // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
                             }
                         } else {
                             $this->log["failure"][] = _LINE . " " . ($key + 2) . ": " . $e->getMessage();
                             // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
                         }
                     }
                 }
                 $defaultGroup = eF_getTableData("groups", "id", "is_default = 1 AND active = 1");
                 if (!empty($defaultGroup) && !empty($addedUsers)) {
                     $defaultGroup = new EfrontGroup($defaultGroup[0]['id']);
                     $defaultGroup->addUsers($addedUsers);
                 }
                 break;
             case "users_to_jobs":
                 $jobDescriptions = $userJobs = $userBranchesAssigned = $userBranchesUnassigned = array();
                 $result = eF_getTableData("module_hcd_job_description", "job_description_ID, branch_ID, description");
                 foreach ($result as $value) {
                     $jobDescriptions[$value['job_description_ID']] = $value;
                 }
                 $result = eF_getTableData("module_hcd_employee_has_job_description", "*");
                 foreach ($result as $value) {
                     $userJobs[$value['users_login']][$value['job_description_ID']] = $value['job_description_ID'];
                 }
                 $result = eF_getTableData("module_hcd_employee_works_at_branch", "*");
                 foreach ($result as $value) {
                     if ($value['assigned']) {
                         $userBranchesAssigned[$value['users_login']][$value['branch_ID']] = $value;
                     } else {
                         $userBranchesUnassigned[$value['users_login']][$value['branch_ID']] = $value;
                     }
                 }
                 $allBranches = eF_getTableData("module_hcd_branch", "branch_ID, father_branch_ID", "");
                 $addedJobs = $addedBranches = array();
                 foreach ($data as $key => $value) {
                     try {
                         if (!$value['description']) {
                             throw new EfrontJobException(_MISSING_JOB_DESCRIPTION, EfrontJobException::MISSING_JOB_DESCRIPTION);
                         }
                         $branchId = $this->getBranchByName($value['branch_name']);
                         //Executes only once
                         if ($branchId[0]) {
                             if (sizeof($branchId) == 1) {
                                 $branchId = $branchId[0];
                             } else {
                                 throw new EfrontBranchException(_BRANCHNAMEAMBIGUOUS . ': ' . $value['branch_name'], EfrontBranchException::BRANCH_AMBIGUOUS);
                             }
                         } else {
                             throw new EfrontBranchException(_BRANCHDOESNOTEXIST . ': ' . $value['branch_name'], EfrontBranchException::BRANCH_NOT_EXISTS);
                         }
                         $jobId = false;
                         foreach ($jobDescriptions as $job) {
                             if ($job['description'] == $value['description'] && $job['branch_ID'] == $branchId) {
                                 $jobId = $job['job_description_ID'];
                             }
                         }
                         if (!$jobId) {
                             $jobId = eF_insertTableData("module_hcd_job_description", array('description' => $value['description'], 'branch_ID' => $branchId));
                             $jobDescriptions[$jobId] = array('job_description_ID' => $jobId, 'description' => $value['description'], 'branch_ID' => $branchId);
                         }
                         $user = EfrontUserFactory::factory($value["users_login"]);
                         $value['users_login'] = $user->user['login'];
                         if (isset($userJobs[$value['users_login']]) && $this->options['replace_assignments']) {
                             $unset = false;
                             foreach ($userJobs[$value['users_login']] as $key => $v) {
                                 if (!isset($addedJobs[$v][$value['users_login']])) {
                                     $user->aspects['hcd']->removeJob($v);
                                     unset($userJobs[$value['users_login']][$v]);
                                     $unset = true;
                                 }
                             }
                             if ($unset) {
                                 unset($userBranchesAssigned[$value['users_login']]);
                             }
                         }
                         if (isset($userJobs[$value['users_login']][$jobId]) && $this->options['replace_existing']) {
                             eF_deleteTableData("module_hcd_employee_has_job_description", "users_login='******'users_login'] . "' AND job_description_ID ='" . $jobId . "'");
                             unset($userJobs[$value['users_login']][$jobId]);
                         }
                         // Check if this job description is already assigned
                         if (!isset($userJobs[$value['users_login']][$jobId])) {
                             if (!isset($userBranchesAssigned[$value['users_login']][$branchId])) {
                                 // Write to the database the new branch assignment: employee to branch (if such an assignment is not already true)
                                 if (isset($userBranchesUnassigned[$value['users_login']][$branchId])) {
                                     eF_updateTableData("module_hcd_employee_works_at_branch", array("assigned" => 1), "users_login='******'users_login'] . "' and branch_ID={$branchId}");
                                     unset($userBranchesUnassigned[$value['users_login']][$branchId]);
                                 } else {
                                     $fields = array('users_login' => $value['users_login'], 'supervisor' => $value['supervisor'], 'assigned' => '1', 'branch_ID' => $branchId);
                                     eF_insertTableData("module_hcd_employee_works_at_branch", $fields);
                                     if ($value['supervisor']) {
                                         //Iterate through sub branches
                                         foreach (eF_subBranches($branchId, $allBranches) as $subBranchId) {
                                             //If this subranch is not associated with the user, associate it
                                             if (!isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && !isset($userBranchesUnassigned[$value['users_login']][$subBranchId])) {
                                                 $fields = array('users_login' => $value['users_login'], 'supervisor' => 1, 'assigned' => '0', 'branch_ID' => $subBranchId);
                                                 eF_insertTableData("module_hcd_employee_works_at_branch", $fields);
                                                 $userBranchesUnassigned[$value['users_login']][$branchId] = array('branch_ID' => $branchId, 'supervisor' => $value['supervisor'], 'assigned' => 0);
                                             } elseif (isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                                 $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                             } elseif (isset($userBranchesUnassigned[$value['users_login']][$subBranchId]) && $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                                 $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                             }
                                         }
                                     }
                                 }
                                 $userBranchesAssigned[$value['users_login']][$branchId] = array('branch_ID' => $branchId, 'supervisor' => $value['supervisor'], 'assigned' => 1);
                                 $addedBranches[$branchId][$value['users_login']] = $value['users_login'];
                             } elseif (!$userBranchesAssigned[$value['users_login']][$branchId]['supervisor'] && $value['supervisor']) {
                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$branchId}");
                                 //Iterate through sub branches
                                 foreach (eF_subBranches($branchId, $allBranches) as $subBranchId) {
                                     //If this subranch is not associated with the user, associate it
                                     if (!isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && !isset($userBranchesUnassigned[$value['users_login']][$subBranchId])) {
                                         $fields = array('users_login' => $value['users_login'], 'supervisor' => 1, 'assigned' => '0', 'branch_ID' => $subBranchId);
                                         eF_insertTableData("module_hcd_employee_works_at_branch", $fields);
                                         $userBranchesUnassigned[$value['users_login']][$branchId] = array('branch_ID' => $branchId, 'supervisor' => $value['supervisor'], 'assigned' => 0);
                                     } elseif (isset($userBranchesAssigned[$value['users_login']][$subBranchId]) && $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                         eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                         $userBranchesAssigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                     } elseif (isset($userBranchesUnassigned[$value['users_login']][$subBranchId]) && $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] == 0) {
                                         eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 1), "users_login='******'users_login'] . "' and branch_ID={$subBranchId}");
                                         $userBranchesUnassigned[$value['users_login']][$subBranchId]['supervisor'] = 1;
                                     }
                                 }
                             } elseif ($userBranchesAssigned[$value['users_login']][$branchId]['supervisor'] && !$value['supervisor']) {
                                 eF_updateTableData("module_hcd_employee_works_at_branch", array("supervisor" => 0), "users_login='******'users_login'] . "' and branch_ID={$branchId}");
                             }
                             // Write to database the new job assignment: employee to job description
                             $fields = array('users_login' => $value['users_login'], 'job_description_ID' => $jobId);
                             eF_insertTableData("module_hcd_employee_has_job_description", $fields);
                             $userJobs[$value['users_login']][$jobId] = $jobId;
                             $addedJobs[$jobId][$value['users_login']] = $value['users_login'];
                             /*
                             									if ($event_info) {
                             										EfrontEvent::triggerEvent(array("type" => EfrontEvent::HCD_NEW_JOB_ASSIGNMENT, "users_LOGIN" => $this -> login, "lessons_ID" => $branchID, "lessons_name" => $bname[0]['name'], "entity_ID" => $jobID, "entity_name" => $job_description, "timestamp" => $event_info['timestamp'], "explicitly_selected" => $event_info['manager']));
                             									} else {
                             										EfrontEvent::triggerEvent(array("type" => EfrontEvent::HCD_NEW_JOB_ASSIGNMENT, "users_LOGIN" => $this -> login, "lessons_ID" => $branchID, "lessons_name" => $bname[0]['name'], "entity_ID" => $jobID, "entity_name" => $job_description));
                             									}
                             */
                         } else {
                             throw new EfrontUserException(_JOBALREADYASSIGNED . ": " . $value['users_login'], EfrontUserException::WRONG_INPUT_TYPE);
                         }
                         $this->log["success"][] = _LINE . " " . ($key + 2) . " : " . _NEWJOBASSIGNMENT . " " . $value["users_login"] . " - (" . $value['branch_name'] . " - " . $value['description'] . ") ";
                     } catch (Exception $e) {
                         $this->log["failure"][] = _LINE . " " . ($key + 2) . " : " . $e->getMessage() . ' (' . $e->getCode() . ')';
                     }
                 }
                 $courseAssignmentsToUsers = $lessonAssignmentsToUsers = array();
                 $result = eF_getTableData("module_hcd_course_to_job_description", "*");
                 foreach ($result as $value) {
                     foreach ($addedJobs[$value['job_description_ID']] as $user) {
                         $courseAssignmentsToUsers[$value['courses_ID']][] = $user;
                     }
                 }
                 $result = eF_getTableData("module_hcd_lesson_to_job_description", "*");
                 foreach ($result as $value) {
                     foreach ($addedJobs[$value['job_description_ID']] as $user) {
                         $lessonAssignmentsToUsers[$value['lessons_ID']][] = $user;
                     }
                 }
                 if ($GLOBALS['configuration']['mode_propagate_courses_to_branch_users']) {
                     $result = eF_getTableData("module_hcd_course_to_branch", "*");
                     foreach ($result as $value) {
                         foreach ($addedBranches[$value['branches_ID']] as $user) {
                             $courseAssignmentsToUsers[$value['courses_ID']][] = $user;
                         }
                     }
                 }
                 foreach ($courseAssignmentsToUsers as $courseId => $users) {
                     $course = new EfrontCourse($courseId);
                     $course->addUsers($users);
                 }
                 foreach ($lessonAssignmentsToUsers as $lessonId => $users) {
                     $course = new EfrontLesson($lessonId);
                     $course->addUsers($users);
                 }
                 break;
         }
     } catch (Exception $e) {
         $this->log["failure"][] = $e->getMessage() . ' (' . $e->getCode() . ')';
         // ." ". str_replace("\n", "<BR>", $e->getTraceAsString());
     }
 }
Beispiel #5
0
 if (isset($_GET['add_lesson'])) {
     $post_target = 'add_lesson=1';
 } else {
     $post_target = 'edit_lesson=' . $_GET['edit_lesson'];
     $smarty->assign("T_LESSON_OPTIONS", array(array('text' => _LESSONSETTINGS, 'image' => "16x16/generic.png", 'href' => basename($_SERVER['PHP_SELF']) . "?ctg=lessons&lesson_settings=" . $_GET['edit_lesson'])));
 }
 $form = new HTML_QuickForm("add_lessons_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=lessons&" . $post_target, "", null, true);
 //Build the form
 $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
 //Register our custom input check function
 $form->addElement('text', 'name', _LESSONNAME, 'class = "inputText"');
 //The lesson name, it is required and of type 'text'
 $form->addRule('name', _THEFIELD . ' "' . _LESSONNAME . '" ' . _ISMANDATORY, 'required', null, 'client');
 $form->addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'noscript');
 if ($GLOBALS['configuration']['onelanguage'] != true) {
     $form->addElement('select', 'languages_NAME', _LANGUAGE, EfrontSystem::getLanguages(true, true));
     //Add a language select box to the form
 }
 try {
     //If there are no direction set, redirect to add direction page
     $directionsTree = new EfrontDirectionsTree();
     if (sizeof($directionsTree->tree) == 0) {
         eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_YOUMUSTFIRSTCREATEDIRECTION) . '&message_type=failure');
         exit;
     }
     $form->addElement('select', 'directions_ID', _DIRECTION, $directionsTree->toPathString());
     //Append a directions select box to the form
 } catch (Exception $e) {
     $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
     $message = _SOMEPROBLEMOCCURED . ': ' . $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
     $message_type = 'failure';
 private function login($user, $password, $encrypted = false)
 {
     //If we are logged in as another user, log him out
     if (isset($_SESSION['s_login']) && $_SESSION['s_login'] != $user->user['login']) {
         try {
             EfrontUserFactory::factory($_SESSION['s_login'])->logout(session_id());
         } catch (Exception $e) {
         }
     }
     //Empty session without destroying it
     foreach ($_SESSION as $key => $value) {
         if ($key != 'login_mode' && strpos($key, "facebook") === false) {
             //'login_mode' is used to facilitate lesson registrations
             unset($_SESSION[$key]);
         }
     }
     if ($user->user['pending']) {
         throw new EfrontUserException(_USERPENDING, EfrontUserException::USER_PENDING);
     }
     if (!$user->user['active']) {
         throw new EfrontUserException(_USERINACTIVE, EfrontUserException::USER_INACTIVE);
     }
     //if user language is deactivated or deleted, login user with system default language
     if ($GLOBALS['configuration']['onelanguage']) {
         $loginLanguage = $GLOBALS['configuration']['default_language'];
     } else {
         $activeLanguages = array_keys(EfrontSystem::getLanguages(true, true));
         if (in_array($user->user['languages_NAME'], $activeLanguages)) {
             $loginLanguage = $user->user['languages_NAME'];
         } else {
             $loginLanguage = $GLOBALS['configuration']['default_language'];
         }
     }
     //Assign session variables
     $_SESSION['s_login'] = $user->user['login'];
     $_SESSION['s_password'] = $user->user['password'];
     $_SESSION['s_type'] = $user->user['user_type'];
     $_SESSION['s_language'] = $loginLanguage;
     $_SESSION['s_custom_identifier'] = sha1(microtime() . $user->user['login']);
     $_SESSION['s_time_target'] = array(0 => 'system');
     //'s_time_target' is used to signify which of the system's area the user is currently accessing. It is a id => entity pair
     //$_SESSION['last_action_timestamp'] = time();	//Initialize first action
     //Insert log entry
     $fields_insert = array('users_LOGIN' => $user->user['login'], 'timestamp' => time(), 'action' => 'login', 'comments' => session_id(), 'session_ip' => eF_encodeIP($_SERVER['REMOTE_ADDR']));
     eF_insertTableData("logs", $fields_insert);
     if ($GLOBALS['configuration']['ban_failed_logins']) {
         eF_deleteTableData("logs", "users_LOGIN='******'login'] . "' and action='failed_login'");
     }
     //Insert user times entry
     $fields = array("session_timestamp" => time(), "session_id" => session_id(), "session_custom_identifier" => $_SESSION['s_custom_identifier'], "session_expired" => 0, "users_LOGIN" => $_SESSION['s_login'], "timestamp_now" => time(), "time" => 0, "entity" => 'system', "entity_id" => 0);
     eF_insertTableData("user_times", $fields);
     return true;
 }
 /**
  * Get lesson statisticsinformation
  *
  * This function returns the lesson information in an array
  * with attributes: 'general_description', 'assessment',
  * 'objectives', 'lesson_topics', 'resources', 'other_info',
  * as well as other information, including professors, projects
  * etc.
  * If a user is specified, the information is customized on this
  * user.
  *
  * <br/>Example:
  * <code>
  * $info = $lesson -> getInformation();         //Get lesson information
  * $info = $lesson -> getInformation('jdoe');   //Get lesson information, customizable for user 'jdoe'
  * </code>
  *
  * @param string $user The user login to customize lesson information for
  * @return array The lesson information
  * @since 3.5.0
  * @access public
  */
 public function getStatisticInformation($user = false)
 {
     $lessonContent = new EFrontContentTree($this->lesson['id']);
     $testIds = array();
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1, 'publish' => 1, 'ctg_type' => 'tests')) as $key => $value) {
         $testIds[$key] = $key;
         //Count tests
     }
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1, 'ctg_type' => 'scorm_test')) as $key => $value) {
         $testIds[$key] = $key;
         //Count scorm tests
     }
     $theoryIds = array();
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'theory', 'active' => 1)) as $key => $value) {
         $theoryIds[$key] = $key;
         //Count theory
     }
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'scorm', 'active' => 1)) as $key => $value) {
         $theoryIds[$key] = $key;
         //Count scorm content
     }
     $exampleIds = array();
     foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($lessonContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'examples', 'active' => 1)) as $key => $value) {
         $exampleIds[$key] = $key;
         //Count examples
     }
     if (!$user) {
         $projects = $this->getProjects();
         $lessonComments = eF_getTableData("comments, content", "comments.*", "comments.content_ID = content.id and content.lessons_ID=" . $this->lesson['id']);
         $lessonMessages = eF_getTableData("f_messages, f_topics, f_forums", "f_messages.*", "f_messages.f_topics_ID = f_topics.id and f_topics.f_forums_ID = f_forums.id and f_forums.lessons_ID=" . $this->lesson['id']);
     } else {
         $projects = $this->getProjects(false, $user, false);
         $lessonComments = eF_getTableData("comments, content", "comments.*", "comments.users_LOGIN='******' and comments.content_ID = content.id and content.lessons_ID=" . $this->lesson['id']);
         $lessonMessages = eF_getTableData("f_messages, f_topics, f_forums", "f_messages.*", "f_messages.users_LOGIN='******' and f_messages.f_topics_ID = f_topics.id and f_topics.f_forums_ID = f_forums.id and f_forums.lessons_ID=" . $this->lesson['id']);
     }
     $direction = $this->getDirection();
     $languages = EfrontSystem::getLanguages(true);
     $info['students'] = $this->getUsers('student');
     $info['professors'] = $this->getUsers('professor');
     $info['tests'] = sizeof($testIds);
     $info['theory'] = sizeof($theoryIds);
     $info['examples'] = sizeof($exampleIds);
     $info['content'] = $info['examples'] + $info['theory'];
     $info['projects'] = sizeof($projects);
     $info['comments'] = sizeof($lessonComments);
     $info['messages'] = sizeof($lessonMessages);
     $info['direction'] = $direction['name'];
     $info['active'] = $this->lesson['active'];
     $info['active_string'] = $this->lesson['active'] == 1 ? _YES : _NO;
     $info['price'] = $this->lesson['price'];
     $info['price_string'] = $this->lesson['price_string'];
     $info['language'] = $languages[$this->lesson['languages_NAME']];
     $info['created'] = $languages[$this->lesson['created']];
     if ($this->lesson['info']) {
         if (unserialize($this->lesson['info']) !== false) {
             $storedInfo = unserialize($this->lesson['info']);
             unset($storedInfo['professors']);
             //Due to an old bug, serialized information may contain professors as well. So, we must remove them
             $info = array_merge($info, $storedInfo);
         } else {
             if (is_array($this->lesson['info'])) {
                 $info = array_merge($info, $this->lesson['info']);
             }
         }
     }
     return $info;
 }
Beispiel #8
0
 $form->addElement('text', 'name', _COURSENAME, 'class = "inputText"');
 $form->addRule('name', _THEFIELD . ' "' . _COURSENAME . '" ' . _ISMANDATORY, 'required', null, 'client');
 //$form -> addRule('name', _INVALIDFIELDDATA, 'checkParameter', 'text');
 try {
     $directionsTree = new EfrontDirectionsTree();
     if (sizeof($directionsTree->tree) == 0) {
         eF_redirect(basename($_SERVER['PHP_SELF']) . '?ctg=directions&add_direction=1&message=' . urlencode(_TOCREATECOURSEYOUMUSTFIRSTCREATECATEGORY) . '&message_type=failure');
     }
     $directions = $directionsTree->toPathString();
 } catch (Exception $e) {
     handleNormalFlowExceptions($e);
 }
 $form->addElement('select', 'directions_ID', _DIRECTION, $directions);
 //Append a directions select box to the form
 if ($GLOBALS['configuration']['onelanguage'] != true) {
     $languages = EfrontSystem::getLanguages(true, true);
     $form->addElement('select', 'languages_NAME', _LANGUAGE, $languages);
 }
 $form->addElement('advcheckbox', 'active', _ACTIVEFEM, null, null, array(0, 1));
 $form->addElement('advcheckbox', 'show_catalog', _SHOWCOURSEINCATALOG, null, null, array(0, 1));
 $form->addElement('text', 'price', _PRICE, 'class = "inputText" style = "width:100px"');
 //$form -> addElement('text', 'course_code', _COURSECODE, 'class = "inputText" style = "width:50px"');
 $form->addElement('text', 'training_hours', _TRAININGHOURS, 'class = "inputText" style = "width:50px"');
 $recurringOptions = array(0 => _NO, 'D' => _DAILY, 'W' => _WEEKLY, 'M' => _MONTHLY, 'Y' => _YEARLY);
 $recurringDurations = array('D' => array_combine(range(1, 90), range(1, 90)), 'W' => array_combine(range(1, 52), range(1, 52)), 'M' => array_combine(range(1, 24), range(1, 24)), 'Y' => array_combine(range(1, 5), range(1, 5)));
 //Imposed by paypal interface
 $form->addElement('select', 'recurring', _SUBSCRIPTION, $recurringOptions, 'onchange = "$(\'duration_row\').show();$$(\'span\').each(function (s) {if (s.id.match(\'_duration\')) {s.hide();}});if (this.selectedIndex) {$(this.options[this.selectedIndex].value+\'_duration\').show();} else {$(\'duration_row\').hide();}"');
 $form->addElement('select', 'D_duration', _DAYSCONDITIONAL, $recurringDurations['D']);
 $form->addElement('select', 'W_duration', _WEEKSCONDITIONAL, $recurringDurations['W']);
 $form->addElement('select', 'M_duration', _MONTHSCONDITIONAL, $recurringDurations['M']);
 $form->addElement('select', 'Y_duration', _YEARSCONDITIONAL, $recurringDurations['Y']);
Beispiel #9
0
         #cpp#ifdef ENTERPRISE
         if ($mode == "branch") {
             $basic_templates_array["branch_name"] = _BRANCHNAME;
         } else {
             if ($mode == "job") {
                 $basic_templates_array["job_description_name"] = _JOBDESCRIPTIONNAME;
             }
         }
     }
     #cpp#endif
 }
 $form->addElement('select', 'templ_add', _ADDTEMPLATIZEDTEXT, $basic_templates_array, "id = 'template_add' class = 'inputSelectMed' onChange= 'addTemplatizedText(this)'");
 if ($GLOBALS['configuration']['onelanguage']) {
     $form->addElement('hidden', 'languages_NAME', $GLOBALS['configuration']['default_language']);
 } else {
     $form->addElement('select', 'languages_NAME', _LANGUAGE, EfrontSystem::getLanguages(true), 'class = "inputSelectMed" onchange="addLanguageTag(this)"');
     // Set default values for new users
     $form->setDefaults(array('languages_NAME' => $GLOBALS['configuration']['default_language']));
 }
 $form->addElement('text', 'header', _SUBJECT, 'class = "inputText" id="messageSubject" onFocus="myActiveElement=\'messageSubject\';" ');
 $form->addRule('header', _THEFIELD . ' ' . _SUBJECT . ' ' . _ISMANDATORY, 'required', null, 'client');
 $form->addRule('header', _INVALIDFIELDDATA, 'checkParameter', 'text');
 $load_editor = true;
 $form->addElement('textarea', 'message', _BODY, 'class = "digestEditor" id="messageBody" onActivate="myActiveElement=\'\';" style = "width:100%;height:200px"');
 // Get available lessons
 $lessons = eF_getTableDataFlat("lessons", "id,name", "archive=0", "name");
 sizeof($lessons) > 0 ? $av_lessons = array_combine(array_merge(array("0"), $lessons['id']), array_merge(array(_ANYLESSON), $lessons['name'])) : ($av_lessons = array(0 => _ANYLESSON));
 sizeof($lessons) > 0 ? $lessons = array_combine($lessons['id'], $lessons['name']) : ($lessons = array());
 // Get available courses
 $courses = eF_getTableDataFlat("courses", "id,name", "archive=0", "name");
 //return only unarchived courses
Beispiel #10
0
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);
    }
}
//setlocale(LC_COLLATE, _HEADERLANGUAGETAG);
//setlocale(LC_CTYPE, _HEADERLANGUAGETAG);
//setlocale(LC_MONETARY, _HEADERLANGUAGETAG);
//setlocale(LC_TIME, _HEADERLANGUAGETAG);
setlocale(LC_ALL, _HEADERLANGUAGETAG);
//Don't set LC_ALL, as this will set the LC_NUMERIC as well, which will automatically convert dots to commas if in greek
//Define theme-related constants and setup the default theme
$currentTheme = setupThemes();
/**The smarty libraries -- must be below themes!*/
require_once $path . "smarty/smarty_config.php";
//Assign the configuration variables to smarty
$smarty->assign("T_CONFIGURATION", $configuration);
//Assign global configuration values to smarty
$smarty->assign("T_MAX_FILE_SIZE", FileSystemTree::getUploadMaxSize());
//Initialize languages and notify smarty on weather we have an RTL language
$languages = EfrontSystem::getLanguages();
if ($languages[$setLanguage]['rtl']) {
    $smarty->assign("T_RTL", 1);
    $GLOBALS['rtl'] = true;
}
//$smarty -> assign("T_RTL", 1);$GLOBALS['rtl'] = true;
//Instantiate current theme
//$currentTheme = new themes(G_CURRENTTHEME);
$smarty->assign("T_THEME_SETTINGS", $currentTheme);
$smarty->assign("T_LOGO", EfrontSystem::setLogoFile($currentTheme));
$smarty->assign("T_FAVICON", EfrontSystem::setFaviconFile($currentTheme));
/**Initialize valid currencies
 * @todo: remove from here, move to a function or class*/
require_once $path . "includes/currencies.php";
//Load filters if smarty is set
if (isset($smarty)) {
Beispiel #12
0
    }
}
$smarty->assign("T_GENERAL_SECURITY_FORM", $generalSecurityForm->toArray());
$generalLocaleForm = new HTML_QuickForm("general_locale", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=general&tab=locale", "", null, true);
$generalLocaleForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$defaultEncodings = array_combine(mb_list_encodings(), mb_list_encodings());
$encodings['UTF7-IMAP'] = 'UTF7-IMAP';
/*
if (in_array(_CHARSET, $defaultEncodings)) {
	$encodings[_CHARSET] = _CHARSET;
}
*/
$encodings['UTF-8'] = 'UTF-8';
$encodings = array_merge($encodings, $defaultEncodings);
// Hard-coded cities per time zone - hopefully all are DST aware
$generalLocaleForm->addElement("select", "default_language", _DEFAULTLANGUAGE, EfrontSystem::getLanguages(true, true), 'class = "inputSelect"');
$generalLocaleForm->addElement("advcheckbox", "onelanguage", _ONLYONELANGUAGE, null, 'class = "inputCheckBox"', array(0, 1));
$generalLocaleForm->addElement("select", "date_format", _DATEFORMAT, array("DD/MM/YYYY" => "DD/MM/YYYY", "MM/DD/YYYY" => "MM/DD/YYYY", "YYYY/MM/DD" => "YYYY/MM/DD"));
$generalLocaleForm->addElement("select", "time_zone", _TIMEZONE, eF_getTimezones(), 'class = "inputText" style="width:40em"');
$generalLocaleForm->addElement("select", "currency", _CURRENCY, $CURRENCYNAMES);
$generalLocaleForm->addElement("select", "currency_order", _SHOWCURRENCYSYMBOL, array(1 => _BEFOREPRICE, 0 => _AFTERPRICE));
//$generalLocaleForm -> addElement("text", "decimal_point", _DECIMALPOINT,	   'class = "inputText" style = "width:50px"');
//$generalLocaleForm -> addElement("text", "thousands_sep", _THOUSANDSSEPARATOR, 'class = "inputText" style = "width:50px"');
$generalLocaleForm->addElement("select", "file_encoding", _TRANSLATEFILESYSTEM, $encodings, 'class = "inputSelect"');
$generalLocaleForm->setDefaults($GLOBALS['configuration']);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $generalLocaleForm->freeze();
} else {
    $generalLocaleForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($generalLocaleForm->isSubmitted() && $generalLocaleForm->validate()) {
        //If the form is submitted and validated