├── .eslintrc.yml ├── .github └── workflows │ ├── linters.yml │ └── tests.yml ├── .gitignore ├── .rubocop.yml ├── .slim-lint.yml ├── .stylelintrc.json ├── CHANGELOG.md ├── INSPECTORS.md ├── LICENSE ├── README.md ├── app ├── controllers │ └── terms_controller.rb ├── helpers │ └── privacy_terms_helper.rb └── views │ ├── redmine_privacy_terms │ ├── _html_head.html.slim │ └── settings │ │ ├── _cookie_agreement.html.slim │ │ ├── _inspect.html.slim │ │ ├── _settings.html.slim │ │ ├── _terms.html.slim │ │ └── _tools.html.slim │ └── users │ └── _privacy_terms_show.html.slim ├── assets ├── javascripts │ ├── .eslintignore │ └── cookie-consent.min.js └── stylesheets │ ├── .stylelintignore │ └── privacy_terms.css ├── config ├── locales │ ├── de.yml │ └── en.yml ├── routes.rb └── settings.yml ├── db └── migrate │ └── 001_add_accept_terms_at_to_user.rb ├── init.rb ├── lib ├── redmine_privacy_terms.rb └── redmine_privacy_terms │ ├── hooks │ ├── model_hook.rb │ └── view_hook.rb │ ├── patches │ ├── application_controller_patch.rb │ └── user_patch.rb │ └── wiki_macros │ ├── terms_accept_macro.rb │ └── terms_reject_macro.rb └── test ├── functional └── terms_controller_test.rb ├── integration └── routing_test.rb ├── support ├── configuration.yml ├── database-mysql.yml ├── database-postgres.yml └── gemfile.rb ├── test_helper.rb └── unit └── i18n_test.rb /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | browser: true 3 | jquery: true 4 | extends: 5 | - 'eslint:recommended' 6 | - 'plugin:no-jquery/deprecated' 7 | plugins: 8 | - no-jquery 9 | parserOptions: 10 | ecmaVersion: 2019 11 | rules: 12 | indent: 13 | - error 14 | - 2 15 | linebreak-style: 16 | - error 17 | - unix 18 | quotes: 19 | - error 20 | - single 21 | semi: 22 | - error 23 | - always 24 | -------------------------------------------------------------------------------- /.github/workflows/linters.yml: -------------------------------------------------------------------------------- 1 | name: Run Linters 2 | on: 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | test: 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v5 12 | 13 | - name: Setup Ruby 14 | uses: ruby/setup-ruby@v1 15 | with: 16 | ruby-version: 3.3 17 | bundler-cache: true 18 | 19 | - name: Setup gems 20 | run: | 21 | cp test/support/gemfile.rb Gemfile 22 | bundle install --jobs 4 --retry 3 23 | 24 | - name: Run RuboCop 25 | run: | 26 | bundle exec rubocop -S 27 | 28 | - name: Run Slim-Lint 29 | run: | 30 | bundle exec slim-lint app/views 31 | if: always() 32 | 33 | - name: Run Brakeman 34 | run: | 35 | bundle exec brakeman -5 36 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | test: 8 | name: ${{ matrix.redmine }} ${{ matrix.db }} ruby-${{ matrix.ruby }} 9 | runs-on: ubuntu-latest 10 | 11 | strategy: 12 | matrix: 13 | ruby: ['3.1', '3.2', '3.3', '3.4'] 14 | redmine: ['6.0-stable', 'master'] 15 | db: ['postgres', 'mysql'] 16 | exclude: 17 | - ruby: '3.1' 18 | redmine: master 19 | - ruby: '3.4' 20 | redmine: 6.0-stable 21 | fail-fast: false 22 | 23 | services: 24 | postgres: 25 | image: postgres:17 26 | env: 27 | POSTGRES_USER: postgres 28 | POSTGRES_PASSWORD: postgres 29 | ports: 30 | - 5432:5432 31 | 32 | options: >- 33 | --health-cmd pg_isready 34 | --health-interval 10s 35 | --health-timeout 5s 36 | --health-retries 5 37 | 38 | mysql: 39 | image: mysql:8.0 40 | env: 41 | MYSQL_ROOT_PASSWORD: 'BestPasswordEver' 42 | ports: 43 | # will assign a random free host port 44 | - 3306/tcp 45 | options: >- 46 | --health-cmd="mysqladmin ping" 47 | --health-interval=10s 48 | --health-timeout=5s 49 | --health-retries=3 50 | 51 | steps: 52 | - name: Verify MySQL connection from host 53 | run: | 54 | mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -uroot -pBestPasswordEver -e "SHOW DATABASES" 55 | if: matrix.db == 'mysql' 56 | 57 | - name: Checkout Redmine 58 | uses: actions/checkout@v5 59 | with: 60 | repository: redmine/redmine 61 | ref: ${{ matrix.redmine }} 62 | path: redmine 63 | 64 | - name: Checkout additionals 65 | uses: actions/checkout@v5 66 | with: 67 | repository: AlphaNodes/additionals 68 | path: redmine/plugins/additionals 69 | 70 | - name: Checkout redmine_privacy_terms 71 | uses: actions/checkout@v5 72 | with: 73 | path: redmine/plugins/redmine_privacy_terms 74 | 75 | - name: Update package archives 76 | run: sudo apt-get update --yes --quiet 77 | 78 | - name: Install package dependencies 79 | run: > 80 | sudo apt-get install --yes --quiet 81 | build-essential 82 | cmake 83 | libicu-dev 84 | libpq-dev 85 | libmysqlclient-dev 86 | 87 | - name: Setup Ruby 88 | uses: ruby/setup-ruby@v1 89 | with: 90 | ruby-version: ${{ matrix.ruby }} 91 | bundler-cache: true # runs 'bundle install' and caches installed gems automatically 92 | 93 | - name: Prepare Redmine source 94 | working-directory: redmine 95 | run: | 96 | cp plugins/redmine_privacy_terms/test/support/database-${{ matrix.db }}.yml config/database.yml 97 | cp plugins/redmine_privacy_terms/test/support/configuration.yml config/configuration.yml 98 | 99 | - name: Install Ruby dependencies 100 | working-directory: redmine 101 | run: | 102 | bundle config set --local without 'development' 103 | bundle install --jobs=4 --retry=3 104 | 105 | - name: Run Redmine rake tasks 106 | env: 107 | RAILS_ENV: test 108 | MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} 109 | working-directory: redmine 110 | run: | 111 | bundle exec rake generate_secret_token 112 | bundle exec rake db:create db:migrate redmine:plugins:migrate 113 | bundle exec rake db:test:prepare 114 | 115 | - name: Run tests 116 | env: 117 | RAILS_ENV: test 118 | MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} 119 | working-directory: redmine 120 | run: bundle exec rake redmine:plugins:test NAME=redmine_privacy_terms RUBYOPT="-W0" 121 | 122 | - name: Run uninstall test 123 | env: 124 | RAILS_ENV: test 125 | MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} 126 | working-directory: redmine 127 | run: bundle exec rake redmine:plugins:migrate NAME=redmine_privacy_terms VERSION=0 128 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .buildpath 3 | coverage/ 4 | .project 5 | .settings/ 6 | .enable_dev 7 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - rubocop-performance 3 | - rubocop-rails 4 | - rubocop-minitest 5 | 6 | AllCops: 7 | TargetRubyVersion: 3.1 8 | TargetRailsVersion: 7.2 9 | NewCops: enable 10 | 11 | Rails: 12 | Enabled: true 13 | 14 | Minitest/MultipleAssertions: 15 | Max: 5 16 | Enabled: true 17 | 18 | Minitest/AssertPredicate: 19 | Enabled: false 20 | 21 | Metrics/AbcSize: 22 | Enabled: false 23 | 24 | Metrics/BlockLength: 25 | Enabled: false 26 | 27 | Metrics/ParameterLists: 28 | Enabled: true 29 | CountKeywordArgs: false 30 | 31 | Metrics/ClassLength: 32 | Enabled: false 33 | 34 | Metrics/CyclomaticComplexity: 35 | Max: 20 36 | 37 | Layout/LineLength: 38 | Max: 140 39 | 40 | Metrics/MethodLength: 41 | Max: 60 42 | 43 | Metrics/ModuleLength: 44 | Enabled: false 45 | 46 | Metrics/PerceivedComplexity: 47 | Max: 25 48 | 49 | Rails/SkipsModelValidations: 50 | Enabled: false 51 | 52 | Performance/ChainArrayAllocation: 53 | Enabled: true 54 | 55 | Style/AutoResourceCleanup: 56 | Enabled: true 57 | 58 | Style/ExpandPathArguments: 59 | Enabled: true 60 | Exclude: 61 | - test/**/* 62 | 63 | Style/FrozenStringLiteralComment: 64 | Enabled: true 65 | Exclude: 66 | - '/**/*.rsb' 67 | 68 | Style/OptionHash: 69 | Enabled: true 70 | SuspiciousParamNames: 71 | - options 72 | - api_options 73 | - opts 74 | - args 75 | - params 76 | - parameters 77 | - settings 78 | Exclude: 79 | - lib/redmine_privacy_terms/patches/*.rb 80 | 81 | Style/ReturnNil: 82 | Enabled: true 83 | 84 | Style/UnlessLogicalOperators: 85 | Enabled: true 86 | 87 | Style/MethodCallWithArgsParentheses: 88 | Enabled: true 89 | AllowParenthesesInMultilineCall: true 90 | AllowParenthesesInChaining: true 91 | EnforcedStyle: omit_parentheses 92 | 93 | Style/Documentation: 94 | Enabled: false 95 | 96 | Naming/VariableNumber: 97 | Enabled: false 98 | -------------------------------------------------------------------------------- /.slim-lint.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | LineLength: 3 | max: 180 4 | RuboCop: 5 | ignored_cops: 6 | - Layout/ArgumentAlignment 7 | - Layout/ArrayAlignment 8 | - Layout/BlockEndNewline 9 | - Layout/EmptyLineAfterGuardClause 10 | - Layout/HashAlignment 11 | - Layout/IndentationConsistency 12 | - Layout/IndentationWidth 13 | - Layout/IndentFirstArgument 14 | - Layout/IndentFirstArrayElement 15 | - Layout/IndentFirstHashElement 16 | - Layout/MultilineArrayBraceLayout 17 | - Layout/MultilineAssignmentLayout 18 | - Layout/MultilineBlockLayout 19 | - Layout/MultilineHashBraceLayout 20 | - Layout/MultilineMethodCallBraceLayout 21 | - Layout/MultilineMethodCallIndentation 22 | - Layout/MultilineMethodDefinitionBraceLayout 23 | - Layout/MultilineOperationIndentation 24 | - Layout/TrailingBlankLines 25 | - Layout/TrailingEmptyLines 26 | - Layout/TrailingWhitespace 27 | - Lint/BlockAlignment 28 | - Lint/EndAlignment 29 | - Lint/Void 30 | - Metrics/BlockLength 31 | - Metrics/BlockNesting 32 | - Metrics/LineLength 33 | - Naming/FileName 34 | - Rails/OutputSafety 35 | - Style/ConditionalAssignment 36 | - Style/FrozenStringLiteralComment 37 | - Style/IdenticalConditionalBranches 38 | - Style/IfUnlessModifier 39 | - Style/Next 40 | - Style/RedundantLineContinuation 41 | - Style/WhileUntilModifier 42 | -------------------------------------------------------------------------------- /.stylelintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "at-rule-no-unknown": true, 4 | "block-no-empty": true, 5 | "color-no-invalid-hex": true, 6 | "comment-no-empty": true, 7 | "declaration-block-no-duplicate-properties": [ 8 | true, 9 | { 10 | "ignore": [ 11 | "consecutive-duplicates-with-different-values" 12 | ] 13 | } 14 | ], 15 | "declaration-property-unit-disallowed-list": { 16 | "font-size": [ 17 | "px" 18 | ] 19 | }, 20 | "declaration-block-no-redundant-longhand-properties": true, 21 | "declaration-block-no-shorthand-property-overrides": true, 22 | "font-family-no-duplicate-names": true, 23 | "font-family-no-missing-generic-family-keyword": true, 24 | "function-calc-no-unspaced-operator": true, 25 | "function-linear-gradient-no-nonstandard-direction": true, 26 | "keyframe-declaration-no-important": true, 27 | "media-feature-name-no-unknown": true, 28 | "no-descending-specificity": true, 29 | "no-duplicate-at-import-rules": true, 30 | "no-duplicate-selectors": true, 31 | "no-empty-source": true, 32 | "no-extra-semicolons": true, 33 | "no-invalid-double-slash-comments": true, 34 | "property-no-unknown": true, 35 | "selector-pseudo-class-no-unknown": true, 36 | "selector-pseudo-element-no-unknown": true, 37 | "selector-type-no-unknown": true, 38 | "string-no-newline": true, 39 | "unit-no-unknown": true, 40 | "at-rule-empty-line-before": [ 41 | "always", 42 | { 43 | "except": [ 44 | "blockless-after-same-name-blockless", 45 | "first-nested" 46 | ], 47 | "ignore": [ 48 | "after-comment" 49 | ] 50 | } 51 | ], 52 | "at-rule-name-case": "lower", 53 | "at-rule-name-space-after": "always-single-line", 54 | "at-rule-semicolon-newline-after": "always", 55 | "block-closing-brace-empty-line-before": "never", 56 | "block-closing-brace-newline-after": "always", 57 | "block-closing-brace-newline-before": "always-multi-line", 58 | "block-closing-brace-space-before": "always-single-line", 59 | "block-opening-brace-newline-after": "always-multi-line", 60 | "block-opening-brace-space-after": "always-single-line", 61 | "block-opening-brace-space-before": "always", 62 | "color-hex-case": "lower", 63 | "color-hex-length": "short", 64 | "comment-empty-line-before": [ 65 | "always", 66 | { 67 | "except": [ 68 | "first-nested" 69 | ], 70 | "ignore": [ 71 | "stylelint-commands" 72 | ] 73 | } 74 | ], 75 | "comment-whitespace-inside": "always", 76 | "custom-property-empty-line-before": [ 77 | "always", 78 | { 79 | "except": [ 80 | "after-custom-property", 81 | "first-nested" 82 | ], 83 | "ignore": [ 84 | "after-comment", 85 | "inside-single-line-block" 86 | ] 87 | } 88 | ], 89 | "declaration-bang-space-after": "never", 90 | "declaration-bang-space-before": "always", 91 | "declaration-block-semicolon-newline-after": "always-multi-line", 92 | "declaration-block-semicolon-space-after": "always-single-line", 93 | "declaration-block-semicolon-space-before": "never", 94 | "declaration-block-single-line-max-declarations": 1, 95 | "declaration-block-trailing-semicolon": "always", 96 | "declaration-colon-newline-after": "always-multi-line", 97 | "declaration-colon-space-after": "always-single-line", 98 | "declaration-colon-space-before": "never", 99 | "declaration-empty-line-before": [ 100 | "always", 101 | { 102 | "except": [ 103 | "after-declaration", 104 | "first-nested" 105 | ], 106 | "ignore": [ 107 | "after-comment", 108 | "inside-single-line-block" 109 | ] 110 | } 111 | ], 112 | "function-comma-newline-after": "always-multi-line", 113 | "function-comma-space-after": "always-single-line", 114 | "function-comma-space-before": "never", 115 | "function-max-empty-lines": 0, 116 | "function-name-case": "lower", 117 | "function-parentheses-newline-inside": "always-multi-line", 118 | "function-parentheses-space-inside": "never-single-line", 119 | "function-whitespace-after": "always", 120 | "indentation": 2, 121 | "length-zero-no-unit": true, 122 | "max-empty-lines": 1, 123 | "media-feature-colon-space-after": "always", 124 | "media-feature-colon-space-before": "never", 125 | "media-feature-name-case": "lower", 126 | "media-feature-parentheses-space-inside": "never", 127 | "media-feature-range-operator-space-after": "always", 128 | "media-feature-range-operator-space-before": "always", 129 | "media-query-list-comma-newline-after": "always-multi-line", 130 | "media-query-list-comma-space-after": "always-single-line", 131 | "media-query-list-comma-space-before": "never", 132 | "no-eol-whitespace": true, 133 | "no-missing-end-of-source-newline": true, 134 | "number-leading-zero": "always", 135 | "number-no-trailing-zeros": true, 136 | "property-case": "lower", 137 | "rule-empty-line-before": [ 138 | "always-multi-line", 139 | { 140 | "except": [ 141 | "first-nested" 142 | ], 143 | "ignore": [ 144 | "after-comment" 145 | ] 146 | } 147 | ], 148 | "selector-attribute-brackets-space-inside": "never", 149 | "selector-attribute-operator-space-after": "never", 150 | "selector-attribute-operator-space-before": "never", 151 | "selector-combinator-space-after": "always", 152 | "selector-combinator-space-before": "always", 153 | "selector-descendant-combinator-no-non-space": true, 154 | "selector-list-comma-newline-after": "always", 155 | "selector-list-comma-space-before": "never", 156 | "selector-max-empty-lines": 0, 157 | "selector-pseudo-class-case": "lower", 158 | "selector-pseudo-class-parentheses-space-inside": "never", 159 | "selector-pseudo-element-case": "lower", 160 | "selector-pseudo-element-colon-notation": "double", 161 | "selector-type-case": "lower", 162 | "unit-case": "lower", 163 | "value-list-comma-newline-after": "always-multi-line", 164 | "value-list-comma-space-after": "always-single-line", 165 | "value-list-comma-space-before": "never", 166 | "value-list-max-empty-lines": 0 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | v1.0.5 5 | ------ 6 | 7 | - Fix bug with settings without reporting plugin 8 | 9 | v1.0.4 10 | ------ 11 | 12 | - Upcoming Redmine support 13 | - Ruby 3 support 14 | - Plugin uses redmine_plugin_kit for loading 15 | - Update cookieconsent to version 4.0.0 16 | 17 | v1.0.3 18 | ------ 19 | 20 | - Redmine 4.2 and support 21 | - Ruby 2.6 or newer is required 22 | 23 | v1.0.2 24 | ------ 25 | 26 | - Ruby 2.4.0 or newer is required 27 | 28 | v1.0.1 29 | ------ 30 | 31 | - Redmine 4 support 32 | - Update cookieconsent to version 3.1.0 33 | 34 | v1.0 35 | ---- 36 | 37 | first release 38 | -------------------------------------------------------------------------------- /INSPECTORS.md: -------------------------------------------------------------------------------- 1 | Privacy & Terms inspectors for Redmine 2 | ====================================== 3 | 4 | This page lists only recommendations that might be a problem for data security. It always depends on your personal use case. So always check on your own if the recommended settings make sense in your case. 5 | 6 | ### [Authentication](#authentication) 7 | 8 | Authentication activation required. Otherwise all guest users (not logged in users) are also able to view content. 9 | 10 | ### [Protocol](#protocol) 11 | 12 | Use HTTPS instead of HTTP to make sure every content is transfered encrypted. This is also a very important aspect in intranet solutions. 13 | 14 | ### [Admistrator amount](#admin_amount) 15 | 16 | Limit the number of user accounts with administration rights. Ideally there should exist only one. 17 | 18 | ### [Password length](#password_min_length) 19 | 20 | Make sure your password lenght is 8 or higher. Each additional character increases password security. 21 | 22 | 23 | ### [User role visibility all](#roles_users_visibility_all) 24 | 25 | Roles with user visibility ALL. You should check - according to your use case - if this setting is really necessary. 26 | 27 | #### Example for user visibility 28 | 29 | There is project A with: 30 | 31 | * User A 32 | * User B 33 | 34 | There is project B with: 35 | 36 | * User B 37 | * User C 38 | 39 | This is what user A sees with user visibility ALL: 40 | 41 | * User A 42 | * User B 43 | * User C 44 | 45 | If you change user visibility of User A to "Members of visible projects" this user will only see: 46 | 47 | * User A 48 | * User B 49 | 50 | The user does not see members of other projects, which makes more sense. 51 | 52 | ### [Inactive users](#inactive_users) 53 | 54 | Registered users which have not been active in the system for more than 1 year. Please check those accounts in case they are not part of your team anymore. Maybe you should inactivate them. 55 | 56 | ### [Terms of use not accepted](#user_terms_not_accepted) 57 | 58 | (will only be displayed if the terms of use policy is activated) 59 | 60 | Displays the number of users who have not accepted the terms of use. 61 | 62 | Users with administration rights are not counted. Those users do not need to accept the terms of use. 63 | 64 | ### [Never logged in users](#never_logedin_users) 65 | 66 | Registerd users which have not logged in yet. Please check those accounts in case they are not part of your team anymore. Maybe you should delete them. 67 | 68 | ### [Public projects](#public_projects) 69 | 70 | All public projects in your system. If users need to login all logged in users have access to them. If users don't need to log in on your system, every one has access to view the content. 71 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Privacy & Terms plugin for Redmine 2 | 3 | [![Rate at redmine.org](https://img.shields.io/badge/rate%20at-redmine.org-blue.svg?style=fla)](https://www.redmine.org/plugins/redmine_privacy_terms) [![Tests](https://github.com/AlphaNodes/redmine_privacy_terms/workflows/Tests/badge.svg)](https://github.com/AlphaNodes/redmine_privacy_terms/actions?query=workflow%3A"Run+Tests) ![Run Linters](https://github.com/AlphaNodes/redmine_privacy_terms/workflows/Run%20Linters/badge.svg) 4 | 5 | ## Features 6 | 7 | * Adds https://cookieconsent.insites.com/ support (cookie agreement) 8 | * Add terms support, which each user has to accept before using Redmine 9 | * Add privacy and security [inspectors](https://github.com/alphanodes/redmine_privacy_terms/blob/master/INSPECTORS.md) 10 | * multilingual support 11 | * API support (if terms are required, API call throw forbitten till user accept terms) 12 | 13 | ## Requirements 14 | 15 | * Redmine version >= 6.0 16 | * Redmine Plugin: [additionals](https://github.com/alphanodes/additionals) 17 | * Ruby version >= 3.1 18 | 19 | ## Installation 20 | 21 | Install ``redmine_privacy_terms`` plugin for `Redmine` 22 | 23 | cd $REDMINE_ROOT 24 | git clone git://github.com/alphanodes/redmine_privacy_terms.git plugins/redmine_privacy_terms 25 | git clone git://github.com/alphanodes/additionals.git plugins/additionals 26 | bundle config set --local without 'development test' 27 | bundle install 28 | bundle exec rake redmine:plugins:migrate RAILS_ENV=production 29 | 30 | Restart Redmine (application server) and you should see the plugin show up in the Plugins page. 31 | 32 | ## Usage 33 | 34 | 1. First of all, add a wiki page for the terms and a wiki page with information for those users who reject the agreement. 35 | Don't forget to add the macros on the wiki page with the terms which implement the "accept" and "reject" buttons: {{terms_accept}} | {{terms_reject}} 36 | If you want to use multiple languages, create a wiki page for each language. If no wiki page is available for a language, the default wiki page will be used. 37 | 38 | E.g. "my_terms" (used as default), my_terms_de, my_terms_it, etc. 39 | 40 | 2. Second, go to the plugin settings and open the section "Terms of use". Enable the function and select your project and add your wiki pages that you have created before. Apply your changes. 41 | 42 | 3. Enable the Terms in settings. 43 | 44 | If you did not specify wiki pages or projects, terms are not activated. Even if you assing a non-existing wiki page, terms are not activated. If all settings are correct, you'll find a "show" link behind the wiki page text field. 45 | 46 | ## Configuration 47 | 48 | ### Plugin settings 49 | 50 | The plugin offers settings for: 51 | 52 | * Cookie agreement 53 | * Terms of use 54 | * Tools 55 | 56 | The "Inspect" section displays information on possible data protection problems you should try to fix. 57 | 58 | ### Permissions 59 | 60 | There is a new permission "Show terms condition" available. Members with this permission can see the terms conditions of other users. A user can always see its own terms condition at his profile (if terms are activated). 61 | 62 | ## Available macros 63 | 64 | ### terms_accept 65 | 66 | You can use title parameter, to overwrite button text. Eg. {{terms_accept(title=I understood)}} 67 | 68 | For multilange support use title_de, title_es, etc.. 69 | 70 | ### terms_reject 71 | 72 | You can use title parameter, to overwrite button text. Eg. {{terms_reject(title=Let me out)}} 73 | 74 | For multilange support use title_de, title_es, etc.. 75 | 76 | ## Uninstall 77 | 78 | Uninstall ``redmine_privacy_terms`` 79 | 80 | cd $REDMINE_ROOT 81 | bundle exec rake redmine:plugins:migrate NAME=redmine_privacy_terms VERSION=0 RAILS_ENV=production 82 | rm -rf plugins/redmine_privacy_terms public/assets/plugin_assets/redmine_privacy_terms 83 | 84 | Restart Redmine (application server) 85 | 86 | ## License 87 | 88 | This plugin is licensed under the terms of GNU/GPL v2. 89 | See [LICENSE](LICENSE) for details. 90 | 91 | ## Redmine Copyright 92 | 93 | The redmine_hedgedoc is a plugin extension for Redmine Project Management Software, whose Copyright follows. 94 | Copyright (C) 2006- Jean-Philippe Lang 95 | 96 | Redmine is a flexible project management web application written using Ruby on Rails framework. 97 | More details can be found in the doc directory or on the official website 98 | 99 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 100 | 101 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 102 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 103 | 104 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 105 | -------------------------------------------------------------------------------- /app/controllers/terms_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class TermsController < ApplicationController 4 | before_action :require_login 5 | before_action :check_terms_active, only: %i[accept reject] 6 | before_action :require_admin, only: %i[reset] 7 | 8 | def accept 9 | User.current.update accept_terms_at: Time.zone.now 10 | redirect_to home_url 11 | end 12 | 13 | def reject 14 | User.current.update accept_terms_at: nil 15 | redirect_to RedminePrivacyTerms.terms_reject_url(::I18n.locale) 16 | end 17 | 18 | def reset 19 | User.update_all accept_terms_at: nil 20 | Setting.plugin_redmine_privacy_terms = RedminePrivacyTerms.send(:settings).merge last_terms_reset: Time.now.utc.to_s 21 | flash[:notice] = flash_msg :notice_terms_reset_successfully 22 | redirect_to plugin_settings_path(id: 'redmine_privacy_terms', tab: 'tools') 23 | end 24 | 25 | private 26 | 27 | def check_terms_active 28 | if RedminePrivacyTerms.setting? :enable_terms 29 | true 30 | else 31 | flash[:warning] = flash_msg :notice_terms_accepted_not_saved 32 | redirect_to home_url 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /app/helpers/privacy_terms_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module PrivacyTermsHelper 4 | def privacy_terms_inspect_results 5 | rc = [] 6 | rc << { name: l(:label_authentication), 7 | id: 'authentication', 8 | value: format_yes(Setting.login_required?), 9 | result: inspect_bool_result(Setting.login_required?) } 10 | rc << { name: l(:setting_protocol), 11 | id: 'protocol', 12 | value: Setting.protocol, 13 | result: inspect_bool_result(Setting.protocol == 'https') } 14 | 15 | admin_amount = User.active.admin.count 16 | rc << { name: l(:inspect_admin_amount), 17 | id: 'admin_amount', 18 | value: admin_amount, 19 | result: inspect_bool_result(admin_amount < 2) } 20 | 21 | rc << { name: l(:setting_password_min_length), 22 | id: 'password_min_length', 23 | value: Setting.password_min_length, 24 | result: inspect_bool_result(Setting.password_min_length.to_i > 7) } 25 | 26 | roles_amount = Role.where(users_visibility: 'all').count 27 | rc << { name: l(:inspect_user_visibility), 28 | id: 'roles_users_visibility_all', 29 | value: roles_amount, 30 | result: inspect_bool_result(roles_amount.zero?) } 31 | 32 | inactive_users = User.active.where(last_login_on: ...1.year.ago).count 33 | rc << { name: l(:inspect_user_inactive_over_one_year), 34 | id: 'inactive_users', 35 | value: inactive_users, 36 | result: inspect_bool_result(inactive_users.zero?) } 37 | 38 | if RedminePrivacyTerms.setting? :enable_terms 39 | terms_not_accepted = User.active.where(admin: false, accept_terms_at: nil).count 40 | rc << { name: l(:inspect_user_terms_not_accepted), 41 | id: 'user_terms_not_accepted', 42 | value: terms_not_accepted, 43 | result: inspect_bool_result(terms_not_accepted.zero?) } 44 | end 45 | 46 | never_logedin_users = User.active.where(last_login_on: nil).count 47 | rc << { name: l(:inspect_never_logedin_users), 48 | id: 'never_logedin_users', 49 | value: never_logedin_users, 50 | result: inspect_bool_result(never_logedin_users.zero?) } 51 | 52 | public_projects = Project.all_public.count 53 | rc << { name: l(:label_public_projects), 54 | id: 'public_projects', 55 | value: public_projects, 56 | result: inspect_bool_result(public_projects.zero?, 57 | down_icon: 'details', 58 | down_class: 'summary') } 59 | 60 | rc 61 | end 62 | 63 | private 64 | 65 | def inspect_bool_result(value, down_icon: nil, down_class: nil) 66 | down_icon ||= 'thumb-down' 67 | down_class ||= 'additionals-number-negative inspect-problem' 68 | 69 | if value 70 | svg_icon_tag 'thumb-up', css_class: 'additionals-number-positive inspect-good' 71 | else 72 | svg_icon_tag down_icon, css_class: down_class 73 | end 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /app/views/redmine_privacy_terms/_html_head.html.slim: -------------------------------------------------------------------------------- 1 | - if RedminePrivacyTerms.setting? :enable_cookie_agreement 2 | = javascript_include_tag 'cookie-consent.min', plugin: 'redmine_privacy_terms' 3 | 4 | javascript: 5 | document.addEventListener('DOMContentLoaded', function () { 6 | cookieconsent.run({ 7 | "notice_banner_type": "#{RedminePrivacyTerms.setting(:cookieconsent_banner_type).presence || 'headline'}", 8 | "consent_type": "#{RedminePrivacyTerms.setting(:cookieconsent_consent_type).presence || 'express'}", 9 | "palette": "#{RedminePrivacyTerms.setting(:cookieconsent_palette).presence || 'light'}", 10 | "language": "#{RedminePrivacyTerms.setting(:cookieconsent_language).presence || 'en'}", 11 | "page_load_consent_levels": ["strictly-necessary"], 12 | "notice_banner_reject_button_hide": false, 13 | "preferences_center_close_button_hide": false, 14 | "website_name": "#{Setting.app_title.presence || 'Redmine'}", 15 | "website_privacy_policy_url": "#{RedminePrivacyTerms.setting :cookieconsent_href}" }); 16 | }); 17 | 18 | - if RedminePrivacyTerms.setting?(:enable_cookie_agreement) || RedminePrivacyTerms.setting?(:enable_terms) 19 | = stylesheet_link_tag 'privacy_terms', plugin: 'redmine_privacy_terms' 20 | -------------------------------------------------------------------------------- /app/views/redmine_privacy_terms/settings/_cookie_agreement.html.slim: -------------------------------------------------------------------------------- 1 | p 2 | = additionals_settings_checkbox :enable_cookie_agreement 3 | 4 | p 5 | = additionals_settings_select :cookieconsent_banner_type, 6 | options_for_select({ 'Simple' => 'simple', 7 | 'Headline' => 'headline', 8 | 'Interstitial' => 'interstitial', 9 | 'Standalone' => 'standalone' }, 10 | @settings[:cookieconsent_banner_type]) 11 | 12 | p 13 | = additionals_settings_select :cookieconsent_consent_type, 14 | options_for_select({ 'Express (GDPR + EU Cookies Directive)' => 'express', 15 | 'Implied (EU Cookies Directive)' => 'implied' }, 16 | @settings[:cookieconsent_consent_type]) 17 | em.info = l :cookieconsent_consent_type_info 18 | 19 | p 20 | = additionals_settings_select :cookieconsent_palette, 21 | options_for_select({ 'Light' => 'light', 22 | 'Dark' => 'dark' }, 23 | @settings[:cookieconsent_palette]) 24 | p 25 | = additionals_settings_select :cookieconsent_language, 26 | options_for_select({ 'English' => 'en', 27 | 'German' => 'de', 28 | 'French' => 'fr', 29 | 'Spanish' => 'es', 30 | 'Catalan' => 'ca_es', 31 | 'Italian' => 'it', 32 | 'Swedish' => 'sv', 33 | 'Norwegian' => 'no', 34 | 'Dutch' => 'nl', 35 | 'Portugese' => 'pt', 36 | 'Finnish' => 'fi', 37 | 'Hungarian' => 'hu', 38 | 'Czech' => 'cs', 39 | 'Croatian' => 'hr', 40 | 'Danish' => 'da', 41 | 'Slovak' => 'sk', 42 | 'Slovenian' => 'sl', 43 | 'Polish' => 'pl', 44 | 'Greek' => 'el', 45 | 'Romanian' => 'ro', 46 | 'Serbian' => 'sr', 47 | 'Lithuanian' => 'lt', 48 | 'Latvian' => 'lv', 49 | 'Russian' => 'ru', 50 | 'Bulgarian' => 'bg', 51 | 'Welsh' => 'cy', 52 | 'Japanese' => 'ja', 53 | 'Arabic' => 'ar', 54 | 'Turkish' => 'tr' }, 55 | @settings[:cookieconsent_language]) 56 | 57 | p 58 | = additionals_settings_textfield :cookieconsent_href, size: 50 59 | - if @settings[:cookieconsent_href].present? 60 | ' 61 | = link_to_external l(:button_show), @settings[:cookieconsent_href] 62 | em.info = l :cookieconsent_href_info 63 | -------------------------------------------------------------------------------- /app/views/redmine_privacy_terms/settings/_inspect.html.slim: -------------------------------------------------------------------------------- 1 | div 2 | em.info = t :privacy_terms_inspect_info 3 | 4 | table 5 | thead 6 | tr 7 | th = l :field_name 8 | th = l :field_value 9 | th = l :field_privacy_terms_result 10 | tbody 11 | - privacy_terms_inspect_results.each do |result| 12 | tr 13 | - if result[:id].present? 14 | td 15 | = link_to_external result[:name], 16 | "#{RedminePrivacyTerms::INSPECTOR_DOC_URL}##{result[:id]}" 17 | - else 18 | td = result[:name] 19 | td = result[:value] 20 | td.icon = result[:result] 21 | = call_hook :view_privacy_terms_inspect 22 | -------------------------------------------------------------------------------- /app/views/redmine_privacy_terms/settings/_settings.html.slim: -------------------------------------------------------------------------------- 1 | = render_tabs [{ name: 'cookie_agreement', 2 | partial: 'redmine_privacy_terms/settings/cookie_agreement', 3 | label: :label_privacy_cookie_agreement }, 4 | { name: 'terms', 5 | partial: 'redmine_privacy_terms/settings/terms', 6 | label: :label_privacy_terms }, 7 | { name: 'tools', 8 | partial: 'redmine_privacy_terms/settings/tools', 9 | label: :label_privacy_terms_tools }, 10 | { name: 'inspect', 11 | partial: 'redmine_privacy_terms/settings/inspect', 12 | label: :label_privacy_terms_inspect }] 13 | -------------------------------------------------------------------------------- /app/views/redmine_privacy_terms/settings/_terms.html.slim: -------------------------------------------------------------------------------- 1 | p 2 | = additionals_settings_checkbox :enable_terms 3 | 4 | fieldset.privacy-terms 5 | legend = l :label_terms_url 6 | 7 | p 8 | = label_tag 'settings[terms_project_id]', l(:label_project) 9 | - if AdditionalsPlugin.active_reporting? 10 | = autocomplete_select_entries('settings[terms_project_id]', 11 | 'projects_auto_completes', 12 | (@settings[:terms_project_id].present? ? Project.find_by(id: @settings[:terms_project_id]) : nil)) 13 | - else 14 | = select_tag('settings[terms_project_id]', 15 | project_tree_options_for_select(Project.active, 16 | selected: @settings[:terms_project_id].present? ? Project.find_by(id: @settings[:terms_project_id]) : nil), 17 | required: true) 18 | p 19 | = additionals_settings_textfield :terms_page, label: l(:label_wiki_page), size: 50 20 | - if RedminePrivacyTerms.valid_terms_url? 21 | ' 22 | = link_to(l(:button_show), RedminePrivacyTerms.terms_url) 23 | em.info = l :terms_url_info 24 | 25 | fieldset.privacy-terms 26 | legend = l :label_terms_reject_url 27 | 28 | p 29 | = label_tag 'settings[terms_reject_project_id]', l(:label_project) 30 | - if AdditionalsPlugin.active_reporting? 31 | = autocomplete_select_entries('settings[terms_reject_project_id]', 32 | 'projects_auto_completes', 33 | (@settings[:terms_reject_project_id].present? ? Project.find_by(id: @settings[:terms_reject_project_id]) : nil), 34 | include_blank: true, allow_clear: true) 35 | - else 36 | = select_tag('settings[terms_reject_project_id]', 37 | project_tree_options_for_select(Project.active, 38 | selected: @settings[:terms_reject_project_id].present? ? Project.find_by(id: @settings[:terms_reject_project_id]) : nil), 39 | include_blank: true) 40 | 41 | p 42 | = additionals_settings_textfield :terms_reject_page, size: 50 43 | - if RedminePrivacyTerms.valid_terms_reject_url? 44 | ' 45 | = link_to(l(:button_show), RedminePrivacyTerms.terms_reject_url) 46 | em.info = l :terms_reject_url_info 47 | -------------------------------------------------------------------------------- /app/views/redmine_privacy_terms/settings/_tools.html.slim: -------------------------------------------------------------------------------- 1 | fieldset.privacy-terms 2 | legend = l :button_reset_terms 3 | 4 | br 5 | = hidden_field_tag 'settings[last_terms_reset]', RedminePrivacyTerms.setting(:last_terms_reset) 6 | 7 | p#caching-run 8 | = l :label_last_terms_reset 9 | ': 10 | - if RedminePrivacyTerms.setting(:last_terms_reset).present? 11 | = format_time RedminePrivacyTerms.setting(:last_terms_reset), true, User.current 12 | - else 13 | ' - 14 | p 15 | = link_to l(:button_reset_terms), reset_terms_path 16 | p 17 | em.info = t :privacy_terms_reset_info 18 | -------------------------------------------------------------------------------- /app/views/users/_privacy_terms_show.html.slim: -------------------------------------------------------------------------------- 1 | - if RedminePrivacyTerms.setting?(:enable_terms) && \ 2 | RedminePrivacyTerms.valid_terms_url? && \ 3 | (User.current == user || User.current.allowed_to?(:show_terms_condition, nil, global: true)) 4 | li.terms-condition 5 | = l :label_privacy_terms 6 | ul 7 | li = link_to l(:button_show), RedminePrivacyTerms.terms_url 8 | li 9 | - if user.accept_terms? 10 | = l :label_terms_accepted_at, value: format_time(user.accept_terms_at, true, User.current) 11 | - else 12 | = l :label_terms_not_accepted 13 | -------------------------------------------------------------------------------- /assets/javascripts/.eslintignore: -------------------------------------------------------------------------------- 1 | # eslint ignore file 2 | *.min.js 3 | -------------------------------------------------------------------------------- /assets/stylesheets/.stylelintignore: -------------------------------------------------------------------------------- 1 | # stylelint ignore file 2 | *.map 3 | *.min.css 4 | -------------------------------------------------------------------------------- /assets/stylesheets/privacy_terms.css: -------------------------------------------------------------------------------- 1 | /* stylelint-disable font-family-no-missing-generic-family-keyword */ 2 | 3 | .termsfeed-com---nb .cc-nb-okagree, 4 | .termsfeed-com---nb .cc-nb-reject, 5 | .termsfeed-com---nb .cc-nb-changep { 6 | min-height: 40px; 7 | } 8 | 9 | .accept-terms-button { 10 | font-weight: bold; 11 | background-color: #1abc9c; 12 | box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 -0.25em 0 rgba(0, 0, 0, 0.25), 0 0.25em 0.25em rgba(0, 0, 0, 0.05); 13 | display: inline-block; 14 | } 15 | 16 | .reject-terms-button { 17 | font-weight: bold; 18 | background-color: #e65d4f; 19 | box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 -0.25em 0 rgba(0, 0, 0, 0.25), 0 0.25em 0.25em rgba(0, 0, 0, 0.05); 20 | display: inline-block; 21 | } 22 | 23 | .accept-terms-button, 24 | .accept-terms-button:hover, 25 | .accept-terms-button:visited, 26 | .reject-terms-button, 27 | .reject-terms-button:hover, 28 | .reject-terms-button:visited { 29 | color: var(--a-color-white) !important; 30 | padding: 8px; 31 | border-radius: 5px; 32 | margin-right: 5px; 33 | text-decoration: none; 34 | cursor: pointer; 35 | } 36 | 37 | .accept-terms-button:active, 38 | .reject-terms-button:active { 39 | box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), inset 0 2px 0 hsla(0, 0%, 100%, 0.1), inset 0 0.25em 0.5em rgba(0, 0, 0, 0.05); 40 | margin-top: 0.25em; 41 | padding-bottom: 0.5em; 42 | } 43 | -------------------------------------------------------------------------------- /config/locales/de.yml: -------------------------------------------------------------------------------- 1 | de: 2 | button_reset_terms: Nutzungsbedingungen neu anfordern 3 | cookieconsent_href_info: Die URL sollte auf eine externe Seite verlinken, auf die jeder Zugriff hat (auch wenn man nicht in Redmine angemeldet ist). 4 | field_privacy_terms_result: Ergebnis 5 | inspect_admin_amount: Anzahl Administratoren 6 | inspect_never_logedin_users: Nie angemeldete Benutzer 7 | inspect_user_inactive_over_one_year: Benutzer inaktiv > 1 Jahr 8 | inspect_user_terms_not_accepted: Benutzer ohne angenommene Nutzungsbedingungen 9 | inspect_user_visibility: Anzahl Benutzer-Sichtbarkeit alle 10 | label_cookieconsent_banner_type: Banner type 11 | label_cookieconsent_consent_type: Consent Type 12 | label_cookieconsent_href: URL Link Cookiehinweis 13 | label_cookieconsent_language: Sprache 14 | label_cookieconsent_palette: Farbschema 15 | label_default_accept_terms: Einverstanden 16 | label_default_reject_terms: Ablehnen 17 | label_enable_cookie_agreement: Cookie Hinweis aktivieren 18 | label_enable_terms: Bedingungen aktivieren 19 | label_last_terms_reset: Letzte Ausführung 20 | label_privacy_cookie_agreement: Cookie Zustimmung 21 | label_privacy_terms_inspect: Prüfung 22 | label_privacy_terms_tools: Tools 23 | label_privacy_terms: Nutzungsbedingungen 24 | label_terms_accepted_at: angenommen am %{value} 25 | label_terms_not_accepted: nicht akzeptiert 26 | label_terms_reject_page: Wiki-Seite oder externere URL 27 | label_terms_reject_url: URL zur Wikiseite für Anwender die Bedingungen ablehnen 28 | label_terms_url: URL zur Wikiseite mit den Bedingungen 29 | notice_terms_accepted_not_saved: Nutzungsbedingungen wurden durch den Admin nicht aktiviert, daher wurde die Aktion nicht gespeichert. 30 | notice_terms_reset_successfully: Nutzungsbedingungen erfolgreich neu angefordert 31 | permission_show_terms_condition: Datenschutz Status anzeigen 32 | privacy_terms_inspect_info: Diese Seite liefert Informationen, die dabei behilflich sein können mögliche Datenschutzprobleme zu identifieren. Im Idealfall ist alles grün. 33 | privacy_terms_reset_info: Alle Benutzer werden erneut aufgefordert die Nutzungsbedingungen anzunehmen. Dies kann z.B. verwendet werden, wenn sich an den Bedingungen etwas geändert hat. 34 | terms_reject_url_info: Hier kann eine Wiki-Seite zum ausgewählten Projekt oder eine externe Webseite angegeben werden. 35 | terms_url_info: Hier muss eine Wiki-Seite im ausgewählten Projekt angegeben werden, auf die jeder Benutzer Lesezugriff hat. Dafür eignet sich am Besten ein öffentliches Projekt. In dieser Wiki-Seite sind die Bedingungen zu definieren. Zusätzlich müssen die beiden Makros {{terms_accept}} und {{terms_reject}} darin verwendet werden. 36 | cookieconsent_consent_type_info: "Express: Die JavaScript-Skripte werden erst geladen, wenn der Benutzer auf 'Ich stimme zu' klickt. Implied: Die JavaScript Skripte werden automatisch geladen." 37 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | button_reset_terms: Request new terms of use 3 | cookieconsent_href_info: This URL must link to an external site to which every visitor has public access. 4 | field_privacy_terms_result: Result 5 | inspect_admin_amount: Amount of admins 6 | inspect_never_logedin_users: Never logged in user 7 | inspect_user_inactive_over_one_year: Inactive user > 1 year 8 | inspect_user_terms_not_accepted: User without accepted term of use 9 | inspect_user_visibility: Number of user-visibility all 10 | label_cookieconsent_banner_type: Banner type 11 | label_cookieconsent_consent_type: Consent Type 12 | label_cookieconsent_href: Cookieconsent URL link 13 | label_cookieconsent_language: Language 14 | label_cookieconsent_palette: Color palette 15 | label_default_accept_terms: I agree 16 | label_default_reject_terms: Reject 17 | label_enable_cookie_agreement: Enable cookie agreement 18 | label_enable_terms: Enable terms 19 | label_last_terms_reset: Last execution 20 | label_privacy_cookie_agreement: Cookie agreement 21 | label_privacy_terms_inspect: Inspect 22 | label_privacy_terms_tools: Tools 23 | label_privacy_terms: Terms of use 24 | label_terms_accepted_at: accepted at %{value} 25 | label_terms_not_accepted: not acccepted yet 26 | label_terms_reject_page: Wiki page or external URL 27 | label_terms_reject_url: URL of the wiki for users who reject the terms 28 | label_terms_url: URL of the wiki with the terms 29 | notice_terms_accepted_not_saved: Terms of use policy was not activated by the administrator. So the action was not saved. 30 | notice_terms_reset_successfully: Terms of use policy successfully requested again 31 | permission_show_terms_condition: Show terms condition 32 | privacy_terms_inspect_info: This page delivers information that may be helpful to identify possible data protection problems. 33 | privacy_terms_reset_info: All users will be asked to accept the privacy policy again. For example use this, if changes have been made to the regulations. 34 | terms_reject_url_info: Here you can specify a wiki page for the selected project or an external website. 35 | terms_url_info: A wiki page must be specified here in the selected project to which each user has read-access. A public project is the best way to do this. In this wiki page the conditions are to be defined. Additionally, the two macros {{terms_accept}} and {{terms_reject}} must be implemented in it. 36 | cookieconsent_consent_type_info: "Express: Your JavaScript scripts will be loaded only after the user clicks 'I agree'. Implied: our JavaScript scripts will be loaded automatically." 37 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Rails.application.routes.draw do 4 | resources :terms, only: [] do 5 | collection do 6 | get :accept 7 | get :reject 8 | get :reset 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /config/settings.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | cookieconsent_banner_type: headline 4 | cookieconsent_consent_type: express 5 | cookieconsent_palette: light 6 | cookieconsent_language: en 7 | cookieconsent_href: 'https://cookiesandyou.com/' 8 | enable_cookie_agreement: 0 9 | enable_terms: 0 10 | last_terms_reset: '' 11 | terms_page: '' 12 | terms_project_id: '' 13 | terms_reject_page: '' 14 | terms_reject_project_id: '' 15 | -------------------------------------------------------------------------------- /db/migrate/001_add_accept_terms_at_to_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddAcceptTermsAtToUser < ActiveRecord::Migration[4.2] 4 | def change 5 | add_column :users, :accept_terms_at, :datetime 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | loader = RedminePluginKit::Loader.new plugin_id: 'redmine_privacy_terms' 4 | 5 | Redmine::Plugin.register :redmine_privacy_terms do 6 | name 'Privacy & Terms' 7 | url 'https://github.com/alphanodes/redmine_privacy_terms' 8 | description 'Add privacy cookie information and terms for users' 9 | version RedminePrivacyTerms::VERSION 10 | author 'AlphaNodes GmbH' 11 | author_url 'https://alphanodes.com/' 12 | requires_redmine version_or_higher: '6.0' 13 | 14 | begin 15 | requires_redmine_plugin :additionals, version_or_higher: '4.1.0' 16 | rescue Redmine::PluginNotFound 17 | raise 'Please install additionals plugin (https://github.com/alphanodes/additionals)' 18 | end 19 | 20 | permission :show_terms_condition, {} 21 | 22 | settings default: loader.default_settings, 23 | partial: 'redmine_privacy_terms/settings/settings' 24 | end 25 | 26 | RedminePluginKit::Loader.persisting { loader.load_model_hooks! } 27 | -------------------------------------------------------------------------------- /lib/redmine_privacy_terms.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RedminePrivacyTerms 4 | VERSION = '1.0.6' 5 | INSPECTOR_DOC_URL = 'https://github.com/alphanodes/redmine_privacy_terms/blob/master/INSPECTORS.md' 6 | 7 | include RedminePluginKit::PluginBase 8 | 9 | class << self 10 | include Additionals::Helpers 11 | 12 | def valid_terms_url? 13 | page = setting :terms_page 14 | return false if page.blank? || external_page?(page) 15 | 16 | project_id = setting :terms_project_id 17 | return false if project_id.blank? 18 | 19 | project = Project.find_by id: project_id 20 | return false if project.blank? 21 | 22 | wiki_page = project.wiki&.find_page page 23 | return true if wiki_page.present? 24 | 25 | false 26 | end 27 | 28 | def valid_terms_reject_url? 29 | page = setting :terms_reject_page 30 | return false if page.blank? 31 | return true if external_page? page 32 | 33 | project_id = setting :terms_reject_project_id 34 | return false if project_id.blank? 35 | 36 | project = Project.find_by id: project_id 37 | return false if project.blank? 38 | 39 | wiki_page = project.wiki&.find_page page 40 | return true if wiki_page.present? 41 | 42 | false 43 | end 44 | 45 | def terms_url(lang = nil) 46 | page = setting :terms_page 47 | project = Project.find_by id: setting(:terms_project_id) 48 | 49 | if lang 50 | i18n_page = additionals_title_for_locale page, lang 51 | wiki_page = project.wiki&.find_page i18n_page 52 | page = i18n_page if wiki_page.present? 53 | end 54 | 55 | Rails.application.routes.url_helpers.url_for(only_path: true, 56 | controller: 'wiki', 57 | action: 'show', 58 | project_id: project, 59 | id: Wiki.titleize(page)) 60 | end 61 | 62 | def terms_reject_url(lang = nil) 63 | page = setting :terms_reject_page 64 | return page if external_page? page 65 | 66 | project = Project.find_by id: setting(:terms_reject_project_id) 67 | 68 | if lang 69 | i18n_page = additionals_title_for_locale page, lang 70 | wiki_page = project.wiki&.find_page i18n_page 71 | page = i18n_page if wiki_page.present? 72 | end 73 | 74 | Rails.application.routes.url_helpers.url_for(only_path: true, 75 | controller: 'wiki', 76 | action: 'show', 77 | project_id: project, 78 | id: Wiki.titleize(page)) 79 | end 80 | 81 | def external_page?(page) 82 | page.include?('http:') || page.include?('https:') 83 | end 84 | 85 | private 86 | 87 | def setup 88 | # Patches 89 | loader.add_patch %w[ApplicationController 90 | User] 91 | 92 | # Helper 93 | loader.add_helper({ controller: SettingsController, helper: 'PrivacyTerms' }) 94 | 95 | # Apply patches and helper 96 | loader.apply! 97 | 98 | # Macros 99 | loader.load_macros! 100 | 101 | # Load view hooks 102 | loader.load_view_hooks! 103 | end 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /lib/redmine_privacy_terms/hooks/model_hook.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RedminePrivacyTerms 4 | module Hooks 5 | class ModelHook < Redmine::Hook::Listener 6 | def after_plugins_loaded(_context = {}) 7 | RedminePrivacyTerms.setup! 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/redmine_privacy_terms/hooks/view_hook.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RedminePrivacyTerms 4 | module Hooks 5 | class ViewHook < Redmine::Hook::ViewListener 6 | render_on :view_layouts_base_html_head, partial: 'redmine_privacy_terms/html_head' 7 | render_on :view_users_show_info, partial: 'users/privacy_terms_show' 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/redmine_privacy_terms/patches/application_controller_patch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RedminePrivacyTerms 4 | module Patches 5 | module ApplicationControllerPatch 6 | extend ActiveSupport::Concern 7 | 8 | included do 9 | include InstanceMethods 10 | 11 | before_action :check_agreement 12 | end 13 | 14 | module InstanceMethods 15 | private 16 | 17 | def check_agreement 18 | return unless RedminePrivacyTerms.valid_terms_url? && 19 | RedminePrivacyTerms.valid_terms_reject_url? && 20 | need_accept_terms? && 21 | !allowed_path? 22 | 23 | if api_request? 24 | render_error message: 'Terms not accepted', status: 403 25 | else 26 | redirect_to RedminePrivacyTerms.terms_url(::I18n.locale) 27 | end 28 | end 29 | 30 | def need_accept_terms? 31 | RedminePrivacyTerms.setting?(:enable_terms) && 32 | User.current.logged? && 33 | !User.current.admin? && 34 | !User.current.accept_terms? 35 | end 36 | 37 | def allowed_path? 38 | [accept_terms_path, 39 | reject_terms_path, 40 | signout_path, 41 | my_password_path, 42 | RedminePrivacyTerms.terms_url(::I18n.locale), 43 | RedminePrivacyTerms.terms_reject_url(::I18n.locale)].include?(request.original_fullpath) 44 | end 45 | end 46 | end 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /lib/redmine_privacy_terms/patches/user_patch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RedminePrivacyTerms 4 | module Patches 5 | module UserPatch 6 | def accept_terms? 7 | accept_terms_at 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/redmine_privacy_terms/wiki_macros/terms_accept_macro.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RedminePrivacyTerms 4 | module WikiMacros 5 | module TermsAcceptMacro 6 | Redmine::WikiFormatting::Macros.register do 7 | desc <<-DESCRIPTION 8 | Add terms accept macro 9 | 10 | Syntax: 11 | 12 | {{terms_accept([title=TEXT, title_de=TEXT, ...)}} 13 | 14 | You can use all language as suffix, eg. title_de, button_it, button_es 15 | 16 | Examples: 17 | 18 | {{terms_accept}} 19 | {{terms_accept(title=Ok understood)}} 20 | {{terms_accept(title='Ok, understood' title_de='Alles klar')}} 21 | 22 | DESCRIPTION 23 | 24 | macro :terms_accept do |_obj, args| 25 | title = if args.any? 26 | options = extract_macro_options(args, *additionals_titles_for_locale(:title)).last 27 | additionals_i18n_title options, :title 28 | end 29 | 30 | link_to(title.presence || l(:label_default_accept_terms), 31 | accept_terms_path, 32 | class: 'accept-terms-button') 33 | end 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /lib/redmine_privacy_terms/wiki_macros/terms_reject_macro.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RedminePrivacyTerms 4 | module WikiMacros 5 | module TermsRejectMacro 6 | Redmine::WikiFormatting::Macros.register do 7 | desc <<-DESCRIPTION 8 | Add terms reject macro 9 | 10 | Syntax: 11 | 12 | {{terms_reject([title=TEXT, title_de=TEXT, ...)}} 13 | 14 | You can use all language as suffix, eg. title_de, button_it, button_es 15 | 16 | Examples: 17 | 18 | {{terms_reject}} 19 | {{terms_reject(title='Reject')}} 20 | {{terms_reject(title='Reject' title_de='Ich stimme nicht zu')}} 21 | 22 | DESCRIPTION 23 | 24 | macro :terms_reject do |_obj, args| 25 | title = if args.any? 26 | options = extract_macro_options(args, *additionals_titles_for_locale(:title)).last 27 | additionals_i18n_title options, :title 28 | end 29 | link_to(title.presence || l(:label_default_reject_terms), 30 | reject_terms_path, 31 | class: 'reject-terms-button') 32 | end 33 | end 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /test/functional/terms_controller_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require File.expand_path '../../test_helper', __FILE__ 4 | 5 | class TermsControllerTest < Redmine::ControllerTest 6 | fixtures :all 7 | 8 | def setup 9 | Setting.default_language = 'en' 10 | User.current = nil 11 | end 12 | 13 | def test_accept 14 | user = User.find 2 15 | 16 | assert user.save 17 | @request.session[:user_id] = user.id 18 | 19 | get :accept 20 | 21 | assert_response :found 22 | end 23 | 24 | def test_reject 25 | user = User.find 2 26 | 27 | assert user.save 28 | @request.session[:user_id] = user.id 29 | 30 | get :reject 31 | 32 | assert_response :found 33 | end 34 | 35 | def test_reset_should_require_admin 36 | user = User.find 2 37 | 38 | assert user.save 39 | @request.session[:user_id] = user.id 40 | 41 | get :reset 42 | 43 | assert_response :forbidden 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /test/integration/routing_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require File.expand_path '../../test_helper', __FILE__ 4 | 5 | class RoutingTest < Redmine::RoutingTest 6 | test 'terms' do 7 | should_route 'GET /terms/accept' => 'terms#accept' 8 | should_route 'GET /terms/reject' => 'terms#reject' 9 | should_route 'GET /terms/reset' => 'terms#reset' 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /test/support/configuration.yml: -------------------------------------------------------------------------------- 1 | # = Redmine configuration file 2 | 3 | # default configuration options for all environments 4 | default: 5 | sudo_mode: false 6 | sudo_mode_timeout: 1 7 | -------------------------------------------------------------------------------- /test/support/database-mysql.yml: -------------------------------------------------------------------------------- 1 | test: 2 | adapter: mysql2 3 | database: redmine 4 | port: <%= ENV["MYSQL_PORT"] %> 5 | host: 127.0.0.1 6 | username: root 7 | password: BestPasswordEver 8 | encoding: utf8mb4 9 | -------------------------------------------------------------------------------- /test/support/database-postgres.yml: -------------------------------------------------------------------------------- 1 | production: 2 | adapter: postgresql 3 | host: localhost 4 | database: redmine 5 | username: postgres 6 | password: postgres 7 | encoding: utf8 8 | 9 | development: 10 | adapter: postgresql 11 | host: localhost 12 | database: redmine 13 | username: postgres 14 | password: postgres 15 | encoding: utf8 16 | 17 | test: 18 | adapter: postgresql 19 | host: localhost 20 | database: redmine 21 | username: postgres 22 | password: postgres 23 | encoding: utf8 24 | -------------------------------------------------------------------------------- /test/support/gemfile.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | 5 | group :test do 6 | gem 'brakeman', require: false 7 | gem 'pandoc-ruby', require: false 8 | gem 'rubocop', require: false 9 | gem 'rubocop-minitest', require: false 10 | gem 'rubocop-performance', require: false 11 | gem 'rubocop-rails', require: false 12 | gem 'slim_lint', require: false 13 | end 14 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | if ENV['COVERAGE'] 4 | require 'simplecov' 5 | require 'simplecov-rcov' 6 | 7 | SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter[SimpleCov::Formatter::HTMLFormatter, 8 | SimpleCov::Formatter::RcovFormatter] 9 | 10 | SimpleCov.start :rails do 11 | add_filter 'init.rb' 12 | root File.expand_path "#{File.dirname __FILE__}/.." 13 | end 14 | end 15 | 16 | require File.expand_path "#{File.dirname __FILE__}/../../../test/test_helper" 17 | require File.expand_path "#{File.dirname __FILE__}/../../additionals/test/global_test_helper" 18 | 19 | module RedminePrivacyTerms 20 | module TestHelper 21 | include Additionals::GlobalTestHelper 22 | end 23 | 24 | class TestCase 25 | include ActionDispatch::TestProcess 26 | include RedminePrivacyTerms::TestHelper 27 | 28 | def self.prepare 29 | Role.where(id: [1, 2]).find_each do |r| 30 | r.permissions << :view_wiki_pages 31 | r.save 32 | end 33 | 34 | Project.where(id: [1, 2]).find_each do |project| 35 | EnabledModule.create project: project, name: 'wiki' 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /test/unit/i18n_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require File.expand_path '../../test_helper', __FILE__ 4 | 5 | class I18nTest < RedminePrivacyTerms::TestCase 6 | include Redmine::I18n 7 | 8 | def setup 9 | User.current = nil 10 | end 11 | 12 | def teardown 13 | set_language_if_valid 'en' 14 | end 15 | 16 | def test_valid_languages 17 | assert_kind_of Array, valid_languages 18 | assert_kind_of Symbol, valid_languages.first 19 | end 20 | 21 | def test_locales_validness 22 | assert_locales_validness plugin: 'redmine_privacy_terms', 23 | file_cnt: 2, 24 | locales: %w[de], 25 | control_string: :field_privacy_terms_result, 26 | control_english: 'Result' 27 | end 28 | end 29 | --------------------------------------------------------------------------------