Commit add9ee64 authored by Claire Kuchly's avatar Claire Kuchly
Browse files

new purge data management / add mail send / extend managment and purge

parent cf14af6f
......@@ -27,6 +27,7 @@ require_once(PATH_t3lib.'stddb/tables.php');
require_once(t3lib_extMgm::extPath('cms','ext_tables.php'));
require_once(PATH_t3lib.'class.t3lib_db.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_db.php');
require_once(t3lib_extMgm::extPath('nG6').'/pi6/class.tx_nG6_pi6.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_utils.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_process.php');
require_once(t3lib_extMgm::extPath('nG6').'/res/smarty/libs/Smarty.class.php');
......@@ -839,13 +840,10 @@ class tx_nG6_eid {
print json_encode(tx_nG6_db::select_storage_evolution($values, $by, $role, $get_analyzes, $octet, $cumulate));
} elseif ($type == 'purge_managment_mail') {
$all_analyses = trim(t3lib_div::_GP('all_analyses'));
$all_runs = trim(t3lib_div::_GP('all_runs'));
$value = trim(t3lib_div::_GP('date_value'));
//Change date format
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
print json_encode(tx_nG6_db::update_purge_date( $all_runs, $all_analyses, "mail_sent_date",$timestamp));
$user_id = trim(t3lib_div::_GP('user_id'));
$all_projects = trim(t3lib_div::_GP('project'));
print json_encode(tx_nG6_pi6::send_purge_demand_mail($user_id,$all_projects));
} elseif ($type == 'refresh_purge_list') {
$max_retention_date = trim(t3lib_div::_GP('max_retention_date'));
......@@ -855,18 +853,24 @@ class tx_nG6_eid {
//Change date format
print json_encode(tx_nG6_db::filter_list_retention_data_info($filter_size,$max_retention_date,$create_users, $without_laboratories_id));
} elseif ($type == 'refresh_retention_date') {
$all_analyses = trim(t3lib_div::_GP('all_analyses'));
$all_runs = trim(t3lib_div::_GP('all_runs'));
$value = trim(t3lib_div::_GP('date_value'));
//Change date format
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
print json_encode(tx_nG6_db::update_purge_date( $all_runs, $all_analyses, "retention_date",$timestamp));
print json_encode(tx_nG6_db::update_purge_date( $all_runs, $all_analyses, "data_state","extended"));
print json_encode(tx_nG6_db::update_purge_date( $all_runs, $all_analyses, "mail_sent_date",""));
}
} elseif ($type == 'delete_data') {
//Delete data link to the list of purge demand
$purge_ids = trim(t3lib_div::_GP('purge_demand'));
#TODO
print json_encode(tx_nG6_db::set_purge_demand_processed(explode(',',$purge_ids),"delete",""));
}
elseif ($type == 'extend_rentention_date') {
//Extend the retention date for the
$purge_ids = trim(t3lib_div::_GP('purge_demand'));
$value = trim(t3lib_div::_GP('date_value'));
//Change date format
$date = explode('/', $value);
$timestamp = mktime (0, 0, 1, $date[1], $date[0], $date[2]);
error_log("extend_rentention_date : ".$purge_ids."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
print json_encode(tx_nG6_db::set_purge_demand_processed(explode(',',$purge_ids),"extend",$timestamp));
}
}
}
......
......@@ -44,12 +44,38 @@ class tx_nG6_db {
* @param string $field the field to change
* @param string $value the new value
*/
function update_field($table, $id, $field, $value) {
function update_field($table, $id, $field, $value) {
if( $field == 'uid' ) {
throw new Exception ("The function 'update_field' cannot change an id.") ;
}
$array=array();
if( is_array($field) ){
for($i =0; $i<count($field);$i++){
$array[$field[$i]]=$value[$i];
}
}else{
$array=array($field => $value);
}
if ( is_array($id) ){
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery ($table, 'uid IN ('.implode(',',$id).')', $array);
}else{
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery ($table, 'uid='.$id, $array);
}
}
/*function update_field($table, $id, $field, $value) {
if( $field == 'uid' ) {
throw new Exception ("The function 'update_field' cannot change an id.") ;
}
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery ($table, 'uid='.$id, array($field => $value));
}
}
$array=array();
if( is_array($field) ){
for($i =0; $i<count($field);$i++){
$array[$field[$i]]=$value[$i];
}
}else{
$array=array($field => $value);
}
$GLOBALS['TYPO3_DB']-> exec_UPDATEquery ($table, 'uid='.$id, $array);
}*/
/**
* Update run and analyze for purge managment
......@@ -60,7 +86,7 @@ class tx_nG6_db {
* @param string $value the new value
*/
function update_purge_date( $all_runs_ids, $all_analyses_ids, $field, $value){
function update_run_analyze_fields( $all_runs_ids, $all_analyses_ids, $field, $value){
foreach(explode(",", $all_runs_ids) as $run_id){
tx_nG6_db::update_field('tx_nG6_run', $run_id, $field, $value);
......@@ -103,7 +129,6 @@ class tx_nG6_db {
function get_project_list_by_group_filter($create_user_id, $user_group_id){
$where="";
$list_project_id_filter_by_group="";
$list_project_id_laboratories="";
......@@ -155,20 +180,26 @@ class tx_nG6_db {
}
}
error_log("WHERE : ".$where."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
error_log("LIST project : ".$list_project_id_laboratories."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
return ($list_project_id_laboratories);
}
################################
# OBSOLETE / PURGE management
################################
function select_obsolete_list_retention_data_info() {
$where = ' DATEDIFF( FROM_UNIXTIME( retention_date ) , now( ) ) <0';
$where .= ' AND purge_demand_id IS NULL ';
$where .= ' AND state IN ( \'stored\', \'extend\') ';
return (tx_nG6_db::select_list_retention_data_info($where));
}
function filter_list_retention_data_info($filter_size, $max_retention_date, $create_user_id, $user_group_id) {
$where = ' DATEDIFF( FROM_UNIXTIME( retention_date ) , now( ) ) <0';
$where .= ' AND purge_demand_id IS NULL ';
$where .= ' AND state IN ( \'stored\', \'extend\') ';
if ($max_retention_date != "") {
$where = ' DATEDIFF( FROM_UNIXTIME( retention_date ) , STR_TO_DATE( "'.$max_retention_date.'", "%d/%m/%Y" ) ) <0';
}
......@@ -223,8 +254,8 @@ class tx_nG6_db {
}
}
$res = tx_nG6_db::select_all_in_view("tx_nG6_view_project_run_analyze",$where);
$res = tx_nG6_db::select_all_in_view("tx_nG6_view_project_run_analyze",$where,'10');
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if (!isset ($by_project[$res_row['project_id']])) {
......@@ -325,6 +356,168 @@ class tx_nG6_db {
return($by_project);
}
/**
* Set purge demand to delete and modif analyze and run in db
*
* @param int $demand_id demand_id
* @return
*/
/*
function set_purge_demand_deleted($demand_id, $date){
$d=tx_nG6_db::_demand_from_id($demand_id);
$all_analyze_ids = $d['analyze_ids'];
$all_run_ids = $d['run_ids' ];
$date =time();
# Run deleted process
foreach($all_run_ids as $run_id){
$res = tx_nG6_db::select_run($run_id);
$run_directory = '/save/ng6-test'.$res['directory'];
tx_nG6_db::update_field('tx_nG6_run',
}
}*/
/**
* Add purge initial purge demand in db
*
* @param int $project_id project id link to the purge demand
* @param int $total_purgeable_size size of files to purge
* @return New purge id
*/
function set_purge_demand_processed($demand_ids,$process, $date){
$all_demands=tx_nG6_db::get_purge_demand_from_id($demand_ids);
$all_runs="";
$all_analyses="";
foreach($all_demands as $res){
$all_analyses=$all_analyses.",".$res["analyze_ids"];
$all_runs=$all_runs.",".$res["run_ids"];
}
if ($process == "extend"){
error_log("set_purge_demand_processed : ".$all_analyses." all_runs ".$all_runs."\n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
tx_nG6_db::update_run_analyze_fields( $all_runs, $all_analyses,
array("retention_date","data_state", "mail_sent_date","purge_demand_id"),
array($date,"extended","",""));
tx_nG6_db::update_field('tx_nG6_purge_demand',$demand_ids,
array("processed_date","demand_state"),
array($date,"extended")
);
}else{
tx_nG6_db::update_run_analyze_fields( $all_runs, $all_analyses,
array("purged_size"),
array("`storage_size`")
);
}
}
function add_purge_demand($cruser_id, $project_id,$total_purgeable_size,$all_runs_ids, $all_analyses_ids,$managers_name){
$date= time();
error_log("DEMAND update purge: run : ".$all_runs_ids." \n analyse:".$all_analyses_ids." \n filed: ".$field." \n value".$value." \n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
$purge_data = array(
'cruser_id' => $cruser_id,
'project_id' => $project_id,
'analyze_ids' => $all_analyses_ids,
'run_ids' => $all_runs_ids,
'mail_sent_date' => $date,
'purge_size' => $total_purgeable_size,
'demand_state' => "sent",
'tstamp' => $date,
'crdate' => $date
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_nG6_purge_demand', $purge_data);
$purge_demand_id = $GLOBALS['TYPO3_DB']->sql_insert_id();
tx_nG6_db::update_run_analyze_fields( $all_runs_ids, $all_analyses_ids, array('mail_sent_date','purge_demand_id'),array($date,$purge_demand_id));
foreach($managers_name as $user_name){
$res= tx_nG6_db::select_user_by_username($user_name);
$purge_data_user = array(
'tstamp' => $date,
'crdate' => $date,
'cruser_id' => $cruser_id,
'purge_demand_id' => $purge_demand_id,
'fe_users_id' => $res['uid']
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_nG6_purge_demand_fe_users', $purge_data_user);
}
error_log("update purge:".$all_runs_ids." analyse:".$all_analyses_ids." filed: ".$field." value".$value." \n",3,"/save/ng6-test/src/nG6/ui/nG6/pi6/test.log");
return $purge_demand_id;
}
function get_purge_demand_from_id($values){
#select all demand id not processed
$queryParts=array(
'SELECT' => ' uid as demand_id,project_id,purge_size,mail_sent_date,processed_date,demand_state,analyze_ids,run_ids',
'FROM' => 'tx_nG6_purge_demand',
'WHERE' => 'uid IN ('.implode(",",$values).')',
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$result=array();
while($res_row= $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$result[]=array(
"demand_id"=>$res_row["demand_id"],
"project_id"=>$res_row["project_id"],
"purge_size"=>$res_row["purge_size"],
"mail_sent_date"=>$res_row["mail_sent_date"],
"processed_date"=>$res_row["processed_date"],
"demand_state"=>$res_row["demand_state"],
"analyze_ids"=>$res_row["analyze_ids"],
"run_ids"=>$res_row["run_ids"]
);
}
return($result);
}
function get_purge_demand_list($delay_in_days){
#select all demand id not processed
$queryParts=array(
'SELECT' => 'tx_nG6_purge_demand.uid AS demand_id, `tx_nG6_purge_demand`.project_id AS project_id, tx_nG6_project.name as project_name,
`tx_nG6_purge_demand`.purge_size AS purge_size, `tx_nG6_purge_demand`.mail_sent_date, `tx_nG6_purge_demand`.demand_state,
`fe_users`.username, `fe_groups`.title AS user_group_title,
DATEDIFF( FROM_UNIXTIME( `tx_nG6_purge_demand`.mail_sent_date ) , now( ) ) >'.$delay_in_days.' AS delay_excedeed',
'FROM' => '`tx_nG6_purge_demand`
INNER JOIN tx_nG6_project ON tx_nG6_project.uid = tx_nG6_purge_demand.project_id
INNER JOIN `tx_nG6_purge_demand_fe_users` ON `tx_nG6_purge_demand_fe_users`.`purge_demand_id` = tx_nG6_purge_demand.uid
INNER JOIN fe_users ON fe_users.uid = `tx_nG6_purge_demand_fe_users`.`fe_users_id`
INNER JOIN fe_groups ON fe_groups.uid = fe_users.usergroup',
'WHERE' => '`tx_nG6_purge_demand`.processed_date IS NULL',
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$results=array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($res_row= $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ( array_key_exists($res_row["demand_id"] , $results)){
$results[$res_row["demand_id"]]["users"][]=array("username"=>$res_row["username"], "user_group_title"=>$res_row["user_group_title"]);
} else {
$results[$res_row["demand_id"]]=array("project_id"=>$res_row["project_id"],
"purge_size"=>$res_row["purge_size"],
"mail_sent_date"=>$res_row["mail_sent_date"],
"project_name"=>$res_row["project_name"],
"demand_state"=>$res_row["demand_state"],
"delay_excedeed"=>$res_row["delay_excedeed"],
"users"=>array(array("username"=>$res_row["username"], "user_group_title"=>$res_row["user_group_title"]))
);
}
}
return ($results);
}
/**
* Select all project for the current user
......
......@@ -39,7 +39,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<li class="active"><a href="#statistics" data-toggle="tab">Statistics</a></li>
<li><a href="#admin_management" data-toggle="tab">Admin management</a></li>
<li><a href="#wf_monitoring" data-toggle="tab">Workflows monitoring</a></li>
<li><a href="#purge_management" data-toggle="tab">Purge management</a></li>
<li><a href="#project_data_management" data-toggle="tab">Projets data management</a></li>
<li><a href="#purge_demand_management" data-toggle="tab">Purge demand management</a></li>
</ul>
<div id="myTabContent" class="tab-content">
......@@ -266,7 +268,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</div>
<div class="tab-pane fade" id="wf_monitoring"></div>
<div class="tab-pane fade" id="purge_management">
<div class="tab-pane fade" id="project_data_management">
<div id="purge_menu" class="clearfix">
<div>
<p>
......@@ -350,24 +352,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<br />
<div id="purge_list">
<div>
<p>
Table with the number of runs and analysis who is obsolete and who has no purge demand mail sended.
</p>
</div>
<table class="table table-striped table-bordered dataTable" id="data_table_obsolete">
<thead>
<tr>
<th rowspan="2"><center><input type="checkbox" id="chk_all_runs"></center></th>
<th rowspan="2">Project</th>
<th rowspan="2">All Run</th>
<th colspan="3"><center>Obsoletes Runs </center></th>
<th colspan="2"><center>Obsoletes Runs </center></th>
<th rowspan="2">All Analyze</th>
<th colspan="3"><center>Obsoletes Analyzes</center></th>
<th colspan="2"><center>Obsoletes Analyzes</center></th>
<th rowspan="2">Total Size Purgeable</th>
<th rowspan="2">Users</th>
</tr>
<tr>
<th>Nb Run purged</th>
<th>Nb Run stored</th>
<th>Nb Run extended</th>
<th>Nb Analyze purged</th>
<th>Nb Analyze stored</th>
<th>Nb Analyze extended</th>
</tr>
......@@ -379,11 +383,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<td><center><input type="checkbox" id="chk_project_{$c_project_id}" value="project_{$c_project_id}" /></center></td>
<td><a href="index.php?id=3&tx_nG6_pi1[project_id]={$c_project_id}">{$project_values.project_name}</a> </td>
<td>{$project_values.nb_runs}</td>
<td>{if $project_values.state.purged.nb_run}{$project_values.state.purged.nb_run} ({$tx_nG6_utils->get_octet_string_representation($project_values.state.purged.size_run)}){else} - {/if}</td>
<td><input type="hidden" values="{$project_values.state.stored.run_ids}" id="rstored_project_{$c_project_id}" />{if $project_values.state.stored.nb_run}{$project_values.state.stored.nb_run} ({$tx_nG6_utils->get_octet_string_representation($project_values.state.stored.size_run)} ){else} - {/if}</td>
<td><input type="hidden" values="{$project_values.state.extended.run_ids}" id="rextended_project_{$c_project_id}" />{if $project_values.state.extended.nb_run}{$project_values.state.extended.nb_run} ({$tx_nG6_utils->get_octet_string_representation($project_values.state.extended.size_run)}) {else} - {/if}</td>
<td>{$project_values.nb_analyses}</td>
<td>{if $project_values.state.purged.nb_analyze}{$project_values.state.purged.nb_analyze} ({$tx_nG6_utils->get_octet_string_representation($project_values.state.purged.size_analyze)}){else} - {/if}</td>
<td><input type="hidden" values="{$project_values.state.stored.analysis_ids}" id="astored_project_{$c_project_id}" />{if $project_values.state.stored.nb_analyze}{$project_values.state.stored.nb_analyze} ({$tx_nG6_utils->get_octet_string_representation($project_values.state.stored.size_analyze)}){else} - {/if}</td>
<td><input type="hidden" values="{$project_values.state.extended.analysis_ids}" id="aextended_project_{$c_project_id}" />{if $project_values.state.extended.nb_analyze}{$project_values.state.extended.nb_analyze} ({$tx_nG6_utils->get_octet_string_representation($project_values.state.extended.size_analyze)}){else} - {/if}</td>
<td>{$tx_nG6_utils->get_octet_string_representation($project_values.total_purgeable_size)}</td>
......@@ -396,27 +398,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{/foreach}
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td><input type="checkbox" id="chk_col_rstored" value="rstored" /></td>
<td><input type="checkbox" id="chk_col_rextended" value="rextended" /></td>
<td></td>
<td></td>
<td><input type="checkbox" id="chk_col_astored" value="astored" /></td>
<td><input type="checkbox" id="chk_col_aextended" value="aextended" /></td>
<td></td>
<td></td>
</tr>
<tr>
<th align="left" colspan="12">
<th align="left" colspan="10">
With selection :
<div class="btn-group">
<button id="mail_sent" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Mark as mail sent </button>
<button id="retention_change" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-refresh"></i> Change retention date </button>
<button id="purge_data_list" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-save"></i> Get purge data list </button>
<div class="btn-group">
<button id="send_mail" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail </button>
</div>
</th>
</tr>
......@@ -424,8 +410,85 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</table>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="purge_demand_management">
<div id="purge_demand_menu" class="clearfix">
<div>
<p>
Please enter the purge demand number to process (one number per line):
</p>
<textarea id="purge_demand_input" rows="4" cols="50"></textarea>
<br />
<button id="delete_data_from_text" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-remove"></i> Delete data</button>
<button id="extend_data_retention_from_text" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-pencil"></i> Extend retention date </button>
</div>
</div>
<div id="purge_demand_list">
<table class="table table-striped table-bordered dataTable" id="data_table_demand">
<thead>
<tr>
<th><center><input type="checkbox" id="chk_purge_demand"></center></th>
<th>Demand number</th>
<th>Project name</th>
<th>Purgeable size</th>
<th>Demand date</th>
<th>Users</th>
<th class="data-filter">Delay exceeded</th>
</tr>
</thead>
<tbody>
{foreach from=$ng6_purge_demands key=c_demand_id item=demand_values}
<tr id="tr_demand_{$c_demand_id}" >
<td><center><input type="checkbox" id="chk_demand_{$c_demand_id}" value="{$c_demand_id}" /></center></td>
<td>{$c_demand_id}</td>
<td><a href="index.php?id=3&tx_nG6_pi1[project_id]={$demand_values.project_id}">{$demand_values.project_name}</a> </td>
<td>{$tx_nG6_utils->get_octet_string_representation($demand_values.purge_size)}</td>
<td>{$demand_values.mail_sent_date|date_format:"%d/%m/%y"}</td>
<td>
{foreach from=$demand_values.users key=c_user_i item=user_values}
{$user_values.username}[{$user_values.user_group_title}],
{/foreach}
</td>
<td class="data-filter">{if $demand_values.delay_excedeed} Yes {else} No {/if}</td>
</tr>
{/foreach}
</tbody>
<tfoot>
<tr>
<th align="left" colspan="7">
With selection :
<div class="btn-group">
<button id="delete_data_from_list" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-remove"></i> Delete data</button>
<button id="extend_data_retention_from_list" type="button" class="btn btn-sm btn-default"><i class="glyphicon glyphicon-pencil"></i> Extend retention date </button>
</div>
</th>
</tr>
</tfoot>
</table>
</div>
</div> <!--purge demand management-->
</div>
</div>
</div>
{include file='../template/modals.tpl'}
......@@ -36,9 +36,8 @@ class tx_nG6_pi6 extends tslib_pibase {
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.
var $extKey = 'nG6'; // The extension key.
//var $pi_checkCHash = TRUE;
/**
* Main method of your PlugIn
*
......@@ -52,11 +51,12 @@ class tx_nG6_pi6 extends tslib_pibase {
$conf['pidList'] = $this->cObj->data['pages'];
$conf['recursive'] = $this->cObj->data['recursive'];
}
$this->pi_loadLL();
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_USER_INT_obj=1;
// Add the jquery libs + the tree plugins and its css
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.min.js"></script>
......@@ -91,14 +91,115 @@ class tx_nG6_pi6 extends tslib_pibase {
$smarty->assign('group_list', $group_list);
$smarty->assign('data_folder', $this->conf["data"]);
$smarty->assign('server_url', $this->conf['server_url']);
$distribution = tx_nG6_db::select_projects_repartition('create_user', 'title');
$smarty->assign('distribution', $distribution);
$smarty->assign('ng6_admin_users', tx_nG6_db::get_ng6_admin_users() );
$smarty->assign('ng6_purge_projects', tx_nG6_db::select_obsolete_list_retention_data_info( ));
$this->projects_obsolete=tx_nG6_db::select_obsolete_list_retention_data_info();
$smarty->assign('ng6_purge_projects',$this->projects_obsolete);
$this->ng6_purge_demands=tx_nG6_db::get_purge_demand_list($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['ng6']['delay_purge']);
$smarty->assign('ng6_purge_demands',$this->ng6_purge_demands);
$txNG6Utils = new tx_nG6_utils;
$smarty->assign_by_ref('tx_nG6_utils', $txNG6Utils);
return $smarty->fetch('administration_view.tpl');
}
function send_purge_demand_mail($user_id,$project_ids) {
$template_mail= 'Dear user,
The data storage time limit of ###nb_run### run(s) and ###nb_analyse### analyse(s) of ###PROJECT_NAME### project (###PROJET_ID###) is coming to end.
This purge alert number ###DEMAND_ID### corresponds to the files (size : ###STORAGE_SIZE###) linked to the following
* runs names: ###RUNS_LIST###
* analyses ids: ###ANALYSES_LIST###
In ###PURGE_DELAY### days, your data will be delete. Until then, you can save them by your own, or ask for extention period with number ###DEMAND_ID###.
###EMAILS###Keep us informed if you wish to extend the storage so that we do not delete the data by error, by answering to this email with following this informations :
Demand number : ###DEMAND_ID###
Extension term (min ###EXTENSION_DURATION###) :
Extension size (min ###EXTENSION_SIZE###) :
Price for ###EXTENSION_SIZE### during ###EXTENSION_DURATION### is about ###EXTENSION_PRICE###.
Yours sincerely
nG6 team';
$project_name="";
foreach(explode(",", $project_ids) as $id){
#retrieve project data
$p=tx_nG6_db::select_a_project_retention_data_info($id);
#build email list of managers
$managers_email=Array();
$managers_name=Array();
$admin_email = Array();
$admin_name = Array();
foreach ( $p[$id]["users"] as $u ){
if ( $u["right_level_label"] == "manager" ){
$managers_email[]=$u["email"];
$managers_name[]=$u["user_name"];
}elseif( $u["right_level_label"] == "administrator"){
$admin_email[] = $u["email"];
$admin_name[] = $u["user_name"];
}
}
#Warn if mail is sent to several manager
$email_warn="" ;
$purge_email_to="";
if ( count($managers_email) > 1 ) {