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


PHP SessionManager::getDayLeftInSession方法代码示例

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


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

示例1: get_session_title_box

 /**
  * Get the session box details as an array
  * @param int       Session ID
  * @return array    Empty array or session array
  * ['title'=>'...','category'=>'','dates'=>'...','coach'=>'...','active'=>true/false,'session_category_id'=>int]
  */
 public static function get_session_title_box($session_id)
 {
     global $nosession;
     if (!$nosession) {
         global $now, $date_start, $date_end;
     }
     $output = array();
     if (!$nosession) {
         $main_user_table = Database::get_main_table(TABLE_MAIN_USER);
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
         $active = false;
         // Request for the name of the general coach
         $sql = 'SELECT tu.lastname, tu.firstname, ts.*
                 FROM ' . $tbl_session . ' ts
                 LEFT JOIN ' . $main_user_table . ' tu
                 ON ts.id_coach = tu.user_id
                 WHERE ts.id = ' . intval($session_id);
         $rs = Database::query($sql);
         $session_info = Database::store_result($rs, 'ASSOC');
         $session_info = $session_info[0];
         $session = array();
         $session['title'] = $session_info['name'];
         $session['coach'] = '';
         $session['dates'] = '';
         if ($session_info['access_end_date'] == '0000-00-00' && $session_info['access_start_date'] == '0000-00-00' || empty($session_info['access_end_date']) && empty($session_info['access_start_date'])) {
             if (api_get_setting('session.show_session_coach') === 'true') {
                 $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name($session_info['firstname'], $session_info['lastname']);
             }
             if (isset($session_info['duration']) && !empty($session_info['duration'])) {
                 $userDurationData = SessionManager::getUserSession(api_get_user_id(), $session_id);
                 $userDuration = 0;
                 if (isset($userDurationData['duration'])) {
                     $userDuration = intval($userDurationData['duration']);
                 }
                 $totalDuration = $session_info['duration'] + $userDuration;
                 $daysLeft = SessionManager::getDayLeftInSession($session_id, api_get_user_id(), $totalDuration);
                 $session['duration'] = sprintf(get_lang('SessionDurationXDaysLeft'), $daysLeft);
             }
             $active = true;
         } else {
             $start = $stop = false;
             $start_buffer = $stop_buffer = '';
             if ($session_info['access_start_date'] == '0000-00-00' || empty($session_info['access_start_date'])) {
                 $session_info['access_start_date'] = '';
             } else {
                 $start = true;
                 $start_buffer = $session_info['access_start_date'];
                 $session_info['access_start_date'] = $session_info['access_start_date'];
             }
             if ($session_info['access_end_date'] == '0000-00-00' || empty($session_info['access_end_date'])) {
                 $session_info['access_end_date'] = '';
             } else {
                 $stop = true;
                 $stop_buffer = $session_info['access_end_date'];
                 $session_info['access_end_date'] = $session_info['access_end_date'];
             }
             if ($start && $stop) {
                 $session['dates'] = Display::tag('em', sprintf(get_lang('FromDateXToDateY'), api_format_date($start_buffer), api_format_date($stop_buffer)));
             } else {
                 $start_buffer = $stop_buffer = null;
                 if (!empty($session_info['access_start_date'])) {
                     $start_buffer = sprintf(get_lang('FromDateX'), api_format_date($session_info['access_start_date']));
                 }
                 if (!empty($session_info['access_end_date'])) {
                     $stop_buffer = sprintf(get_lang('UntilDateX'), api_format_date($session_info['access_end_date']));
                 }
                 $session['dates'] = Display::tag('em', "{$start_buffer} {$stop_buffer}");
             }
             if (api_get_setting('session.show_session_coach') === 'true') {
                 $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name($session_info['firstname'], $session_info['lastname']);
             }
             $active = $date_start <= $now && $date_end >= $now;
         }
         $session['active'] = $active;
         $session['session_category_id'] = $session_info['session_category_id'];
         $session['description'] = $session_info['description'];
         $session['show_description'] = $session_info['show_description'];
         $entityManager = Database::getManager();
         $fieldValuesRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraFieldValues');
         $extraFieldValues = $fieldValuesRepo->getVisibleValues(Chamilo\CoreBundle\Entity\ExtraField::SESSION_FIELD_TYPE, $session_id);
         $session['extra_fields'] = [];
         foreach ($extraFieldValues as $value) {
             $session['extra_fields'][] = ['field' => ['variable' => $value->getField()->getVariable(), 'display_text' => $value->getField()->getDisplayText()], 'value' => $value->getValue()];
         }
         $output = $session;
     }
     return $output;
 }
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:94,代码来源:display.lib.php

