function referentiel_is_author($userid, $referentiel_referentiel, $is_not_student = true)
{
    // return true if userid is refrentiel_referentiel author
    return $is_not_student == true && !empty($referentiel_referentiel->mail_auteur_referentiel) && $referentiel_referentiel->mail_auteur_referentiel == referentiel_get_user_mail($userid);
}
Example #2
0
        // Variables are stored in the session
        $form = $SESSION->modform;
        unset($SESSION->modform);
    } else {
        $form = (object) $_POST;
    }
    if (!$pass && $checkpass == 'checkpass' && !empty($form->pass_referentiel)) {
        $pass = referentiel_check_pass($referentiel_referentiel, $form->pass_referentiel);
        if (!$pass) {
            // Abandonner
            echo $OUTPUT->continue_button($CFG->wwwroot . '/mod/referentiel/view.php?id=' . $cm->id . '&non_redirection=1');
            exit;
        }
    } else {
        // saisie du mot de  passe
        if (isset($referentiel_referentiel->mail_auteur_referentiel) && $referentiel_referentiel->mail_auteur_referentiel != '' && referentiel_get_user_mail($USER->id) != $referentiel_referentiel->mail_auteur_referentiel) {
            //
            echo $OUTPUT->header();
            echo $OUTPUT->box_start('generalbox  boxaligncenter');
            // formulaires
            $appli_appelante = "import.php";
            include_once "pass_inc.php";
            echo $OUTPUT->box_end();
            echo $OUTPUT->footer();
            die;
        }
    }
}
// recuperer le fichier charge
if ($mform->is_cancelled()) {
    redirect(new moodle_url('/course/view.php', array('id' => $course->id)));
Example #3
0
function referentiel_select_delete($blockid, $course, $occurrence, $mode, $pass)
{
    global $USER;
    global $DB;
    global $CFG;
    $s = '';
    $email_user = referentiel_get_user_mail($USER->id);
    $interdire_creer_importer = referentiel_ref_get_item_config('creref', $occurrence->id);
    $old_pass_referentiel = $occurrence->pass_referentiel;
    /*
    // DEBUG
    echo "<br>DEBUG :: delete.php :: 196\n";
    print_object($occurrence);
        echo "<br>$email_user, \n";
    if ($interdire_creer_importer){
            echo "<br>NOT CREREF \n";
    } else{
            echo "<br>YES CREREF \n";
    }
    exit;
    */
    if (!empty($interdire_creer_importer)) {
        $viewurl = new moodle_url('/blocks/referentiel/view.php', array('blockid' => $blockid, 'course->id' => $course->id, 'occurrenceid' => $occurrence->id));
        notice(get_string('suppression_non_autorisee', 'referentiel'), $viewurl);
    } else {
        $records_instance_id = referentiel_referentiel_list_of_instance($occurrence->id);
        $nbinstances = 0;
        if ($records_instance_id) {
            $s .= '<h4 align="center">' . get_string("selection_instance_referentiel", "referentiel") . '</h4>' . "\n";
            $s .= '<div>
<form name="form" method="post" action="delete.php">
<table cellpadding="5" bgcolor="#eeeeee">
';
            foreach ($records_instance_id as $record_id) {
                $record_instance = referentiel_get_referentiel($record_id->id);
                if ($record_instance) {
                    $nbinstances++;
                    $record_course = $DB->get_record("course", array("id" => $record_instance->course));
                    $s .= '<tr valign="top">' . "\n";
                    if ($record_course->id == $course->id) {
                        $s .= '<td align="left"><input type="checkbox" name="t_ref_instance[]" value="' . $record_instance->id . '" checked="checked"  /></td>
<td align="left"><b>' . get_string('cours_courant', 'referentiel') . ' : </b></td>
<td align="left">' . $record_course->fullname . ' (' . $record_course->shortname . ')</td>' . "\n";
                    } else {
                        $s .= '<td align="left"><input type="checkbox" name="t_ref_instance[]" value="' . $record_instance->id . '"  /></td>
<td align="left"><b>' . get_string('cours_externe', 'referentiel') . ' : </b></td>
<td align="left"><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $record_course->id . '">' . $record_course->fullname . '</a> (' . $record_course->shortname . ')</td>' . "\n";
                    }
                    $s .= '<td align="left"><b>' . get_string('name_instance', 'referentiel') . ':</b></td>
<td align="left">' . $record_instance->name . '</td><td align="left"><b>' . get_string('description_instance', 'referentiel') . '</b> : </td>
<td align="left">' . strip_tags($record_instance->description_instance) . '</td></tr>' . "\n";
                }
            }
            $s .= '</table>
<br />
<!-- These hidden variables are always the same -->
<input type="hidden" name="action" value="supprimerinstances" />
<input type="hidden" name="sesskey"     value="' . sesskey() . '" />
<input type="hidden" name="mode" value="update" />
<input type="hidden" name="blockid" value="' . $blockid . '" />
<input type="hidden" name="courseid" value="' . $course->id . '" />
<input type="hidden" name="occurrenceid" value="' . $occurrence->id . '" />
<input type="hidden" name="pass" value="1" />
<input type="submit" name="delete" value="' . get_string("delete") . '" />
<input type="reset"  value="' . get_string("cancel") . '" />
<input type="submit" name="cancel" value="' . get_string("quit", "referentiel") . '" />
</form>
</div>
';
        } else {
            // proposer la suppression de l'occurrence
            $s .= '<div class="ref_aff0">' . "\n";
            $s .= '<form name="form" method="post" action="delete.php">
<p><b>' . get_string('name', 'referentiel') . '</b> : ' . stripslashes($occurrence->name) . '
<br /><b>' . get_string('code', 'referentiel') . '</b> : ' . $occurrence->code_referentiel . '
';
            if (!empty($occurrence->mail_auteur_referentiel)) {
                $s .= '<br /><b>' . get_string('auteur', 'referentiel') . ' </b> : <i>' . $occurrence->mail_auteur_referentiel . '</i>
';
            }
            if (!empty($occurrence->pass_referentiel)) {
                $s .= '<br /><b>' . get_string('pass_referentiel', 'referentiel') . ' </b> : <i>' . get_string('pass_set', 'block_referentiel') . '</i>
';
            }
            $s .= '<br /><b>' . get_string('description', 'referentiel') . '</b> : ' . strip_tags($occurrence->description_referentiel) . '
<br /><b>' . get_string('url', 'referentiel') . '</b> : ' . $occurrence->url_referentiel . '
<br /><b>' . get_string('logo', 'referentiel') . '</b> : ' . $occurrence->logo_referentiel;
            // $s.='<br /><b>'.get_string('seuil_certificat','referentiel').'</b> : '.$occurrence->seuil_certificat;
            $s .= '<br /><b>' . get_string('referentiel_global', 'referentiel') . '</b> : ' . "\n";
            if (!empty($occurrence->local)) {
                $s .= get_string("no") . "\n";
            } else {
                $s .= get_string("yes") . "\n";
            }
            /*
                        $s.='<br /><b>'.get_string('nombre_domaines_supplementaires','referentiel').'</b> :
                '.$occurrence->nb_domaines;
            */
            $s .= '
</p><p>
<input type="hidden" name="action" value="modifierreferentiel" />
<input type="hidden" name="referentiel_id"      value="' . $occurrence->id . '" />
<!-- These hidden variables are always the same -->
<input type="hidden" name="mail_auteur_referentiel" value="' . $occurrence->mail_auteur_referentiel . '" />
<input type="hidden" name="old_pass_referentiel" value="' . $old_pass_referentiel . '" />
<input type="hidden" name="cle_referentiel" value="' . $occurrence->cle_referentiel . '" />
<input type="hidden" name="liste_codes_competence" value="' . $occurrence->liste_codes_competence . '" />
<input type="hidden" name="liste_empreintes_competence" value="' . $occurrence->liste_empreintes_competence . '" />
<input type="hidden" name="sesskey"     value="' . sesskey() . '" />
<input type="hidden" name="blockid" value="' . $blockid . '" />
<input type="hidden" name="courseid" value="' . $course->id . '" />
<input type="hidden" name="occurrenceid" value="' . $occurrence->id . '" />
<input type="hidden" name="pass" value="1" />
<input type="submit" name="delete" value="' . get_string("delete") . '" />
<input type="submit" name="cancel" value="' . get_string("quit", "referentiel") . '" />
</p>
</form>
</div>
';
        }
    }
    return $s;
}
/**
 * Given an object containing all the necessary referentiel,
 * (defined by the form) this function
 * will create a new instance and return the id number
 * of the new instance.
 *
 * @param object $form An object
 * @return int The id of the newly inserted referentiel_referentiel record
 **/
function referentiel_add_referentiel($form)
{
    global $USER;
    global $CFG;
    global $DB;
    // Creer un referentiel_referentiel sans domaine ni competence ni item
    // Added for debugging
    // echo "<br />DEBUG : ADD REFERENTIEL CALLED :: lib.php Ligne 633";
    // DEBUG
    // print_object($form);
    // echo "<br />";
    // referentiel
    $referentiel_referentiel = new object();
    $referentiel_referentiel->name = $form->name;
    $referentiel_referentiel->code_referentiel = $form->code_referentiel;
    $referentiel_referentiel->description_referentiel = $form->description_referentiel;
    $referentiel_referentiel->url_referentiel = $form->url_referentiel;
    $referentiel_referentiel->seuil_certificat = $form->seuil_certificat;
    $referentiel_referentiel->nb_domaines = $form->nb_domaines;
    $referentiel_referentiel->liste_codes_competence = $form->liste_codes_competence;
    $referentiel_referentiel->timemodified = time();
    $referentiel_referentiel->liste_empreintes_competence = $form->liste_empreintes_competence;
    // Modif JF 2012/06/02
    if (isset($form->label_domaine)) {
        $referentiel_referentiel->label_domaine = $form->label_domaine;
    } else {
        $referentiel_referentiel->label_domaine = '';
    }
    if (isset($form->label_competence)) {
        $referentiel_referentiel->label_competence = $form->label_competence;
    } else {
        $referentiel_referentiel->label_competence = '';
    }
    if (isset($form->label_item)) {
        $referentiel_referentiel->label_item = $form->label_item;
    } else {
        $referentiel_referentiel->label_item = '';
    }
    // Modif JF 2009/10/16
    if (isset($form->liste_poids_competence)) {
        $referentiel_referentiel->liste_poids_competence = $form->liste_poids_competence;
    } else {
        $referentiel_referentiel->liste_poids_competence = '';
    }
    $referentiel_referentiel->logo_referentiel = $form->logo_referentiel;
    // local ou global
    if (isset($form->local) && $form->local != 0 && isset($form->course) && $form->course != 0) {
        $referentiel_referentiel->local = $form->course;
    } else {
        $referentiel_referentiel->local = 0;
    }
    // traitements speciaux
    if (!isset($form->mail_auteur_referentiel)) {
        $form->mail_auteur_referentiel = '';
    }
    if (!isset($form->old_pass_referentiel)) {
        $form->old_pass_referentiel = '';
    }
    if (!isset($form->pass_referentiel)) {
        $form->pass_referentiel = '';
    }
    if ($form->mail_auteur_referentiel == '') {
        if (isset($USER->id) && $USER->id > 0) {
            // mail auteur
            $referentiel_referentiel->mail_auteur_referentiel = referentiel_get_user_mail($USER->id);
        } else {
            $referentiel_referentiel->mail_auteur_referentiel = '';
        }
    }
    if ($form->pass_referentiel != '') {
        // MD5
        $referentiel_referentiel->pass_referentiel = md5($form->pass_referentiel);
    } else {
        $referentiel_referentiel->pass_referentiel = $form->old_pass_referentiel;
        // archive md5()
    }
    // DEBUG
    // echo "<br />DEBUG :: lib.php Ligne 658";
    // print_object($referentiel_referentiel);
    // echo "<br />";
    if ($new_referentiel_id = $DB->insert_record("referentiel_referentiel", $referentiel_referentiel)) {
        // echo "REFERENTIEL ID / $referentiel_referentiel_id<br />";
        // MODIF JF 2012/03/04
        referentiel_recalcule_cle_referentiel($new_referentiel_id);
    }
    return $new_referentiel_id;
}
Example #5
0
<?php

// $Id: edit.html,v 1.0 2008/04/29 00:00:00 jfruitet Exp $
/**
 * This page defines the form to create or edit an occurrence of this module
 * It is used from /course/mod.php.  The whole instance is available as $form.
 *
 * @author jfruitet
 * @version $Id: mod.html,v 1.0 2013/04/29 00:00:00 jfruitet Exp $
 * @package referentiel
 **/
$email_user = referentiel_get_user_mail($USER->id);
// DEBUG
// echo "<br />EMAIL_USER : $email_user<br />\n";
/// First we check that form variables have been initialised
// instance
if (isset($referentiel) && $referentiel) {
    // referentiel referentiel
    if (isset($referentiel->ref_referentiel) && $referentiel->ref_referentiel > 0) {
        $referentiel_referentiel = $DB->get_record('referentiel_referentiel', array('id' => $referentiel->ref_referentiel));
    }
    if (!isset($form->occurrence)) {
        $form->occurrence = $referentiel->ref_referentiel;
    } else {
        $form->occurrence = '';
    }
} else {
    if (!isset($form->occurrence)) {
        $form->occurrence = '';
    }
}