-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
194 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/community/Resources/modules/actions/user/report.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {createElement} from 'react' | ||
import get from 'lodash/get' | ||
|
||
import {url} from '#/main/app/api' | ||
import {ASYNC_BUTTON} from '#/main/app/buttons' | ||
import {hasPermission} from '#/main/app/security' | ||
import {trans, transChoice} from '#/main/app/intl/translation' | ||
|
||
import {UserCard} from '#/main/community/user/components/card' | ||
|
||
/** | ||
* Report action. | ||
*/ | ||
export default (users, refresher) => { | ||
const processable = users.filter(user => hasPermission('administrate', user) && !get(user, 'restrictions.disabled', false)) | ||
|
||
return { | ||
name: 'report', | ||
type: ASYNC_BUTTON, | ||
icon: 'fa fa-fw fa-flag', | ||
label: trans('report', {}, 'actions'), | ||
displayed: 0 !== processable.length, | ||
dangerous: true, | ||
confirm: { | ||
title: transChoice('user_reported_confirm_title', processable.length, {}, 'community'), | ||
subtitle: 1 === processable.length ? processable[0].name : transChoice('count_elements', processable.length, {count: processable.length}), | ||
message: transChoice('user_reported_confirm_message', processable.length, {count: processable.length}, 'community'), | ||
additional: [ | ||
createElement('div', { | ||
key: 'additional', | ||
className: 'modal-body' | ||
}, processable.map(user => createElement(UserCard, { | ||
key: user.id, | ||
orientation: 'row', | ||
size: 'xs', | ||
data: user | ||
}))) | ||
] | ||
}, | ||
request: { | ||
url: url(['apiv2_user_report'], {ids: users.map(u => u.id)}), | ||
request: { | ||
method: 'PUT' | ||
}, | ||
success: (response) => refresher.update(response) | ||
}, | ||
scope: ['object', 'collection'], | ||
group: trans('management') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/community/Resources/modules/tools/community/editor/components/reported.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
|
||
import {trans} from '#/main/app/intl' | ||
import {EditorPage} from '#/main/app/editor' | ||
|
||
import {UserList} from '#/main/community/user/components/list' | ||
import {selectors} from '#/main/community/tools/community/editor/store/selectors' | ||
|
||
const CommunityEditorReported = () => | ||
<EditorPage | ||
title={trans('user_reported', {}, 'community')} | ||
help={trans('user_reported_help', {}, 'community')} | ||
> | ||
<UserList | ||
name={selectors.FORM_NAME} | ||
url={['apiv2_user_list_reported']} | ||
/> | ||
</EditorPage> | ||
|
||
export { | ||
CommunityEditorReported | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/core/Installation/Migrations/Version20241018125139.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Claroline\CoreBundle\Installation\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated migration based on mapping information: modify it with caution. | ||
* | ||
* Generation date: 2024/10/18 12:51:41 | ||
*/ | ||
final class Version20241018125139 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql(' | ||
ALTER TABLE claro_user | ||
ADD reported TINYINT(1) NOT NULL | ||
'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql(' | ||
ALTER TABLE claro_user | ||
DROP reported | ||
'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters