projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't allow empty flags.
[platal.git]
/
classes
/
csvimporter.php
diff --git
a/classes/csvimporter.php
b/classes/csvimporter.php
index
6590df4
..
7d56bc8
100644
(file)
--- a/
classes/csvimporter.php
+++ b/
classes/csvimporter.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-20
08
Polytechnique.org *
+ * Copyright (C) 2003-20
10
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-64,12
+64,12
@@
class CSVImporter
return true;
}
return true;
}
-
private function getValue($line, $key, $action
)
+
static public function getValue($line, $key, $action, $relation = null
)
{
if (@array_key_exists($action, $line)) {
$value = $line[$action];
} elseif (is_callable($action, false)) {
{
if (@array_key_exists($action, $line)) {
$value = $line[$action];
} elseif (is_callable($action, false)) {
- $value = call_user_func($action, $line, $key);
+ $value = call_user_func($action, $line, $key
, $relation
);
} else {
$value = $action;
}
} else {
$value = $action;
}
@@
-83,7
+83,7
@@
class CSVImporter
{
$ops = array();
foreach ($relation as $key=>$ref) {
{
$ops = array();
foreach ($relation as $key=>$ref) {
- $ops[$key] = $this->getValue($line, $key, $ref);
+ $ops[$key] = $this->getValue($line, $key, $ref
, $relation
);
}
return $ops;
}
}
return $ops;
}
@@
-92,7
+92,7
@@
class CSVImporter
{
$ops = array();
foreach ($relation as $key=>$ref) {
{
$ops = array();
foreach ($relation as $key=>$ref) {
- $value = $this->getValue($line, $key, $ref);
+ $value = $this->getValue($line, $key, $ref
, $relation
);
if (!is_null($value) && $value != 'NULL') {
$value = "'" . addslashes($value) . "'";
}
if (!is_null($value) && $value != 'NULL') {
$value = "'" . addslashes($value) . "'";
}
@@
-239,7
+239,7
@@
class CSVImporter
}
/** Handle insertion form
}
/** Handle insertion form
- * @param $page Pl
atal
Page to process
+ * @param $page PlPage to process
* @param $url URI of the page
* @param $field Editable fields
*/
* @param $url URI of the page
* @param $field Editable fields
*/
@@
-330,6
+330,7
@@
class CSVImporter
$fields[] = $key;
}
if ($current == 'valid' && Env::has('csv_valid')) {
$fields[] = $key;
}
if ($current == 'valid' && Env::has('csv_valid')) {
+ S::assert_xsrf_token();
$this->run($_SESSION['csv_action'], $insert, $update);
$page->assign('csv_done', true);
$this->cleanSession($sesfields);
$this->run($_SESSION['csv_action'], $insert, $update);
$page->assign('csv_done', true);
$this->cleanSession($sesfields);