Skip to content

Commit

Permalink
Merge pull request #180 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Release 6.0
  • Loading branch information
M0rgan01 authored Aug 23, 2023
2 parents 2a1e4be + 43c6fb1 commit 091e8bf
Show file tree
Hide file tree
Showing 26 changed files with 2,181 additions and 1,441 deletions.
61 changes: 3 additions & 58 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,6 @@ name: Build
on: [push, pull_request]

jobs:
deploy:
name: build dependencies & create artifact
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Install composer dependencies
run: composer install --no-dev -o
- name: Clean-up project
uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0
- name: Prepare auto-index tool
run: |
composer global require prestashop/autoindex
- name: Generate index.php
run: |
~/.composer/vendor/bin/autoindex
- name: Create & upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ github.event.repository.name }}
path: ../
update_release_draft:
runs-on: ubuntu-latest
needs: [deploy]
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ github.event.repository.name }}
- id: release_info
uses: toolmantim/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare for Release
run: |
cd ${{ github.event.repository.name }}
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
- name: Clean existing assets
shell: bash
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'`
for asset in $assets
do
bin/hub api -X DELETE $asset
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GitHub Release
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release_info.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}/${{ github.event.repository.name }}.zip
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip
build-and-release-draft:
name: Build & Release draft
uses: PrestaShop/.github/.github/workflows/build-release.yml@master
24 changes: 12 additions & 12 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ on: [push, pull_request]
jobs:
# Check there is no syntax errors in the project
php-linter:
name: PHP Syntax check 5.6 => 8.1
name: PHP Syntax check 7.2 => 8.2
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.0.0

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master
uses: actions/checkout@v3.1.0

- name: PHP syntax checker 7.2
uses: prestashop/github-action-php-lint/7.2@master
Expand All @@ -27,6 +24,9 @@ jobs:
- name: PHP syntax checker 8.1
uses: prestashop/github-action-php-lint/8.1@master

- name: PHP syntax checker 8.2
uses: prestashop/github-action-php-lint/8.2@master

# Check the PHP code follow the coding standards
php-cs-fixer:
name: PHP-CS-Fixer
Expand All @@ -38,10 +38,10 @@ jobs:
php-version: '7.4'

- name: Checkout
uses: actions/checkout@v2.0.0
uses: actions/checkout@v3.1.0

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}
Expand All @@ -50,34 +50,34 @@ jobs:
run: composer install

- name: Run PHP-CS-Fixer
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no --diff-format udiff
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --using-cache=no

# Run PHPStan against the module and a PrestaShop release
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: ['1.7.6', '1.7.7', '1.7.8', 'latest']
presta-versions: ['1.7.7', '1.7.8', '8.0', 'latest']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Checkout
uses: actions/checkout@v2.0.0
uses: actions/checkout@v3.1.0

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

# Add composer local folder in cache to make next builds faster
- name: Cache composer folder
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: php-composer-cache
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions ProductComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ public static function getRatings($id_product)
return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->getRow($sql);
}

