$context = context_module::instance($cm->id);
//} else {
// $context = context_module::instance($cm);
//}
require_capability('mod/referentiel:export', $context);
/// If it's hidden then it's don't show anything.  :)
/// Some capability checks.
if (empty($cm->visible) && (!has_capability('moodle/course:viewhiddenactivities', $context) && !has_capability('mod/referentiel:managecomments', $context))) {
    print_error(get_string("activityiscurrentlyhidden"), 'error', "{$CFG->wwwroot}/course/view.php?id={$course->id}");
}
// ensure the files area exists for this course
// Moodle 1.9
// make_upload_directory( "$course->id/$CFG->moddata/referentiel" );
if ($certificat_id) {
    // So do you have access?
    if (!(has_capability('mod/referentiel:writereferentiel', $context) or referentiel_certificat_isowner($certificat_id)) or !confirm_sesskey()) {
        print_error(get_string('noaccess', 'referentiel'));
    }
}
// MODIF JF mai 2011
if ($referentiel->ref_referentiel) {
    $existe_pedagos = referentiel_pedagogies_exists($referentiel->ref_referentiel);
} else {
    $existe_pedagos = 0;
}
// parametres d'impression
$param = referentiel_get_param_configuration($referentiel->id, 'config_impression');
// DEBUG
// echo "<br />DEBUG :: print_certificat.php :: 168 \n";
// print_r($param);
// exit;
function referentiel_print_un_certificat_detail($certificat_id, $referentiel_instance, $userid = 0, $select_acc = 0)
{
    global $DB;
    global $CFG;
    global $USER;
    // contexte
    $cm = get_coursemodule_from_instance('referentiel', $referentiel_instance->id);
    $course = $DB->get_record('course', array('id' => $cm->course));
    if (empty($cm) or empty($course)) {
        print_error('REFERENTIEL_ERROR 5 :: print_lib_certificat.php :: 1648 :: You cannot call this script in that way');
    }
    $context = context_module::instance($cm->id);
    $roles = referentiel_roles_in_instance($referentiel_instance->id);
    $iseditor = $roles->is_editor;
    $isadmin = $roles->is_admin;
    $isteacher = $roles->is_teacher;
    $istutor = $roles->is_tutor;
    $isstudent = $roles->is_student;
    $isguest = $roles->is_guest;
    if (!empty($referentiel_instance->ref_referentiel)) {
        $referentiel_referentiel = referentiel_get_referentiel_referentiel($referentiel_instance->ref_referentiel);
        if (!$referentiel_referentiel) {
            if ($isadmin || $isteacher) {
                print_error(get_string('creer_referentiel', 'referentiel'), "edit.php?d={$referentiel_instance->id}&amp;mode=editreferentiel&amp;sesskey=" . sesskey());
            } else {
                print_error(get_string('creer_referentiel', 'referentiel'), "../../course/view.php?id={$course->id}&amp;sesskey=" . sesskey());
            }
        }
        $isreferentielauteur = referentiel_is_author($USER->id, $referentiel_referentiel, !$isstudent);
        // MODIF JF 2012/02/18
        $seuil_certification = $referentiel_referentiel->seuil_certificat;
        $nb_items = referentiel_get_nb_items($referentiel_referentiel->id);
        // empreintes
        $liste_empreintes = referentiel_purge_dernier_separateur(referentiel_get_liste_empreintes_competence($referentiel_referentiel->id), '/');
        $liste_poids = referentiel_purge_dernier_separateur(referentiel_get_liste_poids($referentiel_referentiel->id), '|');
        if ($isadmin || $isreferentielauteur) {
            $protocole_link = "{$CFG->wwwroot}/mod/referentiel/edit_protocole.php?d={$referentiel_instance->id}&amp;mode=protocole&amp;sesskey=" . sesskey();
        } else {
            $protocole_link = "{$CFG->wwwroot}/mod/referentiel/protocole.php?d={$referentiel_instance->id}&amp;mode=protocole&amp;sesskey=" . sesskey();
        }
        // REGENERER LES CERTIFICATS
        // referentiel_regenere_certificats($referentiel_instance);
        // inutile
        $record = referentiel_get_certificat($certificat_id);
        if (!$record) {
            print_error(get_string('nocertificat', 'referentiel'), "activite.php?d=" . $referentiel_instance->id . "&amp;mode=addactivity&amp;sesskey=" . sesskey());
        }
        // Afficher
        $isauthor = referentiel_certificat_isowner($record->id);
        if ($isauthor || $isteacher || $isadmin) {
            referentiel_print_certificat_detail_une_page($record, $nb_items, $liste_empreintes, $liste_poids, $seuil_certification, $protocole_link);
            referentiel_menu_certificat_detail($context, $record->id, $referentiel_instance->id, $record->verrou && $isstudent, $userid, $select_acc, $record->valide);
        }
    }
}
Ejemplo n.º 3
0
    unset($form);
    unset($action);
    // exit;
}
/// selection d'utilisateurs
if (isset($action) && $action == 'selectuser' && !empty($form->userid) && confirm_sesskey()) {
    $userid_filtre = $form->userid;
    if (isset($form->select_acc)) {
        $select_acc = $form->select_acc;
    }
    unset($form);
    unset($action);
    // exit;
}
/// Delete any requested records
if (!empty($delete) && confirm_sesskey() && (has_capability('mod/referentiel:rate', $context) or referentiel_certificat_isowner($delete))) {
    if ($confirm = optional_param('confirm', 0, PARAM_INT)) {
        if (referentiel_delete_certificat_record($delete)) {
            if ($CFG->version > 2014051200) {
                // Moodle 2.7+
                $params = array('contextid' => $context->id, 'objectid' => $delete);
                $event = \mod_referentiel\event\certificat_deleted::create($params);
                $event->trigger();
            } else {
                // Before Moodle 2.7
                add_to_log($course->id, 'referentiel', 'certificate delete', "certificat.php?id={$cm->id}", $delete, $cm->id);
            }
        }
    }
    unset($form);
}