Commit 258914f3 authored by gsalin's avatar gsalin
Browse files
parent dccdebd3
......@@ -302,7 +302,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;
}
......
......@@ -32,39 +32,10 @@ class NG6
$context = GeneralUtility::makeInstance(Context::class);
$userIsLoggedIn = $context->getPropertyFromAspect('frontend.user', 'isLoggedIn');
$id = $context->getPropertyFromAspect('frontend.user', 'username');
error_log("processRequest userIsLoggedIn $id\n", 3, "/work/tmp/mes-erreurs.log");
//$GLOBALS['TSFE'] = GeneralUtility::makeInstance(TypoScriptFrontendController::class, null, 4, 0);
//$GLOBALS['TSFE']->fe_user = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication::class);
// error_log("processRequest userIsLoggedIn $id\n", 3, "/work/tmp/mes-erreurs.log");
//$GLOBALS['TSFE'] -> connectToDB();
//error_log("processRequest $pageId\n", 3, "/work/tmp/mes-erreurs.log");
/** @var TypoScriptFrontendController $typoScriptFrontendController */
// $tsfe = GeneralUtility::makeInstance(
// 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
// $GLOBALS['TYPO3_CONF_VARS'],
// $pageId,
// 0,
// true
// );
// $GLOBALS['TSFE'] = $tsfe;
// $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();
//$this->initializeLanguage();
//$this->initializeData($request);
//return "bl";
// isset($request->getQueryParams()['type']) ? (string)$request->getQueryParams()['type'] : ''
$type = (string)$request->getQueryParams()['type'] ;
// If the type of data requested is project
error_log("processRequest, type= $type\n", 3, "/work/tmp/mes-erreurs.log");
//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'));
......@@ -462,7 +433,7 @@ class NG6
$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'));
$project_id = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project_id');
// try to delete users in project ...
if($project_id != "") {
......@@ -538,7 +509,6 @@ class NG6
// 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'));
......@@ -556,6 +526,7 @@ class NG6
$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) ){
......@@ -584,14 +555,20 @@ class NG6
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("###USER_PASSWORD###", $password, $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
......@@ -614,7 +591,11 @@ class NG6
// 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);
......@@ -623,10 +604,10 @@ class NG6
$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);
......@@ -711,13 +692,17 @@ class NG6
$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'));
$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, tx_nG6_utils::hash_password($password)) ;
$updated = tx_nG6_db::update_user($user_id, $first_name, $last_name, $email, $group_name, $organism, $location) ;
$nb_updated = count($updated);
......@@ -745,7 +730,13 @@ class NG6
$mail_content .= ucwords(str_replace("_", " ", $key)) . "\t: " . $value . "\n" ;
}
}
$mail_content .= "\nThe NG6 team";
$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);
}
}
......@@ -850,31 +841,6 @@ class NG6
$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 == '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"]));
}
}
return GeneralUtility::makeInstance(HtmlResponse::class,$res);
} elseif($type == 'project_data_repartition') {
$role = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('role'));
$by = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('by'));
......@@ -985,42 +951,7 @@ class NG6
return GeneralUtility::makeInstance(JsonResponse::class,tx_nG6_db::select_all_projects());
}
// switch (isset($request->getQueryParams()['type']) ? (string)$request->getQueryParams()['type'] : '') {
// case 'get_size':
// $object = GeneralUtility::makeInstance(tx_nG6_db::class);
// $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);
// }
// }
// // $value = tx_nG6_utils::get_octet_string_representation(12652652122);
// // data size
// break;
// case 'check':
// $this->checkAction();
// break;
// case 'remove':
// $this->removeAction();
// break;
// default:
// // throw new \UnexpectedValueException('No or unknown action passed!', 1543418482439);
// }
// $response = $this->responseFactory
// ->createResponse()
// ->withHeader('Content-Type', 'application/json; charset=utf-8');
// $response->getBody()->write(json_encode("blabla"));
//$this->prepareResponse($response);
//return $response;
return GeneralUtility::makeInstance(HtmlResponse::class,1);
}
......
......@@ -3254,7 +3254,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,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -86,7 +86,11 @@ 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"]);
......
This diff is collapsed.
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment