Skip to content

Commit f14dfa4

Browse files
committed
Adds show_description parameter in import csv files see BT#8617
1 parent e17cb4c commit f14dfa4

File tree

2 files changed

+49
-23
lines changed

2 files changed

+49
-23
lines changed

main/cron/import_csv.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,8 @@ private function importSessionsStatic($file)
10381038
null,
10391039
$coachUserName,
10401040
$categoryId,
1041-
$visibility
1041+
$visibility,
1042+
1
10421043
);
10431044

10441045
if (is_numeric($result)) {
@@ -1084,7 +1085,11 @@ private function importSessionsStatic($file)
10841085
null,
10851086
$coachId,
10861087
$categoryId,
1087-
$visibility
1088+
$visibility,
1089+
true, //$start_limit =
1090+
true, //$end_limit =
1091+
null, //$description
1092+
1 // $showDescription = null,
10881093
);
10891094

10901095
if (is_numeric($result)) {
@@ -1208,7 +1213,10 @@ private function importSessions($file, $moveFile = true)
12081213
$avoid,
12091214
false, // deleteUsersNotInList
12101215
false, // updateCourseCoaches
1211-
true // sessionWithCoursesModifier
1216+
true, // sessionWithCoursesModifier
1217+
true, //$addOriginalCourseTeachersAsCourseSessionCoaches
1218+
true, //$removeAllTeachersFromCourse
1219+
1 // $showDescription
12121220
);
12131221

12141222
if (!empty($result['error_message'])) {

main/inc/lib/sessionmanager.lib.php

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public static function create_session(
8383
$start_limit = true,
8484
$end_limit = true,
8585
$fix_name = false,
86-
$duration = null
86+
$duration = null,
87+
$showDescription = null
8788
) {
8889
global $_configuration;
8990

@@ -203,6 +204,14 @@ public static function create_session(
203204
Database::query($sql);
204205
}
205206

207+
if (!is_null($showDescription)) {
208+
$showDescription = intval($showDescription);
209+
$sql = "UPDATE $tbl_session
210+
SET show_description = '$showDescription'
211+
WHERE id = $session_id";
212+
Database::query($sql);
213+
}
214+
206215
if (!empty($session_id)) {
207216
/*
208217
Sends a message to the user_id = 1
@@ -1313,20 +1322,20 @@ public static function generate_nice_next_session_name($session_name)
13131322
/**
13141323
* Edit a session
13151324
* @author Carlos Vargas from existing code
1316-
* @param integer id
1317-
* @param string name
1318-
* @param integer year_start
1319-
* @param integer month_start
1320-
* @param integer day_start
1321-
* @param integer year_end
1322-
* @param integer month_end
1323-
* @param integer day_end
1324-
* @param integer nb_days_acess_before
1325-
* @param integer nb_days_acess_after
1326-
* @param integer nolimit
1327-
* @param integer id_coach
1328-
* @param integer id_session_category
1329-
* @param int $id_visibility
1325+
* @param integer id
1326+
* @param string name
1327+
* @param integer year_start
1328+
* @param integer month_start
1329+
* @param integer day_start
1330+
* @param integer year_end
1331+
* @param integer month_end
1332+
* @param integer day_end
1333+
* @param integer nb_days_acess_before
1334+
* @param integer nb_days_acess_after
1335+
* @param integer nolimit
1336+
* @param integer id_coach
1337+
* @param integer id_session_category
1338+
* @param int $id_visibility
13301339
* @param bool
13311340
* @param bool
13321341
* @param string $description
@@ -3654,7 +3663,8 @@ static function importCSV(
36543663
$updateCourseCoaches = false,
36553664
$sessionWithCoursesModifier = false,
36563665
$addOriginalCourseTeachersAsCourseSessionCoaches = true,
3657-
$removeAllTeachersFromCourse = true
3666+
$removeAllTeachersFromCourse = true,
3667+
$showDescription = null
36583668
) {
36593669
$content = file($file);
36603670

@@ -3682,6 +3692,10 @@ static function importCSV(
36823692
$extraParameters .= ' , nb_days_access_after_end = '.intval($daysCoachAccessAfterBeginning);
36833693
}
36843694

3695+
if (!is_null($showDescription)) {
3696+
$extraParameters .= ' , show_description = '.intval($showDescription);
3697+
}
3698+
36853699
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
36863700
$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
36873701
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
@@ -3749,10 +3763,10 @@ static function importCSV(
37493763
continue;
37503764
}
37513765

3752-
$date_start = $enreg['DateStart'];
3753-
$date_end = $enreg['DateEnd'];
3754-
$session_category_id = isset($enreg['SessionCategory']) ? $enreg['SessionCategory'] : null;
3755-
$sessionDescription = isset($enreg['SessionDescription']) ? $enreg['SessionDescription'] : null;
3766+
$date_start = $enreg['DateStart'];
3767+
$date_end = $enreg['DateEnd'];
3768+
$session_category_id = isset($enreg['SessionCategory']) ? $enreg['SessionCategory'] : null;
3769+
$sessionDescription = isset($enreg['SessionDescription']) ? $enreg['SessionDescription'] : null;
37563770

37573771
$extraSessionParameters = null;
37583772
if (!empty($sessionDescription)) {
@@ -3893,6 +3907,10 @@ static function importCSV(
38933907
$params['description'] = $sessionDescription;
38943908
}
38953909

3910+
if (!is_null($showDescription)) {
3911+
$params['show_description'] = intval($showDescription);
3912+
}
3913+
38963914
if (!empty($fieldsToAvoidUpdate)) {
38973915
foreach ($fieldsToAvoidUpdate as $field) {
38983916
unset($params[$field]);

0 commit comments

Comments
 (0)