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; }
$event->trigger(); } else { // Before Moodle 2.7 add_to_log($course->id, 'referentiel', 'delete occurrence', "delete.php?id=" . $cm->id, $msg, $cm->module); } redirect($returnlink_course); } else { redirect($returnlink_course, "Could not delete #{$form->referentiel_id} occurrence..."); } exit; } } } elseif ($form->action == "modifierreferentiel") { // enregistre les modifications if (isset($form->referentiel_id) && $form->referentiel_id > 0) { $records_instance = referentiel_referentiel_list_of_instance($form->referentiel_id); if ($records_instance) { $msg = ''; foreach ($records_instance as $r_instance) { $record_instance = referentiel_get_referentiel($r_instance->id); $record_course = $DB->get_record('course', array('id' => $record_instance->course)); $msg .= "<br />" . get_string('instance', 'referentiel') . " {$record_instance->name} (#{$record_instance->id}) " . get_string('course') . " {$record_course->fullname} ({$record_course->shortname}) " . get_string('not_deleted', 'referentiel') . "\n"; } $msg .= get_string("suppression_referentiel_impossible", "referentiel") . " " . $form->referentiel_id; redirect($returnlink_course, $msg); } else { // suppression du referentiel_referentiel $return = referentiel_delete_referentiel_domaines($form->referentiel_id); if (isset($return) && !empty($return) && !is_string($return)) { referentiel_delete_referentiel_certificats($form->referentiel_id); // Mise a jour de la reference du referentiel dans l'instance de certification