aboutsummaryrefslogtreecommitdiff
path: root/lib/models/CourseWizardStepRegistry.php
blob: 7c473c4e9ca002c1eb52192b6a3c03c38742717e (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
58
59
<?php
/**
 * CourseWizardStepRegistry.php
 * Model class for table coursewizardsteps.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * @author      Thomas Hackl <thomas.hackl@uni-passau.de>
 * @copyright   2015 Stud.IP Core-Group
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 *
 * @property string $id database column
 * @property string $name database column
 * @property string $classname database column
 * @property int $number database column
 * @property int $enabled database column
 * @property int $mkdate database column
 * @property int $chdate database column
 */

class CourseWizardStepRegistry extends SimpleORMap
{

    protected static function configure($config = [])
    {
        $config['db_table'] = 'coursewizardsteps';
        parent::configure($config);
    }

    public static function registerStep($name, $class, $number, $enabled=false)
    {
        $step = new CourseWizardStepRegistry();
        $step->name = $name;
        $step->classname = $class;
        $step->number = $number;
        $step->enabled = $enabled ? 1 : 0;
        return $step->store();
    }

    public static function unregisterStep($id)
    {
        $step = self::find($id);
        if ($step)
        {
            return $step->delete();
        }
        return true;
    }

    public static function hasEnabledSteps()
    {
        return sizeof(self::findBySQL("`enabled`=1")) > 0 ? true : false;
    }

}