action_distribution.php 1.45 KB
Newer Older
jlopez's avatar
jlopez committed
1
2
3
4
5
6
7
<?php

define("PATH","..");
define("PAGE","actionDistribution");

session_start ();

jlopez's avatar
jlopez committed
8
if(!isset($_SESSION['manage'])) {
jlopez's avatar
jlopez committed
9
10
11
12
13
14
15
16
17
18
19
20
    header("Location: ../login.php");
}

require_once '../dao/DBquery.php';

$db = new DBquery();

$today = date("Y-m-d G:i:s");

$action  = NULL;

$id      = NULL;
jlopez's avatar
jlopez committed
21
22
$version  = NULL;
$manager  = NULL;
jlopez's avatar
jlopez committed
23
$active   = 0;
jlopez's avatar
jlopez committed
24
$vname = "";
jlopez's avatar
jlopez committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67


if(isset($_POST['action'])) {
    $action = $_POST['action'];
} else {
    if(isset($_GET['action'])) {
        $action = $_GET['action'];
    } else {
        $action = "";
    }
}

if(isset($_POST['distribid'])) {
    $id = $_POST['distribid'];
} else {
    if(isset($_GET['distribid'])) {
        $id = $_GET['distribid'];
    } else {
        $id = -1;
    }
}

if(isset($_POST['name'])) {
    $name = $_POST['name'];
}

if(isset($_POST['version'])) {
    $version = $_POST['version'];
}

if(isset($_POST['manager'])) {
    $manager = $_POST['manager'];
}

if(isset($_POST['active'])) {

    if($_POST['active'] == $id) {
        $active = 1;
    } else {
        $active = 0;
    }
}

jlopez's avatar
jlopez committed
68
69
70
if(isset($_POST['vname'])) {
    $vname = $_POST['vname'];
}
jlopez's avatar
jlopez committed
71

jlopez's avatar
jlopez committed
72
$distrib = new Distribution($id, $name, $version, $manager, $active, $vname);
jlopez's avatar
jlopez committed
73
74
75
76

if($action == "create") {
    $distrib->active = 1;
    $distrib->escape($db);
jlopez's avatar
jlopez committed
77
    $db->create($distrib);
jlopez's avatar
jlopez committed
78
79
80
81
82
83
84
} else if ($action == "update") {
    $distrib->escape($db);
    $db->update($distrib);
} else if ($action == "delete") {
    $db->delete($distrib);
}

jlopez's avatar
Fix #12    
jlopez committed
85
header("Location: ../manage.php#distribution");
jlopez's avatar
jlopez committed
86