Updating / debugging action class implementation
This commit is contained in:
parent
1ca1a6a248
commit
ab74a22ca4
|
@ -19,9 +19,15 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
*
|
* This class manage actions to be performed on the file system on behalf of alternc Classes
|
||||||
* @copyright AlternC-Team 2002-2013 http://alternc.org/
|
* It primary use is to store the actions to be performed ( creating file or folder, deleting, setting permissions etc..) in the action sql table.
|
||||||
*/
|
* The script /usr/lib/alternc/do_actions.php handled by cron and incron is then used to perform those actions.
|
||||||
|
*
|
||||||
|
* Copyleft {@link http://alternc.org/ AlternC Team}
|
||||||
|
*
|
||||||
|
* @copyright AlternC-Team 2013-8-13 http://alternc.org/
|
||||||
|
*
|
||||||
|
*/
|
||||||
class m_action {
|
class m_action {
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** Constructor
|
/** Constructor
|
||||||
|
@ -85,9 +91,19 @@ class m_action {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function archiving a directory ( upon account deletion )
|
* function archiving a directory ( upon account deletion )
|
||||||
|
* @param: $archive : directory to archive within the archive_del_data global variable folder if set.
|
||||||
|
* If archive_del_data is not set we delete the folder.
|
||||||
|
* @param: $dir : sub_directory of the archive directory
|
||||||
*/
|
*/
|
||||||
function archive($archive,$dir) {
|
function archive($archivei,$dir="html") {
|
||||||
global $cuid,$db,$err;
|
global $cuid,$db,$err;
|
||||||
|
|
||||||
|
$arch=variable_get('archive_del_data');
|
||||||
|
if(empty($arch)) {
|
||||||
|
$this->del($archive);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$BACKUP_DIR=$arch;
|
||||||
$db->query("select login from membres where uid=$cuid;");
|
$db->query("select login from membres where uid=$cuid;");
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
if (!$db->Record["login"]) {
|
if (!$db->Record["login"]) {
|
||||||
|
@ -96,11 +112,11 @@ class m_action {
|
||||||
}
|
}
|
||||||
$uidlogin=$cuid."-".$db->Record["login"];
|
$uidlogin=$cuid."-".$db->Record["login"];
|
||||||
|
|
||||||
$BACKUP_DIR="/tmp/backup/";
|
//The path will look like /<archive_del_data>/YYYY-MM/<uid>-<login>/<folder>
|
||||||
//utiliser la function move après avoir construit le chemin
|
|
||||||
$today=getdate();
|
$today=getdate();
|
||||||
$dest=$BACKUP_DIR.'/'.$today["year"].'-'.$today["mon"].'/'.$uidlogin.'/'.$dir;
|
$dest=$BACKUP_DIR.'/'.$today["year"].'-'.$today["mon"].'/'.$uidlogin.'/'.$dir;
|
||||||
$this->move($archive,$dest);
|
$this->move($archive,$dest);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -62,6 +62,7 @@ class m_admin {
|
||||||
4 => _("Domain can be installed, no check at all"),
|
4 => _("Domain can be installed, no check at all"),
|
||||||
5 => _("Domain can be installed, force NO DNS hosting"),
|
5 => _("Domain can be installed, force NO DNS hosting"),
|
||||||
);
|
);
|
||||||
|
$archive=variable_get('archive_del_data','','If folder specified html folder of deleted user is archived, else it is deleted. ');
|
||||||
}
|
}
|
||||||
|
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
|
@ -682,27 +683,10 @@ EOF;
|
||||||
// WE MUST call m_dom before all others because of conflicts ...
|
// WE MUST call m_dom before all others because of conflicts ...
|
||||||
$dom->hook_admin_del_member();
|
$dom->hook_admin_del_member();
|
||||||
|
|
||||||
// TODO: old hook method, FIXME: remove when unused
|
# New way of deleting or backup delted user html folders using action class
|
||||||
/*
|
|
||||||
foreach($classes as $c) {
|
|
||||||
if (method_exists($GLOBALS[$c],"alternc_del_member")) {
|
|
||||||
$GLOBALS[$c]->alternc_del_member();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* New way of deleting or backup delted user html folders using action class
|
|
||||||
*/
|
|
||||||
$archive=variable_get('archive_del_data');
|
|
||||||
$path=getuserpath($tt['login']);
|
$path=getuserpath($tt['login']);
|
||||||
if($archive == 1 ){
|
$action->archive($path);
|
||||||
#echo("archive");
|
|
||||||
$action->archive($path,"html");
|
|
||||||
}else{
|
|
||||||
#echo("del");
|
|
||||||
$action->del($path);
|
|
||||||
}
|
|
||||||
$hooks->invoke("alternc_del_member");
|
$hooks->invoke("alternc_del_member");
|
||||||
$hooks->invoke("hook_admin_del_member");
|
$hooks->invoke("hook_admin_del_member");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue