diff --git a/.gitattributes b/.gitattributes index 15e367d..490d0e7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,7 @@ -tests/ export-ignore -travis/ export-ignore -.github/ export-ignore -.travis.yml export-ignore +.github export-ignore .gitignore export-ignore .gitattributes export-ignore -phpunit.xml.* export-ignore -composer.lock export-ignore build.xml export-ignore +composer.lock export-ignore +phpunit.xml.* export-ignore +tests export-ignore diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 33bec3b..aa1d174 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,441 +13,19 @@ on: branches: # Run tests when commits are pushed to these branches in your repo - main - develop + - dev/* pull_request: # Run tests when pull requests are made on these branches in your repo branches: - main - develop + - dev/* jobs: - # START Basic Checks Job (EPV, code sniffer, images check, etc.) - basic-checks: - runs-on: ubuntu-20.04 - strategy: - matrix: - include: - - php: '7.2' - db: "none" - NOTESTS: 1 - - name: PHP ${{ matrix.php }} - ${{ matrix.db }} - - steps: - - name: Checkout phpBB - uses: actions/checkout@v3 - with: - repository: phpbb/phpbb - ref: ${{ env.PHPBB_BRANCH }} - path: phpBB3 - - - name: Checkout extension - uses: actions/checkout@v3 - with: - path: phpBB3/phpBB/ext/${{ env.EXTNAME }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap - coverage: none - - - name: Setup environment for phpBB - env: - DB: ${{ matrix.db }} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: '1' - run: .github/setup-phpbb.sh $DB $PHP_VERSION $NOTESTS - working-directory: ./phpBB3 - - - name: Setup EPV - if: ${{ env.EPV != 0 }} - run: composer require phpbb/epv:dev-master --dev --no-interaction --ignore-platform-reqs - working-directory: ./phpBB3/phpBB - - - name: Run code sniffer - if: ${{ env.SNIFF != 0 }} - env: - NOTESTS: '1' - run: .github/ext-sniff.sh $EXTNAME $NOTESTS - working-directory: ./phpBB3 - - - name: Check image ICC profiles - if: ${{ env.IMAGE_ICC != 0 }} - run: .github/check-image-icc-profiles.sh - working-directory: ./phpBB3 - - - name: Check executable files - if: ${{ env.EXECUTABLE_FILES != 0 }} - run: .github/ext-check-executable-files.sh ./ $EXTNAME - working-directory: ./phpBB3 - - - name: Run EPV - if: ${{ env.EPV != 0 }} - run: phpBB/vendor/bin/EPV.php run --dir="phpBB/ext/$EXTNAME/" - working-directory: ./phpBB3 - # END Basic Checks Job - - # START MySQL and MariaDB Job - mysql-tests: - runs-on: ubuntu-20.04 - strategy: - matrix: - include: - - php: '7.1' - db: "mariadb:10.1" - - php: '7.1' - db: "mariadb:10.2" - - php: '7.1' - db: "mariadb:10.3" - - php: '7.1' - db: "mariadb:10.4" - - php: '7.1' - db: "mariadb:10.5" - - php: '7.1' - db: "mysql:5.6" - db_alias: "MyISAM Tests" - MYISAM: 1 - - php: '7.1' - db: "mysql:5.6" - - php: '7.1' - db: "mysql:5.7" - - php: '7.2' - db: "mysql:5.7" - COVERAGE: 1 - db_alias: "mysql:5.7 with Coverage" - - php: '7.3' - db: "mysql:5.7" - - php: '7.4' - db: "mysql:5.7" - - php: '7.4' - db: "mysql:8.0" - - php: '8.0' - db: "mysql:5.7" - - php: '8.1' - db: "mysql:5.7" - - php: '8.2' - db: "mysql:5.7" - - name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} - - services: - mysql: - image: ${{ matrix.db }} - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: phpbb_tests - ports: - - 3306:3306 - options: >- - --health-cmd="mysqladmin ping" - --health-interval=10s - --health-timeout=5s - --health-retries=3 - - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 6379:6379 - - steps: - - name: Checkout phpBB - uses: actions/checkout@v3 - with: - repository: phpbb/phpbb - ref: ${{ env.PHPBB_BRANCH }} - path: phpBB3 - - - name: Checkout extension - uses: actions/checkout@v3 - with: - path: phpBB3/phpBB/ext/${{ env.EXTNAME }} - - - id: database-type - env: - MATRIX_DB: ${{ matrix.db }} - run: | - db=$(echo "${MATRIX_DB%%:*}") - echo "db=$db" >> $GITHUB_OUTPUT - - - name: Setup PHP - if: ${{ matrix.COVERAGE != 1 }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap - coverage: none - - - name: Setup PHP with Coverage - if: ${{ matrix.COVERAGE == 1 }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap - coverage: xdebug - - - name: Setup environment for phpBB - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: '0' - run: .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} - working-directory: ./phpBB3 - - - name: Setup database - env: - DB: ${{steps.database-type.outputs.db}} - MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }} - run: .github/setup-database.sh $DB $MYISAM - working-directory: ./phpBB3 - - - name: Setup PHPUnit files - env: - DB: ${{steps.database-type.outputs.db}} - COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }} - run: | - if [ $COVERAGE == '1' ] - then - sed -n '1h;1!H;${;g;s/<\/php>/<\/php>\n\t\n\t\t\n\t\t\t..\/<\/directory>\n\t\t\t\n\t\t\t\t..\/tests\/<\/directory>\n\t\t\t\t..\/language\/<\/directory>\n\t\t\t\t..\/migrations\/<\/directory>\n\t\t\t<\/exclude>\n\t\t<\/whitelist>\n\t<\/filter>/g;p;}' .github/phpunit-$DB-github.xml &> phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml - else - mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_ - fi - working-directory: ./phpBB3 - - - name: Run unit tests - env: - DB: ${{steps.database-type.outputs.db}} - COVERAGE: ${{ matrix.COVERAGE != 1 && '0' || '1' }} - run: | - if [ $COVERAGE == '1' ] - then - phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php --coverage-clover build/logs/clover.xml - else - phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php - fi - working-directory: ./phpBB3 - - - name: Send code coverage - if: ${{ matrix.COVERAGE == 1 }} - uses: codecov/codecov-action@v3 - with: - files: ./phpBB3/build/logs/clover.xml - # END MySQL and MariaDB Job - - # START PostgreSQL Job - postgres-tests: - runs-on: ubuntu-20.04 - strategy: - matrix: - include: - - php: '7.1' - db: "postgres:9.5" - - php: '7.1' - db: "postgres:9.6" - - php: '7.1' - db: "postgres:10" - - php: '7.1' - db: "postgres:11" - - php: '7.1' - db: "postgres:12" - - php: '7.1' - db: "postgres:13" - - php: '7.2' - db: "postgres:13" - - php: '7.3' - db: "postgres:13" - - php: '7.4' - db: "postgres:13" - - php: '8.0' - db: "postgres:12" - - php: '8.0' - db: "postgres:13" - - php: '8.1' - db: "postgres:14" - - php: '8.2' - db: "postgres:14" - - name: PHP ${{ matrix.php }} - ${{ matrix.db }} - - services: - postgres: - image: ${{ matrix.db != 'postgres:9.5' && matrix.db != 'postgres:9.6' && matrix.db != 'postgres:10' && matrix.db != 'postgres:11' && matrix.db != 'postgres:12' && matrix.db != 'postgres:13' && 'postgres:10' || matrix.db }} - env: - POSTGRES_HOST: localhost - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - options: >- - -v /var/run/postgresql:/var/run/postgresql - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 6379:6379 - - steps: - - name: Checkout phpBB - uses: actions/checkout@v3 - with: - repository: phpbb/phpbb - ref: ${{ env.PHPBB_BRANCH }} - path: phpBB3 - - - name: Checkout extension - uses: actions/checkout@v3 - with: - path: phpBB3/phpBB/ext/${{ env.EXTNAME }} - - - id: database-type - env: - MATRIX_DB: ${{ matrix.db }} - run: | - db=$(echo "${MATRIX_DB%%:*}") - echo "db=$db" >> $GITHUB_OUTPUT - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap - coverage: none - - - name: Setup environment for phpBB - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: '0' - run: .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} - working-directory: ./phpBB3 - - - name: Setup database - env: - DB: ${{steps.database-type.outputs.db}} - MYISAM: '0' - run: .github/setup-database.sh $DB $MYISAM - working-directory: ./phpBB3 - - - name: Setup PHPUnit files - run: mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_ - working-directory: ./phpBB3 - - - name: Run unit tests - env: - DB: ${{steps.database-type.outputs.db}} - run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php - working-directory: ./phpBB3 - # END PostgreSQL Job - - # START Other Tests Job (SQLite 3 and mssql) - other-tests: - runs-on: ubuntu-20.04 - strategy: - matrix: - include: - - php: '7.1' - db: "sqlite3" - - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2017-latest" - db_alias: 'MSSQL 2017' - - php: '7.2' - db: "mcr.microsoft.com/mssql/server:2019-latest" - db_alias: 'MSSQL 2019' - - name: PHP ${{ matrix.php }} - ${{ matrix.db_alias != '' && matrix.db_alias || matrix.db }} - - services: - mssql: - image: ${{ matrix.db != 'mcr.microsoft.com/mssql/server:2017-latest' && matrix.db != 'mcr.microsoft.com/mssql/server:2019-latest' && 'mcr.microsoft.com/mssql/server:2017-latest' || matrix.db }} - env: - SA_PASSWORD: "Pssw0rd_12" - ACCEPT_EULA: "y" - ports: - - 1433:1433 - options: >- - --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Pssw0rd_12' -Q \"Use [master]; CREATE DATABASE [phpbb_tests] COLLATE Latin1_General_CI_AS\" || exit 1" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - --health-start-period 10s - - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 6379:6379 - - steps: - - name: Checkout phpBB - uses: actions/checkout@v3 - with: - repository: phpbb/phpbb - ref: ${{ env.PHPBB_BRANCH }} - path: phpBB3 - - - name: Checkout extension - uses: actions/checkout@v3 - with: - path: phpBB3/phpBB/ext/${{ env.EXTNAME }} - - - id: database-type - env: - MATRIX_DB: ${{ matrix.db }} - run: | - if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2017-latest' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-latest' ] - then - db='mssql' - else - db=$(echo "${MATRIX_DB%%:*}") - fi - echo "db=$db" >> $GITHUB_OUTPUT - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, mysqli, sqlite, pdo_sqlite, intl, gd, exif, iconv, sqlsrv, pdo_sqlsrv, ldap - coverage: none - - - name: Setup environment for phpBB - env: - DB: ${{steps.database-type.outputs.db}} - PHP_VERSION: ${{ matrix.php }} - NOTESTS: '0' - run: .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} - working-directory: ./phpBB3 - - - name: Setup database - env: - DB: ${{steps.database-type.outputs.db}} - MYISAM: '0' - run: .github/setup-database.sh $DB $MYISAM - working-directory: ./phpBB3 - - - name: Setup PHPUnit files - run: mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_ - working-directory: ./phpBB3 - - - name: Run unit tests - env: - DB: ${{steps.database-type.outputs.db}} - run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php - working-directory: ./phpBB3 - # END Other Tests Job + call-tests: + name: Extension tests + uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@3.3.x + with: + EXTNAME: cube/matomoanalytics # Your extension vendor/package name + CODECOV: 1 # Run code coverage via codecov? 1 or 0 + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Do not change this diff --git a/CHANGELOG.md b/CHANGELOG.md index a2477b4..a7add77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.1.1 - 2026-02-11 + + - Merge evolutions from upstream: https://github.com/phpbb-extensions/googleanalytics + ## 1.0.0 - 2022-03-10 - changed all names to matomo diff --git a/composer.json b/composer.json index 25fee41..aedd0d5 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,12 @@ "homepage": "https://janwille.de", "role": "Extension Developer" }, + { + "name": "Zorglube", + "email": "630192+zorglube@users.noreply.github.com", + "homepage": "https://blog.broncotoxique.com", + "role": "Extension Contributor" + }, { "name": "Marc Alexander", "email": "admin@m-a-styles.de", @@ -45,7 +51,7 @@ "composer/installers": "~1.0" }, "require-dev": { - "phing/phing": "2.4.*" + "phing/phing": "~2.4" }, "extra": { "display-name": "Matomo Analytics", diff --git a/event/listener.php b/event/listener.php index 79a8875..55a406a 100644 --- a/event/listener.php +++ b/event/listener.php @@ -60,9 +60,10 @@ public function __construct(config $config, language $language, template $templa public static function getSubscribedEvents() { return [ - 'core.acp_board_config_edit_add' => 'add_matomoanalytics_configs', - 'core.page_header' => 'load_matomoanalytics', - 'core.validate_config_variable' => 'validate_matomoanalytics_url', + 'core.page_header' => 'load_matomoanalytics', + 'core.acp_board_config_edit_add' => 'add_matomoanalytics_configs', + 'core.validate_config_variable' => 'validate_matomoanalytics_url', + 'core.page_footer_after' => 'append_agreement', ]; } @@ -159,4 +160,24 @@ public function validate_matomoanalytics_url($event) // Update error event data $event['error'] = $error; } + + /** + * Append additional agreement details to the privacy agreement. + * + * @return void + */ + public function append_agreement() + { + if (!$this->config['googleanalytics_id'] + || (strpos($this->user->page['page_name'], 'ucp') !== 0) + || !$this->template->retrieve_var('S_AGREEMENT') + || ($this->template->retrieve_var('AGREEMENT_TITLE') !== $this->language->lang('PRIVACY'))) + { + return; + } + + $this->language->add_lang('googleanalytics_ucp', 'cube/matomoanalytics'); + + $this->template->append_var('AGREEMENT_TEXT', $this->language->lang('PHPBB_ANALYTICS_PRIVACY_POLICY', $this->config['sitename'])); + } } diff --git a/ext.php b/ext.php index a06ccfc..9b773e8 100644 --- a/ext.php +++ b/ext.php @@ -19,6 +19,7 @@ class ext extends base */ public function is_enableable() { - return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>='); + return phpbb_version_compare(PHPBB_VERSION, '3.2.0', '>=') + && phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '<'); } } diff --git a/language/de/matomoanalytics_ups.php b/language/de/matomoanalytics_ups.php new file mode 100644 index 0000000..9cf389f --- /dev/null +++ b/language/de/matomoanalytics_ups.php @@ -0,0 +1,52 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + */ + +/** +* DO NOT CHANGE +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +if (empty($lang) || !is_array($lang)) +{ + $lang = []; +} + +// DEVELOPERS PLEASE NOTE +// +// All language files should use UTF-8 as their encoding and the files must not contain a BOM. +// +// Placeholders can now contain order information, e.g. instead of +// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows +// translators to re-order the output of data while ensuring it remains correct +// +// You do not need this where single placeholders are used, e.g. 'Message %d' is fine +// equally where a string contains only two placeholders which are used to wrap text +// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine +// +// Some characters you may want to copy&paste: +// ’ » “ ” … +// + +$lang = array_merge($lang, [ + 'PHPBB_ANALYTICS_PRIVACY_POLICY' => ' +

+

Analytics

+ “%1$s” may use MAtomo Analytics, a web analytics service provided by InnoCraft Limited (InnoCraft, we), to help us understand how visitors use the site. Matomo uses cookies and similar technologies to collect information about your interactions with the site, including the pages you visit, the time spent on each page, and general usage patterns. +

+ The information generated by these cookies about your use of “%1$s” (may include your IP address) is transmitted to and stored on the Matomo deployement solution choosed by the website owned (might be on premise, or into cloud solution). The website owner uses this information to evaluate your use of the site, compile reports on website activity, the uses of thoses infornation is decided by the website owner. +

+ Thoses informations may be transfer to a third parties. To learn more about how the statistics informations are used, contact the website owner. +

+ If you want to opt out of the statistics collection
. + ', +]); diff --git a/tests/event/listener_test.php b/tests/event/listener_test.php index 80f3827..2e873f5 100644 --- a/tests/event/listener_test.php +++ b/tests/event/listener_test.php @@ -10,8 +10,6 @@ namespace cube\matomoanalytics\tests\event; -require_once __DIR__ . '/../../../../../includes/functions_acp.php'; - class listener_test extends \phpbb_test_case { /** @var \cube\matomoanalytics\event\listener */ @@ -21,7 +19,7 @@ class listener_test extends \phpbb_test_case protected $config; /** @var \phpbb\language\language */ - protected $lang; + protected $language; /** @var \PHPUnit\Framework\MockObject\MockObject|\phpbb\template\template */ protected $template; @@ -29,6 +27,15 @@ class listener_test extends \phpbb_test_case /** @var \phpbb\user */ protected $user; + public static function setUpBeforeClass(): void + { + $acp_functions = __DIR__ . '/../../../../../includes/functions_acp.php'; + if (is_file($acp_functions)) + { + require_once $acp_functions; + } + } + /** * Setup test environment */ @@ -47,8 +54,8 @@ protected function setUp(): void $this->template = $this->getMockBuilder('\phpbb\template\template') ->getMock(); $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); - $this->lang = new \phpbb\language\language($lang_loader); - $this->user = new \phpbb\user($this->lang, '\phpbb\datetime'); + $this->language = new \phpbb\language\language($lang_loader); + $this->user = new \phpbb\user($this->language, '\phpbb\datetime'); $this->user->data['user_id'] = 2; $this->user->data['is_registered'] = true; } @@ -60,7 +67,7 @@ protected function set_listener() { $this->listener = new \cube\matomoanalytics\event\listener( $this->config, - $this->lang, + $this->language, $this->template, $this->user ); @@ -81,8 +88,8 @@ public function test_construct() public function test_getSubscribedEvents() { self::assertEquals([ - 'core.acp_board_config_edit_add', 'core.page_header', + 'core.acp_board_config_edit_add', 'core.validate_config_variable', ], array_keys(\cube\matomoanalytics\event\listener::getSubscribedEvents())); } @@ -152,7 +159,7 @@ public function test_add_matomoanalytics_configs($mode, $display_vars, $expected $event_data = ['display_vars', 'mode']; $event_data_after = $dispatcher->trigger_event('core.acp_board_config_edit_add', compact($event_data)); - extract($event_data_after, EXTR_OVERWRITE); + extract($event_data_after); $keys = array_keys($display_vars['vars']); @@ -233,7 +240,7 @@ public function test_validate_matomoanalytics_url($cfg_array, $expected_error) { self::assertArrayHasKey($expected, $event_data_after); } - extract($event_data_after, EXTR_OVERWRITE); + extract($event_data_after); self::assertEquals($expected_error, $error); }