Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
4aaf174c
Commit
4aaf174c
authored
Nov 21, 2011
by
Penom Nom
Browse files
No commit message
No commit message
parent
c839b015
Changes
1
Hide whitespace changes
Inline
Side-by-side
ui/nG6/class.tx_nG6_eid.php
View file @
4aaf174c
{
*
Copyright
(
C
)
2009
INRA
This
program
is
free
software
:
you
can
redistribute
it
and
/
or
modify
it
under
the
terms
of
the
GNU
General
Public
License
as
published
by
the
Free
Software
Foundation
,
either
version
3
of
the
License
,
or
(
at
your
option
)
any
later
version
.
This
program
is
distributed
in
the
hope
that
it
will
be
useful
,
but
WITHOUT
ANY
WARRANTY
;
without
even
the
implied
warranty
of
MERCHANTABILITY
or
FITNESS
FOR
A
PARTICULAR
PURPOSE
.
See
the
GNU
General
Public
License
for
more
details
.
You
should
have
received
a
copy
of
the
GNU
General
Public
License
along
with
this
program
.
If
not
,
see
<
http
://
www
.
gnu
.
org
/
licenses
/>.
*
}
<
div
id
=
"user_information_dialog"
title
=
""
></
div
>
<
div
id
=
"error_dialog"
title
=
""
></
div
>
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009 PF bioinformatique de Toulouse <>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
require_once
(
PATH_t3lib
.
'class.t3lib_befunc.php'
);
require_once
(
PATH_t3lib
.
'stddb/tables.php'
);
require_once
(
t3lib_extMgm
::
extPath
(
'cms'
,
'ext_tables.php'
));
require_once
(
PATH_t3lib
.
'class.t3lib_db.php'
);
require_once
(
t3lib_extMgm
::
extPath
(
'nG6'
)
.
'/lib/class.tx_nG6_db.php'
);
require_once
(
t3lib_extMgm
::
extPath
(
'nG6'
)
.
'/lib/class.tx_nG6_utils.php'
);
require_once
(
t3lib_extMgm
::
extPath
(
'nG6'
)
.
'/lib/class.tx_nG6_process.php'
);
/**
* Class 'tx_nG6_eid' for the 'nG6' extension.
* This class is in charge of all communication between the client and the server using AJAX
*
* @author PF bioinformatique de Toulouse <>
*/
class
tx_nG6_eid
{
/**
* The main function of the tx_nG6_eid, this function is the one called when using ajax
*/
function
main
()
{
// Connect to the databse
tslib_eidtools
::
connectDB
();
$type
=
trim
(
t3lib_div
::
_GP
(
'type'
));
$user_group
=
trim
(
t3lib_div
::
_GP
(
'user_group'
));
// If the type of data requested is project
if
(
$type
==
'project'
)
{
$project_id
=
trim
(
t3lib_div
::
_GP
(
'id'
));
// Select all runs linked to the project
$project_runs
=
tx_nG6_db
::
get_project_runs
(
$user_group
,
$project_id
,
'tx_nG6_run.date DESC'
);
// for each run
$html_tree
=
''
;
foreach
(
$project_runs
as
$run_id
=>
$run_values
)
{
$html_tree
.
=
'<li class="jstree-closed" name=\''
.
str_replace
(
array
(
'###SPAN_NAME###'
,
'###SPAN_DATE###'
),
array
(
$run_values
[
'name'
],
strftime
(
'%d-%m-%y'
,
$run_values
[
'date'
])),
trim
(
t3lib_div
::
_GP
(
'run_short_description'
)))
.
'\' id=\''
.
$run_id
.
'\'> <a href=\'#\'>'
.
str_replace
(
array
(
'###SPAN_NAME###'
,
'###SPAN_DATE###'
,
'###SPAN_NB_SEQ###'
,
'###SPAN_SPECIES###'
),
array
(
$run_values
[
'name'
],
strftime
(
'%d-%m-%y'
,
$run_values
[
'date'
]),
$run_values
[
'nb_sequences'
],
$run_values
[
'species'
]),
trim
(
t3lib_div
::
_GP
(
'run_description'
)))
.
'</a></li>'
;
}
// Then all project analysis
$project_analysis
=
tx_nG6_db
::
get_project_analysis
(
$user_group
,
$project_id
,
'tx_nG6_analyze.name'
);
foreach
(
$project_analysis
as
$analyse_id
=>
$analyse_values
)
{
$html_tree
.
=
'<li name=\''
.
str_replace
(
array
(
'###SPAN_NAME###'
),
array
(
$analyse_values
[
"name"
]),
trim
(
t3lib_div
::
_GP
(
'analyse_description'
)))
.
'\' id=\''
.
$analyse_id
.
'\'> <a href=\'#\'>'
.
str_replace
(
array
(
'###SPAN_NAME###'
),
array
(
$analyse_values
[
"name"
]),
trim
(
t3lib_div
::
_GP
(
'analyse_description'
)))
.
'</a></li>'
;
}
// Return the html_tree
print
$html_tree
;
// If the type of data requested is run
}
else
if
(
$type
==
'run'
){
$run_id
=
trim
(
t3lib_div
::
_GP
(
'id'
));
// Select all analysis linked to the run and the run information
$run_analysis
=
tx_nG6_db
::
get_run_analysis
(
$user_group
,
$run_id
,
'tx_nG6_analyze.name'
);
$run_info
=
tx_nG6_db
::
select_run
(
$run_id
);
// for each analysis
$html_tree
=
''
;
$html_tree
.
=
'<li name=\'run_'
.
$run_id
.
'_'
.
trim
(
t3lib_div
::
_GP
(
"raw_data_description"
))
.
'\' id=\'data_'
.
$run_id
.
'\'> <a href=\'#\'>'
.
trim
(
t3lib_div
::
_GP
(
"raw_data_description"
))
.
'</a></li>'
;
foreach
(
$run_analysis
as
$analyse_id
=>
$analyse_values
)
{
$html_tree
.
=
'<li name=\'run_'
.
$run_id
.
'_'
.
str_replace
(
array
(
'###SPAN_NAME###'
),
array
(
$analyse_values
[
"name"
]),
trim
(
t3lib_div
::
_GP
(
'analyse_description'
)))
.
'\' id=\''
.
$analyse_id
.
'\'> <a href=\'#\'>'
.
str_replace
(
array
(
'###SPAN_NAME###'
),
array
(
$analyse_values
[
"name"
]),
trim
(
t3lib_div
::
_GP
(
'analyse_description'
)))
.
'</a></li>'
;
}
// Return the html_tree
print
$html_tree
;
// If downloading data is requested
}
else
if
(
$type
==
'download'
)
{
$format
=
trim
(
t3lib_div
::
_GP
(
'format'
));
// If link in home directory
if
(
$format
==
'home_link'
)
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
$data_folder
=
trim
(
t3lib_div
::
_GP
(
'data_folder'
));
$user_login
=
trim
(
t3lib_div
::
_GP
(
'user_login'
));
$user_pwd
=
trim
(
t3lib_div
::
_GP
(
'user_pwd'
));
$user_directory
=
trim
(
t3lib_div
::
_GP
(
'user_directory'
));
$retcode
=
$this
->
create_symbolic_links
(
$user_group
,
$user_login
,
$user_pwd
,
$ids
,
$data_folder
,
$user_directory
);
print
$retcode
;
// If a .tar.gz file
}
else
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
$data_folder
=
trim
(
t3lib_div
::
_GP
(
'data_folder'
));
$tmp_folder
=
trim
(
t3lib_div
::
_GP
(
'tmp_folder'
));
$user_email
=
trim
(
t3lib_div
::
_GP
(
'user_email'
));
$title_email
=
trim
(
t3lib_div
::
_GP
(
'title_email'
));
$msg_email
=
trim
(
t3lib_div
::
_GP
(
'msg_email'
));
$archive_info
=
$this
->
create_archive_script
(
$user_group
,
$ids
,
$data_folder
,
$tmp_folder
,
"tar.gz"
,
$user_email
,
$title_email
,
$msg_email
);
$process
=
new
Process
(
"tcsh "
.
$archive_info
[
0
]);
print
"pid="
.
$process
->
getPid
()
.
"&archive_path="
.
$archive_info
[
1
];
}
// If asked to check a job status
}
else
if
(
$type
==
'check_status'
)
{
$pid
=
trim
(
t3lib_div
::
_GP
(
'pid'
));
$archive_path
=
trim
(
t3lib_div
::
_GP
(
'archive_path'
));
$process
=
new
Process
();
$process
->
setPid
(
$pid
);
// If the job is done
if
(
$process
->
status
())
{
print
"pid=0&archive_path="
.
$archive_path
;
// If the job is still runing
}
else
{
print
"pid="
.
$process
->
getPid
()
.
"&archive_path="
.
$archive_path
;
}
// If asked to hide a {project/run}
}
else
if
(
$type
==
'hide'
)
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
// {project/run}_id to array (1;2;3;...) -> [1;2;3;...]
$tab_ids
=
explode
(
";"
,
$ids
);
$hide_level
=
trim
(
t3lib_div
::
_GP
(
'hide_level'
));
if
(
$hide_level
==
'project'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
hide_project
(
$value
,
$user_group
);
}
}
else
if
(
$hide_level
==
'run'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
hide_run
(
$value
,
$user_group
);
}
}
else
if
(
$hide_level
==
'analysis'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
hide_analysis
(
$value
,
$user_group
);
}
}
// If asked to unhide a {project/run}
}
else
if
(
$type
==
'unhide'
)
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
// {project/run}_id to array (1;2;3;...) -> [1;2;3;...]
$tab_ids
=
explode
(
";"
,
$ids
);
$unhide_level
=
trim
(
t3lib_div
::
_GP
(
'unhide_level'
));
if
(
$unhide_level
==
'project'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
unhide_project
(
$value
,
$user_group
);
}
}
else
if
(
$unhide_level
==
'run'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
unhide_run
(
$value
,
$user_group
);
}
}
else
if
(
$unhide_level
==
'analysis'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
unhide_analysis
(
$value
,
$user_group
);
}
}
// If asked to delete a {project/run/analyze}
}
else
if
(
$type
==
'delete'
)
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
// {project/run}_id to array (1;2;3;...) -> [1;2;3;...]
$tab_ids
=
explode
(
";"
,
$ids
);
$delete_level
=
trim
(
t3lib_div
::
_GP
(
'del_level'
));
$data_folder
=
trim
(
t3lib_div
::
_GP
(
'data_folder'
));
$user_login
=
trim
(
t3lib_div
::
_GP
(
'user_login'
));
$user_pwd
=
trim
(
t3lib_div
::
_GP
(
'user_pwd'
));
$res
=
0
;
// check login and password
if
(
isset
(
$user_login
)
&&
isset
(
$user_pwd
)
&&
$user_login
!=
'undefined'
&&
$user_pwd
!=
'undefined'
)
{
$res
=
0
;
$connection
=
ssh2_connect
(
'127.0.0.1'
,
22
);
if
(
!
$connection
)
{
$res
=
3
;
}
if
(
!
ssh2_auth_password
(
$connection
,
$user_login
,
$user_pwd
))
{
$res
=
2
;}
}
else
{
$res
=
3
;
}
if
(
$res
==
0
)
{
if
(
$delete_level
==
'project'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
$res
=
tx_nG6_db
::
delete_project
(
$user_group
,
$value
,
$user_login
,
$user_pwd
,
$data_folder
);
if
(
$res
!=
0
)
{
break
;
}
}
}
else
if
(
$delete_level
==
'run'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
$res
=
tx_nG6_db
::
delete_run
(
$user_group
,
$value
,
$user_login
,
$user_pwd
,
$data_folder
);
if
(
$res
!=
0
)
{
break
;
}
}
}
else
if
(
$delete_level
==
'analysis'
)
{
foreach
(
$tab_ids
as
$id
=>
$value
)
{
$res
=
tx_nG6_db
::
delete_analysis
(
$value
,
$user_login
,
$user_pwd
,
$data_folder
);
if
(
$res
!=
0
)
{
break
;
}
}
}
}
print
$res
;
// If asked to publish a project
}
else
if
(
$type
==
'publish'
)
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
// project_id to array (1;2;3;...) -> [1;2;3;...]
$tab_ids
=
explode
(
";"
,
$ids
);
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
publish_project
(
$value
,
$user_group
);
}
// If asked to unpublish a project
}
else
if
(
$type
==
'unpublish'
)
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
// project_id to array (1;2;3;...) -> [1;2;3;...]
$tab_ids
=
explode
(
";"
,
$ids
);
foreach
(
$tab_ids
as
$id
=>
$value
)
{
tx_nG6_db
::
unpublish_project
(
$value
);
}
// If asked the size
}
else
if
(
$type
==
'get_size'
)
{
$ids
=
trim
(
t3lib_div
::
_GP
(
'ids'
));
$view
=
trim
(
t3lib_div
::
_GP
(
'view'
));
$data_folder
=
trim
(
t3lib_div
::
_GP
(
'data_folder'
));
$tab_ids
=
explode
(
","
,
$ids
);
$full_size
=
0
;
foreach
(
$tab_ids
as
$id
=>
$value
)
{
if
(
$view
==
"run"
)
{
$full_size
+=
tx_nG6_db
::
get_run_size
(
$value
,
$data_folder
,
$user_group
);
}
else
if
(
$view
==
"project"
)
{
$full_size
+=
tx_nG6_db
::
get_project_size
(
$value
,
$data_folder
,
$user_group
);
}
}
print
tx_nG6_utils
::
get_octet_string_representation
(
$full_size
);
// If update a field
}
else
if
(
$type
==
'update_db_field'
)
{
//Retrieve infomation
$entity
=
trim
(
t3lib_div
::
_GP
(
'entity'
));
$id
=
trim
(
t3lib_div
::
_GP
(
'id'
));
$field
=
trim
(
t3lib_div
::
_GP
(
'field'
));
$value
=
trim
(
t3lib_div
::
_GP
(
'value'
));
//If change concernes a date
if
(
$field
==
"date"
)
{
//Change date format
$date
=
explode
(
'-'
,
$value
)
;
$timestamp
=
mktime
(
0
,
0
,
1
,
$date
[
1
],
$date
[
0
],
$date
[
2
])
;
//Update the entity
tx_nG6_db
::
update_field
(
$entity
,
$id
,
$field
,
$timestamp
);
}
else
{
//Update the entity
tx_nG6_db
::
update_field
(
$entity
,
$id
,
$field
,
$value
);
}
print
$value
;
// If asked the krona page
}
else
if
(
$type
==
'get_krona'
)
{
$data_folder
=
trim
(
t3lib_div
::
_GP
(
'data_folder'
));
$file_name
=
trim
(
t3lib_div
::
_GP
(
'file_name'
));
$sequence_name
=
trim
(
t3lib_div
::
_GP
(
'sequence_name'
));
$doc
=
new
DomDocument
();
$data_root
=
$doc
->
createElement
(
'data'
);
$doc
->
appendChild
(
$data_root
);
$attr_data_root
=
$doc
->
createAttribute
(
"xml:id"
);
$data_root
->
appendChild
(
$attr_data_root
);
$t_data_root
=
$doc
->
createTextNode
(
'data_root'
);
$attr_data_root
->
appendChild
(
$t_data_root
);
$data_root
->
setIdAttribute
(
"xml:id"
,
true
);
$magnitude
=
$doc
->
createElement
(
'magnitude'
);
$magnitude
->
setAttribute
(
"attribute"
,
"g"
);
$magnitude
=
$data_root
->
appendChild
(
$magnitude
);
$magnitudet
=
$doc
->
createTextNode
(
''
);
$magnitudet
=
$magnitude
->
appendChild
(
$magnitudet
);
$color
=
$doc
->
createElement
(
'color'
);
$color
=
$data_root
->
appendChild
(
$color
);
$colort
=
$doc
->
createTextNode
(
''
);
$colort
=
$color
->
appendChild
(
$colort
);
$attributes
=
$doc
->
createElement
(
'attributes'
);
$attributes
->
setAttribute
(
"g"
,
$sequence_name
);
$attributes
=
$data_root
->
appendChild
(
$attributes
);
$attributest
=
$doc
->
createTextNode
(
''
);
$attributest
=
$attributes
->
appendChild
(
$attributest
);
$datasets
=
$doc
->
createElement
(
'datasets'
);
$datasets
->
setAttribute
(
"names"
,
$file_name
);
$datasets
=
$data_root
->
appendChild
(
$datasets
);
$datasetst
=
$doc
->
createTextNode
(
''
);
$datasetst
=
$datasets
->
appendChild
(
$datasetst
);
$file_path
=
trim
(
t3lib_div
::
_GP
(
'file_path'
));
$file_path
=
$data_folder
.
"/"
.
$file_path
;
// If the file exists
$total
=
0
;
if
(
file_exists
(
$file_path
))
{
$lines
=
file
(
$file_path
);
// Loop through our array
foreach
(
$lines
as
$line_num
=>
$line
)
{
if
(
$line
!=
""
)
{
$mparts
=
explode
(
"
\t
"
,
trim
(
$line
));
if
(
$mparts
[
0
]
!=
"taxlevel"
and
$mparts
[
0
]
!=
"0"
)
{
// If this guy doesnt exist yet
$id_searched
=
str_replace
(
"."
,
"_"
,
"node_"
.
$mparts
[
1
]);
if
(
is_null
(
$doc
->
getElementById
(
$id_searched
)))
{
$parentl
=
implode
(
"_"
,
array_slice
(
explode
(
"."
,
$mparts
[
1
]),
0
,
-
1
));
// If no parent yet, this is the root
if
(
is_null
(
$doc
->
getElementById
(
"node_"
.
$parentl
)))
{
$current_node
=
$doc
->
createElement
(
'node'
);
$current_node
->
setAttribute
(
"name"
,
$mparts
[
2
]);
$current_node
->
setAttribute
(
"g"
,
$mparts
[
4
]);
$id
=
$doc
->
getElementById
(
"data_root"
);
$id
->
appendChild
(
$current_node
);
$attr_current_node
=
$doc
->
createAttribute
(
"xml:id"
);
$current_node
->
appendChild
(
$attr_current_node
);
$t_current_node
=
$doc
->
createTextNode
(
"node_"
.
str_replace
(
"."
,
"_"
,
$mparts
[
1
]));
$attr_current_node
->
appendChild
(
$t_current_node
);
$current_node
->
setIdAttribute
(
"xml:id"
,
true
);
$current_nodet
=
$doc
->
createTextNode
(
''
);
$current_nodet
=
$current_node
->
appendChild
(
$current_nodet
);
}
else
{
$current_node
=
$doc
->
createElement
(
'node'
);
$current_node
->
setAttribute
(
"name"
,
$mparts
[
2
]);
$current_node
->
setAttribute
(
"g"
,
$mparts
[
4
]);
$id
=
$doc
->
getElementById
(
"node_"
.
$parentl
);
$id
->
appendChild
(
$current_node
);
$attr_current_node
=
$doc
->
createAttribute
(
"xml:id"
);
$current_node
->
appendChild
(
$attr_current_node
);
$t_current_node
=
$doc
->
createTextNode
(
"node_"
.
str_replace
(
"."
,
"_"
,
$mparts
[
1
]));
$attr_current_node
->
appendChild
(
$t_current_node
);
$current_node
->
setIdAttribute
(
"xml:id"
,
true
);
$current_nodet
=
$doc
->
createTextNode
(
''
);
$current_nodet
=
$current_node
->
appendChild
(
$current_nodet
);
}
}
}
if
(
$mparts
[
0
]
==
"1"
)
{
$total
+=
(
int
)
$mparts
[
4
];
}
}
}
}
$color
->
setAttribute
(
"attribute"
,
"g"
);
$color
->
setAttribute
(
"valueStart"
,
"0"
);
$color
->
setAttribute
(
"valueEnd"
,
(
string
)
$total
);
$color
->
setAttribute
(
"hueStart"
,
"120"
);
$color
->
setAttribute
(
"hueEnd"
,
"360"
);
$xml_string
=
$doc
->
saveXML
();
$xml_parts
=
explode
(
"
\n
"
,
$xml_string
);
$val
=
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
;
$val
.
=
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">'
;
$val
.
=
'<head>'
;
$val
.
=
'</head>'
;
$val
.
=
'<body>'
;
$val
.
=
'<div id="options" style="position:absolute;left:0;top:0"></div>'
;
$val
.
=
'<div id="details" style="position:absolute;top:1%;right:2%;text-align:right;"></div>'
;
$val
.
=
'<canvas id="canvas" width="100%" height="100%">This browser does not support HTML5</canvas><div>'
;
$val
.
=
'<img id="hiddenImage" src="http://krona.sourceforge.net/img/hidden.png" visibility="hide"/>'
;
$val
.
=
'<script name="tree" src="'
.
t3lib_extMgm
::
siteRelPath
(
'nG6'
)
.
'res/js/krona-1.1.js"></script>'
;
$val
.
=
$xml_parts
[
1
];
$val
.
=
'</div>'
;
$val
.
=
'</body>'
;
$val
.
=
'</html>'
;
print
$val
;
}
}
/**
* Creates an archiving script to archive data from ids
*
* @param string $user_group the user group
* @param array $ids list of ids to download
* @param string $data_folder the data folder where are stored the data
* @param string $tmp_folder the output directory
* @param string $format the archiving format (tar.gz)
* @param string $user_email the user email
* @param string $title_email the email title to send
* @param string $msg_email the email message to send
* @return array (the path to the script, the url path to the final archive)
*/
private
function
create_archive_script
(
$user_group
,
$ids
,
$data_folder
,
$tmp_folder
,
$format
,
$user_email
,
$title_email
,
$msg_email
)
{
// First get the archive name where will be stored the data
$random_key
=
tx_nG6_utils
::
create_random_key
(
10
);
$archive_path
=
$tmp_folder
.
"/ng6_"
.
$random_key
;
while
(
file_exists
(
$archive_path
)
)
$archive_path
=
$tmp_folder
.
"/ng6_"
.
$random_key
;
<
input
type
=
"hidden"
id
=
"cancel_btn_label"
value
=
"
{
$llang
.
cancel_btn_label
}
"
/>
<
input
type
=
"hidden"
id
=
"ok_btn_label"
value
=
"
{
$llang
.
ok_btn_label
}
"
/>
<
input
type
=
"hidden"
id
=
"yes_btn_label"
value
=
"
{
$llang
.
yes_btn_label
}
"
/>
<
input
type
=
"hidden"
id
=
"no_btn_label"
value
=
"
{
$llang
.
no_btn_label
}
"
/>
<
input
type
=
"hidden"
id
=
"confirmation_dialog_title"
value
=
"
{
$llang
.
confirmation_dialog_title
}
"
/>
<
input
type
=
"hidden"
id
=
"information_error_title"
value
=
"
{
$llang
.
information_error_title
}
"
/>
<
input
type
=
"hidden"
id
=
"hide_dialog_title"
value
=
"
{
$llang
.
hide_dialog_title
}
"
/>
<
input
type
=
"hidden"
id
=
"hide_confirmation_msg"
value
=
"
{
$llang
.
hide_confirmation_msg
}
"
/>
<
input
type
=
"hidden"
id
=
"unhide_dialog_title"
value
=
"
{
$llang
.
unhide_dialog_title
}
"
/>
<
input
type
=
"hidden"
id
=
"unhide_confirmation_msg"
value
=
"
{
$llang
.
unhide_confirmation_msg
}
"
/>
<
input
type
=
"hidden"
id
=
"information_error_msg"
value
=
"
{
$llang
.
information_error_msg
}
"
/>
// Then get the directories structure
$directories
=
$this
->
get_directories_structure_and_content
(
$user_group
,
$ids
,
$data_folder
,
$archive_path
);
$archive_script_path
=
$tmp_folder
.
"/ng6_"
.
$random_key
.
".sh"
;
<
input
type
=
"hidden"
id
=
"information_dialog_zero_check"
value
=
"
{
$llang
.
information_dialog_zero_check
}
"
/>
<
input
type
=
"hidden"
id
=
"delete_confirmation_msg"
value
=
"
{
$llang
.
delete_confirmation_msg
}
"
/>
<
input
type
=
"hidden"
id
=
"deleting_dialog_msg"
value
=
"
{
$llang
.
deleting_dialog_msg
}
"
/>
<
input
type
=
"hidden"
id
=
"delete_authentication_dialog_msg"
value
=
"
{
$llang
.
delete_authentication_dialog_msg
|
replace
:
'###SPAN_SERVER###'
:
$server_name
}
"
/>
// And write down the script in charge to create the archive
$fp
=
fopen
(
$archive_script_path
,
'w'
);
foreach
(
$directories
[
0
]
as
$index
=>
$src_directory
)
{
if
(
!
file_exists
(
$directories
[
1
][
$index
]))
{
fwrite
(
$fp
,
"mkdir -p "
.
$directories
[
1
][
$index
]
.
"
\n
"
);
}
// For each files in the source directory
foreach
(
scandir
(
$src_directory
)
as
$file
)
{
if
(
is_file
(
$src_directory
.
"/"
.
$file
)
and
$file
!=
"analyse.xml"
and
$file
!=
"index.html"
and
$file
!=
"run.cfg"
)
{
fwrite
(
$fp
,
"cp "
.
$src_directory
.
"/"
.
$file
.
" "
.
$directories
[
1
][
$index
]
.
"
\n
"
);
}
}
}
fwrite
(
$fp
,
"cd "
.
$tmp_folder
.
"
\n
"
);
fwrite
(
$fp
,
"tar -czf ng6_"
.
$random_key
.
".tar.gz ng6_"
.
$random_key
.
"
\n
"
);
fwrite
(
$fp
,
"rm -rf "
.
$archive_path
.
"
\n
"
);
fwrite
(
$fp
,
'echo "'
.
str_replace
(
array
(
'SPAN_ARCHIVE_NAME'
),
array
(
"ng6_"
.
$random_key
.
".tar.gz"
),
$msg_email
)
.
'" | mail -s "'
.
$title_email
.
'" '
.
$user_email
.
"
\n
"
);
fclose
(
$fp
);
return
array
(
$archive_script_path
,
"ng6_"
.
$random_key
.
".tar.gz"
);
}
/**
* Creates symbolic links between ids from data_folder into user_directory
*
* @param string $user_group the user group
* @param string $user_login the user login to make ssh
* @param string $user_pwd the user pwd to make ssh
* @param array $ids list of ids to download
* @param string $data_folder the data folder where are stored the data
* @param string $user_directory the output directory
* @return 0=>everything ok, 1=>user rigth problem, 2=>wrong authentification, 3=>connection error
*/
private
function
create_symbolic_links
(
$user_group
,
$user_login
,
$user_pwd
,
$ids
,
$data_folder
,
$user_directory
)
{
// First try to connect the specified user using ssh
$connection
=
ssh2_connect
(
'127.0.0.1'
,
22
);
if
(
!
$connection
)
return
3
;
if
(
!
ssh2_auth_password
(
$connection
,
$user_login
,
$user_pwd
))
return
2
;
<
input
type
=
"hidden"
id
=
"user_login"
value
=
"
{
$llang
.
user_login
}
"
/>
<
input
type
=
"hidden"
id
=
"user_pwd"
value
=
"
{
$llang
.
user_pwd
}
"
/>
<
input
type
=
"hidden"
id
=
"user_group"
value
=
"
{
$user_group
}
"
/>
// Then get the directories structure
$directories
=
$this
->
get_directories_structure_and_content
(
$user_group
,
$ids
,
$data_folder
,
$user_directory
);
// And process the directories structure
$creation
=
true
;
foreach
(
$directories
[
0
]
as
$index
=>
$src_directory
)
{
if
(
!
file_exists
(
"ssh2.sftp://"
.
$connection
.
$directories
[
1
][
$index
]))
{
if
(
!
mkdir
(
"ssh2.sftp://"
.
$connection
.
$directories
[
1
][
$index
],
0755
,
true
))
{
$creation
=
false
;
break
;
}
// For each files in the source directory
foreach
(
scandir
(
$src_directory
)
as
$file
)
{
if
(
is_file
(
$src_directory
.
"/"
.
$file
)
and
$file
!=
"analyse.xml"
and
$file
!=
"index.html"
and
$file
!=
"run.cfg"
)
{
if
(
!
ssh2_exec
(
$connection
,
'ln -s '
.
$src_directory
.
'/'
.
$file
.
' '
.
$directories
[
1
][
$index
]
.
'/'
.
$file
))
{
$creation
=
false
;
break
;
}
}
}
}
}
if
(
!
$creation
)
return
1
;
return
0
;
}
/**
* Returns a table with the right directories structure considering ids
*
* @param string $user_group the user group
* @param array $ids List of ids to download
* @param string $data_folder The data folder where are stored the data
* @param string $output_folder The output directory
* @return array [0] => source_directories, [1] => dest_directories
*/
private
function
get_directories_structure_and_content
(
$user_group
,
$ids
,
$data_folder
,
$output_folder
)
{
$src_directories
=
array
();
$dest_directories
=
array
();
$vals
=
preg_split
(
"/;/"
,
$ids
);
<
input
type
=
"hidden"
id
=
"deleting_dialog_title"
value
=
"
{
$llang
.
deleting_dialog_title
}
"
/>
<
input
type
=
"hidden"
id
=
"delete_success_msg"
value
=
"
{
$llang
.
delete_success_msg
}
"
/>
<
input
type
=
"hidden"
id
=
"delete_dialog_rigth_error"
value
=
"
{
$llang
.
delete_dialog_rigth_error
}
"
/>
<
input
type
=
"hidden"
id
=
"delete_dialog_authentification_error"
value
=
"
{
$llang
.
delete_dialog_authentification_error
}
"
/>
<
input
type
=
"hidden"
id
=
"delete_dialog_connection_error"
value
=
"
{
$llang
.
delete_dialog_connection_error
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_length_menu"
value
=
"
{
$llang
.
DataTables_length_menu
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_zero_records"
value
=
"
{
$llang
.
DataTables_zero_records
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_info"
value
=
"
{
$llang
.
DataTables_info
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_info_empty"
value
=
"
{
$llang
.
DataTables_info_empty
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_info_filtered"
value
=
"
{
$llang
.
DataTables_info_filtered
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_search"
value
=
"
{
$llang
.
DataTables_search
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_pagination_first"
value
=
"
{
$llang
.
DataTables_pagination_first
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_pagination_last"
value
=
"
{
$llang
.
DataTables_pagination_last
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_pagination_next"
value
=
"
{
$llang
.
DataTables_pagination_next
}
"
/>
<
input
type
=
"hidden"
id
=
"DataTables_pagination_previous"
value
=
"
{
$llang
.
DataTables_pagination_previous
}
"
/>
<
input
type
=
"hidden"
id
=
"Jeditable_dblClickTitle"
value
=
"
{
$llang
.
Jeditable_dblClickTitle
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_closeText"
value
=
"
{
$llang
.
Datepicker_closeText
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_prevText"
value
=
"
{
$llang
.
Datepicker_prevText
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_nextText"
value
=
"
{
$llang
.
Datepicker_nextText
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_currentText"
value
=
"
{
$llang
.
Datepicker_currentText
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_monthNames"
value
=
"
{
$llang
.
Datepicker_monthNames
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_monthNamesShort"
value
=
"
{
$llang
.
Datepicker_monthNamesShort
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_dayNames"
value
=
"
{
$llang
.
Datepicker_dayNames
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_dayNamesShort"
value
=
"
{
$llang
.
Datepicker_dayNamesShort
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_dayNamesMin"
value
=
"
{
$llang
.
Datepicker_dayNamesMin
}
"
/>
<
input
type
=
"hidden"
id
=
"Datepicker_weekHeader"
value
=
"
{
$llang
.
Datepicker_weekHeader
}
"
/>
<
input
type
=
"hidden"
id
=
"data_folder"
value
=
"
{
$data_folder
}
"
/>
<
input
type
=
"hidden"
id
=
"view"
value
=
"run"
/>
<
input
type
=
"hidden"
id
=
"ids"
value
=
"
{
$run_ids
}
"
/>
{
*
If
no
runs
can
be
displayed
*
}
{
if
$runs
|@
count
==
0
}
{
$llang
.
no_raw
}
{
*
If
a
single
run
has
to
be
displayed
*
}
{
elseif
$runs
|@
count
==
1
}
<
div
class
=
"run"
>
<
h2
>
{
$llang
.
run
}
{
$runs
[
$first_id
]
.
name
}
:</
h2
>
<
p
><
strong
>
{
$runs
[
$first_id
]
.
description
}
</
strong
>
<
br
/>
{
if
$run_analysis
|@
count
>
0
}
{(
$llang
.
miltiple_analysis_run_desc
|
replace
:
"###RUN_NAME###"
:
$runs
[
$first_id
]
.
name
)
|
replace
:
"###NB_ANALYSIS###"
:
(
$run_analysis
|@
count
)}
{
else
}
{(
$llang
.
single_analysis_run_desc
|
replace
:
"###RUN_NAME###"
:
$runs
[
$first_id
]
.
name
)
|
replace
:
"###NB_ANALYSIS###"
:
(
$run_analysis
|@
count
)}
{
/
if
}
<
br
/>
{
assign
var
=
"run_size"
value
=
"<span id='size' class='tx-nG6-mini-wait'></span>"
}
{(
$llang
.
run_desc
|
replace
:
"###RUN_SIZE###"
:
"<strong>###RUN_SIZE###</strong>"
)
|
replace
:
"###RUN_SIZE###"
:
$run_size
}
</
p
>