39 global
$msg, $L_INOTIFY_DO_ACTION;
40 $msg->log(
"action",
"do_action");
41 if (!@touch($L_INOTIFY_DO_ACTION)) {
57 return $this->
set(
'create_file',
$user, array(
'file' => $file,
'content' =>
$content));
70 return $this->
set(
'chmod',
$user, array(
'filename' => $filename,
"perms" => $perms));
82 return $this->
set(
'create_dir',
$user, array(
'dir' => $dir));
93 return $this->
set(
'fix_user',
$user, array(
'uid' =>
$uid));
105 return $this->
set(
'fix_dir',
$user, array(
'dir' => $dir));
117 return $this->
set(
'fix_file',
$user, array(
'file' => $file));
129 return $this->
set(
'delete',
$user, array(
'dir' => $dir));
142 return $this->
set(
'move',
$user, array(
'src' => $src,
'dst' => $dst));
163 $this->
del($archive);
167 $db->query(
"select login from membres where uid= ?;", array(
$cuid));
169 if (!
$db->Record[
"login"]) {
170 $msg->raise(
"ERROR",
"action", _(
"Login corresponding to $cuid not found"));
173 $uidlogin =
$cuid .
"-" .
$db->Record[
"login"];
177 $dest = $BACKUP_DIR .
'/' . $today[
"year"] .
'-' . $today[
"mon"] .
'/' . $uidlogin .
'/' . $dir;
178 $this->
move($archive, $dest);
193 function set($type,
$user, $parameters) {
195 $msg->log(
"action",
"set", $type);
196 $serialized = serialize($parameters);
197 $type = strtoupper($type);
198 if (in_array($type, array(
'CHMOD',
206 $query =
"INSERT INTO `actions` (type, parameters, creation, user) VALUES('$type', '$serialized', now(), '$user');";
212 $msg->raise(
"ERROR",
"action", _(
"Error setting actions"));
229 $purge =
"select * from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
230 $result =
$db->query($purge);
232 $msg->raise(
"ERROR",
"action", _(
"Error selecting old actions"));
235 return $db->num_rows($result);
249 $purge =
"delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2 and status = 0;";
251 $purge =
"delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
253 $result =
$db->query($purge);
255 $msg->raise(
"ERROR",
"action", _(
"Error purging old actions"));
258 return $db->num_rows($result);
272 $db->query(
'select * from actions where end = 0 and begin = 0 order by id limit 1;');
273 if (
$db->next_record()) {
292 if (!
$db->query(
"update actions set begin=now() where id= ? ;", array(
$id))) {
293 $msg->raise(
"ERROR",
"action", _(
"Error locking the action : $id"));
311 if (!
$db->query(
"update actions set end=now(),status=? where id= ?;", array($return,
$id))) {
312 $msg->raise(
"ERROR",
"action", _(
"Error unlocking the action : $id"));
328 if (!
$db->query(
"update actions set end=0,begin=0,status='' where id= ?;", array(
$id))) {
329 $msg->raise(
"ERROR",
"action", _(
"Error unlocking the action : $id"));
346 $db->query(
"Select * from actions where begin !=0 and end = 0 ;");
347 if (
$db->next_record()) {
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
This class manage actions to be performed on the file system on behalf of alternc Classes It primary ...
move($src, $dst, $user="root")
function returning the first not locked line of the action table
del($dir, $user="root")
function to delete file / folder
create_dir($dir, $user="root")
Plans the creation of a dir.
get_old()
This seems to be unused ?
chmod($filename, $perms, $user="root")
Plans the a chmod on file or dir.
begin($id)
function locking an entry while it is being executed by the action script
do_action()
Tell the incron that an action should be performed.
cancel($id)
function locking an entry while it is being executed by the action script
create_file($file, $content="", $user="root")
Plans a file creation.
fix_user($uid, $user="root")
Plans a perms fix upon user creation.
archive($archive, $dir="html")
function archiving a directory ( upon account deletion )
fix_dir($dir, $user="root")
Plans a dir permission fix.
fix_file($file, $user="root")
Plans a file permission fix.
get_action()
function returning the first not locked line of the action table
get_job()
Returns a list of actions marked as executable and ready for execution.
finish($id, $return=0)
function locking an entry while it is being executed by the action script
if(!isset($is_include)) if(! $key &&! $crt) $id