From 60ec88174e16ea70f97993aabeb353a1af588144 Mon Sep 17 00:00:00 2001 From: Steven Mondji-Lerider Date: Tue, 14 May 2013 08:24:17 +0000 Subject: [PATCH] Implementing fixfile for action class --- bureau/class/m_action.php | 11 +++++++++++ bureau/class/m_admin.php | 23 +++++++++++++++++++---- bureau/class/m_bro.php | 2 +- install/mysql.sql | 2 +- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/bureau/class/m_action.php b/bureau/class/m_action.php index ed35ae70..cb0ae933 100644 --- a/bureau/class/m_action.php +++ b/bureau/class/m_action.php @@ -56,6 +56,13 @@ class m_action { return $this->set('fix_dir',$user, array('dir'=>$dir)); } + /* + * function to set the cration of a file + */ + function fix_file($file,$user="root") { + return $this->set('fix_file',$user, array('file'=>$file)); + } + /* * function to delete file / folder */ @@ -95,6 +102,7 @@ class m_action { */ function set($type,$user,$parameters) { global $db,$err; + $err->log("action","set",$type); $serialized=serialize($parameters); switch($type){ @@ -107,6 +115,9 @@ class m_action { case 'move': $query="insert into actions values ('','MOVE','$serialized',now(),'','','$user','');"; break; + case 'fix_file': + $query="insert into actions values ('','FIXFILE','$serialized',now(),'','','$user','');"; + break; case 'fix_dir': $query="insert into actions values ('','FIXDIR','$serialized',now(),'','','$user','');"; break; diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php index 6a89eac5..f3a40e45 100644 --- a/bureau/class/m_admin.php +++ b/bureau/class/m_admin.php @@ -418,7 +418,7 @@ class m_admin { * @return boolean Returns FALSE if an error occurs, TRUE if not. */ function add_mem($login, $pass, $nom, $prenom, $mail, $canpass=1, $type='default', $duration=0, $notes = "", $force=0, $create_dom=false, $db_server_id) { - global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks; + global $err,$quota,$classes,$cuid,$mem,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$hooks,$action; $err->log("admin","add_mem",$login."/".$mail); if (!$this->enabled) { $err->raise("admin",_("-- Only administrators can access this page! --")); @@ -475,7 +475,10 @@ class m_admin { $db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');"); $db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');"); $this->renew_update($uid, $duration); - exec("sudo /usr/lib/alternc/mem_add ".$login." ".$uid); + #exec("sudo /usr/lib/alternc/mem_add ".$login." ".$uid); + $action->create_dir(getuserpath("$login")); + $action->fix_dir(getuserpath("$login")); + // Triggering hooks $mem->su($uid); // TODO: old hook method FIXME: when unused remove this @@ -663,7 +666,7 @@ EOF; * @return boolean Returns FALSE if an error occurs, TRUE if not. */ function del_mem($uid) { - global $err,$quota,$classes,$cuid,$mem,$dom,$hooks; + global $err,$quota,$classes,$cuid,$mem,$dom,$hooks,$action; $err->log("admin","del_mem",$uid); if (!$this->enabled) { @@ -687,12 +690,24 @@ EOF; } } */ + + /* + * New way of deleting or backup delted user html folders using action class + */ + $archive=variable_get('archive_del_data'); + $path=getuserpath($tt['login']); + if($archive == 1 ){ + echo("archive"); + $action->archive($path,"html"); + }else{ + echo("del"); + $action->del($path); + } $hooks->invoke("alternc_del_member"); $hooks->invoke("hook_admin_del_member"); if (($db->query("DELETE FROM membres WHERE uid='$uid';")) && ($db->query("DELETE FROM local WHERE uid='$uid';"))) { - exec("sudo /usr/lib/alternc/mem_del ".$tt["login"]); $mem->unsu(); // If this user was (one day) an administrator one, he may have a list of his own accounts. Let's associate those accounts to nobody as a creator. $db->query("UPDATE membres SET creator=2000 WHERE creator='$uid';"); diff --git a/bureau/class/m_bro.php b/bureau/class/m_bro.php index 3a2bc7e9..2a6cd35e 100644 --- a/bureau/class/m_bro.php +++ b/bureau/class/m_bro.php @@ -552,7 +552,7 @@ class m_bro { @touch($absolute."/".$_FILES['userfile']['name']); } if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name'])) { - $action->fix_dir($absolute."/".$_FILES['userfile']['name']); + $action->fix_file($absolute."/".$_FILES['userfile']['name']); return $absolute."/".$_FILES['userfile']['name']; } else { $err->raise("bro",_("Cannot create the requested file. Please check the permissions")); diff --git a/install/mysql.sql b/install/mysql.sql index 2e2813b9..042f3ed2 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -731,7 +731,7 @@ CREATE TABLE IF NOT EXISTS `vm_history` ( CREATE TABLE IF NOT EXISTS `actions` ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, - type enum ('CREATE_FILE','CREATE_DIR','DELETE','MOVE','FIXDIR'), + type enum ('CREATE_FILE','CREATE_DIR','DELETE','MOVE','FIXDIR','FIXFILE'), parameters longtext default NULL, creation timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, begin timestamp,