Adding fields to avoid see BT#6449

1.9.x
Julio Montoya 11 years ago
parent 37f6995c9c
commit fbc9eaae24
  1. 7
      main/cron/import_csv.php
  2. 41
      main/inc/lib/sessionmanager.lib.php

@ -538,6 +538,10 @@ class ImportCsv
*/
private function importSessions($file)
{
$avoid = null;
if (isset($this->conditions['importSessions']) && isset($this->conditions['importSessions']['update'])) {
$avoid = $this->conditions['importSessions']['update'];
}
$result = SessionManager::importCSV(
$file,
true,
@ -547,7 +551,8 @@ class ImportCsv
$this->extraFieldIdNameList['session'],
$this->daysCoachAccessBeforeBeginning,
$this->daysCoachAccessAfterBeginning,
$this->defaultSessionVisibility
$this->defaultSessionVisibility,
$avoid
);
if (!empty($result['error_message'])) {

@ -1887,7 +1887,8 @@ class SessionManager
$extraFieldId = null,
$daysCoachAccessBeforeBeginning = null,
$daysCoachAccessAfterBeginning = null,
$sessionVisibility = 1
$sessionVisibility = 1,
$fieldsToAvoidUpdate = array()
)
{
$content = file($file);
@ -2045,7 +2046,7 @@ class SessionManager
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id'".$extraParameters;
session_category_id = '$session_category_id' ".$extraParameters;
Database::query($sql_session);
// We get the last insert id.
@ -2066,30 +2067,28 @@ class SessionManager
}
} else {
$params = array(
'id_coach' => $coach_id,
'date_start' => $date_start,
'date_end' => $date_end,
'visibility' => $visibility,
'session_category_id' => $session_category_id
);
if (!empty($fieldsToAvoidUpdate)) {
foreach ($fieldsToAvoidUpdate as $field) {
unset($params[$field]);
}
}
if (isset($sessionId) && !empty($sessionId)) {
// The session already exists, update it then.
$sql_session = "UPDATE $tbl_session SET
id_coach = '$coach_id',
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id'
WHERE id = '$sessionId'";
//name = '$session_name'
Database::query($sql_session);
Database::update($tbl_session, $params, array('id = ?' => $sessionId));
$session_id = $sessionId;
} else {
Database::update($tbl_session, $params, array("name = '?' " => $session_name));
// The session already exists, update it then.
$sql_session = "UPDATE $tbl_session SET
id_coach = '$coach_id',
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id'
WHERE name = '$session_name'";
Database::query($sql_session);
$row = Database::query("SELECT id FROM $tbl_session WHERE name='$session_name'");
$row = Database::query("SELECT id FROM $tbl_session WHERE name = '$session_name'");
list($session_id) = Database::fetch_array($row);
}

Loading…
Cancel
Save