Beispiel #1
0
require_once 'Connection.class.php';
require_once 'ActivityDAO.class.php';
require_once 'SongDAO.class.php';
require_once 'partial_form_track.php';
$action = from_get('action', 'new');
$id = from_get('id', -1);
if ($action !== 'update' && $action !== 'new') {
    die('opció invalida');
    exit;
}
if ($action === 'update') {
    $c = new Connection();
    $conn = $c->getConnection();
    $activityDAO = new ActivityDAO($conn);
    $activity = $activityDAO->select($id);
    $songDAO = new SongDAO($conn);
    $songs = $songDAO->selectFromActivity($id);
} else {
    $activity = array('id' => -1, 'activity_name' => '', 'description' => '', 'goals' => '', 'materials' => '', 'observations' => '', 'assesment' => '', 'comments' => '', 'keywords' => '', 'types' => '', 'song_themes' => '', 'ages' => '');
    $songs = array();
}
$title = $action === 'new' ? 'Nova activitat' : 'Modificar activitat';
include 'head.php';
?>


<br>
<div>

<h1 class="text-center"><?php 
echo $title;
Beispiel #2
0
        $songs = array();
        for ($i = 0; $i < count($song_names); $i++) {
            $songs[] = array('name' => $song_names[$i], 'duration' => empty($song_durations[$i]) ? '' : $song_durations[$i], 'file' => '');
        }
        /*echo 'SONGS:';
          print_r($songs);*/
}
/*
echo 'action: '.$action;
echo '$activity';
print_r($activity);
*/
$c = new Connection();
$conn = $c->getConnection();
$activityDAO = new ActivityDAO($conn);
$songDAO = new SongDAO($conn);
$response = array('status' => '1', 'message' => '');
switch ($action) {
    case 'new':
        $insert_id = $activityDAO->create($activity);
        if (count($songs) > 0) {
            $songDAO->createSongs($insert_id, $songs);
        }
        break;
    case 'update':
        $activityDAO->update($activity);
        $songDAO->unlinkFromActivity($activity['id']);
        $songDAO->createSongs($activity['id'], $songs);
        break;
    case 'delete':
        //echo 'delete dao'.$id; exit;