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
1881ae7b
Commit
1881ae7b
authored
Mar 19, 2021
by
Romain Therville
🐭
Browse files
Merge branch 'issue#192' into 'master'
Merge branch Issue#192 with master See merge request
!116
parents
75426c7e
e450a49e
Changes
5
Hide whitespace changes
Inline
Side-by-side
bin/ng6_database.sql
View file @
1881ae7b
...
...
@@ -1233,6 +1233,33 @@ CREATE ALGORITHM=UNDEFINED DEFINER=`ng6`@`localhost` SQL SECURITY DEFINER VIEW `
CREATE
ALGORITHM
=
UNDEFINED
DEFINER
=
`ng6`
@
`localhost`
SQL
SECURITY
DEFINER
VIEW
`tx_nG6_view_project_user`
AS
select
`tx_nG6_project`
.
`uid`
AS
`project_id`
,
`tx_nG6_project`
.
`space_id`
AS
`space_id`
,
`fe_users`
.
`uid`
AS
`user_id`
,
`fe_users`
.
`username`
AS
`user_name`
,
`fe_users`
.
`email`
AS
`email`
,
`fe_users`
.
`usergroup`
AS
`user_group`
,
`fe_rights_levels`
.
`right_level_label`
AS
`right_level_label`
,
`fe_groups`
.
`title`
AS
`user_group_title`
from
((((
`tx_nG6_project`
join
`fe_rights`
on
((
`fe_rights`
.
`project_id`
=
`tx_nG6_project`
.
`uid`
)))
join
`fe_users`
on
((
`fe_rights`
.
`fe_user_id`
=
`fe_users`
.
`uid`
)))
join
`fe_groups`
on
((
`fe_users`
.
`usergroup`
=
`fe_groups`
.
`uid`
)))
join
`fe_rights_levels`
on
((
`fe_rights_levels`
.
`right_level_id`
=
`fe_rights`
.
`right_id`
)));
--
-- Trigger check_demand_insert to prevent the insertion of a second purge demand for a single project
--
DELIMITER
;;
CREATE
TRIGGER
check_demand_insert
BEFORE
INSERT
ON
`tx_nG6_purge_demand`
FOR
EACH
ROW
BEGIN
DECLARE
var_demand_state
,
var_project_id
,
var_count
int
;
SELECT
demand_state
,
project_id
,
count
(
*
)
as
count
INTO
var_demand_state
,
var_project_id
,
var_count
FROM
tx_nG6_purge_demand
WHERE
demand_state
=
'sent'
AND
project_id
=
new
.
project_id
GROUP
BY
demand_state
,
project_id
;
IF
var_count
>
0
THEN
set
@
message_text
=
concat
(
'A purge demand already exists for project '
,
new
.
project_id
);
signal
sqlstate
'45000'
set
message_text
=
@
message_text
;
END
IF
;
END
;
;;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */
;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */
;
...
...
src/ng6/utils.py
View file @
1881ae7b
...
...
@@ -538,6 +538,7 @@ class SSH(object):
x
=
os
.
read
(
f
,
1024
)
except
Exception
as
e
:
# this always fails with io error
#raise Exception(e)
pass
return
x
.
decode
()
...
...
ui/nG6/lib/class.tx_nG6_db.php
View file @
1881ae7b
...
...
@@ -365,21 +365,24 @@ class tx_nG6_db {
'tstamp'
=>
$date
,
'crdate'
=>
$date
);
$GLOBALS
[
'TYPO3_DB'
]
->
exec_INSERTquery
(
'tx_nG6_purge_demand'
,
$purge_data
);
$purge_demand_id
=
$GLOBALS
[
'TYPO3_DB'
]
->
sql_insert_id
();
tx_nG6_db
::
update_field
(
'tx_nG6_run'
,
$all_runs_ids
,
array
(
'mail_sent_date'
,
'purge_demand_id'
),
array
(
$date
,
$purge_demand_id
));
tx_nG6_db
::
update_field
(
'tx_nG6_analyze'
,
$all_analyses_ids
,
array
(
'mail_sent_date'
,
'purge_demand_id'
),
array
(
$date
,
$purge_demand_id
));
foreach
(
$user_ids
as
$a_id
){
$purge_data_user
=
array
(
'tstamp'
=>
$date
,
'crdate'
=>
$date
,
'cruser_id'
=>
$cruser_id
,
'purge_demand_id'
=>
$purge_demand_id
,
'fe_users_id'
=>
$a_id
);
$GLOBALS
[
'TYPO3_DB'
]
->
exec_INSERTquery
(
'tx_nG6_purge_demand_fe_users'
,
$purge_data_user
);
if
(
$purge_demand_id
>
0
){
tx_nG6_db
::
update_field
(
'tx_nG6_run'
,
$all_runs_ids
,
array
(
'mail_sent_date'
,
'purge_demand_id'
),
array
(
$date
,
$purge_demand_id
));
tx_nG6_db
::
update_field
(
'tx_nG6_analyze'
,
$all_analyses_ids
,
array
(
'mail_sent_date'
,
'purge_demand_id'
),
array
(
$date
,
$purge_demand_id
));
foreach
(
$user_ids
as
$a_id
){
$purge_data_user
=
array
(
'tstamp'
=>
$date
,
'crdate'
=>
$date
,
'cruser_id'
=>
$cruser_id
,
'purge_demand_id'
=>
$purge_demand_id
,
'fe_users_id'
=>
$a_id
);
$GLOBALS
[
'TYPO3_DB'
]
->
exec_INSERTquery
(
'tx_nG6_purge_demand_fe_users'
,
$purge_data_user
);
}
}
return
$purge_demand_id
;
}
...
...
ui/nG6/lib/class.tx_nG6_utils.php
View file @
1881ae7b
...
...
@@ -266,6 +266,27 @@ $template_mail.='<p>Yours sincerely</p>
return
$mail
;
}
static
function
get_multiple_purge_demand_mail
(
$project_name
)
{
$template_mail
=
'
<html>
<head>
<title>Data Purge on nG6</title>
</head>
<body>
<p>Dear nG6 admin,</p>
<p>A purge demand already exists for the project ###PROJECT_NAME###.</p>
<p>Please, purge the data corresponding to the previous purge demand before opening a new one.</p></br>
<p>Yours sincerely</p>
<p>nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)</p>
</body>
</html>
'
;
$mail
=
str_replace
(
'###PROJECT_NAME###'
,
$project_name
,
$template_mail
);
return
$mail
;
}
/**
* hash password (using default encryption method)
* @param string $password
...
...
ui/nG6/pi6/class.tx_nG6_pi6.php
View file @
1881ae7b
...
...
@@ -198,39 +198,55 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
}
$log_file_path
=
tx_nG6_utils
::
get_log_path
();
error_log
(
date
(
"d/m/Y, h:i:s"
)
.
" IN tx_nG6_pi6.php, 'add_purge_demand'
\n
all_purgeable_runs = "
.
print_r
(
$all_purgeable_runs
,
TRUE
),
3
,
$log_file_path
);
#Add purge demand to get id
$purge_demand_id
=
tx_nG6_db
::
add_purge_demand
(
$GLOBALS
[
'TSFE'
]
->
fe_user
->
user
[
'uid'
],
$project_id
,
$p
[
$project_id
][
"total_purgeable_size"
],
$all_purgeable_runs
,
$all_purgeable_analysis
,
$purge_user_id_to
);
if
(
$purge_demand_id
>
0
){
#Build corresponding string array
//TODO RETURN TOTAL SIZE tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_size"]
$total_project_size
=
tx_nG6_db
::
get_project_size
(
$project_id
,
true
);
#Build corresponding string array
//TODO RETURN TOTAL SIZE tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_size"]
$total_project_size
=
tx_nG6_db
::
get_project_size
(
$project_id
,
true
);
$mail
=
tx_nG6_utils
::
get_purge_mail
(
$p
[
$project_id
][
"project_name"
],
$project_id
,
$nb_run_purgeable
,
$nb_analyse_purgeable
,
$purge_demand_id
,
tx_nG6_utils
::
get_octet_string_representation
(
$p
[
$project_id
][
"total_purgeable_size"
]),
tx_nG6_utils
::
get_octet_string_representation
(
$total_project_size
),
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"delay_purge"
],
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"extension_url_price"
],
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"min_extension_duration"
],
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"min_extension_size"
],
$email_warn
,
join
(
', '
,
$run_info
),
join
(
', '
,
$analyses_info
),
$extension_allowed
);
$mail
=
tx_nG6_utils
::
get_purge_mail
(
$p
[
$project_id
][
"project_name"
],
$project_id
,
$nb_run_purgeable
,
$nb_analyse_purgeable
,
$purge_demand_id
,
tx_nG6_utils
::
get_octet_string_representation
(
$p
[
$project_id
][
"total_purgeable_size"
]),
tx_nG6_utils
::
get_octet_string_representation
(
$total_project_size
),
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"delay_purge"
],
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"extension_url_price"
],
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"min_extension_duration"
],
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"min_extension_size"
],
$email_warn
,
join
(
', '
,
$run_info
),
join
(
', '
,
$analyses_info
),
$extension_allowed
);
$to
=
$purge_email_to
;
$subject
=
'[nG6 purge] No '
.
$purge_demand_id
.
' - Project '
.
$p
[
$project_id
][
"project_name"
];
$headers
[]
=
'From: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_from"
];
//$headers[] = 'From: gerald.salin@inra.fr';
//$headers[] = 'Errors-To: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_copy"];
$headers
[]
=
'Errors-To: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_from"
];
$headers
[]
=
'X-Mailer: PHP/'
.
phpversion
();
$headers
[]
=
'MIME-Version: 1.0'
;
$headers
[]
=
'Content-type: text/html; charset=utf-8'
;
$headers
[]
=
'Cc: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_copy"
];
mail
(
$to
,
$subject
,
$mail
,
implode
(
"
\r\n
"
,
$headers
));
//TODO check return function mail ok
$to
=
$purge_email_to
;
$subject
=
'[nG6 purge] No '
.
$purge_demand_id
.
' - Project '
.
$p
[
$project_id
][
"project_name"
];
$headers
[]
=
'From: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_from"
];
//$headers[] = 'From: gerald.salin@inra.fr';
//$headers[] = 'Errors-To: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_copy"];
$headers
[]
=
'Errors-To: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_from"
];
$headers
[]
=
'X-Mailer: PHP/'
.
phpversion
();
$headers
[]
=
'MIME-Version: 1.0'
;
$headers
[]
=
'Content-type: text/html; charset=utf-8'
;
$headers
[]
=
'Cc: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_copy"
];
mail
(
$to
,
$subject
,
$mail
,
implode
(
"
\r\n
"
,
$headers
));
//TODO check return function mail ok
}
else
{
$mail
=
tx_nG6_utils
::
get_multiple_purge_demand_mail
(
$p
[
$project_id
][
"project_name"
]);
//We send the mail to ng6-support@groupes.renater.fr
//$to = $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
$to
=
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_warning"
];
$subject
=
'[nG6 purge] Project '
.
$p
[
$project_id
][
"project_name"
]
.
' already has a purge demand'
;
$headers
[]
=
'From: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_from"
];
$headers
[]
=
'Errors-To: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_from"
];
$headers
[]
=
'X-Mailer: PHP/'
.
phpversion
();
$headers
[]
=
'MIME-Version: 1.0'
;
$headers
[]
=
'Content-type: text/html; charset=utf-8'
;
$headers
[]
=
'Cc: '
.
$GLOBALS
[
'TSFE'
]
->
tmpl
->
setup
[
"plugin."
][
"tx_nG6_pi6."
][
"email_copy"
];
mail
(
$to
,
$subject
,
$mail
,
implode
(
"
\r\n
"
,
$headers
));
}
}
return
"Mail sent"
;
}
static
function
resend_purge_demand_mail
(
$demands_id
)
{
static
function
resend_purge_demand_mail
(
$demands_id
)
{
$res_demands
=
tx_nG6_db
::
get_purge_demand_from_id
(
$demands_id
);
foreach
(
$res_demands
as
$res_demand
){
$res_project
=
tx_nG6_db
::
select_project
(
$res_demand
[
"project_id"
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment