├── lang
├── _manifest_exclude
└── en.yml
├── .github
├── FUNDING.yml
├── workflows
│ └── ci.yml
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── _config
└── config.yml
├── _config.php
├── code-of-conduct.md
├── .tx
└── config
├── phpcs.xml.dist
├── .editorconfig
├── phpunit.xml.dist
├── CONTRIBUTING.md
├── LICENSE.md
├── templates
└── Dynamic
│ └── Elements
│ └── FileList
│ └── Elements
│ └── ElementFileList.ss
├── composer.json
├── README.md
├── src
├── Elements
│ └── ElementFileList.php
└── Model
│ └── FileListObject.php
└── CHANGELOG.md
/lang/_manifest_exclude:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [dynamic]
2 |
--------------------------------------------------------------------------------
/_config/config.yml:
--------------------------------------------------------------------------------
1 | ---
2 | Name: silverstripeelemental-filelistconfig
3 | ---
--------------------------------------------------------------------------------
/_config.php:
--------------------------------------------------------------------------------
1 | .yml
6 | minimum_perc = 0
7 | source_file = lang/en.yml
8 | source_lang = en
9 | type = YAML_GENERIC
10 |
11 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | pull_request:
6 | workflow_dispatch:
7 |
8 | jobs:
9 | ci:
10 | name: CI
11 | uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
12 | with:
13 | phpcoverage: false
14 |
--------------------------------------------------------------------------------
/phpcs.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeSniffer ruleset for SilverStripe coding conventions.
4 |
5 | src
6 | tests
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # For more information about the properties used in this file,
2 | # please see the EditorConfig documentation:
3 | # http://editorconfig.org
4 |
5 | [*]
6 | charset = utf-8
7 | end_of_line = lf
8 | indent_size = 4
9 | indent_style = space
10 | insert_final_newline = true
11 | trim_trailing_whitespace = true
12 |
13 | [{*.yml,package.json}]
14 | indent_size = 2
15 |
16 | # The indent size used in the package.json file cannot be changed:
17 | # https://github.com/npm/npm/pull/3180#issuecomment-16336516
18 |
--------------------------------------------------------------------------------
/lang/en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | Dynamic\Elements\FileList\Elements\ElementFileList:
3 | FilesLabel: 'Files'
4 | PLURALNAME: 'File List Elements'
5 | PLURALS:
6 | one: 'A File List'
7 | other: '{count} File Lists'
8 | SINGULARNAME: 'File List Element'
9 | Dynamic\Elements\FileList\Model\FileListObject:
10 | FileLabel: 'File'
11 | FileNameLabel: 'File'
12 | PLURALNAME: 'Files'
13 | PLURALS:
14 | one: 'A File'
15 | other: '{count} Files'
16 | SINGULARNAME: 'File'
17 | TitleLabel: 'Title'
18 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | src/
6 |
7 |
8 | tests/
9 |
10 |
11 |
12 |
13 | tests/
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: 'FEATURE '
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: 'BUG '
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 | - Maintenance on this module is a shared effort of those who use it
3 | - To contribute improvements to the code, ensure you raise a pull request and discuss with the module maintainers
4 | - Please follow the SilverStripe [code contribution guidelines](https://docs.silverstripe.org/en/contributing/code/) and [Module Standard](https://docs.silverstripe.org/en/developer_guides/extending/modules/#module-standard)
5 | - Supply documentation that followS the [GitHub Flavored Markdown](https://help.github.com/articles/markdown-basics/) conventions
6 | - When having discussions about this module in issues or pull request please adhere to the [SilverStripe Community Code of Conduct](https://docs.silverstripe.org/en/contributing/code_of_conduct/)
7 |
8 |
9 | ## Contributor license agreement
10 | By supplying code to this module in patches, tickets and pull requests, you agree to assign copyright
11 | of that code to Dynamic, on the condition that these code changes are released under the
12 | same BSD license as the original module. We ask for this so that the ownership in the license is clear
13 | and unambiguous. By releasing this code under a permissive license such as BSD, this copyright assignment
14 | won't prevent you from using the code in any way you see fit.
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018, Dynamic
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5 |
6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7 |
8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9 |
10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11 |
12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13 |
--------------------------------------------------------------------------------
/templates/Dynamic/Elements/FileList/Elements/ElementFileList.ss:
--------------------------------------------------------------------------------
1 | <% if $Title && $ShowTitle %>
$Title
<% end_if %>
2 | <% if $Content %>$Content
<% end_if %>
3 |
4 | <% if $Files %>
5 |
29 | <% end_if %>
30 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dynamic/silverstripe-elemental-filelist",
3 | "description": "A multi file block for SilverStripe Elemental",
4 | "license": "BSD-3-Clause",
5 | "type": "silverstripe-vendormodule",
6 | "keywords": [
7 | "silverstripe",
8 | "elemental",
9 | "file"
10 | ],
11 | "authors": [
12 | {
13 | "name": "Dynamic",
14 | "email": "dev@dynamicagency.com",
15 | "homepage": "https://www.dynamicagency.com"
16 | }
17 | ],
18 | "funding": [
19 | {
20 | "type": "github",
21 | "url": "https://github.com/sponsors/dynamic"
22 | }
23 | ],
24 | "require": {
25 | "dnadesign/silverstripe-elemental": "^5",
26 | "silverstripe/framework": "^5"
27 | },
28 | "require-dev": {
29 | "silverstripe/recipe-testing": "^3"
30 | },
31 | "suggest": {
32 | "colymba/gridfield-bulk-editing-tools": "Bulk upload files to a list."
33 | },
34 | "minimum-stability": "dev",
35 | "prefer-stable": true,
36 | "autoload": {
37 | "psr-4": {
38 | "Dynamic\\Elements\\FileList\\": "src/",
39 | "Dynamic\\Elements\\FileList\\Test\\": "tests/"
40 | }
41 | },
42 | "config": {
43 | "allow-plugins": {
44 | "composer/installers": true,
45 | "silverstripe/vendor-plugin": true,
46 | "silverstripe/recipe-plugin": true
47 | },
48 | "process-timeout": 600
49 | },
50 | "extra": {
51 | "branch-alias": {
52 | "dev-master": "3.x-dev"
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Silverstripe Elemental File List
2 |
3 | [](https://github.com/sponsors/dynamic)
4 |
5 | A multi file block for SilverStripe Elemental.
6 |
7 | [](https://codecov.io/gh/dynamic/silverstripe-elemental-filelist)
8 |
9 | [](https://packagist.org/packages/dynamic/silverstripe-elemental-filelist)
10 | [](https://packagist.org/packages/dynamic/silverstripe-elemental-filelist)
11 | [](https://packagist.org/packages/dynamic/silverstripe-elemental-filelist)
12 | [](https://packagist.org/packages/dynamic/silverstripe-elemental-filelist)
13 |
14 | ## Requirements
15 |
16 | * Silverstripe ^5.0
17 | * Silverstripe Elemental ^5.0
18 |
19 | #### Optional
20 |
21 | * colymba/gridfield-bulk-editing-tools ^3.0
22 |
23 | ## Installation
24 |
25 | `composer require dynamic/silverstripe-elemental-filelist`
26 |
27 | ## License
28 |
29 | See [License](license.md)
30 |
31 | ## Usage
32 |
33 | Elemental FileList Block will add the following Element to your site:
34 |
35 | * FileList
36 |
37 | The FileList Element will display a list of files for download.
38 |
39 | ## Getting more elements
40 |
41 | See [Elemental modules by Dynamic](https://github.com/orgs/dynamic/repositories?q=elemental&type=all&language=&sort=)
42 |
43 | ## Configuration
44 |
45 | See [SilverStripe Elemental Configuration](https://github.com/dnadesign/silverstripe-elemental#configuration)
46 |
47 |
48 | ## Translations
49 |
50 | The translations for this project are managed via [Transifex](https://www.transifex.com/dynamicagency/silverstripe-elemental-filelist/)
51 | and are updated automatically during the release process. To contribute, please head to the link above and get
52 | translating!
53 |
54 | ## Maintainers
55 |
56 | * [Dynamic](http://www.dynamicagency.com) ()
57 |
58 | ## Bugtracker
59 | Bugs are tracked in the issues section of this repository. Before submitting an issue please read over
60 | existing issues to ensure yours is unique.
61 |
62 | If the issue does look like a new bug:
63 |
64 | - Create a new issue
65 | - Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots
66 | and screencasts can help here.
67 | - Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version,
68 | Operating System, any installed SilverStripe modules.
69 |
70 | Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.
71 |
72 | ## Development and contribution
73 | If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.
74 |
--------------------------------------------------------------------------------
/src/Elements/ElementFileList.php:
--------------------------------------------------------------------------------
1 | 'HTMLText',
31 | ];
32 |
33 | /**
34 | * @var array
35 | */
36 | private static $has_many = [
37 | 'Files' => FileListObject::class,
38 | ];
39 |
40 | /**
41 | * @var array
42 | */
43 | private static $owns = [
44 | 'Files',
45 | ];
46 |
47 | /**
48 | * @var bool
49 | */
50 | private static $inline_editable = false;
51 |
52 | /**
53 | * @param bool $includerelations
54 | * @return array
55 | */
56 | public function fieldLabels($includerelations = true)
57 | {
58 | $labels = parent::fieldLabels($includerelations);
59 |
60 | $labels['Files'] = _t(__CLASS__.'.FilesLabel', 'Files');
61 |
62 | return $labels;
63 | }
64 |
65 | /**
66 | * @return FieldList
67 | */
68 | public function getCMSFields()
69 | {
70 | $this->beforeUpdateCMSFields(function (FieldList $fields) {
71 | $fields->dataFieldByName('Content')
72 | ->setRows(8);
73 |
74 | if ($this->ID) {
75 | $field = $fields->dataFieldByName('Files');
76 | $fields->removeByName('Files');
77 |
78 | $config = $field->getConfig();
79 | $config
80 | ->addComponents([
81 | new GridFieldOrderableRows('SortOrder')
82 | ])
83 | ->removeComponentsByType([
84 | GridFieldAddExistingAutocompleter::class,
85 | GridFieldDeleteAction::class
86 | ]);
87 | if (class_exists(BulkUploader::class)) {
88 | $config->addComponents([
89 | new BulkUploader()
90 | ]);
91 | $config->getComponentByType(BulkUploader::class)
92 | ->setUfSetup('setFolderName', 'Uploads/Elements/FileList/');
93 | }
94 | $fields->addFieldToTab('Root.Main', $field);
95 | }
96 | });
97 |
98 | return parent::getCMSFields();
99 | }
100 |
101 | /**
102 | * @return DBHTMLText
103 | */
104 | public function getSummary()
105 | {
106 | if ($this->Files()->count() == 1) {
107 | $label = ' file';
108 | } else {
109 | $label = ' files';
110 | }
111 | return DBField::create_field('HTMLText', $this->Files()->count() . $label)->Summary(20);
112 | }
113 |
114 | /**
115 | * @return array
116 | */
117 | protected function provideBlockSchema()
118 | {
119 | $blockSchema = parent::provideBlockSchema();
120 | $blockSchema['content'] = $this->getSummary();
121 | return $blockSchema;
122 | }
123 |
124 | /**
125 | * @return string
126 | */
127 | public function getType()
128 | {
129 | return _t(__CLASS__.'.BlockType', 'File List');
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## [3.0.0-alpha1](https://github.com/dynamic/silverstripe-elemental-filelist/tree/3.0.0-alpha1) (2023-02-012)
4 | * REFACTOR migrate phpunit config by @jsirish in https://github.com/dynamic/silverstripe-elemental-filelist/pull/22
5 | * REFACTOR Allow Elemental 5 by @jsirish in https://github.com/dynamic/silverstripe-elemental-filelist/pull/21
6 | * README Update requirements by @jsirish in https://github.com/dynamic/silverstripe-elemental-filelist/pull/23
7 |
8 |
9 | **Full Changelog**: https://github.com/dynamic/silverstripe-elemental-filelist/compare/2.0.3...3.0.0-alpha1
10 |
11 | ## [2.0.3](https://github.com/dynamic/silverstripe-elemental-filelist/tree/2.0.3) (2022-12-05)
12 |
13 | * CI workflow adjustments by @jsirish in https://github.com/dynamic/silverstripe-elemental-filelist/pull/18
14 | * README cleanup by @jsirish in https://github.com/dynamic/silverstripe-elemental-filelist/pull/19
15 | * FEATURE default Bootstrap template by @jsirish in https://github.com/dynamic/silverstripe-elemental-filelist/pull/20
16 |
17 |
18 | **Full Changelog**: https://github.com/dynamic/silverstripe-elemental-filelist/compare/2.0.2...2.0.3
19 |
20 | ## [2.0.2](https://github.com/dynamic/silverstripe-elemental-filelist/tree/2.0.2) (2019-06-03)
21 | [Full Changelog](https://github.com/dynamic/silverstripe-elemental-filelist/compare/2.0.1...2.0.2)
22 |
23 | **Implemented enhancements:**
24 |
25 | - BUG - set FolderName for File field [\#16](https://github.com/dynamic/silverstripe-elemental-filelist/issues/16)
26 | - initial i18n support [\#13](https://github.com/dynamic/silverstripe-elemental-filelist/issues/13)
27 | - Enhancement: Use Bulk Uploader [\#5](https://github.com/dynamic/silverstripe-elemental-filelist/issues/5)
28 |
29 | **Fixed bugs:**
30 |
31 | - BUG - set FolderName for File field [\#16](https://github.com/dynamic/silverstripe-elemental-filelist/issues/16)
32 | - BUG missing CRUD permissions [\#6](https://github.com/dynamic/silverstripe-elemental-filelist/issues/6)
33 |
34 | **Merged pull requests:**
35 |
36 | - bugfix - set folder name for File field [\#17](https://github.com/dynamic/silverstripe-elemental-filelist/pull/17) ([jsirish](https://github.com/jsirish))
37 | - initial i18n implementation [\#15](https://github.com/dynamic/silverstripe-elemental-filelist/pull/15) ([jsirish](https://github.com/jsirish))
38 | - FileListObject - add can\* checks for permissions [\#12](https://github.com/dynamic/silverstripe-elemental-filelist/pull/12) ([jsirish](https://github.com/jsirish))
39 | - update docs and guidelines [\#11](https://github.com/dynamic/silverstripe-elemental-filelist/pull/11) ([jsirish](https://github.com/jsirish))
40 | - new travis, scrutinizer, jenkinsfile CI configs [\#10](https://github.com/dynamic/silverstripe-elemental-filelist/pull/10) ([jsirish](https://github.com/jsirish))
41 | - CMS Design [\#9](https://github.com/dynamic/silverstripe-elemental-filelist/pull/9) ([jsirish](https://github.com/jsirish))
42 |
43 | ## [2.0.1](https://github.com/dynamic/silverstripe-elemental-filelist/tree/2.0.1) (2019-03-21)
44 | [Full Changelog](https://github.com/dynamic/silverstripe-elemental-filelist/compare/2.0.0...2.0.1)
45 |
46 | **Closed issues:**
47 |
48 | - REQUIREMENTS remove @dev references for composer requirements [\#7](https://github.com/dynamic/silverstripe-elemental-filelist/issues/7)
49 |
50 | **Merged pull requests:**
51 |
52 | - UPDATE requirements to not include @dev [\#8](https://github.com/dynamic/silverstripe-elemental-filelist/pull/8) ([muskie9](https://github.com/muskie9))
53 |
54 | ## [2.0.0](https://github.com/dynamic/silverstripe-elemental-filelist/tree/2.0.0) (2019-01-20)
55 | [Full Changelog](https://github.com/dynamic/silverstripe-elemental-filelist/compare/1.0.0...2.0.0)
56 |
57 | **Merged pull requests:**
58 |
59 | - add support for Elemental 4 [\#4](https://github.com/dynamic/silverstripe-elemental-filelist/pull/4) ([jsirish](https://github.com/jsirish))
60 |
61 | ## [1.0.0](https://github.com/dynamic/silverstripe-elemental-filelist/tree/1.0.0) (2019-01-20)
62 | **Merged pull requests:**
63 |
64 | - remove branch alias [\#3](https://github.com/dynamic/silverstripe-elemental-filelist/pull/3) ([jsirish](https://github.com/jsirish))
65 | - initial tests [\#2](https://github.com/dynamic/silverstripe-elemental-filelist/pull/2) ([jsirish](https://github.com/jsirish))
66 | - update README, cleanup [\#1](https://github.com/dynamic/silverstripe-elemental-filelist/pull/1) ([jsirish](https://github.com/jsirish))
67 |
68 |
69 |
70 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
71 |
--------------------------------------------------------------------------------
/src/Model/FileListObject.php:
--------------------------------------------------------------------------------
1 | 'Varchar(255)',
27 | 'Content' => 'HTMLText',
28 | 'SortOrder' => "Int",
29 | ];
30 |
31 | /**
32 | * @var array
33 | */
34 | private static $has_one = [
35 | 'FileList' => ElementFileList::class,
36 | 'File' => File::class,
37 | ];
38 |
39 | /**
40 | * @var array
41 | */
42 | private static $owns = [
43 | 'File',
44 | ];
45 |
46 | /**
47 | * @var array
48 | */
49 | private static $summary_fields = [
50 | 'File.Name',
51 | 'Title',
52 | ];
53 |
54 | /**
55 | * @param bool $includerelations
56 | * @return array
57 | */
58 | public function fieldLabels($includerelations = true)
59 | {
60 | $labels = parent::fieldLabels($includerelations);
61 |
62 | $labels['Title'] = _t(__CLASS__.'.TitleLabel', 'Title');
63 | $labels['File.Name'] = _t(__CLASS__.'.FileNameLabel', 'File');
64 | $labels['File'] = _t(__CLASS__.'.FileLabel', 'File');
65 |
66 | return $labels;
67 | }
68 |
69 | /**
70 | * @var string
71 | */
72 | private static $table_name = 'FileListObject';
73 |
74 | /**
75 | * @return \SilverStripe\Forms\FieldList
76 | */
77 | public function getCMSFields()
78 | {
79 | $fields = parent::getCMSFields();
80 |
81 | $fields->dataFieldByName('File')
82 | ->setTitle($this->fieldLabel('File'))
83 | ->setFolderName('Uploads/Elements/FileList/');
84 |
85 | $fields->removeByName([
86 | 'FileListID',
87 | 'SortOrder',
88 | ]);
89 |
90 | return $fields;
91 | }
92 |
93 | /**
94 | * Basic permissions, defaults to page perms where possible.
95 | *
96 | * @param \SilverStripe\Security\Member|null $member
97 | * @return boolean
98 | */
99 | public function canView($member = null)
100 | {
101 | $extended = $this->extendedCan(__FUNCTION__, $member);
102 | if ($extended !== null) {
103 | return $extended;
104 | }
105 |
106 | if ($page = $this->FileList()->getPage()) {
107 | return $page->canView($member);
108 | }
109 |
110 | return Permission::check('CMS_ACCESS', 'any', $member);
111 | }
112 |
113 | /**
114 | * Basic permissions, defaults to page perms where possible.
115 | *
116 | * @param \SilverStripe\Security\Member|null $member
117 | *
118 | * @return boolean
119 | */
120 | public function canEdit($member = null)
121 | {
122 | $extended = $this->extendedCan(__FUNCTION__, $member);
123 | if ($extended !== null) {
124 | return $extended;
125 | }
126 |
127 | if ($page = $this->FileList()->getPage()) {
128 | return $page->canEdit($member);
129 | }
130 |
131 | return Permission::check('CMS_ACCESS', 'any', $member);
132 | }
133 |
134 | /**
135 | * Basic permissions, defaults to page perms where possible.
136 | *
137 | * Uses archive not delete so that current stage is respected i.e if a
138 | * element is not published, then it can be deleted by someone who doesn't
139 | * have publishing permissions.
140 | *
141 | * @param \SilverStripe\Security\Member|null $member
142 | *
143 | * @return boolean
144 | */
145 | public function canDelete($member = null)
146 | {
147 | $extended = $this->extendedCan(__FUNCTION__, $member);
148 | if ($extended !== null) {
149 | return $extended;
150 | }
151 |
152 | if ($page = $this->FileList()->getPage()) {
153 | return $page->canArchive($member);
154 | }
155 |
156 | return Permission::check('CMS_ACCESS', 'any', $member);
157 | }
158 |
159 | /**
160 | * Basic permissions, defaults to page perms where possible.
161 | *
162 | * @param \SilverStripe\Security\Member|null $member
163 | * @param array $context
164 | *
165 | * @return boolean
166 | */
167 | public function canCreate($member = null, $context = array())
168 | {
169 | $extended = $this->extendedCan(__FUNCTION__, $member);
170 | if ($extended !== null) {
171 | return $extended;
172 | }
173 |
174 | return Permission::check('CMS_ACCESS', 'any', $member);
175 | }
176 | }
177 |
--------------------------------------------------------------------------------