Merge pull request #517 from AngelFQC/fix-add-session

Fix save session description and extra fields
1.10.x
Angel Fernando Quiroz Campos 10 years ago
commit 94f79aa402
  1. 37
      main/admin/session_add.php
  2. 37
      main/admin/session_edit.php
  3. 4
      main/inc/lib/sessionmanager.lib.php

@ -258,7 +258,7 @@ if (intval($countUsers) < 50) {
$form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions, array( $form->addElement('select', 'coach_username', get_lang('CoachName'), $coachesOptions, array(
'id' => 'coach_username', 'id' => 'coach_username',
'class' => 'chzn-select', 'class' => 'chzn-select',
'style' => 'width:350px;' 'style' => 'width:370px;'
)); ));
$form->addElement('advanced_settings', Display::return_icon('synthese_view.gif') . ' ' . get_lang('ActivityCoach')); $form->addElement('advanced_settings', Display::return_icon('synthese_view.gif') . ' ' . get_lang('ActivityCoach'));
} else { } else {
@ -276,7 +276,7 @@ $form->add_html('<div id="ajax_list_coachs"></div>');
$form->add_select('session_category', get_lang('SessionCategory'), $categoriesOptions, array( $form->add_select('session_category', get_lang('SessionCategory'), $categoriesOptions, array(
'id' => 'session_category', 'id' => 'session_category',
'class' => 'chzn-select', 'class' => 'chzn-select',
'style' => 'width:350px;' 'style' => 'width:370px;'
)); ));
$form->addElement('advanced_settings','<a class="btn-show" id="advanced_parameters" href="javascript://">'.get_lang('DefineSessionOptions').'</a>'); $form->addElement('advanced_settings','<a class="btn-show" id="advanced_parameters" href="javascript://">'.get_lang('DefineSessionOptions').'</a>');
@ -327,6 +327,18 @@ $form->addGroup($visibilityGroup, 'visibility_group', null, null, false);
$form->addElement('html','</div>'); $form->addElement('html','</div>');
$form->addElement(
'textarea',
'description',
get_lang('Description'),
array(
'class' => 'span4',
'rows' => 3
)
);
$form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription'));
$form->addElement( $form->addElement(
'text', 'text',
'duration', 'duration',
@ -385,6 +397,8 @@ if ($form->validate()) {
$end_limit = isset($params['end_limit']) ? true : false; $end_limit = isset($params['end_limit']) ? true : false;
$start_limit = isset($params['start_limit']) ? true : false; $start_limit = isset($params['start_limit']) ? true : false;
$duration = isset($params['duration']) ? $params['duration'] : null; $duration = isset($params['duration']) ? $params['duration'] : null;
$description = $params['description'];
$showDescription = isset($params['show_description']) ? 1: 0;
if (empty($end_limit) && empty($start_limit)) { if (empty($end_limit) && empty($start_limit)) {
$nolimit = 1; $nolimit = 1;
@ -401,9 +415,22 @@ if ($form->validate()) {
} }
$return = SessionManager::create_session( $return = SessionManager::create_session(
$name, $startDate, $endDate, $nb_days_acess_before, $name,
$nb_days_acess_after, $nolimit, $coach_username, $id_session_category, $id_visibility, $start_limit, $startDate,
$end_limit, false, $duration, $extraFields $endDate,
$nb_days_acess_before,
$nb_days_acess_after,
$nolimit,
$coach_username,
$id_session_category,
$id_visibility,
$start_limit,
$end_limit,
false,
$duration,
$description,
$showDescription,
$extraFields
); );
if ($return == strval(intval($return))) { if ($return == strval(intval($return))) {

@ -37,17 +37,6 @@ $interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id,"name"
list($year_start, $month_start, $day_start) = explode('-', $infos['date_start']); list($year_start, $month_start, $day_start) = explode('-', $infos['date_start']);
list($year_end, $month_end, $day_end) = explode('-', $infos['date_end']); list($year_end, $month_end, $day_end) = explode('-', $infos['date_end']);
// Default value
$showDescriptionChecked = 'checked';
if (isset($infos['show_description'])) {
if (!empty($infos['show_description'])) {
$showDescriptionChecked = 'checked';
} else {
$showDescriptionChecked = null;
}
}
$end_year_disabled = $end_month_disabled = $end_day_disabled = ''; $end_year_disabled = $end_month_disabled = $end_day_disabled = '';
if (isset($_POST['formSent']) && $_POST['formSent']) { if (isset($_POST['formSent']) && $_POST['formSent']) {
@ -219,18 +208,24 @@ $form->addGroup($visibilityGroup, 'visibility_group', null, null, false);
$form->addElement('html','</div>'); $form->addElement('html','</div>');
if (array_key_exists('show_description', $infos)) { $form->addElement(
$form->addElement('textarea', 'description', get_lang('Description')); 'textarea',
'description',
$chkDescriptionAttributes = array(); get_lang('Description'),
array(
'class' => 'span4',
'rows' => 3
)
);
if (!empty($showDescriptionChecked)) { $chkDescriptionAttributes = array();
$chkDescriptionAttributes['checked'] = '';
}
$form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription'), $chkDescriptionAttributes); if (!empty($infos['show_description'])) {
$chkDescriptionAttributes['checked'] = '';
} }
$form->addElement('checkbox', 'show_description', null, get_lang('ShowDescription'), $chkDescriptionAttributes);
$duration = empty($infos['duration']) ? null : $infos['duration']; $duration = empty($infos['duration']) ? null : $infos['duration'];
$form->addElement( $form->addElement(
@ -268,7 +263,7 @@ $formDefaults = array(
'date_start' => $infos['date_start'], 'date_start' => $infos['date_start'],
'date_end' => $infos['date_end'], 'date_end' => $infos['date_end'],
'session_visibility' => $infos['visibility'], 'session_visibility' => $infos['visibility'],
'description' => array_key_exists('show_description', $infos) ? $infos['description'] : '' 'description' => $infos['description']
); );
if ($formSent) { if ($formSent) {
@ -297,7 +292,7 @@ if ($form->validate()) {
$id_session_category = $params['session_category']; $id_session_category = $params['session_category'];
$id_visibility = $params['session_visibility']; $id_visibility = $params['session_visibility'];
$duration = isset($params['duration']) ? $params['duration'] : null; $duration = isset($params['duration']) ? $params['duration'] : null;
$description = isset($params['description']) ? $params['description'] : null; $description = $params['description'];
$showDescription = isset($params['show_description']) ? 1: 0; $showDescription = isset($params['show_description']) ? 1: 0;
$end_limit = $params['end_limit']; $end_limit = $params['end_limit'];

@ -66,6 +66,7 @@ class SessionManager
* @param string $duration * @param string $duration
* @param string $description Optional. The session description * @param string $description Optional. The session description
* @param int $showDescription Optional. Whether show the session description * @param int $showDescription Optional. Whether show the session description
* @param array $extrafields
* @todo use an array to replace all this parameters or use the model.lib.php ... * @todo use an array to replace all this parameters or use the model.lib.php ...
* @return mixed Session ID on success, error message otherwise * @return mixed Session ID on success, error message otherwise
* */ * */
@ -84,7 +85,8 @@ class SessionManager
$fix_name = false, $fix_name = false,
$duration = null, $duration = null,
$description = null, $description = null,
$showDescription = 0 $showDescription = 0,
$extraFields = array()
) { ) {
global $_configuration; global $_configuration;

Loading…
Cancel
Save