|
|
|
|
@ -10,44 +10,42 @@ $cidReset = true; |
|
|
|
|
|
|
|
|
|
require_once __DIR__.'/../../../main/inc/global.inc.php'; |
|
|
|
|
|
|
|
|
|
if (api_is_anonymous()) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
api_block_anonymous_users(); |
|
|
|
|
|
|
|
|
|
$plugin = CustomCertificatePlugin::create(); |
|
|
|
|
$enable = $plugin->get('enable_plugin_customcertificate') == 'true'; |
|
|
|
|
$action = isset($_GET['a']) ? $_GET['a'] : null; |
|
|
|
|
|
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
if ($enable === false) { |
|
|
|
|
api_not_allowed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$action = isset($_GET['a']) ? $_GET['a'] : null; |
|
|
|
|
|
|
|
|
|
switch ($action) { |
|
|
|
|
case 'delete_certificate': |
|
|
|
|
if (api_is_anonymous()) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$table = Database::get_main_table(CustomCertificatePlugin::TABLE_CUSTOMCERTIFICATE); |
|
|
|
|
$courseId = isset($_POST['courseId']) ? (int) $_POST['courseId'] : 0; |
|
|
|
|
$sessionId = isset($_POST['sessionId']) ? (int) $_POST['sessionId'] : 0; |
|
|
|
|
$accessUrlId = isset($_POST['accessUrlId']) ? (int) $_POST['accessUrlId'] : 1; |
|
|
|
|
|
|
|
|
|
if (!empty($courseId)) { |
|
|
|
|
$sql = "DELETE FROM $table |
|
|
|
|
WHERE c_id=$courseId AND session_id=$sessionId AND access_url_id=$accessUrlId"; |
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
echo Display::addFlash( |
|
|
|
|
Display::return_message( |
|
|
|
|
get_plugin_lang("SuccessDelete", "CustomCertificatePlugin"), |
|
|
|
|
'success' |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
WHERE |
|
|
|
|
c_id = $courseId AND |
|
|
|
|
session_id = $sessionId AND |
|
|
|
|
access_url_id = $accessUrlId"; |
|
|
|
|
Database::query($sql); |
|
|
|
|
echo Display::return_message( |
|
|
|
|
get_plugin_lang('SuccessDelete', 'CustomCertificatePlugin'), |
|
|
|
|
'success' |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
echo Display::addFlash( |
|
|
|
|
Display::return_message( |
|
|
|
|
get_plugin_lang("ProblemDelete", "CustomCertificatePlugin"), |
|
|
|
|
'error', |
|
|
|
|
false |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
echo Display::return_message( |
|
|
|
|
get_plugin_lang('ProblemDelete', 'CustomCertificatePlugin'), |
|
|
|
|
'error', |
|
|
|
|
false |
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|