diff --git a/ui/nG6/Classes/Controller/class.tx_nG6_pi6_purge.php b/ui/nG6/Classes/Controller/class.tx_nG6_pi6_purge.php new file mode 100644 index 0000000000000000000000000000000000000000..d5dbcb342743deea629185e37bc364588567497e --- /dev/null +++ b/ui/nG6/Classes/Controller/class.tx_nG6_pi6_purge.php @@ -0,0 +1,282 @@ +<?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 diff --git a/ui/nG6/lib/class.tx_nG6_utils.php b/ui/nG6/Classes/Controller/class.tx_nG6_utils.php similarity index 95% rename from ui/nG6/lib/class.tx_nG6_utils.php rename to ui/nG6/Classes/Controller/class.tx_nG6_utils.php index 98badf83774c6f5ce6503904e114264c229fe2e6..29e227998c4357d8f51057756c17d5597cd0112d 100644 --- a/ui/nG6/lib/class.tx_nG6_utils.php +++ b/ui/nG6/Classes/Controller/class.tx_nG6_utils.php @@ -1,4 +1,5 @@ <?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; } diff --git a/ui/nG6/Classes/Controller/ng6.php b/ui/nG6/Classes/Controller/ng6.php new file mode 100644 index 0000000000000000000000000000000000000000..862cf1784352654dd6f2c76bb79c5a92111697ff --- /dev/null +++ b/ui/nG6/Classes/Controller/ng6.php @@ -0,0 +1,962 @@ +<?php +declare(strict_types=1); +namespace ng6\Controller; + +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\ResponseFactoryInterface; +use TYPO3\CMS\Core\Http\JsonResponse; +use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Http\HtmlResponse; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; + +require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'Classes/Controller/tx_nG6_db.php'); +require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'Classes/Controller/class.tx_nG6_utils.php'); +require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'lib/class.tx_nG6_process.php'); +require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'Classes/Controller/class.tx_nG6_pi6_purge.php'); +require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'res/smarty/libs/Smarty.class.php'); + +/** + * Class NG6 + */ +class NG6 +{ + + /** + * @param ServerRequestInterface $request + * @param ResponseInterface $response + * @return ResponseInterface + */ + public function processRequest(ServerRequestInterface $request) + { + $context = GeneralUtility::makeInstance(Context::class); + $user_id = $context->getPropertyFromAspect('frontend.user', 'id'); + + $type = (string)$request->getQueryParams()['type'] ; + //error_log("processRequest, type= $type\n", 3, "/work/tmp/mes-erreurs.log"); + if ($type == 'project') { + error_log("processRequest, type=project $project_id\n", 3, "/work/tmp/mes-erreurs.log"); + $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('object_id')); + // Select all runs linked to the project + $project_runs = tx_nG6_db::get_user_project_runs($user_id, $project_id, 'tx_nG6_run.date DESC'); + // for each run + $html_tree = ''; + foreach($project_runs as $run_id => $run_values) { + //error_log("processRequest, type=project ".var_dump($run_values)."\n", 3, "/work/tmp/mes-erreurs.log"); + $date = $run_values['date']; + settype($date,'int'); + $html_tree .= '<li class="jstree-closed" name=\''.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###'), array($run_values['name'], strftime('%d-%m-%y',$date)), trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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',$date), $run_values['nb_sequences'], $run_values['species']), trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('run_description'))).'</a></li>'; + } + // Then all project analysis + $project_analysis = tx_nG6_db::get_user_project_analysis($user_id, $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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'</a></li>'; + } + error_log("processRequest, type=project $html_tree\n", 3, "/work/tmp/mes-erreurs.log"); + // Return the html_tree + return GeneralUtility::makeInstance(HtmlResponse::class, $html_tree); + + // If the type of data requested is run + } + elseif ($type == 'run'){ + $run_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('object_id')); + // Select all analysis linked to the run and the run information + $run_analysis = tx_nG6_db::get_user_run_analysis($user_id, $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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP("raw_data_description")).'\' id=\'data_'.$run_id.'\'> <a href=\'#\'>'.trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'</a></li>'; + } + // Return the html_tree + return GeneralUtility::makeInstance(HtmlResponse::class, $html_tree); + + // If asked to check a job status + } + elseif($type == 'check_status') { + $pid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pid')); + $archive_path = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('archive_path')); + $process = new Process(); + $process->setPid($pid); + // If the job is done + if ($process->status()) { + return GeneralUtility::makeInstance(HtmlResponse::class,"pid=0&archive_path=".$archive_path); + // If the job is still runing + } else { + return GeneralUtility::makeInstance(HtmlResponse::class,"pid=".$process->getPid()."&archive_path=".$archive_path); + } + + // If asked to hide a {project/run} + } elseif ($type == 'hide') { + + $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); + // {project/run}_id to array (1;2;3;...) -> [1;2;3;...] + $tab_ids = explode(";",$ids); + $hide_level = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hide_level')); + + if ($hide_level == 'project') { + foreach($tab_ids as $id => $value) { + tx_nG6_db::hide_project($value); + } + } elseif ($hide_level == 'run') { + foreach($tab_ids as $id => $value) { + tx_nG6_db::hide_run($value, $user_id); + } + } elseif ($hide_level == 'analysis') { + foreach($tab_ids as $id => $value) { + tx_nG6_db::hide_analysis($value, $user_id); + } + } + return GeneralUtility::makeInstance(HtmlResponse::class,1); + + // If asked to unhide a {project/run} + } elseif ($type == 'unhide') { + + $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); + error_log("processRequest ids $ids\n", 3, "/work/tmp/mes-erreurs.log"); + // {project/run}_id to array (1;2;3;...) -> [1;2;3;...] + $tab_ids = explode(";",$ids); + $unhide_level = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('unhide_level')); + error_log("processRequest unhide_level $unhide_level\n", 3, "/work/tmp/mes-erreurs.log"); + if ($unhide_level == 'project') { + foreach($tab_ids as $id => $value) { + tx_nG6_db::unhide_project($value); + } + } elseif ($unhide_level == 'run') { + foreach($tab_ids as $id => $value) { + tx_nG6_db::unhide_run($value, true); + } + } elseif ($unhide_level == 'analysis') { + foreach($tab_ids as $id => $value) { + tx_nG6_db::unhide_analysis($value, true); + } + } + return GeneralUtility::makeInstance(HtmlResponse::class,1); + // If asked to delete a {project/run/analyze} + } + elseif ($type == 'delete') { + + $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); + // {project/run}_id to array (1;2;3;...) -> [1;2;3;...] + $tab_ids = explode(";",$ids); + $delete_level = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('del_level')); + $data_folder = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_folder')); + $user_login = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_login')); + $user_pwd = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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($value, $user_login, $user_pwd, $data_folder); + if ($res != 0) { break; } + } + } elseif ($delete_level == 'run') { + foreach($tab_ids as $id => $value) { + $res = tx_nG6_db::delete_run($value, $user_login, $user_pwd, $data_folder); + if ($res != 0) { break; } + } + } elseif ($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; } + } + } + } + return GeneralUtility::makeInstance(HtmlResponse::class,$res); + + // If asked to publish a project + } elseif ($type == 'publish') { + + $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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); + } + return GeneralUtility::makeInstance(HtmlResponse::class,1); + // If asked to unpublish a project + } elseif ($type == 'unpublish') { + + $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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 + } elseif ($type == 'get_size') { + $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); + $view = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view')); + $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, true); + } elseif ($view == "project") { + $full_size += tx_nG6_db::get_project_size($value, true); + } + } + return GeneralUtility::makeInstance(HtmlResponse::class,tx_nG6_utils::get_octet_string_representation($full_size)); + + // data size + }elseif ($type == 'get_data_size'){ + $run_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('run_ids')); + $data_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_ids')); + $analysis_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analysis_ids')); + $full_size = 0; + + if ($run_ids){ + $data = explode(',', $run_ids); + foreach($data as $id => $value) { + $full_size += tx_nG6_db::get_run_size($value, true); + } + } + if ($data_ids){ + $data = explode(',', $data_ids); + foreach($data as $id => $value) { + $full_size += tx_nG6_db::get_run_size($value, false); + } + } + if ($analysis_ids){ + $data = explode(',', $analysis_ids); + foreach($data as $id => $value) { + $full_size += tx_nG6_db::get_analysis_size($value); + } + } + return GeneralUtility::makeInstance(HtmlResponse::class,$full_size . ":::" . tx_nG6_utils::get_octet_string_representation($full_size)); + + // If update a field + } elseif ($type == 'update_db_field') { + + //Retrieve infomation + $table = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('table')); + $id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pk')); + $field = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('field')); + $value = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('value')); + + //If change concernes a date + if( $field == "date" || $field == "crdate" ) { + //Change date format + $date = explode('-', $value); + $timestamp = mktime (0, 0, 1, $date[1], $date[2], $date[0]); + //Update the entity + tx_nG6_db::update_field($table, $id, $field, $timestamp); + } + else { + //Update the entity + tx_nG6_db::update_field($table, $id, $field, $value); + } + return GeneralUtility::makeInstance(HtmlResponse::class,$value); + + } + // add comment + elseif ($type == 'add_comment') { + $view = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view')); + $view_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view_id')); // project_id or run_id or analyze_id + $new_comment = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('new_comment')); + $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cruser_id')); + $res = 0 ; + + if ($new_comment){ + if($view == 'project'){ + $res = tx_nG6_db::add_project_comment($view_id, $cruser_id, $new_comment) ; + } + elseif ($view == 'run') { + $res = tx_nG6_db::add_run_comment($view_id, $cruser_id, $new_comment) ; + } + elseif ($view == 'analyze') { + $res = tx_nG6_db::add_analyze_comment($view_id, $cruser_id, $new_comment) ; + } + } + + return GeneralUtility::makeInstance(HtmlResponse::class,$res); + } + //delete comment + elseif ($type == 'delete_comment') { + $view = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view')); + $view_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view_id')); // project_id or run_id or analyze_id + $comment_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('comment_id')); + $res = 0 ; + if($view == 'project'){ + $res = tx_nG6_db::delete_project_comment($view_id, $comment_id); + } + elseif ($view == 'run') { + $res = tx_nG6_db::delete_run_comment($view_id, $comment_id); + } + elseif ($view == 'analyze') { + $res = tx_nG6_db::delete_analyze_comment($view_id, $comment_id); + } + return GeneralUtility::makeInstance(HtmlResponse::class,$res); + } + //update comment + elseif ($type == 'update_comment') { + $comment_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('comment_id')); + $new_comment = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('new_comment')); + $res = 0; + $new_comment = urldecode($new_comment); + $res = tx_nG6_db::update_comment($comment_id, $new_comment); + return GeneralUtility::makeInstance(HtmlResponse::class,$res); + + // If asked the krona page + } elseif ($type == 'get_krona') { + + $data_folder = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_folder')); + $file_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('file_name')); + $sequence_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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(\TYPO3\CMS\Core\Utility\GeneralUtility::_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="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath('nG6')).'res/js/krona-1.1.js"></script>'; + $val .= $xml_parts[1]; + $val .= '</div>'; + $val .= '</body>'; + $val .= '</html>'; + return GeneralUtility::makeInstance(HtmlResponse::class,$val); + + } elseif ($type == 'delete_users') { + + $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); + // users_id to array (1;2;3;...) -> [1;2;3;...] + $tab_ids = explode(";",$ids); + $project_id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id'); + + // try to delete users in project ... + if($project_id != "") { + $none_access = ""; + foreach($tab_ids as $id => $del_user_id) { + tx_nG6_db::delete_access_to_project($del_user_id, $project_id); + + // find if user can't access to any project + $users_access = tx_nG6_db::count_number_of_project_access($del_user_id); + if($users_access == '0'){ + $none_access .= $del_user_id.";"; + } + } + + if($none_access == ""){ // everybody has at least one access to a project + $others_access = '0'; + }else{ // list separate by coma of users who can't access to any project + $others_access = substr($none_access, 0, -1); + } + + return GeneralUtility::makeInstance(HtmlResponse::class,$others_access); + + // delete users of DB... + }else{ + + foreach($tab_ids as $k_id => $v_id){ + // delete group + $gid = tx_nG6_db::get_user_usergroup($v_id); + // delete user + tx_nG6_db::delete_user($v_id); + if(tx_nG6_db::count_users_in_group($gid) == 0){ + tx_nG6_db::delete_group($gid); + } + } + + } + return GeneralUtility::makeInstance(HtmlResponse::class,1); + // to change users' right on project + } elseif ($type == 'change_right') { + + $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); + $c_user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('c_user_id')); + $right_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('right_id')); + + tx_nG6_db::change_access_to_project($c_user_id, $project_id, $right_id); + + // jquery autocomplete + } elseif ($type == 'autocomplete') { + + $col = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('gender')); + $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); + $name_start = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('name_start')); + + // user search + if($col != 'title' && $col != 'location' && $col != 'organism'){ + $res = tx_nG6_db::get_all_names_starting_with($name_start, $col); + foreach($res as $res_id => $res_val){ + // find right on project + $res[$res_id]['right_id'] = tx_nG6_db::get_user_right_on_project($res_val['uid'], $project_id); + + // find creator username + $cruser_infos = tx_nG6_db::get_user_informations($res[$res_id]['cruser_id']); + $res[$res_id]['cruser_username'] = $cruser_infos['username']; + } + + // group search + }else{ + if ($col == "location" || $col == "organism") { $col = "tx_nG6_".$col; } + $res = tx_nG6_db::get_all_starts_with_in_group($name_start, $col); + } + return GeneralUtility::makeInstance(JsonResponse::class,$res); + + // add a new member on project + } elseif ($type == 'add_user') { + + $user_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('username')); + $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); + $right_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('right')); + $group_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('title')); + $location = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('location')); + $organism = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('organism')); + $email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('email')); + $first_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('first_name')); + $last_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('last_name')); + $password = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('password')); + $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('creator')); + $from_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('from_email')); + $envelope_sender_address = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('envelope_sender_address')); + $pid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pid')); + $project_url = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_url')); + $send_an_email = filter_var(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('send_an_email')), FILTER_VALIDATE_BOOLEAN); + + + // if group not exists, create group + $group_id = tx_nG6_db::get_group_id($group_name); + if( !isset($group_id) ){ + + $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('creator')); + tx_nG6_db::create_new_group($cruser_id, $group_name, $organism, $location); + $group_id = tx_nG6_db::get_group_id($group_name); + + } + + $user = tx_nG6_db::select_user_by_username($user_name); + + // if user does not exists in DB + if(!isset($user)){ + + $create_user_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('create_user_email')); + $create_user_title = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('create_user_title')); + + $res_code = tx_nG6_db::add_user($user_name, $first_name, $last_name, $email, tx_nG6_utils::hash_password($password), $cruser_id, $group_id, $pid); + + if ($res_code == 0) { + // find the new user id + $user = tx_nG6_db::select_user_by_username($user_name); + + // authorize new access + tx_nG6_db::add_access_to_project($user["uid"], $project_id, $right_id); + + if ($send_an_email) { + $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 = "\nYou can visit the following address to (re)init your password, linked to $email : ".$reinitPasswordURL."."; + // send an email to the new user + $message = str_replace("###USER_FIRST_NAME###", $first_name, $create_user_email); + $message = str_replace("###USER_LAST_NAME###", $last_name, $message); + $message = str_replace("###USER_LOGIN###", $user_name, $message); + $message = str_replace("###PROJECT_LINK###", $project_url, $message); + $message = str_replace("###REINIT_PASSWORD###", $reinit_password_message, $message); + $msg_table = explode('\n', $message); + $message = implode("\n", $msg_table); + + mail($email, $create_user_title, $message, "From: <".$from_email.">",'-f '.$envelope_sender_address); + } + return GeneralUtility::makeInstance(HtmlResponse::class,2); // ok + } elseif ($res_code == 1) { + return GeneralUtility::makeInstance(HtmlResponse::class,4); // username exists + } elseif ($res_code == 2) { + return GeneralUtility::makeInstance(HtmlResponse::class,5); // email exists + } + + // user exists in DB + } elseif ($user["username"] != $user_name || $user["email"] != $email || $user["first_name"] != $first_name || $user["last_name"] != $last_name) { + // there is difference between information provided and the user account + return GeneralUtility::makeInstance(HtmlResponse::class,3); + } else { + // can user access to the project ? + if(tx_nG6_db::get_user_right_on_project($user["uid"], $project_id) == -1){ + + // authorize new access + tx_nG6_db::add_access_to_project($user["uid"], $project_id, $right_id); + + // send an email to the user + if ($email != "" && $send_an_email) { + $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 = "\nYou can visit the following address to (re)init your password, linked to $email : ".$reinitPasswordURL."."; + $add_user_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('add_user_email')); + $add_user_title = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('add_user_title')); + $project = tx_nG6_db::select_project($project_id); + $message = str_replace("###USER_FIRST_NAME###", $first_name, $add_user_email); + $message = str_replace("###USER_LAST_NAME###", $last_name, $message); + $message = str_replace("###PROJECT_NAME###", $project["name"], $message); + $message = str_replace("###PROJECT_DESCRIPTION###", $project["description"], $message); + $message = str_replace("###PROJECT_LINK###", $project_url, $message); + $message = str_replace("###REINIT_PASSWORD###", $reinit_password_message, $message); + $msg_table = explode('\n', $message); + $message = implode("\n", $msg_table); + mail($email, $add_user_title, $message, "From: <".$from_email.">",'-f '.$envelope_sender_address); + } + return GeneralUtility::makeInstance(HtmlResponse::class,0); + + } else { + return GeneralUtility::makeInstance(HtmlResponse::class,1); // already access to the project + } + } + + } + elseif ($type == 'check_ssh_user'){ + $user_login = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_login')); + $user_pwd = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_pwd')); + $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); + + $path_to_check = tx_nG6_utils::get_project_data_save_dir($project_id); + + $res = 3; + // check login and password + if (isset($user_login) && isset($user_pwd) && $user_login != 'undefined' && $user_pwd != 'undefined') { + $ssh_command = 'touch '.$path_to_check.'/run/test ; rm -f '.$path_to_check.'/run/test' ; + $connection = ssh2_connect('127.0.0.1', 22); + + if (!$connection) { + //1st test, basic SSH connection + $res = 3; + } elseif( !ssh2_auth_password($connection, $user_login,$user_pwd ) ){ + //2nd test, SSH connection with user + pwd + $res = 2; + }else{ + //3rd test, excuting the SSH command + $stream = ssh2_exec($connection, $ssh_command ); + $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR); + // Enable blocking for both streams + stream_set_blocking($errorStream, true); + stream_set_blocking($stream, true); + + if(stream_get_contents($errorStream)) { + // Close the streams + fclose($errorStream); + fclose($stream); + $res = 4; + }else{ + fclose($errorStream); + fclose($stream); + $res = 0; + } + } + + } else { + //The user and/or password is missing + $res = 3; + } + return GeneralUtility::makeInstance(HtmlResponse::class,$res); + } + elseif ( $type == 'add_to_ng6_admin'){ + $userid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userid')); + tx_nG6_db::add_to_ng6_admin($userid); + return GeneralUtility::makeInstance(HtmlResponse::class,1); + } + elseif ( $type == 'delete_from_ng6_admin'){ + $userids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userids')); + $userids = explode(',', $userids); + tx_nG6_db::remove_from_ng6_admin($userids); + return GeneralUtility::makeInstance(HtmlResponse::class,1); + } + elseif ( $type == 'add_to_ng6_superadmin'){ + $userid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userid')); + tx_nG6_db::add_to_ng6_superadmin($userid); + return GeneralUtility::makeInstance(HtmlResponse::class,1); + } + elseif ( $type == 'delete_from_ng6_superadmin'){ + $userids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userids')); + $userids = explode(',', $userids); + tx_nG6_db::remove_from_ng6_superadmin($userids); + return GeneralUtility::makeInstance(HtmlResponse::class,1); + } + elseif($type == 'update_user'){ + $email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('email')); + $first_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('first_name')); + $last_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('last_name')); + $group_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('title')); + $location = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('location')); + $organism = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('organism')); + $user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); + $password = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('password'); + if($password){ + $password = trim($password); + } + + $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('creator')); + $send_an_email = filter_var(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('send_an_email')), FILTER_VALIDATE_BOOLEAN); + $from_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('from_email')); + $envelope_sender_address = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('envelope_sender_address')); + + $updated = tx_nG6_db::update_user($user_id, $first_name, $last_name, $email, $group_name, $organism, $location) ; + + $nb_updated = count($updated); + + if ( $nb_updated > 0 && $send_an_email){ + $user_infos = tx_nG6_db::get_user_informations($user_id); + $email = $user_infos['email']; + $first_name = $user_infos['first_name']; + $last_name = $user_infos['last_name']; + $username = $user_infos['username']; + + $mail_title = "[NG6]Your user informations have been updated."; + $mail_content = "Dear " . $first_name . " " . $last_name . " (user name : ".$username."),\n\nSome of your personnal informations have been updated : \n\n"; + if ($email != ''){ + foreach($updated as $key => $value){ + + if($key == 'password'){ + $mail_content .= 'password' . "\t: " . $password . "\n" ; + } + elseif ($key == 'usergroup'){ + $mail_content .= 'title' . "\t: " . $group_name . "\n" ; + $mail_content .= 'location' . "\t: " . $location . "\n" ; + $mail_content .= 'organism' . "\t: " . $organism . "\n" ; + } + else { + $mail_content .= ucwords(str_replace("_", " ", $key)) . "\t: " . $value . "\n" ; + } + } + + + $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"]; + $mail_content .= "\nYou can visit the following address to update your password : ".$reinitPasswordURL."."; + mail($email, $mail_title, $mail_content, "From: <".$from_email.">",'-f '.$envelope_sender_address); + } + } + + return GeneralUtility::makeInstance(HtmlResponse::class,$nb_updated); + } + elseif ($type == 'get_user_group'){ + $id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::get_group_informations(tx_nG6_db::get_user_usergroup($id))); + } + elseif($type == 'runs_table') { + $smarty = new Smarty(); + $smarty->setTemplateDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/pi1'); + $smarty->setCompileDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/templates_c'); + $smarty->setCacheDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/cache'); + $smarty->setConfigDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/configs'); + $smarty->security = true; + $smarty->security_settings['MODIFIER_FUNCS'] = array('count'); + $project_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id'))); + $user_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id'))); + $login_user = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('login_user'))); + $page_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('page_id'))); + $project_runs = tx_nG6_db::get_project_runs($project_id); + $is_project_admin = tx_nG6_db::is_administrator($user_id, 'project', $project_id); + $is_at_least_admin_of_1_run = false; + error_log("processRequest, type=runs_table - $user_id\n", 3, "/work/tmp/mes-erreurs.log"); + foreach($project_runs as $run_id => $run_values) { + $is_admin = tx_nG6_db::is_administrator($user_id, 'run', $run_values['id']); + $project_runs[$run_id]['is_admin'] = $is_admin; + if ($is_admin) { $is_at_least_admin_of_1_run = true; } + $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[run_id]='.$run_values['id'].'&tx_nG6_pi1[project_id]='.$run_values['project_id'].'">'.$run_values['name'].'</a>'; + $project_runs[$run_id]['href'] = $href; + } + $smarty->assign('runs', $project_runs); + $smarty->assign('is_project_admin', $is_project_admin); + $smarty->assign('is_at_least_admin_of_1_run', $is_at_least_admin_of_1_run); + $smarty->assign('login_user', $login_user); + return GeneralUtility::makeInstance(HtmlResponse::class,$smarty->fetch('run_table.tpl')); + + } + elseif($type == 'projects_table') { + $smarty = new Smarty(); + $smarty->setTemplateDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/pi1'); + $smarty->setCompileDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/templates_c'); + $smarty->setCacheDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/cache'); + $smarty->setConfigDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/configs'); + $smarty->security = true; + $smarty->security_settings['MODIFIER_FUNCS'] = array('count'); + $user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); + $login_user = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('login_user'))); + $page_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('page_id'))); + $projects = tx_nG6_db::select_all_user_projects($user_id, 'tx_nG6_project.uid DESC'); + //$projects = tx_nG6_db::select_all_user_projects($user_id, 'tx_nG6_project.name'); + $is_at_least_admin_of_1_project = false; + error_log("processRequest, type=projects_table - $user_id\n", 3, "/work/tmp/mes-erreurs.log"); + foreach($projects as $project_id => $project_values) { + $is_admin = tx_nG6_db::is_project_administrator($user_id, $project_values['id']); + if ($is_admin) { $is_at_least_admin_of_1_project = true; } + $projects[$project_id]['is_admin'] = $is_admin; + $projects[$project_id]['is_manager'] = tx_nG6_db::is_project_manager($user_id, $project_values['id']); + $projects[$project_id]['is_member'] = tx_nG6_db::is_project_member($user_id, $project_values['id']); + $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_values['id'].'">'.$project_values['name'].'</a>'; + $projects[$project_id]['href'] = $href; + } + $smarty->assign('projects', $projects); + $smarty->assign('is_at_least_admin_of_1_project', $is_at_least_admin_of_1_project); + $smarty->assign('login_user', $login_user); + $smarty->assign('is_ng6_admin', tx_nG6_db::is_ng6_administrator($user_id) ? true : false); + return GeneralUtility::makeInstance(HtmlResponse::class,$smarty->fetch('project_table.tpl')); + + } elseif($type == 'analyses_table') { + $smarty = new Smarty(); + $smarty->setTemplateDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/pi1'); + $smarty->setCompileDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/templates_c'); + $smarty->setCacheDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/cache'); + $smarty->setConfigDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/configs'); + $smarty->security = true; + $smarty->security_settings['MODIFIER_FUNCS'] = array('count'); + $user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); + $login_user = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('login_user'))); + $page_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('page_id'))); + $project_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id'))); + $run_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('run_id'))); + if ($run_id != "") { + $analysis = tx_nG6_db::get_run_analysis($run_id); + } else { + $analysis = tx_nG6_db::get_project_analysis($project_id); + } + // Add some information to the table + foreach($analysis as $analysis_id => $analysis_values) { + if (tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id'])) { $is_admin = true; } + $analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id']); + if ($run_id != "") { + $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_id.'&tx_nG6_pi1[run_id]='.$run_id.'&tx_nG6_pi1[analyze_id]='.$analysis_values['id'].'">'.$analysis_values['name'].'</a>'; + } else { + $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_id.'&tx_nG6_pi1[analyze_id]='.$analysis_values['id'].'">'.$analysis_values['name'].'</a>'; + } + $analysis[$analysis_id]['href'] = $href; + } + $smarty->assign('display_analysis_result', $is_admin); + $smarty->assign('is_admin', $is_admin); + $smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($analysis)); + $smarty->assign('login_user', $login_user); + return GeneralUtility::makeInstance(HtmlResponse::class,$smarty->fetch('analysis_table.tpl')); + } elseif($type == 'project_data_repartition') { + $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); + $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::select_projects_repartition($role, $by)); + } elseif($type == 'project_distribution') { + $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); + $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); + $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::select_projects_distribution($values, $by, $role)); + } elseif($type == 'project_evolution') { + $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); + $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); + $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); + $cumulate = false; + if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cumulate')) == '1'){ + $cumulate = true; + } + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::select_projects_evolution($values, $by, $role, $cumulate)); + + } elseif($type == 'data_distribution'){ + $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); + $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); + $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); + $get_analyzes = false; + if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('get_analyzes')) == '1'){ + $get_analyzes = true; + } + $octet = true; + if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('bases')) == '1'){ + $octet = false; + } + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::select_storage_distribution($values, $by, $role, $get_analyzes, $octet)); + + } elseif($type == 'data_evolution'){ + $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); + $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); + $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); + $get_analyzes = false; + if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('get_analyzes')) == '1'){ + $get_analyzes = true; + } + $octet = true; + if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('bases')) == '1'){ + $octet = false; + } + $cumulate = false; + if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cumulate')) == '1'){ + $cumulate = true; + } + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $cumulate)); + + } elseif ($type == 'purge_managment_mail') { + $all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project')); + $with_extension = 1; + tx_nG6_pi6_purge::send_purge_demand_mail($all_projects,$with_extension); + return GeneralUtility::makeInstance(HtmlResponse::class,1); + + } elseif ($type == 'purge_managment_mail_without_extension') { + $all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project')); + $with_extension = 0; + tx_nG6_pi6_purge::send_purge_demand_mail($all_projects,$with_extension); + return GeneralUtility::makeInstance(HtmlResponse::class,1); + + } elseif ($type == 'purge_managment_resend_mail') { + $purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand')); + tx_nG6_pi6_purge::resend_purge_demand_mail($purge_ids); + return GeneralUtility::makeInstance(HtmlResponse::class,1); + } elseif ($type == 'refresh_purge_demand') { + $purge_delay = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_delay')); + $purge_demand_filter_space = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand_filter_space')); + $purge_demand_filter_delay_exceeded = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand_filter_delay_exceeded')); + + + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::get_purge_demand_list($purge_delay,$purge_demand_filter_space,$purge_demand_filter_delay_exceeded)); + } elseif ($type == 'refresh_purge_list') { + $max_retention_date = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('max_retention_date')); + $filter_space = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('filter_space')); + + $without_laboratories_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('without_lab')); + $with_laboratories_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('with_lab')); + $create_users = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('create_users')); + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::filter_list_retention_data_info($filter_space,$max_retention_date,$create_users, $without_laboratories_id,$with_laboratories_id)); + } elseif ($type == 'delete_purge_data') { + //Delete data link to the list of purge demand + $purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand')); + $data_folder = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_folder')); + $user_login = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_login')); + $user_pwd = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_pwd')); + + $res = tx_nG6_db::delete_purge_demand($purge_ids,$user_login, $user_pwd, $data_folder); + return GeneralUtility::makeInstance(HtmlResponse::class,$res); + } elseif ($type == 'extend_retention_date_from_demand') { + //Extend the retention date for the + $purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand')); + $value = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('date_value')); + $type_extend = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type_extend')); //all project or only run/analyse obsolete + //Change date format + $date = explode('/', $value); + $timestamp = mktime (0, 0, 1, (int)$date[1], (int)$date[0], (int)$date[2]); + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::extend_retention_date_from_demand(explode(',',$purge_ids),$timestamp,$type_extend)); + } elseif ($type == 'extend_retention_date_from_project') { + //Extend the retention date for the + $projects_id_str = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('projects_id')); + $value = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('date_value')); + //Change date format + $date = explode('/', $value); + error_log("processRequest extend_retention_date_from_project $date[0] $date[1] $date[2]\n", 3, "/work/tmp/mes-erreurs.log"); + $timestamp = mktime (0, 0, 1, (int)$date[1], (int)$date[0], (int)$date[2]); + //TODO project + return GeneralUtility::makeInstance(HtmlResponse::class,tx_nG6_db::extend_retention_date_from_project($projects_id_str,$timestamp, TRUE)); + } elseif ($type == 'get_all_project') { + return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::select_all_projects()); + } + + + return GeneralUtility::makeInstance(HtmlResponse::class,1); + } + +} \ No newline at end of file diff --git a/ui/nG6/lib/class.tx_nG6_db.php b/ui/nG6/Classes/Controller/tx_nG6_db.php similarity index 99% rename from ui/nG6/lib/class.tx_nG6_db.php rename to ui/nG6/Classes/Controller/tx_nG6_db.php index 4e8ad24410e9e643422a075ce7ca56cc10a9dbf5..517305d53ad1d4bc414f30c5866cdb84e1bdaad3 100644 --- a/ui/nG6/lib/class.tx_nG6_db.php +++ b/ui/nG6/Classes/Controller/tx_nG6_db.php @@ -1,4 +1,5 @@ <?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, diff --git a/ui/nG6/Configuration/RequestMiddlewares.php b/ui/nG6/Configuration/RequestMiddlewares.php new file mode 100644 index 0000000000000000000000000000000000000000..3e2d41aad04db4ea5c02883b2f5c05b6a77a8d13 --- /dev/null +++ b/ui/nG6/Configuration/RequestMiddlewares.php @@ -0,0 +1,18 @@ +<?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 diff --git a/ui/nG6/class.tx_nG6_eid.php b/ui/nG6/class.tx_nG6_eid.php deleted file mode 100644 index bf943c15d792bdaefa8575a9e4d0cc1a712c9cff..0000000000000000000000000000000000000000 --- a/ui/nG6/class.tx_nG6_eid.php +++ /dev/null @@ -1,987 +0,0 @@ - - -<?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(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cms','ext_tables.php')); -//require_once(PATH_t3lib.'class.t3lib_db.php'); -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_process.php'); -require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/libs/Smarty.class.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 - //\TYPO3\CMS\Frontend\Utility\EidUtility::connectDB(); - $type = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type')); - $user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); - $GLOBALS['TSFE'] = $tsfe = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'), ''); - /** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfe */ - $tsfe->connectToDB(); - $tsfe->initFEuser(); - $tsfe->determineId(); - $tsfe->initTemplate(); - $tsfe->getConfigArray(); - $tsfe->settingLanguage(); - - //error_log("tx_nG6_eid ".$type." \n ", 3, "/work/tmp/mes-erreurs.log"); - // If the type of data requested is project - if ($type == 'project') { - $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('object_id')); - // Select all runs linked to the project - $project_runs = tx_nG6_db::get_user_project_runs($user_id, $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(\TYPO3\CMS\Core\Utility\GeneralUtility::_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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('run_description'))).'</a></li>'; - } - // Then all project analysis - $project_analysis = tx_nG6_db::get_user_project_analysis($user_id, $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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'</a></li>'; - } - // Return the html_tree - print $html_tree; - - // If the type of data requested is run - } - elseif ($type == 'run'){ - $run_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('object_id')); - // Select all analysis linked to the run and the run information - $run_analysis = tx_nG6_db::get_user_run_analysis($user_id, $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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP("raw_data_description")).'\' id=\'data_'.$run_id.'\'> <a href=\'#\'>'.trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analyse_description'))).'</a></li>'; - } - // Return the html_tree - print $html_tree; - - // If asked to check a job status - } - elseif($type == 'check_status') { - $pid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pid')); - $archive_path = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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} - } elseif ($type == 'hide') { - - $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); - // {project/run}_id to array (1;2;3;...) -> [1;2;3;...] - $tab_ids = explode(";",$ids); - $hide_level = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hide_level')); - - if ($hide_level == 'project') { - foreach($tab_ids as $id => $value) { - tx_nG6_db::hide_project($value); - } - } elseif ($hide_level == 'run') { - foreach($tab_ids as $id => $value) { - tx_nG6_db::hide_run($value, $user_id); - } - } elseif ($hide_level == 'analysis') { - foreach($tab_ids as $id => $value) { - tx_nG6_db::hide_analysis($value, $user_id); - } - } - - // If asked to unhide a {project/run} - } elseif ($type == 'unhide') { - - $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); - // {project/run}_id to array (1;2;3;...) -> [1;2;3;...] - $tab_ids = explode(";",$ids); - $unhide_level = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('unhide_level')); - - if ($unhide_level == 'project') { - foreach($tab_ids as $id => $value) { - tx_nG6_db::unhide_project($value); - } - } elseif ($unhide_level == 'run') { - foreach($tab_ids as $id => $value) { - tx_nG6_db::unhide_run($value, true); - } - } elseif ($unhide_level == 'analysis') { - foreach($tab_ids as $id => $value) { - tx_nG6_db::unhide_analysis($value, true); - } - } - - // If asked to delete a {project/run/analyze} - } - elseif ($type == 'delete') { - - $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); - // {project/run}_id to array (1;2;3;...) -> [1;2;3;...] - $tab_ids = explode(";",$ids); - $delete_level = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('del_level')); - $data_folder = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_folder')); - $user_login = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_login')); - $user_pwd = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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($value, $user_login, $user_pwd, $data_folder); - if ($res != 0) { break; } - } - } elseif ($delete_level == 'run') { - foreach($tab_ids as $id => $value) { - $res = tx_nG6_db::delete_run($value, $user_login, $user_pwd, $data_folder); - if ($res != 0) { break; } - } - } elseif ($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 - } elseif ($type == 'publish') { - - $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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); - } - - // If asked to unpublish a project - } elseif ($type == 'unpublish') { - - $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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 - } elseif ($type == 'get_size') { - $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); - $view = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view')); - $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, true); - } elseif ($view == "project") { - $full_size += tx_nG6_db::get_project_size($value, true); - } - } - print tx_nG6_utils::get_octet_string_representation($full_size); - - // data size - }elseif ($type == 'get_data_size'){ - $run_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('run_ids')); - $data_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_ids')); - $analysis_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('analysis_ids')); - $full_size = 0; - - if ($run_ids){ - $data = explode(',', $run_ids); - foreach($data as $id => $value) { - $full_size += tx_nG6_db::get_run_size($value, true); - } - } - if ($data_ids){ - $data = explode(',', $data_ids); - foreach($data as $id => $value) { - $full_size += tx_nG6_db::get_run_size($value, false); - } - } - if ($analysis_ids){ - $data = explode(',', $analysis_ids); - foreach($data as $id => $value) { - $full_size += tx_nG6_db::get_analysis_size($value); - } - } - print $full_size . ":::" . tx_nG6_utils::get_octet_string_representation($full_size); - - // If update a field - } elseif ($type == 'update_db_field') { - - //Retrieve infomation - $table = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('table')); - $id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pk')); - $field = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('field')); - $value = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('value')); - - //If change concernes a date - if( $field == "date" || $field == "crdate" ) { - //Change date format - $date = explode('-', $value); - $timestamp = mktime (0, 0, 1, $date[1], $date[2], $date[0]); - //Update the entity - tx_nG6_db::update_field($table, $id, $field, $timestamp); - } - else { - //Update the entity - tx_nG6_db::update_field($table, $id, $field, $value); - } - print $value; - - } - // add comment - elseif ($type == 'add_comment') { - $view = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view')); - $view_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view_id')); // project_id or run_id or analyze_id - $new_comment = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('new_comment')); - $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cruser_id')); - $res = 0 ; - - if ($new_comment){ - if($view == 'project'){ - $res = tx_nG6_db::add_project_comment($view_id, $cruser_id, $new_comment) ; - } - elseif ($view == 'run') { - $res = tx_nG6_db::add_run_comment($view_id, $cruser_id, $new_comment) ; - } - elseif ($view == 'analyze') { - $res = tx_nG6_db::add_analyze_comment($view_id, $cruser_id, $new_comment) ; - } - } - - print $res; - } - //delete comment - elseif ($type == 'delete_comment') { - $view = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view')); - $view_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('view_id')); // project_id or run_id or analyze_id - $comment_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('comment_id')); - $res = 0 ; - if($view == 'project'){ - $res = tx_nG6_db::delete_project_comment($view_id, $comment_id); - } - elseif ($view == 'run') { - $res = tx_nG6_db::delete_run_comment($view_id, $comment_id); - } - elseif ($view == 'analyze') { - $res = tx_nG6_db::delete_analyze_comment($view_id, $comment_id); - } - print $res; - } - //update comment - elseif ($type == 'update_comment') { - $comment_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('comment_id')); - $new_comment = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('new_comment')); - $res = 0; - $new_comment = urldecode($new_comment); - $res = tx_nG6_db::update_comment($comment_id, $new_comment); - print $res; - - // If asked the krona page - } elseif ($type == 'get_krona') { - - $data_folder = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_folder')); - $file_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('file_name')); - $sequence_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_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(\TYPO3\CMS\Core\Utility\GeneralUtility::_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="'.\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(ExtensionManagementUtility::extPath('nG6')).'res/js/krona-1.1.js"></script>'; - $val .= $xml_parts[1]; - $val .= '</div>'; - $val .= '</body>'; - $val .= '</html>'; - print $val; - - } elseif ($type == 'delete_users') { - - $ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ids')); - // users_id to array (1;2;3;...) -> [1;2;3;...] - $tab_ids = explode(";",$ids); - $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); - - // try to delete users in project ... - if($project_id != "") { - $none_access = ""; - foreach($tab_ids as $id => $del_user_id) { - tx_nG6_db::delete_access_to_project($del_user_id, $project_id); - - // find if user can't access to any project - $users_access = tx_nG6_db::count_number_of_project_access($del_user_id); - if($users_access == '0'){ - $none_access .= $del_user_id.";"; - } - } - - if($none_access == ""){ // everybody has at least one access to a project - $others_access = '0'; - }else{ // list separate by coma of users who can't access to any project - $others_access = substr($none_access, 0, -1); - } - - print $others_access; - - // delete users of DB... - }else{ - - foreach($tab_ids as $k_id => $v_id){ - // delete group - $gid = tx_nG6_db::get_user_usergroup($v_id); - // delete user - tx_nG6_db::delete_user($v_id); - if(tx_nG6_db::count_users_in_group($gid) == 0){ - tx_nG6_db::delete_group($gid); - } - } - - } - - // to change users' right on project - } elseif ($type == 'change_right') { - - $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); - $c_user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('c_user_id')); - $right_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('right_id')); - - tx_nG6_db::change_access_to_project($c_user_id, $project_id, $right_id); - - // jquery autocomplete - } elseif ($type == 'autocomplete') { - - $col = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('gender')); - $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); - $name_start = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('name_start')); - - // user search - if($col != 'title' && $col != 'location' && $col != 'organism'){ - $res = tx_nG6_db::get_all_names_starting_with($name_start, $col); - foreach($res as $res_id => $res_val){ - // find right on project - $res[$res_id]['right_id'] = tx_nG6_db::get_user_right_on_project($res_val['uid'], $project_id); - - // find creator username - $cruser_infos = tx_nG6_db::get_user_informations($res[$res_id]['cruser_id']); - $res[$res_id]['cruser_username'] = $cruser_infos['username']; - } - - // group search - }else{ - if ($col == "location" || $col == "organism") { $col = "tx_nG6_".$col; } - $res = tx_nG6_db::get_all_starts_with_in_group($name_start, $col); - } - $json_res = json_encode($res); - print $json_res; - - // add a new member on project - } elseif ($type == 'add_user') { - - $part = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('part')); - $user_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('username')); - $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); - $right_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('right')); - $group_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('title')); - $location = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('location')); - $organism = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('organism')); - $email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('email')); - $first_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('first_name')); - $last_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('last_name')); - $password = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('password')); - $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('creator')); - $from_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('from_email')); - $envelope_sender_address = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('envelope_sender_address')); - $pid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pid')); - $project_url = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_url')); - $send_an_email = filter_var(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('send_an_email')), FILTER_VALIDATE_BOOLEAN); - - // if group not exists, create group - $group_id = tx_nG6_db::get_group_id($group_name); - if( !isset($group_id) ){ - - $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('creator')); - tx_nG6_db::create_new_group($cruser_id, $group_name, $organism, $location); - $group_id = tx_nG6_db::get_group_id($group_name); - - } - - $user = tx_nG6_db::select_user_by_username($user_name); - - // if user does not exists in DB - if(!isset($user)){ - - $create_user_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('create_user_email')); - $create_user_title = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('create_user_title')); - - $res_code = tx_nG6_db::add_user($user_name, $first_name, $last_name, $email, tx_nG6_utils::hash_password($password), $cruser_id, $group_id, $pid); - - if ($res_code == 0) { - // find the new user id - $user = tx_nG6_db::select_user_by_username($user_name); - - // authorize new access - tx_nG6_db::add_access_to_project($user["uid"], $project_id, $right_id); - - if ($send_an_email) { - // send an email to the new user - $message = str_replace("###USER_FIRST_NAME###", $first_name, $create_user_email); - $message = str_replace("###USER_LAST_NAME###", $last_name, $message); - $message = str_replace("###USER_LOGIN###", $user_name, $message); - $message = str_replace("###USER_PASSWORD###", $password, $message); - $message = str_replace("###PROJECT_LINK###", $project_url, $message); - $msg_table = explode('\n', $message); - $message = implode("\n", $msg_table); - mail($email, $create_user_title, $message, "From: <".$from_email.">",'-f '.$envelope_sender_address); - } - print '2'; // ok - } elseif ($res_code == 1) { - print '4'; // username exists - } elseif ($res_code == 2) { - print '5'; // email exists - } - - // user exists in DB - } elseif ($user["username"] != $user_name || $user["email"] != $email || $user["first_name"] != $first_name || $user["last_name"] != $last_name) { - // there is difference between information provided and the user account - print '3'; - } else { - // can user access to the project ? - if(tx_nG6_db::get_user_right_on_project($user["uid"], $project_id) == -1){ - - // authorize new access - tx_nG6_db::add_access_to_project($user["uid"], $project_id, $right_id); - - // send an email to the user - if ($email != "" && $send_an_email) { - - $add_user_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('add_user_email')); - $add_user_title = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('add_user_title')); - $project = tx_nG6_db::select_project($project_id); - $message = str_replace("###USER_FIRST_NAME###", $first_name, $add_user_email); - $message = str_replace("###USER_LAST_NAME###", $last_name, $message); - $message = str_replace("###PROJECT_NAME###", $project["name"], $message); - $message = str_replace("###PROJECT_DESCRIPTION###", $project["description"], $message); - $message = str_replace("###PROJECT_LINK###", $project_url, $message); - $msg_table = explode('\n', $message); - $message = implode("\n", $msg_table); - mail($email, $add_user_title, $message, "From: <".$from_email.">",'-f '.$envelope_sender_address); - - } - print '0'; - - } else { - print '1'; // already access to the project - } - } - - } - elseif ($type == 'check_ssh_user'){ - $user_login = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_login')); - $user_pwd = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_pwd')); - $project_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id')); - - $path_to_check = tx_nG6_utils::get_project_data_save_dir($project_id); - - $res = 3; - // check login and password - if (isset($user_login) && isset($user_pwd) && $user_login != 'undefined' && $user_pwd != 'undefined') { - $ssh_command = 'touch '.$path_to_check.'/run/test ; rm -f '.$path_to_check.'/run/test' ; - $connection = ssh2_connect('127.0.0.1', 22); - - if (!$connection) { - //1st test, basic SSH connection - $res = 3; - } elseif( !ssh2_auth_password($connection, $user_login,$user_pwd ) ){ - //2nd test, SSH connection with user + pwd - $res = 2; - }else{ - //3rd test, excuting the SSH command - $stream = ssh2_exec($connection, $ssh_command ); - $errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR); - // Enable blocking for both streams - stream_set_blocking($errorStream, true); - stream_set_blocking($stream, true); - - if(stream_get_contents($errorStream)) { - // Close the streams - fclose($errorStream); - fclose($stream); - $res = 4; - }else{ - fclose($errorStream); - fclose($stream); - $res = 0; - } - } - - } else { - //The user and/or password is missing - $res = 3; - } - print $res; - - - } - elseif ( $type == 'add_to_ng6_admin'){ - $userid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userid')); - tx_nG6_db::add_to_ng6_admin($userid); - } - elseif ( $type == 'delete_from_ng6_admin'){ - $userids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userids')); - $userids = explode(',', $userids); - tx_nG6_db::remove_from_ng6_admin($userids); - } - elseif ( $type == 'add_to_ng6_superadmin'){ - $userid = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userid')); - tx_nG6_db::add_to_ng6_superadmin($userid); - } - elseif ( $type == 'delete_from_ng6_superadmin'){ - $userids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('userids')); - $userids = explode(',', $userids); - tx_nG6_db::remove_from_ng6_superadmin($userids); - } - elseif($type == 'update_user'){ - $email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('email')); - $first_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('first_name')); - $last_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('last_name')); - $group_name = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('title')); - $location = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('location')); - $organism = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('organism')); - $user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); - $password = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('password')); - $cruser_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('creator')); - $send_an_email = filter_var(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('send_an_email')), FILTER_VALIDATE_BOOLEAN); - $from_email = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('from_email')); - $envelope_sender_address = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('envelope_sender_address')); - - $updated = tx_nG6_db::update_user($user_id, $first_name, $last_name, $email, $group_name, $organism, $location, tx_nG6_utils::hash_password($password)) ; - - $nb_updated = count($updated); - - if ( $nb_updated > 0 && $send_an_email){ - $user_infos = tx_nG6_db::get_user_informations($user_id); - $email = $user_infos['email']; - $first_name = $user_infos['first_name']; - $last_name = $user_infos['last_name']; - $username = $user_infos['username']; - - $mail_title = "[NG6]Your user informations have been updated."; - $mail_content = "Dear " . $first_name . " " . $last_name . " (user name : ".$username."),\n\nSome of your personnal informations have been updated : \n\n"; - if ($email != ''){ - foreach($updated as $key => $value){ - - if($key == 'password'){ - $mail_content .= 'password' . "\t: " . $password . "\n" ; - } - elseif ($key == 'usergroup'){ - $mail_content .= 'title' . "\t: " . $group_name . "\n" ; - $mail_content .= 'location' . "\t: " . $location . "\n" ; - $mail_content .= 'organism' . "\t: " . $organism . "\n" ; - } - else { - $mail_content .= ucwords(str_replace("_", " ", $key)) . "\t: " . $value . "\n" ; - } - } - $mail_content .= "\nThe NG6 team"; - mail($email, $mail_title, $mail_content, "From: <".$from_email.">",'-f '.$envelope_sender_address); - } - } - - print $nb_updated; - } - elseif ($type == 'get_user_group'){ - $id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); - print json_encode(tx_nG6_db::get_group_informations(tx_nG6_db::get_user_usergroup($id))); - } - elseif($type == 'runs_table') { - $smarty = new Smarty(); - $smarty->setTemplateDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/pi1'); - $smarty->setCompileDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/templates_c'); - $smarty->setCacheDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/cache'); - $smarty->setConfigDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/configs'); - $smarty->security = true; - $smarty->security_settings['MODIFIER_FUNCS'] = array('count'); - $project_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id'))); - $user_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id'))); - $login_user = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('login_user'))); - $page_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('page_id'))); - $project_runs = tx_nG6_db::get_project_runs($project_id); - $is_project_admin = tx_nG6_db::is_administrator($user_id, 'project', $project_id); - $is_at_least_admin_of_1_run = false; - foreach($project_runs as $run_id => $run_values) { - $is_admin = tx_nG6_db::is_administrator($user_id, 'run', $run_values['id']); - $project_runs[$run_id]['is_admin'] = $is_admin; - if ($is_admin) { $is_at_least_admin_of_1_run = true; } - $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[run_id]='.$run_values['id'].'&tx_nG6_pi1[project_id]='.$run_values['project_id'].'">'.$run_values['name'].'</a>'; - $project_runs[$run_id]['href'] = $href; - } - $smarty->assign('runs', $project_runs); - $smarty->assign('is_project_admin', $is_project_admin); - $smarty->assign('is_at_least_admin_of_1_run', $is_at_least_admin_of_1_run); - $smarty->assign('login_user', $login_user); - print $smarty->fetch('run_table.tpl'); - - } - elseif($type == 'projects_table') { - $smarty = new Smarty(); - $smarty->setTemplateDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/pi1'); - $smarty->setCompileDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/templates_c'); - $smarty->setCacheDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/cache'); - $smarty->setConfigDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/configs'); - $smarty->security = true; - $smarty->security_settings['MODIFIER_FUNCS'] = array('count'); - $user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); - $login_user = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('login_user'))); - $page_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('page_id'))); - $projects = tx_nG6_db::select_all_user_projects($user_id, 'tx_nG6_project.uid DESC'); - //$projects = tx_nG6_db::select_all_user_projects($user_id, 'tx_nG6_project.name'); - $is_at_least_admin_of_1_project = false; - foreach($projects as $project_id => $project_values) { - $is_admin = tx_nG6_db::is_project_administrator($user_id, $project_values['id']); - if ($is_admin) { $is_at_least_admin_of_1_project = true; } - $projects[$project_id]['is_admin'] = $is_admin; - $projects[$project_id]['is_manager'] = tx_nG6_db::is_project_manager($user_id, $project_values['id']); - $projects[$project_id]['is_member'] = tx_nG6_db::is_project_member($user_id, $project_values['id']); - $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_values['id'].'">'.$project_values['name'].'</a>'; - $projects[$project_id]['href'] = $href; - } - $smarty->assign('projects', $projects); - $smarty->assign('is_at_least_admin_of_1_project', $is_at_least_admin_of_1_project); - $smarty->assign('login_user', $login_user); - $smarty->assign('is_ng6_admin', tx_nG6_db::is_ng6_administrator($user_id) ? true : false); - print $smarty->fetch('project_table.tpl'); - - } elseif($type == 'analyses_table') { - $smarty = new Smarty(); - $smarty->setTemplateDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/pi1'); - $smarty->setCompileDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/templates_c'); - $smarty->setCacheDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/cache'); - $smarty->setConfigDir(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/configs'); - $smarty->security = true; - $smarty->security_settings['MODIFIER_FUNCS'] = array('count'); - $user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id')); - $login_user = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('login_user'))); - $page_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('page_id'))); - $project_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id'))); - $run_id = intVal(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('run_id'))); - if ($run_id != "") { - $analysis = tx_nG6_db::get_run_analysis($run_id); - } else { - $analysis = tx_nG6_db::get_project_analysis($project_id); - } - // Add some information to the table - foreach($analysis as $analysis_id => $analysis_values) { - if (tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id'])) { $is_admin = true; } - $analysis[$analysis_id]['is_admin'] = tx_nG6_db::is_administrator($user_id, 'analyze', $analysis_values['id']); - if ($run_id != "") { - $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_id.'&tx_nG6_pi1[run_id]='.$run_id.'&tx_nG6_pi1[analyze_id]='.$analysis_values['id'].'">'.$analysis_values['name'].'</a>'; - } else { - $href = '<a href="index.php?id='.$page_id.'&tx_nG6_pi1[project_id]='.$project_id.'&tx_nG6_pi1[analyze_id]='.$analysis_values['id'].'">'.$analysis_values['name'].'</a>'; - } - $analysis[$analysis_id]['href'] = $href; - } - $smarty->assign('display_analysis_result', $is_admin); - $smarty->assign('is_admin', $is_admin); - $smarty->assign('h_analysis', tx_nG6_utils::trace_hierarchy($analysis)); - $smarty->assign('login_user', $login_user); - print $smarty->fetch('analysis_table.tpl'); - } elseif($type == 'install') { - $res = tx_nG6_db::select_user_by_username("admin_install"); - if ($res != null){ - $res2 = tx_nG6_db::finalize_installation($res["uid"], - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('username')), - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('first_name')), - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('last_name')), - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('email')), - tx_nG6_utils::hash_password(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('password'))), - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('pid')), - "Demo project", - "This project presents demonstration workflows", - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('title')), - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('organism')), - trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('location')) - - ); - // if there is a result, then log the user - if ($res2) { - $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'), ''); - $GLOBALS['TSFE']->initFEuser(); - $GLOBALS['TSFE']->fe_user->createUserSession(array('uid' =>$res["uid"])); - } - } - print $res; - } elseif($type == 'project_data_repartition') { - $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); - $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); - print json_encode(tx_nG6_db::select_projects_repartition($role, $by)); - } elseif($type == 'project_distribution') { - $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); - $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); - $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); - print json_encode(tx_nG6_db::select_projects_distribution($values, $by, $role)); - } elseif($type == 'project_evolution') { - $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); - $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); - $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); - $cumulate = false; - if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cumulate')) == '1'){ - $cumulate = true; - } - print json_encode(tx_nG6_db::select_projects_evolution($values, $by, $role, $cumulate)); - - } elseif($type == 'data_distribution'){ - $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); - $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); - $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); - $get_analyzes = false; - if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('get_analyzes')) == '1'){ - $get_analyzes = true; - } - $octet = true; - if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('bases')) == '1'){ - $octet = false; - } - print json_encode(tx_nG6_db::select_storage_distribution($values, $by, $role, $get_analyzes, $octet)); - - } elseif($type == 'data_evolution'){ - $values = explode(",", trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('values'))); - $by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by')); - $role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role')); - $get_analyzes = false; - if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('get_analyzes')) == '1'){ - $get_analyzes = true; - } - $octet = true; - if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('bases')) == '1'){ - $octet = false; - } - $cumulate = false; - if(trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cumulate')) == '1'){ - $cumulate = true; - } - print json_encode(tx_nG6_db::select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $cumulate)); - - } elseif ($type == 'purge_managment_mail') { - $all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project')); - $with_extension = 1; - print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects,$with_extension)); - - } elseif ($type == 'purge_managment_mail_without_extension') { - $all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project')); - $with_extension = 0; - print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects,$with_extension)); - - } elseif ($type == 'purge_managment_resend_mail') { - $purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand')); - print json_encode(tx_nG6_pi6::resend_purge_demand_mail($purge_ids)); - } elseif ($type == 'refresh_purge_demand') { - $purge_delay = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_delay')); - $purge_demand_filter_space = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand_filter_space')); - $purge_demand_filter_delay_exceeded = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand_filter_delay_exceeded')); - - - print json_encode(tx_nG6_db::get_purge_demand_list($purge_delay,$purge_demand_filter_space,$purge_demand_filter_delay_exceeded)); - } elseif ($type == 'refresh_purge_list') { - $max_retention_date = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('max_retention_date')); - $filter_space = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('filter_space')); - - $without_laboratories_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('without_lab')); - $with_laboratories_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('with_lab')); - $create_users = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('create_users')); - print json_encode(tx_nG6_db::filter_list_retention_data_info($filter_space,$max_retention_date,$create_users, $without_laboratories_id,$with_laboratories_id)); - } elseif ($type == 'delete_purge_data') { - //Delete data link to the list of purge demand - $purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand')); - $data_folder = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('data_folder')); - $user_login = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_login')); - $user_pwd = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_pwd')); - - $res = tx_nG6_db::delete_purge_demand($purge_ids,$user_login, $user_pwd, $data_folder); - //print $res; - print $res; - } elseif ($type == 'extend_retention_date_from_demand') { - //Extend the retention date for the - $purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand')); - $value = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('date_value')); - $type_extend = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type_extend')); //all project or only run/analyse obsolete - //Change date format - $date = explode('/', $value); - $timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]); - print json_encode(tx_nG6_db::extend_retention_date_from_demand(explode(',',$purge_ids),$timestamp,$type_extend)); - } elseif ($type == 'extend_retention_date_from_project') { - //Extend the retention date for the - $projects_id_str = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('projects_id')); - $value = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('date_value')); - //Change date format - $date = explode('/', $value); - $timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]); - //TODO project - print json_encode(tx_nG6_db::extend_retention_date_from_project($projects_id_str,$timestamp, TRUE)); - } elseif ($type == 'get_all_project') { - print json_encode(tx_nG6_db::select_all_projects()); - } - } - -} - -if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_eid.php']) { - include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_eid.php']); -} - -// Instanciation -$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_nG6_eid'); -$SOBE->main(); - -?> diff --git a/ui/nG6/ext_localconf.php b/ui/nG6/ext_localconf.php index d3d3b7cdd5f27045371c64e942eccd101e1a113d..9995b61fe5b011e23e27c5f83592100b568ecaba 100644 --- a/ui/nG6/ext_localconf.php +++ b/ui/nG6/ext_localconf.php @@ -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'; + ?> diff --git a/ui/nG6/felogin.html b/ui/nG6/felogin.html index e391355e0cdc1159fb70ae9ec82ced87ecf18739..ad713e06e41fc03d390f850f648deb07b27cdb1d 100644 --- a/ui/nG6/felogin.html +++ b/ui/nG6/felogin.html @@ -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> diff --git a/ui/nG6/pi1/class.tx_nG6_pi1.php b/ui/nG6/pi1/class.tx_nG6_pi1.php index a496f836474acdd8003f9dd314cbd3f3a12b9856..73c7062e16185ca812d351f2da098ec76b63e5cb 100644 --- a/ui/nG6/pi1/class.tx_nG6_pi1.php +++ b/ui/nG6/pi1/class.tx_nG6_pi1.php @@ -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']); diff --git a/ui/nG6/pi1/project_table.tpl b/ui/nG6/pi1/project_table.tpl index 1e5ce2410c04cc63b59678807f7553e89660c1a4..bee62af1d6eac180fba070ec7fb562ad366d092c 100644 --- a/ui/nG6/pi1/project_table.tpl +++ b/ui/nG6/pi1/project_table.tpl @@ -14,7 +14,6 @@ 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/>. *} - <table class="table table-striped table-bordered dataTable" id="project_data_table"> <thead> <tr> diff --git a/ui/nG6/pi3/class.tx_nG6_pi3.php b/ui/nG6/pi3/class.tx_nG6_pi3.php index c94c0561009a2784b0a5a817a164266a99b42568..25f181e24394e5d0602c2aa7cc6f956fd69cb4fe 100644 --- a/ui/nG6/pi3/class.tx_nG6_pi3.php +++ b/ui/nG6/pi3/class.tx_nG6_pi3.php @@ -26,7 +26,7 @@ * * @author PF bioinformatique de Toulouse <> */ - +use TYPO3\CMS\Core\Context\Context; require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/lib/class.tx_nG6_db.php'); @@ -44,7 +44,8 @@ class tx_nG6_pi3 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { * @return The content that should be displayed on the website */ function main($content,$conf) { - + $context = \TYPO3\CMS\Core\Utility\GeneralUtility ::makeInstance(Context::class); + $user_id = $context->getPropertyFromAspect('frontend.user', 'id'); if (strstr($this->cObj->currentRecord,'tt_content')) { $conf['pidList'] = $this->cObj->data['pages']; $conf['recursive'] = $this->cObj->data['recursive']; @@ -60,7 +61,7 @@ class tx_nG6_pi3 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { 'SELECT' => 'pro.*, rights.right_id ', 'FROM' => 'fe_rights rights ' .' INNER JOIN tx_nG6_project pro ON pro.uid=rights.project_id ', - 'WHERE' => 'rights.fe_user_id='.$GLOBALS['TSFE']->fe_user->user['uid'] + 'WHERE' => 'rights.fe_user_id='.$user_id .' AND (pro.name LIKE "%'.$GLOBALS['_POST']['text-search'].'%" ' .' OR pro.description LIKE "%'.$GLOBALS['_POST']['text-search'].'%")', 'GROUPBY' => '', @@ -77,7 +78,7 @@ class tx_nG6_pi3 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { .' INNER JOIN tx_nG6_project pro ON pro.uid=rights.project_id ' .' INNER JOIN tx_nG6_project_run p_run ON pro.uid=p_run.project_id ' .' INNER JOIN tx_nG6_run run ON run.uid=p_run.run_id', - 'WHERE' => 'rights.fe_user_id='.$GLOBALS['TSFE']->fe_user->user['uid'] + 'WHERE' => 'rights.fe_user_id='.$user_id .' AND (run.name LIKE "%'.$GLOBALS['_POST']['text-search'].'%" ' .' OR run.description LIKE "%'.$GLOBALS['_POST']['text-search'].'%")', 'GROUPBY' => '', @@ -96,7 +97,7 @@ class tx_nG6_pi3 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { .' INNER JOIN tx_nG6_project pro ON pro.uid=rights.project_id ' .' INNER JOIN tx_nG6_project_analyze p_ana ON pro.uid=p_ana.project_id ' .' INNER JOIN tx_nG6_analyze ana ON ana.uid=p_ana.analyze_id', - 'WHERE' => 'rights.fe_user_id='.$GLOBALS['TSFE']->fe_user->user['uid'] + 'WHERE' => 'rights.fe_user_id='.$user_id .' AND (ana.name LIKE "%'.$GLOBALS['_POST']['text-search'].'%" ' .' OR ana.description LIKE "%'.$GLOBALS['_POST']['text-search'].'%")', 'GROUPBY' => '', @@ -115,7 +116,7 @@ class tx_nG6_pi3 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { .' INNER JOIN tx_nG6_run run ON run.uid=p_run.run_id' .' INNER JOIN tx_nG6_run_analyze r_ana ON run.uid=r_ana.run_id' .' INNER JOIN tx_nG6_analyze ana ON ana.uid=r_ana.analyze_id', - 'WHERE' => 'rights.fe_user_id='.$GLOBALS['TSFE']->fe_user->user['uid'] + 'WHERE' => 'rights.fe_user_id='.$user_id .' AND (ana.name LIKE "%'.$GLOBALS['_POST']['text-search'].'%" ' .' OR ana.description LIKE "%'.$GLOBALS['_POST']['text-search'].'%")', 'GROUPBY' => '', diff --git a/ui/nG6/pi4/class.tx_nG6_pi4.php b/ui/nG6/pi4/class.tx_nG6_pi4.php index 28287f1469e8eb91b66f55c3ffae7744cc9aa5a9..3a04e39c14f541dd1404ce8b183d644ab262292d 100644 --- a/ui/nG6/pi4/class.tx_nG6_pi4.php +++ b/ui/nG6/pi4/class.tx_nG6_pi4.php @@ -29,7 +29,7 @@ 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_pi4 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { var $prefixId = 'tx_nG6_pi1'; // Same as class name var $scriptRelPath = 'pi4/class.tx_nG6_pi4.php'; // Path to this script relative to the extension dir. @@ -44,7 +44,9 @@ class tx_nG6_pi4 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { * @return The content that should be displayed on the website */ function main($content,$conf) { - if (strstr($this->cObj->currentRecord,'tt_content')) { + $context = \TYPO3\CMS\Core\Utility\GeneralUtility ::makeInstance(Context::class); + $user_id = $context->getPropertyFromAspect('frontend.user', 'id'); + if (strstr($this->cObj->currentRecord,'tt_content')) { $conf['pidList'] = $this->cObj->data['pages']; $conf['recursive'] = $this->cObj->data['recursive']; } @@ -60,7 +62,7 @@ class tx_nG6_pi4 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { //$p1Vars = \TYPO3\CMS\Core\Utility\GeneralUtility::GPMerged('tx_nG6_pi1'); $p1Vars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged('tx_nG6_pi1'); - if (tx_nG6_db::user_is_authorized($GLOBALS['TSFE']->fe_user->user['uid'], $this->piVars['project_id'], $this->piVars['run_id'])) { + if (tx_nG6_db::user_is_authorized($user_id, $this->piVars['project_id'], $this->piVars['run_id'])) { if ($p1Vars['project_id'] && $p1Vars['run_id'] && $p1Vars['analyze_id']) { $content = '<p '.$this->pi_classParam('path').'>'. $this->pi_list_linkSingle($this->pi_getLL('Projets','Projets'),0, 1, array()); diff --git a/ui/nG6/pi5/class.tx_nG6_pi5.php b/ui/nG6/pi5/class.tx_nG6_pi5.php index 91984b62ddb5479715c948e5875a33e25a7115dd..738b32c80223cc2a4ed1709c912e51795db4e297 100755 --- a/ui/nG6/pi5/class.tx_nG6_pi5.php +++ b/ui/nG6/pi5/class.tx_nG6_pi5.php @@ -49,6 +49,8 @@ class tx_nG6_pi5 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { */ function main($content,$conf) { $context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Context::class); + $user_id = $context->getPropertyFromAspect('frontend.user', 'id'); + $user_name = $context->getPropertyFromAspect('frontend.user', 'username'); if (strstr($this->cObj->currentRecord,'tt_content')) { $conf['pidList'] = $this->cObj->data['pages']; $conf['recursive'] = $this->cObj->data['recursive']; @@ -84,22 +86,26 @@ class tx_nG6_pi5 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { } // get server url from pi1 - $smarty->assign('server_url', $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_nG6_pi1.']['server_url']); + $configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager'); + //$configurationManager->currentPageId = 1; + $extbaseFrameworkConfiguration = $configurationManager->getTypoScriptSetup(); + $serverURL = $extbaseFrameworkConfiguration['plugin.']['tx_nG6_pi1.']["server_url"]; + $smarty->assign('server_url', $serverURL); $smarty->assign('server_name', $this->conf["server_name"]); $smarty->assign('data_folder', $this->conf["data"]); $smarty->assign('temp_folder', $this->conf["temp"]); - $smarty->assign('user_login', $GLOBALS['TSFE']->fe_user->user['username']); + $smarty->assign('user_login', $user_name); if ($this->conf["directory_prefix"]) { $smarty->assign('directory_prefix', $this->conf["directory_prefix"]); } else { $smarty->assign('directory_prefix', ""); } - $smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']); + $smarty->assign('user_id', $user_id); $smarty->assign('tmp_url', substr($this->conf["temp"], strpos($this->conf["temp"], "fileadmin"))); // Build the lists of all elements if (!$context->getPropertyFromAspect('frontend.user', 'isLoggedIn')) { $user_id = null; } - else { $user_id = $GLOBALS['TSFE']->fe_user->user['uid']; } + else { $user_id = $user_id; } $projects = tx_nG6_db::get_user_projects($user_id, 'tx_nG6_project.name'); $smarty->assign('projects', $projects); diff --git a/ui/nG6/pi6/class.tx_nG6_pi6.php b/ui/nG6/pi6/class.tx_nG6_pi6.php index 8bb1eb32984276fb2580a9b0c022169acdc0cb2f..706e2693cfe33afb1d571c3d629882a386124643 100755 --- a/ui/nG6/pi6/class.tx_nG6_pi6.php +++ b/ui/nG6/pi6/class.tx_nG6_pi6.php @@ -1,4 +1,5 @@ <?php +//namespace ng6\Controller; /*************************************************************** * Copyright notice * @@ -30,6 +31,7 @@ require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6'). require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/lib/class.tx_nG6_db.php'); require_once(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('nG6').'/res/smarty/libs/Smarty.class.php'); use \TYPO3\CMS\Core\Utility\ExtensionManagementUtility; +use TYPO3\CMS\Core\Context\Context; class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { var $prefixId = 'tx_nG6_pi6'; // Same as class name var $scriptRelPath = 'pi6/class.tx_nG6_pi6.php'; // Path to this script relative to the extension dir. @@ -45,7 +47,9 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { * @return The content that should be displayed on the website */ function main($content,$conf) { - + $context = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Context::class); + $user_id = $context->getPropertyFromAspect('frontend.user', 'id'); + $user_name = $context->getPropertyFromAspect('frontend.user', 'username'); if (strstr($this->cObj->currentRecord,'tt_content')) { $conf['pidList'] = $this->cObj->data['pages']; $conf['recursive'] = $this->cObj->data['recursive']; @@ -84,9 +88,9 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { $smarty->security_settings['MODIFIER_FUNCS'] = array('count'); $group_list = tx_nG6_db::get_group_list(); - $smarty->assign('login_user', $GLOBALS['TSFE']->loginUser); - $smarty->assign('user_id', $GLOBALS['TSFE']->fe_user->user['uid']); - $smarty->assign('user_name', $GLOBALS['TSFE']->fe_user->user['username']); + $smarty->assign('login_user', $user_namer); + $smarty->assign('user_id', $user_id); + $smarty->assign('user_name', $user_namer); $smarty->assign('group_list', $group_list); $smarty->assign('data_folder', $this->conf["data"]); $smarty->assign('server_url', $this->conf['server_url']); @@ -97,7 +101,7 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { $smarty->assign('ng6_admin_users', tx_nG6_db::get_ng6_admin_users() ); $smarty->assign('ng6_superadmin_users', tx_nG6_db::get_ng6_superadmin_users() ); - $smarty->assign('is_current_user_superadmin', tx_nG6_db::is_user_ng6_superadmin($GLOBALS['TSFE']->fe_user->user['uid']) ); + $smarty->assign('is_current_user_superadmin', tx_nG6_db::is_user_ng6_superadmin($user_id) ); $smarty->assign('available_space_ids', tx_nG6_utils::get_available_space_ids()); $smarty->assign('tx_nG6_pi6_redirection_page',$this->conf['redirection_page']); @@ -105,223 +109,7 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin { return $smarty->fetch('administration_view.tpl'); } - static function send_purge_demand_mail($project_ids, $extension_allowed = 1){ - $project_name=""; - 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 = $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["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, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["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, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["run_link_url"]).'">'.$analysis_name.' ('.$analysis_id.')</a>'; - } - if (!$GLOBALS['TSFE']->fe_user->user['uid']){ - 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($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 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, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["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, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["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), - $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 = array(); - $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), '-f '. $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["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"]); - - //We send the mail to ng6-support@groupes.renater.fr and Didier (See $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_warning"] ) - $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), '-f '. $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["envelope_sender_address"]); - } - } - return "Mail sent"; - } - - 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"]); - //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, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["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, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["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), - $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"], "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: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"]; - //$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"]; - - $to= join(",",$res_demand["emails"]); - mail($to, $subject, $mail, implode("\r\n", $headers), '-f '. $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["envelope_sender_address"]); - } - } + } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/pi6/class.tx_nG6_pi6.php']) { diff --git a/ui/nG6/res/js/tx_nG6_pi1.js b/ui/nG6/res/js/tx_nG6_pi1.js index bcf57fbb088fa936167f2ee71fd6367c4e2fbb64..7f2c6b2b9ecc2f041dd0a2eb305313584a77a42d 100644 --- a/ui/nG6/res/js/tx_nG6_pi1.js +++ b/ui/nG6/res/js/tx_nG6_pi1.js @@ -889,9 +889,9 @@ $(function () { val_url += "&project_id=" + $("#current_project_id").val(); val_url += "&right=" + $("#cbb_user_right").val(); val_url += "&pid=" + $("#pid").val(); - val_url += "&add_user_email=" + escape("Dear ###USER_FIRST_NAME### ###USER_LAST_NAME###,\nYou have now acccess to the ###PROJECT_NAME### project (###PROJECT_DESCRIPTION###) accessible once logged in by the following url: ###PROJECT_LINK###\nThe NG6 team\nPS: this is an automatic e-mail message generated by the NG6 system. Please DO NOT RESPOND to this e-mail because the mail box is unattended."); + val_url += "&add_user_email=" + escape("Dear ###USER_FIRST_NAME### ###USER_LAST_NAME###,\nYou have now acccess to the ###PROJECT_NAME### project (###PROJECT_DESCRIPTION###) accessible once logged in by the following url: ###PROJECT_LINK###\n###REINIT_PASSWORD###\nThe NG6 team\n"); val_url += "&add_user_title=[NG6] You have been added to a project"; - val_url += "&create_user_email=" + escape("Dear ###USER_FIRST_NAME### ###USER_LAST_NAME###,\nPlease find bellow your login/password required to log into the NG6 system (###PROJECT_LINK###): \n - login: ###USER_LOGIN###\n - password: ###USER_PASSWORD###\nThe NG6 team\nPS: this is an automatic e-mail message generated by the NG6 system. Please DO NOT RESPOND to this e-mail because the mail box is unattended."); + val_url += "&create_user_email=" + escape("Dear ###USER_FIRST_NAME### ###USER_LAST_NAME###,\nPlease find below your login required to log into the NG6 system (###PROJECT_LINK###): \n - login: ###USER_LOGIN###\n###REINIT_PASSWORD###\nThe NG6 team\n"); val_url += "&create_user_title=[NG6] Account creation"; val_url += "&from_email=" + $("#from_email").val(); val_url += "&envelope_sender_address=" + $("#envelope_sender_address").val(); diff --git a/ui/nG6/template/Resources/Private/Templates/NG6.html b/ui/nG6/template/Resources/Private/Templates/NG6.html index d308e752394ad89da4ddfa93ac840d07f2b72d62..0c2ff6cac11fa0b89aee59a806412ffeebd8c59d 100755 --- a/ui/nG6/template/Resources/Private/Templates/NG6.html +++ b/ui/nG6/template/Resources/Private/Templates/NG6.html @@ -4,7 +4,7 @@ <div id="ng6-header"> <div id="ng6-header-inside"> <ul id="evitement"> - <li><a href="mailto:@">Contact us</a></li> + <li><a href="mailto:ng6-support@groupes.renater.fr">Contact us</a></li> </ul> <!-- fin de evitement --> <h1></h1>