/** * @author Sebastien Piraux <*****@*****.**> old code * @author Julio Montoya 2013 * @desc Record information for login event when an user identifies himself with username & password */ function event_login(User $user) { $userId = $user->getUserId(); $TABLETRACK_LOGIN = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $reallyNow = api_get_utc_datetime(); $sql = "INSERT INTO " . $TABLETRACK_LOGIN . " (login_user_id, login_ip, login_date, logout_date) VALUES\n ('" . $userId . "',\n '" . Database::escape_string(api_get_real_ip()) . "',\n '" . $reallyNow . "',\n '" . $reallyNow . "'\n )"; Database::query($sql); $roles = $user->getRoles(); // auto subscribe foreach ($roles as $role) { $userStatusParsed = 'student'; switch ($role) { case 'ROLE_SESSION_MANAGER': $userStatusParsed = 'sessionadmin'; break; case 'ROLE_TEACHER': $userStatusParsed = 'teacher'; break; case 'ROLE_RRHH': $userStatusParsed = 'DRH'; break; } $autoSubscribe = api_get_setting($userStatusParsed . '_autosubscribe'); if ($autoSubscribe) { $autoSubscribe = explode('|', $autoSubscribe); foreach ($autoSubscribe as $code) { if (CourseManager::course_exists($code)) { CourseManager::subscribe_user($userId, $code); } } } } }
/** * @author Sebastien Piraux <*****@*****.**> * @desc Record information for login event * (when an user identifies himself with username & password) */ function event_login() { global $TABLETRACK_LOGIN; global $_user; // @todo use api_get_user_info(); //$userInfo = api_get_user_info(); $userInfo = $_user; if (empty($userInfo)) { return false; } $userId = api_get_user_id(); $reallyNow = api_get_utc_datetime(); $sql = "INSERT INTO " . $TABLETRACK_LOGIN . " (login_user_id, login_ip, login_date, logout_date) VALUES\n ('" . $userId . "',\n '" . Database::escape_string(api_get_real_ip()) . "',\n '" . $reallyNow . "',\n '" . $reallyNow . "'\n )"; Database::query($sql); // Auto subscribe $user_status = $userInfo['status'] == SESSIONADMIN ? 'sessionadmin' : $userInfo['status'] == COURSEMANAGER ? 'teacher' : $userInfo['status'] == DRH ? 'DRH' : 'student'; $autoSubscribe = api_get_setting($user_status . '_autosubscribe'); if ($autoSubscribe) { $autoSubscribe = explode('|', $autoSubscribe); foreach ($autoSubscribe as $code) { if (CourseManager::course_exists($code)) { CourseManager::subscribe_user($userId, $code); } } } }
public function process() { $results = array(); foreach ($this->rows as $row_val) { $search_show_unlinked_results = api_get_setting('search_show_unlinked_results') == 'true'; $course_visible_for_user = api_is_course_visible_for_user(NULL, $row_val['courseid']); // can view course? if ($course_visible_for_user || $search_show_unlinked_results) { // is visible? $visibility = api_get_item_visibility(api_get_course_info($row_val['courseid']), TOOL_DOCUMENT, $row_val['xapian_data'][SE_DATA]['doc_id']); if ($visibility) { list($thumbnail, $image, $name, $author, $url) = $this->get_information($row_val['courseid'], $row_val['xapian_data'][SE_DATA]['doc_id']); $result = array('toolid' => TOOL_DOCUMENT, 'score' => $row_val['score'], 'url' => $url, 'thumbnail' => $thumbnail, 'image' => $image, 'title' => $name, 'author' => $author); if ($course_visible_for_user) { $results[] = $result; } else { // course not visible for user if ($search_show_unlinked_results) { $result['url'] = ''; $results[] = $result; } } } } } // get information to sort foreach ($results as $key => $row) { $score[$key] = $row['score']; } // Sort results with score descending array_multisort($score, SORT_DESC, $results); return $results; }
function cloud_getScormEngineService() { require_once 'CloudPHPLibrary/ScormEngineService.php'; $ServiceUrl = api_get_setting('scormCloudCredsUrl', 'appUrl'); $AppId = api_get_setting('scormCloudCredsId', 'appId'); $SecretKey = api_get_setting('scormCloudCredsPw', 'appPw'); return new ScormEngineService($ServiceUrl, $AppId, $SecretKey); }
/** * Function to check if a username is of the correct format * * @param string $username Wanted username * @param array $options * * @return boolean True if username is of the correct format * @author Modified by Ivan Tcholakov, 15-SEP-2009. * @see HTML_QuickForm_Rule * The validation rule is served by the UserManager class as of this moment. */ public function validate($username, $options) { if (api_get_setting('login_is_email') == 'true') { return api_valid_email($username); } else { return UserManager::is_username_valid($username); } }
/** * @return array */ public function getConditionalPlugins() { $plugins = array(); if (api_get_setting('document.show_glossary_in_documents') == 'ismanual') { $plugins[] = 'glossary'; } return $plugins; }
/** * @Route("/config_editor", name="config_editor") * @Method({"GET"}) * * @return Response */ public function configEditorAction() { $moreButtonsInMaximizedMode = false; if (api_get_setting('editor.more_buttons_maximized_mode') == 'true') { $moreButtonsInMaximizedMode = true; } return $this->render('ChamiloCoreBundle:default/javascript/editor/ckeditor:config_js.html.twig', array('more_buttons_in_max_mode' => $moreButtonsInMaximizedMode, 'course_id' => '1', 'session_id' => '1')); }
/** * Check whether to display the courses list * @global array $_configuration Configuration * * @return boolean whether to display */ public static function showCourses() { $catalogShow = intval(api_get_setting('platform.catalog_show_courses_sessions')); if ($catalogShow == CATALOG_COURSES || $catalogShow == CATALOG_COURSES_SESSIONS) { return true; } return false; }
function validate_data($users) { global $defined_auth_sources; $errors = array(); $usernames = array(); // 1. Check if mandatory fields are set. $mandatory_fields = array('LastName', 'FirstName'); if (api_get_setting('registration', 'email') == 'true') { $mandatory_fields[] = 'Email'; } foreach ($users as $index => $user) { foreach ($mandatory_fields as $field) { if (empty($user[$field])) { $user['error'] = get_lang($field . 'Mandatory'); $errors[] = $user; } } // 2. Check username, first, check whether it is empty. if (!UserManager::is_username_empty($user['UserName'])) { // 2.1. Check whether username is too long. if (UserManager::is_username_too_long($user['UserName'])) { $user['error'] = get_lang('UserNameTooLong'); $errors[] = $user; } // 2.2. Check whether the username was used twice in import file. if (isset($usernames[$user['UserName']])) { $user['error'] = get_lang('UserNameUsedTwice'); $errors[] = $user; } $usernames[$user['UserName']] = 1; // 2.3. Check whether username is allready occupied. if (!UserManager::is_username_available($user['UserName'])) { $user['error'] = get_lang('UserNameNotAvailable'); $errors[] = $user; } } // 3. Check status. if (isset($user['Status']) && !api_status_exists($user['Status'])) { $user['error'] = get_lang('WrongStatus'); $errors[] = $user; } // 4. Check classname if (!empty($user['ClassName'])) { if (!ClassManager::class_name_exists($user['ClassName'])) { $user['error'] = get_lang('ClassNameNotAvailable'); $errors[] = $user; } } // 5. Check authentication source if (!empty($user['AuthSource'])) { if (!in_array($user['AuthSource'], $defined_auth_sources)) { $user['error'] = get_lang('AuthSourceNotAvailable'); $errors[] = $user; } } } return $errors; }
/** * Get the toolbar config * @return array */ public function getConfig() { if (api_get_setting('more_buttons_maximized_mode') != 'true') { $config['toolbar'] = $this->getNormalToolbar(); } else { $config['toolbar_minToolbar'] = $this->getMinimizedToolbar(); } return $config; }
/** * Uninstall the plugin * @return void */ public function uninstall() { $setting = api_get_setting('plugin_pens'); if (!empty($setting)) { $this->uninstallHook(); // Note: Keeping area field data is intended so it will not be removed $this->uninstallDatabase(); } }
/** * @Route("/courses/{cidReq}/{sessionId}") * @Method({"GET"}) * * @param string $cidReq * @param int $id_session * @return Response */ public function indexAction($cidReq, $id_session = null) { $courseCode = api_get_course_id(); $sessionId = api_get_session_id(); $userId = $this->getUser()->getUserId(); $coursesAlreadyVisited = $this->getRequest()->getSession()->get('coursesAlreadyVisited'); $result = $this->autolaunch(); $showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning']; $showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning']; if ($showAutoLaunchLpWarning) { $this->getTemplate()->assign('lp_warning', Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'), 'warning')); } if ($showAutoLaunchExerciseWarning) { $this->getTemplate()->assign('exercise_warning', Display::return_message(get_lang('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'), 'warning')); } if ($this->isCourseTeacher()) { $editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('course_home.controller:iconListAction', array('course' => api_get_course_id()))); $this->getTemplate()->assign('edit_icons', $editIcons); } if (!isset($coursesAlreadyVisited[$courseCode])) { event_access_course(); $coursesAlreadyVisited[$courseCode] = 1; $this->getRequest()->getSession()->set('coursesAlreadyVisited', $coursesAlreadyVisited); } $this->getRequest()->getSession()->remove('toolgroup'); $this->getRequest()->getSession()->remove('_gid'); $isSpecialCourse = \CourseManager::is_special_course($courseCode); if ($isSpecialCourse) { $autoreg = $this->getRequest()->get('autoreg'); if ($autoreg == 1) { \CourseManager::subscribe_user($userId, $courseCode, STUDENT); } } $script = 'activity.php'; if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_view') == 'activity_big') { $script = 'activity.php'; } elseif (api_get_setting('homepage_view') == '2column') { $script = '2column.php'; } elseif (api_get_setting('homepage_view') == '3column') { $script = '3column.php'; } elseif (api_get_setting('homepage_view') == 'vertical_activity') { $script = 'vertical_activity.php'; } $result = (require_once api_get_path(SYS_CODE_PATH) . 'course_home/' . $script); $toolList = $result['tool_list']; $this->getTemplate()->assign('icons', $result['content']); $introduction = Display::return_introduction_section($this->get('url_generator'), TOOL_COURSE_HOMEPAGE, $toolList); $this->getTemplate()->assign('introduction_text', $introduction); if (api_get_setting('show_session_data') == 'true' && $sessionId) { $sessionInfo = \CourseHome::show_session_data($sessionId); $this->getTemplate()->assign('session_info', $sessionInfo); } $response = $this->get('template')->render_template($this->getTemplatePath() . 'index.tpl'); return new Response($response, 200, array()); }
/** * Function to convert from ppt to png * This function is used from Chamilo Rapid Lesson * * @param array $pptData * @return string */ function wsConvertPpt($pptData) { $fileData = $pptData['file_data']; $dataInfo = pathinfo($pptData['file_name']); $fileName = basename($pptData['file_name'], '.' . $dataInfo['extension']); $fullFileName = $pptData['file_name']; $tempArchivePath = api_get_path(SYS_ARCHIVE_PATH); $tempPath = $tempArchivePath . 'wsConvert/' . $fileName . '/'; $tempPathNewFiles = $tempArchivePath . 'wsConvert/' . $fileName . '-n/'; $perms = api_get_permissions_for_new_directories(); if (!is_dir($tempPath)) { mkdir($tempPath, $perms, true); } if (!is_dir($tempPathNewFiles)) { mkdir($tempPathNewFiles, $perms, true); } if (!is_dir($tempPathNewFiles . $fileName)) { mkdir($tempPathNewFiles . $fileName, $perms, true); } $file = base64_decode($fileData); file_put_contents($tempPath . $fullFileName, $file); if (IS_WINDOWS_OS) { // IS_WINDOWS_OS has been defined in main_api.lib.php $converterPath = str_replace('/', '\\', api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'); $classPath = $converterPath . ';' . $converterPath . '/jodconverter-2.2.2.jar;' . $converterPath . '/jodconverter-cli-2.2.2.jar'; $cmd = 'java -Dfile.encoding=UTF-8 -cp "' . $classPath . '" DokeosConverter'; } else { $converterPath = api_get_path(SYS_PATH) . 'main/inc/lib/ppt2png'; $classPath = ' -Dfile.encoding=UTF-8 -cp .:jodconverter-2.2.2.jar:jodconverter-cli-2.2.2.jar'; $cmd = 'cd ' . $converterPath . ' && java ' . $classPath . ' DokeosConverter'; } $cmd .= ' -p ' . api_get_setting('service_ppt2lp', 'port'); $cmd .= ' -w 720 -h 540 -d oogie "' . $tempPath . $fullFileName . '" "' . $tempPathNewFiles . $fileName . '.html"'; $perms = api_get_permissions_for_new_files(); chmod($tempPathNewFiles . $fileName, $perms, true); $files = array(); $return = 0; $shell = exec($cmd, $files, $return); if ($return === 0) { $images = array(); foreach ($files as $file) { $imageData = explode('||', $file); $images[$imageData[1]] = base64_encode(file_get_contents($tempPathNewFiles . $fileName . '/' . $imageData[1])); } $data = array('files' => $files, 'images' => $images); deleteDirectory($tempPath); deleteDirectory($tempPathNewFiles); return serialize($data); } else { deleteDirectory($tempPath); deleteDirectory($tempPathNewFiles); return false; } }
/** * */ public function __construct() { $this->table = Database::get_main_table(TABLE_NOTIFICATION); $this->sender_email = api_get_setting('noreply_email_address'); $this->sender_name = api_get_setting('siteName'); // If no-reply email doesn't exist use the admin email if (empty($this->sender_email)) { $this->sender_email = api_get_setting('emailAdministrator'); $this->sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); } }
public function process() { $results = array(); foreach ($this->links as $courseid => $one_course_links) { $course_info = api_get_course_info($courseid); $search_show_unlinked_results = (api_get_setting('search_show_unlinked_results') == 'true'); $course_visible_for_user = api_is_course_visible_for_user(NULL, $courseid); // can view course? if ($course_visible_for_user || $search_show_unlinked_results) { $result = NULL; foreach ($one_course_links['links'] as $one_link) { // is visible? $visibility = api_get_item_visibility($course_info, TOOL_LINK, $one_link['link_id']); if ($visibility) { // if one is visible let show the result for a course // also asume all data of this item like the data of the whole group of links(Ex. author) list($thumbnail, $image, $name, $author, $url) = $this->get_information($courseid, $one_link['link_id']); $result_tmp = array( 'toolid' => TOOL_LINK, 'score' => $one_course_links['total_score'] / (count($one_course_links) - 1), // not count total_score array item 'url' => $url, 'thumbnail' => $thumbnail, 'image' => $image, 'title' => $name, 'author' => $author, ); if ($course_visible_for_user) { $result = $result_tmp; } else { // course not visible for user if ($search_show_unlinked_results) { $result_tmp['url'] = ''; $result = $result_tmp; } } break; } } if (!is_null($result)) { // if there is at least one link item found show link to course Links tool page $results[] = $result; } } } // get information to sort foreach ($results as $key => $row) { $score[$key] = $row['score']; } // Sort results with score descending array_multisort($score, SORT_DESC, $results); return $results; }
/** * Get actual array data * @return array 2-dimensional array - each array contains the elements: * 0 ['id'] : user id * 1 ['result_id'] : result id * 2 ['lastname'] : user lastname * 3 ['firstname'] : user firstname * 4 ['score'] : student's score * 5 ['display'] : custom score display (only if custom scoring enabled) */ public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf = false) { // do some checks on count, redefine if invalid value $number_decimals = api_get_setting('gradebook_number_decimals'); if (!isset($count)) { $count = count($this->results) - $start; } if ($count < 0) { $count = 0; } $scoredisplay = ScoreDisplay::instance(); // generate actual data array $table = array(); foreach ($this->results as $result) { $user = array(); $info = get_user_info_from_id($result->get_user_id()); $user['id'] = $result->get_user_id(); if ($pdf) { $user['username'] = $info['username']; } $user['result_id'] = $result->get_id(); $user['lastname'] = $info['lastname']; $user['firstname'] = $info['firstname']; if ($pdf) { $user['score'] = $result->get_score(); } else { $user['score'] = $this->get_score_display($result->get_score(), true, $ignore_score_color); } $user['percentage_score'] = intval($scoredisplay->display_score(array($result->get_score(), $this->evaluation->get_max()), SCORE_PERCENT, SCORE_BOTH, true)); if ($pdf && $number_decimals == null) { $user['scoreletter'] = $result->get_score(); } if ($scoredisplay->is_custom()) { $user['display'] = $this->get_score_display($result->get_score(), false, $ignore_score_color); } $table[] = $user; } // sort array if ($sorting & self::RDG_SORT_LASTNAME) { usort($table, array('ResultsDataGenerator', 'sort_by_last_name')); } elseif ($sorting & self::RDG_SORT_FIRSTNAME) { usort($table, array('ResultsDataGenerator', 'sort_by_first_name')); } elseif ($sorting & self::RDG_SORT_SCORE) { usort($table, array('ResultsDataGenerator', 'sort_by_score')); } elseif ($sorting & self::RDG_SORT_MASK) { usort($table, array('ResultsDataGenerator', 'sort_by_mask')); } if ($sorting & self::RDG_SORT_DESC) { $table = array_reverse($table); } $return = array_slice($table, $start, $count); return $return; }
/** * Redirect to the session "request uri" if it exists. * @param bool Whether the user just logged in (in this case, use page_after_login rules) */ static function session_request_uri($logging_in = false, $user_id = null) { $no_redirection = isset($_SESSION['noredirection']) ? $_SESSION['noredirection'] : false; if ($no_redirection) { unset($_SESSION['noredirection']); return; } $url = isset($_SESSION['request_uri']) ? $_SESSION['request_uri'] : ''; unset($_SESSION['request_uri']); if (!empty($url)) { self::navigate($url); } elseif ($logging_in || isset($_REQUEST['sso_referer']) && !empty($_REQUEST['sso_referer'])) { if (isset($user_id)) { // Make sure we use the appropriate role redirection in case one has been defined $user_status = api_get_user_status($user_id); switch ($user_status) { case COURSEMANAGER: $redir = api_get_setting('teacher_page_after_login'); if (!empty($redir)) { self::navigate(api_get_path(WEB_PATH) . $redir); } break; case STUDENT: $redir = api_get_setting('student_page_after_login'); if (!empty($redir)) { self::navigate(api_get_path(WEB_PATH) . $redir); } break; case DRH: $redir = api_get_setting('drh_page_after_login'); if (!empty($redir)) { self::navigate(api_get_path(WEB_PATH) . $redir); } break; case SESSIONADMIN: $redir = api_get_setting('sessionadmin_page_after_login'); if (!empty($redir)) { self::navigate(api_get_path(WEB_PATH) . $redir); } break; default: break; } } $page_after_login = api_get_setting('page_after_login'); if (!empty($page_after_login)) { self::navigate(api_get_path(WEB_PATH) . $page_after_login); } } }
public static function redirect() { global $param; $param = isset($param) ? $param : ''; $redirect_url = ''; /* //If session request url is setted, we go there if (!empty($_SESSION['request_uri'])) { $req = $_SESSION['request_uri']; unset($_SESSION['request_uri']); header('location: '.$req); exit(); } */ if (api_is_student() && !api_get_setting('student_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('student_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_teacher() && !api_get_setting('teacher_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('teacher_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_drh() && !api_get_setting('drh_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('drh_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (api_is_session_admin() && !api_get_setting('sessionadmin_page_after_login') == '') { $redirect_url = html_entity_decode(api_get_setting('sessionadmin_page_after_login')); if ($redirect_url[0] == "/") { $redirect_url = substr(api_get_path(WEB_PATH), 0, -1) . $redirect_url; } } if (!empty($redirect_url)) { header('Location: ' . $redirect_url . $param); exit; } // Custom pages if (CustomPages::enabled()) { CustomPages::display(CustomPages::INDEX_LOGGED); } header('location: ' . api_get_path(WEB_PATH) . api_get_setting('page_after_login') . $param); exit; }
/** * Class constructor */ function SelectLanguage($elementName = null, $elementLabel = null, $options = null, $attributes = null) { parent::__construct($elementName, $elementLabel, $options, $attributes); // Get all languages $languages = api_get_languages(); $this->_options = array(); $this->_values = array(); foreach ($languages['name'] as $index => $name) { if ($languages['folder'][$index] == api_get_setting('platformLanguage')) { $this->addOption($name, $languages['folder'][$index], array('selected' => 'selected')); } else { $this->addOption($name, $languages['folder'][$index]); } } }
/** * Class constructor */ public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null) { parent::__construct($elementName, $elementLabel, $options, $attributes); // Get all languages $languages = api_get_languages(); $this->_options = array(); $this->_values = array(); foreach ($languages as $iso => $name) { if ($iso == api_get_setting('language.platform_language')) { $this->addOption($name, $iso, array('selected' => 'selected')); } else { $this->addOption($name, $iso); } } }
/** * Instanciates the object, initializing all relevant URL strings */ public function __construct() { $this->protocol = api_get_setting('sso_authentication_protocol'); // There can be multiple domains, so make sure to take only the first // This might be later extended with a decision process $domains = split(',', api_get_setting('sso_authentication_domain')); $this->domain = trim($domains[0]); $this->auth_uri = api_get_setting('sso_authentication_auth_uri'); $this->deauth_uri = api_get_setting('sso_authentication_unauth_uri'); //cut the string to avoid recursive URL construction in case of failure $this->referer = $this->protocol . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'sso')); $this->deauth_url = $this->protocol . $this->domain . $this->deauth_uri; $this->master_url = $this->protocol . $this->domain . $this->auth_uri; $this->target = api_get_path(WEB_PATH); }
/** * Get the toolbar config * @return array */ public function getConfig() { if (api_get_setting('more_buttons_maximized_mode') != 'true') { $config['toolbar'] = $this->getNormalToolbar(); } else { $config['toolbar_minToolbar'] = $this->getNormalToolbar(); $config['toolbar_maxToolbar'] = $this->getNormalToolbar(); } $config['fullPage'] = false; $config['extraPlugins'] = 'wordcount'; $config['wordcount'] = array('showWordCount' => true, 'showCharCount' => true, 'charLimit' => 'unlimited', 'wordLimit' => 'unlimited'); $config['removePlugins'] = 'elementspath'; //$config['height'] = '200'; return $config; }
/** * Functions to get the data for the chamilo diagnostics * @return array of data */ function get_chamilo_data() { $array = array(); $writable_folders = array('archive', 'courses', 'home', 'main/upload/users/', 'main/default_course_document/images/'); foreach ($writable_folders as $index => $folder) { $writable = is_writable(api_get_path(SYS_PATH) . $folder); $status = $writable ? self::STATUS_OK : self::STATUS_ERROR; $array[] = $this->build_setting($status, '[FILES]', get_lang('IsWritable') . ': ' . $folder, 'http://be2.php.net/manual/en/function.is-writable.php', $writable, 1, 'yes_no', get_lang('DirectoryMustBeWritable')); } $exists = file_exists(api_get_path(SYS_CODE_PATH) . 'install'); $status = $exists ? self::STATUS_WARNING : self::STATUS_OK; $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists') . ': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved')); $app_version = api_get_setting('chamilo_database_version'); $array[] = $this->build_setting(self::STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version'); return $array; }
/** * @Route("/", name="course_home") * @Route("/index.php") * @Method({"GET"}) * * @param Request $request * @return Response */ public function indexAction(Request $request) { $sessionId = api_get_session_id(); $course = $this->getCourse(); $courseCode = $course->getId(); $result = $this->autoLaunch(); $showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning']; $showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning']; if ($showAutoLaunchLpWarning) { $this->addFlash('warning', $this->trans('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP')); } if ($showAutoLaunchExerciseWarning) { $this->addFlash('warning', $this->trans('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise')); } if (true) { $editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('chamilo_course_home_home_iconlist', array('course' => api_get_course_id()))); } $isSpecialCourse = \CourseManager::isSpecialCourse($courseCode); if ($isSpecialCourse) { $user = $this->getUser(); if (!empty($user)) { $userId = $this->getUser()->getId(); $autoreg = $request->get('autoreg'); if ($autoreg == 1) { \CourseManager::subscribe_user($userId, $courseCode, STUDENT); } } } $homeView = api_get_setting('course.homepage_view'); if ($homeView == 'activity' || $homeView == 'activity_big') { $result = $this->renderActivityView(); } elseif ($homeView == '2column') { $result = $this->render2ColumnView(); } elseif ($homeView == '3column') { $result = $this->render3ColumnView(); } elseif ($homeView == 'vertical_activity') { $result = $this->renderVerticalActivityView(); } $toolList = $result['tool_list']; $introduction = Display::return_introduction_section(TOOL_COURSE_HOMEPAGE, $toolList); $sessionInfo = null; if (api_get_setting('session.show_session_data') == 'true' && $sessionId) { $sessionInfo = CourseHome::show_session_data($sessionId); } return $this->render('ChamiloCourseBundle:Home:index.html.twig', array('course' => $course, 'session_info' => $sessionInfo, 'icons' => $result['content'], 'edit_icons' => $editIcons, 'introduction_text' => $introduction, 'exercise_warning' => null, 'lp_warning' => null)); }
/** * Checks if the user accepted or not the legal conditions * * @param array $user * @return boolean true if user pass, false otherwise */ function check_platform_legal_conditions($user) { if (api_get_setting('allow_terms_conditions') == 'true') { $term_and_condition_status = api_check_term_condition($user['user_id']); // @todo not sure why we need the login password and update_term_status if ($term_and_condition_status == false) { $_SESSION['term_and_condition'] = array('user_id' => $user['user_id']); return false; } else { unset($_SESSION['term_and_condition']); return true; } } else { //No validation user can pass return true; } }
/** * This function connect to facebook and retrieves the user info * If user does not exist in chamilo, it creates it and logs in * If user already exists, it updates his info * */ function facebook_connect() { global $facebook; // See if there is a user from a cookie $user = $facebook->getUser(); if ($user) { try { //Gets facebook user info $fu = $facebook->api('/me'); $username = $fu['username']; if (api_get_setting('login_is_email') == 'true' || empty($fu['username'])) { $username = change_to_valid_chamilo_login($fu['email']); } //Checks if user already exists in chamilo $u = array('firstname' => $fu['first_name'], 'lastname' => $fu['last_name'], 'status' => STUDENT, 'email' => $fu['email'], 'username' => $username, 'language' => 'french', 'password' => DEFAULT_PASSWORD, 'auth_source' => 'facebook', 'extra' => array()); $cu = api_get_user_info_from_username($username); $chamilo_uinfo = api_get_user_info_from_username($username); if ($chamilo_uinfo === false) { //we have to create the user $chamilo_uid = external_add_user($u); if ($chamilo_uid !== false) { $_user['user_id'] = $chamilo_uid; $_user['uidReset'] = true; $_SESSION['_user'] = $_user; header('Location:' . api_get_path(WEB_PATH)); exit; } else { return false; } } else { //User already exists, update info and login $chamilo_uid = $chamilo_uinfo['user_id']; $u['user_id'] = $chamilo_uid; external_update_user($u); $_user['user_id'] = $chamilo_uid; $_user['uidReset'] = true; $_SESSION['_user'] = $_user; header('Location:' . api_get_path(WEB_PATH)); exit; } } catch (FacebookApiException $e) { echo '<pre>' . htmlspecialchars(print_r($e, true)) . '</pre>'; $user = null; } } }
function install() { // Create database tables require_once api_get_path(SYS_PLUGIN_PATH) . PLUGIN_NAME . '/database.php'; // Create link tab $homep = api_get_path(SYS_PATH) . 'home/'; //homep for Home Path $menutabs = 'home_tabs'; //menutabs for tabs Menu $menuf = $menutabs; $ext = '.html'; //ext for HTML Extension - when used frequently, variables are faster than hardcoded strings $lang = ''; //el for "Edit Language" if (!empty($_SESSION['user_language_choice'])) { $lang = $_SESSION['user_language_choice']; } elseif (!empty($_SESSION['_user']['language'])) { $lang = $_SESSION['_user']['language']; } else { $lang = api_get_setting('platformLanguage'); } $link_url = api_get_path(WEB_PLUGIN_PATH) . 'ticket/s/myticket.php'; $home_menu = '<li class="show_menu"><a href="' . $link_url . '" target="_self"><span>Ticket</span></a></li>'; // Write if (file_exists($homep . $menuf . '_' . $lang . $ext)) { if (is_writable($homep . $menuf . '_' . $lang . $ext)) { $fp = fopen($homep . $menuf . '_' . $lang . $ext, 'w'); fputs($fp, $home_menu); fclose($fp); if (file_exists($homep . $menuf . $ext)) { if (is_writable($homep . $menuf . $ext)) { $fpo = fopen($homep . $menuf . $ext, 'w'); fputs($fpo, $home_menu); fclose($fpo); } } } else { $errorMsg = get_lang('HomePageFilesNotWritable'); } } else { //File does not exist $fp = fopen($homep . $menuf . '_' . $lang . $ext, 'w'); fputs($fp, $home_menu); fclose($fp); } }
/** * Class constructor */ function HTML_QuickForm_Select_Language($elementName = null, $elementLabel = null, $options = null, $attributes = null) { if (!isset($attributes['class'])) { $attributes['class'] = 'chzn-select'; } parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes); // Get all languages $languages = api_get_languages(); $this->_options = array(); $this->_values = array(); foreach ($languages['name'] as $index => $name) { if ($languages['folder'][$index] == api_get_setting('platformLanguage')) { $this->addOption($name, $languages['folder'][$index], array('selected' => 'selected')); } else { $this->addOption($name, $languages['folder'][$index]); } } }
/** * Function to sort users after getting the list in the DB. * Necessary because there are 2 or 3 queries. Called by usort() */ function sort_users($user_a, $user_b) { $orderListByOfficialCode = api_get_setting('platform.order_user_list_by_official_code'); if ($orderListByOfficialCode === 'true') { $cmp = api_strcmp($user_a['official_code'], $user_b['official_code']); if ($cmp !== 0) { return $cmp; } else { $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']); if ($cmp !== 0) { return $cmp; } else { return api_strcmp($user_a['username'], $user_b['username']); } } } if (api_sort_by_first_name()) { $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']); if ($cmp !== 0) { return $cmp; } else { $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']); if ($cmp !== 0) { return $cmp; } else { return api_strcmp($user_a['username'], $user_b['username']); } } } else { $cmp = api_strcmp($user_a['lastname'], $user_b['lastname']); if ($cmp !== 0) { return $cmp; } else { $cmp = api_strcmp($user_a['firstname'], $user_b['firstname']); if ($cmp !== 0) { return $cmp; } else { return api_strcmp($user_a['username'], $user_b['username']); } } } }
public function process() { $results = array(); foreach ($this->learnpaths as $courseid => $learnpaths) { $search_show_unlinked_results = api_get_setting('search_show_unlinked_results') == 'true'; $course_visible_for_user = api_is_course_visible_for_user(NULL, $courseid); // can view course? if ($course_visible_for_user || $search_show_unlinked_results) { foreach ($learnpaths as $lp_id => $lp) { // is visible? $visibility = api_get_item_visibility(api_get_course_info($courseid), TOOL_LEARNPATH, $lp_id); if ($visibility) { list($thumbnail, $image, $name, $author) = $this->get_information($courseid, $lp_id, $lp['has_document_id']); $url = api_get_path(WEB_PATH) . 'main/newscorm/lp_controller.php?cidReq=%s&action=view&lp_id=%s'; $url = sprintf($url, $courseid, $lp_id); $result = array('toolid' => TOOL_LEARNPATH, 'score' => $lp['total_score'] / (count($lp) - 1), 'url' => $url, 'thumbnail' => $thumbnail, 'image' => $image, 'title' => $name, 'author' => $author); if ($course_visible_for_user) { $results[] = $result; } else { // course not visible for user if ($search_show_unlinked_results) { $result['url'] = ''; $results[] = $result; } } } } } } // get information to sort foreach ($results as $key => $row) { $score[$key] = $row['score']; } // Sort results with score descending array_multisort($score, SORT_DESC, $results); return $results; }