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


PHP SessionManager::get_session_by_name方法代码示例

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


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

示例1: add

 /**
  * Creates a session
  * @param array Fields to use in the creation of the session
  * @param boolean Whether to allow for same-name sessions or not.
  * @assert (array()) === false
  */
 public static function add($params, $allow_homonyms = false)
 {
     global $_configuration;
     //just in case
     if (isset($params['id'])) {
         unset($params['id']);
     }
     //Check portal limits
     $access_url_id = 1;
     if (api_is_multiple_url_enabled()) {
         $access_url_id = api_get_current_access_url_id();
     }
     if (is_array($_configuration[$access_url_id]) && isset($_configuration[$access_url_id]['hosting_limit_sessions']) && $_configuration[$access_url_id]['hosting_limit_sessions'] > 0) {
         $num = self::count_sessions();
         if ($num >= $_configuration[$access_url_id]['hosting_limit_sessions']) {
             return get_lang('PortalSessionsLimitReached');
         }
     }
     if (!$allow_homonyms) {
         $my_session_result = SessionManager::get_session_by_name($params['name']);
         $session_id = null;
         if ($my_session_result == false) {
             $session_model = new SessionModel();
             $session_id = $session_model->save($params);
         } else {
             error_log('Session already exists with name: ' . $params['name'] . " session_id: " . $my_session_result['id']);
         }
     } else {
         //with the allow_homonyms option, two sessions can share names
         $session_model = new SessionModel();
         $session_id = $session_model->save($params);
     }
     if (!empty($session_id)) {
         /*
         Sends a message to the user_id = 1
         
         $user_info = api_get_user_info(1);
         $complete_name = $user_info['firstname'].' '.$user_info['lastname'];
         $subject = api_get_setting('siteName').' - '.get_lang('ANewSessionWasCreated');
         $message = get_lang('ANewSessionWasCreated')." <br /> ".get_lang('NameOfTheSession').' : '.$name;
         api_mail_html($complete_name, $user_info['email'], $subject, $message);
         *
         */
         //Saving extra fields
         $session_field_value = new SessionFieldValue();
         $params['session_id'] = $session_id;
         $session_field_value->save_field_values($params);
         //Adding to the correct URL
         $access_url_id = api_get_current_access_url_id();
         UrlManager::add_session_to_url($session_id, $access_url_id);
         // Add event to system log
         event_system(LOG_SESSION_CREATE, LOG_SESSION_ID, $session_id, api_get_utc_datetime(), api_get_user_id());
         if (isset($params['course_code'])) {
             $courseInfo = api_get_course_info($params['course_code']);
             self::add_courses_to_session($session_id, array($courseInfo['real_id']));
             //Update default course gradebook to the session if exists
             $create_gradebook_evaluation = isset($params['create_gradebook_evaluation']) ? $params['create_gradebook_evaluation'] : false;
             if ($create_gradebook_evaluation) {
                 require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php';
                 $category_id = create_default_course_gradebook($params['course_code'], false, $session_id);
                 /*
                                     if ($category_id && isset($params['gradebook_params'])) {
                                         $eval = new Evaluation();
                                         $eval->set_name($params['gradebook_params']['name']);
                                         $eval->set_user_id($params['gradebook_params']['user_id']);
                                         $eval->set_course_code($params['course_code']);
                                         $eval->set_category_id($category_id);
                                         $eval->set_weight($params['gradebook_params']['weight']);
                                         $eval->set_max($params['gradebook_params']['max']);
                                         $eval->set_visible(0);
                                         $eval->add();
                                     }*/
                 /*$tbl_gradebook_category = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
                   $sql = "SELECT id FROM $tbl_gradebook_category WHERE course_code = {$params['course_code']} AND session_id = 0 LIMIT 1";
                   $result = Database::query($sql);
                   if (Database::num_rows($result)) {
                       $gradebook_data = Database::fetch_array($result, 'ASSOC');
                       if (!empty($gradebook_data)) {
                           $sql = "UPDATE SET session_id = $session_id WHERE id = {$gradebook_data['id']}";
                           Database::query($sql);
                       }
                   }*/
             }
         }
     } else {
         if (isset($params['return_item_if_already_exists']) && $params['return_item_if_already_exists']) {
             $my_session_result = SessionManager::get_session_by_name($params['name']);
             $session_id = $my_session_result['id'];
         }
     }
     return $session_id;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:98,代码来源:sessionmanager.lib.php

示例2: importCSV


//.........这里部分代码省略.........
                 }
                 $sessionCondition = '';
                 if (!empty($session_category_id)) {
                     $sessionCondition = "session_category_id = '{$session_category_id}',";
                 }
                 // Creating the session.
                 $sql = "INSERT IGNORE INTO {$tbl_session} SET\n                            name = '" . $session_name . "',\n                            id_coach = '{$coach_id}',\n                            access_start_date = '{$date_start}',\n                            access_end_date = '{$date_end}',\n                            visibility = '{$visibilityAfterExpirationPerSession}',\n                            {$sessionCondition}\n                            session_admin_id = " . intval($defaultUserId) . $extraParameters . $extraSessionParameters;
                 Database::query($sql);
                 $session_id = Database::insert_id();
                 if ($debug) {
                     if ($session_id) {
                         foreach ($enreg as $key => $value) {
                             if (substr($key, 0, 6) == 'extra_') {
                                 //an extra field
                                 self::update_session_extra_field_value($session_id, substr($key, 6), $value);
                             }
                         }
                         $logger->addInfo("Sessions - Session created: #{$session_id} - {$session_name}");
                     } else {
                         $logger->addError("Sessions - Session NOT created: {$session_name}");
                     }
                 }
                 $session_counter++;
             } else {
                 $sessionId = null;
                 if (isset($extraFields) && !empty($extraFields) && !empty($enreg['extra_' . $extraFieldId])) {
                     $sessionId = self::getSessionIdFromOriginalId($enreg['extra_' . $extraFieldId], $extraFieldId);
                     if (empty($sessionId)) {
                         $my_session_result = false;
                     } else {
                         $my_session_result = true;
                     }
                 } else {
                     $my_session_result = self::get_session_by_name($enreg['SessionName']);
                 }
                 if ($my_session_result === false) {
                     // Creating a session.
                     $sql = "INSERT IGNORE INTO {$tbl_session} SET\n                                name = '{$session_name}',\n                                id_coach = '{$coach_id}',\n                                access_start_date = '{$date_start}',\n                                access_end_date = '{$date_end}',\n                                visibility = '{$visibilityAfterExpirationPerSession}',\n                                session_category_id = '{$session_category_id}' " . $extraParameters . $extraSessionParameters;
                     Database::query($sql);
                     // We get the last insert id.
                     $my_session_result = SessionManager::get_session_by_name($enreg['SessionName']);
                     $session_id = $my_session_result['id'];
                     if ($session_id) {
                         foreach ($enreg as $key => $value) {
                             if (substr($key, 0, 6) == 'extra_') {
                                 //an extra field
                                 self::update_session_extra_field_value($session_id, substr($key, 6), $value);
                             }
                         }
                         if ($debug) {
                             $logger->addInfo("Sessions - #{$session_id} created: {$session_name}");
                         }
                         // Delete session-user relation only for students
                         $sql = "DELETE FROM {$tbl_session_user}\n                                    WHERE session_id = '{$session_id}' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH;
                         Database::query($sql);
                         $sql = "DELETE FROM {$tbl_session_course} WHERE session_id = '{$session_id}'";
                         Database::query($sql);
                         // Delete session-course-user relationships students and coaches.
                         if ($updateCourseCoaches) {
                             $sql = "DELETE FROM {$tbl_session_course_user}\n                                        WHERE session_id = '{$session_id}' AND status in ('0', '2')";
                             Database::query($sql);
                         } else {
                             // Delete session-course-user relation ships *only* for students.
                             $sql = "DELETE FROM {$tbl_session_course_user}\n                                        WHERE session_id = '{$session_id}' AND status <> 2";
                             Database::query($sql);
                         }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:67,代码来源:sessionmanager.lib.php

示例3: intval

         $rs = Database::query($sql);
         if (Database::result($rs, 0, 0)) {
             $i++;
         } else {
             $unique_name = true;
             $session_name .= $suffix;
         }
     }
     // Creating the session.
     $sql_session = "INSERT IGNORE INTO {$tbl_session} SET\n                                    name = '" . Database::escape_string($session_name) . "',\n                                    id_coach = '{$coach_id}',\n                                    date_start = '{$date_start}',\n                                    date_end = '{$date_end}',\n                                    visibility = '{$visibility}',\n                                    session_category_id = '{$session_category_id}',\n                                    session_admin_id=" . intval($_user['user_id']);
     $rs_session = Database::query($sql_session);
     $session_id = Database::insert_id();
     $session_counter++;
 } else {
     // Update the session if it is needed.
     $my_session_result = SessionManager::get_session_by_name($session_name);
     if ($my_session_result === false) {
         // Creating the session.
         $sql_session = "INSERT IGNORE INTO {$tbl_session} SET\n                                        name = '" . Database::escape_string($session_name) . "',\n                                        id_coach = '{$coach_id}',\n                                        date_start = '{$date_start}',\n                                        date_end = '{$date_end}',\n                                        visibility = '{$visibility}',\n                                        session_category_id = '{$session_category_id}',\n                                        session_admin_id=" . intval($_user['user_id']);
         $rs_session = Database::query($sql_session);
         $session_id = Database::insert_id();
         $session_counter++;
     } else {
         // if the session already exists - update it.
         $sql_session = "UPDATE {$tbl_session} SET\n                                        id_coach = '{$coach_id}',\n                                        date_start = '{$date_start}',\n                                        date_end = '{$date_end}',\n                                        visibility = '{$visibility}',\n                                        session_category_id = '{$session_category_id}'\n                                    WHERE name = '{$session_name}'";
         $rs_session = Database::query($sql_session);
         $session_id = Database::query("SELECT id FROM {$tbl_session} WHERE name='{$session_name}'");
         list($session_id) = Database::fetch_array($session_id);
         Database::query("DELETE FROM {$tbl_session_user} WHERE id_session='{$session_id}'");
         Database::query("DELETE FROM {$tbl_session_course} WHERE id_session='{$session_id}'");
         Database::query("DELETE FROM {$tbl_session_course_user} WHERE id_session='{$session_id}'");
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:session_import.php

示例4: check_session_name

function check_session_name($name)
{
    $session = SessionManager::get_session_by_name($name);
    return empty($session) ? true : false;
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:5,代码来源:session_add.php


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