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(
'id' => 'coach_username',
'class' => 'chzn-select',
'style' => 'width:350px;'
'style' => 'width:370px;'
));
$form->addElement('advanced_settings', Display::return_icon('synthese_view.gif') . ' ' . get_lang('ActivityCoach'));
} else {
@ -276,7 +276,7 @@ $form->add_html('<div id="ajax_list_coachs"></div>');
$form->add_select('session_category', get_lang('SessionCategory'), $categoriesOptions, array(
'id' => 'session_category',
'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>');
@ -327,6 +327,18 @@ $form->addGroup($visibilityGroup, 'visibility_group', null, null, false);
$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(
'text',
'duration',
@ -385,6 +397,8 @@ if ($form->validate()) {
$end_limit = isset($params['end_limit']) ? true : false;
$start_limit = isset($params['start_limit']) ? true : false;
$duration = isset($params['duration']) ? $params['duration'] : null;
$description = $params['description'];
$showDescription = isset($params['show_description']) ? 1: 0;
if (empty($end_limit) && empty($start_limit)) {
$nolimit = 1;
@ -401,9 +415,22 @@ if ($form->validate()) {
}
$return = SessionManager::create_session(
$name, $startDate, $endDate, $nb_days_acess_before,
$nb_days_acess_after, $nolimit, $coach_username, $id_session_category, $id_visibility, $start_limit,
$end_limit, false, $duration, $extraFields
$name,
$startDate,
$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))) {

@ -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_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 = '';
if (isset($_POST['formSent']) && $_POST['formSent']) {
@ -219,18 +208,24 @@ $form->addGroup($visibilityGroup, 'visibility_group', null, null, false);
$form->addElement('html','</div>');
if (array_key_exists('show_description', $infos)) {
$form->addElement('textarea', 'description', get_lang('Description'));
$chkDescriptionAttributes = array();
$form->addElement(
'textarea',
'description',
get_lang('Description'),
array(
'class' => 'span4',
'rows' => 3
)
);
if (!empty($showDescriptionChecked)) {
$chkDescriptionAttributes['checked'] = '';
}
$chkDescriptionAttributes = array();
$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'];
$form->addElement(
@ -268,7 +263,7 @@ $formDefaults = array(
'date_start' => $infos['date_start'],
'date_end' => $infos['date_end'],
'session_visibility' => $infos['visibility'],
'description' => array_key_exists('show_description', $infos) ? $infos['description'] : ''
'description' => $infos['description']
);
if ($formSent) {
@ -297,7 +292,7 @@ if ($form->validate()) {
$id_session_category = $params['session_category'];
$id_visibility = $params['session_visibility'];
$duration = isset($params['duration']) ? $params['duration'] : null;
$description = isset($params['description']) ? $params['description'] : null;
$description = $params['description'];
$showDescription = isset($params['show_description']) ? 1: 0;
$end_limit = $params['end_limit'];

@ -66,6 +66,7 @@ class SessionManager
* @param string $duration
* @param string $description Optional. 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 ...
* @return mixed Session ID on success, error message otherwise
* */
@ -84,7 +85,8 @@ class SessionManager
$fix_name = false,
$duration = null,
$description = null,
$showDescription = 0
$showDescription = 0,
$extraFields = array()
) {
global $_configuration;

Loading…
Cancel
Save