refactor code, and correct return true, which may be false because of do_action()

This commit is contained in:
root 2014-06-30 17:08:37 +02:00
parent 7ef2d8bd0d
commit 64fa8a2795
1 changed files with 14 additions and 27 deletions

View File

@ -185,37 +185,24 @@ class m_action {
$err->log("action", "set", $type); $err->log("action", "set", $type);
$serialized = serialize($parameters); $serialized = serialize($parameters);
switch ($type) { $type = strtoupper($type);
case 'create_file': if (in_array($type, array('CREATE_FILE',
$query = "insert into actions values ('','CREATE_FILE','$serialized',now(),'','','$user','');"; 'CREATE_DIR',
break; 'MOVE',
case 'create_dir': 'FIX_USER',
$query = "insert into actions values ('','CREATE_DIR','$serialized',now(),'','','$user','');"; 'FIX_FILE',
break; 'FIX_DIR',
case 'move': 'DELETE'))) {
$query = "insert into actions values ('','MOVE','$serialized',now(),'','','$user','');"; $query = 'INSERT INTO `actions` (type, parameters, creation, user) VALUES(?, ?, now())';
break; } else {
case 'fix_user': return false;
$query = "insert into actions values ('','FIX_USER','$serialized',now(),'','','$user','');";
break;
case 'fix_file':
$query = "insert into actions values ('','FIX_FILE','$serialized',now(),'','','$user','');";
break;
case 'fix_dir':
$query = "insert into actions values ('','FIX_DIR','$serialized',now(),'','','$user','');";
break;
case 'delete':
$query = "insert into actions values ('','DELETE','$serialized',now(),'','','$user','');";
break;
default:
return false;
} }
if (!$db->query($query)) {
if (!$db->query($query, array($type, $serialized))) {
$err->raise("action", _("Error setting actions")); $err->raise("action", _("Error setting actions"));
return false; return false;
} }
$this->do_action(); return $this->do_action();
return true;
} }
/** /**