diff --git a/public_html/aulatek/_filefetch.php b/public_html/aulatek/_filefetch.php index b73b20e..d4ada45 100755 --- a/public_html/aulatek/_filefetch.php +++ b/public_html/aulatek/_filefetch.php @@ -23,6 +23,15 @@ switch ($type) { } $relpath = "entreaulas/$orgs_base_dir/$centro/Aularios/$aulario/Alumnos/$alumno/photo.jpg"; break; + case "aulario_photo": + $centro = safe_organization_id($_GET["organization"] ?? $_GET["organizacion"] ?? $_GET["org"] ?? $_GET["centro"] ?? ''); + $aulario = safe_id_segment($_GET["aulario"] ?? ''); + if (empty($centro) || empty($aulario)) { + header("HTTP/1.1 400 Bad Request"); + die("Invalid parameters"); + } + $relpath = "entreaulas/$orgs_base_dir/$centro/Aularios/$aulario/photo.jpg"; + break; case "panel_actividades": $centro = safe_organization_id($_GET["organization"] ?? $_GET["organizacion"] ?? $_GET["org"] ?? $_GET["centro"] ?? ''); $activity = safe_id_segment($_GET["activity"] ?? ''); diff --git a/public_html/sysadmin/aularios.php b/public_html/sysadmin/aularios.php index 76616b3..922badc 100644 --- a/public_html/sysadmin/aularios.php +++ b/public_html/sysadmin/aularios.php @@ -81,6 +81,9 @@ switch ($form_action) { exit(); break; case "save_edit": + ini_set('memory_limit', '512M'); + ini_set('upload_max_filesize', '256M'); + ini_set('post_max_size', '256M'); $aulario_id = safe_path_segment(Sf($_POST["aulario_id"] ?? "")); $centro_id = safe_path_segment(Sf($_POST["centro_id"] ?? "")); if ($aulario_id === "" || $centro_id === "") { @@ -103,11 +106,26 @@ switch ($form_action) { if (isset($_POST['shared_comedor_from'])) { $extra['shared_comedor_from'] = Sf($_POST['shared_comedor_from']); } + // Determine icon: uploaded photo takes priority over text input + $icon = Sf($_POST["icon"] ?? "/static/logo-entreaulas.png"); + $aulario_photo = $_FILES["photo"] ?? null; + if ($aulario_photo !== null && $aulario_photo["error"] === UPLOAD_ERR_OK) { + $image_info = getimagesize($aulario_photo["tmp_name"]); + if ($image_info !== false) { + $aulario_dir = aulatek_orgs_base_path() . "/$centro_id/Aularios/$aulario_id"; + if (!is_dir($aulario_dir)) { + mkdir($aulario_dir, 0755, true); + } + if (move_uploaded_file($aulario_photo["tmp_name"], "$aulario_dir/photo.jpg")) { + $icon = "/aulatek/_filefetch.php?type=aulario_photo&org=" . urlencode($centro_id) . "&aulario=" . urlencode($aulario_id); + } + } + } db()->prepare( "UPDATE aularios SET name = ?, icon = ?, extra = ? WHERE org_id = ? AND aulario_id = ?" )->execute([ Sf($_POST["name"] ?? ""), - Sf($_POST["icon"] ?? "/static/logo-entreaulas.png"), + $icon, json_encode($extra), $centro_id, $aulario_id, @@ -165,7 +183,7 @@ switch ($view_action) {

Aulario:

-
+
@@ -173,9 +191,15 @@ switch ($view_action) {
- - +
+
+
+ + + Dejar vacĂ­o para mantener la imagen actual. +
+