本文整理汇总了PHP中ChamiloSession::read方法的典型用法代码示例。如果您正苦于以下问题:PHP ChamiloSession::read方法的具体用法?PHP ChamiloSession::read怎么用?PHP ChamiloSession::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChamiloSession
的用法示例。
在下文中一共展示了ChamiloSession::read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fixDocumentNameCallback
function fixDocumentNameCallback($p_event, &$p_header)
{
global $remove_dir;
$files = Session::read('doc_files_to_download');
$storedFile = $remove_dir . $p_header['stored_filename'];
if (!isset($files[$storedFile])) {
return 0;
}
$documentData = $files[$storedFile];
$documentNameFixed = DocumentManager::undoFixDocumentName($documentData['path'], $documentData['c_id'], $documentData['session_id'], $documentData['to_group_id']);
// Changes file.phps to file.php
$basename = basename($documentNameFixed);
$basenamePHPFixed = str_replace('.phps', '.php', $basename);
$documentNameFixed = str_replace($basename, $basenamePHPFixed, $documentNameFixed);
if ($remove_dir != '/') {
$documentNameFixed = str_replace($remove_dir, '/', $documentNameFixed);
if (substr($documentNameFixed, 0, 1) == '/') {
$documentNameFixed = substr($documentNameFixed, 1, api_strlen($documentNameFixed));
}
} else {
$documentNameFixed = ltrim($documentNameFixed, '/');
}
$p_header['stored_filename'] = $documentNameFixed;
return 1;
}
示例2: preventMultipleLogin
/**
* @param int $userId
*/
function preventMultipleLogin($userId)
{
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$userId = intval($userId);
if (api_get_settings('prevent_multiple_simultaneous_login') === 'true') {
if (!empty($userId) && !api_is_anonymous()) {
$isFirstLogin = Session::read('first_user_login');
if (empty($isFirstLogin)) {
$sql = "SELECT login_id FROM {$table}\n WHERE login_user_id = " . $userId . " LIMIT 1";
$result = Database::query($sql);
$loginData = array();
if (Database::num_rows($result)) {
$loginData = Database::fetch_array($result);
}
$userIsReallyOnline = user_is_online($userId);
// Trying double login.
if (!empty($loginData) && $userIsReallyOnline == true) {
session_regenerate_id();
Session::destroy();
header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=multiple_connection_not_allowed');
exit;
} else {
// First time
Session::write('first_user_login', 1);
}
}
}
}
}
示例3: startSession
/**
* Starts a chat session and returns JSON array of status and chat history
* @return void (prints output in JSON format)
*/
public function startSession()
{
$items = Session::read('chatHistory', []);
$return = array('user_status' => $this->get_user_status(), 'me' => get_lang('Me'), 'items' => $items);
echo json_encode($return);
exit;
}
示例4: display_success_message
/**
* Displays info stating that the message is sent successfully.
* @deprecated
*/
public static function display_success_message($uid)
{
$socialExist = Session::read('social_exist');
$userInfo = api_get_user_info($uid);
if (isset($socialExist) && $socialExist === true) {
if (api_get_setting('social.allow_social_tool') == 'true' && api_get_setting('message.allow_message_tool') == 'true') {
$success = get_lang('MessageSentTo') . " <b>" . $userInfo['complete_name'] . "</b>";
} else {
$success = get_lang('MessageSentTo') . " <b>" . $userInfo['complete_name'] . "</b>";
}
} else {
$success = get_lang('MessageSentTo') . " <b>" . $userInfo['complete_name'] . "</b>";
}
return Display::return_message(api_xml_http_response_encode($success), 'confirmation', false);
}
示例5: removeGeneratedAudioTempFile
/**
* Erase temp nanogong audio.
*/
public static function removeGeneratedAudioTempFile()
{
$tempAudio = Session::read('temp_audio_nanogong');
if (isset($tempAudio) && !empty($tempAudio) && is_file($tempAudio)) {
unlink($tempAudio);
Session::erase('temp_audio_nanogong');
}
}
示例6: api_is_student_view_active
function api_is_student_view_active()
{
$studentView = Session::read('studentview');
return $studentView == "studentview";
}
示例7: get_glossary_data
/**
* Get all the data of a glossary
*
* @param integer From which item
* @param integer Number of items to collect
* @param string Name of column on which to order
* @param string Whether to sort in ascending (ASC) or descending (DESC)
* @return unknown
*
* @author Patrick Cool <patrick.cool@ugent.be>
* @author Julio Montoya fixing this function, adding intvals
* @version januari 2009, dokeos 1.8.6
*/
public static function get_glossary_data($from, $number_of_items, $column, $direction)
{
$_user = api_get_user_info();
// Database table definition
$t_glossary = Database::get_course_table(TABLE_GLOSSARY);
$t_item_propery = Database::get_course_table(TABLE_ITEM_PROPERTY);
$glossaryView = Session::read('glossary_view');
if (api_is_allowed_to_edit(null, true)) {
$col2 = " glossary.glossary_id\tas col2, ";
} else {
$col2 = " ";
}
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, true, 'glossary.session_id');
$column = intval($column);
if (!in_array($direction, array('DESC', 'ASC'))) {
$direction = 'ASC';
}
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql = "SELECT\n glossary.name \t\t\tas col0,\n\t\t\t\t\tglossary.description \tas col1,\n\t\t\t\t\t{$col2}\n\t\t\t\t\tglossary.session_id\n\t\t\t\tFROM {$t_glossary} glossary, {$t_item_propery} ip\n\t\t\t\tWHERE\n\t\t\t\t glossary.glossary_id = ip.ref AND\n\t\t\t\t\ttool = '" . TOOL_GLOSSARY . "' {$condition_session} AND\n\t\t\t\t\tglossary.c_id = " . api_get_course_int_id() . " AND\n\t\t\t\t\tip.c_id = " . api_get_course_int_id() . "\n\t\t ORDER BY col{$column} {$direction}\n\t\t LIMIT {$from},{$number_of_items}";
$res = Database::query($sql);
$return = array();
$array = array();
while ($data = Database::fetch_array($res)) {
// Validation when belongs to a session
$session_img = api_get_session_image($data['session_id'], $_user['status']);
$array[0] = $data[0] . $session_img;
if (!$glossaryView || $glossaryView == 'table') {
$array[1] = str_replace(array('<p>', '</p>'), array('', '<br />'), $data[1]);
} else {
$array[1] = $data[1];
}
if (api_is_allowed_to_edit(null, true)) {
$array[2] = $data[2];
}
$return[] = $array;
}
return $return;
}
示例8: isset
$form_count = 0;
if (api_is_allowed_to_edit(false, true)) {
//if is called from a learning path lp_id
$lp_id = isset($_REQUEST['lp_id']) ? intval($_REQUEST['lp_id']) : null;
handle_forum_and_forumcategories($lp_id);
}
// Notification
if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) {
api_not_allowed();
}
$return_message = set_notification($_GET['content'], $_GET['id']);
Display::display_confirmation_message($return_message, false);
}
get_whats_new();
$whatsnew_post_info = Session::read('whatsnew_post_info');
/* TRACKING */
Event::event_access_tool(TOOL_FORUM);
/*
RETRIEVING ALL THE FORUM CATEGORIES AND FORUMS
note: we do this here just after het handling of the actions to be
sure that we already incorporate the latest changes
*/
// Step 1: We store all the forum categories in an array $forum_categories.
$forumCategories = get_forum_categories();
// Step 2: We find all the forums (only the visible ones if it is a student).
// display group forum in general forum tool depending to configuration option
$setting = api_get_setting('display_groups_forum_in_general_tool');
$forum_list = get_forums('', '', $setting == 'true');
$user_id = api_get_user_id();
/* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
示例9: get_thematic_advance_data
/**
* Get the thematic advances to display on the current page (fill the sortable-table)
* @param int offset of first user to recover
* @param int Number of users to get
* @param int Column to sort on
* @param string Order (ASC,DESC)
* @see SortableTable#get_table_data($from)
*/
public static function get_thematic_advance_data($from, $number_of_items, $column, $direction)
{
$thematic_id = Session::read('thematic_id');
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
$data = array();
$course_id = api_get_course_int_id();
if (api_is_allowed_to_edit(null, true)) {
$sql = "SELECT id AS col0, start_date AS col1, duration AS col2, content AS col3\n FROM {$tbl_thematic_advance}\n \t\t\t\tWHERE c_id = {$course_id} AND thematic_id = {$thematic_id}\n \t\t\t\tORDER BY col{$column} {$direction}\n \t\t\t\tLIMIT {$from},{$number_of_items} ";
$list = api_get_item_property_by_tool('thematic_advance', api_get_course_id(), api_get_session_id());
$elements = array();
foreach ($list as $value) {
$elements[] = $value['ref'];
}
$res = Database::query($sql);
$i = 1;
while ($thematic_advance = Database::fetch_row($res)) {
if (in_array($thematic_advance[0], $elements)) {
$thematic_advance[1] = api_get_local_time($thematic_advance[1]);
$thematic_advance[1] = api_format_date($thematic_advance[1], DATE_TIME_FORMAT_LONG);
$actions = '';
$actions .= '<a href="index.php?' . api_get_cidreq() . '&action=thematic_advance_edit&thematic_id=' . $thematic_id . '&thematic_advance_id=' . $thematic_advance[0] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', 22) . '</a>';
$actions .= '<a onclick="javascript:if(!confirm(\'' . get_lang('AreYouSureToDelete') . '\')) return false;" href="index.php?' . api_get_cidreq() . '&action=thematic_advance_delete&thematic_id=' . $thematic_id . '&thematic_advance_id=' . $thematic_advance[0] . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', 22) . '</a></center>';
$data[] = array($i, $thematic_advance[1], $thematic_advance[2], $thematic_advance[3], $actions);
$i++;
}
}
}
return $data;
}
示例10:
$term_preview = LegalManager::get_last_condition($language);
}
}
// Version and language
$form->addElement('hidden', 'legal_accept_type', $term_preview['version'] . ':' . $term_preview['language_id']);
$form->addElement('hidden', 'legal_info', $term_preview['legal_id'] . ':' . $term_preview['language_id']);
if ($term_preview['type'] == 1) {
$form->addElement('checkbox', 'legal_accept', null, get_lang('IHaveReadAndAgree') . ' <a href="inscription.php?legal" target="_blank">' . get_lang('TermsAndConditions') . '</a>');
$form->addRule('legal_accept', get_lang('ThisFieldIsRequired'), 'required');
} else {
$preview = LegalManager::show_last_condition($term_preview);
$form->addElement('label', null, $preview);
}
}
$form->addButtonCreate(get_lang('RegisterUser'));
$course_code_redirect = Session::read('course_redirect');
if ($form->validate()) {
$values = $form->getSubmitValues(1);
// Make *sure* the login isn't too long
if (isset($values['username'])) {
$values['username'] = api_substr($values['username'], 0, USERNAME_MAX_LENGTH);
}
if (api_get_setting('registration.allow_registration_as_teacher') == 'false') {
$values['status'] = STUDENT;
}
if (empty($values['official_code']) && !empty($values['username'])) {
$values['official_code'] = api_strtoupper($values['username']);
}
if (api_get_setting('profile.login_is_email') == 'true') {
$values['username'] = $values['email'];
}
示例11: isset
Display :: display_header(null);
echo '<div class="actions">';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) {
echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin.'">';
echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
if (!empty($my_folder_data['title'])) {
echo Display::page_subheader($my_folder_data['title']);
}
$error_message = Session::read('error_message');
if (!empty($error_message)) {
echo $error_message;
Session::erase('error_message');
}
if (!empty($my_folder_data['description'])) {
echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description']).'</p></div></p>';
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
switch ($action) {
case 'delete':
$fileDeleted = deleteWorkItem($item_id, $courseInfo);
示例12: time
$time_control = false;
$clock_expired_time = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
if ($objExercise->expired_time != 0 && !empty($clock_expired_time)) {
$time_control = true;
}
if ($time_control) {
// Get time left for exipiring time
$time_left = api_strtotime($clock_expired_time, 'UTC') - time();
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH) . 'javascript/epiclock/stylesheet/jquery.epiclock.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH) . 'javascript/epiclock/renderers/minute/epiclock.minute.css');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.dateformat.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/javascript/jquery.epiclock.min.js');
$htmlHeadXtra[] = api_get_js('epiclock/renderers/minute/epiclock.minute.js');
$htmlHeadXtra[] = $objExercise->show_time_control_js($time_left);
}
$exe_id = intval(Session::read('exe_id'));
$exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id);
if (!empty($exercise_stat_info['data_tracking'])) {
$question_list = explode(',', $exercise_stat_info['data_tracking']);
}
if (empty($exercise_stat_info) || empty($question_list)) {
api_not_allowed();
}
$nameTools = get_lang('Exercises');
$interbreadcrumb[] = array("url" => "exercise.php?" . api_get_cidreq(), "name" => get_lang('Exercises'));
if ($origin != 'learnpath') {
//so we are not in learnpath tool
Display::display_header($nameTools, get_lang('Exercise'));
} else {
Display::display_reduced_header();
}
示例13: isset
* and frames refresh
* @author Denes Nagy <darkden@freemail.hu> (original author - 2003-2004)
* @author Yannick Warnier <ywarnier@beeznest.org> (extended and maintained - 2005-2014)
* @version v 1.2
* @access public
* @package chamilo.learnpath.scorm
*/
// If you open the imsmanifest.xml via local machine (f.ex.: file://c:/...), then the Apiwrapper.js
// of Maritime Navigation when trying to execute this row
// var result = api.LMSInitialize("");
// get the error response : you are not authorized to call this function
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
//require_once '../inc/global.inc.php';
\Chamilo\CoreBundle\Framework\Container::$legacyTemplate = 'layout_empty.html.twig';
$file = Session::read('file');
/** @var learnpath $oLP */
$oLP = learnpath::getCurrentLpFromSession();
/** @var learnpathItem $oItem */
$oItem = isset($oLP->items[$oLP->current]) ? $oLP->items[$oLP->current] : null;
if (!is_object($oItem)) {
error_log('New LP - scorm_api - Could not load oItem item', 0);
exit;
}
$autocomplete_when_80pct = 0;
$user = api_get_user_info();
$userId = api_get_user_id();
header('Content-type: text/javascript');
?>
var scorm_logs=<?php
echo (empty($oLP->scorm_debug) or !api_is_course_admin() && !api_is_platform_admin()) ? '0' : '3';
示例14: createAnswersForm
/**
* function which redifines Question::createAnswersForm
* @param FormValidator $form
* @param the answers number to display
*/
function createAnswersForm($form)
{
// getting the exercise list
$obj_ex = Session::read('objExercise');
$editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
//this line define how many question by default appear when creating a choice question
$nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3;
// The previous default value was 2. See task #1759.
$nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
/*
Types of Feedback
$feedback_option[0]=get_lang('Feedback');
$feedback_option[1]=get_lang('DirectFeedback');
$feedback_option[2]=get_lang('NoFeedback');
*/
$feedback_title = '';
$comment_title = '';
if ($obj_ex->selectFeedbackType() == 1) {
$editor_config['Width'] = '250';
$editor_config['Height'] = '110';
$comment_title = '<th width="50%" >' . get_lang('Comment') . '</th>';
$feedback_title = '<th width="50%" >' . get_lang('Scenario') . '</th>';
} else {
$comment_title = '<th width="50%">' . get_lang('Comment') . '</th>';
}
$html = '<table class="table table-striped table-hover">';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th>' . get_lang('Number') . '</th>';
$html .= '<th>' . get_lang('True') . '</th>';
$html .= '<th width="50%">' . get_lang('Answer') . '</th>';
$html .= $comment_title . $feedback_title;
$html .= '<th>' . get_lang('Weighting') . '</th>';
$html .= '</tr>';
$html .= '</thead>';
$html .= '<tbody>';
$form->addHeader(get_lang('Answers'));
$form->addHtml($html);
$defaults = array();
$correct = 0;
$answer = false;
if (!empty($this->id)) {
$answer = new Answer($this->id);
$answer->read();
if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
$nb_answers = $answer->nbrAnswers;
}
}
$temp_scenario = array();
if ($nb_answers < 1) {
$nb_answers = 1;
Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
}
$editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : false;
if ($editQuestion) {
//fixing $nb_answers
$new_list = array();
$count = 1;
if (isset($_POST['lessAnswers'])) {
$lessFromSession = Session::read('less_answer');
if (!isset($lessFromSession)) {
Session::write('less_answer', $this->id);
$nb_answers--;
}
}
for ($k = 1; $k <= $nb_answers; ++$k) {
if ($answer->position[$k] != '666') {
$new_list[$count] = $count;
$count++;
}
}
} else {
for ($k = 1; $k <= $nb_answers; ++$k) {
$new_list[$k] = $k;
}
}
$i = 1;
//for ($k = 1 ; $k <= $real_nb_answers; $k++) {
foreach ($new_list as $key) {
$i = $key;
$form->addElement('html', '<tr>');
if (is_object($answer)) {
if ($answer->position[$i] == 666) {
//we set nothing
} else {
if ($answer->correct[$i]) {
$correct = $i;
}
$answer_result = $answer->answer[$i];
$weight_result = float_format($answer->weighting[$i], 1);
if ($nb_answers == $i) {
$weight_result = '0';
}
$defaults['answer[' . $i . ']'] = $answer_result;
$defaults['comment[' . $i . ']'] = $answer->comment[$i];
//.........这里部分代码省略.........
示例15: redirectToCourse
/**
* Direct course link see #5299
*
* You can send to your students an URL like this
* http://chamilodev.beeznest.com/main/auth/inscription.php?c=ABC&e=3
* Where "c" is the course code and "e" is the exercise Id, after a successful
* registration the user will be sent to the course or exercise
*
*/
public static function redirectToCourse($form_data)
{
$course_code_redirect = Session::read('course_redirect');
$_user = api_get_user_info();
$user_id = api_get_user_id();
if (!empty($course_code_redirect)) {
$course_info = api_get_course_info($course_code_redirect);
if (!empty($course_info)) {
if (in_array($course_info['visibility'], array(COURSE_VISIBILITY_OPEN_PLATFORM, COURSE_VISIBILITY_OPEN_WORLD))) {
if (CourseManager::is_user_subscribed_in_course($user_id, $course_info['code'])) {
$form_data['action'] = $course_info['course_public_url'];
$form_data['message'] = sprintf(get_lang('YouHaveBeenRegisteredToCourseX'), $course_info['title']);
$form_data['button'] = Display::button('next', get_lang('GoToCourse', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
$exercise_redirect = intval(Session::read('exercise_redirect'));
// Specify the course id as the current context does not
// hold a global $_course array
$objExercise = new Exercise($course_info['real_id']);
$result = $objExercise->read($exercise_redirect);
if (!empty($exercise_redirect) && !empty($result)) {
$form_data['action'] = api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?exerciseId=' . $exercise_redirect . '&cidReq=' . $course_info['code'];
$form_data['message'] .= '<br />' . get_lang('YouCanAccessTheExercise');
$form_data['button'] = Display::button('next', get_lang('Go', null, $_user['language']), array('class' => 'btn btn-primary btn-large'));
}
if (!empty($form_data['action'])) {
header('Location: ' . $form_data['action']);
exit;
}
}
}
}
}
return $form_data;
}