123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- class SessionModel extends Model
- {
- public $columns = array(
- 'id',
- 'id_coach',
- 'name',
- 'nbr_courses',
- 'nbr_users',
- 'nbr_classes',
- 'session_admin_id',
- 'visibility',
- 'session_category_id',
- 'promotion_id',
- 'display_start_date',
- 'display_end_date',
- 'access_start_date',
- 'access_end_date',
- 'coach_access_start_date',
- 'coach_access_end_date',
- );
- public function __construct()
- {
- $this->table = Database::get_main_table(TABLE_MAIN_SESSION);
- }
- public function clean_parameters($params)
- {
- //Convert dates
- $params['display_start_date'] = isset($params['display_start_date']) ? api_get_utc_datetime(
- $params['display_start_date'],
- true
- ) : null;
- $params['display_end_date'] = isset($params['display_end_date']) ? api_get_utc_datetime(
- $params['display_end_date'],
- true
- ) : null;
- $params['access_start_date'] = isset($params['access_start_date']) ? api_get_utc_datetime(
- $params['access_start_date'],
- true
- ) : null;
- $params['access_end_date'] = isset($params['access_end_date']) ? api_get_utc_datetime(
- $params['access_end_date'],
- true
- ) : null;
- $params['coach_access_start_date'] = isset($params['coach_access_start_date']) ? api_get_utc_datetime(
- $params['coach_access_start_date'],
- true
- ) : null;
- $params['coach_access_end_date'] = isset($params['coach_access_end_date']) ? api_get_utc_datetime(
- $params['coach_access_end_date'],
- true
- ) : null;
- $params['id_coach'] = is_array(
- $params['id_coach']
- ) ? $params['id_coach'][0] : $params['id_coach'];
- if (empty($params['access_end_date'])) {
- $params['visibility'] = SessionManager::DEFAULT_VISIBILITY;
- }
- unset($params['submit']);
- return $params;
- }
- function save($params, $show_query = false)
- {
- $params = self::clean_parameters($params);
- return parent::save($params, $show_query);
- }
- function update($params)
- {
- $params = self::clean_parameters($params);
- $result = parent::update($params);
- return $result;
- }
- }
|