Commit dd0f10c2 authored by Romain Therville's avatar Romain Therville 🐭

Merge branch 'issue#120' into 'master'

Issue#120

See merge request !51
parents 9a264575 3f190de0
......@@ -1553,6 +1553,27 @@ static function get_project_runs($project_id, $orderby='', $limit='') {
}
return $full_size;
}
static function get_project_space_id($project_id){
$queryParts = Array(
'SELECT' => ' space_id ',
'FROM' => 'tx_nG6_project ',
'WHERE' => 'uid = '.$project_id.' ',
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$space_id = "";
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$space_id = $row['space_id'];
}
return $space_id;
}
/*
......
......@@ -278,10 +278,92 @@ please have a look at our storage fees (<a href="###URL_PRICE###">###URL_PRICE##
return $connection ;
}
static function get_config_content(){
$config_file_path = __DIR__."/../../../application.properties";
$config_file_content = file_get_contents($config_file_path);
return($config_file_content);
}
static function get_retention_policy_from_space_id($space_id = "default"){
$config_file_content = tx_nG6_utils::get_config_content("default");
//file_put_contents("/work/ng6-test/jflow_rtherville/ng6_php.log", "tx_nG6_utils, get_retention_policy_from_space_id(), config_file_content: \n".$config_file_content."\n", FILE_APPEND);
//To explode the file content by line, we use PHP_EOL
$array_config_content = explode(PHP_EOL, $config_file_content);
//file_put_contents("/work/ng6-test/jflow_rtherville/ng6_php.log", "tx_nG6_utils, get_retention_policy_from_space_id(), array_config_content: \n".print_r($array_config_content,TRUE)."\n", FILE_APPEND);
$space_id_retention_config = array();
$pattern_to_find = "[space_".$space_id."]";
$is_space_id_found = FALSE;
//We want to return the space id config as an array
foreach($array_config_content as $line_id => $line_content){
//if we found the right section
if($line_content == $pattern_to_find){
$is_space_id_found = TRUE;
}
//If we enter a new section, we stop the line copying
if($is_space_id_found && $line_content != $pattern_to_find && strpos($line_content,'[')===0 ){
$is_space_id_found = FALSE;
}
if($is_space_id_found){
$space_id_retention_config[] = $line_content;
}
}
return($space_id_retention_config);
}
static function get_project_retention_policy( $project_id ){
$space_id = tx_nG6_db::get_project_space_id($project_id);
$retention_policy = tx_nG6_utils::get_retention_policy_from_space_id($space_id);
$retention_line = "";
$policy = "";
$retention_value = "";
$return_text = "";
foreach($retention_policy as $line => $line_content){
if( strpos($line_content,"retention") === 0 ){
$retention_line = $line_content;
}
}
if( is_numeric(strpos($retention_line,"date"))){
$policy = "date";
}elseif( is_numeric(strpos($retention_line,"period"))){
$policy = "period";
}
$split_retention_line = explode('=',$retention_line);
$retention_value = $split_retention_line[1];
if($policy == "date"){
$date = date("d/m/Y", strtotime($retention_value));
$nice_date = date('l jS \of F Y h:i:s A', $date);
$return_text = " until ".$nice_date;
}elseif($policy == "period"){
$return_text = " for ".$retention_value." months";
}
return($return_text);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_utils.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_utils.php']);
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_db.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/nG6/class.tx_nG6_db.php']);
}
?>
......@@ -223,6 +223,8 @@ class tx_nG6_pi1 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$txNG6Utils = new tx_nG6_utils;
//$smarty->register_object('tx_nG6_utils',$txNG6Utils);
$smarty->assign_by_ref('tx_nG6_utils', $txNG6Utils);
$smarty->assign_by_ref('retention_policy', tx_nG6_utils::get_project_retention_policy($projects[key($projects)]['id']));
}
return $smarty->fetch('project_view.tpl');
......
......@@ -52,6 +52,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<br />
{assign var="project_size" value="<span id='size' class='tx-nG6-mini-wait'></span>"}
Raw data and analysis results use <strong>{$project_size}</strong> on the hard drive for the whole project.<br />
New data added to this project will be kept{$retention_policy}. <br />
<br><label>Data overview</label><br>
<table class="table table-striped table-bordered dataTable" id="manag_purged_data_table">
......
......@@ -164,7 +164,6 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
//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"];
......@@ -238,7 +237,16 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$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>';
}
//We now use join(', ', $run_info) and join(', ', $analyses_info) in get_purge_mail().
/*
$mail = tx_nG6_utils::get_purge_mail($res_project["name"],$res_demand["project_id"],
count(explode(",", $res_demand["run_ids"])), count(explode(",", $res_demand["analyze_ids"])), $res_demand["demand_id"],
tx_nG6_utils::get_octet_string_representation($res_demand["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"]).". ", $res_demand["run_ids"], $res_demand["analyze_ids"]);
*/
$mail = tx_nG6_utils::get_purge_mail($res_project["name"],$res_demand["project_id"],
count(explode(",", $res_demand["run_ids"])), count(explode(",", $res_demand["analyze_ids"])), $res_demand["demand_id"],
tx_nG6_utils::get_octet_string_representation($res_demand["purge_size"]), tx_nG6_utils::get_octet_string_representation($total_project_size),
......
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