Location: PHPKode > projects > Digital Media Courseware > template/admin/curso.php
<?php

require_once( DMCROOT . 'lib/class/DMC.php');
require_once( DMCROOT . 'lib/class/Sesion.php');
require_once( DMCROOT . 'lib/class/Course.php');
require_once( DMCROOT . 'lib/class/Ejercicio.php');
require_once( DMCROOT . 'lib/class/Persona.php');

$DMC = new DMC();
$Sesion = new Sesion();
$Course = new Course();
$Ejercicio = new Ejercicio();
$Persona = new Persona();

if (!$Sesion->validateCurso($id,1)) {
	$Sesion->logout();
	header ("Location: index.php");
}

$DMC->setPage('be_curso');

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

// manejo del post para crear/modificar/eliminar

if ((isset($_POST["DM_post"])) && ($_POST["DM_post"] == "frm_curso")) {
	if ($_POST['accion'] == 2) {
		// accion modificar
		if ($_POST['borrarfoto'] == 'si') {
			$_POST['foto'] = $Course->updateCoursePhoto(false,$_POST['path'],$_POST['foto']);
		} else {
			if ($_FILES['tempfoto']['name'] != '') $_POST['foto'] = $Course->updateCoursePhoto('tempfoto',$_POST['path'],$_POST['foto']);
		}
		$e = $Course->updateCourse($_POST['titulo'],$_POST['subtitulo'],$_POST['texto'],$_POST['foto'],$_POST['programa'],$_POST['horario'],$_POST['fecha'],$_POST['visible'],$_POST['activo'],$_POST['id']);
	}
	// nos largamos de acá
	if ($e) header ("Location: curso.php");
}

// si es accion == 2 sacamos la info del curso y de los ejercicios

