This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, 6.0 has been updated
via 7624fc59ed69cbb1d4326e51e5274a1d9bd3816d (commit)
via e0594b49a767c500051fff39f43959b0e47732f4 (commit)
via 32e8119ba1c0724af70cb2dc26a73398e8595854 (commit)
from 1c676d1ec83e80fd3f42e1f6aad49562f7a14bcb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 7624fc59ed69cbb1d4326e51e5274a1d9bd3816d
Merge: 1c676d1 e0594b4
Author: Franck Villaume <[email protected]>
Date: Mon Apr 6 13:56:54 2015 +0200
Merge Branch_5_3
diff --cc src/www/pm/postuploadcsv.php
index c81b8f3,3c2a0f2..0cdf95b
--- a/src/www/pm/postuploadcsv.php
+++ b/src/www/pm/postuploadcsv.php
@@@ -45,85 -44,71 +45,85 @@@ require_once $gfcommon.'pm/import_utils
$input_file = getUploadedFile('userfile');
if (isset($input_file) && isset($input_file['tmp_name']) &&
- is_uploaded_file($input_file['tmp_name'])) {
- $handle = fopen($input_file['tmp_name'], 'r');
- $tasks = array();
+ is_uploaded_file($input_file['tmp_name'])) {
- // Detect separator & if headers are present or not.
- $sep = ',';
- $values = fgetcsv($handle, 4096, $sep);
- if (count($values) == 1) {
- $sep = ';';
- fseek($handle, 0);
- $values = fgetcsv($handle, 4096, $sep);
+ if (function_exists('finfo_open')) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $uploaded_data_type = finfo_file($finfo,
$input_file['tmp_name']);
+ } else {
+ $uploaded_data_type = $input_file['type'];
}
- $headers = (in_array('project_task_id', $values) && in_array('title',
$values));
- // Rewind the file.
- fseek($handle, 0);
- if ($headers) {
- // Headers are given in the file (first line).
- $headers = array_flip(fgetcsv($handle, 4096, $sep));
- while (($values = fgetcsv($handle, 4096, $sep)) !== false) {
- $task = array();
- foreach($headers as $name => $id) {
- if ($name == 'project_task_id') $name = 'id';
- if ($name == 'title') $name = 'name';
- $task[$name] = $values[$id];
- }
- $tasks[] = $task;
+ if ($uploaded_data_type === "text/plain") {
+
+ $handle = fopen($input_file['tmp_name'], 'r');
+ $tasks = array();
+
+ // Detect separator & if headers are present or not.
+ $sep = ',';
+ $values = fgetcsv($handle, 4096, $sep);
+ if (count($values) == 1) {
+ $sep = ';';
+ fseek($handle, 0);
+ $values = fgetcsv($handle, 4096, $sep);
}
- } else {
- // Original code (default format, no headers)
- while (($cols = fgetcsv($handle, 4096, $sep)) !== false) {
+ $headers = (in_array('project_task_id', $values) &&
in_array('title', $values));
- $resources = array();
- for ($i=12;$i<17;$i++) {
- if (trim($cols[$i]) != '') {
- $resources[] =
array('user_name'=>$cols[$i]);
+ // Rewind the file.
+ fseek($handle, 0);
+
+ if ($headers) {
+ // Headers are given in the file (first line).
+ $headers = array_flip(fgetcsv($handle, 4096, $sep));
+ while (($values = fgetcsv($handle, 4096, $sep)) !==
false) {
+ $task = array();
+ foreach($headers as $name => $id) {
+ if ($name == 'project_task_id') $name =
'id';
+ if ($name == 'title') $name = 'name';
+ $task[$name] = $values[$id];
}
+ $tasks[] = $task;
}
+ } else {
+ // Original code (default format, no headers)
+ while (($cols = fgetcsv($handle, 4096, $sep)) !==
false) {
+
+ $resources = array();
+ for ($i=12;$i<17;$i++) {
+ if (trim($cols[$i]) != '') {
+ $resources[] =
array('user_name'=>$cols[$i]);
+ }
+ }
- $dependentOn = array();
+ $dependentOn = array();
- for ($i=17;$i<30;$i=$i+3) {
- if (trim($cols[$i]) != '') {
- $dependentOn[] =
array('task_id'=>$cols[$i], 'msproj_id'=>$cols[$i+1], 'task_name'=>'',
'link_type'=>$cols[$i+2]);
+ for ($i=17;$i<30;$i=$i+3) {
+ if (trim($cols[$i]) != '') {
+ $dependentOn[] =
array('task_id'=>$cols[$i], 'msproj_id'=>$cols[$i+1], 'task_name'=>'',
'link_type'=>$cols[$i+2]);
+ }
}
- }
- $tasks[] = array('id'=>$cols[0],
- 'msproj_id'=>$cols[1],
- 'parent_id'=>$cols[2],
- 'parent_msproj_id'=>$cols[3],
- 'name'=>$cols[4],
- 'duration'=>$cols[5],
- 'work'=>$cols[6],
- 'start_date'=>$cols[7],
- 'end_date'=>$cols[8],
- 'percent_complete'=>$cols[9],
- 'priority'=>$cols[10],
- 'resources'=>$resources,
- 'dependenton'=>$dependentOn,
- 'notes'=>$cols[11]);
+ $tasks[] = array('id'=>$cols[0],
+ 'msproj_id'=>$cols[1],
+ 'parent_id'=>$cols[2],
+ 'parent_msproj_id'=>$cols[3],
+ 'name'=>$cols[4],
+ 'duration'=>$cols[5],
+ 'work'=>$cols[6],
+ 'start_date'=>$cols[7],
+ 'end_date'=>$cols[8],
+ 'percent_complete'=>$cols[9],
+ 'priority'=>$cols[10],
+ 'resources'=>$resources,
+ 'dependenton'=>$dependentOn,
+ 'notes'=>$cols[11]);
+ }
- $res = &pm_import_tasks($group_project_id, $tasks);
++ $res = &pm_import_tasks($group_project_id, $tasks,
getIntFromRequest('replace') == 1);
}
+ } else {
+ $res['errormessage'] = _('Wrong file type. Only plain CSV file
supported');
}
- $res=&pm_import_tasks($group_project_id, $tasks,
getIntFromRequest('replace') == 1);
} else {
$res['errormessage'] = _('Parameter error');
}
-----------------------------------------------------------------------
Summary of changes:
src/CHANGES | 1 +
src/common/pm/import_utils.php | 4 ++--
src/www/pm/csv.php | 6 ++++--
src/www/pm/postuploadcsv.php | 2 +-
4 files changed, 8 insertions(+), 5 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits