From ab74a22ca4648828146f727351d56fdcd161525d Mon Sep 17 00:00:00 2001 From: Steven Mondji-Lerider Date: Wed, 14 Aug 2013 13:17:16 +0000 Subject: [PATCH] Updating / debugging action class implementation --- bureau/class/m_action.php | 28 ++++++++++++++++++++++------ bureau/class/m_admin.php | 24 ++++-------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/bureau/class/m_action.php b/bureau/class/m_action.php index 0a2e3869..6b29fdd9 100644 --- a/bureau/class/m_action.php +++ b/bureau/class/m_action.php @@ -19,9 +19,15 @@ ---------------------------------------------------------------------- */ /** - * - * @copyright AlternC-Team 2002-2013 http://alternc.org/ - */ +* This class manage actions to be performed on the file system on behalf of alternc Classes +* 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 { /*---------------------------------------------------------------------------*/ /** Constructor @@ -85,9 +91,19 @@ class m_action { /* * 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; + + $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->next_record(); if (!$db->Record["login"]) { @@ -96,11 +112,11 @@ class m_action { } $uidlogin=$cuid."-".$db->Record["login"]; - $BACKUP_DIR="/tmp/backup/"; - //utiliser la function move après avoir construit le chemin + //The path will look like //YYYY-MM/-/ $today=getdate(); $dest=$BACKUP_DIR.'/'.$today["year"].'-'.$today["mon"].'/'.$uidlogin.'/'.$dir; $this->move($archive,$dest); + return true; } /* diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php index 00869e08..d93cedb0 100644 --- a/bureau/class/m_admin.php +++ b/bureau/class/m_admin.php @@ -62,6 +62,7 @@ class m_admin { 4 => _("Domain can be installed, no check at all"), 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() { @@ -682,27 +683,10 @@ EOF; // WE MUST call m_dom before all others because of conflicts ... $dom->hook_admin_del_member(); - // TODO: old hook method, FIXME: remove when unused - /* - 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'); + # New way of deleting or backup delted user html folders using action class $path=getuserpath($tt['login']); - if($archive == 1 ){ - #echo("archive"); - $action->archive($path,"html"); - }else{ - #echo("del"); - $action->del($path); - } + $action->archive($path); + $hooks->invoke("alternc_del_member"); $hooks->invoke("hook_admin_del_member");