Skip to content

Commit

Permalink
Adds show_description parameter in import csv files see BT#8617
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Feb 3, 2015
1 parent e17cb4c commit f14dfa4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
14 changes: 11 additions & 3 deletions main/cron/import_csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,8 @@ private function importSessionsStatic($file)
null,
$coachUserName,
$categoryId,
$visibility
$visibility,
1
);

if (is_numeric($result)) {
Expand Down Expand Up @@ -1084,7 +1085,11 @@ private function importSessionsStatic($file)
null,
$coachId,
$categoryId,
$visibility
$visibility,
true, //$start_limit =
true, //$end_limit =
null, //$description
1 // $showDescription = null,
);

if (is_numeric($result)) {
Expand Down Expand Up @@ -1208,7 +1213,10 @@ private function importSessions($file, $moveFile = true)
$avoid,
false, // deleteUsersNotInList
false, // updateCourseCoaches
true // sessionWithCoursesModifier
true, // sessionWithCoursesModifier
true, //$addOriginalCourseTeachersAsCourseSessionCoaches
true, //$removeAllTeachersFromCourse
1 // $showDescription
);

if (!empty($result['error_message'])) {
Expand Down
58 changes: 38 additions & 20 deletions main/inc/lib/sessionmanager.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public static function create_session(
$start_limit = true,
$end_limit = true,
$fix_name = false,
$duration = null
$duration = null,
$showDescription = null
) {
global $_configuration;

Expand Down Expand Up @@ -203,6 +204,14 @@ public static function create_session(
Database::query($sql);
}

if (!is_null($showDescription)) {
$showDescription = intval($showDescription);
$sql = "UPDATE $tbl_session
SET show_description = '$showDescription'
WHERE id = $session_id";
Database::query($sql);
}

if (!empty($session_id)) {
/*
Sends a message to the user_id = 1
Expand Down Expand Up @@ -1313,20 +1322,20 @@ public static function generate_nice_next_session_name($session_name)
/**
* Edit a session
* @author Carlos Vargas from existing code
* @param integer id
* @param string name
* @param integer year_start
* @param integer month_start
* @param integer day_start
* @param integer year_end
* @param integer month_end
* @param integer day_end
* @param integer nb_days_acess_before
* @param integer nb_days_acess_after
* @param integer nolimit
* @param integer id_coach
* @param integer id_session_category
* @param int $id_visibility
* @param integer id
* @param string name
* @param integer year_start
* @param integer month_start
* @param integer day_start
* @param integer year_end
* @param integer month_end
* @param integer day_end
* @param integer nb_days_acess_before
* @param integer nb_days_acess_after
* @param integer nolimit
* @param integer id_coach
* @param integer id_session_category
* @param int $id_visibility
* @param bool
* @param bool
* @param string $description
Expand Down Expand Up @@ -3654,7 +3663,8 @@ static function importCSV(
$updateCourseCoaches = false,
$sessionWithCoursesModifier = false,
$addOriginalCourseTeachersAsCourseSessionCoaches = true,
$removeAllTeachersFromCourse = true
$removeAllTeachersFromCourse = true,
$showDescription = null
) {
$content = file($file);

Expand Down Expand Up @@ -3682,6 +3692,10 @@ static function importCSV(
$extraParameters .= ' , nb_days_access_after_end = '.intval($daysCoachAccessAfterBeginning);
}

if (!is_null($showDescription)) {
$extraParameters .= ' , show_description = '.intval($showDescription);
}

$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
Expand Down Expand Up @@ -3749,10 +3763,10 @@ static function importCSV(
continue;
}

$date_start = $enreg['DateStart'];
$date_end = $enreg['DateEnd'];
$session_category_id = isset($enreg['SessionCategory']) ? $enreg['SessionCategory'] : null;
$sessionDescription = isset($enreg['SessionDescription']) ? $enreg['SessionDescription'] : null;
$date_start = $enreg['DateStart'];
$date_end = $enreg['DateEnd'];
$session_category_id = isset($enreg['SessionCategory']) ? $enreg['SessionCategory'] : null;
$sessionDescription = isset($enreg['SessionDescription']) ? $enreg['SessionDescription'] : null;

$extraSessionParameters = null;
if (!empty($sessionDescription)) {
Expand Down Expand Up @@ -3893,6 +3907,10 @@ static function importCSV(
$params['description'] = $sessionDescription;
}

if (!is_null($showDescription)) {
$params['show_description'] = intval($showDescription);
}

if (!empty($fieldsToAvoidUpdate)) {
foreach ($fieldsToAvoidUpdate as $field) {
unset($params[$field]);
Expand Down

0 comments on commit f14dfa4

Please sign in to comment.