当前位置: 首页>>代码示例>>PHP>>正文


PHP ChamiloSession::write方法代码示例

本文整理汇总了PHP中ChamiloSession::write方法的典型用法代码示例。如果您正苦于以下问题:PHP ChamiloSession::write方法的具体用法?PHP ChamiloSession::write怎么用?PHP ChamiloSession::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ChamiloSession的用法示例。


在下文中一共展示了ChamiloSession::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
                }
            }
        }
    }
}
开发者ID:daffef,项目名称:chamilo-lms,代码行数:32,代码来源:online.inc.php

示例2: login

 /**
  * Create a Shibboleth session for the user ID
  *
  * @param  string $uid - The user ID
  * @return $_user (array) - The user infos array created when the user logs in
  */
 function login($uid)
 {
     /* This must be set for local.inc.php to register correctly the global variables in session
      * This is BAD. Logic should be migrated into a function and stop relying on global variables.
      */
     global $_uid, $is_allowedCreateCourse, $_real_cid, $_courseUser;
     global $is_courseMember, $is_courseTutor, $is_allowed_in_course, $_gid;
     $_uid = $uid;
     //is_allowedCreateCourse
     $user = User::store()->get_by_user_id($uid);
     if (empty($user)) {
         return;
     }
     $this->logout();
     Chamilo::session()->start();
     Session::write('_uid', $_uid);
     global $_user;
     $_user = (array) $user;
     $_SESSION['_user'] = $_user;
     $_SESSION['_user']['user_id'] = $_uid;
     $_SESSION['noredirection'] = true;
     //must be called before 'init_local.inc.php'
     event_login();
     //used in 'init_local.inc.php' this is BAD but and should be changed
     $loginFailed = false;
     $uidReset = true;
     $gidReset = true;
     $cidReset = false;
     //FALSE !!
     $mainDbName = Database::get_main_database();
     $includePath = api_get_path(INCLUDE_PATH);
     $no_redirection = true;
     require "{$includePath}/local.inc.php";
     return $_user;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:41,代码来源:shibboleth_session.class.php

示例3: xajaxResponse

 /**
  * Search for a session based on a given search string
  * @param string A search string
  * @param string A search box type (single or anything else)
  * @return string XajaxResponse
  * @assert () !== ''
  * @assert ('abc','single') !== ''
  */
 function search_courses($needle, $type)
 {
     $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
     $xajax_response = new xajaxResponse();
     $return = '';
     if (!empty($needle) && !empty($type)) {
         // xajax send utf8 datas... datas in db can be non-utf8 datas
         $charset = api_get_system_encoding();
         $needle = api_convert_encoding($needle, $charset, 'utf-8');
         $needle = Database::escape_string($needle);
         $sql = 'SELECT * FROM ' . $tbl_session . ' WHERE name LIKE "' . $needle . '%" ORDER BY id';
         $rs = Database::query($sql);
         $course_list = array();
         $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
         while ($course = Database::fetch_array($rs)) {
             $course_list[] = $course['id'];
             $return .= '<option value="' . $course['id'] . '" title="' . htmlspecialchars($course['name'], ENT_QUOTES) . '">' . $course['name'] . '</option>';
         }
         $return .= '</select>';
         $xajax_response->addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
     }
     Session::write('course_list', $course_list);
     return $xajax_response;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:32,代码来源:add_many_session_to_category_functions.lib.php

示例4: reuseQuestionAction

 /**
  * @param Application $app
  * @param int $exerciseId
  * @param int $questionId
  * @return Response
  */
 public function reuseQuestionAction(Application $app, $exerciseId, $questionId)
 {
     /** @var \Question $question */
     $question = \Question::read($questionId);
     if ($question) {
         // adds the exercise ID represented by $fromExercise into the list of exercises for the current question
         $question->addToList($exerciseId);
         $objExercise = new \Exercise();
         $objExercise->read($exerciseId);
         // adds the question ID represented by $recup into the list of questions for the current exercise
         $objExercise->addToList($exerciseId);
         Session::write('objExercise', $objExercise);
         /*$params = array(
               'cidReq' => api_get_course_id(),
               'id_session' => api_get_session_id(),
               'id' => $questionId,
               'exerciseId' => $exerciseId
           );
           $url = $app['url_generator']->generate('exercise_question_pool', $params);
           return $app->redirect($url);*/
         $response = \Display::return_message(get_lang('QuestionReused') . ": " . $question->question);
         return new Response($response, 200, array());
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:30,代码来源:ExerciseController.php

示例5: setDisableChat

 /**
  * SET Disable Chat
  * @param boolean status to disable chat
  * @return void
  */
 public static function setDisableChat($status = true)
 {
     Session::write('disable_chat', $status);
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:9,代码来源:chat.lib.php

示例6: header

             $message = Display::return_message(get_lang('CannotCreateDir'), 'error');
         }
         Session::write('message', $message);
         header('Location: ' . $currentUrl);
         exit;
     } else {
         $content = $form->return_form();
     }
     break;
 case 'delete_dir':
     if ($is_allowed_to_edit) {
         $work_to_delete = get_work_data_by_id($_REQUEST['id']);
         $result = deleteDirWork($_REQUEST['id']);
         if ($result) {
             $message = Display::return_message(get_lang('DirDeleted') . ': ' . $work_to_delete['title'], 'success');
             Session::write('message', $message);
         }
         header('Location: ' . $currentUrl);
         exit;
     }
     break;
 case 'move':
     /*	Move file form request */
     if ($is_allowed_to_edit) {
         if (!empty($item_id)) {
             $content = generateMoveForm($item_id, $curdirpath, $course_info, $group_id, $session_id);
         }
     }
     break;
 case 'move_to':
     /* Move file command */
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:work.php

示例7: array

<?php

/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
 *	This file allows creating new svg and png documents with an online editor.
 *
 *	@package chamilo.document
 *
 * @author Juan Carlos Raña Trabado herodoto@telefonica.net
 * @since 5/mar/2011
*/
//require_once '../inc/global.inc.php';
Session::write('whereami', 'document/voicerecord');
$this_section = SECTION_COURSES;
$nameTools = get_lang('VoiceRecord');
api_protect_course_script();
api_block_anonymous_users();
$groupId = api_get_group_id();
$document_data = array();
if (isset($_GET['id'])) {
    $document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
}
if (empty($document_data)) {
    if (api_is_in_group()) {
        $group_properties = GroupManager::get_group_properties($groupId);
        $document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
        $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
    }
}
$document_id = $document_data['id'];
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:record_audio.php

示例8: rl_get_resource_link_for_learnpath


//.........这里部分代码省略.........
    switch ($type) {
        case 'dokeos_chapter':
            $link .= $main_dir_path . 'newscorm/blank.php';
        case TOOL_CALENDAR_EVENT:
            $link .= $main_dir_path . 'calendar/agenda.php?origin=' . $origin . '&agenda_id=' . $id;
            break;
        case TOOL_ANNOUNCEMENT:
            $link .= $main_dir_path . 'announcements/announcements.php?origin=' . $origin . '&ann_id=' . $id;
            break;
        case TOOL_LINK:
            $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
            $result = Database::query("SELECT * FROM {$TABLETOOLLINK} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $thelink = $myrow["url"];
            $link .= $thelink;
            break;
        case TOOL_QUIZ:
            if (!empty($id)) {
                $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
                $sql = "SELECT * FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND id={$id}";
                $result = Database::query($sql);
                $myrow = Database::fetch_array($result);
                if ($row_item['title'] != '') {
                    $myrow['title'] = $row_item['title'];
                }
                $link .= $main_dir_path . 'exercice/overview.php?cidReq=' . $course_code . '&session_id=' . $session_id . '&lp_init=1&origin=' . $origin . '&learnpath_id=' . $learnpath_id . '&learnpath_item_id=' . $id_in_path . '&exerciseId=' . $id;
            }
            break;
        case 'hotpotatoes':
            //lowercase because of strtolower above
            $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
            $result = Database::query("SELECT * FROM " . $TBL_DOCUMENT . " WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $path = $myrow['path'];
            $link .= $main_dir_path . 'exercice/showinframes.php?file=' . $path . '' . '&origin=' . $origin . '&cid=' . $course_code . '&uid=' . api_get_user_id() . '' . '&learnpath_id=' . $learnpath_id . '&learnpath_item_id=' . $id_in_path . '&lp_view_id=' . $lpViewId;
            break;
        case TOOL_FORUM:
            $link .= $main_dir_path . 'forum/viewforum.php?forum=' . $id . '&lp=true&origin=learnpath';
            break;
        case TOOL_THREAD:
            //forum post
            $tbl_topics = Database::get_course_table(TABLE_FORUM_THREAD);
            if (!empty($id)) {
                $sql = "SELECT * FROM {$tbl_topics} WHERE c_id = {$course_id} AND thread_id={$id}";
                $result = Database::query($sql);
                $myrow = Database::fetch_array($result);
                $link .= $main_dir_path . 'forum/viewthread.php?origin=learnpath&thread=' . $id . '' . '&forum=' . $myrow['forum_id'] . '&lp=true';
            }
            break;
        case TOOL_POST:
            $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
            $result = Database::query("SELECT * FROM {$tbl_post} WHERE c_id = {$course_id} AND post_id={$id}");
            $myrow = Database::fetch_array($result);
            $title = $myrow['post_title'];
            //$desc = $row_item['description'];
            $posternom = $myrow['poster_name'];
            $posttime = $myrow['post_date'];
            $posttext = $myrow['post_text'];
            $posttitle = $title;
            $posttext = str_replace('"', "'", $posttext);
            $link .= $main_dir_path . 'forum/viewthread.php?post=' . $id . '' . '&thread=' . $myrow['thread_id'] . '&forum=' . $myrow['forum_id'] . '' . '&lp=true';
            break;
        case TOOL_DOCUMENT:
            $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
            $sql = "SELECT * FROM {$tbl_doc} WHERE c_id = {$course_id} AND id = {$id}";
            $result = Database::query($sql);
            $myrow = Database::fetch_array($result);
            $docurl = str_replace('%2F', '/', urlencode($myrow['path']));
            $link .= $main_course_path . 'document' . $docurl . '?cidReq=' . $course_code . '&id_session=' . $session_id;
            $openmethod = 2;
            $officedoc = false;
            Session::write('openmethod', $openmethod);
            Session::write('officedoc', $officedoc);
            break;
        case 'assignments':
            $link .= $main_dir_path . 'work/work.php?origin=' . $origin;
            break;
        case TOOL_DROPBOX:
            $link .= $main_dir_path . 'dropbox/index.php?origin=learnpath';
            break;
        case 'introduction_text':
            //DEPRECATED
            $link .= '';
            break;
        case TOOL_COURSE_DESCRIPTION:
            $link .= $main_dir_path . 'course_description?origin=learnpath';
            break;
        case TOOL_GROUP:
            $link .= $main_dir_path . 'group/group.php?origin=' . $origin;
            break;
        case TOOL_USER:
            $link .= $main_dir_path . 'user/user.php?origin=' . $origin;
            break;
        case 'student_publication':
            $link .= $main_dir_path . 'work/work.php?origin=learnpath';
            break;
    }
    //end switch
    return $link;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:101,代码来源:resourcelinker.inc.php

示例9: generateAudioTempFile

 /**
  * Sets
  * @param string $file ($document_data['path'])
  * @param string $file_url_sys
  * @return string
  */
 public static function generateAudioTempFile($file, $file_url_sys)
 {
     //make temp audio
     $temp_folder = api_get_path(SYS_ARCHIVE_PATH) . 'temp/audio';
     if (!file_exists($temp_folder)) {
         @mkdir($temp_folder, api_get_permissions_for_new_directories(), true);
     }
     //make htaccess with allow from all, and file index.html into temp/audio
     $htaccess = api_get_path(SYS_ARCHIVE_PATH) . 'temp/audio/.htaccess';
     if (!file_exists($htaccess)) {
         $htaccess_content = "order deny,allow\r\nallow from all\r\nOptions -Indexes";
         $fp = @fopen(api_get_path(SYS_ARCHIVE_PATH) . 'temp/audio/.htaccess', 'w');
         if ($fp) {
             fwrite($fp, $htaccess_content);
             fclose($fp);
         }
     }
     //encript temp name file
     $name_crip = sha1(uniqid());
     //encript
     $findext = explode(".", $file);
     $extension = $findext[count($findext) - 1];
     $file_crip = $name_crip . '.' . $extension;
     //copy file to temp/audio directory
     $from_sys = $file_url_sys;
     $to_sys = api_get_path(SYS_ARCHIVE_PATH) . 'temp/audio/' . $file_crip;
     if (file_exists($from_sys)) {
         copy($from_sys, $to_sys);
     }
     //get  file from tmp directory
     Session::write('temp_audio_nanogong', $to_sys);
     return api_get_path(WEB_ARCHIVE_PATH) . 'temp/audio/' . $file_crip;
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:39,代码来源:document.lib.php

示例10: 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];
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:unique_answer_no_option.class.php

示例11: display_glossary

 /**
  * This is the main function that displays the list or the table with all
  * the glossary terms
  * @param  string  View ('table' or 'list'). Optional parameter.
  * Defaults to 'table' and prefers glossary_view from the session by default.
  * @return void
  * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
  * @version januari 2009, dokeos 1.8.6
  */
 public static function display_glossary($view = 'table')
 {
     // This function should always be called with the corresponding
     // parameter for view type. Meanwhile, use this cheap trick.
     $glossaryView = Session::read('glossary_view');
     if (empty($glossaryView)) {
         Session::write('glossary_view', $view);
     }
     // action links
     echo '<div class="actions">';
     if (api_is_allowed_to_edit(null, true)) {
         echo '<a href="index.php?' . api_get_cidreq() . '&action=addglossary&msg=add?' . api_get_cidreq() . '">' . Display::return_icon('new_glossary_term.png', get_lang('TermAddNew'), '', ICON_SIZE_MEDIUM) . '</a>';
     }
     echo '<a href="index.php?' . api_get_cidreq() . '&action=export">' . Display::return_icon('export_csv.png', get_lang('ExportGlossaryAsCSV'), '', ICON_SIZE_MEDIUM) . '</a>';
     if (api_is_allowed_to_edit(null, true)) {
         echo '<a href="index.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('ImportGlossary'), '', ICON_SIZE_MEDIUM) . '</a>';
     }
     echo '<a href="index.php?' . api_get_cidreq() . '&action=export_to_pdf">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a>';
     if (isset($glossaryView) && $glossaryView == 'table' or !isset($glossaryView)) {
         echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=list">' . Display::return_icon('view_detailed.png', get_lang('ListView'), '', ICON_SIZE_MEDIUM) . '</a>';
     } else {
         echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=table">' . Display::return_icon('view_text.png', get_lang('TableView'), '', ICON_SIZE_MEDIUM) . '</a>';
     }
     echo '</div>';
     if (!$glossaryView || $glossaryView == 'table') {
         $table = new SortableTable('glossary', array('GlossaryManager', 'get_number_glossary_terms'), array('GlossaryManager', 'get_glossary_data'), 0);
         //$table->set_header(0, '', false);
         $table->set_header(0, get_lang('TermName'), true);
         $table->set_header(1, get_lang('TermDefinition'), true);
         if (api_is_allowed_to_edit(null, true)) {
             $table->set_header(2, get_lang('Actions'), false, 'width=90px', array('class' => 'td_actions'));
             $table->set_column_filter(2, array('GlossaryManager', 'actions_filter'));
         }
         $table->display();
     }
     if ($glossaryView == 'list') {
         GlossaryManager::display_glossary_list();
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:48,代码来源:glossary.lib.php

示例12: calc_score

 /**
  * Calculate the score of this evaluation
  * @param int $stud_id (default: all students who have results for this eval - then the average is returned)
  * @param string $type (best, average, ranking)
  * @return	array (score, max) if student is given
  * 			array (sum of scores, number of scores) otherwise
  * 			or null if no scores available
  */
 public function calc_score($stud_id = null, $type = null)
 {
     $useSession = true;
     if (isset($stud_id) && empty($type)) {
         $key = 'result_score_student_list_' . api_get_course_int_id() . '_' . api_get_session_id() . '_' . $this->id . '_' . $stud_id;
         $data = Session::read('calc_score');
         $results = isset($data[$key]) ? $data[$key] : null;
         if ($useSession == false) {
             $results = null;
         }
         if (empty($results)) {
             $results = Result::load(null, $stud_id, $this->id);
             Session::write('calc_score', array($key => $results));
         }
         $score = 0;
         /** @var Result $res */
         foreach ($results as $res) {
             $score = $res->get_score();
         }
         return array($score, $this->get_max());
     } else {
         $count = 0;
         $sum = 0;
         $bestResult = 0;
         $weight = 0;
         $sumResult = 0;
         $key = 'result_score_student_list_' . api_get_course_int_id() . '_' . api_get_session_id() . '_' . $this->id;
         $data = Session::read('calc_score');
         $allResults = isset($data[$key]) ? $data[$key] : null;
         if ($useSession == false) {
             $allResults = null;
         }
         if (empty($allResults)) {
             $allResults = Result::load(null, null, $this->id);
             Session::write($key, $allResults);
         }
         $students = array();
         /** @var Result $res */
         foreach ($allResults as $res) {
             $score = $res->get_score();
             if (!empty($score) || $score == '0') {
                 $count++;
                 $sum += $score / $this->get_max();
                 $sumResult += $score;
                 if ($score > $bestResult) {
                     $bestResult = $score;
                 }
                 $weight = $this->get_max();
             }
             $students[$res->get_user_id()] = $score;
         }
         if (empty($count)) {
             return null;
         }
         switch ($type) {
             case 'best':
                 return array($bestResult, $weight);
                 break;
             case 'average':
                 return array($sumResult / $count, $weight);
                 break;
             case 'ranking':
                 $students = array();
                 /** @var Result $res */
                 foreach ($allResults as $res) {
                     $score = $res->get_score();
                     $students[$res->get_user_id()] = $score;
                 }
                 return AbstractLink::getCurrentUserRanking($stud_id, $students);
                 break;
             default:
                 return array($sum, $count);
                 break;
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:84,代码来源:evaluation.class.php

示例13: array

$(function() {
<?php 
// grid definition see the $career->display() function
echo Display::grid_js('careers', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
?>
});
</script>
<?php 
$career = new Career();
// Action handling: Add
switch ($action) {
    case 'add':
        if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
            api_not_allowed();
        }
        Session::write('notebook_view', 'creation_date');
        $url = api_get_self() . '?action=' . Security::remove_XSS($_GET['action']);
        $form = $career->return_form($url, 'add');
        // The validation or display
        if ($form->validate()) {
            if ($check) {
                $values = $form->exportValues();
                $res = $career->save($values);
                if ($res) {
                    Display::display_confirmation_message(get_lang('ItemAdded'));
                }
            }
            $career->display();
        } else {
            echo '<div class="actions">';
            echo '<a href="' . api_get_self() . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>';
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:careers.php

示例14: loginUser

/**
*	Make sure this function is protected because it does NOT check password!
*
*	This function defines globals.
*   @param  int     $userId
 *
*   @return bool    False on failure, redirection on success
*	@author Evie Embrechts
*   @author Yannick Warnier <yannick.warnier@dokeos.com>
*/
function loginUser($userId)
{
    $userId = intval($userId);
    $userInfo = api_get_user_info($userId);
    // Check if the user is allowed to 'login_as'
    $canLoginAs = api_can_login_as($userId);
    if (!$canLoginAs || empty($userInfo)) {
        return false;
    }
    $firstname = $userInfo['firstname'];
    $lastname = $userInfo['lastname'];
    if (api_is_western_name_order()) {
        $message = sprintf(get_lang('AttemptingToLoginAs'), $firstname, $lastname, $userId);
    } else {
        $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId);
    }
    if ($userId) {
        // Logout the current user
        LoginDelete(api_get_user_id());
        Session::erase('_user');
        Session::erase('is_platformAdmin');
        Session::erase('is_allowedCreateCourse');
        Session::erase('_uid');
        // Cleaning session variables
        $_user['firstName'] = $userInfo['firstname'];
        $_user['lastName'] = $userInfo['lastname'];
        $_user['mail'] = $userInfo['email'];
        //$_user['lastLogin'] = $user_data['login_date'];
        $_user['official_code'] = $userInfo['official_code'];
        $_user['picture_uri'] = $userInfo['picture_uri'];
        $_user['user_id'] = $userId;
        $_user['id'] = $userId;
        $_user['status'] = $userInfo['status'];
        // Filling session variables with new data
        Session::write('_uid', $userId);
        Session::write('_user', $userInfo);
        Session::write('is_platformAdmin', (bool) UserManager::is_admin($userId));
        Session::write('is_allowedCreateCourse', (bool) ($userInfo['status'] == 1));
        // will be useful later to know if the user is actually an admin or not (example reporting)
        Session::write('login_as', true);
        $target_url = api_get_path(WEB_PATH) . "user_portal.php";
        $message .= '<br />' . sprintf(get_lang('LoginSuccessfulGoToX'), '<a href="' . $target_url . '">' . $target_url . '</a>');
        Display::display_header(get_lang('UserList'));
        Display::display_normal_message($message, false);
        Display::display_footer();
        exit;
    }
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:58,代码来源:user_list.php

示例15: ldap_put_user_info_locally

/**
*    This function uses the data from ldap_find_user_info()
*    to add the userdata to Chamilo
*    "firstname", "name", "email", "isEmployee"
*    @author Roan Embrechts
*/
function ldap_put_user_info_locally($login, $info_array)
{
    //error_log('Entering ldap_put_user_info_locally('.$login.',info_array)',0);
    global $ldap_pass_placeholder;
    global $submitRegistration, $submit, $uname, $email, $nom, $prenom, $password, $password1, $status;
    global $platformLanguage;
    global $loginFailed, $uidReset, $_user;
    /*----------------------------------------------------------
          1. set the necessary variables
      ------------------------------------------------------------ */
    $uname = $login;
    $email = $info_array["email"];
    $nom = $info_array["name"];
    $prenom = $info_array["firstname"];
    $password = $ldap_pass_placeholder;
    $password1 = $ldap_pass_placeholder;
    $official_code = '';
    define("STUDENT", 5);
    define("COURSEMANAGER", 1);
    $tutor_field = api_get_setting('ldap_filled_tutor_field');
    $tutor_value = api_get_setting('ldap_filled_tutor_field_value');
    if (empty($tutor_field)) {
        $status = STUDENT;
    } else {
        if (empty($tutor_value)) {
            //in this case, we are assuming that the admin didn't give a criteria
            // so that if the field is not empty, it is a tutor
            if (!empty($info_array[$tutor_field])) {
                $status = COURSEMANAGER;
            } else {
                $status = STUDENT;
            }
        } else {
            //the tutor_value is filled, so we need to check the contents of the LDAP field
            if (is_array($info_array[$tutor_field]) && in_array($tutor_value, $info_array[$tutor_field])) {
                $status = COURSEMANAGER;
            } else {
                $status = STUDENT;
            }
        }
    }
    //$official_code = xxx; //example: choose an attribute
    /*----------------------------------------------------------
          2. add info to Chamilo
      ------------------------------------------------------------ */
    $language = api_get_setting('platformLanguage');
    if (empty($language)) {
        $language = 'english';
    }
    $_userId = UserManager::create_user($prenom, $nom, $status, $email, $uname, $password, $official_code, $language, '', '', 'ldap');
    //echo "new user added to Chamilo, id = $_userId";
    //user_id, username, password, auth_source
    /*----------------------------------------------------------
          3. register session
      ------------------------------------------------------------ */
    $uData['user_id'] = $_userId;
    $uData['username'] = $uname;
    $uData['auth_source'] = "ldap";
    $loginFailed = false;
    $uidReset = true;
    $_user['user_id'] = $uData['user_id'];
    Session::write('_uid', $_uid);
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:69,代码来源:authldap.php


注:本文中的ChamiloSession::write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。