From 0d71f9f3f7289224dbe4fff17c17df2c86e34f0c Mon Sep 17 00:00:00 2001 From: dmzx Date: Mon, 4 Apr 2016 22:08:48 +0200 Subject: [PATCH] Version 2.0.0-RC5 --- .travis.yml | 23 +++++++++++----------- composer.json | 4 ++-- core/functions.php | 6 +++++- core/mchat.php | 35 +++++++++++++++++++++++----------- migrations/mchat_2_0_0_rc5.php | 29 ++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 25 deletions(-) create mode 100644 migrations/mchat_2_0_0_rc5.php diff --git a/.travis.yml b/.travis.yml index f0b49e9..fed516c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,12 @@ language: php matrix: include: + - php: 5.3.3 + env: DB=mysqli + - php: 5.3 + env: DB=mysqli # MyISAM - php: 5.4 - env: DB=none;NOTESTS=1 - - php: 5.4 - env: DB=mysqli #myisam + env: DB=mysqli - php: 5.4 env: DB=mysql - php: 5.4 @@ -16,16 +18,15 @@ matrix: env: DB=postgres - php: 5.4 env: DB=sqlite3 + - php: 5.4 + env: DB=mysqli;SLOWTESTS=1 - php: 5.5 env: DB=mysqli - php: 5.6 env: DB=mysqli - - php: 7.0 - env: DB=mysqli - php: hhvm env: DB=mysqli allow_failures: - - php: 7.0 - php: hhvm fast_finish: true @@ -51,7 +52,7 @@ before_install: - sudo rm -rf phpbb-ext-acme-demo install: - - composer install --dev --no-interaction --prefer-source + - composer install --no-interaction --prefer-source - travis/prepare-phpbb.sh $EXTNAME $PHPBB_BRANCH - cd ../../phpBB3 - travis/prepare-extension.sh $EXTNAME $PHPBB_BRANCH @@ -61,7 +62,7 @@ before_script: - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION script: - - sh -c "if [ '$SNIFF' != '0' ]; then travis/ext-sniff.sh $DB $TRAVIS_PHP_VERSION $EXTNAME $NOTESTS; fi" - - sh -c "if [ '$IMAGE_ICC' != '0' ]; then travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION $NOTESTS; fi" - - sh -c "if [ '$NOTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/travis/phpunit-$DB-travis.xml --bootstrap ./tests/bootstrap.php; fi" - - sh -c "if [ '$EPV' != '0' ] && [ '$NOTESTS' = '1' ]; then phpBB/ext/$EXTNAME/vendor/bin/EPV.php run --dir='phpBB/ext/$EXTNAME/'; fi" + - sh -c "if [ '$SNIFF' != '0' ]; then travis/ext-sniff.sh $DB $TRAVIS_PHP_VERSION $EXTNAME; fi" + - sh -c "if [ '$IMAGE_ICC' != '0' ]; then travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION; fi" + - phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/travis/phpunit-$DB-travis.xml --bootstrap ./tests/bootstrap.php + - sh -c "if [ '$EPV' != '0' ] && [ '$TRAVIS_PHP_VERSION' = '5.3.3' ] && [ '$DB' = 'mysqli' ]; then phpBB/ext/$EXTNAME/vendor/bin/EPV.php run --dir='phpBB/ext/$EXTNAME/'; fi" diff --git a/composer.json b/composer.json index 627e175..4ab54d4 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,8 @@ "type": "phpbb-extension", "description": "mChat Extension", "homepage": "http://www.dmzx-web.net", - "version": "2.0.0-RC4", - "time": "2016-03-31", + "version": "2.0.0-RC5", + "time": "2016-04-03", "keywords": ["phpbb", "extension", "mchat"], "license": "GPL-2.0", "authors": [ diff --git a/core/functions.php b/core/functions.php index 023a6a2..46df26e 100644 --- a/core/functions.php +++ b/core/functions.php @@ -281,12 +281,16 @@ class functions } $sql_array = array( - 'SELECT' => 'm.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm', + 'SELECT' => 'm.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm, p.post_visibility', 'FROM' => array($this->mchat_table => 'm'), 'LEFT_JOIN' => array( array( 'FROM' => array(USERS_TABLE => 'u'), 'ON' => 'm.user_id = u.user_id', + ), + array( + 'FROM' => array(POSTS_TABLE => 'p'), + 'ON' => 'm.post_id = p.post_id', ) ), 'WHERE' => $sql_where, diff --git a/core/mchat.php b/core/mchat.php index 06432e0..40a9723 100644 --- a/core/mchat.php +++ b/core/mchat.php @@ -678,6 +678,25 @@ class mchat */ protected function assign_messages($rows) { + // Auth checks + foreach ($rows as $i => $row) + { + if ($row['forum_id']) + { + // No permission to read forum + if (!$this->auth->acl_get('f_read', $row['forum_id'])) + { + unset($rows[$i]); + } + + // Post is not approved and no approval permission + if ($row['post_visibility'] !== ITEM_APPROVED && !$this->auth->acl_get('m_approve', $row['forum_id'])) + { + unset($rows[$i]); + } + } + } + if (!$rows) { return; @@ -713,19 +732,8 @@ class mchat foreach ($rows as $i => $row) { - // Auth checks - if ($row['forum_id'] && !$this->auth->acl_get('f_read', $row['forum_id'])) - { - continue; - } - $message_for_edit = generate_text_for_edit($row['message'], $row['bbcode_uid'], $row['bbcode_options']); - if (in_array($row['user_id'], $foes)) - { - $row['message'] = $this->user->lang('MCHAT_FOE', get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST'))); - } - $username_full = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang('GUEST')); // Fix profile link root path by replacing relative paths with absolute board URL @@ -734,6 +742,11 @@ class mchat $username_full = preg_replace('#(?<=href=")[\./]+?/(?=\w)#', $board_url, $username_full); } + if (in_array($row['user_id'], $foes)) + { + $row['message'] = $this->user->lang('MCHAT_FOE', $username_full); + } + $message_age = time() - $row['message_time']; $minutes_ago = $this->get_minutes_ago($message_age); $datetime = $this->user->format_date($row['message_time'], $this->settings->cfg('mchat_date')); diff --git a/migrations/mchat_2_0_0_rc5.php b/migrations/mchat_2_0_0_rc5.php new file mode 100644 index 0000000..e7dcbe1 --- /dev/null +++ b/migrations/mchat_2_0_0_rc5.php @@ -0,0 +1,29 @@ +