summaryrefslogtreecommitdiff
path: root/includes/model/EventConfig_model.php
blob: 330863a9250ed16c2ad800c928e05867384ebb61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
<?php

/**
 * Get event config.
 *
 * łreturn array|false|null
 */
function EventConfig()
{
    $event_config = sql_select('SELECT * FROM `EventConfig` LIMIT 1');
    if ($event_config === false) {
        engelsystem_error('Unable to load event config.');
        return false;
    }
    if (count($event_config) > 0) {
        return $event_config[0];
    }
    return null;
}

/**
 * Update event config.
 *
 * @param string $event_name
 * @param int    $buildup_start_date
 * @param int    $event_start_date
 * @param int    $event_end_date
 * @param int    $teardown_end_date
 * @param string $event_welcome_msg
 * @return mysqli_result|false
 */
function EventConfig_update(
    $event_name,
    $buildup_start_date,
    $event_start_date,
    $event_end_date,
    $teardown_end_date,
    $event_welcome_msg
) {
    if (EventConfig() == null) {
        return sql_query("INSERT INTO `EventConfig` SET
      `event_name`=" . sql_null($event_name) . ",
      `buildup_start_date`=" . sql_null($buildup_start_date) . ",
      `event_start_date`=" . sql_null($event_start_date) . ",
      `event_end_date`=" . sql_null($event_end_date) . ",
      `teardown_end_date`=" . sql_null($teardown_end_date) . ",
      `event_welcome_msg`=" . sql_null($event_welcome_msg));
    }

    return sql_query("UPDATE `EventConfig` SET
      `event_name`=" . sql_null($event_name) . ", 
      `buildup_start_date`=" . sql_null($buildup_start_date) . ",
      `event_start_date`=" . sql_null($event_start_date) . ",
      `event_end_date`=" . sql_null($event_end_date) . ",
      `teardown_end_date`=" . sql_null($teardown_end_date) . ",        
      `event_welcome_msg`=" . sql_null($event_welcome_msg));
}