Example #1
0
/**
 * Given an object containing all the necessary referentiel, 
 * (defined by the form in mod.html) this function 
 * will create a new instance and return the id number 
 * of the new instance.
 *
 * @param object $instance An object from the form in eturdiant.html
 * @return int The id of the newly inserted referentiel record
 **/
function referentiel_update_etudiant($form)
{
    // MAJ etudiant
    global $DB;
    $ok = true;
    // DEBUG
    // echo "DEBUG : UPDATE ETUDIANT CALLED";
    // print_object($form);
    // echo "<br />";
    // certificat
    if (isset($form->action) && $form->action == "modifier_etudiant") {
        $record = new object();
        $record->id = $form->etudiant_id;
        $record->num_etudiant = $form->num_etudiant;
        $record->ddn_etudiant = $form->ddn_etudiant;
        $record->lieu_naissance = $form->lieu_naissance;
        $record->departement_naissance = $form->departement_naissance;
        $record->adresse_etudiant = $form->adresse_etudiant;
        $record->ref_etablissement = $form->ref_etablissement;
        $record->userid = $form->userid;
        // controle
        if ($record->userid > 0 && ($record->num_etudiant == '' || $record->num_etudiant == 'l_inconnu')) {
            $record->num_etudiant = referentiel_get_student_number($record->userid);
        }
        if (!$DB->update_record("referentiel_etudiant", $record)) {
            // echo "<br /> ERREUR UPDATE ETUDIANT\n";
            $ok = false;
        } else {
            // echo "<br /> UPDATE ETUDIANT $record->id\n";
            $ok = true;
        }
        return $ok;
    }
}
/**
 * This page defines the form to create or edit an instance of this module
 * It is used from /mod/referentiel/etudiant.php.  The whole instance is available as $form.
 *
 * @author jf
 * @version $Id: etudiant_inc.php,v 1. 2013/05/04 09:012:00 jf Exp $
 * @package referentiel
 **/
if (isset($mode) && $mode == "addetudiant") {
    // ajouter un etudiant
    if (!isset($form->userid)) {
        $form->userid = $USER->id;
    }
    if (!isset($form->num_etudiant)) {
        $form->num_etudiant = referentiel_get_student_number($form->userid);
    }
    if (!isset($form->ddn_etudiant)) {
        $form->ddn_etudiant = "";
    }
    if (!isset($form->lieu_naissance)) {
        $form->lieu_naissance = "";
    }
    if (!isset($form->departement_naissance)) {
        $form->departement_naissance = "";
    }
    if (!isset($form->adresse_etudiant)) {
        $form->adresse_etudiant = "";
    }
    if (!isset($form->ref_etablissement)) {
        $form->ref_etablissement = 0;