50 global
$err, $L_INOTIFY_DO_ACTION;
51 $err->log(
"action",
"do_action");
52 if( ! touch($L_INOTIFY_DO_ACTION) ){
67 return $this->
set(
'create_file',
$user, array(
'file' => $file,
'content' =>
$content));
78 return $this->
set(
'create_dir',
$user, array(
'dir' => $dir));
88 return $this->
set(
'fix_user',
$user, array(
'uid' =>
$uid));
99 return $this->
set(
'fix_dir',
$user, array(
'dir' => $dir));
110 return $this->
set(
'fix_file',
$user, array(
'file' => $file));
121 return $this->
set(
'delete',
$user, array(
'dir' => $dir));
133 return $this->
set(
'move',
$user, array(
'src' => $src,
'dst' => $dst));
153 $this->
del($archive);
157 $db->query(
"select login from membres where uid=$cuid;");
159 if (!$db->Record[
"login"]) {
160 $err->raise(
"action", _(
"Login corresponding to $cuid not found"));
163 $uidlogin = $cuid .
"-" . $db->Record[
"login"];
167 $dest = $BACKUP_DIR .
'/' . $today[
"year"] .
'-' . $today[
"mon"] .
'/' . $uidlogin .
'/' . $dir;
168 $this->
move($archive, $dest);
184 $err->log(
"action",
"set", $type);
189 $query =
"insert into actions values ('','CREATE_FILE','$serialized',now(),'','','$user','');";
192 $query =
"insert into actions values ('','CREATE_DIR','$serialized',now(),'','','$user','');";
195 $query =
"insert into actions values ('','MOVE','$serialized',now(),'','','$user','');";
198 $query =
"insert into actions values ('','FIX_USER','$serialized',now(),'','','$user','');";
201 $query =
"insert into actions values ('','FIX_FILE','$serialized',now(),'','','$user','');";
204 $query =
"insert into actions values ('','FIX_DIR','$serialized',now(),'','','$user','');";
207 $query =
"insert into actions values ('','DELETE','$serialized',now(),'','','$user','');";
212 if (!$db->query(
$query)) {
213 $err->raise(
"action", _(
"Error setting actions"));
231 $purge =
"select * from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
232 $result = $db->query($purge);
234 $err->raise(
"action", _(
"Error selecting old actions"));
237 return $db->num_rows($result) ;
250 $purge =
"delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2 and status = 0;";
252 $purge =
"delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
254 $result = $db->query($purge);
256 $err->raise(
"action", _(
"Error purging old actions"));
259 return $db->num_rows($result) ;
274 $db->query(
'select * from actions where end = 0 and begin = 0 order by id limit 1;');
275 if ($db->next_record()) {
276 $tab[] = $db->Record;
293 if (!$db->query(
"update actions set begin=now() where id=$id ;")) {
294 $err->raise(
"action", _(
"Error locking the action : $id"));
311 if (!$db->query(
"update actions set end=now(),status='$return' where id=$id ;")) {
312 $err->raise(
"action", _(
"Error unlocking the action : $id"));
327 if (!$db->query(
"update actions set end=0,begin=0,status='' where id=$id ;")) {
328 $err->raise(
"action", _(
"Error unlocking the action : $id"));
344 $db->query(
"Select * from actions where begin !=0 and end = 0 ;");
345 if ($db->next_record()) {
346 $tab[] = $db->Record;