Schema.php 3.17 KB
Newer Older
1 2 3 4
<?php

namespace ACP3\Modules\ACP3\Files\Installer;

5
use ACP3\Core\ACL\PrivilegeEnum;
6 7 8 9 10 11 12 13
use ACP3\Core\Modules;

/**
 * Class Installer
 * @package ACP3\Modules\ACP3\Files
 */
class Schema implements Modules\Installer\SchemaInterface
{
14 15
    const MODULE_NAME = 'files';

16 17 18 19 20
    /**
     * @return array
     */
    public function specialResources()
    {
21 22 23 24 25
        return [
            'admin' => [
                'index' => [
                    'create' => PrivilegeEnum::ADMIN_CREATE,
                    'delete' => PrivilegeEnum::ADMIN_DELETE,
26 27 28
                    'duplicate' => PrivilegeEnum::ADMIN_CREATE,
                    'edit' => PrivilegeEnum::ADMIN_EDIT,
                    'index' => PrivilegeEnum::ADMIN_VIEW,
29 30
                    'settings' => PrivilegeEnum::ADMIN_SETTINGS,
                    'sort' => PrivilegeEnum::ADMIN_CREATE,
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
                ]
            ],
            'frontend' => [
                'index' => [
                    'index' => PrivilegeEnum::FRONTEND_VIEW,
                    'details' => PrivilegeEnum::FRONTEND_VIEW,
                    'download' => PrivilegeEnum::FRONTEND_VIEW,
                    'files' => PrivilegeEnum::FRONTEND_VIEW
                ]
            ],
            'widget' => [
                'index' => [
                    'index' => PrivilegeEnum::FRONTEND_VIEW,
                ]
            ]
        ];
47 48 49 50 51 52 53
    }

    /**
     * @return string
     */
    public function getModuleName()
    {
54
        return static::MODULE_NAME;
55 56 57 58 59 60 61
    }

    /**
     * @return int
     */
    public function getSchemaVersion()
    {
62
        return 47;
63 64 65 66 67 68 69 70 71 72
    }

    /**
     * @return array
     */
    public function createTables()
    {
        return [
            "CREATE TABLE `{pre}files` (
                `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
73
                `active` TINYINT(1) UNSIGNED NOT NULL,
74 75
                `start` DATETIME NOT NULL,
                `end` DATETIME NOT NULL,
Tino Goratsch's avatar
Tino Goratsch committed
76
                `updated_at` DATETIME NOT NULL,
77
                `category_id` INT(10) UNSIGNED,
78 79 80 81
                `file` VARCHAR(120) NOT NULL,
                `size` VARCHAR(20) NOT NULL,
                `title` VARCHAR(255) NOT NULL,
                `text` TEXT NOT NULL,
82
                `sort` INT(10) UNSIGNED NOT NULL,
83
                `comments` TINYINT(1) UNSIGNED NOT NULL,
84
                `user_id` INT UNSIGNED,
85
                PRIMARY KEY (`id`),
86
                FULLTEXT KEY `fulltext_index` (`title`, `file`, `text`),
87
                INDEX `foreign_category_id` (`category_id`),
88
                INDEX (`user_id`),
89
                INDEX (`sort`),
90
                FOREIGN KEY (`category_id`) REFERENCES `{pre}categories` (`id`) ON DELETE SET NULL,
91
                FOREIGN KEY (`user_id`) REFERENCES `{pre}users` (`id`) ON DELETE SET NULL
92 93 94 95 96 97 98 99 100 101
            ) {ENGINE} {CHARSET};"
        ];
    }

    /**
     * @return array
     */
    public function removeTables()
    {
        return [
102
            "DROP TABLE IF EXISTS `{pre}files`;"
103 104 105 106 107 108 109 110 111 112 113 114
        ];
    }

    /**
     * @return array
     */
    public function settings()
    {
        return [
            'comments' => 1,
            'dateformat' => 'long',
            'sidebar' => 5,
115
            'order_by' => 'date'
116 117 118
        ];
    }
}