aboutsummaryrefslogtreecommitdiff
path: root/lib/models/WidgetDefault.php
blob: 29354e02004c612147a345407e86456b0341a407 (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
<?php
/**
 * WidgetDefault.php
 * model class for table widget_default
 *
 * 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.
 *
 * @property array $id alias for pk
 * @property int $pluginid database column
 * @property int $col database column
 * @property int $position database column
 * @property string $perm database column
 */

class WidgetDefault extends SimpleORMap
{
    /**
     * Configure the database mapping.
     */
    protected static function configure($config = [])
    {
        $config['db_table'] = 'widget_default';

        parent::configure($config);
    }

    public static function getWidgets($perm): array
    {
        $result = [];
        $widgets = self::findBySQL('perm = ? ORDER BY position', [$perm]);

        foreach ($widgets as $widget) {
            $result[$widget->col][] = $widget->pluginid;
        }

        return $result;
    }
}