|
|
|
@ -78,6 +78,10 @@ class ImportCsv |
|
|
|
|
*/ |
|
|
|
|
public function run() |
|
|
|
|
{ |
|
|
|
|
/* |
|
|
|
|
global $_configuration; |
|
|
|
|
$_configuration['access_url'] = 2; |
|
|
|
|
*/ |
|
|
|
|
$path = api_get_path(SYS_CODE_PATH).'cron/incoming/'; |
|
|
|
|
if (!is_dir($path)) { |
|
|
|
|
echo "The folder! $path does not exits"; |
|
|
|
@ -94,6 +98,8 @@ class ImportCsv |
|
|
|
|
$files = scandir($path); |
|
|
|
|
$fileToProcess = array(); |
|
|
|
|
$fileToProcessStatic = array(); |
|
|
|
|
$teacherBackup = array(); |
|
|
|
|
$groupBackup = array(); |
|
|
|
|
|
|
|
|
|
if (!empty($files)) { |
|
|
|
|
foreach ($files as $file) { |
|
|
|
@ -109,7 +115,7 @@ class ImportCsv |
|
|
|
|
|
|
|
|
|
if (method_exists($this, $method)) { |
|
|
|
|
if (($method == 'importUnsubscribeStatic' || |
|
|
|
|
$method == 'importSubscribeStatic') || |
|
|
|
|
$method == 'importSubscribeStatic') || |
|
|
|
|
empty($isStatic) |
|
|
|
|
) { |
|
|
|
|
$fileToProcess[$parts[1]][] = array( |
|
|
|
@ -149,7 +155,6 @@ class ImportCsv |
|
|
|
|
'subscribe-static', |
|
|
|
|
'unsubscribe-static' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
foreach ($sections as $section) { |
|
|
|
|
$this->logger->addInfo("-- Import $section --"); |
|
|
|
|
|
|
|
|
@ -161,7 +166,11 @@ class ImportCsv |
|
|
|
|
|
|
|
|
|
echo 'File: '.$file.PHP_EOL; |
|
|
|
|
$this->logger->addInfo("Reading file: $file"); |
|
|
|
|
$this->$method($file, true); |
|
|
|
|
if ($method == 'importSessions') { |
|
|
|
|
$this->$method($file, true, $teacherBackup, $groupBackup); |
|
|
|
|
} else { |
|
|
|
|
$this->$method($file, true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -186,7 +195,7 @@ class ImportCsv |
|
|
|
|
$file = $fileInfo['file']; |
|
|
|
|
echo 'Static file: '.$file.PHP_EOL; |
|
|
|
|
$this->logger->addInfo("Reading static file: $file"); |
|
|
|
|
$this->$method($file, true); |
|
|
|
|
$this->$method($file, true, $teacherBackup, $groupBackup); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -224,8 +233,8 @@ class ImportCsv |
|
|
|
|
$extraField = new ExtraField('calendar_event'); |
|
|
|
|
$extraField->save(array( |
|
|
|
|
'field_type' => ExtraField::FIELD_TYPE_TEXT, |
|
|
|
|
'variable' => $this->extraFieldIdNameList['calendar_event'], |
|
|
|
|
'display_text' => 'External calendar event id' |
|
|
|
|
'field_variable' => $this->extraFieldIdNameList['calendar_event'], |
|
|
|
|
'field_display_text' => 'External calendar event id' |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -261,7 +270,7 @@ class ImportCsv |
|
|
|
|
$row['email'] = $row['Email']; |
|
|
|
|
$row['username'] = $row['UserName']; |
|
|
|
|
$row['password'] = $row['Password']; |
|
|
|
|
$row['auth_source'] = $row['AuthSource']; |
|
|
|
|
$row['auth_source'] = isset($row['AuthSource']) ? $row['AuthSource'] : PLATFORM_AUTH_SOURCE; |
|
|
|
|
$row['official_code'] = $row['OfficialCode']; |
|
|
|
|
$row['phone'] = $row['PhoneNumber']; |
|
|
|
|
|
|
|
|
@ -326,7 +335,7 @@ class ImportCsv |
|
|
|
|
*/ |
|
|
|
|
private function importTeachers($file, $moveFile = true) |
|
|
|
|
{ |
|
|
|
|
$data = Import::csvToArray($file); |
|
|
|
|
$data = Import::csv_to_array($file); |
|
|
|
|
|
|
|
|
|
/* Unique identifier: official-code username. |
|
|
|
|
Email address and password should never get updated. *ok |
|
|
|
@ -370,7 +379,7 @@ class ImportCsv |
|
|
|
|
$language, //$row['language'], |
|
|
|
|
$row['phone'], |
|
|
|
|
null, //$row['picture'], //picture |
|
|
|
|
PLATFORM_AUTH_SOURCE, // ? |
|
|
|
|
$row['auth_source'], // ? |
|
|
|
|
$expirationDate, //'0000-00-00 00:00:00', //$row['expiration_date'], //$expiration_date = '0000-00-00 00:00:00', |
|
|
|
|
1, //active |
|
|
|
|
0, |
|
|
|
@ -405,7 +414,7 @@ class ImportCsv |
|
|
|
|
$row['lastname'], // <<-- changed |
|
|
|
|
$userInfo['username'], |
|
|
|
|
null, //$password = null, |
|
|
|
|
PLATFORM_AUTH_SOURCE, |
|
|
|
|
$row['auth_source'], |
|
|
|
|
$userInfo['email'], |
|
|
|
|
COURSEMANAGER, |
|
|
|
|
$userInfo['official_code'], |
|
|
|
@ -446,7 +455,6 @@ class ImportCsv |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param string $file |
|
|
|
|
*/ |
|
|
|
@ -461,9 +469,7 @@ class ImportCsv |
|
|
|
|
*/ |
|
|
|
|
private function importStudents($file, $moveFile = true) |
|
|
|
|
{ |
|
|
|
|
$data = Import::csvToArray($file); |
|
|
|
|
|
|
|
|
|
$userRepository = UserManager::getRepository(); |
|
|
|
|
$data = Import::csv_to_array($file); |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* Another users import. |
|
|
|
@ -474,7 +480,8 @@ class ImportCsv |
|
|
|
|
All other fields should be updateable, though passwords should of course not get updated. ok |
|
|
|
|
If a user gets deleted (not there anymore), |
|
|
|
|
He should be set inactive one year after the current date. |
|
|
|
|
So I presume you’ll just update the expiration date. We want to grant access to courses up to a year after deletion. |
|
|
|
|
So I presume you’ll just update the expiration date. |
|
|
|
|
We want to grant access to courses up to a year after deletion. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
if (!empty($data)) { |
|
|
|
@ -509,7 +516,7 @@ class ImportCsv |
|
|
|
|
$language, //$row['language'], |
|
|
|
|
$row['phone'], |
|
|
|
|
null, //$row['picture'], //picture |
|
|
|
|
PLATFORM_AUTH_SOURCE, // ? |
|
|
|
|
$row['auth_source'], // ? |
|
|
|
|
$expirationDate, //'0000-00-00 00:00:00', //$row['expiration_date'], //$expiration_date = '0000-00-00 00:00:00', |
|
|
|
|
1, //active |
|
|
|
|
0, |
|
|
|
@ -530,6 +537,7 @@ class ImportCsv |
|
|
|
|
$this->logger->addError("Students - User NOT created: ".$row['username']." ".$row['firstname']." ".$row['lastname']); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
if (empty($userInfo)) { |
|
|
|
|
$this->logger->addError("Students - Can't update user :".$row['username']); |
|
|
|
|
continue; |
|
|
|
@ -560,27 +568,19 @@ class ImportCsv |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2. Condition |
|
|
|
|
if (!in_array($userInfo['email'], $avoidUsersWithEmail) && |
|
|
|
|
!in_array($row['email'], $avoidUsersWithEmail) |
|
|
|
|
) { |
|
|
|
|
if (!in_array($userInfo['email'], $avoidUsersWithEmail) && !in_array($row['email'], $avoidUsersWithEmail)) { |
|
|
|
|
$email = $userInfo['email']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 3. Condition |
|
|
|
|
if (in_array($userInfo['email'], $avoidUsersWithEmail) && |
|
|
|
|
!in_array($row['email'], $avoidUsersWithEmail) |
|
|
|
|
) { |
|
|
|
|
if (in_array($userInfo['email'], $avoidUsersWithEmail) && !in_array($row['email'], $avoidUsersWithEmail)) { |
|
|
|
|
$email = $row['email']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Blocking password update |
|
|
|
|
$avoidUsersWithPassword = $this->conditions['importStudents']['update']['avoid']['password']; |
|
|
|
|
|
|
|
|
|
$user = $userRepository->find($userInfo['user_id']); |
|
|
|
|
|
|
|
|
|
if ($userInfo['password'] != UserManager::encryptPassword($row['password'], $user) && |
|
|
|
|
in_array($row['password'], $avoidUsersWithPassword) |
|
|
|
|
) { |
|
|
|
|
if ($userInfo['password'] != api_get_encrypted_password($row['password']) && in_array($row['password'], $avoidUsersWithPassword)) { |
|
|
|
|
$this->logger->addInfo("Students - User password is not updated: ".$row['username']." because the avoid conditions (password)."); |
|
|
|
|
$password = null; |
|
|
|
|
$resetPassword = 0; // disallow password change |
|
|
|
@ -597,7 +597,7 @@ class ImportCsv |
|
|
|
|
$row['lastname'], // <<-- changed |
|
|
|
|
$row['username'], // <<-- changed |
|
|
|
|
$password, //$password = null, |
|
|
|
|
PLATFORM_AUTH_SOURCE, |
|
|
|
|
$row['auth_source'], |
|
|
|
|
$email, |
|
|
|
|
STUDENT, |
|
|
|
|
$userInfo['official_code'], |
|
|
|
@ -615,6 +615,7 @@ class ImportCsv |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($result) { |
|
|
|
|
|
|
|
|
|
if ($row['username'] != $userInfo['username']) { |
|
|
|
|
$this->logger->addInfo("Students - Username was changes from '".$userInfo['username']."' to '".$row['username']."' "); |
|
|
|
|
} |
|
|
|
@ -645,9 +646,9 @@ class ImportCsv |
|
|
|
|
/** |
|
|
|
|
* @param string $file |
|
|
|
|
*/ |
|
|
|
|
private function importCoursesStatic($file) |
|
|
|
|
private function importCoursesStatic($file, $moveFile, &$teacherBackup = array(), &$groupBackup = array()) |
|
|
|
|
{ |
|
|
|
|
$this->importCourses($file, false); |
|
|
|
|
$this->importCourses($file, false, $teacherBackup, $groupBackup); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -658,29 +659,7 @@ class ImportCsv |
|
|
|
|
*/ |
|
|
|
|
private function importCalendarStatic($file, $moveFile = true) |
|
|
|
|
{ |
|
|
|
|
$data = Import::csvToArray($file); |
|
|
|
|
|
|
|
|
|
if ($this->getDumpValues()) { |
|
|
|
|
// Remove all calendar items |
|
|
|
|
$truncateTables = array( |
|
|
|
|
Database::get_course_table(TABLE_AGENDA), |
|
|
|
|
Database::get_course_table(TABLE_AGENDA_ATTACHMENT), |
|
|
|
|
Database::get_course_table(TABLE_AGENDA_REPEAT), |
|
|
|
|
Database::get_course_table(TABLE_AGENDA_REPEAT_NOT), |
|
|
|
|
Database::get_main_table(TABLE_PERSONAL_AGENDA), |
|
|
|
|
Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT_NOT), |
|
|
|
|
Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
foreach ($truncateTables as $table) { |
|
|
|
|
$sql = "TRUNCATE $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
|
|
|
$sql = "DELETE FROM $table WHERE tool = 'calendar_event'"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
} |
|
|
|
|
$data = Import::csv_to_array($file); |
|
|
|
|
|
|
|
|
|
if (!empty($data)) { |
|
|
|
|
$this->logger->addInfo(count($data) . " records found."); |
|
|
|
@ -691,7 +670,7 @@ class ImportCsv |
|
|
|
|
$externalSessionId = null; |
|
|
|
|
if (isset($row['external_sessionID'])) { |
|
|
|
|
$externalSessionId = $row['external_sessionID']; |
|
|
|
|
$sessionId = SessionManager::getSessionIdFromOriginalId( |
|
|
|
|
$sessionId = SessionManager::get_session_id_from_original_id( |
|
|
|
|
$externalSessionId, |
|
|
|
|
$this->extraFieldIdNameList['session'] |
|
|
|
|
); |
|
|
|
@ -715,7 +694,7 @@ class ImportCsv |
|
|
|
|
if (!empty($sessionId) && !empty($courseInfo)) { |
|
|
|
|
$courseIncluded = SessionManager::relation_session_course_exist( |
|
|
|
|
$sessionId, |
|
|
|
|
$courseInfo['real_id'] |
|
|
|
|
$courseInfo['code'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if ($courseIncluded == false) { |
|
|
|
@ -754,6 +733,8 @@ class ImportCsv |
|
|
|
|
$startTime = $row['time_start']; |
|
|
|
|
$endTime = $row['time_end']; |
|
|
|
|
$title = $row['title']; |
|
|
|
|
$comment = $row['comment']; |
|
|
|
|
$color = isset($row['color']) ? $row['color'] : ''; |
|
|
|
|
|
|
|
|
|
$startDateYear = substr($date, 0, 4); |
|
|
|
|
$startDateMonth = substr($date, 4, 2); |
|
|
|
@ -762,13 +743,18 @@ class ImportCsv |
|
|
|
|
$startDate = $startDateYear.'-'.$startDateMonth.'-'.$startDateDay.' '.$startTime.":00"; |
|
|
|
|
$endDate = $startDateYear.'-'.$startDateMonth.'-'.$startDateDay.' '.$endTime.":00"; |
|
|
|
|
|
|
|
|
|
if (!api_is_valid_date($startDate) OR !api_is_valid_date($endDate)) { |
|
|
|
|
if (!api_is_valid_date($startDate) || !api_is_valid_date($endDate)) { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Verify your dates: '$startDate' : '$endDate' " |
|
|
|
|
); |
|
|
|
|
$errorFound = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// If old events do nothing. |
|
|
|
|
/*if (api_strtotime($startDate) < time()) { |
|
|
|
|
continue; |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
if ($errorFound == false) { |
|
|
|
|
$eventsToCreate[] = array( |
|
|
|
|
'start' => $startDate, |
|
|
|
@ -777,6 +763,8 @@ class ImportCsv |
|
|
|
|
'sender_id' => $teacherId, |
|
|
|
|
'course_id' => $courseInfo['real_id'], |
|
|
|
|
'session_id' => $sessionId, |
|
|
|
|
'comment' => $comment, |
|
|
|
|
'color' => $color, |
|
|
|
|
$this->extraFieldIdNameList['calendar_event'] => $row['external_calendar_itemID'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -794,7 +782,6 @@ class ImportCsv |
|
|
|
|
"Ready to insert events" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$content = null; |
|
|
|
|
$agenda = new Agenda(); |
|
|
|
|
|
|
|
|
|
$extraFieldValue = new ExtraFieldValue('calendar_event'); |
|
|
|
@ -813,6 +800,8 @@ class ImportCsv |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($eventsToCreate as $event) { |
|
|
|
|
$update = false; |
|
|
|
|
$item = null; |
|
|
|
|
if (!isset($event[$extraFieldName])) { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"No external_calendar_itemID found. Skipping ..." |
|
|
|
@ -820,16 +809,34 @@ class ImportCsv |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
$externalEventId = $event[$extraFieldName]; |
|
|
|
|
$item = $extraFieldValue->get_item_id_from_field_variable_and_field_value( |
|
|
|
|
if (empty($externalEventId)) { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"external_calendar_itemID was set but empty. Skipping ..." |
|
|
|
|
); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$items = $extraFieldValue->get_item_id_from_field_variable_and_field_value( |
|
|
|
|
$extraFieldName, |
|
|
|
|
$externalEventId |
|
|
|
|
$externalEventId, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!empty($item) || empty($externalEventId)) { |
|
|
|
|
$item = null; |
|
|
|
|
foreach ($items as $tempItem) { |
|
|
|
|
if ($tempItem['c_id'] == $event['course_id']) { |
|
|
|
|
$item = $tempItem; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($item)) { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Event #$externalEventId was already added . Skipping ..." |
|
|
|
|
"Event #$externalEventId was already added. Updating ..." |
|
|
|
|
); |
|
|
|
|
continue; |
|
|
|
|
$update = true; |
|
|
|
|
//continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -841,6 +848,11 @@ class ImportCsv |
|
|
|
|
$agenda->setIsAllowedToEdit(true); |
|
|
|
|
|
|
|
|
|
$eventComment = $event['comment']; |
|
|
|
|
$color = $event['color']; |
|
|
|
|
|
|
|
|
|
// To use the event comment you need |
|
|
|
|
// ALTER TABLE c_calendar_event ADD COLUMN comment TEXT; |
|
|
|
|
// add in configuration.php allow_agenda_event_comment = true |
|
|
|
|
|
|
|
|
|
if (empty($courseInfo)) { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
@ -856,35 +868,66 @@ class ImportCsv |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$eventId = $agenda->addEvent( |
|
|
|
|
$event['start'], |
|
|
|
|
$event['end'], |
|
|
|
|
false, |
|
|
|
|
$event['title'], |
|
|
|
|
$content, |
|
|
|
|
array('everyone'), // send to |
|
|
|
|
false, //$addAsAnnouncement = false |
|
|
|
|
null, // $parentEventId |
|
|
|
|
array(), //$attachmentArray = array(), |
|
|
|
|
null, //$attachmentComment = null, |
|
|
|
|
$eventComment |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!empty($eventId)) { |
|
|
|
|
$extraFieldValue->save( |
|
|
|
|
array( |
|
|
|
|
'value' => $externalEventId, |
|
|
|
|
'field_id' => $extraFieldInfo['id'], |
|
|
|
|
'item_id' => $eventId |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Event added: #$eventId" |
|
|
|
|
$content = ''; |
|
|
|
|
|
|
|
|
|
if ($update && isset($item['calendar_event_id'])) { |
|
|
|
|
//the event already exists, just update |
|
|
|
|
$eventId = $agenda->edit_event( |
|
|
|
|
$item['calendar_event_id'], |
|
|
|
|
$event['start'], |
|
|
|
|
$event['end'], |
|
|
|
|
false, |
|
|
|
|
$event['title'], |
|
|
|
|
$content, |
|
|
|
|
array('everyone'), // send to |
|
|
|
|
array(), //$attachmentArray = array(), |
|
|
|
|
null, //$attachmentComment = null, |
|
|
|
|
$eventComment, |
|
|
|
|
$color |
|
|
|
|
); |
|
|
|
|
if ($eventId !== false) { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Event updated: #$eventId" |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Error while updating event." |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Error while creating event." |
|
|
|
|
// New event. Create it. |
|
|
|
|
$eventId = $agenda->add_event( |
|
|
|
|
$event['start'], |
|
|
|
|
$event['end'], |
|
|
|
|
false, |
|
|
|
|
$event['title'], |
|
|
|
|
$content, |
|
|
|
|
array('everyone'), // send to |
|
|
|
|
false, //$addAsAnnouncement = false |
|
|
|
|
null, // $parentEventId |
|
|
|
|
array(), //$attachmentArray = array(), |
|
|
|
|
null, //$attachmentComment = null, |
|
|
|
|
$eventComment, |
|
|
|
|
$color |
|
|
|
|
); |
|
|
|
|
if (!empty($eventId)) { |
|
|
|
|
$extraFieldValue->is_course_model = true; |
|
|
|
|
$extraFieldValue->save( |
|
|
|
|
array( |
|
|
|
|
'field_value' => $externalEventId, |
|
|
|
|
'field_id' => $extraFieldInfo['id'], |
|
|
|
|
'calendar_event_id' => $eventId, |
|
|
|
|
'c_id' => $event['course_id'] |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Event added: #$eventId" |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$this->logger->addInfo( |
|
|
|
|
"Error while creating event." |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -897,10 +940,12 @@ class ImportCsv |
|
|
|
|
/** |
|
|
|
|
* @param string $file |
|
|
|
|
* @param bool $moveFile |
|
|
|
|
* @param array $teacherBackup |
|
|
|
|
* @param array $groupBackup |
|
|
|
|
*/ |
|
|
|
|
private function importCourses($file, $moveFile = true) |
|
|
|
|
private function importCourses($file, $moveFile = true, &$teacherBackup = array(), &$groupBackup = array()) |
|
|
|
|
{ |
|
|
|
|
$data = Import::csvToArray($file); |
|
|
|
|
$data = Import::csv_to_array($file); |
|
|
|
|
|
|
|
|
|
if (!empty($data)) { |
|
|
|
|
$this->logger->addInfo(count($data)." records found."); |
|
|
|
@ -908,12 +953,12 @@ class ImportCsv |
|
|
|
|
foreach ($data as $row) { |
|
|
|
|
$row = $this->cleanCourseRow($row); |
|
|
|
|
|
|
|
|
|
$courseId = CourseManager::getCourseInfoFromOriginalId( |
|
|
|
|
$courseCode = CourseManager::get_course_id_from_original_id( |
|
|
|
|
$row['extra_' . $this->extraFieldIdNameList['course']], |
|
|
|
|
$this->extraFieldIdNameList['course'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$courseInfo = api_get_course_info_by_id($courseId); |
|
|
|
|
$courseInfo = api_get_course_info($courseCode); |
|
|
|
|
|
|
|
|
|
if (empty($courseInfo)) { |
|
|
|
|
// Create |
|
|
|
@ -942,16 +987,66 @@ class ImportCsv |
|
|
|
|
// Update |
|
|
|
|
$params = array( |
|
|
|
|
'title' => $row['title'], |
|
|
|
|
'category_code' => $row['course_category'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$result = CourseManager::update_attributes($courseInfo['real_id'], $params); |
|
|
|
|
$result = CourseManager::update_attributes( |
|
|
|
|
$courseInfo['real_id'], |
|
|
|
|
$params |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$addTeacherToSession = isset($courseInfo['add_teachers_to_sessions_courses']) && !empty($courseInfo['add_teachers_to_sessions_courses']) ? true : false; |
|
|
|
|
|
|
|
|
|
$teachers = $row['teachers']; |
|
|
|
|
if (!is_array($teachers)) { |
|
|
|
|
$teachers = array($teachers); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($addTeacherToSession) { |
|
|
|
|
CourseManager::updateTeachers($courseInfo['real_id'], $row['teachers'], false, true, false); |
|
|
|
|
CourseManager::updateTeachers( |
|
|
|
|
$courseInfo['id'], |
|
|
|
|
$row['teachers'], |
|
|
|
|
false, |
|
|
|
|
true, |
|
|
|
|
false, |
|
|
|
|
$teacherBackup |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
CourseManager::updateTeachers($courseInfo['real_id'], $row['teachers'], false, false); |
|
|
|
|
CourseManager::updateTeachers( |
|
|
|
|
$courseInfo['id'], |
|
|
|
|
$row['teachers'], |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
$teacherBackup |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ($teachers as $teacherId) { |
|
|
|
|
if (isset($groupBackup['tutor'][$teacherId]) && |
|
|
|
|
isset($groupBackup['tutor'][$teacherId][$courseInfo['code']]) |
|
|
|
|
) { |
|
|
|
|
foreach ($groupBackup['tutor'][$teacherId][$courseInfo['code']] as $data) { |
|
|
|
|
GroupManager::subscribe_tutors( |
|
|
|
|
array($teacherId), |
|
|
|
|
$data['group_id'], |
|
|
|
|
$data['c_id'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($groupBackup['user'][$teacherId]) && |
|
|
|
|
isset($groupBackup['user'][$teacherId][$courseInfo['code']]) && |
|
|
|
|
!empty($groupBackup['user'][$teacherId][$courseInfo['code']]) |
|
|
|
|
) { |
|
|
|
|
foreach ($groupBackup['user'][$teacherId][$courseInfo['code']] as $data) { |
|
|
|
|
GroupManager::subscribe_users( |
|
|
|
|
array($teacherId), |
|
|
|
|
$data['group_id'], |
|
|
|
|
$data['c_id'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($result) { |
|
|
|
@ -1012,7 +1107,7 @@ class ImportCsv |
|
|
|
|
// Looping the sessions. |
|
|
|
|
foreach ($sessions as $session) { |
|
|
|
|
if (!empty($session['SessionID'])) { |
|
|
|
|
$sessionId = SessionManager::getSessionIdFromOriginalId( |
|
|
|
|
$sessionId = SessionManager::get_session_id_from_original_id( |
|
|
|
|
$session['SessionID'], |
|
|
|
|
$this->extraFieldIdNameList['session'] |
|
|
|
|
); |
|
|
|
@ -1021,8 +1116,8 @@ class ImportCsv |
|
|
|
|
$categoryId = isset($session['category_id']) ? $session['category_id'] : null; |
|
|
|
|
|
|
|
|
|
// 2014-06-30 |
|
|
|
|
$dateStart = str_replace('/', '-', $session['DateStart']); |
|
|
|
|
$dateEnd = str_replace('/', '-', $session['DateEnd']); |
|
|
|
|
$dateStart = explode('/', $session['DateStart']); |
|
|
|
|
$dateEnd = explode('/', $session['DateEnd']); |
|
|
|
|
$visibility = $this->defaultSessionVisibility; |
|
|
|
|
|
|
|
|
|
$coachId = null; |
|
|
|
@ -1031,30 +1126,22 @@ class ImportCsv |
|
|
|
|
$coachId = $coachInfo['user_id']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$coachStartDate = null; |
|
|
|
|
if (!empty($this->daysCoachAccessBeforeBeginning)) { |
|
|
|
|
$day = intval($this->daysCoachAccessBeforeBeginning); |
|
|
|
|
$coachStartDate = date('Y-m-d ', strtotime($dateStart. ' + '.$day.' days')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$coachEndDate = null; |
|
|
|
|
if (!empty($this->daysCoachAccessAfterBeginning)) { |
|
|
|
|
$day = intval($this->daysCoachAccessAfterBeginning); |
|
|
|
|
$coachEndDate = date('Y-m-d ', strtotime($dateEnd. ' + '.$day.' days')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (empty($sessionId)) { |
|
|
|
|
$result = SessionManager::create_session( |
|
|
|
|
$session['SessionName'], |
|
|
|
|
$dateStart, |
|
|
|
|
$dateEnd, |
|
|
|
|
$dateStart, |
|
|
|
|
$dateEnd, |
|
|
|
|
$coachStartDate, |
|
|
|
|
$coachEndDate, |
|
|
|
|
$coachId, |
|
|
|
|
$dateStart[0], |
|
|
|
|
$dateStart[1], |
|
|
|
|
$dateStart[2], |
|
|
|
|
$dateEnd[0], |
|
|
|
|
$dateEnd[1], |
|
|
|
|
$dateEnd[2], |
|
|
|
|
$this->daysCoachAccessBeforeBeginning, |
|
|
|
|
$this->daysCoachAccessAfterBeginning, |
|
|
|
|
null, |
|
|
|
|
$coachUserName, |
|
|
|
|
$categoryId, |
|
|
|
|
$visibility |
|
|
|
|
$visibility, |
|
|
|
|
1 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (is_numeric($result)) { |
|
|
|
@ -1068,21 +1155,43 @@ class ImportCsv |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
$sessionInfo = api_get_session_info($sessionId); |
|
|
|
|
$accessBefore = null; |
|
|
|
|
$accessAfter = null; |
|
|
|
|
|
|
|
|
|
if (empty($sessionInfo['nb_days_access_before_beginning']) || |
|
|
|
|
(!empty($sessionInfo['nb_days_access_before_beginning']) && |
|
|
|
|
$sessionInfo['nb_days_access_before_beginning'] < $this->daysCoachAccessBeforeBeginning) |
|
|
|
|
) { |
|
|
|
|
$accessBefore = intval($this->daysCoachAccessBeforeBeginning); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$accessAfter = null; |
|
|
|
|
if (empty($sessionInfo['nb_days_access_after_end']) || |
|
|
|
|
(!empty($sessionInfo['nb_days_access_after_end']) && |
|
|
|
|
$sessionInfo['nb_days_access_after_end'] < $this->daysCoachAccessAfterBeginning) |
|
|
|
|
) { |
|
|
|
|
$accessAfter = intval($this->daysCoachAccessAfterBeginning); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$showDescription = isset($sessionInfo['show_description']) ? $sessionInfo['show_description'] : 1; |
|
|
|
|
|
|
|
|
|
$result = SessionManager::edit_session( |
|
|
|
|
$sessionId, |
|
|
|
|
$session['SessionName'], |
|
|
|
|
$dateStart, |
|
|
|
|
$dateEnd, |
|
|
|
|
$dateStart, |
|
|
|
|
$dateEnd, |
|
|
|
|
$sessionInfo['coach_access_start_date'], |
|
|
|
|
$sessionInfo['coach_access_end_date'], |
|
|
|
|
$dateStart[0], |
|
|
|
|
$dateStart[1], |
|
|
|
|
$dateStart[2], |
|
|
|
|
$dateEnd[0], |
|
|
|
|
$dateEnd[1], |
|
|
|
|
$dateEnd[2], |
|
|
|
|
$accessBefore, |
|
|
|
|
$accessAfter, |
|
|
|
|
null, |
|
|
|
|
$coachId, |
|
|
|
|
$categoryId, |
|
|
|
|
$visibility, |
|
|
|
|
true, //$start_limit = |
|
|
|
|
true, //$end_limit = |
|
|
|
|
null, //$description |
|
|
|
|
$showDescription // $showDescription = null, |
|
|
|
|
); |
|
|
|
@ -1101,7 +1210,6 @@ class ImportCsv |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Courses |
|
|
|
|
|
|
|
|
|
$courses = explode('|', $session['Courses']); |
|
|
|
|
$courseList = array(); |
|
|
|
|
foreach ($courses as $course) { |
|
|
|
@ -1123,8 +1231,6 @@ class ImportCsv |
|
|
|
|
foreach ($courses as $course) { |
|
|
|
|
$courseArray = bracketsToArray($course); |
|
|
|
|
$courseCode = $courseArray[0]; |
|
|
|
|
$courseInfo = api_get_course_info($courseCode); |
|
|
|
|
|
|
|
|
|
if (CourseManager::course_exists($courseCode)) { |
|
|
|
|
// Coaches |
|
|
|
|
$courseCoaches = isset($courseArray[1]) ? $courseArray[1] : null; |
|
|
|
@ -1141,7 +1247,7 @@ class ImportCsv |
|
|
|
|
} |
|
|
|
|
SessionManager::updateCoaches( |
|
|
|
|
$sessionId, |
|
|
|
|
$courseInfo['real_id'], |
|
|
|
|
$courseCode, |
|
|
|
|
$coachList, |
|
|
|
|
true |
|
|
|
|
); |
|
|
|
@ -1150,7 +1256,6 @@ class ImportCsv |
|
|
|
|
// Students |
|
|
|
|
$courseUsers = isset($courseArray[2]) ? $courseArray[2] : null; |
|
|
|
|
$courseUsers = explode(',', $courseUsers); |
|
|
|
|
|
|
|
|
|
if (!empty($courseUsers)) { |
|
|
|
|
$userList = array(); |
|
|
|
|
foreach ($courseUsers as $username) { |
|
|
|
@ -1189,8 +1294,10 @@ class ImportCsv |
|
|
|
|
/** |
|
|
|
|
* @param string $file |
|
|
|
|
* @param bool $moveFile |
|
|
|
|
* @param array $teacherBackup |
|
|
|
|
* @param array $groupBackup |
|
|
|
|
*/ |
|
|
|
|
private function importSessions($file, $moveFile = true) |
|
|
|
|
private function importSessions($file, $moveFile = true, &$teacherBackup = array(), &$groupBackup = array()) |
|
|
|
|
{ |
|
|
|
|
$avoid = null; |
|
|
|
|
if (isset($this->conditions['importSessions']) && |
|
|
|
@ -1214,7 +1321,9 @@ class ImportCsv |
|
|
|
|
true, // sessionWithCoursesModifier |
|
|
|
|
true, //$addOriginalCourseTeachersAsCourseSessionCoaches |
|
|
|
|
true, //$removeAllTeachersFromCourse |
|
|
|
|
1 // $showDescription |
|
|
|
|
1, // $showDescription, |
|
|
|
|
$teacherBackup, |
|
|
|
|
$groupBackup |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!empty($result['error_message'])) { |
|
|
|
@ -1255,7 +1364,7 @@ class ImportCsv |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userId = UserManager::get_user_id_from_username($chamiloUserName); |
|
|
|
|
$userId = Usermanager::get_user_id_from_username($chamiloUserName); |
|
|
|
|
|
|
|
|
|
if (empty($userId)) { |
|
|
|
|
$this->logger->addError('User does not exists: '.$chamiloUserName); |
|
|
|
@ -1276,7 +1385,7 @@ class ImportCsv |
|
|
|
|
SessionManager::set_coach_to_course_session( |
|
|
|
|
$userId, |
|
|
|
|
$chamiloSessionId, |
|
|
|
|
$courseInfo['real_id'] |
|
|
|
|
$courseInfo['code'] |
|
|
|
|
); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -1291,7 +1400,7 @@ class ImportCsv |
|
|
|
|
/** |
|
|
|
|
* @param string $file |
|
|
|
|
*/ |
|
|
|
|
private function importUnsubscribeStatic($file) |
|
|
|
|
private function importUnsubscribeStatic($file, $moveFile = false, &$teacherBackup = array(), &$groupBackup = array()) |
|
|
|
|
{ |
|
|
|
|
$data = Import::csv_reader($file); |
|
|
|
|
|
|
|
|
@ -1315,14 +1424,50 @@ class ImportCsv |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userId = UserManager::get_user_id_from_username($chamiloUserName); |
|
|
|
|
$userId = Usermanager::get_user_id_from_username($chamiloUserName); |
|
|
|
|
|
|
|
|
|
if (empty($userId)) { |
|
|
|
|
$this->logger->addError('User does not exists: '.$chamiloUserName); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CourseManager::unsubscribe_user($userId, $courseInfo['code'], $chamiloSessionId); |
|
|
|
|
$sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
|
|
|
WHERE |
|
|
|
|
user_id = ".$userId." AND |
|
|
|
|
course_code = '".$courseInfo['code']."' |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$userCourseData = Database::fetch_array($result, 'ASSOC'); |
|
|
|
|
$teacherBackup[$userId][$courseInfo['code']] = $userCourseData; |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM ".Database::get_course_table(TABLE_GROUP_USER)." |
|
|
|
|
WHERE |
|
|
|
|
user_id = ".$userId." AND |
|
|
|
|
c_id = '".$courseInfo['real_id']."' |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
while ($groupData = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
|
$groupBackup['user'][$userId][$courseInfo['code']][$groupData['group_id']] = $groupData; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM ".Database::get_course_table(TABLE_GROUP_TUTOR)." |
|
|
|
|
WHERE |
|
|
|
|
user_id = ".$userId." AND |
|
|
|
|
c_id = '".$courseInfo['real_id']."' |
|
|
|
|
"; |
|
|
|
|
|
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
while ($groupData = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
|
$groupBackup['tutor'][$userId][$courseInfo['code']][$groupData['group_id']] = $groupData; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CourseManager::unsubscribe_user( |
|
|
|
|
$userId, |
|
|
|
|
$courseInfo['code'], |
|
|
|
|
$chamiloSessionId |
|
|
|
|
); |
|
|
|
|
$this->logger->addError( |
|
|
|
|
"User '$chamiloUserName' was removed from session: #$chamiloSessionId, Course: ".$courseInfo['code'] |
|
|
|
|
); |
|
|
|
@ -1345,65 +1490,108 @@ class ImportCsv |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
// Course |
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_COURSE); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
// Sessions |
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_SESSION); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_SESSION_USER); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
// Truncate tables |
|
|
|
|
$truncateTables = array( |
|
|
|
|
Database::get_main_table(TABLE_MAIN_COURSE), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_COURSE_USER), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_CATEGORY), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_COURSE_MODULE), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION_COURSE), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION_USER), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_USER_FIELD), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_COURSE_FIELD), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_COURSE_FIELD_VALUES), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION_FIELD), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES), |
|
|
|
|
Database::get_course_table(TABLE_AGENDA), |
|
|
|
|
Database::get_course_table(TABLE_AGENDA_ATTACHMENT), |
|
|
|
|
Database::get_course_table(TABLE_AGENDA_REPEAT), |
|
|
|
|
Database::get_course_table(TABLE_AGENDA_REPEAT_NOT), |
|
|
|
|
Database::get_main_table(TABLE_PERSONAL_AGENDA), |
|
|
|
|
Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT_NOT), |
|
|
|
|
Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_CALENDAR_EVENT_VALUES), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_UPLOADS), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTSPOT), |
|
|
|
|
Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT_LOG), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY), |
|
|
|
|
Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE), |
|
|
|
|
Database::get_course_table(TABLE_STUDENT_PUBLICATION), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_QUESTION), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_TEST), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_ORDER), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_ANSWER), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_TEST_QUESTION), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY), |
|
|
|
|
Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY), |
|
|
|
|
Database::get_course_table(TABLE_LP_MAIN), |
|
|
|
|
Database::get_course_table(TABLE_LP_ITEM), |
|
|
|
|
Database::get_course_table(TABLE_LP_VIEW), |
|
|
|
|
Database::get_course_table(TABLE_LP_ITEM_VIEW), |
|
|
|
|
Database::get_course_table(TABLE_DOCUMENT), |
|
|
|
|
Database::get_course_table(TABLE_ITEM_PROPERTY), |
|
|
|
|
Database::get_course_table(TABLE_TOOL_LIST), |
|
|
|
|
Database::get_course_table(TABLE_TOOL_INTRO), |
|
|
|
|
Database::get_course_table(TABLE_COURSE_SETTING), |
|
|
|
|
Database::get_course_table(TABLE_SURVEY), |
|
|
|
|
Database::get_course_table(TABLE_SURVEY_QUESTION), |
|
|
|
|
Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION), |
|
|
|
|
Database::get_course_table(TABLE_SURVEY_INVITATION), |
|
|
|
|
Database::get_course_table(TABLE_SURVEY_ANSWER), |
|
|
|
|
Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP), |
|
|
|
|
Database::get_course_table(TABLE_SURVEY_REPORT), |
|
|
|
|
Database::get_course_table(TABLE_GLOSSARY), |
|
|
|
|
Database::get_course_table(TABLE_LINK), |
|
|
|
|
Database::get_course_table(TABLE_LINK_CATEGORY), |
|
|
|
|
Database::get_course_table(TABLE_GROUP), |
|
|
|
|
Database::get_course_table(TABLE_GROUP_USER), |
|
|
|
|
Database::get_course_table(TABLE_GROUP_TUTOR), |
|
|
|
|
Database::get_course_table(TABLE_GROUP_CATEGORY), |
|
|
|
|
Database::get_course_table(TABLE_DROPBOX_CATEGORY), |
|
|
|
|
Database::get_course_table(TABLE_DROPBOX_FEEDBACK), |
|
|
|
|
Database::get_course_table(TABLE_DROPBOX_POST), |
|
|
|
|
Database::get_course_table(TABLE_DROPBOX_FILE), |
|
|
|
|
Database::get_course_table(TABLE_DROPBOX_PERSON) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Extra fields |
|
|
|
|
$table = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
|
|
|
$sql = "DELETE FROM $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
foreach ($truncateTables as $table) { |
|
|
|
|
$sql = "TRUNCATE $table"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo $sql.PHP_EOL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
use Monolog\Handler\BufferHandler; |
|
|
|
|
use Monolog\Handler\RotatingFileHandler; |
|
|
|
|
use Monolog\Handler\StreamHandler; |
|
|
|
|
use Monolog\Logger; |
|
|
|
|
use Monolog\Handler\StreamHandler; |
|
|
|
|
use Monolog\Handler\NativeMailerHandler; |
|
|
|
|
use Monolog\Handler\RotatingFileHandler; |
|
|
|
|
use Monolog\Handler\BufferHandler; |
|
|
|
|
|
|
|
|
|
$logger = new Logger('cron'); |
|
|
|
|
$emails = isset($_configuration['cron_notification_mails']) ? $_configuration['cron_notification_mails'] : null; |
|
|
|
@ -1467,7 +1655,7 @@ if (isset($_configuration['import_csv_fix_permissions']) && |
|
|
|
|
echo "Executing: ".$command.PHP_EOL; |
|
|
|
|
system($command); |
|
|
|
|
|
|
|
|
|
$command = "sudo find ".api_get_path(SYS_UPLOAD_PATH)."users -type d -exec chmod 777 {} \;"; |
|
|
|
|
$command = "sudo find ".api_get_path(SYS_CODE_PATH)."upload/users -type d -exec chmod 777 {} \;"; |
|
|
|
|
echo "Executing: ".$command.PHP_EOL; |
|
|
|
|
system($command); |
|
|
|
|
} |
|
|
|
|