33 lines
1.2 KiB
PHP
33 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
require_once __DIR__.'/auth_guard.php';
|
||
|
|
require_once __DIR__.'/audit.php';
|
||
|
|
require_once "../config.php";
|
||
|
|
|
||
|
|
$idobjetivo = isset($_POST['idobjetivo']) ? (int)$_POST['idobjetivo'] : 0;
|
||
|
|
$urlimginsignia = isset($_POST['urlimginsignia']) ? $_POST['urlimginsignia'] : '';
|
||
|
|
$tipo = (isset($_POST['tipo']) && $_POST['tipo'] == 'categoria') ? 'Categoría' : 'Recurso';
|
||
|
|
$nombre = isset($_POST['nombre']) ? $_POST['nombre'] : '';
|
||
|
|
$desc = isset($_POST['desc']) ? $_POST['desc'] : '';
|
||
|
|
$habilitado = isset($_POST['habilitado']) ? (int)$_POST['habilitado'] : 0;
|
||
|
|
|
||
|
|
global $link;
|
||
|
|
dbConnect();
|
||
|
|
|
||
|
|
$sql = "INSERT INTO insignias (idobjetivo,objetivo,nombre,descripcion,imagen,habilitado) VALUES (?,?,?,?,?,?)";
|
||
|
|
$stmt = mysqli_prepare($link, $sql);
|
||
|
|
if ($stmt) {
|
||
|
|
mysqli_stmt_bind_param($stmt, 'issssi', $idobjetivo, $tipo, $nombre, $desc, $urlimginsignia, $habilitado);
|
||
|
|
if (mysqli_stmt_execute($stmt)) {
|
||
|
|
audit_log('insignia_create', 'nombre=' . $nombre . ' objetivo=' . $idobjetivo . ' tipo=' . $tipo);
|
||
|
|
echo "Insignia creada";
|
||
|
|
} else {
|
||
|
|
http_response_code(500);
|
||
|
|
echo "Error al crear insignia";
|
||
|
|
}
|
||
|
|
mysqli_stmt_close($stmt);
|
||
|
|
} else {
|
||
|
|
http_response_code(500);
|
||
|
|
echo "Error al preparar la consulta";
|
||
|
|
}
|
||
|
|
?>
|