From a475e6301c5a07be062ab7aac5aea920b153d98b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 13 Sep 2013 15:28:32 +0200 Subject: [PATCH] Allow multiple teachers when importing csv see BT#6449 --- main/cron/import_csv.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/main/cron/import_csv.php b/main/cron/import_csv.php index ac3dbcb40c..a8c382f667 100644 --- a/main/cron/import_csv.php +++ b/main/cron/import_csv.php @@ -212,9 +212,15 @@ class ImportCsv $row['teachers'] = array(); if (isset($row['Teacher']) && !empty($row['Teacher'])) { - $userInfo = api_get_user_info_from_username($row['Teacher']); - if (!empty($userInfo)) { - $row['teachers'] = $userInfo['user_id']; + $teachers = explode(',', $row['Teacher']); + if (!empty($teachers)) { + foreach ($teachers as $teacherUserName) { + $teacherUserName = trim($teacherUserName); + $userInfo = api_get_user_info_from_username($teacherUserName); + if (!empty($userInfo)) { + $row['teachers'][] = $userInfo['user_id']; + } + } } } @@ -506,7 +512,7 @@ class ImportCsv $params['wanted_code'] = $row['course_code']; $params['course_category'] = $row['course_category']; $params['course_language'] = $row['language']; - $params['teachers'] = $row['teachers']; + $params['teachers'] = $row['teachers']; $courseInfo = CourseManager::create_course($params); @@ -658,13 +664,13 @@ if (!is_array($emails)) { } $subject = "Cron main/cron/import_csv.php ".date('Y-m-d h:i:s'); $from = api_get_setting('emailAdministrator'); - +/* if (!empty($emails)) { foreach ($emails as $email) { $stream = new NativeMailerHandler($email, $subject, $from, $minLevel); $logger->pushHandler(new BufferHandler($stream, 0, $minLevel)); } -} +}*/ $stream = new StreamHandler(api_get_path(SYS_ARCHIVE_PATH).'import_csv.log', $minLevel); $logger->pushHandler(new BufferHandler($stream, 0, $minLevel));