function referentiel_purge_archives($contextid, $delai_destruction = 0, $debug = false)
{
    // appelee par le cron
    global $CFG;
    $msg = '';
    if ($contextid) {
        // fileareas autorisees
        $filearea = 'archive';
        $fs = get_file_storage();
        if ($files = $fs->get_area_files($contextid, 'mod_referentiel', $filearea, 0, 'timemodified', false)) {
            foreach ($files as $file) {
                // print_object($file);
                $filesize = $file->get_filesize();
                $filename = $file->get_filename();
                $mimetype = $file->get_mimetype();
                $filepath = $file->get_filepath();
                $fullpath = '/' . $contextid . '/mod_referentiel/' . $filearea . '/' . '0' . $filepath . $filename;
                // echo "<br />FULPATH :: $fullpath \n";
                $timecreated = $file->get_timecreated();
                $timemodified = $file->get_timemodified();
                // echo "<br />$file_time :: $file_url was last modified: " . date ("F d Y H:i:s.", $file_time)."<br />\n";
                if (time() - $timemodified > $delai_destruction) {
                    referentiel_delete_a_file($fullpath);
                    if ($debug) {
                        mtrace($fullpath . "deleted \n");
                    }
                }
                if ($debug) {
                    mtrace(".");
                }
            }
        }
    }
    return $msg;
}
Exemple #2
0
$occurrence_object = new occurrence($params);
// RECUPERER LES FORMULAIRES
if (isset($SESSION->modform)) {
    // Variables are stored in the session
    $form = $SESSION->modform;
    unset($SESSION->modform);
} else {
    $form = (object) $_POST;
}
// Suppression des fichiers d'export
if (!empty($form->deletefile) && confirm_sesskey()) {
    foreach ($form->deletefile as $fullpathfile) {
        if ($fullpathfile) {
            // echo "<br />DEBUG :: archive.php :: 252<br />\n";
            // echo "<br />$fullpathfile\n";
            referentiel_delete_a_file($fullpathfile);
        }
    }
    unset($form);
}
$currenttab = 'export';
$pagetitle = get_string('occurrence', 'block_referentiel', $occurrence_object->referentiel->code_referentiel);
$PAGE->set_url('/blocks/referentiel/export.php', array('blockid' => $blockid, 'courseid' => $courseid, 'occurrenceid' => $occurrenceid, 'mode' => $mode));
$PAGE->requires->css('/mod/referentiel/referentiel.css');
// $PAGE->requires->js('/mod/referentiel/functions.js');
$PAGE->set_pagelayout('standard');
$PAGE->set_heading($course->fullname);
$PAGE->set_title($pagetitle);
$PAGE->navbar->add($occurrence_object->referentiel->code_referentiel);
//$settingsnode = $PAGE->settingsnav->add(get_string('displayoccurrence', 'block_referentiel'));
//$site = get_site();
Exemple #3
0
function referentiel_delete_consigne_record($id)
{
    // suppression consigne
    global $DB;
    $ok_consigne = false;
    if (!empty($id)) {
        if ($consigne = $DB->get_record("referentiel_consigne", array("id" => "{$id}"))) {
            if (!preg_match('/http/', $consigne->url_consigne)) {
                // Fichier à supprimer
                referentiel_delete_a_file($consigne->url_consigne);
            }
            $ok_consigne = $DB->delete_records("referentiel_consigne", array("id" => "{$id}"));
            if ($ok_consigne) {
                $task = $DB->get_record('referentiel_task', array('id' => $consigne->ref_task));
                if ($task) {
                    $ok = $DB->set_field('referentiel_task', 'date_modif', time(), array('id' => $task->id));
                }
            }
        }
    }
    return $ok_consigne;
}