├── .git-blame-ignore-revs
├── .gitattributes
├── .github
├── CODEOWNERS
├── ISSUE_TEMPLATE
│ ├── 1_bug_report.md
│ ├── 1_bug_report.md.license
│ ├── 2_feature_request.md
│ ├── 2_feature_request.md.license
│ └── config.yml
├── contributing.md
├── dependabot.yml
└── workflows
│ ├── appstore-build-publish.yml
│ ├── block-unconventional-commits.yml
│ ├── dependabot-approve-merge.yml
│ ├── fixup.yml
│ ├── lint-info-xml.yml
│ ├── lint-php-cs.yml
│ ├── lint-php.yml
│ ├── pr-feedback.yml
│ ├── psalm.yml
│ ├── reuse.yml
│ ├── update-nextcloud-ocp-approve-merge.yml
│ └── update-nextcloud-ocp.yml
├── .gitignore
├── .php-cs-fixer.dist.php
├── AUTHORS.md
├── CHANGELOG.md
├── COPYING
├── LICENSES
├── AGPL-3.0-or-later.txt
├── CC0-1.0.txt
└── MIT.txt
├── Makefile
├── README.md
├── REUSE.toml
├── appinfo
└── info.xml
├── composer.json
├── composer.lock
├── docs
├── screenshot.png
└── screenshot.png.license
├── lib
├── AppInfo
│ └── Application.php
├── Command
│ └── Generate.php
├── Formatter.php
├── Listener.php
├── Migration
│ ├── Version1001Date20180806133516.php
│ ├── Version1004Date20200626143122.php
│ ├── Version1004Date20200626143419.php
│ └── Version1004Date20200630071803.php
└── Reports
│ ├── AllUsers.php
│ └── SingleUser.php
├── psalm.xml
├── tests
├── bootstrap.php
├── phpunit.xml
├── psalm-baseline.xml
└── psalm-baseline.xml.license
└── vendor-bin
├── cs-fixer
├── composer.json
└── composer.lock
├── phpunit
├── composer.json
└── composer.lock
└── psalm
├── composer.json
└── composer.lock
/.git-blame-ignore-revs:
--------------------------------------------------------------------------------
1 | # .git-blame-ignore-revs
2 |
3 | # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
4 | # SPDX-License-Identifier: AGPL-3.0-or-later
5 |
6 | # coding-standard 1.2.3
7 | 60e018a25d246c4ed4019a56754481dabe2873a9
8 | # coding-standard 1.3.1
9 | 8d83815ad8231e2f7aee7f5fb361db1567f88f2c
10 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
2 | # SPDX-License-Identifier: AGPL-3.0-or-later
3 | /vendor-bin/**/composer.lock binary
4 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
2 | # SPDX-License-Identifier: AGPL-3.0-or-later
3 | # App maintainer
4 | /appinfo/info.xml @JuliaKirschenheuter @kesselb
5 |
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/1_bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 🐞 Bug report
3 | about: Help us to improve by reporting a bug
4 | labels: 0. Needs triage, bug
5 | ---
6 |
7 |
8 |
9 | ### How to use GitHub
10 |
11 | * Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
12 | * Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
13 | * Subscribe to receive notifications on status change and new comments.
14 |
15 | ---
16 |
17 | ### Steps to reproduce
18 | 1.
19 | 2.
20 | 3.
21 |
22 | ### Expected behaviour
23 | Tell us what should happen
24 |
25 | ### Actual behaviour
26 | Tell us what happens instead, if possible also add a screenshot
27 |
28 | ### Server configuration
29 |
30 | **Web server:** Apache/Nginx
31 |
32 | **Database:** MySQL/Maria/SQLite/PostgreSQL
33 |
34 | **PHP version:** 8.1/8.2/8.3
35 |
36 | **Nextcloud version:** (see Nextcloud admin page)
37 |
38 |
39 | List of activated apps
40 |
41 | ```
42 | If you have access to your command line run e.g.:
43 | sudo -u www-data php occ app:list
44 | from within your Nextcloud installation folder
45 | ```
46 |
47 |
48 |
49 | Nextcloud configuration
50 |
51 | ```
52 | If you have access to your command line run e.g.:
53 | sudo -u www-data php occ config:list system
54 | from within your Nextcloud installation folder
55 | ```
56 |
57 |
58 | ### Browser
59 |
60 | **Browser name:** Firefox/Chrome/Safari/…
61 |
62 | **Browser version:** 124/125/…
63 |
64 | **Operating system:** Windows/Ubuntu/Mac/…
65 |
66 |
67 | Browser log
68 |
69 | ```
70 | Insert your browser log here, this could for example include:
71 | a) The javascript console log
72 | b) The network log
73 | c) ...
74 | ```
75 |
76 |
77 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/1_bug_report.md.license:
--------------------------------------------------------------------------------
1 | SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
2 | SPDX-License-Identifier: AGPL-3.0-or-later
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/2_feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 🚀 Feature request
3 | about: Suggest an idea for this app
4 | labels: 0. Needs triage, enhancement
5 | ---
6 |
7 |
8 |
9 | ### How to use GitHub
10 |
11 | * Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are interested into the same feature.
12 | * Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
13 | * Subscribe to receive notifications on status change and new comments.
14 |
15 | ---
16 |
17 | ## Feature request
18 |
19 | **Which Nextcloud Version are you currently using:** (see administration page)
20 |
21 | **Is your feature request related to a problem? Please describe.**
22 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
23 |
24 | **Describe the solution you'd like**
25 | A clear and concise description of what you want to happen.
26 |
27 | **Describe alternatives you've considered**
28 | A clear and concise description of any alternative solutions or features you've considered.
29 |
30 | **Additional context**
31 | Add any other context or screenshots about the feature request here.
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/2_feature_request.md.license:
--------------------------------------------------------------------------------
1 | SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
2 | SPDX-License-Identifier: AGPL-3.0-or-later
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
2 | # SPDX-License-Identifier: AGPL-3.0-or-later
3 | contact_links:
4 | - name: 🚨 Report a security or privacy issue
5 | url: https://hackerone.com/nextcloud
6 | about: Report security and privacy related issues privately to the Nextcloud team, so we can coordinate the fix and release without potentially exposing all Nextcloud servers and users in the meantime.
7 | - name: ❓ Community Support and Help
8 | url: https://help.nextcloud.com/
9 | about: Configuration, webserver/proxy or performance issues and other questions
10 | - name: 💼 Nextcloud Enterprise
11 | url: https://portal.nextcloud.com/
12 | about: If you are a Nextcloud Enterprise customer, or need Professional support, so it can be resolved directly by our dedicated engineers more quickly
13 |
--------------------------------------------------------------------------------
/.github/contributing.md:
--------------------------------------------------------------------------------
1 |
5 | ## Submitting issues
6 |
7 | If you have questions about how to install or use Nextcloud, please direct these to our [forum][forum]. We are also available on [IRC][irc].
8 |
9 | ### Short version
10 |
11 | * The [**issue template can be found here**][template]. Please always use the issue template when reporting issues.
12 |
13 | ### Guidelines
14 | * Please search the existing issues first, it's likely that your issue was already reported or even fixed.
15 | - Go to one of the repositories, click "issues" and type any word in the top search/command bar.
16 | - You can also filter by appending e. g. "state:open" to the search string.
17 | - More info on [search syntax within github](https://help.github.com/articles/searching-issues)
18 | * This repository ([User usage report](https://github.com/nextcloud/user_usage_report/issues)) is *only* for issues within this app.
19 | * __SECURITY__: Report any potential security bug to us via [our HackerOne page](https://hackerone.com/nextcloud) or security@nextcloud.com following our [security policy](https://nextcloud.com/security/) instead of filing an issue in our bug tracker
20 | * Report the issue using our [template][template], it includes all the information we need to track down the issue.
21 |
22 | Help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues.
23 |
24 | [template]: https://raw.github.com/nextcloud/user_usage_report/master/.github/issue_template.md
25 | [forum]: https://help.nextcloud.com/
26 | [irc]: https://webchat.freenode.net/?channels=nextcloud
27 |
28 | ### Contribute Code and translations
29 | Please check [server's contribution guidelines](https://github.com/nextcloud/server/blob/master/CONTRIBUTING.md#contributing-to-source-code) for further information about contributing code and translations.
30 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
2 | # SPDX-License-Identifier: AGPL-3.0-or-later
3 | version: 2
4 | updates:
5 |
6 | # Composer
7 | - package-ecosystem: composer
8 | directory: "/"
9 | commit-message:
10 | prefix: "build"
11 | include: "scope"
12 | versioning-strategy: "increase"
13 | schedule:
14 | interval: weekly
15 | day: saturday
16 | time: "03:00"
17 | timezone: Europe/Paris
18 | labels:
19 | - 3. to review
20 | - dependencies
21 |
22 | # Composer (tooling)
23 | - package-ecosystem: composer
24 | directories:
25 | - "/vendor-bin/cs-fixer"
26 | - "/vendor-bin/phpunit"
27 | - "/vendor-bin/psalm"
28 | commit-message:
29 | prefix: "ci"
30 | include: "scope"
31 | versioning-strategy: "increase"
32 | schedule:
33 | interval: weekly
34 | day: saturday
35 | time: "03:15"
36 | timezone: Europe/Berlin
37 | labels:
38 | - 3. to review
39 | - dependencies
40 |
41 | # GitHub Actions
42 | - package-ecosystem: "github-actions"
43 | directory: ".github/workflows"
44 | commit-message:
45 | prefix: "ci"
46 | include: "scope"
47 | schedule:
48 | interval: weekly
49 | day: saturday
50 | time: "03:30"
51 | timezone: Europe/Berlin
52 | labels:
53 | - 3. to review
54 | - dependencies
55 |
--------------------------------------------------------------------------------
/.github/workflows/appstore-build-publish.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Build and publish app release
10 |
11 | on:
12 | release:
13 | types: [published]
14 |
15 | permissions:
16 | contents: write
17 |
18 | jobs:
19 | build_and_publish:
20 | runs-on: ubuntu-latest
21 |
22 | # Only allowed to be run on nextcloud-releases repositories
23 | if: ${{ github.repository_owner == 'nextcloud-releases' }}
24 |
25 | steps:
26 | - name: Check actor permission
27 | uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v3.0
28 | with:
29 | require: write
30 |
31 | - name: Set app env
32 | run: |
33 | # Split and keep last
34 | echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
35 | echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
36 |
37 | - name: Checkout
38 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39 | with:
40 | persist-credentials: false
41 | path: ${{ env.APP_NAME }}
42 |
43 | - name: Get app version number
44 | id: app-version
45 | uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # master
46 | with:
47 | filename: ${{ env.APP_NAME }}/appinfo/info.xml
48 | expression: "//info//version/text()"
49 |
50 | - name: Validate app version against tag
51 | run: |
52 | [ "${{ env.APP_VERSION }}" = "v${{ fromJSON(steps.app-version.outputs.result).version }}" ]
53 |
54 | - name: Get appinfo data
55 | id: appinfo
56 | uses: skjnldsv/xpath-action@f5b036e9d973f42c86324833fd00be90665fbf77 # master
57 | with:
58 | filename: ${{ env.APP_NAME }}/appinfo/info.xml
59 | expression: "//info//dependencies//nextcloud/@min-version"
60 |
61 | - name: Read package.json node and npm engines version
62 | uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
63 | id: versions
64 | # Continue if no package.json
65 | continue-on-error: true
66 | with:
67 | path: ${{ env.APP_NAME }}
68 | fallbackNode: '^20'
69 | fallbackNpm: '^10'
70 |
71 | - name: Set up node ${{ steps.versions.outputs.nodeVersion }}
72 | # Skip if no package.json
73 | if: ${{ steps.versions.outputs.nodeVersion }}
74 | uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
75 | with:
76 | node-version: ${{ steps.versions.outputs.nodeVersion }}
77 |
78 | - name: Set up npm ${{ steps.versions.outputs.npmVersion }}
79 | # Skip if no package.json
80 | if: ${{ steps.versions.outputs.npmVersion }}
81 | run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
82 |
83 | - name: Get php version
84 | id: php-versions
85 | uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
86 | with:
87 | filename: ${{ env.APP_NAME }}/appinfo/info.xml
88 |
89 | - name: Set up php ${{ steps.php-versions.outputs.php-min }}
90 | uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
91 | with:
92 | php-version: ${{ steps.php-versions.outputs.php-min }}
93 | coverage: none
94 | env:
95 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 |
97 | - name: Check composer.json
98 | id: check_composer
99 | uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
100 | with:
101 | files: "${{ env.APP_NAME }}/composer.json"
102 |
103 | - name: Install composer dependencies
104 | if: steps.check_composer.outputs.files_exists == 'true'
105 | run: |
106 | cd ${{ env.APP_NAME }}
107 | composer install --no-dev
108 |
109 | - name: Build ${{ env.APP_NAME }}
110 | # Skip if no package.json
111 | if: ${{ steps.versions.outputs.nodeVersion }}
112 | env:
113 | CYPRESS_INSTALL_BINARY: 0
114 | run: |
115 | cd ${{ env.APP_NAME }}
116 | npm ci
117 | npm run build --if-present
118 |
119 | - name: Check Krankerl config
120 | id: krankerl
121 | uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
122 | with:
123 | files: ${{ env.APP_NAME }}/krankerl.toml
124 |
125 | - name: Install Krankerl
126 | if: steps.krankerl.outputs.files_exists == 'true'
127 | run: |
128 | wget https://github.com/ChristophWurst/krankerl/releases/download/v0.14.0/krankerl_0.14.0_amd64.deb
129 | sudo dpkg -i krankerl_0.14.0_amd64.deb
130 |
131 | - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with krankerl
132 | if: steps.krankerl.outputs.files_exists == 'true'
133 | run: |
134 | cd ${{ env.APP_NAME }}
135 | krankerl package
136 |
137 | - name: Package ${{ env.APP_NAME }} ${{ env.APP_VERSION }} with makefile
138 | if: steps.krankerl.outputs.files_exists != 'true'
139 | run: |
140 | cd ${{ env.APP_NAME }}
141 | make appstore
142 |
143 | - name: Checkout server ${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}
144 | continue-on-error: true
145 | id: server-checkout
146 | run: |
147 | NCVERSION='${{ fromJSON(steps.appinfo.outputs.result).nextcloud.min-version }}'
148 | wget --quiet https://download.nextcloud.com/server/releases/latest-$NCVERSION.zip
149 | unzip latest-$NCVERSION.zip
150 |
151 | - name: Checkout server master fallback
152 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
153 | if: ${{ steps.server-checkout.outcome != 'success' }}
154 | with:
155 | persist-credentials: false
156 | submodules: true
157 | repository: nextcloud/server
158 | path: nextcloud
159 |
160 | - name: Sign app
161 | run: |
162 | # Extracting release
163 | cd ${{ env.APP_NAME }}/build/artifacts
164 | tar -xvf ${{ env.APP_NAME }}.tar.gz
165 | cd ../../../
166 | # Setting up keys
167 | echo '${{ secrets.APP_PRIVATE_KEY }}' > ${{ env.APP_NAME }}.key
168 | wget --quiet "https://github.com/nextcloud/app-certificate-requests/raw/master/${{ env.APP_NAME }}/${{ env.APP_NAME }}.crt"
169 | # Signing
170 | php nextcloud/occ integrity:sign-app --privateKey=../${{ env.APP_NAME }}.key --certificate=../${{ env.APP_NAME }}.crt --path=../${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}
171 | # Rebuilding archive
172 | cd ${{ env.APP_NAME }}/build/artifacts
173 | tar -zcvf ${{ env.APP_NAME }}.tar.gz ${{ env.APP_NAME }}
174 |
175 | - name: Attach tarball to github release
176 | uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2
177 | id: attach_to_release
178 | with:
179 | repo_token: ${{ secrets.GITHUB_TOKEN }}
180 | file: ${{ env.APP_NAME }}/build/artifacts/${{ env.APP_NAME }}.tar.gz
181 | asset_name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}.tar.gz
182 | tag: ${{ github.ref }}
183 | overwrite: true
184 |
185 | - name: Upload app to Nextcloud appstore
186 | uses: nextcloud-releases/nextcloud-appstore-push-action@a011fe619bcf6e77ddebc96f9908e1af4071b9c1 # v1
187 | with:
188 | app_name: ${{ env.APP_NAME }}
189 | appstore_token: ${{ secrets.APPSTORE_TOKEN }}
190 | download_url: ${{ steps.attach_to_release.outputs.browser_download_url }}
191 | app_private_key: ${{ secrets.APP_PRIVATE_KEY }}
192 |
--------------------------------------------------------------------------------
/.github/workflows/block-unconventional-commits.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Block unconventional commits
10 |
11 | on:
12 | pull_request:
13 | types: [opened, ready_for_review, reopened, synchronize]
14 |
15 | permissions:
16 | contents: read
17 |
18 | concurrency:
19 | group: block-unconventional-commits-${{ github.head_ref || github.run_id }}
20 | cancel-in-progress: true
21 |
22 | jobs:
23 | block-unconventional-commits:
24 | name: Block unconventional commits
25 |
26 | runs-on: ubuntu-latest-low
27 |
28 | steps:
29 | - name: Checkout
30 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31 | with:
32 | persist-credentials: false
33 |
34 | - uses: webiny/action-conventional-commits@8bc41ff4e7d423d56fa4905f6ff79209a78776c7 # v1.3.0
35 | with:
36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 |
--------------------------------------------------------------------------------
/.github/workflows/dependabot-approve-merge.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Dependabot
10 |
11 | on:
12 | pull_request_target: # zizmor: ignore[dangerous-triggers]
13 | branches:
14 | - main
15 | - master
16 | - stable*
17 |
18 | permissions:
19 | contents: read
20 |
21 | concurrency:
22 | group: dependabot-approve-merge-${{ github.head_ref || github.run_id }}
23 | cancel-in-progress: true
24 |
25 | jobs:
26 | auto-approve-merge:
27 | if: github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'renovate[bot]'
28 | runs-on: ubuntu-latest-low
29 | permissions:
30 | # for hmarr/auto-approve-action to approve PRs
31 | pull-requests: write
32 |
33 | steps:
34 | - name: Disabled on forks
35 | if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
36 | run: |
37 | echo 'Can not approve PRs from forks'
38 | exit 1
39 |
40 | # GitHub actions bot approve
41 | - uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
42 | with:
43 | github-token: ${{ secrets.GITHUB_TOKEN }}
44 |
45 | # Nextcloud bot approve and merge request
46 | - uses: ahmadnassri/action-dependabot-auto-merge@45fc124d949b19b6b8bf6645b6c9d55f4f9ac61a # v2
47 | with:
48 | target: minor
49 | github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}
50 |
--------------------------------------------------------------------------------
/.github/workflows/fixup.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Block fixup and squash commits
10 |
11 | on:
12 | pull_request:
13 | types: [opened, ready_for_review, reopened, synchronize]
14 |
15 | permissions:
16 | contents: read
17 |
18 | concurrency:
19 | group: fixup-${{ github.head_ref || github.run_id }}
20 | cancel-in-progress: true
21 |
22 | jobs:
23 | commit-message-check:
24 | if: github.event.pull_request.draft == false
25 |
26 | permissions:
27 | pull-requests: write
28 | name: Block fixup and squash commits
29 |
30 | runs-on: ubuntu-latest-low
31 |
32 | steps:
33 | - name: Run check
34 | uses: skjnldsv/block-fixup-merge-action@c138ea99e45e186567b64cf065ce90f7158c236a # v2
35 | with:
36 | repo-token: ${{ secrets.GITHUB_TOKEN }}
37 |
--------------------------------------------------------------------------------
/.github/workflows/lint-info-xml.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Lint info.xml
10 |
11 | on: pull_request
12 |
13 | permissions:
14 | contents: read
15 |
16 | concurrency:
17 | group: lint-info-xml-${{ github.head_ref || github.run_id }}
18 | cancel-in-progress: true
19 |
20 | jobs:
21 | xml-linters:
22 | runs-on: ubuntu-latest-low
23 |
24 | name: info.xml lint
25 | steps:
26 | - name: Checkout
27 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28 | with:
29 | persist-credentials: false
30 |
31 | - name: Download schema
32 | run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd
33 |
34 | - name: Lint info.xml
35 | uses: ChristophWurst/xmllint-action@36f2a302f84f8c83fceea0b9c59e1eb4a616d3c1 # v1.2
36 | with:
37 | xml-file: ./appinfo/info.xml
38 | xml-schema-file: ./info.xsd
39 |
--------------------------------------------------------------------------------
/.github/workflows/lint-php-cs.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Lint php-cs
10 |
11 | on: pull_request
12 |
13 | permissions:
14 | contents: read
15 |
16 | concurrency:
17 | group: lint-php-cs-${{ github.head_ref || github.run_id }}
18 | cancel-in-progress: true
19 |
20 | jobs:
21 | lint:
22 | runs-on: ubuntu-latest
23 |
24 | name: php-cs
25 |
26 | steps:
27 | - name: Checkout
28 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29 | with:
30 | persist-credentials: false
31 |
32 | - name: Get php version
33 | id: versions
34 | uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
35 |
36 | - name: Set up php${{ steps.versions.outputs.php-min }}
37 | uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
38 | with:
39 | php-version: ${{ steps.versions.outputs.php-min }}
40 | extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
41 | coverage: none
42 | ini-file: development
43 | env:
44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 |
46 | - name: Install dependencies
47 | run: |
48 | composer remove nextcloud/ocp --dev --no-scripts
49 | composer i
50 |
51 | - name: Lint
52 | run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
53 |
--------------------------------------------------------------------------------
/.github/workflows/lint-php.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Lint php
10 |
11 | on: pull_request
12 |
13 | permissions:
14 | contents: read
15 |
16 | concurrency:
17 | group: lint-php-${{ github.head_ref || github.run_id }}
18 | cancel-in-progress: true
19 |
20 | jobs:
21 | matrix:
22 | runs-on: ubuntu-latest-low
23 | outputs:
24 | php-versions: ${{ steps.versions.outputs.php-versions }}
25 | steps:
26 | - name: Checkout app
27 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28 | with:
29 | persist-credentials: false
30 |
31 | - name: Get version matrix
32 | id: versions
33 | uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.0.0
34 |
35 | php-lint:
36 | runs-on: ubuntu-latest
37 | needs: matrix
38 | strategy:
39 | matrix:
40 | php-versions: ${{fromJson(needs.matrix.outputs.php-versions)}}
41 |
42 | name: php-lint
43 |
44 | steps:
45 | - name: Checkout
46 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47 | with:
48 | persist-credentials: false
49 |
50 | - name: Set up php ${{ matrix.php-versions }}
51 | uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
52 | with:
53 | php-version: ${{ matrix.php-versions }}
54 | extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
55 | coverage: none
56 | ini-file: development
57 | env:
58 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 |
60 | - name: Lint
61 | run: composer run lint
62 |
63 | summary:
64 | permissions:
65 | contents: none
66 | runs-on: ubuntu-latest-low
67 | needs: php-lint
68 |
69 | if: always()
70 |
71 | name: php-lint-summary
72 |
73 | steps:
74 | - name: Summary status
75 | run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi
76 |
--------------------------------------------------------------------------------
/.github/workflows/pr-feedback.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 |
6 | # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-FileCopyrightText: 2023 Marcel Klehr
8 | # SPDX-FileCopyrightText: 2023 Joas Schilling <213943+nickvergessen@users.noreply.github.com>
9 | # SPDX-FileCopyrightText: 2023 Daniel Kesselberg
10 | # SPDX-FileCopyrightText: 2023 Florian Steffens
11 | # SPDX-License-Identifier: MIT
12 |
13 | name: 'Ask for feedback on PRs'
14 | on:
15 | schedule:
16 | - cron: '30 1 * * *'
17 |
18 | permissions:
19 | contents: read
20 | pull-requests: write
21 |
22 | jobs:
23 | pr-feedback:
24 | if: ${{ github.repository_owner == 'nextcloud' }}
25 | runs-on: ubuntu-latest
26 | steps:
27 | - name: The get-github-handles-from-website action
28 | uses: marcelklehr/get-github-handles-from-website-action@06b2239db0a48fe1484ba0bfd966a3ab81a08308 # v1.0.1
29 | id: scrape
30 | with:
31 | website: 'https://nextcloud.com/team/'
32 |
33 | - name: Get blocklist
34 | id: blocklist
35 | run: |
36 | blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -)
37 | echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT"
38 |
39 | - uses: nextcloud/pr-feedback-action@1883b38a033fb16f576875e0cf45f98b857655c4 # main
40 | with:
41 | feedback-message: |
42 | Hello there,
43 | Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.
44 |
45 | We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.
46 |
47 | Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6
48 |
49 | Thank you for contributing to Nextcloud and we hope to hear from you soon!
50 |
51 | (If you believe you should not receive this message, you can add yourself to the [blocklist](https://github.com/nextcloud/.github/blob/master/non-community-usernames.txt).)
52 | days-before-feedback: 14
53 | start-date: '2024-04-30'
54 | exempt-authors: '${{ steps.blocklist.outputs.blocklist }},${{ steps.scrape.outputs.users }}'
55 | exempt-bots: true
56 |
--------------------------------------------------------------------------------
/.github/workflows/psalm.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Static analysis
10 |
11 | on: pull_request
12 |
13 | concurrency:
14 | group: psalm-${{ github.head_ref || github.run_id }}
15 | cancel-in-progress: true
16 |
17 | permissions:
18 | contents: read
19 |
20 | jobs:
21 | static-analysis:
22 | runs-on: ubuntu-latest
23 |
24 | name: static-psalm-analysis
25 | steps:
26 | - name: Checkout
27 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28 | with:
29 | persist-credentials: false
30 |
31 | - name: Get php version
32 | id: versions
33 | uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
34 |
35 | - name: Check enforcement of minimum PHP version ${{ steps.versions.outputs.php-min }} in psalm.xml
36 | run: grep 'phpVersion="${{ steps.versions.outputs.php-min }}' psalm.xml
37 |
38 | - name: Set up php${{ steps.versions.outputs.php-available }}
39 | uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
40 | with:
41 | php-version: ${{ steps.versions.outputs.php-available }}
42 | extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
43 | coverage: none
44 | ini-file: development
45 | # Temporary workaround for missing pcntl_* in PHP 8.3
46 | ini-values: disable_functions=
47 | env:
48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 |
50 | - name: Install dependencies
51 | run: |
52 | composer remove nextcloud/ocp --dev --no-scripts
53 | composer i
54 |
55 | - name: Install nextcloud/ocp
56 | run: composer require --dev nextcloud/ocp:dev-${{ steps.versions.outputs.branches-max }} --ignore-platform-reqs --with-dependencies
57 |
58 | - name: Run coding standards check
59 | run: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github
60 |
--------------------------------------------------------------------------------
/.github/workflows/reuse.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 |
6 | # SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V.
7 | #
8 | # SPDX-License-Identifier: CC0-1.0
9 |
10 | name: REUSE Compliance Check
11 |
12 | on: [pull_request]
13 |
14 | permissions:
15 | contents: read
16 |
17 | jobs:
18 | reuse-compliance-check:
19 | runs-on: ubuntu-latest-low
20 | steps:
21 | - name: Checkout
22 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23 | with:
24 | persist-credentials: false
25 |
26 | - name: REUSE Compliance Check
27 | uses: fsfe/reuse-action@bb774aa972c2a89ff34781233d275075cbddf542 # v5.0.0
28 |
--------------------------------------------------------------------------------
/.github/workflows/update-nextcloud-ocp-approve-merge.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Auto approve nextcloud/ocp
10 |
11 | on:
12 | pull_request_target: # zizmor: ignore[dangerous-triggers]
13 | branches:
14 | - main
15 | - master
16 | - stable*
17 |
18 | permissions:
19 | contents: read
20 |
21 | concurrency:
22 | group: update-nextcloud-ocp-approve-merge-${{ github.head_ref || github.run_id }}
23 | cancel-in-progress: true
24 |
25 | jobs:
26 | auto-approve-merge:
27 | if: github.actor == 'nextcloud-command'
28 | runs-on: ubuntu-latest-low
29 | permissions:
30 | # for hmarr/auto-approve-action to approve PRs
31 | pull-requests: write
32 | # for alexwilson/enable-github-automerge-action to approve PRs
33 | contents: write
34 |
35 | steps:
36 | - name: Disabled on forks
37 | if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
38 | run: |
39 | echo 'Can not approve PRs from forks'
40 | exit 1
41 |
42 | - uses: mdecoleman/pr-branch-name@55795d86b4566d300d237883103f052125cc7508 # v3.0.0
43 | id: branchname
44 | with:
45 | repo-token: ${{ secrets.GITHUB_TOKEN }}
46 |
47 | # GitHub actions bot approve
48 | - uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
49 | if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp')
50 | with:
51 | github-token: ${{ secrets.GITHUB_TOKEN }}
52 |
53 | # Enable GitHub auto merge
54 | - name: Auto merge
55 | uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # v2.0.0
56 | if: startsWith(steps.branchname.outputs.branch, 'automated/noid/') && endsWith(steps.branchname.outputs.branch, 'update-nextcloud-ocp')
57 | with:
58 | github-token: ${{ secrets.GITHUB_TOKEN }}
59 |
--------------------------------------------------------------------------------
/.github/workflows/update-nextcloud-ocp.yml:
--------------------------------------------------------------------------------
1 | # This workflow is provided via the organization template repository
2 | #
3 | # https://github.com/nextcloud/.github
4 | # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5 | #
6 | # SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
7 | # SPDX-License-Identifier: MIT
8 |
9 | name: Update nextcloud/ocp
10 |
11 | on:
12 | workflow_dispatch:
13 | schedule:
14 | - cron: "5 2 * * 0"
15 |
16 | permissions:
17 | contents: read
18 |
19 | jobs:
20 | update-nextcloud-ocp:
21 | runs-on: ubuntu-latest
22 |
23 | strategy:
24 | fail-fast: false
25 | matrix:
26 | branches: ['main', 'master', 'stable31', 'stable30']
27 |
28 | name: update-nextcloud-ocp-${{ matrix.branches }}
29 |
30 | steps:
31 | - id: checkout
32 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33 | with:
34 | persist-credentials: false
35 | ref: ${{ matrix.branches }}
36 | submodules: true
37 | continue-on-error: true
38 |
39 | - name: Set up php8.2
40 | if: steps.checkout.outcome == 'success'
41 | uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
42 | with:
43 | php-version: 8.2
44 | # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
45 | extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
46 | coverage: none
47 | env:
48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 |
50 | - name: Read codeowners
51 | if: steps.checkout.outcome == 'success'
52 | id: codeowners
53 | run: |
54 | grep '/appinfo/info.xml' .github/CODEOWNERS | cut -f 2- -d ' ' | xargs | awk '{ print "codeowners="$0 }' >> $GITHUB_OUTPUT
55 | continue-on-error: true
56 |
57 | - name: Composer install
58 | if: steps.checkout.outcome == 'success'
59 | run: composer install
60 |
61 | - name: Composer update nextcloud/ocp
62 | id: update_branch
63 | if: ${{ steps.checkout.outcome == 'success' && matrix.branches != 'main' }}
64 | run: composer require --dev 'nextcloud/ocp:dev-${{ matrix.branches }}'
65 |
66 | - name: Raise on issue on failure
67 | uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0
68 | if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_branch.conclusion == 'failure' }}
69 | with:
70 | token: ${{ secrets.GITHUB_TOKEN }}
71 | title: 'Failed to update nextcloud/ocp package on branch ${{ matrix.branches }}'
72 | body: 'Please check the output of the GitHub action and manually resolve the issues ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} ${{ steps.codeowners.outputs.codeowners }}'
73 |
74 | - name: Composer update nextcloud/ocp
75 | id: update_main
76 | if: ${{ steps.checkout.outcome == 'success' && matrix.branches == 'main' }}
77 | run: composer require --dev nextcloud/ocp:dev-master
78 |
79 | - name: Raise on issue on failure
80 | uses: dacbd/create-issue-action@cdb57ab6ff8862aa09fee2be6ba77a59581921c2 # v2.0.0
81 | if: ${{ steps.checkout.outcome == 'success' && failure() && steps.update_main.conclusion == 'failure' }}
82 | with:
83 | token: ${{ secrets.GITHUB_TOKEN }}
84 | title: 'Failed to update nextcloud/ocp package on branch ${{ matrix.branches }}'
85 | body: 'Please check the output of the GitHub action and manually resolve the issues ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} ${{ steps.codeowners.outputs.codeowners }}'
86 |
87 | - name: Reset checkout 3rdparty
88 | if: steps.checkout.outcome == 'success'
89 | run: |
90 | git clean -f 3rdparty
91 | git checkout 3rdparty
92 | continue-on-error: true
93 |
94 | - name: Reset checkout vendor
95 | if: steps.checkout.outcome == 'success'
96 | run: |
97 | git clean -f vendor
98 | git checkout vendor
99 | continue-on-error: true
100 |
101 | - name: Reset checkout vendor-bin
102 | if: steps.checkout.outcome == 'success'
103 | run: |
104 | git clean -f vendor-bin
105 | git checkout vendor-bin
106 | continue-on-error: true
107 |
108 | - name: Create Pull Request
109 | if: steps.checkout.outcome == 'success'
110 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
111 | with:
112 | token: ${{ secrets.COMMAND_BOT_PAT }}
113 | commit-message: 'chore(dev-deps): Bump nextcloud/ocp package'
114 | committer: GitHub
115 | author: nextcloud-command
116 | signoff: true
117 | branch: 'automated/noid/${{ matrix.branches }}-update-nextcloud-ocp'
118 | title: '[${{ matrix.branches }}] Update nextcloud/ocp dependency'
119 | body: |
120 | Auto-generated update of [nextcloud/ocp](https://github.com/nextcloud-deps/ocp/) dependency
121 | labels: |
122 | dependencies
123 | 3. to review
124 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
2 | # SPDX-License-Identifier: AGPL-3.0-or-later
3 | /.php-cs-fixer.cache
4 | /.php_cs.cache
5 | /tests/.phpunit.result.cache
6 | /vendor
7 | /vendor-bin/**/vendor/
8 |
--------------------------------------------------------------------------------
/.php-cs-fixer.dist.php:
--------------------------------------------------------------------------------
1 | getFinder()
17 | ->notPath('build')
18 | ->notPath('l10n')
19 | ->notPath('node_modules')
20 | ->notPath('src')
21 | ->notPath('vendor')
22 | ->in(__DIR__);
23 | return $config;
24 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 |
5 | # Authors
6 |
7 | - Andy Scherzinger
8 | - Anna Larch
9 | - Avinash Gusain
10 | - Christoph Wurst
11 | - Côme Chilliet <91878298+come-nc@users.noreply.github.com>
12 | - Damien Norris
13 | - Daniel Kesselberg
14 | - Joas Schilling
15 | - John Molakvoæ
16 | - Morris Jobke
17 | - Pietro Marini <85954408+pmarini-nc@users.noreply.github.com>
18 | - Robin Appelman
19 | - Roeland Jago Douma
20 | - Vincent Petry
21 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
5 | # Changelog
6 | All notable changes to this project will be documented in this file.
7 |
8 | ## 1.14.0 - 2024-09-15
9 |
10 | Many thanks to https://github.com/jmcclelland
11 |
12 | ### Added
13 | - Compatibility with Nextcloud 30
14 |
15 | ### Fixed
16 | - fix: ensure the userid exist before adding data to report (https://github.com/nextcloud/user_usage_report/pull/281)
17 | - fix: handle missing display name for single user reports (https://github.com/nextcloud/user_usage_report/pull/282)
18 |
19 | ## 1.13.0 - 2024-05-22
20 |
21 | ### Added
22 | - Compatibility with Nextcloud 29
23 |
24 | ## 1.12.0 - 2023-11-27
25 | ### Added
26 | - Compatibility with Nextcloud 28
27 |
28 | ### Fixed
29 | - check if array offset exists before accessing it (https://github.com/nextcloud/user_usage_report/pull/183)
30 |
31 | ### Changed
32 | - listen to typed filesystem events (https://github.com/nextcloud/user_usage_report/pull/175)
33 |
34 | ## 1.11.1 - 2023-11-15
35 | ### Fixed
36 | - check if array offset exists before accessing it (https://github.com/nextcloud/user_usage_report/pull/183)
37 |
38 | ## 1.11.0 – 2023-03-03
39 | ### Added
40 | - Compatibility with Nextcloud 27
41 |
42 | ## 1.10.0 – 2023-02-17
43 | ### Added
44 | - Compatibility with Nextcloud 26
45 |
46 | ## 1.9.0 – 2022-10-24
47 | ### Added
48 | - Added an option to pipe the output to a file
49 | - Added an option to save the output as JSON
50 |
51 | ### Changed
52 | - Require Nextcloud 25
53 |
54 | ### Fixed
55 | - Proper error handling when a user does not exist
56 |
57 | ## 1.8.0 – 2022-04-11
58 | ### Changed
59 | - Nextcloud 24 support
60 |
61 | ## 1.7.0 – 2021-11-24
62 | ### Changed
63 | - Nextcloud 23 support
64 |
65 | ## 1.6.0 – 2021-07-06
66 | ### Changed
67 | - Nextcloud 22 support
68 |
69 | ## 1.5.0 – 2021-01-08
70 | ### Changed
71 | - Nextcloud 21 support
72 |
73 | ## 1.4.2 – 2020-09-04
74 | ### Changed
75 | - Nextcloud 20 support
76 |
77 | ## 1.3.3 – 2020-07-07
78 | ### Fixed
79 | - Fix increment query for Postgres
80 | [#47](https://github.com/nextcloud/user_usage_report/pull/47)
81 |
82 | ## 1.2.3 – 2020-07-07
83 | ### Fixed
84 | - Fix increment query for Postgres
85 | [#48](https://github.com/nextcloud/user_usage_report/pull/48)
86 |
87 | ## 1.1.5 – 2020-07-07
88 | ### Fixed
89 | - Fix increment query for Postgres
90 | [#49](https://github.com/nextcloud/user_usage_report/pull/49)
91 |
92 | ## 1.3.2 – 2020-06-30
93 | ### Fixed
94 | - Improve migration performance
95 | [#41](https://github.com/nextcloud/user_usage_report/pull/41)
96 |
97 | ## 1.2.2 – 2020-06-30
98 | ### Fixed
99 | - Improve migration performance
100 | [#42](https://github.com/nextcloud/user_usage_report/pull/42)
101 |
102 | ## 1.1.4 – 2020-06-30
103 | ### Fixed
104 | - Improve migration performance
105 | [#43](https://github.com/nextcloud/user_usage_report/pull/43)
106 |
107 | ## 1.3.1 – 2020-06-29
108 | ### Fixed
109 | - Fix issue with database table not having a primary key
110 | [#36](https://github.com/nextcloud/user_usage_report/pull/36)
111 |
112 | ## 1.2.1 – 2020-06-29
113 | ### Fixed
114 | - Fix issue with database table not having a primary key
115 | [#37](https://github.com/nextcloud/user_usage_report/pull/37)
116 |
117 | ## 1.1.3 – 2020-06-29
118 | ### Fixed
119 | - Fix issue with database table not having a primary key
120 | [#38](https://github.com/nextcloud/user_usage_report/pull/38)
121 |
122 | ## 1.3.0 – 2020-06-03
123 | ### Changed
124 | - Nextcloud 19 support
125 |
126 | ## 1.2.0 – 2020-01-17
127 | ### Changed
128 | - Nextcloud 18 support
129 |
130 | ## 1.1.2 – 2019-07-04
131 | ### Changed
132 | - Nextcloud 17 support
133 |
134 | ## 1.1.1 – 2018-11-28
135 | ### Changed
136 | - Nextcloud 16 support
137 |
138 | ## 1.1.0 – 2018-08-06
139 | ### Changed
140 | - Nextcloud 15 support
141 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for
11 | software and other kinds of works, specifically designed to ensure
12 | cooperation with the community in the case of network server software.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | our General Public Licenses are intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users.
19 |
20 | When we speak of free software, we are referring to freedom, not
21 | price. Our General Public Licenses are designed to make sure that you
22 | have the freedom to distribute copies of free software (and charge for
23 | them if you wish), that you receive source code or can get it if you
24 | want it, that you can change the software or use pieces of it in new
25 | free programs, and that you know you can do these things.
26 |
27 | Developers that use our General Public Licenses protect your rights
28 | with two steps: (1) assert copyright on the software, and (2) offer
29 | you this License which gives you legal permission to copy, distribute
30 | and/or modify the software.
31 |
32 | A secondary benefit of defending all users' freedom is that
33 | improvements made in alternate versions of the program, if they
34 | receive widespread use, become available for other developers to
35 | incorporate. Many developers of free software are heartened and
36 | encouraged by the resulting cooperation. However, in the case of
37 | software used on network servers, this result may fail to come about.
38 | The GNU General Public License permits making a modified version and
39 | letting the public access it on a server without ever releasing its
40 | source code to the public.
41 |
42 | The GNU Affero General Public License is designed specifically to
43 | ensure that, in such cases, the modified source code becomes available
44 | to the community. It requires the operator of a network server to
45 | provide the source code of the modified version running there to the
46 | users of that server. Therefore, public use of a modified version, on
47 | a publicly accessible server, gives the public access to the source
48 | code of the modified version.
49 |
50 | An older license, called the Affero General Public License and
51 | published by Affero, was designed to accomplish similar goals. This is
52 | a different license, not a version of the Affero GPL, but Affero has
53 | released a new version of the Affero GPL which permits relicensing under
54 | this license.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | TERMS AND CONDITIONS
60 |
61 | 0. Definitions.
62 |
63 | "This License" refers to version 3 of the GNU Affero General Public License.
64 |
65 | "Copyright" also means copyright-like laws that apply to other kinds of
66 | works, such as semiconductor masks.
67 |
68 | "The Program" refers to any copyrightable work licensed under this
69 | License. Each licensee is addressed as "you". "Licensees" and
70 | "recipients" may be individuals or organizations.
71 |
72 | To "modify" a work means to copy from or adapt all or part of the work
73 | in a fashion requiring copyright permission, other than the making of an
74 | exact copy. The resulting work is called a "modified version" of the
75 | earlier work or a work "based on" the earlier work.
76 |
77 | A "covered work" means either the unmodified Program or a work based
78 | on the Program.
79 |
80 | To "propagate" a work means to do anything with it that, without
81 | permission, would make you directly or secondarily liable for
82 | infringement under applicable copyright law, except executing it on a
83 | computer or modifying a private copy. Propagation includes copying,
84 | distribution (with or without modification), making available to the
85 | public, and in some countries other activities as well.
86 |
87 | To "convey" a work means any kind of propagation that enables other
88 | parties to make or receive copies. Mere interaction with a user through
89 | a computer network, with no transfer of a copy, is not conveying.
90 |
91 | An interactive user interface displays "Appropriate Legal Notices"
92 | to the extent that it includes a convenient and prominently visible
93 | feature that (1) displays an appropriate copyright notice, and (2)
94 | tells the user that there is no warranty for the work (except to the
95 | extent that warranties are provided), that licensees may convey the
96 | work under this License, and how to view a copy of this License. If
97 | the interface presents a list of user commands or options, such as a
98 | menu, a prominent item in the list meets this criterion.
99 |
100 | 1. Source Code.
101 |
102 | The "source code" for a work means the preferred form of the work
103 | for making modifications to it. "Object code" means any non-source
104 | form of a work.
105 |
106 | A "Standard Interface" means an interface that either is an official
107 | standard defined by a recognized standards body, or, in the case of
108 | interfaces specified for a particular programming language, one that
109 | is widely used among developers working in that language.
110 |
111 | The "System Libraries" of an executable work include anything, other
112 | than the work as a whole, that (a) is included in the normal form of
113 | packaging a Major Component, but which is not part of that Major
114 | Component, and (b) serves only to enable use of the work with that
115 | Major Component, or to implement a Standard Interface for which an
116 | implementation is available to the public in source code form. A
117 | "Major Component", in this context, means a major essential component
118 | (kernel, window system, and so on) of the specific operating system
119 | (if any) on which the executable work runs, or a compiler used to
120 | produce the work, or an object code interpreter used to run it.
121 |
122 | The "Corresponding Source" for a work in object code form means all
123 | the source code needed to generate, install, and (for an executable
124 | work) run the object code and to modify the work, including scripts to
125 | control those activities. However, it does not include the work's
126 | System Libraries, or general-purpose tools or generally available free
127 | programs which are used unmodified in performing those activities but
128 | which are not part of the work. For example, Corresponding Source
129 | includes interface definition files associated with source files for
130 | the work, and the source code for shared libraries and dynamically
131 | linked subprograms that the work is specifically designed to require,
132 | such as by intimate data communication or control flow between those
133 | subprograms and other parts of the work.
134 |
135 | The Corresponding Source need not include anything that users
136 | can regenerate automatically from other parts of the Corresponding
137 | Source.
138 |
139 | The Corresponding Source for a work in source code form is that
140 | same work.
141 |
142 | 2. Basic Permissions.
143 |
144 | All rights granted under this License are granted for the term of
145 | copyright on the Program, and are irrevocable provided the stated
146 | conditions are met. This License explicitly affirms your unlimited
147 | permission to run the unmodified Program. The output from running a
148 | covered work is covered by this License only if the output, given its
149 | content, constitutes a covered work. This License acknowledges your
150 | rights of fair use or other equivalent, as provided by copyright law.
151 |
152 | You may make, run and propagate covered works that you do not
153 | convey, without conditions so long as your license otherwise remains
154 | in force. You may convey covered works to others for the sole purpose
155 | of having them make modifications exclusively for you, or provide you
156 | with facilities for running those works, provided that you comply with
157 | the terms of this License in conveying all material for which you do
158 | not control copyright. Those thus making or running the covered works
159 | for you must do so exclusively on your behalf, under your direction
160 | and control, on terms that prohibit them from making any copies of
161 | your copyrighted material outside their relationship with you.
162 |
163 | Conveying under any other circumstances is permitted solely under
164 | the conditions stated below. Sublicensing is not allowed; section 10
165 | makes it unnecessary.
166 |
167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168 |
169 | No covered work shall be deemed part of an effective technological
170 | measure under any applicable law fulfilling obligations under article
171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172 | similar laws prohibiting or restricting circumvention of such
173 | measures.
174 |
175 | When you convey a covered work, you waive any legal power to forbid
176 | circumvention of technological measures to the extent such circumvention
177 | is effected by exercising rights under this License with respect to
178 | the covered work, and you disclaim any intention to limit operation or
179 | modification of the work as a means of enforcing, against the work's
180 | users, your or third parties' legal rights to forbid circumvention of
181 | technological measures.
182 |
183 | 4. Conveying Verbatim Copies.
184 |
185 | You may convey verbatim copies of the Program's source code as you
186 | receive it, in any medium, provided that you conspicuously and
187 | appropriately publish on each copy an appropriate copyright notice;
188 | keep intact all notices stating that this License and any
189 | non-permissive terms added in accord with section 7 apply to the code;
190 | keep intact all notices of the absence of any warranty; and give all
191 | recipients a copy of this License along with the Program.
192 |
193 | You may charge any price or no price for each copy that you convey,
194 | and you may offer support or warranty protection for a fee.
195 |
196 | 5. Conveying Modified Source Versions.
197 |
198 | You may convey a work based on the Program, or the modifications to
199 | produce it from the Program, in the form of source code under the
200 | terms of section 4, provided that you also meet all of these conditions:
201 |
202 | a) The work must carry prominent notices stating that you modified
203 | it, and giving a relevant date.
204 |
205 | b) The work must carry prominent notices stating that it is
206 | released under this License and any conditions added under section
207 | 7. This requirement modifies the requirement in section 4 to
208 | "keep intact all notices".
209 |
210 | c) You must license the entire work, as a whole, under this
211 | License to anyone who comes into possession of a copy. This
212 | License will therefore apply, along with any applicable section 7
213 | additional terms, to the whole of the work, and all its parts,
214 | regardless of how they are packaged. This License gives no
215 | permission to license the work in any other way, but it does not
216 | invalidate such permission if you have separately received it.
217 |
218 | d) If the work has interactive user interfaces, each must display
219 | Appropriate Legal Notices; however, if the Program has interactive
220 | interfaces that do not display Appropriate Legal Notices, your
221 | work need not make them do so.
222 |
223 | A compilation of a covered work with other separate and independent
224 | works, which are not by their nature extensions of the covered work,
225 | and which are not combined with it such as to form a larger program,
226 | in or on a volume of a storage or distribution medium, is called an
227 | "aggregate" if the compilation and its resulting copyright are not
228 | used to limit the access or legal rights of the compilation's users
229 | beyond what the individual works permit. Inclusion of a covered work
230 | in an aggregate does not cause this License to apply to the other
231 | parts of the aggregate.
232 |
233 | 6. Conveying Non-Source Forms.
234 |
235 | You may convey a covered work in object code form under the terms
236 | of sections 4 and 5, provided that you also convey the
237 | machine-readable Corresponding Source under the terms of this License,
238 | in one of these ways:
239 |
240 | a) Convey the object code in, or embodied in, a physical product
241 | (including a physical distribution medium), accompanied by the
242 | Corresponding Source fixed on a durable physical medium
243 | customarily used for software interchange.
244 |
245 | b) Convey the object code in, or embodied in, a physical product
246 | (including a physical distribution medium), accompanied by a
247 | written offer, valid for at least three years and valid for as
248 | long as you offer spare parts or customer support for that product
249 | model, to give anyone who possesses the object code either (1) a
250 | copy of the Corresponding Source for all the software in the
251 | product that is covered by this License, on a durable physical
252 | medium customarily used for software interchange, for a price no
253 | more than your reasonable cost of physically performing this
254 | conveying of source, or (2) access to copy the
255 | Corresponding Source from a network server at no charge.
256 |
257 | c) Convey individual copies of the object code with a copy of the
258 | written offer to provide the Corresponding Source. This
259 | alternative is allowed only occasionally and noncommercially, and
260 | only if you received the object code with such an offer, in accord
261 | with subsection 6b.
262 |
263 | d) Convey the object code by offering access from a designated
264 | place (gratis or for a charge), and offer equivalent access to the
265 | Corresponding Source in the same way through the same place at no
266 | further charge. You need not require recipients to copy the
267 | Corresponding Source along with the object code. If the place to
268 | copy the object code is a network server, the Corresponding Source
269 | may be on a different server (operated by you or a third party)
270 | that supports equivalent copying facilities, provided you maintain
271 | clear directions next to the object code saying where to find the
272 | Corresponding Source. Regardless of what server hosts the
273 | Corresponding Source, you remain obligated to ensure that it is
274 | available for as long as needed to satisfy these requirements.
275 |
276 | e) Convey the object code using peer-to-peer transmission, provided
277 | you inform other peers where the object code and Corresponding
278 | Source of the work are being offered to the general public at no
279 | charge under subsection 6d.
280 |
281 | A separable portion of the object code, whose source code is excluded
282 | from the Corresponding Source as a System Library, need not be
283 | included in conveying the object code work.
284 |
285 | A "User Product" is either (1) a "consumer product", which means any
286 | tangible personal property which is normally used for personal, family,
287 | or household purposes, or (2) anything designed or sold for incorporation
288 | into a dwelling. In determining whether a product is a consumer product,
289 | doubtful cases shall be resolved in favor of coverage. For a particular
290 | product received by a particular user, "normally used" refers to a
291 | typical or common use of that class of product, regardless of the status
292 | of the particular user or of the way in which the particular user
293 | actually uses, or expects or is expected to use, the product. A product
294 | is a consumer product regardless of whether the product has substantial
295 | commercial, industrial or non-consumer uses, unless such uses represent
296 | the only significant mode of use of the product.
297 |
298 | "Installation Information" for a User Product means any methods,
299 | procedures, authorization keys, or other information required to install
300 | and execute modified versions of a covered work in that User Product from
301 | a modified version of its Corresponding Source. The information must
302 | suffice to ensure that the continued functioning of the modified object
303 | code is in no case prevented or interfered with solely because
304 | modification has been made.
305 |
306 | If you convey an object code work under this section in, or with, or
307 | specifically for use in, a User Product, and the conveying occurs as
308 | part of a transaction in which the right of possession and use of the
309 | User Product is transferred to the recipient in perpetuity or for a
310 | fixed term (regardless of how the transaction is characterized), the
311 | Corresponding Source conveyed under this section must be accompanied
312 | by the Installation Information. But this requirement does not apply
313 | if neither you nor any third party retains the ability to install
314 | modified object code on the User Product (for example, the work has
315 | been installed in ROM).
316 |
317 | The requirement to provide Installation Information does not include a
318 | requirement to continue to provide support service, warranty, or updates
319 | for a work that has been modified or installed by the recipient, or for
320 | the User Product in which it has been modified or installed. Access to a
321 | network may be denied when the modification itself materially and
322 | adversely affects the operation of the network or violates the rules and
323 | protocols for communication across the network.
324 |
325 | Corresponding Source conveyed, and Installation Information provided,
326 | in accord with this section must be in a format that is publicly
327 | documented (and with an implementation available to the public in
328 | source code form), and must require no special password or key for
329 | unpacking, reading or copying.
330 |
331 | 7. Additional Terms.
332 |
333 | "Additional permissions" are terms that supplement the terms of this
334 | License by making exceptions from one or more of its conditions.
335 | Additional permissions that are applicable to the entire Program shall
336 | be treated as though they were included in this License, to the extent
337 | that they are valid under applicable law. If additional permissions
338 | apply only to part of the Program, that part may be used separately
339 | under those permissions, but the entire Program remains governed by
340 | this License without regard to the additional permissions.
341 |
342 | When you convey a copy of a covered work, you may at your option
343 | remove any additional permissions from that copy, or from any part of
344 | it. (Additional permissions may be written to require their own
345 | removal in certain cases when you modify the work.) You may place
346 | additional permissions on material, added by you to a covered work,
347 | for which you have or can give appropriate copyright permission.
348 |
349 | Notwithstanding any other provision of this License, for material you
350 | add to a covered work, you may (if authorized by the copyright holders of
351 | that material) supplement the terms of this License with terms:
352 |
353 | a) Disclaiming warranty or limiting liability differently from the
354 | terms of sections 15 and 16 of this License; or
355 |
356 | b) Requiring preservation of specified reasonable legal notices or
357 | author attributions in that material or in the Appropriate Legal
358 | Notices displayed by works containing it; or
359 |
360 | c) Prohibiting misrepresentation of the origin of that material, or
361 | requiring that modified versions of such material be marked in
362 | reasonable ways as different from the original version; or
363 |
364 | d) Limiting the use for publicity purposes of names of licensors or
365 | authors of the material; or
366 |
367 | e) Declining to grant rights under trademark law for use of some
368 | trade names, trademarks, or service marks; or
369 |
370 | f) Requiring indemnification of licensors and authors of that
371 | material by anyone who conveys the material (or modified versions of
372 | it) with contractual assumptions of liability to the recipient, for
373 | any liability that these contractual assumptions directly impose on
374 | those licensors and authors.
375 |
376 | All other non-permissive additional terms are considered "further
377 | restrictions" within the meaning of section 10. If the Program as you
378 | received it, or any part of it, contains a notice stating that it is
379 | governed by this License along with a term that is a further
380 | restriction, you may remove that term. If a license document contains
381 | a further restriction but permits relicensing or conveying under this
382 | License, you may add to a covered work material governed by the terms
383 | of that license document, provided that the further restriction does
384 | not survive such relicensing or conveying.
385 |
386 | If you add terms to a covered work in accord with this section, you
387 | must place, in the relevant source files, a statement of the
388 | additional terms that apply to those files, or a notice indicating
389 | where to find the applicable terms.
390 |
391 | Additional terms, permissive or non-permissive, may be stated in the
392 | form of a separately written license, or stated as exceptions;
393 | the above requirements apply either way.
394 |
395 | 8. Termination.
396 |
397 | You may not propagate or modify a covered work except as expressly
398 | provided under this License. Any attempt otherwise to propagate or
399 | modify it is void, and will automatically terminate your rights under
400 | this License (including any patent licenses granted under the third
401 | paragraph of section 11).
402 |
403 | However, if you cease all violation of this License, then your
404 | license from a particular copyright holder is reinstated (a)
405 | provisionally, unless and until the copyright holder explicitly and
406 | finally terminates your license, and (b) permanently, if the copyright
407 | holder fails to notify you of the violation by some reasonable means
408 | prior to 60 days after the cessation.
409 |
410 | Moreover, your license from a particular copyright holder is
411 | reinstated permanently if the copyright holder notifies you of the
412 | violation by some reasonable means, this is the first time you have
413 | received notice of violation of this License (for any work) from that
414 | copyright holder, and you cure the violation prior to 30 days after
415 | your receipt of the notice.
416 |
417 | Termination of your rights under this section does not terminate the
418 | licenses of parties who have received copies or rights from you under
419 | this License. If your rights have been terminated and not permanently
420 | reinstated, you do not qualify to receive new licenses for the same
421 | material under section 10.
422 |
423 | 9. Acceptance Not Required for Having Copies.
424 |
425 | You are not required to accept this License in order to receive or
426 | run a copy of the Program. Ancillary propagation of a covered work
427 | occurring solely as a consequence of using peer-to-peer transmission
428 | to receive a copy likewise does not require acceptance. However,
429 | nothing other than this License grants you permission to propagate or
430 | modify any covered work. These actions infringe copyright if you do
431 | not accept this License. Therefore, by modifying or propagating a
432 | covered work, you indicate your acceptance of this License to do so.
433 |
434 | 10. Automatic Licensing of Downstream Recipients.
435 |
436 | Each time you convey a covered work, the recipient automatically
437 | receives a license from the original licensors, to run, modify and
438 | propagate that work, subject to this License. You are not responsible
439 | for enforcing compliance by third parties with this License.
440 |
441 | An "entity transaction" is a transaction transferring control of an
442 | organization, or substantially all assets of one, or subdividing an
443 | organization, or merging organizations. If propagation of a covered
444 | work results from an entity transaction, each party to that
445 | transaction who receives a copy of the work also receives whatever
446 | licenses to the work the party's predecessor in interest had or could
447 | give under the previous paragraph, plus a right to possession of the
448 | Corresponding Source of the work from the predecessor in interest, if
449 | the predecessor has it or can get it with reasonable efforts.
450 |
451 | You may not impose any further restrictions on the exercise of the
452 | rights granted or affirmed under this License. For example, you may
453 | not impose a license fee, royalty, or other charge for exercise of
454 | rights granted under this License, and you may not initiate litigation
455 | (including a cross-claim or counterclaim in a lawsuit) alleging that
456 | any patent claim is infringed by making, using, selling, offering for
457 | sale, or importing the Program or any portion of it.
458 |
459 | 11. Patents.
460 |
461 | A "contributor" is a copyright holder who authorizes use under this
462 | License of the Program or a work on which the Program is based. The
463 | work thus licensed is called the contributor's "contributor version".
464 |
465 | A contributor's "essential patent claims" are all patent claims
466 | owned or controlled by the contributor, whether already acquired or
467 | hereafter acquired, that would be infringed by some manner, permitted
468 | by this License, of making, using, or selling its contributor version,
469 | but do not include claims that would be infringed only as a
470 | consequence of further modification of the contributor version. For
471 | purposes of this definition, "control" includes the right to grant
472 | patent sublicenses in a manner consistent with the requirements of
473 | this License.
474 |
475 | Each contributor grants you a non-exclusive, worldwide, royalty-free
476 | patent license under the contributor's essential patent claims, to
477 | make, use, sell, offer for sale, import and otherwise run, modify and
478 | propagate the contents of its contributor version.
479 |
480 | In the following three paragraphs, a "patent license" is any express
481 | agreement or commitment, however denominated, not to enforce a patent
482 | (such as an express permission to practice a patent or covenant not to
483 | sue for patent infringement). To "grant" such a patent license to a
484 | party means to make such an agreement or commitment not to enforce a
485 | patent against the party.
486 |
487 | If you convey a covered work, knowingly relying on a patent license,
488 | and the Corresponding Source of the work is not available for anyone
489 | to copy, free of charge and under the terms of this License, through a
490 | publicly available network server or other readily accessible means,
491 | then you must either (1) cause the Corresponding Source to be so
492 | available, or (2) arrange to deprive yourself of the benefit of the
493 | patent license for this particular work, or (3) arrange, in a manner
494 | consistent with the requirements of this License, to extend the patent
495 | license to downstream recipients. "Knowingly relying" means you have
496 | actual knowledge that, but for the patent license, your conveying the
497 | covered work in a country, or your recipient's use of the covered work
498 | in a country, would infringe one or more identifiable patents in that
499 | country that you have reason to believe are valid.
500 |
501 | If, pursuant to or in connection with a single transaction or
502 | arrangement, you convey, or propagate by procuring conveyance of, a
503 | covered work, and grant a patent license to some of the parties
504 | receiving the covered work authorizing them to use, propagate, modify
505 | or convey a specific copy of the covered work, then the patent license
506 | you grant is automatically extended to all recipients of the covered
507 | work and works based on it.
508 |
509 | A patent license is "discriminatory" if it does not include within
510 | the scope of its coverage, prohibits the exercise of, or is
511 | conditioned on the non-exercise of one or more of the rights that are
512 | specifically granted under this License. You may not convey a covered
513 | work if you are a party to an arrangement with a third party that is
514 | in the business of distributing software, under which you make payment
515 | to the third party based on the extent of your activity of conveying
516 | the work, and under which the third party grants, to any of the
517 | parties who would receive the covered work from you, a discriminatory
518 | patent license (a) in connection with copies of the covered work
519 | conveyed by you (or copies made from those copies), or (b) primarily
520 | for and in connection with specific products or compilations that
521 | contain the covered work, unless you entered into that arrangement,
522 | or that patent license was granted, prior to 28 March 2007.
523 |
524 | Nothing in this License shall be construed as excluding or limiting
525 | any implied license or other defenses to infringement that may
526 | otherwise be available to you under applicable patent law.
527 |
528 | 12. No Surrender of Others' Freedom.
529 |
530 | If conditions are imposed on you (whether by court order, agreement or
531 | otherwise) that contradict the conditions of this License, they do not
532 | excuse you from the conditions of this License. If you cannot convey a
533 | covered work so as to satisfy simultaneously your obligations under this
534 | License and any other pertinent obligations, then as a consequence you may
535 | not convey it at all. For example, if you agree to terms that obligate you
536 | to collect a royalty for further conveying from those to whom you convey
537 | the Program, the only way you could satisfy both those terms and this
538 | License would be to refrain entirely from conveying the Program.
539 |
540 | 13. Remote Network Interaction; Use with the GNU General Public License.
541 |
542 | Notwithstanding any other provision of this License, if you modify the
543 | Program, your modified version must prominently offer all users
544 | interacting with it remotely through a computer network (if your version
545 | supports such interaction) an opportunity to receive the Corresponding
546 | Source of your version by providing access to the Corresponding Source
547 | from a network server at no charge, through some standard or customary
548 | means of facilitating copying of software. This Corresponding Source
549 | shall include the Corresponding Source for any work covered by version 3
550 | of the GNU General Public License that is incorporated pursuant to the
551 | following paragraph.
552 |
553 | Notwithstanding any other provision of this License, you have
554 | permission to link or combine any covered work with a work licensed
555 | under version 3 of the GNU General Public License into a single
556 | combined work, and to convey the resulting work. The terms of this
557 | License will continue to apply to the part which is the covered work,
558 | but the work with which it is combined will remain governed by version
559 | 3 of the GNU General Public License.
560 |
561 | 14. Revised Versions of this License.
562 |
563 | The Free Software Foundation may publish revised and/or new versions of
564 | the GNU Affero General Public License from time to time. Such new versions
565 | will be similar in spirit to the present version, but may differ in detail to
566 | address new problems or concerns.
567 |
568 | Each version is given a distinguishing version number. If the
569 | Program specifies that a certain numbered version of the GNU Affero General
570 | Public License "or any later version" applies to it, you have the
571 | option of following the terms and conditions either of that numbered
572 | version or of any later version published by the Free Software
573 | Foundation. If the Program does not specify a version number of the
574 | GNU Affero General Public License, you may choose any version ever published
575 | by the Free Software Foundation.
576 |
577 | If the Program specifies that a proxy can decide which future
578 | versions of the GNU Affero General Public License can be used, that proxy's
579 | public statement of acceptance of a version permanently authorizes you
580 | to choose that version for the Program.
581 |
582 | Later license versions may give you additional or different
583 | permissions. However, no additional obligations are imposed on any
584 | author or copyright holder as a result of your choosing to follow a
585 | later version.
586 |
587 | 15. Disclaimer of Warranty.
588 |
589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597 |
598 | 16. Limitation of Liability.
599 |
600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608 | SUCH DAMAGES.
609 |
610 | 17. Interpretation of Sections 15 and 16.
611 |
612 | If the disclaimer of warranty and limitation of liability provided
613 | above cannot be given local legal effect according to their terms,
614 | reviewing courts shall apply local law that most closely approximates
615 | an absolute waiver of all civil liability in connection with the
616 | Program, unless a warranty or assumption of liability accompanies a
617 | copy of the Program in return for a fee.
618 |
619 | END OF TERMS AND CONDITIONS
620 |
621 | How to Apply These Terms to Your New Programs
622 |
623 | If you develop a new program, and you want it to be of the greatest
624 | possible use to the public, the best way to achieve this is to make it
625 | free software which everyone can redistribute and change under these terms.
626 |
627 | To do so, attach the following notices to the program. It is safest
628 | to attach them to the start of each source file to most effectively
629 | state the exclusion of warranty; and each file should have at least
630 | the "copyright" line and a pointer to where the full notice is found.
631 |
632 |
633 | Copyright (C)
634 |
635 | This program is free software: you can redistribute it and/or modify
636 | it under the terms of the GNU Affero General Public License as published by
637 | the Free Software Foundation, either version 3 of the License, or
638 | (at your option) any later version.
639 |
640 | This program is distributed in the hope that it will be useful,
641 | but WITHOUT ANY WARRANTY; without even the implied warranty of
642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643 | GNU Affero General Public License for more details.
644 |
645 | You should have received a copy of the GNU Affero General Public License
646 | along with this program. If not, see .
647 |
648 | Also add information on how to contact you by electronic and paper mail.
649 |
650 | If your software can interact with users remotely through a computer
651 | network, you should also make sure that it provides a way for users to
652 | get its source. For example, if your program is a web application, its
653 | interface could display a "Source" link that leads users to an archive
654 | of the code. There are many ways you could offer source, and different
655 | solutions will be better for different programs; see section 13 for the
656 | specific requirements.
657 |
658 | You should also get your employer (if you work as a programmer) or school,
659 | if any, to sign a "copyright disclaimer" for the program, if necessary.
660 | For more information on this, and how to apply and follow the GNU AGPL, see
661 | .
--------------------------------------------------------------------------------
/LICENSES/AGPL-3.0-or-later.txt:
--------------------------------------------------------------------------------
1 | GNU AFFERO GENERAL PUBLIC LICENSE
2 | Version 3, 19 November 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 |
6 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
11 |
12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
13 |
14 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
15 |
16 | Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
17 |
18 | A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
19 |
20 | The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
21 |
22 | An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
23 |
24 | The precise terms and conditions for copying, distribution and modification follow.
25 |
26 | TERMS AND CONDITIONS
27 |
28 | 0. Definitions.
29 |
30 | "This License" refers to version 3 of the GNU Affero General Public License.
31 |
32 | "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
33 |
34 | "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
35 |
36 | To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
37 |
38 | A "covered work" means either the unmodified Program or a work based on the Program.
39 |
40 | To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
41 |
42 | To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
43 |
44 | An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
45 |
46 | 1. Source Code.
47 | The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
48 |
49 | A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
50 |
51 | The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
52 |
53 | The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
54 | subprograms and other parts of the work.
55 |
56 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
57 |
58 | The Corresponding Source for a work in source code form is that same work.
59 |
60 | 2. Basic Permissions.
61 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
62 |
63 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
64 |
65 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
66 |
67 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
68 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
69 |
70 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
71 |
72 | 4. Conveying Verbatim Copies.
73 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
74 |
75 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
76 |
77 | 5. Conveying Modified Source Versions.
78 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
79 |
80 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
81 |
82 | b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
83 |
84 | c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
85 |
86 | d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
87 |
88 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
89 |
90 | 6. Conveying Non-Source Forms.
91 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
92 |
93 | a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
94 |
95 | b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
96 |
97 | c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
98 |
99 | d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
100 |
101 | e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
102 |
103 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
104 |
105 | A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
106 |
107 | "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
108 |
109 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
110 |
111 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
112 |
113 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
114 |
115 | 7. Additional Terms.
116 | "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
117 |
118 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
119 |
120 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
121 |
122 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
123 |
124 | b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
125 |
126 | c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
127 |
128 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
129 |
130 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
131 |
132 | f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
133 |
134 | All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
135 |
136 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
137 |
138 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
139 |
140 | 8. Termination.
141 |
142 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
143 |
144 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
145 |
146 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
147 |
148 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
149 |
150 | 9. Acceptance Not Required for Having Copies.
151 |
152 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
153 |
154 | 10. Automatic Licensing of Downstream Recipients.
155 |
156 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
157 |
158 | An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
159 |
160 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
161 |
162 | 11. Patents.
163 |
164 | A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
165 |
166 | A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
167 |
168 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
169 |
170 | In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
171 |
172 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
173 | license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
174 |
175 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
176 |
177 | A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
178 |
179 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
180 |
181 | 12. No Surrender of Others' Freedom.
182 |
183 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
184 | not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
185 |
186 | 13. Remote Network Interaction; Use with the GNU General Public License.
187 |
188 | Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
189 |
190 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
191 |
192 | 14. Revised Versions of this License.
193 |
194 | The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
195 |
196 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
197 |
198 | If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
199 |
200 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
201 |
202 | 15. Disclaimer of Warranty.
203 |
204 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
205 |
206 | 16. Limitation of Liability.
207 |
208 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
209 |
210 | 17. Interpretation of Sections 15 and 16.
211 |
212 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
213 |
214 | END OF TERMS AND CONDITIONS
215 |
216 | How to Apply These Terms to Your New Programs
217 |
218 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
219 |
220 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
221 |
222 |
223 | Copyright (C)
224 |
225 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
226 |
227 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
228 |
229 | You should have received a copy of the GNU Affero General Public License along with this program. If not, see .
230 |
231 | Also add information on how to contact you by electronic and paper mail.
232 |
233 | If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
234 |
235 | You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see .
236 |
--------------------------------------------------------------------------------
/LICENSES/CC0-1.0.txt:
--------------------------------------------------------------------------------
1 | Creative Commons Legal Code
2 |
3 | CC0 1.0 Universal
4 |
5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12 | HEREUNDER.
13 |
14 | Statement of Purpose
15 |
16 | The laws of most jurisdictions throughout the world automatically confer
17 | exclusive Copyright and Related Rights (defined below) upon the creator
18 | and subsequent owner(s) (each and all, an "owner") of an original work of
19 | authorship and/or a database (each, a "Work").
20 |
21 | Certain owners wish to permanently relinquish those rights to a Work for
22 | the purpose of contributing to a commons of creative, cultural and
23 | scientific works ("Commons") that the public can reliably and without fear
24 | of later claims of infringement build upon, modify, incorporate in other
25 | works, reuse and redistribute as freely as possible in any form whatsoever
26 | and for any purposes, including without limitation commercial purposes.
27 | These owners may contribute to the Commons to promote the ideal of a free
28 | culture and the further production of creative, cultural and scientific
29 | works, or to gain reputation or greater distribution for their Work in
30 | part through the use and efforts of others.
31 |
32 | For these and/or other purposes and motivations, and without any
33 | expectation of additional consideration or compensation, the person
34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35 | is an owner of Copyright and Related Rights in the Work, voluntarily
36 | elects to apply CC0 to the Work and publicly distribute the Work under its
37 | terms, with knowledge of his or her Copyright and Related Rights in the
38 | Work and the meaning and intended legal effect of CC0 on those rights.
39 |
40 | 1. Copyright and Related Rights. A Work made available under CC0 may be
41 | protected by copyright and related or neighboring rights ("Copyright and
42 | Related Rights"). Copyright and Related Rights include, but are not
43 | limited to, the following:
44 |
45 | i. the right to reproduce, adapt, distribute, perform, display,
46 | communicate, and translate a Work;
47 | ii. moral rights retained by the original author(s) and/or performer(s);
48 | iii. publicity and privacy rights pertaining to a person's image or
49 | likeness depicted in a Work;
50 | iv. rights protecting against unfair competition in regards to a Work,
51 | subject to the limitations in paragraph 4(a), below;
52 | v. rights protecting the extraction, dissemination, use and reuse of data
53 | in a Work;
54 | vi. database rights (such as those arising under Directive 96/9/EC of the
55 | European Parliament and of the Council of 11 March 1996 on the legal
56 | protection of databases, and under any national implementation
57 | thereof, including any amended or successor version of such
58 | directive); and
59 | vii. other similar, equivalent or corresponding rights throughout the
60 | world based on applicable law or treaty, and any national
61 | implementations thereof.
62 |
63 | 2. Waiver. To the greatest extent permitted by, but not in contravention
64 | of, applicable law, Affirmer hereby overtly, fully, permanently,
65 | irrevocably and unconditionally waives, abandons, and surrenders all of
66 | Affirmer's Copyright and Related Rights and associated claims and causes
67 | of action, whether now known or unknown (including existing as well as
68 | future claims and causes of action), in the Work (i) in all territories
69 | worldwide, (ii) for the maximum duration provided by applicable law or
70 | treaty (including future time extensions), (iii) in any current or future
71 | medium and for any number of copies, and (iv) for any purpose whatsoever,
72 | including without limitation commercial, advertising or promotional
73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74 | member of the public at large and to the detriment of Affirmer's heirs and
75 | successors, fully intending that such Waiver shall not be subject to
76 | revocation, rescission, cancellation, termination, or any other legal or
77 | equitable action to disrupt the quiet enjoyment of the Work by the public
78 | as contemplated by Affirmer's express Statement of Purpose.
79 |
80 | 3. Public License Fallback. Should any part of the Waiver for any reason
81 | be judged legally invalid or ineffective under applicable law, then the
82 | Waiver shall be preserved to the maximum extent permitted taking into
83 | account Affirmer's express Statement of Purpose. In addition, to the
84 | extent the Waiver is so judged Affirmer hereby grants to each affected
85 | person a royalty-free, non transferable, non sublicensable, non exclusive,
86 | irrevocable and unconditional license to exercise Affirmer's Copyright and
87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the
88 | maximum duration provided by applicable law or treaty (including future
89 | time extensions), (iii) in any current or future medium and for any number
90 | of copies, and (iv) for any purpose whatsoever, including without
91 | limitation commercial, advertising or promotional purposes (the
92 | "License"). The License shall be deemed effective as of the date CC0 was
93 | applied by Affirmer to the Work. Should any part of the License for any
94 | reason be judged legally invalid or ineffective under applicable law, such
95 | partial invalidity or ineffectiveness shall not invalidate the remainder
96 | of the License, and in such case Affirmer hereby affirms that he or she
97 | will not (i) exercise any of his or her remaining Copyright and Related
98 | Rights in the Work or (ii) assert any associated claims and causes of
99 | action with respect to the Work, in either case contrary to Affirmer's
100 | express Statement of Purpose.
101 |
102 | 4. Limitations and Disclaimers.
103 |
104 | a. No trademark or patent rights held by Affirmer are waived, abandoned,
105 | surrendered, licensed or otherwise affected by this document.
106 | b. Affirmer offers the Work as-is and makes no representations or
107 | warranties of any kind concerning the Work, express, implied,
108 | statutory or otherwise, including without limitation warranties of
109 | title, merchantability, fitness for a particular purpose, non
110 | infringement, or the absence of latent or other defects, accuracy, or
111 | the present or absence of errors, whether or not discoverable, all to
112 | the greatest extent permissible under applicable law.
113 | c. Affirmer disclaims responsibility for clearing rights of other persons
114 | that may apply to the Work or any use thereof, including without
115 | limitation any person's Copyright and Related Rights in the Work.
116 | Further, Affirmer disclaims responsibility for obtaining any necessary
117 | consents, permissions or other rights required for any use of the
118 | Work.
119 | d. Affirmer understands and acknowledges that Creative Commons is not a
120 | party to this document and has no duty or obligation with respect to
121 | this CC0 or use of the Work.
122 |
--------------------------------------------------------------------------------
/LICENSES/MIT.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Makefile for building the project
2 | # SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
3 | # SPDX-License-Identifier: AGPL-3.0-or-later
4 |
5 | app_name=user_usage_report
6 |
7 | project_dir=$(CURDIR)/../$(app_name)
8 | build_dir=$(CURDIR)/build/artifacts
9 | appstore_dir=$(build_dir)/appstore
10 | source_dir=$(build_dir)/source
11 | sign_dir=$(build_dir)/sign
12 | package_name=$(app_name)
13 | cert_dir=$(HOME)/.nextcloud/certificates
14 | version+=master
15 |
16 | all: appstore
17 |
18 | release: appstore create-tag
19 |
20 | create-tag:
21 | git tag -a v$(version) -m "Tagging the $(version) release."
22 | git push origin v$(version)
23 |
24 | clean:
25 | rm -rf $(build_dir)
26 | rm -rf node_modules
27 |
28 | appstore: clean
29 | mkdir -p $(sign_dir)
30 | rsync -a \
31 | --exclude=/build \
32 | --exclude=/docs \
33 | --exclude=/translationfiles \
34 | --exclude=/.tx \
35 | --exclude=/tests \
36 | --exclude=/vendor \
37 | --exclude=/.git \
38 | --exclude=/.github \
39 | --exclude=/l10n/l10n.pl \
40 | --exclude=/README.md \
41 | --exclude=/.gitattributes \
42 | --exclude=/.gitignore \
43 | --exclude=/.php-cs-fixer.cache \
44 | --exclude=/.php-cs-fixer.dist.php \
45 | --exclude=/composer.json \
46 | --exclude=/composer.lock \
47 | --exclude=/Makefile \
48 | --exclude=/psalm.xml \
49 | $(project_dir)/ $(sign_dir)/$(app_name)
50 | @if [ -f $(cert_dir)/$(app_name).key ]; then \
51 | echo "Signing app files…"; \
52 | php ../../occ integrity:sign-app \
53 | --privateKey=$(cert_dir)/$(app_name).key\
54 | --certificate=$(cert_dir)/$(app_name).crt\
55 | --path=$(sign_dir)/$(app_name); \
56 | fi
57 | tar -czf $(build_dir)/$(app_name).tar.gz \
58 | -C $(sign_dir) $(app_name)
59 | @if [ -f $(cert_dir)/$(app_name).key ]; then \
60 | echo "Signing package…"; \
61 | openssl dgst -sha512 -sign $(cert_dir)/$(app_name).key $(build_dir)/$(app_name).tar.gz | openssl base64; \
62 | fi
63 |
64 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
5 | # User usage report
6 |
7 | [](https://api.reuse.software/info/github.com/nextcloud/user_usage_report)
8 |
9 | To generate the report for a user, run the following command:
10 |
11 | ```sh
12 | $ sudo -u www-data ./occ usage-report:generate admin
13 | "admin","2017-09-18T09:00:01+00:00",5368709120,786432000,12,1,1,2
14 | ```
15 |
16 | Leaving out the user argument will generate a report for all users on the system:
17 |
18 | ```sh
19 | $ sudo -u www-data ./occ usage-report:generate --display-name
20 | "admin","Nextcloud Admin","2017-09-18T09:00:01+00:00",5368709120,786432000,12,1,1,2
21 | "test1","Test User 1","2017-09-18T09:00:01+00:00",-2,954368,6,0,2,10
22 | "test2","Second Test user","2017-09-18T09:00:01+00:00",-2,164,4,0,0,0
23 | "test3","Test User Three","2017-09-18T09:00:01+00:00",-2,164,4,0,0,0
24 | "test5","Fifth Tester","2017-09-18T09:00:01+00:00",-2,164,4,0,0,0
25 | ```
26 |
27 | The CSV data is the following:
28 |
29 | * User identifier
30 | * User display name (when `--display-name` is given)
31 | * Current date and time (default in ISO 8601 format, but any format can be specified)
32 | * Last login date and time (default in ISO 8601 format, but any format can be specified) (when `--last-login` is given)
33 | * Assigned home storage size in bytes (`-3` is unlimited, `-2` is unknown/not set)
34 | * Disk space consumed by home storage in bytes (`-2` is unknown)
35 | * Number of files in home storage
36 | * Number of shares created
37 | * Number of files created (new files only)
38 | * Number of files read (download/view)
39 |
40 | To include the header of the fields in the CSV use the `--verbose` option:
41 |
42 | ```sh
43 | $ sudo -u www-data ./occ usage-report:generate --verbose admin
44 | "user-id","date as 'c'","assigned quota (5 GB)","used quota (500 MB)",number of files,number of shares,number of uploads,number of downloads
45 | "admin","2017-09-18T09:00:01+00:00",5368709120,786432000,12,1,1,2
46 | ```
47 |
48 |
--------------------------------------------------------------------------------
/REUSE.toml:
--------------------------------------------------------------------------------
1 | # SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
2 | # SPDX-License-Identifier: AGPL-3.0-or-later
3 | version = 1
4 | SPDX-PackageName = "user_usage_report"
5 | SPDX-PackageSupplier = "Nextcloud "
6 | SPDX-PackageDownloadLocation = "https://github.com/nextcloud/user_usage_report"
7 |
8 | [[annotations]]
9 | path = ["composer.json", "composer.lock", "vendor-bin/**/composer.json", "vendor-bin/**/composer.lock"]
10 | precedence = "aggregate"
11 | SPDX-FileCopyrightText = "none"
12 | SPDX-License-Identifier = "CC0-1.0"
13 |
--------------------------------------------------------------------------------
/appinfo/info.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
8 | user_usage_report
9 | User usage report
10 | Provides a command which generates a report about all the users and their usage
11 |
26 |
27 | 3.0.0-dev.0
28 | agpl
29 | Joas Schilling
30 |
31 | UserUsageReport
32 |
33 |
34 |
35 |
36 |
37 | monitoring
38 |
39 | https://github.com/nextcloud/user_usage_report
40 | https://github.com/nextcloud/user_usage_report/issues
41 | https://github.com/nextcloud/user_usage_report.git
42 |
43 | https://raw.githubusercontent.com/nextcloud/user_usage_report/master/docs/screenshot.png
44 |
45 |
46 |
47 |
48 |
49 |
50 | OCA\UserUsageReport\Command\Generate
51 |
52 |
53 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nextcloud/user_usage_report",
3 | "description": "user_usage_report",
4 | "license": "AGPL-3.0-or-later",
5 | "require-dev": {
6 | "bamarni/composer-bin-plugin": "^1.8",
7 | "nextcloud/ocp": "dev-master"
8 | },
9 | "config": {
10 | "allow-plugins": {
11 | "bamarni/composer-bin-plugin": true
12 | },
13 | "optimize-autoloader": true,
14 | "platform": {
15 | "php": "8.1"
16 | },
17 | "sort-packages": true
18 | },
19 | "extra": {
20 | "bamarni-bin": {
21 | "bin-links": false,
22 | "forward-command": true,
23 | "target-directory": "vendor-bin"
24 | }
25 | },
26 | "scripts": {
27 | "cs:check": "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff",
28 | "cs:fix": "vendor-bin/cs-fixer/vendor/bin/php-cs-fixer fix",
29 | "lint": "find . -name \\*.php -not -path './vendor/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
30 | "psalm": "vendor-bin/psalm/vendor/bin/psalm --threads=1",
31 | "psalm:clear": "vendor-bin/psalm/vendor/bin/psalm --clear-cache && vendor-bin/psalm/vendor/bin/psalm --clear-global-cache",
32 | "psalm:update-baseline": "vendor-bin/psalm/vendor/bin/psalm --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml",
33 | "test:unit": "vendor-bin/phpunit/vendor/bin/phpunit -c tests/phpunit.xml --fail-on-warning"
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "0e24b292bf3bdcebab9700655f8a39d5",
8 | "packages": [],
9 | "packages-dev": [
10 | {
11 | "name": "bamarni/composer-bin-plugin",
12 | "version": "1.8.2",
13 | "source": {
14 | "type": "git",
15 | "url": "https://github.com/bamarni/composer-bin-plugin.git",
16 | "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880"
17 | },
18 | "dist": {
19 | "type": "zip",
20 | "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880",
21 | "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880",
22 | "shasum": ""
23 | },
24 | "require": {
25 | "composer-plugin-api": "^2.0",
26 | "php": "^7.2.5 || ^8.0"
27 | },
28 | "require-dev": {
29 | "composer/composer": "^2.0",
30 | "ext-json": "*",
31 | "phpstan/extension-installer": "^1.1",
32 | "phpstan/phpstan": "^1.8",
33 | "phpstan/phpstan-phpunit": "^1.1",
34 | "phpunit/phpunit": "^8.5 || ^9.5",
35 | "symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
36 | "symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
37 | "symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0"
38 | },
39 | "type": "composer-plugin",
40 | "extra": {
41 | "class": "Bamarni\\Composer\\Bin\\BamarniBinPlugin"
42 | },
43 | "autoload": {
44 | "psr-4": {
45 | "Bamarni\\Composer\\Bin\\": "src"
46 | }
47 | },
48 | "notification-url": "https://packagist.org/downloads/",
49 | "license": [
50 | "MIT"
51 | ],
52 | "description": "No conflicts for your bin dependencies",
53 | "keywords": [
54 | "composer",
55 | "conflict",
56 | "dependency",
57 | "executable",
58 | "isolation",
59 | "tool"
60 | ],
61 | "support": {
62 | "issues": "https://github.com/bamarni/composer-bin-plugin/issues",
63 | "source": "https://github.com/bamarni/composer-bin-plugin/tree/1.8.2"
64 | },
65 | "time": "2022-10-31T08:38:03+00:00"
66 | },
67 | {
68 | "name": "nextcloud/ocp",
69 | "version": "dev-master",
70 | "source": {
71 | "type": "git",
72 | "url": "https://github.com/nextcloud-deps/ocp.git",
73 | "reference": "c659c0643c3711086eac4f87980fefefd3fcb787"
74 | },
75 | "dist": {
76 | "type": "zip",
77 | "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/c659c0643c3711086eac4f87980fefefd3fcb787",
78 | "reference": "c659c0643c3711086eac4f87980fefefd3fcb787",
79 | "shasum": ""
80 | },
81 | "require": {
82 | "php": "~8.1 || ~8.2 || ~8.3 || ~8.4",
83 | "psr/clock": "^1.0",
84 | "psr/container": "^2.0.2",
85 | "psr/event-dispatcher": "^1.0",
86 | "psr/log": "^3.0.2"
87 | },
88 | "default-branch": true,
89 | "type": "library",
90 | "extra": {
91 | "branch-alias": {
92 | "dev-master": "32.0.0-dev"
93 | }
94 | },
95 | "notification-url": "https://packagist.org/downloads/",
96 | "license": [
97 | "AGPL-3.0-or-later"
98 | ],
99 | "authors": [
100 | {
101 | "name": "Christoph Wurst",
102 | "email": "christoph@winzerhof-wurst.at"
103 | },
104 | {
105 | "name": "Joas Schilling",
106 | "email": "coding@schilljs.com"
107 | }
108 | ],
109 | "description": "Composer package containing Nextcloud's public OCP API and the unstable NCU API",
110 | "support": {
111 | "issues": "https://github.com/nextcloud-deps/ocp/issues",
112 | "source": "https://github.com/nextcloud-deps/ocp/tree/master"
113 | },
114 | "time": "2025-06-06T00:52:12+00:00"
115 | },
116 | {
117 | "name": "psr/clock",
118 | "version": "1.0.0",
119 | "source": {
120 | "type": "git",
121 | "url": "https://github.com/php-fig/clock.git",
122 | "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d"
123 | },
124 | "dist": {
125 | "type": "zip",
126 | "url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d",
127 | "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d",
128 | "shasum": ""
129 | },
130 | "require": {
131 | "php": "^7.0 || ^8.0"
132 | },
133 | "type": "library",
134 | "autoload": {
135 | "psr-4": {
136 | "Psr\\Clock\\": "src/"
137 | }
138 | },
139 | "notification-url": "https://packagist.org/downloads/",
140 | "license": [
141 | "MIT"
142 | ],
143 | "authors": [
144 | {
145 | "name": "PHP-FIG",
146 | "homepage": "https://www.php-fig.org/"
147 | }
148 | ],
149 | "description": "Common interface for reading the clock.",
150 | "homepage": "https://github.com/php-fig/clock",
151 | "keywords": [
152 | "clock",
153 | "now",
154 | "psr",
155 | "psr-20",
156 | "time"
157 | ],
158 | "support": {
159 | "issues": "https://github.com/php-fig/clock/issues",
160 | "source": "https://github.com/php-fig/clock/tree/1.0.0"
161 | },
162 | "time": "2022-11-25T14:36:26+00:00"
163 | },
164 | {
165 | "name": "psr/container",
166 | "version": "2.0.2",
167 | "source": {
168 | "type": "git",
169 | "url": "https://github.com/php-fig/container.git",
170 | "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
171 | },
172 | "dist": {
173 | "type": "zip",
174 | "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
175 | "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
176 | "shasum": ""
177 | },
178 | "require": {
179 | "php": ">=7.4.0"
180 | },
181 | "type": "library",
182 | "extra": {
183 | "branch-alias": {
184 | "dev-master": "2.0.x-dev"
185 | }
186 | },
187 | "autoload": {
188 | "psr-4": {
189 | "Psr\\Container\\": "src/"
190 | }
191 | },
192 | "notification-url": "https://packagist.org/downloads/",
193 | "license": [
194 | "MIT"
195 | ],
196 | "authors": [
197 | {
198 | "name": "PHP-FIG",
199 | "homepage": "https://www.php-fig.org/"
200 | }
201 | ],
202 | "description": "Common Container Interface (PHP FIG PSR-11)",
203 | "homepage": "https://github.com/php-fig/container",
204 | "keywords": [
205 | "PSR-11",
206 | "container",
207 | "container-interface",
208 | "container-interop",
209 | "psr"
210 | ],
211 | "support": {
212 | "issues": "https://github.com/php-fig/container/issues",
213 | "source": "https://github.com/php-fig/container/tree/2.0.2"
214 | },
215 | "time": "2021-11-05T16:47:00+00:00"
216 | },
217 | {
218 | "name": "psr/event-dispatcher",
219 | "version": "1.0.0",
220 | "source": {
221 | "type": "git",
222 | "url": "https://github.com/php-fig/event-dispatcher.git",
223 | "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
224 | },
225 | "dist": {
226 | "type": "zip",
227 | "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
228 | "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
229 | "shasum": ""
230 | },
231 | "require": {
232 | "php": ">=7.2.0"
233 | },
234 | "type": "library",
235 | "extra": {
236 | "branch-alias": {
237 | "dev-master": "1.0.x-dev"
238 | }
239 | },
240 | "autoload": {
241 | "psr-4": {
242 | "Psr\\EventDispatcher\\": "src/"
243 | }
244 | },
245 | "notification-url": "https://packagist.org/downloads/",
246 | "license": [
247 | "MIT"
248 | ],
249 | "authors": [
250 | {
251 | "name": "PHP-FIG",
252 | "homepage": "http://www.php-fig.org/"
253 | }
254 | ],
255 | "description": "Standard interfaces for event handling.",
256 | "keywords": [
257 | "events",
258 | "psr",
259 | "psr-14"
260 | ],
261 | "support": {
262 | "issues": "https://github.com/php-fig/event-dispatcher/issues",
263 | "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
264 | },
265 | "time": "2019-01-08T18:20:26+00:00"
266 | },
267 | {
268 | "name": "psr/log",
269 | "version": "3.0.2",
270 | "source": {
271 | "type": "git",
272 | "url": "https://github.com/php-fig/log.git",
273 | "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3"
274 | },
275 | "dist": {
276 | "type": "zip",
277 | "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
278 | "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
279 | "shasum": ""
280 | },
281 | "require": {
282 | "php": ">=8.0.0"
283 | },
284 | "type": "library",
285 | "extra": {
286 | "branch-alias": {
287 | "dev-master": "3.x-dev"
288 | }
289 | },
290 | "autoload": {
291 | "psr-4": {
292 | "Psr\\Log\\": "src"
293 | }
294 | },
295 | "notification-url": "https://packagist.org/downloads/",
296 | "license": [
297 | "MIT"
298 | ],
299 | "authors": [
300 | {
301 | "name": "PHP-FIG",
302 | "homepage": "https://www.php-fig.org/"
303 | }
304 | ],
305 | "description": "Common interface for logging libraries",
306 | "homepage": "https://github.com/php-fig/log",
307 | "keywords": [
308 | "log",
309 | "psr",
310 | "psr-3"
311 | ],
312 | "support": {
313 | "source": "https://github.com/php-fig/log/tree/3.0.2"
314 | },
315 | "time": "2024-09-11T13:17:53+00:00"
316 | }
317 | ],
318 | "aliases": [],
319 | "minimum-stability": "stable",
320 | "stability-flags": {
321 | "nextcloud/ocp": 20
322 | },
323 | "prefer-stable": false,
324 | "prefer-lowest": false,
325 | "platform": {},
326 | "platform-dev": {},
327 | "platform-overrides": {
328 | "php": "8.1"
329 | },
330 | "plugin-api-version": "2.6.0"
331 | }
332 |
--------------------------------------------------------------------------------
/docs/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nextcloud/user_usage_report/308d59279c6dbcd3fdb65c450211f3e69eef186b/docs/screenshot.png
--------------------------------------------------------------------------------
/docs/screenshot.png.license:
--------------------------------------------------------------------------------
1 | SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
2 | SPDX-License-Identifier: AGPL-3.0-or-later
3 |
--------------------------------------------------------------------------------
/lib/AppInfo/Application.php:
--------------------------------------------------------------------------------
1 | registerEventListener(BeforeNodeReadEvent::class, Listener::class);
30 | $context->registerEventListener(BeforePreviewFetchedEvent::class, Listener::class);
31 | $context->registerEventListener(NodeCreatedEvent::class, Listener::class);
32 | }
33 |
34 | public function boot(IBootContext $context): void {
35 | // done
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/lib/Command/Generate.php:
--------------------------------------------------------------------------------
1 | single = $single;
37 | $this->all = $all;
38 | $this->userManager = $userManager;
39 | }
40 |
41 | protected function configure(): void {
42 | $this
43 | ->setHelp(
44 | 'Print usage information for a given or all users.' . "\n"
45 | . "\n"
46 | . "Example (with --verbose to show the header):\n"
47 | . "\n"
48 | . '"user-id","date as \'c\'","assigned quota (5 GB)","used quota (500 MB)",number of files,number of shares,number of uploads,number of downloads' . "\n"
49 | . '"admin","2017-09-18T09:00:01+00:00",5368709120,786432000,1024,23,1400,5678'
50 | )
51 | ->addArgument(
52 | 'user-id',
53 | InputArgument::OPTIONAL,
54 | 'User to generate the report for, if none is given the report is generated for all users'
55 | )
56 | ->addOption(
57 | 'field-separator',
58 | '',
59 | InputOption::VALUE_REQUIRED,
60 | 'Separator for the fields in the list (Only used when output format is CSV)',
61 | ','
62 | )
63 | ->addOption(
64 | 'date-format',
65 | '',
66 | InputOption::VALUE_REQUIRED,
67 | 'Date format of the entries (see http://php.net/manual/en/function.date.php for more information)',
68 | 'c'
69 | )
70 | ->addOption(
71 | 'last-login',
72 | '',
73 | InputOption::VALUE_NONE,
74 | 'Should the last login date be included in the report'
75 | )
76 | ->addOption(
77 | 'display-name',
78 | '',
79 | InputOption::VALUE_NONE,
80 | 'Should the display name be included in the report'
81 | )
82 | ->addOption(
83 | 'output',
84 | '',
85 | InputOption::VALUE_REQUIRED,
86 | 'Output format (csv or json)',
87 | 'csv'
88 | )
89 | ->addOption(
90 | 'output-file',
91 | 'O',
92 | InputOption::VALUE_REQUIRED,
93 | 'Output file for stdout'
94 | )
95 | ;
96 | }
97 |
98 | /**
99 | * @param InputInterface $input
100 | * @param OutputInterface $output
101 | * @return int
102 | */
103 | protected function execute(InputInterface $input, OutputInterface $output): int {
104 | $outputFile = $input->getOption('output-file');
105 |
106 | if ($outputFile) {
107 | $stream = fopen($outputFile, 'w');
108 | $streamOutput = new StreamOutput($stream, $output->getVerbosity(), null, $output->getFormatter());
109 | } else {
110 | $streamOutput = $output;
111 | }
112 |
113 | $userId = $input->getArgument('user-id');
114 | if ($userId) {
115 | if (!$this->userManager->userExists($userId)) {
116 | $output->writeln('User with ID "' . $userId . '" could not be found.');
117 | return 1;
118 | }
119 | }
120 |
121 | if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
122 | $separator = $input->getOption('field-separator');
123 |
124 | $header = [];
125 | $header['user_id'] = '';
126 | $data = '"user-id"' . $separator;
127 | if ($input->getOption('display-name')) {
128 | $header['display_name'] = '';
129 | $data .= '"display name"' . $separator;
130 | }
131 | $header['date'] = '';
132 | $data .= '"date as \'' . $input->getOption('date-format') . '\'"' . $separator;
133 | if ($input->getOption('last-login')) {
134 | $header['login'] = '';
135 | $data .= '"last login date as \'' . $input->getOption('date-format') . '\'"' . $separator;
136 | }
137 | $header['quota'] = '';
138 | $data .= '"assigned quota (5 GB)"' . $separator;
139 | $header['used'] = '';
140 | $data .= '"used quota (500 MB)"' . $separator;
141 | $header['files'] = 0;
142 | $data .= 'number of files' . $separator;
143 | $header['shares'] = 0;
144 | $data .= 'number of shares' . $separator;
145 | $header['uploads'] = 0;
146 | $data .= 'number of uploads' . $separator;
147 | $header['downloads'] = 0;
148 | $data .= 'number of downloads';
149 |
150 | if ($input->getOption('output') === 'csv') {
151 | $streamOutput->writeln($data);
152 | } else {
153 | $streamOutput->writeln(json_encode($header));
154 | }
155 | }
156 |
157 | if ($input->getArgument('user-id')) {
158 | $this->single->printReport($input, $streamOutput, $userId);
159 | } else {
160 | $this->all->printReport($input, $output, $streamOutput);
161 | }
162 |
163 | return 0;
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/lib/Formatter.php:
--------------------------------------------------------------------------------
1 | getOption('field-separator');
19 | if ($this->timestamp === null) {
20 | $this->timestamp = date($input->getOption('date-format'));
21 | }
22 |
23 | $jsonArray = ['user_id' => $userId];
24 | $data = '"' . $userId . '"' . $separator;
25 | if ($input->getOption('display-name')) {
26 | $jsonArray['display_name'] = $report['display_name'] ?? 'no display name found';
27 | $data .= '"' . ($report['display_name'] ?? 'no display name found') . '"' . $separator;
28 | }
29 | $jsonArray['date'] = $this->timestamp;
30 | $data .= '"' . $this->timestamp . '"' . $separator;
31 | if ($input->getOption('last-login')) {
32 | $report['login'] = isset($report['login']) ? date($input->getOption('date-format'), $report['login']) : 'no last login found';
33 | $jsonArray['login'] = $report['login'];
34 | $data .= '"' . $report['login'] . '"' . $separator;
35 | }
36 |
37 | // ensure all fields we are trying to print are set
38 | $fields = ['quota', 'used', 'files', 'shares', 'uploads', 'downloads'];
39 | foreach ($fields as $field) {
40 | if (!isset($report[$field])) {
41 | $report[$field] = 0;
42 | }
43 | }
44 |
45 | $data .= (!is_numeric($report['quota']) ? '"' . $report['quota'] . '"' : $report['quota']) . $separator;
46 | $jsonArray['quota'] = $report['quota'];
47 | $data .= (!is_numeric($report['used']) ? '"' . $report['used'] . '"' : $report['used']) . $separator;
48 | $jsonArray['used'] = $report['used'];
49 | $data .= $report['files'] . $separator;
50 | $jsonArray['files'] = $report['files'];
51 | $data .= $report['shares'] . $separator;
52 | $jsonArray['shares'] = $report['shares'];
53 | $data .= $report['uploads'] . $separator;
54 | $jsonArray['uploads'] = $report['uploads'];
55 | $data .= $report['downloads'];
56 | $jsonArray['downloads'] = $report['downloads'];
57 |
58 | if ($input->getOption('output') === 'csv') {
59 | $output->writeln($data);
60 | } else {
61 | $output->writeln(json_encode($jsonArray));
62 | }
63 | }
64 |
65 | public function humanFileSize($bytes) {
66 | if ($bytes < 0) {
67 | return FileInfo::SPACE_UNKNOWN;
68 | }
69 |
70 | if ($bytes < 1024) {
71 | return "$bytes B";
72 | }
73 | $bytes = round($bytes / 1024, 2);
74 | if ($bytes < 1024) {
75 | return "$bytes KB";
76 | }
77 | $bytes = round($bytes / 1024, 2);
78 | if ($bytes < 1024) {
79 | return "$bytes MB";
80 | }
81 | $bytes = round($bytes / 1024, 2);
82 | if ($bytes < 1024) {
83 | return "$bytes GB";
84 | }
85 | $bytes = round($bytes / 1024, 2);
86 | if ($bytes < 1024) {
87 | return "$bytes TB";
88 | }
89 |
90 | $bytes = round($bytes / 1024, 2);
91 | return "$bytes PB";
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/lib/Listener.php:
--------------------------------------------------------------------------------
1 |
24 | */
25 | class Listener implements IEventListener {
26 |
27 | /** @var IUserSession */
28 | protected $userSession;
29 |
30 | /** @var IDBConnection */
31 | protected $connection;
32 |
33 | /** @var IQueryBuilder */
34 | protected $insert;
35 |
36 | /** @var IQueryBuilder */
37 | protected $update;
38 |
39 | public function __construct(IUserSession $userSession, IDBConnection $connection) {
40 | $this->userSession = $userSession;
41 | $this->connection = $connection;
42 | }
43 |
44 | public function handle(Event $event): void {
45 | if ($event instanceof BeforeNodeReadEvent) {
46 | $this->fileRead();
47 | }
48 |
49 | if ($event instanceof BeforePreviewFetchedEvent && ($event->getHeight() > 256 || $event->getWidth() > 256)) {
50 | $this->fileRead();
51 | }
52 |
53 | if ($event instanceof NodeCreatedEvent) {
54 | $this->fileCreated();
55 | }
56 | }
57 |
58 | /**
59 | * Log file creation
60 | */
61 | public function fileCreated(): void {
62 | $this->storeAction('created');
63 | }
64 |
65 | /**
66 | * Log reading of file
67 | */
68 | public function fileRead(): void {
69 | $this->storeAction('read');
70 | }
71 |
72 | protected function storeAction(string $action): void {
73 | $user = $this->userSession->getUser();
74 | if (!$user instanceof IUser) {
75 | // Guest user
76 | return;
77 | }
78 |
79 | $update = $this->getUpdateQuery();
80 | $update
81 | ->setParameter('user', $user->getUID(), IQueryBuilder::PARAM_STR)
82 | ->setParameter('action', $action, IQueryBuilder::PARAM_STR)
83 | ;
84 | $updated = $update->executeStatement();
85 |
86 | if ($updated === 0) {
87 | $insert = $this->getInsertQuery();
88 | $insert
89 | ->setParameter('user', $user->getUID(), IQueryBuilder::PARAM_STR)
90 | ->setParameter('action', $action, IQueryBuilder::PARAM_STR)
91 | ;
92 |
93 | try {
94 | $insert->executeStatement();
95 | } catch (Exception $e) {
96 | // Ignore temporary issues only when two entries are generated in parallel
97 | if ($e->getReason() !== Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
98 | throw $e;
99 | }
100 | }
101 | }
102 | }
103 |
104 | protected function getUpdateQuery(): IQueryBuilder {
105 | if ($this->update !== null) {
106 | return $this->update;
107 | }
108 |
109 | $query = $this->connection->getQueryBuilder();
110 | $query->update('preferences')
111 | ->set('configvalue',
112 | $query->expr()->castColumn(
113 | $query->createFunction(
114 | '(' . $query->expr()->castColumn('configvalue', IQueryBuilder::PARAM_INT)
115 | . ' + 1)'
116 | ), IQueryBuilder::PARAM_STR
117 | )
118 | )
119 | ->where($query->expr()->eq('userid', $query->createParameter('user')))
120 | ->andWhere($query->expr()->eq('configkey', $query->createParameter('action')))
121 | ->andWhere($query->expr()->eq('appid', $query->createParameter('appid')))
122 | ->setParameter('appid', 'user_usage_report');
123 | $this->update = $query;
124 |
125 | return $query;
126 | }
127 |
128 | protected function getInsertQuery(): IQueryBuilder {
129 | if ($this->insert !== null) {
130 | return $this->insert;
131 | }
132 |
133 | $query = $this->connection->getQueryBuilder();
134 | $query->insert('preferences')
135 | ->values([
136 | 'userid' => $query->createParameter('user'),
137 | 'appid' => $query->createParameter('appid'),
138 | 'configkey' => $query->createParameter('action'),
139 | 'configvalue' => $query->createParameter('configvalue'),
140 | ])
141 | ->setParameter('appid', 'user_usage_report')
142 | ->setParameter('configvalue', '1');
143 | $this->insert = $query;
144 |
145 | return $query;
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/lib/Migration/Version1001Date20180806133516.php:
--------------------------------------------------------------------------------
1 | hasTable('usage_report')) {
28 | // $table = $schema->createTable('usage_report');
29 | // $table->addColumn('user_id', Types::STRING, [
30 | // 'notnull' => true,
31 | // 'length' => 64,
32 | // ]);
33 | // $table->addColumn('action', Types::STRING, [
34 | // 'notnull' => false,
35 | // 'length' => 64,
36 | // ]);
37 | // $table->addColumn('timestamp', Types::DATETIME_MUTABLE, [
38 | // 'notnull' => false,
39 | // ]);
40 | // $table->addIndex(['user_id', 'action', 'timestamp'], 'usage_report_uta');
41 | // }
42 | // return $schema;
43 | return null;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/lib/Migration/Version1004Date20200626143122.php:
--------------------------------------------------------------------------------
1 | connection = $connection;
25 | }
26 |
27 | /**
28 | * @param IOutput $output
29 | * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
30 | * @param array $options
31 | * @return null|ISchemaWrapper
32 | */
33 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
34 | // /** @var ISchemaWrapper $schema */
35 | // $schema = $schemaClosure();
36 | //
37 | // if (!$schema->hasTable('usage_report_actions')) {
38 | // $table = $schema->createTable('usage_report_actions');
39 | // $table->addColumn('id', Types::BIGINT, [
40 | // 'autoincrement' => true,
41 | // 'notnull' => true,
42 | // 'length' => 20,
43 | // ]);
44 | // $table->addColumn('user_id', Types::STRING, [
45 | // 'notnull' => true,
46 | // 'length' => 64,
47 | // ]);
48 | // $table->addColumn('action', Types::STRING, [
49 | // 'notnull' => false,
50 | // 'length' => 64,
51 | // ]);
52 | // $table->addColumn('datetime', Types::DATETIME_MUTABLE, [
53 | // 'notnull' => false,
54 | // ]);
55 | // $table->addIndex(['user_id', 'action', 'datetime'], 'usage_report_uad');
56 | //
57 | // $table->setPrimaryKey(['id']);
58 | // }
59 | //
60 | // return $schema;
61 | return null;
62 | }
63 |
64 | // /**
65 | // * @param IOutput $output
66 | // * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
67 | // * @param array $options
68 | // */
69 | // public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
70 | // $insert = $this->connection->getQueryBuilder();
71 | // $insert->insert('usage_report_actions')
72 | // ->values([
73 | // 'user_id' => $insert->createParameter('user'),
74 | // 'action' => $insert->createParameter('action'),
75 | // 'datetime' => $insert->createParameter('datetime'),
76 | // ]);
77 | //
78 | // $query = $this->connection->getQueryBuilder();
79 | // $query->select('*')
80 | // ->from('usage_report')
81 | // ->orderBy('timestamp', 'ASC')
82 | // ->addOrderBy('user_id', 'ASC')
83 | // ->addOrderBy('action', 'ASC')
84 | // ->setMaxResults(self::MIGRATION_SIZE);
85 | //
86 | // $offset = 0;
87 | // do {
88 | // $query->setFirstResult($offset);
89 | // $result = $query->execute();
90 | // $rows = $result->fetchAll();
91 | // $result->closeCursor();
92 | //
93 | // if (empty($rows)) {
94 | // return;
95 | // }
96 | //
97 | // foreach ($rows as $row) {
98 | // $date = new \DateTime($row['timestamp']);
99 | // $insert->setParameter('user', $row['user_id'])
100 | // ->setParameter('action', $row['action'])
101 | // ->setParameter('datetime', $date, IQueryBuilder::PARAM_DATE);
102 | // $insert->execute();
103 | // }
104 | //
105 | // $offset += self::MIGRATION_SIZE;
106 | // } while (true);
107 | // }
108 | }
109 |
--------------------------------------------------------------------------------
/lib/Migration/Version1004Date20200626143419.php:
--------------------------------------------------------------------------------
1 | hasTable('usage_report')) {
28 | // $schema->dropTable('usage_report');
29 | // }
30 | // return $schema;
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/lib/Migration/Version1004Date20200630071803.php:
--------------------------------------------------------------------------------
1 | connection = $connection;
26 | }
27 |
28 | /**
29 | * @param IOutput $output
30 | * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
31 | * @param array $options
32 | */
33 | public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
34 | /** @var ISchemaWrapper $schema */
35 | $schema = $schemaClosure();
36 |
37 | if ($schema->hasTable('usage_report')) {
38 | $sourceTable = 'usage_report';
39 | } elseif ($schema->hasTable('usage_report_actions')) {
40 | $sourceTable = 'usage_report_actions';
41 | } else {
42 | return;
43 | }
44 |
45 | $insert = $this->connection->getQueryBuilder();
46 | $insert->insert('preferences')
47 | ->values([
48 | 'userid' => $insert->createParameter('userid'),
49 | 'appid' => $insert->createParameter('appid'),
50 | 'configkey' => $insert->createParameter('configkey'),
51 | 'configvalue' => $insert->createParameter('configvalue'),
52 | ]);
53 |
54 | $query = $this->connection->getQueryBuilder();
55 | $query->select(['user_id', 'action'])
56 | ->selectAlias($query->createFunction('COUNT(*)'), 'num_actions')
57 | ->from($sourceTable)
58 | ->groupBy('user_id')
59 | ->addGroupBy('action')
60 | ->orderBy('user_id', 'ASC')
61 | ->addOrderBy('action', 'ASC')
62 | ->setMaxResults(self::MIGRATION_SIZE);
63 |
64 | $offset = 0;
65 | do {
66 | $query->setFirstResult($offset);
67 | $result = $query->execute();
68 | $rows = $result->fetchAll();
69 | $result->closeCursor();
70 |
71 | if (empty($rows)) {
72 | return;
73 | }
74 |
75 | foreach ($rows as $row) {
76 | $insert->setParameter('userid', $row['user_id'])
77 | ->setParameter('appid', 'user_usage_report')
78 | ->setParameter('configkey', $row['action'])
79 | ->setParameter('configvalue', $row['num_actions']);
80 | $insert->execute();
81 | }
82 |
83 | $offset += self::MIGRATION_SIZE;
84 | } while (true);
85 | }
86 |
87 | /**
88 | * @param IOutput $output
89 | * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
90 | * @param array $options
91 | * @return null|ISchemaWrapper
92 | */
93 | public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
94 | /** @var ISchemaWrapper $schema */
95 | $schema = $schemaClosure();
96 |
97 | if ($schema->hasTable('usage_report_actions')) {
98 | $schema->dropTable('usage_report_actions');
99 | }
100 |
101 | if ($schema->hasTable('usage_report')) {
102 | $schema->dropTable('usage_report');
103 | }
104 |
105 | return $schema;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/lib/Reports/AllUsers.php:
--------------------------------------------------------------------------------
1 | connection = $connection;
50 | $this->config = $config;
51 | $this->userManager = $userManager;
52 | }
53 |
54 | /**
55 | * @param InputInterface $input
56 | * @param OutputInterface $output
57 | * @param OutputInterface $streamOutput
58 | */
59 | public function printReport(InputInterface $input, OutputInterface $output, OutputInterface $streamOutput): void {
60 | $this->createQueries();
61 |
62 | $default = [
63 | 'uploads' => 0,
64 | 'downloads' => 0,
65 | 'files' => 0,
66 | 'used' => FileInfo::SPACE_UNKNOWN,
67 | 'quota' => $this->config->getAppValue('files', 'default_quota', (string)FileInfo::SPACE_UNKNOWN),
68 | 'shares' => 0,
69 | 'login' => 0,
70 | 'display_name' => '',
71 | ];
72 |
73 | $progress = new ProgressBar($output);
74 |
75 | $i = 0;
76 | $this->userManager->callForAllUsers(function (IUser $user) use ($default, $input, $progress, &$i) {
77 | $this->reports[$user->getUID()] = $default;
78 | if ($input->getOption('display-name')) {
79 | $this->reports[$user->getUID()]['display_name'] = $user->getDisplayName();
80 | }
81 |
82 | $home = 'home::' . $user->getUID();
83 | if (strlen($home) > 64) {
84 | $home = md5($home);
85 | }
86 | $this->storageMap[$home] = $user->getUID();
87 |
88 | $home = 'object::user:' . $user->getUID();
89 | if (strlen($home) > 64) {
90 | $home = md5($home);
91 | }
92 | $this->storageMap[$home] = $user->getUID();
93 |
94 | if ($i % 200 === 0) {
95 | $progress->advance();
96 | }
97 | $i++;
98 | });
99 |
100 | $progress->advance();
101 |
102 | $this->getFilecacheStats($progress);
103 | $this->getNumberOfActions($progress);
104 | $this->getUserQuota($progress);
105 | $this->getNumberOfShares($progress);
106 | if ($input->getOption('last-login')) {
107 | $this->getUserLastLogin($progress);
108 | }
109 | $progress->advance();
110 |
111 |
112 | $progress->clear();
113 |
114 | foreach ($this->reports as $userId => $report) {
115 | $this->printRecord($input, $streamOutput, $userId, $report);
116 | }
117 | }
118 |
119 | protected function getNumberOfActions(ProgressBar $progress): void {
120 | $offset = 0;
121 | do {
122 | $numResults = $this->getNumberOfActionsBatch($offset);
123 | $offset += $numResults;
124 | $progress->advance();
125 | } while ($numResults === self::BATCH_SIZE);
126 | }
127 |
128 | /**
129 | * @param int $offset
130 | * @return int
131 | */
132 | protected function getNumberOfActionsBatch(int $offset): int {
133 | $query = $this->queries['countActions'];
134 | $query->setFirstResult($offset);
135 |
136 | $result = $query->executeQuery();
137 | $numResults = 0;
138 | while ($row = $result->fetch()) {
139 | try {
140 | $metric = $this->actionToMetric($row['action']);
141 | $this->reports[$row['user_id']][$metric] = (int)$row['num_actions'];
142 | } catch (\InvalidArgumentException $e) {
143 | }
144 | $numResults++;
145 | }
146 | $result->closeCursor();
147 |
148 | return $numResults;
149 | }
150 |
151 | protected function getFilecacheStats(ProgressBar $progress): void {
152 | $offset = 0;
153 | do {
154 | $result = $this->countFilesBatch($offset);
155 | $this->getRootSizeBatch($result);
156 | $this->mapStorageToUser($result);
157 |
158 | $offset += $result['results'];
159 | $progress->advance();
160 | } while ($result['results'] === self::BATCH_SIZE);
161 | }
162 |
163 | /**
164 | * @param int $offset
165 | * @return array
166 | */
167 | protected function countFilesBatch(int $offset): array {
168 | $query = $this->queries['countFiles'];
169 | $query->setFirstResult($offset);
170 |
171 | $result = $query->executeQuery();
172 | $numResults = $first = $last = 0;
173 |
174 | while ($row = $result->fetch()) {
175 | if ($first === 0) {
176 | $first = (int)$row['storage'];
177 | }
178 | $last = (int)$row['storage'];
179 | $this->storages[$last] = [
180 | 'files' => (int)$row['num_files'],
181 | 'used' => FileInfo::SPACE_UNKNOWN,
182 | ];
183 | $numResults++;
184 | }
185 | $result->closeCursor();
186 |
187 | return ['results' => $numResults, 'first' => $first, 'last' => $last];
188 | }
189 |
190 | /**
191 | * @param array $limits
192 | */
193 | protected function getRootSizeBatch(array $limits): void {
194 | $query = $this->queries['getUsedSpace'];
195 | $query->setParameter('bottom', $limits['first'])
196 | ->setParameter('top', $limits['last']);
197 |
198 | $result = $query->executeQuery();
199 | while ($row = $result->fetch()) {
200 | $this->storages[(int)$row['storage']]['used'] = (int)$row['size'];
201 | }
202 | $result->closeCursor();
203 | }
204 |
205 | protected function mapStorageToUser(array $limits): void {
206 | $query = $this->queries['getStorage'];
207 | $query->setParameter('bottom', $limits['first'])
208 | ->setParameter('top', $limits['last']);
209 |
210 | $result = $query->executeQuery();
211 | while ($row = $result->fetch()) {
212 | $storage = (int)$row['numeric_id'];
213 |
214 | if (!isset($this->storageMap[$row['id']], $this->storages[$storage])) {
215 | unset($this->storages[$storage]);
216 | continue;
217 | }
218 |
219 | $userId = $this->storageMap[$row['id']];
220 | $this->reports[$userId]['used'] = $this->storages[$storage]['used'];
221 | $this->reports[$userId]['files'] = $this->storages[$storage]['files'];
222 | unset($this->storages[$storage]);
223 | }
224 | $result->closeCursor();
225 | }
226 |
227 | protected function getUserQuota(ProgressBar $progress): void {
228 | $offset = 0;
229 | do {
230 | $numResults = $this->getUserQuotaBatch($offset);
231 | $offset += $numResults;
232 | $progress->advance();
233 | } while ($numResults === self::BATCH_SIZE);
234 | }
235 |
236 | /**
237 | * @param int $offset
238 | * @return int
239 | */
240 | protected function getUserQuotaBatch(int $offset): int {
241 | $query = $this->queries['getQuota'];
242 | $query->setFirstResult($offset);
243 |
244 | $result = $query->executeQuery();
245 | $numResults = 0;
246 | while ($row = $result->fetch()) {
247 | if ($row['configvalue'] !== 'default') {
248 | $quota = \OC_Helper::computerFileSize($row['configvalue']);
249 | $this->reports[$row['userid']]['quota'] = $quota === false ? $row['configvalue'] : $quota;
250 | }
251 | $numResults++;
252 | }
253 | $result->closeCursor();
254 |
255 | return $numResults;
256 | }
257 |
258 | protected function getUserLastLogin(ProgressBar $progress): void {
259 | $offset = 0;
260 | do {
261 | $numResults = $this->getUserLastLoginBatch($offset);
262 | $offset += $numResults;
263 | $progress->advance();
264 | } while ($numResults === self::BATCH_SIZE);
265 | }
266 |
267 | /**
268 | * @param int $offset
269 | * @return int
270 | */
271 | protected function getUserLastLoginBatch(int $offset): int {
272 | $query = $this->queries['lastLogin'];
273 | $query->setFirstResult($offset);
274 |
275 | $result = $query->executeQuery();
276 | $numResults = 0;
277 | while ($row = $result->fetch()) {
278 | $this->reports[$row['userid']]['login'] = $row['configvalue'];
279 | $numResults++;
280 | }
281 | $result->closeCursor();
282 |
283 | return $numResults;
284 | }
285 |
286 | protected function getNumberOfShares(ProgressBar $progress): void {
287 | $offset = 0;
288 | do {
289 | $numResults = $this->getNumberOfSharesBatch($offset);
290 | $offset += $numResults;
291 | $progress->advance();
292 | } while ($numResults === self::BATCH_SIZE);
293 | }
294 |
295 | /**
296 | * @param int $offset
297 | * @return int
298 | */
299 | protected function getNumberOfSharesBatch(int $offset): int {
300 | $query = $this->queries['countShares'];
301 | $query->setFirstResult($offset);
302 |
303 | $result = $query->executeQuery();
304 | $numResults = 0;
305 | while ($row = $result->fetch()) {
306 | if (array_key_exists($row['uid_initiator'], $this->reports)) {
307 | $this->reports[$row['uid_initiator']]['shares'] = (int)$row['num_shares'];
308 | }
309 | $numResults++;
310 | }
311 | $result->closeCursor();
312 |
313 | return $numResults;
314 | }
315 |
316 | /**
317 | * @param string $action
318 | * @return 'uploads'|'downloads'
319 | * @throws \InvalidArgumentException
320 | */
321 | protected function actionToMetric(string $action): string {
322 | switch ($action) {
323 | case 'created':
324 | return 'uploads';
325 | case 'read':
326 | return 'downloads';
327 | default:
328 | throw new \InvalidArgumentException('Unknown action');
329 | }
330 | }
331 |
332 | protected function createQueries(): void {
333 | if (!empty($this->queries)) {
334 | return;
335 | }
336 |
337 | // Get home storage
338 | $query = $this->connection->getQueryBuilder();
339 | $query->select(['numeric_id', 'id'])
340 | ->from('storages')
341 | ->where($query->expr()->gte('numeric_id', $query->createParameter('bottom')))
342 | ->andWhere($query->expr()->lte('numeric_id', $query->createParameter('top')));
343 | $this->queries['getStorage'] = $query;
344 |
345 | // Get number of files
346 | $query = $this->connection->getQueryBuilder();
347 | $query->select('storage')
348 | ->selectAlias($query->createFunction('COUNT(*)'), 'num_files')
349 | ->from('filecache')
350 | ->groupBy('storage')
351 | ->orderBy('storage', 'ASC');
352 | $this->queries['countFiles'] = $query;
353 |
354 | // Get used quota
355 | $query = $this->connection->getQueryBuilder();
356 | $query->select(['storage', 'size'])
357 | ->from('filecache')
358 | ->where($query->expr()->gte('storage', $query->createParameter('bottom')))
359 | ->andWhere($query->expr()->lte('storage', $query->createParameter('top')))
360 | ->andWhere($query->expr()->eq('path_hash', $query->createNamedParameter(md5('files'))));
361 | $this->queries['getUsedSpace'] = $query;
362 |
363 | // Get quota
364 | $query = $this->connection->getQueryBuilder();
365 | $query->select(['userid', 'configvalue'])
366 | ->from('preferences')
367 | ->where($query->expr()->eq('appid', $query->createNamedParameter('files')))
368 | ->andWhere($query->expr()->eq('configkey', $query->createNamedParameter('quota')))
369 | ->orderBy('userid', 'ASC')
370 | ->setMaxResults(self::BATCH_SIZE);
371 | $this->queries['getQuota'] = $query;
372 |
373 | // Get last_login
374 | $query = $this->connection->getQueryBuilder();
375 | $query->select(['userid', 'configvalue'])
376 | ->from('preferences')
377 | ->where($query->expr()->eq('appid', $query->createNamedParameter('login')))
378 | ->andWhere($query->expr()->eq('configkey', $query->createNamedParameter('lastLogin')))
379 | ->orderBy('userid', 'ASC')
380 | ->setMaxResults(self::BATCH_SIZE);
381 | $this->queries['lastLogin'] = $query;
382 |
383 | // Get number of shares
384 | $query = $this->connection->getQueryBuilder();
385 | $query->select('uid_initiator')
386 | ->selectAlias($query->createFunction('COUNT(*)'), 'num_shares')
387 | ->from('share')
388 | ->groupBy('uid_initiator')
389 | ->orderBy('uid_initiator', 'ASC')
390 | ->setMaxResults(self::BATCH_SIZE);
391 | $this->queries['countShares'] = $query;
392 |
393 | // Get number of downloads and uploads
394 | $query = $this->connection->getQueryBuilder();
395 | $query->selectAlias('userid', 'user_id')
396 | ->selectAlias('configkey', 'action')
397 | ->selectAlias('configvalue', 'num_actions')
398 | ->from('preferences')
399 | ->where($query->expr()->eq('appid', $query->createNamedParameter('user_usage_report')))
400 | ->orderBy('userid', 'ASC')
401 | ->addOrderBy('configkey', 'ASC');
402 | $this->queries['countActions'] = $query;
403 | }
404 | }
405 |
--------------------------------------------------------------------------------
/lib/Reports/SingleUser.php:
--------------------------------------------------------------------------------
1 | connection = $connection;
33 | $this->config = $config;
34 | }
35 |
36 | /**
37 | * @param InputInterface $input
38 | * @param OutputInterface $output
39 | * @param string $userId
40 | */
41 | public function printReport(InputInterface $input, OutputInterface $output, string $userId): void {
42 | $this->createQueries();
43 |
44 | $report = array_merge(
45 | $this->getNumberOfActionsForUser($userId),
46 | $this->getFilecacheStatsForUser($userId)
47 | );
48 |
49 | $report['quota'] = $this->getUserQuota($userId);
50 | if (is_numeric($report['quota'])) {
51 | $report['quota'] = (int)$report['quota'];
52 | }
53 | if ($input->getOption('last-login')) {
54 | $report['login'] = $this->getUserLastLogin($userId);
55 | }
56 | $report['shares'] = $this->getNumberOfSharesForUser($userId);
57 | if ($input->getOption('display-name')) {
58 | $report['display_name'] = $this->getUserDisplayName($userId);
59 | }
60 |
61 | $this->printRecord($input, $output, $userId, $report);
62 | }
63 |
64 | /**
65 | * @param string $userId
66 | * @return array
67 | */
68 | protected function getNumberOfActionsForUser(string $userId): array {
69 | $query = $this->queries['countActions'];
70 | $query->setParameter('user', $userId);
71 | $result = $query->executeQuery();
72 |
73 | $numActions = [
74 | 'uploads' => 0,
75 | 'downloads' => 0,
76 | ];
77 |
78 | while ($row = $result->fetch()) {
79 | try {
80 | $metric = $this->actionToMetric($row['action']);
81 | $numActions[$metric] = (int)$row['num_actions'];
82 | } catch (\InvalidArgumentException $e) {
83 | continue;
84 | }
85 | }
86 | $result->closeCursor();
87 |
88 | return $numActions;
89 | }
90 |
91 | /**
92 | * @param string $userId
93 | * @return array
94 | */
95 | protected function getFilecacheStatsForUser(string $userId): array {
96 | $query = $this->queries['getStorageId'];
97 |
98 | $home = 'home::' . $userId;
99 | if (strlen($home) > 64) {
100 | $home = md5($home);
101 | }
102 |
103 | $query->setParameter('storage_identifier', $home);
104 | $result = $query->executeQuery();
105 | $storageId = (int)$result->fetchOne();
106 | $result->closeCursor();
107 |
108 | if ($storageId === 0) {
109 | $home = 'object::user:' . $userId;
110 | if (strlen($home) > 64) {
111 | $home = md5($home);
112 | }
113 |
114 | $query->setParameter('storage_identifier', $home);
115 | $result = $query->executeQuery();
116 | $storageId = (int)$result->fetchOne();
117 | $result->closeCursor();
118 | }
119 |
120 | $query = $this->queries['countFiles'];
121 | $query->setParameter('storage_identifier', $storageId);
122 | $result = $query->executeQuery();
123 | $numFiles = (int)$result->fetchOne();
124 | $result->closeCursor();
125 |
126 | $query = $this->queries['getUsedSpace'];
127 | $query->setParameter('storage_identifier', $storageId);
128 | $result = $query->executeQuery();
129 | $usedSpace = (int)$result->fetchOne();
130 | $result->closeCursor();
131 |
132 | return [
133 | 'files' => $numFiles,
134 | 'used' => $usedSpace,
135 | ];
136 | }
137 |
138 | /**
139 | * @param string $userId
140 | * @return int
141 | */
142 | protected function getUserLastLogin(string $userId): int {
143 | $query = $this->queries['lastLogin'];
144 | $query->setParameter('user', $userId);
145 | $result = $query->executeQuery();
146 | $lastLogin = $result->fetchOne();
147 | $result->closeCursor();
148 |
149 | return (int)$lastLogin;
150 | }
151 |
152 | /**
153 | * @param string $userId
154 | * @return int|string
155 | */
156 | protected function getUserQuota(string $userId) {
157 | $query = $this->queries['getQuota'];
158 | $query->setParameter('user', $userId);
159 | $result = $query->executeQuery();
160 | $quota = $result->fetchOne();
161 | $result->closeCursor();
162 |
163 | if (is_numeric($quota)) {
164 | return (int)$quota;
165 | }
166 |
167 | if ($quota === 'none') {
168 | return FileInfo::SPACE_UNLIMITED;
169 | }
170 |
171 | if ($quota) {
172 | $quota = \OC_Helper::computerFileSize($quota);
173 | if ($quota !== false) {
174 | return (int)$quota;
175 | }
176 | }
177 |
178 | return $this->config->getAppValue('files', 'default_quota', (string)FileInfo::SPACE_UNKNOWN);
179 | }
180 |
181 | /**
182 | * @param string $userId
183 | * @return int
184 | */
185 | protected function getNumberOfSharesForUser(string $userId): int {
186 | $query = $this->queries['countShares'];
187 | $query->setParameter('initiator', $userId);
188 | $result = $query->executeQuery();
189 | $numShares = (int)$result->fetchOne();
190 | $result->closeCursor();
191 |
192 | return $numShares;
193 | }
194 |
195 | protected function getUserDisplayName(string $userId): ?string {
196 | $query = $this->queries['displayName'];
197 | $query->setParameter('user', $userId);
198 | $result = $query->executeQuery();
199 |
200 | if ($result->rowCount() === 0) {
201 | return null;
202 | }
203 |
204 | return (string)$result->fetchOne();
205 | }
206 |
207 |
208 | /**
209 | * @param string $action
210 | * @return string
211 | * @throws \InvalidArgumentException
212 | */
213 | protected function actionToMetric(string $action): string {
214 | switch ($action) {
215 | case 'created':
216 | return 'uploads';
217 | case 'read':
218 | return 'downloads';
219 | default:
220 | throw new \InvalidArgumentException('Unknown action');
221 | }
222 | }
223 |
224 | protected function createQueries(): void {
225 | if (!empty($this->queries)) {
226 | return;
227 | }
228 |
229 | // Get home storage
230 | $query = $this->connection->getQueryBuilder();
231 | $query->select('numeric_id')
232 | ->from('storages')
233 | ->where($query->expr()->eq('id', $query->createParameter('storage_identifier')));
234 | $this->queries['getStorageId'] = $query;
235 |
236 | // Get number of files
237 | $query = $this->connection->getQueryBuilder();
238 | $query->selectAlias($query->createFunction('COUNT(*)'), 'num_files')
239 | ->from('filecache')
240 | ->where($query->expr()->eq('storage', $query->createParameter('storage_identifier')));
241 | $this->queries['countFiles'] = $query;
242 |
243 | // Get used quota
244 | $query = $this->connection->getQueryBuilder();
245 | $query->select('size')
246 | ->from('filecache')
247 | ->where($query->expr()->eq('storage', $query->createParameter('storage_identifier')))
248 | ->andWhere($query->expr()->eq('path_hash', $query->createNamedParameter(md5('files'))));
249 | $this->queries['getUsedSpace'] = $query;
250 |
251 | // Get quota
252 | $query = $this->connection->getQueryBuilder();
253 | $query->select('configvalue')
254 | ->from('preferences')
255 | ->where($query->expr()->eq('userid', $query->createParameter('user')))
256 | ->andWhere($query->expr()->eq('appid', $query->createNamedParameter('files')))
257 | ->andWhere($query->expr()->eq('configkey', $query->createNamedParameter('quota')));
258 | $this->queries['getQuota'] = $query;
259 |
260 | // Get quota
261 | $query = $this->connection->getQueryBuilder();
262 | $query->select('configvalue')
263 | ->from('preferences')
264 | ->where($query->expr()->eq('userid', $query->createParameter('user')))
265 | ->andWhere($query->expr()->eq('appid', $query->createNamedParameter('login')))
266 | ->andWhere($query->expr()->eq('configkey', $query->createNamedParameter('lastLogin')));
267 | $this->queries['lastLogin'] = $query;
268 |
269 | // Get number of shares
270 | $query = $this->connection->getQueryBuilder();
271 | $query->selectAlias($query->createFunction('COUNT(*)'), 'num_shares')
272 | ->from('share')
273 | ->where($query->expr()->eq('uid_initiator', $query->createParameter('initiator')));
274 | $this->queries['countShares'] = $query;
275 |
276 | // Get number of downloads and uploads
277 | $query = $this->connection->getQueryBuilder();
278 | $query->selectAlias('configkey', 'action')
279 | ->selectAlias('configvalue', 'num_actions')
280 | ->from('preferences')
281 | ->where($query->expr()->eq('userid', $query->createParameter('user')))
282 | ->andWhere($query->expr()->eq('appid', $query->createParameter('appid')))
283 | ->orderBy('userid', 'ASC')
284 | ->addOrderBy('configkey', 'ASC')
285 | ->setParameter('appid', 'user_usage_report');
286 | $this->queries['countActions'] = $query;
287 |
288 | // Get User Display Name
289 | $query = $this->connection->getQueryBuilder();
290 | $query->select('value')
291 | ->from('accounts_data')
292 | ->where($query->expr()->eq('name', $query->createNamedParameter('displayname')))
293 | ->andWhere($query->expr()->eq('uid', $query->createParameter('user')));
294 | $this->queries['displayName'] = $query;
295 | }
296 | }
297 |
--------------------------------------------------------------------------------
/psalm.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/tests/bootstrap.php:
--------------------------------------------------------------------------------
1 | get(IAppManager::class)->loadApp('user_usage_report');
18 | OC_Hook::clear();
19 |
--------------------------------------------------------------------------------
/tests/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
12 |
13 | ../../user_usage_report/lib
14 |
15 |
16 | ../../user_usage_report/l10n
17 | ../../user_usage_report/tests
18 |
19 |
20 |
21 | .
22 |
23 |
24 |
--------------------------------------------------------------------------------
/tests/psalm-baseline.xml:
--------------------------------------------------------------------------------
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 | expr()->castColumn('configvalue', IQueryBuilder::PARAM_INT)]]>
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 |
60 |
61 | dropTable('usage_report_actions')]]>
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/tests/psalm-baseline.xml.license:
--------------------------------------------------------------------------------
1 | SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
2 | SPDX-License-Identifier: AGPL-3.0-or-later
3 |
--------------------------------------------------------------------------------
/vendor-bin/cs-fixer/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require-dev": {
3 | "nextcloud/coding-standard": "^1.3"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/vendor-bin/cs-fixer/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "d0631b9ae59c4002db807918a547e53c",
8 | "packages": [],
9 | "packages-dev": [
10 | {
11 | "name": "kubawerlos/php-cs-fixer-custom-fixers",
12 | "version": "v3.24.0",
13 | "source": {
14 | "type": "git",
15 | "url": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers.git",
16 | "reference": "93222100a91399314c3726857e249e76c4a7d760"
17 | },
18 | "dist": {
19 | "type": "zip",
20 | "url": "https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/93222100a91399314c3726857e249e76c4a7d760",
21 | "reference": "93222100a91399314c3726857e249e76c4a7d760",
22 | "shasum": ""
23 | },
24 | "require": {
25 | "ext-filter": "*",
26 | "ext-tokenizer": "*",
27 | "friendsofphp/php-cs-fixer": "^3.61.1",
28 | "php": "^7.4 || ^8.0"
29 | },
30 | "require-dev": {
31 | "phpunit/phpunit": "^9.6.22 || 10.5.45 || ^11.5.7"
32 | },
33 | "type": "library",
34 | "autoload": {
35 | "psr-4": {
36 | "PhpCsFixerCustomFixers\\": "src"
37 | }
38 | },
39 | "notification-url": "https://packagist.org/downloads/",
40 | "license": [
41 | "MIT"
42 | ],
43 | "authors": [
44 | {
45 | "name": "Kuba Werłos",
46 | "email": "werlos@gmail.com"
47 | }
48 | ],
49 | "description": "A set of custom fixers for PHP CS Fixer",
50 | "support": {
51 | "issues": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/issues",
52 | "source": "https://github.com/kubawerlos/php-cs-fixer-custom-fixers/tree/v3.24.0"
53 | },
54 | "time": "2025-03-22T16:51:39+00:00"
55 | },
56 | {
57 | "name": "nextcloud/coding-standard",
58 | "version": "v1.3.2",
59 | "source": {
60 | "type": "git",
61 | "url": "https://github.com/nextcloud/coding-standard.git",
62 | "reference": "9c719c4747fa26efc12f2e8b21c14a9a75c6ba6d"
63 | },
64 | "dist": {
65 | "type": "zip",
66 | "url": "https://api.github.com/repos/nextcloud/coding-standard/zipball/9c719c4747fa26efc12f2e8b21c14a9a75c6ba6d",
67 | "reference": "9c719c4747fa26efc12f2e8b21c14a9a75c6ba6d",
68 | "shasum": ""
69 | },
70 | "require": {
71 | "kubawerlos/php-cs-fixer-custom-fixers": "^3.22",
72 | "php": "^7.3|^8.0",
73 | "php-cs-fixer/shim": "^3.17"
74 | },
75 | "type": "library",
76 | "autoload": {
77 | "psr-4": {
78 | "Nextcloud\\CodingStandard\\": "src"
79 | }
80 | },
81 | "notification-url": "https://packagist.org/downloads/",
82 | "license": [
83 | "MIT"
84 | ],
85 | "authors": [
86 | {
87 | "name": "Christoph Wurst",
88 | "email": "christoph@winzerhof-wurst.at"
89 | }
90 | ],
91 | "description": "Nextcloud coding standards for the php cs fixer",
92 | "support": {
93 | "issues": "https://github.com/nextcloud/coding-standard/issues",
94 | "source": "https://github.com/nextcloud/coding-standard/tree/v1.3.2"
95 | },
96 | "time": "2024-10-14T16:49:05+00:00"
97 | },
98 | {
99 | "name": "php-cs-fixer/shim",
100 | "version": "v3.75.0",
101 | "source": {
102 | "type": "git",
103 | "url": "https://github.com/PHP-CS-Fixer/shim.git",
104 | "reference": "eea219a577085bd13ff0cb644a422c20798316c7"
105 | },
106 | "dist": {
107 | "type": "zip",
108 | "url": "https://api.github.com/repos/PHP-CS-Fixer/shim/zipball/eea219a577085bd13ff0cb644a422c20798316c7",
109 | "reference": "eea219a577085bd13ff0cb644a422c20798316c7",
110 | "shasum": ""
111 | },
112 | "require": {
113 | "ext-json": "*",
114 | "ext-tokenizer": "*",
115 | "php": "^7.4 || ^8.0"
116 | },
117 | "replace": {
118 | "friendsofphp/php-cs-fixer": "self.version"
119 | },
120 | "suggest": {
121 | "ext-dom": "For handling output formats in XML",
122 | "ext-mbstring": "For handling non-UTF8 characters."
123 | },
124 | "bin": [
125 | "php-cs-fixer",
126 | "php-cs-fixer.phar"
127 | ],
128 | "type": "application",
129 | "notification-url": "https://packagist.org/downloads/",
130 | "license": [
131 | "MIT"
132 | ],
133 | "authors": [
134 | {
135 | "name": "Fabien Potencier",
136 | "email": "fabien@symfony.com"
137 | },
138 | {
139 | "name": "Dariusz Rumiński",
140 | "email": "dariusz.ruminski@gmail.com"
141 | }
142 | ],
143 | "description": "A tool to automatically fix PHP code style",
144 | "support": {
145 | "issues": "https://github.com/PHP-CS-Fixer/shim/issues",
146 | "source": "https://github.com/PHP-CS-Fixer/shim/tree/v3.75.0"
147 | },
148 | "time": "2025-03-31T18:45:02+00:00"
149 | }
150 | ],
151 | "aliases": [],
152 | "minimum-stability": "stable",
153 | "stability-flags": {},
154 | "prefer-stable": false,
155 | "prefer-lowest": false,
156 | "platform": {},
157 | "platform-dev": {},
158 | "plugin-api-version": "2.6.0"
159 | }
160 |
--------------------------------------------------------------------------------
/vendor-bin/phpunit/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require-dev": {
3 | "phpunit/phpunit": "^10"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/vendor-bin/psalm/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require-dev": {
3 | "vimeo/psalm": "^6.11"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------