示例2: get_session_title_box

 /**
  * Get the session box details as an array
  * @param int       Session ID
  * @return array    Empty array or session array ['title'=>'...','category'=>'','dates'=>'...','coach'=>'...','active'=>true/false,'session_category_id'=>int]
  */
 public static function get_session_title_box($session_id)
 {
     global $nosession;
     if (!$nosession) {
         global $now, $date_start, $date_end;
     }
     $output = array();
     if (!$nosession) {
         $main_user_table = Database::get_main_table(TABLE_MAIN_USER);
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
         $active = false;
         // Request for the name of the general coach
         $sql = 'SELECT tu.lastname, tu.firstname, ts.*
                 FROM ' . $tbl_session . ' ts  LEFT JOIN ' . $main_user_table . ' tu ON ts.id_coach = tu.user_id
                 WHERE ts.id = ' . intval($session_id);
         $rs = Database::query($sql);
         $session_info = Database::store_result($rs, 'ASSOC');
         $session_info = $session_info[0];
         $session = array();
         $session['title'] = $session_info['name'];
         $session['coach'] = '';
         $session['dates'] = '';
         if ($session_info['date_end'] == '0000-00-00' && $session_info['date_start'] == '0000-00-00') {
             if (api_get_setting('show_session_coach') === 'true') {
                 $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name($session_info['firstname'], $session_info['lastname']);
             }
             if (isset($session_info['duration']) && !empty($session_info['duration'])) {
                 $userDurationData = SessionManager::getUserSession(api_get_user_id(), $session_id);
                 $userDuration = 0;
                 if (isset($userDurationData['duration'])) {
                     $userDuration = intval($userDurationData['duration']);
                 }
                 $totalDuration = $session_info['duration'] + $userDuration;
                 $daysLeft = SessionManager::getDayLeftInSession($session_id, api_get_user_id(), $totalDuration);
                 $session['duration'] = sprintf(get_lang('SessionDurationXDaysLeft'), $daysLeft);
             }
             $active = true;
         } else {
             $start = $stop = false;
             $start_buffer = $stop_buffer = '';
             if ($session_info['date_start'] == '0000-00-00') {
                 $session_info['date_start'] = '';
             } else {
                 $start = true;
                 $start_buffer = $session_info['date_start'];
                 $session_info['date_start'] = get_lang('From') . ' ' . $session_info['date_start'];
             }
             if ($session_info['date_end'] == '0000-00-00') {
                 $session_info['date_end'] = '';
             } else {
                 $stop = true;
                 $stop_buffer = $session_info['date_end'];
                 $session_info['date_end'] = get_lang('Until') . ' ' . $session_info['date_end'];
             }
             if ($start && $stop) {
                 $session['dates'] = Display::tag('i', sprintf(get_lang('FromDateXToDateY'), $start_buffer, $stop_buffer));
             } else {
                 $session['dates'] = Display::tag('i', $session_info['date_start'] . ' ' . $session_info['date_end']);
             }
             if (api_get_setting('show_session_coach') === 'true') {
                 $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name($session_info['firstname'], $session_info['lastname']);
             }
             $active = $date_start <= $now && $date_end >= $now;
         }
         $session['active'] = $active;
         $session['session_category_id'] = $session_info['session_category_id'];
         if (array_key_exists('show_description', $session_info)) {
             if (!empty($session_info['show_description'])) {
                 $session['description'] = $session_info['description'];
             }
         }
         $output = $session;
     }
     return $output;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:80,代码来源:display.lib.php

示例3: FormValidator

$form = new FormValidator('edit', 'post', api_get_self() . '?session_id=' . $sessionId . '&user_id=' . $userId);
$form->add_header(get_lang('EditUserSessionDuration'));
$data = SessionManager::getUserSession($userId, $sessionId);
$userInfo = api_get_user_info($userId);
// Show current end date for the session for this user, if any
$userAccess = CourseManager::getFirstCourseAccessPerSessionAndUser($sessionId, $userId);
if (count($userAccess) == 0) {
    // User never accessed the session. End date is still open
    $msg = sprintf(get_lang('UserNeverAccessedSessionDefaultDurationIsX'), $sessionInfo['duration']);
} else {
    // The user already accessed the session. Show a clear detail of the days count.
    $duration = $sessionInfo['duration'];
    if (!empty($data['duration'])) {
        $duration = $duration + $data['duration'];
    }
    $days = SessionManager::getDayLeftInSession($sessionId, $userId, $duration);
    $firstAccess = api_strtotime($userAccess['login_course_date'], 'UTC');
    $firstAccessString = api_convert_and_format_date($userAccess['login_course_date'], DATE_FORMAT_SHORT, 'UTC');
    if ($days > 0) {
        $msg = sprintf(get_lang('FirstAccessWasXSessionDurationYEndDateInZDays'), $firstAccessString, $duration, $days);
    } else {
        $endDateInSeconds = $firstAccess + $duration * 24 * 60 * 60;
        $last = api_convert_and_format_date($endDateInSeconds, DATE_FORMAT_SHORT);
        $msg = sprintf(get_lang('FirstAccessWasXSessionDurationYEndDateWasZ'), $firstAccessString, $duration, $last);
    }
}
$form->addElement('html', sprintf(get_lang('UserXSessionY'), $userInfo['complete_name'], $sessionInfo['name']));
$form->addElement('html', '<br>');
$form->addElement('html', $msg);
$form->addElement('text', 'duration', array(get_lang('ExtraDurationForUser'), null, get_lang('Days')));
$form->addElement('button', 'submit', get_lang('Send'));
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:session_user_edit.php


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