Adding reseting job + getting current job +perms fixing to action class possibilities

This commit is contained in:
Steven Mondji-Lerider 2013-04-23 16:08:56 +00:00
parent 58fb92df48
commit 85c97da157
2 changed files with 32 additions and 5 deletions

View File

@ -41,6 +41,12 @@ class m_action {
return $this->set('create_dir',$user, array('dir'=>$dir)); return $this->set('create_dir',$user, array('dir'=>$dir));
} }
/* /*
* function to set the cration of a file
*/
function fix_dir($dir,$user="root") {
return $this->set('fix_dir',$user, array('dir'=>$dir));
}
/*
* function to delete file / folder * function to delete file / folder
*/ */
function del($dir,$user="root") { function del($dir,$user="root") {
@ -80,19 +86,18 @@ class m_action {
$serialized=serialize($parameters); $serialized=serialize($parameters);
switch($type){ switch($type){
case 'create_file': case 'create_file':
//do some shit
$query="insert into actions values ('','CREATE_FILE','$serialized',now(),'','','$user','');"; $query="insert into actions values ('','CREATE_FILE','$serialized',now(),'','','$user','');";
break; break;
case 'create_dir': case 'create_dir':
//do more shit
$query="insert into actions values ('','CREATE_DIR','$serialized',now(),'','','$user','');"; $query="insert into actions values ('','CREATE_DIR','$serialized',now(),'','','$user','');";
break; break;
case 'move': case 'move':
//do more shit
$query="insert into actions values ('','MOVE','$serialized',now(),'','','$user','');"; $query="insert into actions values ('','MOVE','$serialized',now(),'','','$user','');";
break; break;
case 'fix_dir':
$query="insert into actions values ('','FIXDIR','$serialized',now(),'','','$user','');";
break;
case 'delete': case 'delete':
//do more shit
$query="insert into actions values ('','DELETE','$serialized',now(),'','','$user','');"; $query="insert into actions values ('','DELETE','$serialized',now(),'','','$user','');";
break; break;
default: default:
@ -147,6 +152,28 @@ class m_action {
} }
return true; return true;
} }
function reset_job($id) {
global $db,$err;
if(!$db->query("update actions set end=0,begin=0,status='' where id=$id ;")){
$err->raise("action",_("Error unlocking the action : $id"));
return false;
}
return true;
}
function get_job() {
global $db,$err;
$tab=array();
$db->query("Select id,type from actions where begin !=0 and end = 0 ;");
if ($db->next_record()){
$tab[]=$db->Record;
return $tab;
}else{
return false;
}
}
/* /*
* function locking an entry while it is being executed by the action script * function locking an entry while it is being executed by the action script
*/ */

View File

@ -731,7 +731,7 @@ CREATE TABLE IF NOT EXISTS `vm_history` (
CREATE TABLE IF NOT EXISTS `actions` ( CREATE TABLE IF NOT EXISTS `actions` (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT, id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
type enum ('CREATE_FILE','CREATE_DIR','DELETE','MOVE'), type enum ('CREATE_FILE','CREATE_DIR','DELETE','MOVE','FIXDIR'),
parameters longtext default NULL, parameters longtext default NULL,
creation timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, creation timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
begin timestamp, begin timestamp,