Commit 98391d8b authored by Gerald Salin's avatar Gerald Salin
Browse files

Merge branch 'typo3v10' into 'master'

Typo3v10

See merge request !129
parents 1b546e00 fa066cfc
<?php
namespace ng6\Controller;
/***************************************************************
* 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!
***************************************************************/
/**
* Plugin 'nG6' for the 'nG6' extension.
*
* @author PF bioinformatique de Toulouse <>
*/
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/lib/class.tx_nG6_utils.php');
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/lib/class.tx_nG6_db.php');
use TYPO3\CMS\Core\Context\Context;
class tx_nG6_pi6_purge {
static function send_purge_demand_mail($project_ids, $extension_allowed = 1){
$context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Context::class);
$user_id = $context->getPropertyFromAspect('frontend.user', 'id');
$project_name="";
$configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager');
//$configurationManager->currentPageId = 1;
$extbaseFrameworkConfiguration = $configurationManager->getTypoScriptSetup();
$email_to_discard = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_to_discard"];
$run_link_url = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["run_link_url"];
$min_extension_duration = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["min_extension_duration"];
$delay_purge = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["delay_purge"];
$min_extension_size = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["min_extension_size"];
$extension_url_price = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["extension_url_price"];
$email_from = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_from"];
$email_copy = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_copy"];
$envelope_sender_address = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["envelope_sender_address"];
$email_warning= $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_warning"];
foreach(explode(",", $project_ids) as $project_id){
#retrieve project data
$p=tx_nG6_db::select_a_project_retention_data_info($project_id, FALSE, TRUE);
#retrieve discarded emails
$string_emails_to_discard = $email_to_discard ;
$array_emails_to_discard = explode(',',$string_emails_to_discard);
#build email list of managers
$users_id=array();
$users_emails = array();
foreach ( $p[$project_id]["users"] as $u ){
if (!isset ($users_id[$u["right_level_label"]]) ){
$users_id[$u["right_level_label"]]=Array();
$users_emails[$u["right_level_label"]]=Array();
}
$users_id[$u["right_level_label"]][] = $u["user_id"];
$users_emails[$u["right_level_label"]][] = $u["email"];
}
//Warn if mail is sent to several manager
$email_warn="" ;
$purge_email_to="";
if ( count( $users_emails['manager']) > 1 ) {
$email_warn.="Be aware that every user associated with this project received this email, please send only one answer per purge alert number.\n";
}
$purge_user_id_to = array();
$users_emails_to = array();
if(isset($users_emails['administrator'])){
$users_emails_to = array_merge($users_emails_to, $users_emails['administrator']);
$purge_user_id_to = array_merge($purge_user_id_to, $users_id['administrator']);
}
if(isset($users_emails['manager'])){
$users_emails_to = array_merge($users_emails_to,$users_emails['manager']);
$purge_user_id_to = array_merge($purge_user_id_to, $users_id['manager']);
}
if(isset($users_emails['member'])){
$users_emails_to = array_merge($users_emails_to, $users_emails['member']);
$purge_user_id_to = array_merge($purge_user_id_to, $users_id['member']);
}
$purge_email_to = join(', ',$users_emails_to );
$email_warn.= "Every user associated with this project received this alert.\n";
if( isset($users_emails['administrator']) && count($users_emails['administrator']) > 0 ){
$email_warn.= " - Administrator(s): ".join(', ',$users_emails['administrator']). "\n";
}
if( isset($users_emails['manager']) && count($users_emails['manager']) > 0 ){
$email_warn.= " - Manager(s): ".join(', ',$users_emails['manager']). "\n";
}
if( isset($users_emails['member']) && count($users_emails['member']) > 0 ){
$email_warn.= " - Member(s): ".join(', ',$users_emails['member']). "\n";
}
//Retrieve purgeable information for email
$run_info=Array();
$analyses_info=Array();
$all_purgeable_runs=array_merge($p[$project_id]["state"]["stored"]["run_ids"],$p[$project_id]["state"]["extended"]["run_ids"]);
$all_purgeable_analysis=array_merge($p[$project_id]["state"]["stored"]["analysis_ids"],$p[$project_id]["state"]["extended"]["analysis_ids"]);
$nb_run_purgeable = $p[$project_id]["state"]["stored"]["nb_run"]+ $p[$project_id]["state"]["extended"]["nb_run"];
$nb_analyse_purgeable = $p[$project_id]["state"]["stored"]["nb_analyze"]+ $p[$project_id]["state"]["extended"]["nb_analyze"];
//Retrieve run name
$search=array("###TYPE_OBJECT###","###RUN_ID###","###PROJECT_ID###");
foreach($all_purgeable_runs as $run_id ){
$run = tx_nG6_db::select_run($run_id);
$run_name = $run["name"];
$replace=array("run_id",$run_id,$project_id);
$run_info[] = '<a href="'.str_replace($search, $replace, $run_link_url).'">'.$run["name"].' ('.$run_id.')</a>';
}
foreach($all_purgeable_analysis as $analysis_id ){
$analysis = tx_nG6_db::select_analyse($analysis_id);
$analysis_name = $analysis["name"];
$replace=array("analyze_id",$analysis_id,$project_id);
$analyses_info[] = '<a href="'.str_replace($search, $replace, $run_link_url).'">'.$analysis_name.' ('.$analysis_id.')</a>';
}
if (!$user_id){
http_response_code(401);
return "Nobody seems to be authenticated.";
}
#Add purge demand to get id
$purge_demand_id = tx_nG6_db::add_purge_demand($user_id,$project_id,$p[$project_id]["total_purgeable_size"],$all_purgeable_runs,$all_purgeable_analysis,$purge_user_id_to);
//If the trigger check_demand_insert is triggered, add_purge_demand() returns 0 and the process has to send a mail to warn the admins instead.
if($purge_demand_id > 0){
// We remove the hidden runs and analyzes from $p so they will not appear in the purge alert mail
$p=tx_nG6_db::select_a_project_retention_data_info($project_id, FALSE, FALSE);
//We then need to compute the displayed values once more, to make the hidden elements part of the purge without displaying them in the mail
$all_purgeable_runs=array_merge($p[$project_id]["state"]["stored"]["run_ids"],$p[$project_id]["state"]["extended"]["run_ids"]);
$all_purgeable_analysis=array_merge($p[$project_id]["state"]["stored"]["analysis_ids"],$p[$project_id]["state"]["extended"]["analysis_ids"]);
$nb_run_purgeable = $p[$project_id]["state"]["stored"]["nb_run"]+ $p[$project_id]["state"]["extended"]["nb_run"];
$nb_analyse_purgeable = $p[$project_id]["state"]["stored"]["nb_analyze"]+ $p[$project_id]["state"]["extended"]["nb_analyze"];
//We need to reset those values to only display unhidden elements
$run_info=Array();
$analyses_info=Array();
foreach($all_purgeable_runs as $run_id ){
$run = tx_nG6_db::select_run($run_id);
$run_name = $run["name"];
$replace=array("run_id",$run_id,$project_id);
$run_info[] = '<a href="'.str_replace($search, $replace, $run_link_url).'">'.$run["name"].' ('.$run_id.')</a>';
}
foreach($all_purgeable_analysis as $analysis_id ){
$analysis = tx_nG6_db::select_analyse($analysis_id);
$analysis_name = $analysis["name"];
$replace=array("analyze_id",$analysis_id,$project_id);
$analyses_info[] = '<a href="'.str_replace($search, $replace, $run_link_url).'">'.$analysis_name.' ('.$analysis_id.')</a>';
}
#Build corresponding string array
//We get the project size without any hidden run or analyze
$total_project_size = tx_nG6_db::get_project_size($project_id, true, false);
$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),
$$delay_purge,
$extension_url_price,$min_extension_duration,
$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 = array();
$headers[] = 'From: '.$email_from;
$headers[] = 'Errors-To: '.$email_from;
$headers[] = 'X-Mailer: PHP/' . phpversion();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';
$headers[] = 'Cc: '.$email_copy;
mail($to, $subject, $mail, implode("\r\n", $headers), '-f '. $envelope_sender_address);
//TODO check return function mail ok
}else{
//If the demand could not be inserted because another one already exists for the given project, we send a mail to the nG6 admins
$mail = tx_nG6_utils::get_multiple_purge_demand_mail($p[$project_id]["project_name"]);
$to = $email_warning;
$subject = '[nG6 purge] Project '.$p[$project_id]["project_name"].' already has a purge demand';
$headers[] = 'From: '.$email_from;
$headers[] = 'Errors-To: '.$email_from;
$headers[] = 'X-Mailer: PHP/' . phpversion();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';
$headers[] = 'Cc: '.$email_copy;
mail($to, $subject, $mail, implode("\r\n", $headers), '-f '. $envelope_sender_address);
}
}
return "Mail sent";
}
static function resend_purge_demand_mail ($demands_id) {
$configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager');
//$configurationManager->currentPageId = 1;
$extbaseFrameworkConfiguration = $configurationManager->getTypoScriptSetup();
$run_link_url = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["run_link_url"];
$email_to_discard = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_to_discard"];
$run_link_url = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["run_link_url"];
$min_extension_duration = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["min_extension_duration"];
$delay_purge = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["delay_purge"];
$min_extension_size = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["min_extension_size"];
$extension_url_price = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["extension_url_price"];
$email_from = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_from"];
$email_copy = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_copy"];
$envelope_sender_address = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["envelope_sender_address"];
$email_warning= $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["email_warning"];
$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"]);
//We compute the project size without hidden elements
$total_project_size = tx_nG6_db::get_project_size($res_demand["project_id"], true, false) ;
$run_info=Array();
$analyses_info=Array();
$search=array("###TYPE_OBJECT###","###RUN_ID###","###PROJECT_ID###");
$project_id = $res_demand["project_id"];
$all_purgeable_runs = explode(',',$res_demand["run_ids"]);
$all_purgeable_analysis = explode(',',$res_demand["analyze_ids"]);
$nb_run_purgeable = 0;
$nb_analyse_purgeable = 0;
$displayed_purge_size = 0;
foreach($all_purgeable_runs as $run_id ){
$run = tx_nG6_db::select_run($run_id);
// We exclude hidden runs from the mail
if( $run["hidden"] != 1 && isset($run["name"]) ){
$run_name = $run["name"];
$replace=array("run_id",$run_id,$project_id);
$run_info[] = '<a href="'.str_replace($search, $replace, $run_link_url).'">'.$run["name"].' ('.$run_id.')</a>';
$nb_run_purgeable++;
$displayed_purge_size = $displayed_purge_size + $run["storage_size"];
}
}
foreach($all_purgeable_analysis as $analysis_id ){
$analysis = tx_nG6_db::select_analyse($analysis_id);
// We exclude hidden analyzes from the mail
if( $analysis["hidden"] != 1 && isset($analysis["name"]) ){
$analysis_name = $analysis["name"];
$replace=array("analyze_id",$analysis_id,$project_id);
$analyses_info[] = '<a href="'.str_replace($search, $replace, $run_link_url).'">'.$analysis_name.' ('.$analysis_id.')</a>';
$nb_analyse_purgeable++;
$displayed_purge_size = $displayed_purge_size + $analysis["storage_size"];
}
}
//We now use join(', ', $run_info) and join(', ', $analyses_info) in get_purge_mail().
$extension_allowed = 1;
$mail = tx_nG6_utils::get_purge_mail($res_project["name"],$res_demand["project_id"],
$nb_run_purgeable, $nb_analyse_purgeable, $res_demand["demand_id"],
tx_nG6_utils::get_octet_string_representation($displayed_purge_size), tx_nG6_utils::get_octet_string_representation($total_project_size),
$delay_purge,
$extension_url_price, $min_extension_duration,
$min_extension_size, "This email was send to ". join(', ',$res_demand["emails"]).". ", join(', ', $run_info), join(', ', $analyses_info), $extension_allowed);
$headers = array();
$subject = '[nG6 purge / reminder] No '.$res_demand["demand_id"].' - Project '.$res_project["name"];
$headers[] = 'From: '.$email_from;
$headers[] = 'Errors-To: '.$email_from;
$headers[] = 'X-Mailer: PHP/' . phpversion();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';
$headers[] = 'Cc: '.$email_copy;
$to= join(",",$res_demand["emails"]);
mail($to, $subject, $mail, implode("\r\n", $headers), '-f '. $envelope_sender_address);
}
}
}
?>
\ No newline at end of file
<?php
namespace ng6\Controller;
/***************************************************************
* Copyright notice
*
......@@ -207,6 +208,12 @@ class tx_nG6_utils {
$purgeable_size, $project_size, $purge_delay, $url_price, $min_extention_duration,
$min_extention_size, $emails, $runs_list, $analyse_list, $with_extension) {
$configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager');
//$configurationManager->currentPageId = 1;
$extbaseFrameworkConfiguration = $configurationManager->getTypoScriptSetup();
$reinitPasswordURL = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi6.']["reinit_password_url"];
$reinit_password_message = "<p>You can visit the following address to (re)init your password, linked to your email : ".$reinitPasswordURL.".</p>";
$template_mail='
<html>
<head>
......@@ -236,9 +243,11 @@ class tx_nG6_utils {
$template_mail .= '<p>###EMAILS###</p>';
}
$template_mail.='The nG6 purge process is undergoing an important overhaul.</br>
You can visit our FAQ at the following address : https://ng6.toulouse.inra.fr/faq .</br>
If you have any question or demand, do not hesitate to contact our support team at ng6-support@groupes.renater.fr.</br>';
$template_mail.='The nG6 purge process is undergoing an important overhaul.<br />
You can visit our FAQ at the following address : https://ng6.toulouse.inra.fr/faq .<br />
If you have any question or demand, do not hesitate to contact our support team at ng6-support@groupes.renater.fr.<br />';
$template_mail .= $reinit_password_message.'<br />';
$template_mail.='<p>Yours sincerely</p>
<p>nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)</p>
......@@ -301,7 +310,7 @@ $template_mail.='<p>Yours sincerely</p>
* @return hashed password
*/
static function hash_password($password){
$hashInstance = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory::class)->getDefaultHashInstance('FE');
$hashInstance = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory::class)->getDefaultHashInstance('FE');
$hashedPassword = $hashInstance->getHashedPassword($password);
return $hashedPassword;
}
......
This diff is collapsed.
<?php
namespace ng6\Controller;
/***************************************************************
* Copyright notice
*
......@@ -548,6 +549,7 @@ INNER JOIN fe_groups ON fe_groups.uid = fe_users.usergroup',
array($date,"extended"));
}
}
return 1;
}
static function extend_runs_analyses($all_runs, $all_analyses, $date){
tx_nG6_db::update_field('tx_nG6_run', $all_runs,
......@@ -1462,7 +1464,9 @@ static function get_project_runs($project_id, $get_hidden=TRUE, $orderby='', $li
);
// Then create the result hash table
$results = array();
//error_log("tx_ng6_db ".$GLOBALS['TYPO3_DB']."-\n", 3, "/work/tmp/mes-erreurs.log");
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
//error_log("tx_ng6_db ".$res."-\n", 3, "/work/tmp/mes-erreurs.log");
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$analyze_id = $row['analyze_id'];
if (!isset ($results['analyse_'.$analyze_id])) {
......@@ -2072,7 +2076,8 @@ static function get_project_runs($project_id, $get_hidden=TRUE, $orderby='', $li
* @param boolean $get_analyzes get analyzes size ?
*/
static function get_run_size($r_id, $get_analyzes=false) {
$full_size = 0;
//error_log("get_run_size $r_id\n", 3, "/work/tmp/mes-erreurs.log");
$full_size = 0;
if($get_analyzes){
$run_analysis = tx_nG6_db::get_run_analysis($r_id);
foreach($run_analysis as $analyse_id => $analyze_values) {
......@@ -2081,6 +2086,7 @@ static function get_project_runs($project_id, $get_hidden=TRUE, $orderby='', $li
}
// Then select the run
$my_run = tx_nG6_db::select_run($r_id);
//error_log("get_run_size ".var_dump($my_run)."\n", 3, "/work/tmp/mes-erreurs.log");
$full_size += $my_run['storage_size'];
return $full_size;
......@@ -2481,7 +2487,7 @@ static function get_project_runs($project_id, $get_hidden=TRUE, $orderby='', $li
* @param string $a_id the analysis id to hide
*/
static function unhide_analysis($a_id, $unhide_up=false) {
error_log("unhide_analysis\n", 3, "/work/tmp/mes-erreurs.log");
if ($unhide_up) {
$queryParts = array(
'SELECT' => 'tx_nG6_project_analyze.uid',
......@@ -3249,7 +3255,7 @@ static function get_project_runs($project_id, $get_hidden=TRUE, $orderby='', $li
* @param array $user_data the user array
* @return
*/
static function update_user( $user_id , $first_name, $last_name, $email, $group_name,$organism, $location, $password ){
static function update_user( $user_id , $first_name, $last_name, $email, $group_name,$organism, $location ){
$user_datas = array(
'first_name' => $first_name,
......
<?php
return [
'frontend' => [
'typo3/cms-frontend/eid' => [
'disabled' => true
],
'typo3/cms-frontend/eid-new' => [
'target' => \TYPO3\CMS\Frontend\Middleware\EidHandler::class,
'after' => [
'typo3/cms-frontend/tsfe',
],
'before' => [
'typo3/cms-frontend/prepare-tsfe-rendering',
]
]
]
];
\ No newline at end of file
This diff is collapsed.
......@@ -55,6 +55,8 @@ exec('chmod 777 '.\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('n
## Added to do some ajax
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_nG6'] = 'EXT:nG6/class.tx_nG6_eid.php';
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_nG62'] = \ng6\Controller\tx_nG6_eid::class. '::processRequest';
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['tx_nG6'] =\ng6\Controller\NG6::class . '::processRequest';
?>
......@@ -160,6 +160,11 @@
</div>
<div class="ng6-content-header-right">
<dl class="dl-horizontal">
<dt>HOW TO...</dt> <dd> <a href="https://genomique.genotoul.fr/e-SIToul-ResetPassword/mail" target="_blanck">recover my username and password</a>?</dd>
<dt></dt> <dd> <a href="https://ng6.toulouse.inra.fr/faq">get my data</a>?</dd>
<dt></dt> <dd> <a href="https://ng6.toulouse.inra.fr/faq">add a user to my project so it can access the data</a>?</dd>
</dl>
<h2><small>Keep up with </small>news</h2>
<dl class="dl-horizontal">
<dt>September 18 2018</dt> <dd>NG6 v3.2 is available on <a href="https://forgemia.inra.fr/genotoul-bioinfo/ng6/tags">https://forgemia.inra.fr/genotoul-bioinfo/ng6/tags</a>. Illumina pipelines were greatly improved (less time to make the data and analysis results available). An Oxford nanopore Technologies pipeline is now available. Can now work with slurm and sge. All runs come with a md5 sum file for raw data. New interface to manage projects and purge associated data is now included.</dd>
......
......@@ -27,6 +27,7 @@
* @author PF bioinformatique de Toulouse <>
*/
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/lib/class.tx_nG6_db.php');
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/lib/class.tx_nG6_utils.php');
require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/lib/class.tx_nG6_upgrade.php');
......@@ -48,7 +49,7 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
* @return The content that should be displayed on the website
*/
function main($content,$conf) {
//error_log("tx_nG6_pi1 \n", 3, "/work/tmp/mes-erreurs.log");
error_log("tx_nG6_pi1 \n", 3, "/work/tmp/mes-erreurs.log");
$context = \TYPO3\CMS\Core\Utility\GeneralUtility ::makeInstance(Context::class);
if (strstr($this->cObj->currentRecord,'tt_content')) {
$conf['pidList'] = $this->cObj->data['pages'];
......@@ -136,11 +137,13 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
* Return the project view
*/
function pi_project_view() {
$projects = array();
error_log("pi_project_view \n", 3, "/work/tmp/mes-erreurs.log");
$projects = array();
$context = \TYPO3\CMS\Core\Utility\GeneralUtility ::makeInstance(Context::class);
if (!$context->getPropertyFromAspect('frontend.user', 'isLoggedIn')) { $user_id = null; }
else { $user_id = $GLOBALS['TSFE']->fe_user->user['uid']; }
else { $user_id = $context->getPropertyFromAspect('frontend.user', 'id'); }
$is_current_user_superadmin = tx_nG6_db::is_user_ng6_superadmin($user_id);
error_log("pi_project_view user_id = $user_id\n", 3, "/work/tmp/mes-erreurs.log");
$single_project_display = false;
......@@ -176,13 +179,15 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$smarty->security_settings['MODIFIER_FUNCS'] = array('count');
// Add some information to the table
$project_ids = "";
$user_id = $context->getPropertyFromAspect('frontend.user', 'id');
$user_name = $context->getPropertyFromAspect('frontend.user', 'username');
foreach($projects as $project_id => $project_values) {
// project admin ?
$projects[$project_id]['is_admin'] = tx_nG6_db::is_project_administrator($GLOBALS['TSFE']->fe_user->user['uid'], $project_values['id']);
$projects[$project_id]['is_admin'] = tx_nG6_db::is_project_administrator($user_id, $project_values['id']);
// project manager ?
$projects[$project_id]['is_manager'] = tx_nG6_db::is_project_manager($GLOBALS['TSFE']->fe_user->user['uid'], $project_values['id']);
$projects[$project_id]['is_manager'] = tx_nG6_db::is_project_manager($user_id, $project_values['id']);
// project member ?
$projects[$project_id]['is_member'] = tx_nG6_db::is_project_member($GLOBALS['TSFE']->fe_user->user['uid'], $project_values['id']);
$projects[$project_id]['is_member'] = tx_nG6_db::is_project_member($user_id, $project_values['id']);
//If the user is a superadmin, we set its rights to admin on each project
if( $is_current_user_superadmin ){
......@@ -193,9 +198,9 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$projects[$project_id]['href'] = $this->pi_list_linkSingle($project_values['name'],$project_values['id'],1, array('project_id'=>$project_values['id']));
}
$smarty->assign('projects', $projects);
$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
$smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']);
$smarty->assign('user_login', $GLOBALS['TSFE']->fe_user->user['username']);
$smarty->assign('login_user', $user_name);
$smarty->assign('user_id', $user_id);
$smarty->assign('user_login', $user_name);
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('from_email', $this->conf["FromEmail"]);
$smarty->assign('envelope_sender_address', $this->conf["envelope_sender_address"]);
......@@ -223,7 +228,7 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
// Add some information to the table
$project_runs = tx_nG6_db::get_project_runs($projects[key($projects)]['id']);
foreach($project_runs as $run_id => $run_values) {
$project_runs[$run_id]['is_admin'] = tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'run', $run_values['id']);
$project_runs[$run_id]['is_admin'] = tx_nG6_db::is_administrator($user_id, 'run', $run_values['id']);
if( $is_current_user_superadmin ){
$project_runs[$run_id]['is_admin'] = 1;
......@@ -236,7 +241,7 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
// Add some information to the table
foreach($project_analysis as $analysis_id => $analysis_values) {
$project_analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'analyze', $analysis_values['id']);
$project_analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id']);
if( $is_current_user_superadmin ){
$project_analysis[$analysis_id]['is_admin'] = 1;
......@@ -275,7 +280,10 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$context = \TYPO3\CMS\Core\Utility\GeneralUtility ::makeInstance(Context::class);
$runs = array();
if (!$context->getPropertyFromAspect('frontend.user', 'isLoggedIn')) { $user_id = null; }
else { $user_id = $GLOBALS['TSFE']->fe_user->user['uid']; }
else {
$user_id = $context->getPropertyFromAspect('frontend.user', 'id');
$user_name = $context->getPropertyFromAspect('frontend.user', 'username');
}
$is_current_user_superadmin = tx_nG6_db::is_user_ng6_superadmin($user_id);
$single_run_display = false;
......@@ -314,9 +322,9 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
}
}
$smarty->assign('runs', $runs);
$smarty->assign('login_user', $GLOBALS['TSFE']->loginUser);
$smarty->assign('user_login', $GLOBALS['TSFE']->fe_user->user['username']);
$smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']);
$smarty->assign('login_user', $user_name);
$smarty->assign('user_login', $user_name);
$smarty->assign('user_id', $user_id);
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('server_name', $this->conf["server_name"]);
$smarty->assign('server_url', $this->conf['server_url']);
......@@ -338,7 +346,7 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$run_analysis = tx_nG6_db::get_run_analysis($runs[key($runs)]['id']);
// Add some information to the table
foreach($run_analysis as $analysis_id => $analysis_values) {
$run_analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($GLOBALS['TSFE']->fe_user->user['uid'], 'analyze', $analysis_values['id']);
$run_analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id']);
if($is_current_user_superadmin){
$run_analysis[$analysis_id]['is_admin'] = 1;
}
......@@ -364,7 +372,10 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
function pi_analyze_view() {
$context = \TYPO3\CMS\Core\Utility\GeneralUtility ::makeInstance(Context::class);
if (!$context->getPropertyFromAspect('frontend.user', 'isLoggedIn')) { $user_id = null; }
else { $user_id = $GLOBALS['TSFE']->fe_user->user['uid']; }
else {
$user_id = $context->getPropertyFromAspect('frontend.user', 'id');
$user_name = $context->getPropertyFromAspect('frontend.user', 'username');
}
$is_current_user_superadmin = tx_nG6_db::is_user_ng6_superadmin($user_id);
$smarty = new Smarty();
......@@ -379,7 +390,7 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$analyse = tx_nG6_db::select_analyse($this->piVars['analyze_id']);
// is project admin
$is_project_admin = tx_nG6_db::is_project_administrator($GLOBALS['TSFE']->fe_user->user['uid'], $analyse['project_id']);
$is_project_admin = tx_nG6_db::is_project_administrator($user_id, $analyse['project_id']);
if( $is_current_user_superadmin ){ $is_project_admin = 1; }
......@@ -408,8 +419,8 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('analyze_id', $this->piVars['analyze_id']);
$smarty->assign('server_url', $this->conf['server_url']);
$smarty->assign('user_login', $GLOBALS['TSFE']->fe_user->user['username']);
$smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']);
$smarty->assign('user_login', $user_name);
$smarty->assign('user_id', $user_id);
$retention_policy = tx_nG6_db::select_analysis_retention_status($this->piVars['analyze_id']);
$smarty->assign('analysis_data_state', $retention_policy['analysis_data_state']);
......