/**
* @deprecated 4.0.0
*/
public static function getAverageGrade($id_product)
{
$validate = Configuration::get('PRODUCT_COMMENTS_MODERATE');
Expand Down Expand Up @@ -235,6 +238,8 @@ public static function getAveragesByProduct($id_product, $id_lang)
* Return number of comments and average grade by products
*
* @return int|false
*
* @deprecated 4.0.0
*/
public static function getCommentNumber($id_product)
{
Expand Down Expand Up @@ -279,6 +284,8 @@ public static function getGradedCommentNumber($id_product)
* Get comments by Validation
*
* @return array Comments
*
* @deprecated 6.0.0
*/
public static function getByValidate($validate = '0', $deleted = false, $p = null, $limit = null, $skip_validate = false)
{
Expand Down Expand Up @@ -306,6 +313,8 @@ public static function getByValidate($validate = '0', $deleted = false, $p = nul
* Get numbers of comments by Validation
*
* @return int Count of comments
*
* @deprecated 6.0.0
*/
public static function getCountByValidate($validate = '0', $skip_validate = false)
{
Expand Down Expand Up @@ -360,6 +369,8 @@ public function validate($validate = '1')
* Delete a comment, grade and report data
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public function delete()
{
Expand All @@ -373,6 +384,8 @@ public function delete()
* Delete Grades
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteGrades($id_product_comment)
{
Expand All @@ -389,6 +402,8 @@ public static function deleteGrades($id_product_comment)
* Delete Reports
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteReports($id_product_comment)
{
Expand All @@ -405,6 +420,8 @@ public static function deleteReports($id_product_comment)
* Delete usefulness
*
* @return bool succeed
*
* @deprecated 6.0.0
*/
public static function deleteUsefulness($id_product_comment)
{
Expand Down Expand Up @@ -473,6 +490,8 @@ public static function isAlreadyUsefulness($id_product_comment, $id_customer)
* Get reported comments
*
* @return array Comments
*
* @deprecated 6.0.0
*/
public static function getReportedComments()
{
Expand Down
21 changes: 21 additions & 0 deletions ProductCommentCriterion.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public function addCategory($id_category)
* Add grade to a criterion
*
* @return bool succeed
*
* @deprecated 4.0.0
*/
public function addGrade($id_product_comment, $grade)
{
Expand All @@ -154,6 +156,8 @@ public function addGrade($id_product_comment, $grade)
* Get criterion by Product
*
* @return array Criterion
*
* @deprecated 4.0.0
*/
public static function getByProduct($id_product, $id_lang)
{
Expand Down Expand Up @@ -201,6 +205,8 @@ public static function getByProduct($id_product, $id_lang)
* Get Criterions
*
* @return array Criterions
*
* @deprecated 6.0.0
*/
public static function getCriterions($id_lang, $type = false, $active = false)
{
Expand All @@ -224,6 +230,9 @@ public static function getCriterions($id_lang, $type = false, $active = false)
return $criterions;
}

/**
* @deprecated 6.0.0
*/
public function getProducts()
{
$res = Db::getInstance()->executeS('
Expand All @@ -240,6 +249,9 @@ public function getProducts()
return $products;
}

/**
* @deprecated 6.0.0
*/
public function getCategories()
{
$res = Db::getInstance()->executeS('
Expand All @@ -256,20 +268,29 @@ public function getCategories()
return $criterions;
}

/**
* @deprecated 6.0.0
*/
public function deleteCategories()
{
return Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'product_comment_criterion_category`
WHERE `id_product_comment_criterion` = ' . (int) $this->id);
}

/**
* @deprecated 6.0.0
*/
public function deleteProducts()
{
return Db::getInstance()->execute('
DELETE FROM `' . _DB_PREFIX_ . 'product_comment_criterion_product`
WHERE `id_product_comment_criterion` = ' . (int) $this->id);
}

/**
* @deprecated 6.0.0
*/
public static function getTypes()
{
// Instance of module class for translations
Expand Down
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,36 @@

Allow users to post reviews on your products and/or rate them based on specific criteria.

## Compatibility

PrestaShop: `1.7.7` or newer

## Multistore compatibility

This module is partially compatible with the multistore feature. Some of its options might not be available.

## How to test

Link to specs : https://docs.prestashop-project.org/functional-documentation/functional-documentation/ux-ui/back-office/improve/modules/product-comments-productcomments

In BO, check that Configuration options work well
Check if reviews are displayed
Approve/delete reviews
Add a review criteria
In FO, add comments to products
Report/thumb up or down a comment
Check product comment in Quickview

### Update dependency

The only dependency for this module (for now) is https://github.com/flaviusmatis/simplePagination.js.git
You can install/update it by launching the command
There is no JS dependency for this module (for now).
You can install PHP dependency by launching the command

```
# yarn install
# composer install
```

(We use yarn because this library is not served as a package for npm).

This will install the library js in views/js folder.
This will install the PHP libraries in vendor folder.

## Reporting issues

Expand All @@ -36,7 +50,7 @@ Just make sure to follow our [contribution guidelines][contribution-guidelines].
This module is released under the [Academic Free License 3.0][AFL-3.0]

[report-issue]: https://github.com/PrestaShop/PrestaShop/issues/new/choose
[prestashop]: https://www.prestashop.com/
[prestashop]: https://www.prestashop-project.org/
[contribution-guidelines]: https://devdocs.prestashop.com/1.7/contribute/contribution-guidelines/project-modules/
[AFL-3.0]: https://opensource.org/licenses/AFL-3.0

9 changes: 3 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@
}
],
"require": {
"php": ">=5.6.0"
"php": ">=7.1.3"
},
"require-dev": {
"prestashop/php-dev-tools": "^3.4"
"prestashop/php-dev-tools": "^4.3"
},
"config": {
"preferred-install": "dist",
"classmap-authoritative": true,
"optimize-autoloader": true,
"prepend-autoloader": false,
"platform": {
"php": "5.6"
}
"prepend-autoloader": false
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 091e8bf

Please sign in to comment.