if ($_GET['accion'] == 2 && $_GET['id']) {
	$q = $Course->courseDetail($_GET['id']);
	if (count($q) > 0) {
		foreach ($q as $key => $value) {
			$GLOBALS[$key] = $value;
		}
	}
	$ejercicios = $Ejercicio->excerciseList($_GET['id']);
	$personas = $Persona->personList($_GET['id']);
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $DMC->lang_data['base']['nombre'] ?>: <?php echo $DMC->m('encabezado') ?></title>
<script language="JavaScript" type="text/javascript">
<!--
imageUrl = '../../../cal';
-->
</script>
<script src="../../../cal/js/javascript.js" type="text/javascript" language="JavaScript"></script>
<script src="../../../cal/js/popcalendar.js" type="text/javascript" language="JavaScript"></script>
<script src="../../../js/validador.php" type="text/javascript" language="JavaScript"></script>
<link href="../../../css/admin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<h1><?php echo $DMC->m('encabezado') ?>: <?php if ($_GET['accion'] == 1) { echo $DMC->m('titulo_crear'); } else { echo $DMC->m('titulo_modificar'); } ?></h1>
<p>&laquo; <a href="logout.php"><?php echo $DMC->m('ln_salir') ?></a></p>
<?php
if (!$q && $_GET['accion'] == 2) {
?>
<p><?php echo $DMC->m('err_no_curso') ?></p>
<?php
} else {
?>
<table width="100%" border="0" cellpadding="0" cellspacing="5" >
    <tr valign="top">
    <td width="500">
	<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="frm_curso" onsubmit="return validar('frm_curso','boton');">
		<table>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right"><?php echo $DMC->m('frm_carpeta') ?>:</th>
				<td>
					<?php echo $path ?>
					<input type="hidden" name="path" value="<?php echo $path ?>" size="20" />
				</td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right" class="req"><?php echo $DMC->m('frm_titulo') ?>:</th>
				<td><input type="text" name="titulo" value="<?php echo $titulo ?>" size="32" /></td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right"><?php echo $DMC->m('frm_subtitulo') ?>:</th>
				<td><input type="text" name="subtitulo" value="<?php echo $subtitulo ?>" size="32" /></td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right" valign="top"><?php echo $DMC->m('frm_texto') ?>:</th>
				<td><textarea name="texto" cols="32" rows="5"><?php echo htmlentities($texto,ENT_QUOTES,'UTF-8') ?></textarea>
				</td>
			</tr>
			<tr valign="top">
				<th nowrap="nowrap" align="right"><?php echo $DMC->m('frm_foto') ?>:</th>
				<td>
<?php 
	if ($_GET['accion'] == 2 && $foto != "") {
?>
					<img src="<?php echo $DMC->app['DMC_url'] . $DMC->app['DMC_course_folder'] . '/' . $path . '/files/' . $foto ?>" /><br />
					<input type="checkbox" name="borrarfoto" id="borrarfoto" value="si" />
                    <label for="borrarfoto"><?php echo $DMC->m('frm_borrar_foto') ?></label><br />
<?php 
	}
?>
					<input type="hidden" name="foto" value="<?php echo $foto ?>" />
                    <input type="file" name="tempfoto" size="20" />
				</td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right" valign="top"><?php echo $DMC->m('frm_programa') ?>:</th>
				<td><textarea name="programa" cols="32" rows="5"><?php echo htmlentities($programa,ENT_QUOTES,'UTF-8') ?></textarea>
				</td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right" valign="top"><?php echo $DMC->m('frm_horario') ?>:</th>
				<td><textarea name="horario" cols="32" rows="5"><?php echo htmlentities($horario,ENT_QUOTES,'UTF-8') ?></textarea>
				</td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right" class="req"><?php echo $DMC->m('frm_fecha') ?>:</th>
				<td><input type="text" name="fecha" value="<?php echo $fecha ?>" size="10" />
				<img src='../../../cal/cal.gif' alt="<?php echo $DMC->m('frm_seleccione_fecha') ?>" name="date_button" id="date_button" onclick="popUpCalendar(this, document.frm_curso.fecha, 'dd/mm/yyyy')" /></td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right"><?php echo $DMC->m('frm_visible') ?>:</th>
				<td><select name="visible">
						<option value="0" <?php if ($visible==0) { ?>selected="selected"<?php } ?>><?php echo $DMC->lang_data['base']['no'] ?></option>
						<option value="1" <?php if ($visible==1) { ?>selected="selected"<?php } ?>><?php echo $DMC->lang_data['base']['si'] ?></option>
					</select>
				</td>
			</tr>
			<tr valign="baseline">
				<th nowrap="nowrap" align="right"><?php echo $DMC->m('frm_activo') ?>:</th>
				<td><select name="activo">
						<option value="0" <?php if ($activo==0) { ?>selected="selected"<?php } ?>><?php echo $DMC->lang_data['base']['no'] ?></option>
						<option value="1" <?php if ($activo==1) { ?>selected="selected"<?php } ?>><?php echo $DMC->lang_data['base']['si'] ?></option>
					</select>
				</td>
			</tr>
			<tr valign="baseline">
				<td nowrap="nowrap" align="right">&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<tr valign="baseline">
				<td nowrap="nowrap" align="right">&nbsp;</td>
				<td><input type="submit" value="<?php echo $DMC->m('frm_boton_modificar'); ?>" name="boton" class="boton" /></td>
			</tr>
		</table>
<?php
	if ($id) {
?>
		<input type="hidden" name="id" value="<?php echo $id ?>" />
<?php
	}
?>
		<input type="hidden" name="accion" value="<?php if ($_POST['accion']) { echo $_POST['accion']; } elseif ($_GET['accion']) { echo $_GET['accion']; } else { echo $accion; } ?>" />
		<input type="hidden" name="DM_post" value="frm_curso" />
		<input type="hidden" name="__campos__" value="path,titulo,fecha" />
		<input type="hidden" name="__nombres__" value="<?php echo $DMC->m('js_carpeta') ?>,<?php echo $DMC->m('js_titulo') ?>,<?php echo $DMC->m('js_fecha') ?>" />
		<input type="hidden" name="__tipos__" value="texto,texto,fecha" />
	</form>
	</td>
<?php
	if ($_GET['accion'] == 2) {
?>
	<td nowrap="nowrap">
		<h3><?php echo $DMC->m('titulo_ejercicios') ?></h3>
		<p><a href="ejercicio.php?accion=1"><?php echo $DMC->m('ln_nuevo_ejercicio') ?></a> &raquo;</p>
<?php
		if (count($ejercicios) > 0) {
?>
		<ul>
<?php
			foreach ($ejercicios as $row) {
?>
			<li><a href="ejercicio.php?accion=2&amp;id=<?php echo $row['id'] ?>"><?php echo $row['titulo'] ?></a></li>
<?php	    
			}
?>
		</ul>
<?php	    
		} else {
?>
	    <p><?php echo $DMC->m('err_no_ejercicios') ?></p>
<?php	    
		}
?>
	</td>
	<td nowrap="nowrap">
		<h3><?php echo $DMC->m('titulo_personas') ?></h3>
		<p><a href="persona.php?accion=1"><?php echo $DMC->m('ln_nueva_persona') ?></a> &raquo;</p>
<?php
		if (count($personas) > 0) {
?>
        <ul>
<?php
			foreach ($personas as $row) {
?>
        	<li><a href="persona.php?accion=2&amp;id=<?php echo $row['id'] ?>"><?php echo $row['nombre'] ?> <?php echo $row['apellido'] ?></a></li>
<?php	    
			}
?>
       	</ul>
<?php	    
		} else {
?>
	    <p><?php echo $DMC->m('err_no_personas') ?></p>
<?php	    
		}
?>
	</td>
	</tr>
<?php	    
	}
?>
</table>
<?php
}
?>
</body>
</html>
Return current item: Digital Media Courseware