mirror of
https://github.com/flarum/core.git
synced 2025-08-14 12:24:33 +02:00
Compare commits
159 Commits
v0.1.0-bet
...
v0.1.0-bet
Author | SHA1 | Date | |
---|---|---|---|
|
ce8a5b3e0f | ||
|
5faf0fcde5 | ||
|
65c0b436c0 | ||
|
8d76168bd4 | ||
|
d16f4dbefa | ||
|
e3e4786391 | ||
|
c1c7d4c73a | ||
|
8da8c9ac7d | ||
|
fb68aa88db | ||
|
afc597c189 | ||
|
4f3e67714e | ||
|
54be3ad3c8 | ||
|
0b00d56416 | ||
|
89d4a1e849 | ||
|
43ee7b59a4 | ||
|
d052f6b639 | ||
|
4b47adabcf | ||
|
93140b8fa4 | ||
|
ade2166310 | ||
|
a9969119d2 | ||
|
94a8eaec64 | ||
|
8ea13dc826 | ||
|
99d42372c3 | ||
|
01b56eecdb | ||
|
bcdcb8c20e | ||
|
d6c99eccdb | ||
|
01cb8ab79d | ||
|
877aed215b | ||
|
57570d960e | ||
|
04c4806f6f | ||
|
4c0339c30e | ||
|
e64dc4ea45 | ||
|
305076814f | ||
|
e31edd29d2 | ||
|
23b423c6ce | ||
|
1af1f472f9 | ||
|
7c86f7a34c | ||
|
14e49269d6 | ||
|
7837fff107 | ||
|
3dfa6bc8cb | ||
|
e47fe288fa | ||
|
03e30d7d4f | ||
|
9836ff6c54 | ||
|
bb1c655c90 | ||
|
bf20fe595a | ||
|
b5db57156b | ||
|
a7d3bdf244 | ||
|
c82f0bde61 | ||
|
986102c1d3 | ||
|
2140619c0b | ||
|
2f714a01ed | ||
|
231d018de5 | ||
|
5d62231004 | ||
|
123c3a93f5 | ||
|
c1eec2b261 | ||
|
60d3d6ef99 | ||
|
7862bd32dd | ||
|
92b555a246 | ||
|
687ec6a199 | ||
|
f788a0a972 | ||
|
e7bec9fe29 | ||
|
57da4e24cb | ||
|
7d1a22bcb5 | ||
|
8cc117d89d | ||
|
31ef02dc2c | ||
|
95c9ff9243 | ||
|
9718f54683 | ||
|
bb1e3278de | ||
|
bbcc33b5b5 | ||
|
30076547e5 | ||
|
7b710d5898 | ||
|
d02b5c9db7 | ||
|
cd70819fd5 | ||
|
20b4619e75 | ||
|
fdec2fd094 | ||
|
d7e4ae09b3 | ||
|
fcfc1b2a37 | ||
|
01eba18164 | ||
|
0dcf7d6aa9 | ||
|
015967a76c | ||
|
3cd59e12f5 | ||
|
26d07699e9 | ||
|
b7d6ba4893 | ||
|
d3753d94ae | ||
|
9349ed13fc | ||
|
91ace15f6d | ||
|
7c1b0bfcf2 | ||
|
542bae6277 | ||
|
275c14ee7f | ||
|
bccc970231 | ||
|
da6f79b34a | ||
|
a3cbec25db | ||
|
2225fdec72 | ||
|
6a532ec14e | ||
|
9416d16ebb | ||
|
d6857b0fe5 | ||
|
2c7e7f5b39 | ||
|
b5b18dd436 | ||
|
4778ae5f74 | ||
|
0936a630ef | ||
|
ec8ae6e03b | ||
|
9ffdeff608 | ||
|
8540932638 | ||
|
974f45e4e8 | ||
|
32ac48c6a9 | ||
|
af5b86806a | ||
|
aeef45b3cd | ||
|
8aa70de765 | ||
|
076a71c621 | ||
|
06c32b668d | ||
|
7af4b8d45f | ||
|
cbba325a87 | ||
|
b7d7e8b18a | ||
|
1031826a3d | ||
|
3612ca7aca | ||
|
c2ee84a115 | ||
|
060745ecb7 | ||
|
dd209b1747 | ||
|
aeb0a411b9 | ||
|
1ebb8bf39a | ||
|
fcdf36b3d0 | ||
|
ab912ba1ad | ||
|
4b8eb5d6e4 | ||
|
0e20949eb0 | ||
|
b2c691a03d | ||
|
dde0de046a | ||
|
7a9795fbc3 | ||
|
f30fac6a94 | ||
|
1fb8092987 | ||
|
ea6b943dbd | ||
|
b9918e6c40 | ||
|
b3e1a023c2 | ||
|
96926a180a | ||
|
f3bdc163fa | ||
|
0df6eee10f | ||
|
258a4b352d | ||
|
24580ced7a | ||
|
8e90d9f9e2 | ||
|
af36ef3fa9 | ||
|
eef63745e6 | ||
|
c702e911b3 | ||
|
73d2ee825b | ||
|
9f99610542 | ||
|
1192867c4f | ||
|
b048498b84 | ||
|
81f7a39a31 | ||
|
ea12bbaf48 | ||
|
c8122a7879 | ||
|
1a5d7a337d | ||
|
c29ea98d48 | ||
|
3702ffa998 | ||
|
58f9c22375 | ||
|
939a1e9ca8 | ||
|
736f22a31a | ||
|
592dd6a927 | ||
|
2c5aa138cd | ||
|
53fd7b66b4 | ||
|
a1a22aa4ce | ||
|
05c9ce335e |
7
.gitattributes
vendored
7
.gitattributes
vendored
@@ -2,3 +2,10 @@
|
||||
.gitignore export-ignore
|
||||
.gitmodules export-ignore
|
||||
.travis.yml export-ignore
|
||||
.editorconfig export-ignore
|
||||
.styleci.yml export-ignore
|
||||
|
||||
phpunit.xml export-ignore
|
||||
tests export-ignore
|
||||
|
||||
js/*/dist/*.js -diff
|
||||
|
@@ -5,6 +5,7 @@ enabled:
|
||||
|
||||
disabled:
|
||||
- align_double_arrow
|
||||
- blank_line_after_opening_tag
|
||||
- multiline_array_trailing_comma
|
||||
- new_with_braces
|
||||
- phpdoc_align
|
||||
|
@@ -1,9 +1,9 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
- hhvm
|
||||
|
||||
matrix:
|
||||
|
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2016 Toby Zerner
|
||||
Copyright (c) 2014-2017 Toby Zerner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@@ -20,7 +20,7 @@
|
||||
"docs": "http://flarum.org/docs"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"php": ">=5.6.0",
|
||||
"dflydev/fig-cookies": "^1.0.2",
|
||||
"doctrine/dbal": "^2.5",
|
||||
"components/font-awesome": "^4.6",
|
||||
@@ -50,10 +50,10 @@
|
||||
"symfony/http-foundation": "^2.7",
|
||||
"symfony/translation": "^2.7",
|
||||
"symfony/yaml": "^2.7",
|
||||
"s9e/text-formatter": "^0.6.1",
|
||||
"s9e/text-formatter": "^0.8.1",
|
||||
"tobscure/json-api": "^0.3.0",
|
||||
"zendframework/zend-diactoros": "^1.1",
|
||||
"zendframework/zend-stratigility": "^1.1"
|
||||
"zendframework/zend-stratigility": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^0.9.4",
|
||||
|
456
js/admin/dist/app.js
vendored
456
js/admin/dist/app.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ export default class AddExtensionModal extends Modal {
|
||||
}
|
||||
|
||||
title() {
|
||||
return 'Add Extension';
|
||||
return app.translator.trans('core.admin.add_extension.title');
|
||||
}
|
||||
|
||||
content() {
|
||||
|
@@ -28,8 +28,8 @@ export default class AppearancePage extends Page {
|
||||
</div>
|
||||
|
||||
<div className="AppearancePage-colors-input">
|
||||
<input className="FormControl" placeholder="#aaaaaa" value={this.primaryColor()} onchange={m.withAttr('value', this.primaryColor)}/>
|
||||
<input className="FormControl" placeholder="#aaaaaa" value={this.secondaryColor()} onchange={m.withAttr('value', this.secondaryColor)}/>
|
||||
<input className="FormControl" type="color" placeholder="#aaaaaa" value={this.primaryColor()} onchange={m.withAttr('value', this.primaryColor)}/>
|
||||
<input className="FormControl" type="color" placeholder="#aaaaaa" value={this.secondaryColor()} onchange={m.withAttr('value', this.secondaryColor)}/>
|
||||
</div>
|
||||
|
||||
{Switch.component({
|
||||
|
@@ -5,6 +5,7 @@ import Button from 'flarum/components/Button';
|
||||
import Alert from 'flarum/components/Alert';
|
||||
import saveSettings from 'flarum/utils/saveSettings';
|
||||
import ItemList from 'flarum/utils/ItemList';
|
||||
import Switch from 'flarum/components/Switch';
|
||||
|
||||
export default class BasicsPage extends Page {
|
||||
init() {
|
||||
@@ -16,6 +17,7 @@ export default class BasicsPage extends Page {
|
||||
'forum_title',
|
||||
'forum_description',
|
||||
'default_locale',
|
||||
'show_language_selector',
|
||||
'default_route',
|
||||
'welcome_title',
|
||||
'welcome_message'
|
||||
@@ -23,13 +25,15 @@ export default class BasicsPage extends Page {
|
||||
this.values = {};
|
||||
|
||||
const settings = app.data.settings;
|
||||
this.fields.forEach(key => this.values[key] = m.prop(settings[key]));
|
||||
this.fields.forEach(key => this.values[key] = m.prop(settings[key] || false));
|
||||
|
||||
this.localeOptions = {};
|
||||
const locales = app.data.locales;
|
||||
for (const i in locales) {
|
||||
this.localeOptions[i] = `${locales[i]} (${i})`;
|
||||
}
|
||||
|
||||
if (typeof this.values.show_language_selector() !== "number") this.values.show_language_selector(1);
|
||||
}
|
||||
|
||||
view() {
|
||||
@@ -60,7 +64,13 @@ export default class BasicsPage extends Page {
|
||||
children: [
|
||||
Select.component({
|
||||
options: this.localeOptions,
|
||||
value: this.values.default_locale(),
|
||||
onchange: this.values.default_locale
|
||||
}),
|
||||
Switch.component({
|
||||
state: this.values.show_language_selector(),
|
||||
onchange: this.values.show_language_selector,
|
||||
children: app.translator.trans('core.admin.basics.show_language_selector_label'),
|
||||
})
|
||||
]
|
||||
})
|
||||
|
@@ -91,6 +91,13 @@ export default class PermissionGrid extends Component {
|
||||
allowGuest: true
|
||||
}, 100);
|
||||
|
||||
items.add('viewUserList', {
|
||||
icon: 'users',
|
||||
label: app.translator.trans('core.admin.permissions.view_user_list_label'),
|
||||
permission: 'viewUserList',
|
||||
allowGuest: true
|
||||
}, 100);
|
||||
|
||||
items.add('signUp', {
|
||||
icon: 'user-plus',
|
||||
label: app.translator.trans('core.admin.permissions.sign_up_label'),
|
||||
|
@@ -11,6 +11,7 @@
|
||||
"es6-micro-loader": "caridy/es6-micro-loader#v0.2.1",
|
||||
"fastclick": "~1.0.6",
|
||||
"autolink": "~1.0.0",
|
||||
"m.attrs.bidi": "tobscure/m.attrs.bidi"
|
||||
"m.attrs.bidi": "tobscure/m.attrs.bidi",
|
||||
"punycode": "http://cdnjs.cloudflare.com/ajax/libs/punycode/1.4.1/punycode.js"
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,8 @@ gulp({
|
||||
|
||||
bowerDir + '/spin.js/spin.js',
|
||||
bowerDir + '/spin.js/jquery.spin.js',
|
||||
bowerDir + '/fastclick/lib/fastclick.js'
|
||||
bowerDir + '/fastclick/lib/fastclick.js',
|
||||
bowerDir + '/punycode/index.js'
|
||||
],
|
||||
modules: {
|
||||
'flarum': [
|
||||
|
1509
js/forum/dist/app.js
vendored
1509
js/forum/dist/app.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@ export default class EditUserModal extends Modal {
|
||||
|
||||
this.username = m.prop(user.username() || '');
|
||||
this.email = m.prop(user.email() || '');
|
||||
this.isActivated = m.prop(user.isActivated() || false);
|
||||
this.setPassword = m.prop(false);
|
||||
this.password = m.prop(user.password() || '');
|
||||
this.groups = {};
|
||||
@@ -37,22 +38,32 @@ export default class EditUserModal extends Modal {
|
||||
<div className="Modal-body">
|
||||
<div className="Form">
|
||||
<div className="Form-group">
|
||||
<label>Username</label>
|
||||
<label>{app.translator.trans('core.forum.edit_user.username_heading')}</label>
|
||||
<input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.username_label'))}
|
||||
bidi={this.username} />
|
||||
</div>
|
||||
|
||||
{app.session.user !== this.props.user ? [
|
||||
<div className="Form-group">
|
||||
<label>Email</label>
|
||||
<label>{app.translator.trans('core.forum.edit_user.email_heading')}</label>
|
||||
<div>
|
||||
<input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.email_label'))}
|
||||
bidi={this.email} />
|
||||
</div>
|
||||
{!this.isActivated() ? (
|
||||
<div>
|
||||
{Button.component({
|
||||
className: 'Button Button--block',
|
||||
children: app.translator.trans('core.forum.edit_user.activate_button'),
|
||||
loading: this.loading,
|
||||
onclick: this.activate.bind(this)
|
||||
})}
|
||||
</div>
|
||||
) : ''}
|
||||
</div>,
|
||||
|
||||
<div className="Form-group">
|
||||
<label>Password</label>
|
||||
<label>{app.translator.trans('core.forum.edit_user.password_heading')}</label>
|
||||
<div>
|
||||
<label className="checkbox">
|
||||
<input type="checkbox" checked={this.setPassword()} onchange={e => {
|
||||
@@ -61,7 +72,7 @@ export default class EditUserModal extends Modal {
|
||||
if (e.target.checked) this.$('[name=password]').select();
|
||||
m.redraw.strategy('none');
|
||||
}}/>
|
||||
Set new password
|
||||
{app.translator.trans('core.forum.edit_user.set_password_label')}
|
||||
</label>
|
||||
{this.setPassword() ? (
|
||||
<input className="FormControl" type="password" name="password" placeholder={extractText(app.translator.trans('core.forum.edit_user.password_label'))}
|
||||
@@ -72,7 +83,7 @@ export default class EditUserModal extends Modal {
|
||||
] : ''}
|
||||
|
||||
<div className="Form-group EditUserModal-groups">
|
||||
<label>Groups</label>
|
||||
<label>{app.translator.trans('core.forum.edit_user.groups_heading')}</label>
|
||||
<div>
|
||||
{Object.keys(this.groups)
|
||||
.map(id => app.store.getById('groups', id))
|
||||
@@ -100,6 +111,24 @@ export default class EditUserModal extends Modal {
|
||||
);
|
||||
}
|
||||
|
||||
activate() {
|
||||
this.loading = true;
|
||||
const data = {
|
||||
username: this.username(),
|
||||
isActivated: true,
|
||||
};
|
||||
this.props.user.save(data, {errorHandler: this.onerror.bind(this)})
|
||||
.then(() => {
|
||||
this.isActivated(true);
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
})
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
});
|
||||
}
|
||||
|
||||
data() {
|
||||
const groups = Object.keys(this.groups)
|
||||
.filter(id => this.groups[id]())
|
||||
|
@@ -39,7 +39,7 @@ export default class HeaderSecondary extends Component {
|
||||
|
||||
items.add('search', app.search.render(), 30);
|
||||
|
||||
if (Object.keys(app.data.locales).length > 1) {
|
||||
if (app.forum.attribute("showLanguageSelector") && Object.keys(app.data.locales).length > 1) {
|
||||
const locales = [];
|
||||
|
||||
for (const locale in app.data.locales) {
|
||||
|
@@ -8,7 +8,7 @@ import WelcomeHero from 'flarum/components/WelcomeHero';
|
||||
import DiscussionComposer from 'flarum/components/DiscussionComposer';
|
||||
import LogInModal from 'flarum/components/LogInModal';
|
||||
import DiscussionPage from 'flarum/components/DiscussionPage';
|
||||
import Select from 'flarum/components/Select';
|
||||
import Dropdown from 'flarum/components/Dropdown';
|
||||
import Button from 'flarum/components/Button';
|
||||
import LinkButton from 'flarum/components/LinkButton';
|
||||
import SelectDropdown from 'flarum/components/SelectDropdown';
|
||||
@@ -55,7 +55,7 @@ export default class IndexPage extends Page {
|
||||
app.cache.discussionList = new DiscussionList({params});
|
||||
}
|
||||
|
||||
app.history.push('index', icon('bars'));
|
||||
app.history.push('index', app.translator.trans('core.forum.header.back_to_index_tooltip'));
|
||||
|
||||
this.bodyClass = 'App--index';
|
||||
}
|
||||
@@ -212,10 +212,20 @@ export default class IndexPage extends Page {
|
||||
}
|
||||
|
||||
items.add('sort',
|
||||
Select.component({
|
||||
options: sortOptions,
|
||||
value: this.params().sort || Object.keys(sortMap)[0],
|
||||
onchange: this.changeSort.bind(this)
|
||||
Dropdown.component({
|
||||
buttonClassName: 'Button',
|
||||
label: sortOptions[this.params().sort] || Object.keys(sortMap).map(key => sortOptions[key])[0],
|
||||
children: Object.keys(sortOptions).map(value => {
|
||||
const label = sortOptions[value];
|
||||
const active = (this.params().sort || Object.keys(sortMap)[0]) === value;
|
||||
|
||||
return Button.component({
|
||||
children: label,
|
||||
icon: active ? 'check' : true,
|
||||
onclick: this.changeSort.bind(this, value),
|
||||
active: active,
|
||||
})
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -236,7 +246,13 @@ export default class IndexPage extends Page {
|
||||
title: app.translator.trans('core.forum.index.refresh_tooltip'),
|
||||
icon: 'refresh',
|
||||
className: 'Button Button--icon',
|
||||
onclick: () => app.cache.discussionList.refresh()
|
||||
onclick: () => {
|
||||
app.cache.discussionList.refresh();
|
||||
if (app.session.user) {
|
||||
app.store.find('users', app.session.user.id());
|
||||
m.redraw();
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
@@ -11,7 +11,7 @@ import extractText from 'flarum/utils/extractText';
|
||||
*
|
||||
* ### Props
|
||||
*
|
||||
* - `email`
|
||||
* - `identification`
|
||||
* - `password`
|
||||
*/
|
||||
export default class LogInModal extends Modal {
|
||||
@@ -19,11 +19,11 @@ export default class LogInModal extends Modal {
|
||||
super.init();
|
||||
|
||||
/**
|
||||
* The value of the email input.
|
||||
* The value of the identification input.
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
this.email = m.prop(this.props.email || '');
|
||||
this.identification = m.prop(this.props.identification || '');
|
||||
|
||||
/**
|
||||
* The value of the password input.
|
||||
@@ -31,6 +31,13 @@ export default class LogInModal extends Modal {
|
||||
* @type {Function}
|
||||
*/
|
||||
this.password = m.prop(this.props.password || '');
|
||||
|
||||
/**
|
||||
* The value of the remember me input.
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
this.remember = m.prop(!!this.props.remember);
|
||||
}
|
||||
|
||||
className() {
|
||||
@@ -48,8 +55,8 @@ export default class LogInModal extends Modal {
|
||||
|
||||
<div className="Form Form--centered">
|
||||
<div className="Form-group">
|
||||
<input className="FormControl" name="email" type="text" placeholder={extractText(app.translator.trans('core.forum.log_in.username_or_email_placeholder'))}
|
||||
bidi={this.email}
|
||||
<input className="FormControl" name="identification" type="text" placeholder={extractText(app.translator.trans('core.forum.log_in.username_or_email_placeholder'))}
|
||||
bidi={this.identification}
|
||||
disabled={this.loading} />
|
||||
</div>
|
||||
|
||||
@@ -59,6 +66,15 @@ export default class LogInModal extends Modal {
|
||||
disabled={this.loading} />
|
||||
</div>
|
||||
|
||||
<div className="Form-group">
|
||||
<div>
|
||||
<label className="checkbox">
|
||||
<input type="checkbox" bidi={this.remember} disabled={this.loading} />
|
||||
{app.translator.trans('core.forum.log_in.remember_me_label')}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="Form-group">
|
||||
{Button.component({
|
||||
className: 'Button Button--primary Button--block',
|
||||
@@ -90,7 +106,7 @@ export default class LogInModal extends Modal {
|
||||
* @public
|
||||
*/
|
||||
forgotPassword() {
|
||||
const email = this.email();
|
||||
const email = this.identification();
|
||||
const props = email.indexOf('@') !== -1 ? {email} : undefined;
|
||||
|
||||
app.modal.show(new ForgotPasswordModal(props));
|
||||
@@ -104,14 +120,14 @@ export default class LogInModal extends Modal {
|
||||
*/
|
||||
signUp() {
|
||||
const props = {password: this.password()};
|
||||
const email = this.email();
|
||||
props[email.indexOf('@') !== -1 ? 'email' : 'username'] = email;
|
||||
const identification = this.identification();
|
||||
props[identification.indexOf('@') !== -1 ? 'email' : 'username'] = identification;
|
||||
|
||||
app.modal.show(new SignUpModal(props));
|
||||
}
|
||||
|
||||
onready() {
|
||||
this.$('[name=' + (this.email() ? 'password' : 'email') + ']').select();
|
||||
this.$('[name=' + (this.identification() ? 'password' : 'identification') + ']').select();
|
||||
}
|
||||
|
||||
onsubmit(e) {
|
||||
@@ -119,13 +135,15 @@ export default class LogInModal extends Modal {
|
||||
|
||||
this.loading = true;
|
||||
|
||||
const email = this.email();
|
||||
const identification = this.identification();
|
||||
const password = this.password();
|
||||
const remember = this.remember();
|
||||
|
||||
app.session.login(email, password, {errorHandler: this.onerror.bind(this)}).then(
|
||||
() => window.location.reload(),
|
||||
this.loaded.bind(this)
|
||||
);
|
||||
app.session.login({identification, password, remember}, {errorHandler: this.onerror.bind(this)})
|
||||
.then(
|
||||
() => window.location.reload(),
|
||||
this.loaded.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
onerror(error) {
|
||||
|
70
js/forum/src/components/RenameDiscussionModal.js
Normal file
70
js/forum/src/components/RenameDiscussionModal.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import Modal from 'flarum/components/Modal';
|
||||
import Button from 'flarum/components/Button';
|
||||
|
||||
/**
|
||||
* The 'RenameDiscussionModal' displays a modal dialog with an input to rename a discussion
|
||||
*/
|
||||
export default class RenameDiscussionModal extends Modal {
|
||||
init() {
|
||||
super.init();
|
||||
|
||||
this.discussion = this.props.discussion;
|
||||
this.currentTitle = this.props.currentTitle;
|
||||
this.newTitle = m.prop(this.currentTitle);
|
||||
}
|
||||
|
||||
className() {
|
||||
return 'RenameDiscussionModal Modal--small';
|
||||
}
|
||||
|
||||
title() {
|
||||
return app.translator.trans('core.forum.rename_discussion.title');
|
||||
}
|
||||
|
||||
content() {
|
||||
return (
|
||||
<div className="Modal-body">
|
||||
<div className="Form Form--centered">
|
||||
<div className="Form-group">
|
||||
<input className="FormControl" bidi={this.newTitle} type="text" />
|
||||
</div>
|
||||
<div className="Form-group">
|
||||
{Button.component({
|
||||
className: 'Button Button--primary Button--block',
|
||||
type: 'submit',
|
||||
loading: this.loading,
|
||||
children: app.translator.trans('core.forum.rename_discussion.submit_button')
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
onsubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.loading = true;
|
||||
|
||||
const title = this.newTitle;
|
||||
const currentTitle = this.currentTitle;
|
||||
|
||||
// If the title is different to what it was before, then save it. After the
|
||||
// save has completed, update the post stream as there will be a new post
|
||||
// indicating that the discussion was renamed.
|
||||
if (title && title !== currentTitle) {
|
||||
return this.discussion.save({title}).then(() => {
|
||||
if (app.viewingDiscussion(this.discussion)) {
|
||||
app.current.stream.update();
|
||||
}
|
||||
m.redraw();
|
||||
this.hide();
|
||||
}).catch(() => {
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
});
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
}
|
@@ -83,6 +83,7 @@ export default class Search extends Component {
|
||||
})}>
|
||||
<div className="Search-input">
|
||||
<input className="FormControl"
|
||||
type="search"
|
||||
placeholder={extractText(app.translator.trans('core.forum.header.search_placeholder'))}
|
||||
value={this.value()}
|
||||
oninput={m.withAttr('value', this.value)}
|
||||
|
@@ -116,7 +116,7 @@ export default class SignUpModal extends Modal {
|
||||
*/
|
||||
logIn() {
|
||||
const props = {
|
||||
email: this.email() || this.username(),
|
||||
identification: this.email() || this.username(),
|
||||
password: this.password()
|
||||
};
|
||||
|
||||
|
@@ -45,15 +45,14 @@ export default class UserBio extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
content = <div className="UserBio-content">{subContent}</div>;
|
||||
content = <div className="UserBio-content" onclick={this.edit.bind(this)}>{subContent}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={'UserBio ' + classList({
|
||||
editable: this.props.editable,
|
||||
editing: this.editing
|
||||
})}
|
||||
onclick={this.edit.bind(this)}>
|
||||
})}>
|
||||
{content}
|
||||
</div>
|
||||
);
|
||||
|
@@ -26,8 +26,6 @@ export default class UserPage extends Page {
|
||||
*/
|
||||
this.user = null;
|
||||
|
||||
app.history.push('user');
|
||||
|
||||
this.bodyClass = 'App--user';
|
||||
}
|
||||
|
||||
@@ -74,7 +72,6 @@ export default class UserPage extends Page {
|
||||
show(user) {
|
||||
this.user = user;
|
||||
|
||||
app.history.push('user', user.username());
|
||||
app.setTitle(user.username());
|
||||
|
||||
m.redraw();
|
||||
|
@@ -4,7 +4,6 @@ import ScrollListener from 'flarum/utils/ScrollListener';
|
||||
import Pane from 'flarum/utils/Pane';
|
||||
import Drawer from 'flarum/utils/Drawer';
|
||||
import mapRoutes from 'flarum/utils/mapRoutes';
|
||||
import icon from 'flarum/helpers/icon';
|
||||
import Navigation from 'flarum/components/Navigation';
|
||||
import HeaderPrimary from 'flarum/components/HeaderPrimary';
|
||||
import HeaderSecondary from 'flarum/components/HeaderSecondary';
|
||||
@@ -31,7 +30,7 @@ export default function boot(app) {
|
||||
}
|
||||
|
||||
app.routes[defaultAction].path = '/';
|
||||
app.history.push(defaultAction, icon('bars'), '/');
|
||||
app.history.push(defaultAction, app.translator.trans('core.forum.header.back_to_index_tooltip'), '/');
|
||||
|
||||
m.startComputation();
|
||||
|
||||
@@ -62,6 +61,10 @@ export default function boot(app) {
|
||||
if (e.ctrlKey || e.metaKey || e.which === 2) return;
|
||||
e.preventDefault();
|
||||
app.history.home();
|
||||
if (app.session.user) {
|
||||
app.store.find('users', app.session.user.id());
|
||||
m.redraw();
|
||||
}
|
||||
});
|
||||
|
||||
// Add a class to the body which indicates that the page has been scrolled
|
||||
|
@@ -3,6 +3,7 @@ import ReplyComposer from 'flarum/components/ReplyComposer';
|
||||
import LogInModal from 'flarum/components/LogInModal';
|
||||
import Button from 'flarum/components/Button';
|
||||
import Separator from 'flarum/components/Separator';
|
||||
import RenameDiscussionModal from 'flarum/components/RenameDiscussionModal';
|
||||
import ItemList from 'flarum/utils/ItemList';
|
||||
import extractText from 'flarum/utils/extractText';
|
||||
|
||||
@@ -227,19 +228,9 @@ export default {
|
||||
* @return {Promise}
|
||||
*/
|
||||
renameAction() {
|
||||
const currentTitle = this.title();
|
||||
const title = prompt(extractText(app.translator.trans('core.forum.discussion_controls.rename_text')), currentTitle);
|
||||
|
||||
// If the title is different to what it was before, then save it. After the
|
||||
// save has completed, update the post stream as there will be a new post
|
||||
// indicating that the discussion was renamed.
|
||||
if (title && title !== currentTitle) {
|
||||
return this.save({title}).then(() => {
|
||||
if (app.viewingDiscussion(this)) {
|
||||
app.current.stream.update();
|
||||
}
|
||||
m.redraw();
|
||||
});
|
||||
}
|
||||
return app.modal.show(new RenameDiscussionModal({
|
||||
currentTitle: this.title(),
|
||||
discussion: this
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
@@ -18,11 +18,11 @@ export default {
|
||||
* @return {ItemList}
|
||||
* @public
|
||||
*/
|
||||
controls(discussion, context) {
|
||||
controls(user, context) {
|
||||
const items = new ItemList();
|
||||
|
||||
['user', 'moderation', 'destructive'].forEach(section => {
|
||||
const controls = this[section + 'Controls'](discussion, context).toArray();
|
||||
const controls = this[section + 'Controls'](user, context).toArray();
|
||||
if (controls.length) {
|
||||
controls.forEach(item => items.add(item.itemName, item));
|
||||
items.add(section + 'Separator', Separator.component());
|
||||
|
@@ -4,22 +4,38 @@
|
||||
*
|
||||
* @param {DOMElement} element
|
||||
* @param {Boolean} isInitialized
|
||||
* @param {Object} context
|
||||
*/
|
||||
export default function affixSidebar(element, isInitialized) {
|
||||
export default function affixSidebar(element, isInitialized, context) {
|
||||
if (isInitialized) return;
|
||||
|
||||
const $sidebar = $(element);
|
||||
const $header = $('#header');
|
||||
const $footer = $('#footer');
|
||||
const onresize = () => {
|
||||
const $sidebar = $(element);
|
||||
const $header = $('#header');
|
||||
const $footer = $('#footer');
|
||||
const $affixElement = $sidebar.find('> ul');
|
||||
|
||||
// Don't affix the sidebar if it is taller than the viewport (otherwise
|
||||
// there would be no way to scroll through its content).
|
||||
if ($sidebar.outerHeight(true) > $(window).height() - $header.outerHeight(true)) return;
|
||||
$(window).off('.affix');
|
||||
$affixElement
|
||||
.removeClass('affix affix-top affix-bottom')
|
||||
.removeData('bs.affix');
|
||||
|
||||
$sidebar.find('> ul').affix({
|
||||
offset: {
|
||||
top: () => $sidebar.offset().top - $header.outerHeight(true) - parseInt($sidebar.css('margin-top'), 10),
|
||||
bottom: () => this.bottom = $footer.outerHeight(true)
|
||||
}
|
||||
});
|
||||
// Don't affix the sidebar if it is taller than the viewport (otherwise
|
||||
// there would be no way to scroll through its content).
|
||||
if ($sidebar.outerHeight(true) > $(window).height() - $header.outerHeight(true)) return;
|
||||
|
||||
$affixElement.affix({
|
||||
offset: {
|
||||
top: () => $sidebar.offset().top - $header.outerHeight(true) - parseInt($sidebar.css('margin-top'), 10),
|
||||
bottom: () => this.bottom = $footer.outerHeight(true)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Register the affix plugin to execute on every window resize (and trigger)
|
||||
$(window).on('resize', onresize).resize();
|
||||
|
||||
context.onunload = () => {
|
||||
$(window).off('resize', onresize);
|
||||
}
|
||||
}
|
||||
|
@@ -30,11 +30,11 @@ export default class Session {
|
||||
* @return {Promise}
|
||||
* @public
|
||||
*/
|
||||
login(identification, password, options = {}) {
|
||||
login(data, options = {}) {
|
||||
return app.request(Object.assign({
|
||||
method: 'POST',
|
||||
url: app.forum.attribute('baseUrl') + '/login',
|
||||
data: {identification, password}
|
||||
data
|
||||
}, options));
|
||||
}
|
||||
|
||||
|
@@ -50,10 +50,10 @@ export default class Navigation extends Component {
|
||||
const previous = history.getPrevious() || {};
|
||||
|
||||
return LinkButton.component({
|
||||
className: 'Button Navigation-back ' + (previous.title ? '' : 'Button--icon'),
|
||||
className: 'Button Navigation-back Button--icon',
|
||||
href: history.backUrl(),
|
||||
icon: 'chevron-left',
|
||||
children: previous.title,
|
||||
title: previous.title,
|
||||
config: () => {},
|
||||
onclick: e => {
|
||||
if (e.shiftKey || e.ctrlKey || e.metaKey || e.which === 2) return;
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function icon(name, attrs = {}) {
|
||||
attrs.className = 'icon fa fa-fw fa-' + name + ' ' + (attrs.className || '');
|
||||
attrs.className = 'icon fa fa-' + name + ' ' + (attrs.className || '');
|
||||
|
||||
return <i {...attrs}/>;
|
||||
}
|
||||
|
@@ -102,5 +102,3 @@ Object.assign(Discussion.prototype, {
|
||||
return posts ? posts.data.map(link => link.id) : [];
|
||||
}
|
||||
});
|
||||
|
||||
export default Discussion;
|
||||
|
@@ -17,5 +17,3 @@ Object.assign(Notification.prototype, {
|
||||
sender: Model.hasOne('sender'),
|
||||
subject: Model.hasOne('subject')
|
||||
});
|
||||
|
||||
export default Notification;
|
@@ -26,5 +26,3 @@ Object.assign(Post.prototype, {
|
||||
canEdit: Model.attribute('canEdit'),
|
||||
canDelete: Model.attribute('canDelete')
|
||||
});
|
||||
|
||||
export default Post;
|
||||
|
@@ -109,5 +109,3 @@ Object.assign(User.prototype, {
|
||||
return this.save({preferences});
|
||||
}
|
||||
});
|
||||
|
||||
export default User;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* the prototype of a parent object.
|
||||
*
|
||||
* @example
|
||||
* class MyClass extends mixin(ExtistingClass, evented, etc) {}
|
||||
* class MyClass extends mixin(ExistingClass, evented, etc) {}
|
||||
*
|
||||
* @param {Class} Parent The class to extend the new class from.
|
||||
* @param {...Object} mixins The objects to mix in.
|
||||
|
@@ -9,7 +9,7 @@
|
||||
}
|
||||
|
||||
fieldset {
|
||||
margin-bottom: 30px;
|
||||
margin-bottom: 20px;
|
||||
|
||||
> ul {
|
||||
list-style: none;
|
||||
|
@@ -61,6 +61,7 @@
|
||||
}
|
||||
.icon {
|
||||
font-size: 14px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@
|
||||
.icon {
|
||||
font-size: 14px;
|
||||
margin-right: 2px;
|
||||
.fa-fw();
|
||||
}
|
||||
}
|
||||
.NotificationGrid-checkbox {
|
||||
|
@@ -224,14 +224,14 @@
|
||||
}
|
||||
}
|
||||
.Button-icon {
|
||||
margin-right: 3px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
.Button-icon,
|
||||
.Button-caret {
|
||||
font-size: 14px;
|
||||
}
|
||||
.Button-caret {
|
||||
margin-left: 3px;
|
||||
margin-left: 7px;
|
||||
}
|
||||
.Button-badge {
|
||||
font-size: 12px;
|
||||
|
@@ -49,6 +49,7 @@
|
||||
float: left;
|
||||
margin-left: -25px;
|
||||
margin-top: 2px;
|
||||
.fa-fw();
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
|
@@ -60,6 +60,7 @@
|
||||
padding-left: 32px;
|
||||
padding-right: 32px;
|
||||
.transition(all 0.4s);
|
||||
box-sizing: inherit !important;
|
||||
}
|
||||
.Button {
|
||||
float: left;
|
||||
|
@@ -16,4 +16,5 @@
|
||||
margin-left: -30px;
|
||||
pointer-events: none;
|
||||
color: @control-color;
|
||||
.fa-fw();
|
||||
}
|
||||
|
@@ -83,6 +83,10 @@ fieldset {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
|
||||
> ul > li {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
legend {
|
||||
font-size: 14px;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return Migration::addColumns('discussions', [
|
||||
'is_private' => ['boolean', 'default' => false]
|
||||
]);
|
16
migrations/2017_04_07_114138_add_is_private_to_posts.php
Normal file
16
migrations/2017_04_07_114138_add_is_private_to_posts.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Database\Migration;
|
||||
|
||||
return Migration::addColumns('posts', [
|
||||
'is_private' => ['boolean', 'default' => false]
|
||||
]);
|
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Schema\Builder;
|
||||
|
||||
return [
|
||||
'up' => function (Builder $schema) {
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->mediumText('content')->change();
|
||||
});
|
||||
},
|
||||
|
||||
'down' => function (Builder $schema) {
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->text('content')->change();
|
||||
});
|
||||
}
|
||||
];
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -25,11 +25,16 @@ class Server extends AbstractServer
|
||||
protected function getMiddleware(Application $app)
|
||||
{
|
||||
$pipe = new MiddlewarePipe;
|
||||
$pipe->raiseThrowables();
|
||||
|
||||
if ($app->isInstalled()) {
|
||||
$path = parse_url($app->url('admin'), PHP_URL_PATH);
|
||||
$errorDir = __DIR__.'/../../error';
|
||||
|
||||
// All requests should first be piped through our global error handler
|
||||
$debugMode = ! $app->isUpToDate() || $app->inDebugMode();
|
||||
$pipe->pipe($path, new HandleErrors($errorDir, $app->make('log'), $debugMode));
|
||||
|
||||
if ($app->isUpToDate()) {
|
||||
$pipe->pipe($path, $app->make('Flarum\Http\Middleware\ParseJsonBody'));
|
||||
$pipe->pipe($path, $app->make('Flarum\Http\Middleware\StartSession'));
|
||||
@@ -41,12 +46,10 @@ class Server extends AbstractServer
|
||||
event(new ConfigureMiddleware($pipe, $path, $this));
|
||||
|
||||
$pipe->pipe($path, $app->make('Flarum\Http\Middleware\DispatchRoute', ['routes' => $app->make('flarum.admin.routes')]));
|
||||
$pipe->pipe($path, new HandleErrors($errorDir, $app->make('log'), $app->inDebugMode()));
|
||||
} else {
|
||||
$app->register('Flarum\Update\UpdateServiceProvider');
|
||||
|
||||
$pipe->pipe($path, $app->make('Flarum\Http\Middleware\DispatchRoute', ['routes' => $app->make('flarum.update.routes')]));
|
||||
$pipe->pipe($path, new HandleErrors($errorDir, $app->make('log'), true));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
@@ -12,30 +13,29 @@ namespace Flarum\Api;
|
||||
|
||||
use Exception;
|
||||
use Flarum\Core\User;
|
||||
use Flarum\Foundation\Application;
|
||||
use Flarum\Http\Controller\ControllerInterface;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use InvalidArgumentException;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
|
||||
class Client
|
||||
{
|
||||
/**
|
||||
* @var Container
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @var ErrorHandler
|
||||
*/
|
||||
protected $errorHandler;
|
||||
/**
|
||||
* @var Application
|
||||
*/
|
||||
private $app;
|
||||
|
||||
/**
|
||||
* @param Container $container
|
||||
* @param Application $app
|
||||
* @param ErrorHandler $errorHandler
|
||||
*/
|
||||
public function __construct(Container $container, ErrorHandler $errorHandler)
|
||||
public function __construct(Application $app, ErrorHandler $errorHandler)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->app = $app;
|
||||
$this->errorHandler = $errorHandler;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class Client
|
||||
* @param array $queryParams
|
||||
* @param array $body
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function send($controller, $actor, array $queryParams = [], array $body = [])
|
||||
{
|
||||
@@ -55,7 +56,7 @@ class Client
|
||||
$request = $request->withAttribute('actor', $actor);
|
||||
|
||||
if (is_string($controller)) {
|
||||
$controller = $this->container->make($controller);
|
||||
$controller = $this->app->make($controller);
|
||||
}
|
||||
|
||||
if (! ($controller instanceof ControllerInterface)) {
|
||||
@@ -67,6 +68,10 @@ class Client
|
||||
try {
|
||||
return $controller->handle($request);
|
||||
} catch (Exception $e) {
|
||||
if ($this->app->inDebugMode()) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $this->errorHandler->handle($e);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
@@ -185,7 +186,7 @@ abstract class AbstractSerializeController implements ControllerInterface
|
||||
*/
|
||||
protected function extractFilter(ServerRequestInterface $request)
|
||||
{
|
||||
return $this->buildParameters($request)->getFilter();
|
||||
return $this->buildParameters($request)->getFilter() ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
@@ -11,6 +12,7 @@
|
||||
namespace Flarum\Api\Controller;
|
||||
|
||||
use Flarum\Api\UrlGenerator;
|
||||
use Flarum\Core\Exception\PermissionDeniedException;
|
||||
use Flarum\Core\Search\SearchCriteria;
|
||||
use Flarum\Core\Search\User\UserSearcher;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
@@ -33,7 +35,7 @@ class ListUsersController extends AbstractCollectionController
|
||||
*/
|
||||
public $sortFields = [
|
||||
'username',
|
||||
'postsCount',
|
||||
'commentsCount',
|
||||
'discussionsCount',
|
||||
'lastSeenTime',
|
||||
'joinTime'
|
||||
@@ -65,6 +67,11 @@ class ListUsersController extends AbstractCollectionController
|
||||
protected function data(ServerRequestInterface $request, Document $document)
|
||||
{
|
||||
$actor = $request->getAttribute('actor');
|
||||
|
||||
if ($actor->cannot('viewUserList')) {
|
||||
throw new PermissionDeniedException;
|
||||
}
|
||||
|
||||
$query = array_get($this->extractFilter($request), 'q');
|
||||
$sort = $this->extractSort($request);
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user