mirror of
https://github.com/flarum/framework.git
synced 2025-04-01 21:55:16 +08:00
Upgrade to L5 + huge refactor + more. closes #2
New stuff: - Signup + email confirmation. - Updated authentication strategy with remember cookies. closes #5 - New search system with some example gambits! This is cool - check out the source. Fulltext drivers will be implemented as decorators overriding the EloquentPostRepository’s findByContent method. - Lay down the foundation for bootstrapping the Ember app. - Update Web layer’s asset manager to properly publish CSS/JS files. - Console commands to run installation migrations and seeds. Refactoring: - New structure: move models, repositories, commands, and events into their own namespaces, rather than grouping by entity. - All events are classes. - Use L5 middleware and command bus implementations. - Clearer use of repositories and the Active Record pattern. Repositories are used only for retrieval of ActiveRecord objects, and then save/delete operations are called directly on those ActiveRecords. This way, we don’t over-abstract at the cost of Eloquent magic, but testing is still easy. - Refactor of Web layer so that it uses the Actions routing architecture. - “Actor” concept instead of depending on Laravel’s Auth. - General cleanup!
This commit is contained in:
parent
330bff0ec8
commit
2733b5810d
@ -1,35 +1,32 @@
|
||||
{
|
||||
"name": "flarum/core",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Toby Zerner",
|
||||
"email": "toby@flarum.org"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/support": "4.2.*",
|
||||
"laracasts/commander": "1.1.*",
|
||||
"tobscure/json-api": "dev-master",
|
||||
"tobscure/permissible": "dev-master",
|
||||
"misd/linkify": "1.1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "1.4.0",
|
||||
"codeception/codeception": "~2.0.0",
|
||||
"codeception/mockery-module": "*",
|
||||
"laracasts/testdummy": "~2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/migrations"
|
||||
],
|
||||
"psr-4": {
|
||||
"Flarum\\Core\\": "src/Flarum/Core",
|
||||
"Flarum\\Api\\": "src/Flarum/Api",
|
||||
"Flarum\\Web\\": "src/Flarum/Web"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
{
|
||||
"name": "flarum/core",
|
||||
"description": "",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Toby Zerner",
|
||||
"email": "toby@flarum.org"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"illuminate/support": "5.0.*",
|
||||
"tobscure/json-api": "dev-master",
|
||||
"tobscure/permissible": "dev-master",
|
||||
"misd/linkify": "1.1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "1.4.0",
|
||||
"codeception/codeception": "~2.0.0",
|
||||
"codeception/mockery-module": "*",
|
||||
"laracasts/testdummy": "~2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"seeds"
|
||||
],
|
||||
"psr-4": {
|
||||
"Flarum\\": "src/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
|
429
framework/core/composer.lock
generated
429
framework/core/composer.lock
generated
@ -4,35 +4,158 @@
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "f965b67cdaace68ab3e159d2c058c449",
|
||||
"hash": "eacf297f994d4976c0c3a9d9ded71bf6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "danielstjules/stringy",
|
||||
"version": "1.9.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/danielstjules/Stringy.git",
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/danielstjules/Stringy/zipball/3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"reference": "3cf18e9e424a6dedc38b7eb7ef580edb0929461b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Stringy\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/Create.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Daniel St. Jules",
|
||||
"email": "danielst.jules@gmail.com",
|
||||
"homepage": "http://www.danielstjules.com"
|
||||
}
|
||||
],
|
||||
"description": "A string manipulation library with multibyte support",
|
||||
"homepage": "https://github.com/danielstjules/Stringy",
|
||||
"keywords": [
|
||||
"UTF",
|
||||
"helpers",
|
||||
"manipulation",
|
||||
"methods",
|
||||
"multibyte",
|
||||
"string",
|
||||
"utf-8",
|
||||
"utility",
|
||||
"utils"
|
||||
],
|
||||
"time": "2015-02-10 06:19:18"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/inflector.git",
|
||||
"reference": "e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/inflector/zipball/e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d",
|
||||
"reference": "e5eaf8c7ded0877195b5d2848491e17b1c0a6c4d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Doctrine\\Common\\Inflector\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Common String Manipulations with regard to casing and singular/plural rules.",
|
||||
"homepage": "http://www.doctrine-project.org",
|
||||
"keywords": [
|
||||
"inflection",
|
||||
"pluralize",
|
||||
"singularize",
|
||||
"string"
|
||||
],
|
||||
"time": "2015-01-01 18:34:57"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/container",
|
||||
"version": "4.2.x-dev",
|
||||
"target-dir": "Illuminate/Container",
|
||||
"version": "5.0.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/container.git",
|
||||
"reference": "8db091c1b4e503ef8dcd4586d5c63e3997bc4e89"
|
||||
"reference": "7ffdad0a2b2c600445deb57f5f7e93092e44ca2a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/container/zipball/8db091c1b4e503ef8dcd4586d5c63e3997bc4e89",
|
||||
"reference": "8db091c1b4e503ef8dcd4586d5c63e3997bc4e89",
|
||||
"url": "https://api.github.com/repos/illuminate/container/zipball/7ffdad0a2b2c600445deb57f5f7e93092e44ca2a",
|
||||
"reference": "7ffdad0a2b2c600445deb57f5f7e93092e44ca2a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Illuminate\\Container": ""
|
||||
"psr-4": {
|
||||
"Illuminate\\Container\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -45,45 +168,86 @@
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"time": "2014-12-17 20:39:51"
|
||||
"description": "The Illuminate Container package.",
|
||||
"time": "2015-02-11 16:00:31"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/contracts",
|
||||
"version": "5.0.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/contracts.git",
|
||||
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/contracts/zipball/78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||
"reference": "78f1dba092d5fcb6d3a19537662abe31c4d128fd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Contracts\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Contracts package.",
|
||||
"time": "2015-01-30 16:27:08"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/database",
|
||||
"version": "4.2.x-dev",
|
||||
"target-dir": "Illuminate/Database",
|
||||
"version": "5.0.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/database.git",
|
||||
"reference": "eabb5ad0db896339f821ef088ca2fd0d6972e137"
|
||||
"reference": "0c86cd20e7b0fb0bd0979bbddc7946239c58ad66"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/database/zipball/eabb5ad0db896339f821ef088ca2fd0d6972e137",
|
||||
"reference": "eabb5ad0db896339f821ef088ca2fd0d6972e137",
|
||||
"url": "https://api.github.com/repos/illuminate/database/zipball/0c86cd20e7b0fb0bd0979bbddc7946239c58ad66",
|
||||
"reference": "0c86cd20e7b0fb0bd0979bbddc7946239c58ad66",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/container": "4.2.*",
|
||||
"illuminate/events": "4.2.*",
|
||||
"illuminate/support": "4.2.*",
|
||||
"illuminate/container": "5.0.*",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"illuminate/support": "5.0.*",
|
||||
"nesbot/carbon": "~1.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/cache": "4.2.*",
|
||||
"illuminate/console": "4.2.*",
|
||||
"illuminate/filesystem": "4.2.*",
|
||||
"illuminate/pagination": "4.2.*"
|
||||
"suggest": {
|
||||
"doctrine/dbal": "Required to rename columns and drop SQLite columns (~2.4).",
|
||||
"illuminate/console": "Required to use the database commands (5.0.*).",
|
||||
"illuminate/events": "Required to use the observers with Eloquent (5.0.*).",
|
||||
"illuminate/filesystem": "Required to use the migrations (5.0.*)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Illuminate\\Database": ""
|
||||
"psr-4": {
|
||||
"Illuminate\\Database\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -96,91 +260,51 @@
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Database package.",
|
||||
"keywords": [
|
||||
"database",
|
||||
"laravel",
|
||||
"orm",
|
||||
"sql"
|
||||
],
|
||||
"time": "2015-01-27 20:51:43"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/events",
|
||||
"version": "4.2.x-dev",
|
||||
"target-dir": "Illuminate/Events",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/events.git",
|
||||
"reference": "a8471d3f6c3e87c50e25e18f13908fffaef159df"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/events/zipball/a8471d3f6c3e87c50e25e18f13908fffaef159df",
|
||||
"reference": "a8471d3f6c3e87c50e25e18f13908fffaef159df",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/container": "4.2.*",
|
||||
"illuminate/support": "4.2.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Illuminate\\Events": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"time": "2014-10-02 19:49:50"
|
||||
"time": "2015-02-18 02:07:31"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/support",
|
||||
"version": "4.2.x-dev",
|
||||
"target-dir": "Illuminate/Support",
|
||||
"version": "5.0.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/support.git",
|
||||
"reference": "db61f3f6d507ce417ca993e1f93585db7efd8b12"
|
||||
"reference": "405a2241fefa49cfc39b7fba8cc54f69fce2f101"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/db61f3f6d507ce417ca993e1f93585db7efd8b12",
|
||||
"reference": "db61f3f6d507ce417ca993e1f93585db7efd8b12",
|
||||
"url": "https://api.github.com/repos/illuminate/support/zipball/405a2241fefa49cfc39b7fba8cc54f69fce2f101",
|
||||
"reference": "405a2241fefa49cfc39b7fba8cc54f69fce2f101",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"danielstjules/stringy": "~1.8",
|
||||
"doctrine/inflector": "~1.0",
|
||||
"ext-mbstring": "*",
|
||||
"illuminate/contracts": "5.0.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"jeremeamia/superclosure": "~1.0.1",
|
||||
"patchwork/utf8": "~1.1"
|
||||
"suggest": {
|
||||
"jeremeamia/superclosure": "Required to be able to serialize closures (~2.0)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
"dev-master": "5.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Illuminate\\Support": ""
|
||||
"psr-4": {
|
||||
"Illuminate\\Support\\": ""
|
||||
},
|
||||
"files": [
|
||||
"Illuminate/Support/helpers.php"
|
||||
"helpers.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
@ -193,44 +317,8 @@
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"time": "2015-01-27 20:51:43"
|
||||
},
|
||||
{
|
||||
"name": "laracasts/commander",
|
||||
"version": "1.1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laracasts/Commander.git",
|
||||
"reference": "89b47ceb08e26d6beae35781010522e7110aded3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laracasts/Commander/zipball/89b47ceb08e26d6beae35781010522e7110aded3",
|
||||
"reference": "89b47ceb08e26d6beae35781010522e7110aded3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/support": "~4.0",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Laracasts\\Commander": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jeffrey Way",
|
||||
"email": "jeffrey@laracasts.com"
|
||||
}
|
||||
],
|
||||
"description": "Commands and domain events in Laravel",
|
||||
"time": "2014-07-03 13:05:27"
|
||||
"description": "The Illuminate Support package.",
|
||||
"time": "2015-02-11 11:08:03"
|
||||
},
|
||||
{
|
||||
"name": "misd/linkify",
|
||||
@ -371,16 +459,16 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tobscure/permissible.git",
|
||||
"reference": "223a62784672981a45170d2192c9786971b3abee"
|
||||
"reference": "35d92ad11e66bafc94666cae3224d0ca08f44a6a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/tobscure/permissible/zipball/223a62784672981a45170d2192c9786971b3abee",
|
||||
"reference": "223a62784672981a45170d2192c9786971b3abee",
|
||||
"url": "https://api.github.com/repos/tobscure/permissible/zipball/35d92ad11e66bafc94666cae3224d0ca08f44a6a",
|
||||
"reference": "35d92ad11e66bafc94666cae3224d0ca08f44a6a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/database": "4.2.*",
|
||||
"illuminate/database": "5.0.*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
@ -400,7 +488,7 @@
|
||||
}
|
||||
],
|
||||
"description": "Powerful, flexible, relational permissions using Eloquent.",
|
||||
"time": "2014-07-26 05:00:03"
|
||||
"time": "2015-02-18 23:38:49"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
@ -410,12 +498,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Codeception/Codeception.git",
|
||||
"reference": "1416a5ed429615664ba406a37de141a7cba2982b"
|
||||
"reference": "4e267293bb8070e03fb358f27e74271c2d10acbe"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/1416a5ed429615664ba406a37de141a7cba2982b",
|
||||
"reference": "1416a5ed429615664ba406a37de141a7cba2982b",
|
||||
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/4e267293bb8070e03fb358f27e74271c2d10acbe",
|
||||
"reference": "4e267293bb8070e03fb358f27e74271c2d10acbe",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -482,7 +570,7 @@
|
||||
"functional testing",
|
||||
"unit testing"
|
||||
],
|
||||
"time": "2015-02-07 01:27:55"
|
||||
"time": "2015-02-16 11:49:51"
|
||||
},
|
||||
{
|
||||
"name": "codeception/mockery-module",
|
||||
@ -727,12 +815,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/RingPHP.git",
|
||||
"reference": "0b13b4f0d595c4e886ae8eecdfe27e049ba38375"
|
||||
"reference": "a1da305d1c5c0175abf7bc912cb065e906de9500"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/0b13b4f0d595c4e886ae8eecdfe27e049ba38375",
|
||||
"reference": "0b13b4f0d595c4e886ae8eecdfe27e049ba38375",
|
||||
"url": "https://api.github.com/repos/guzzle/RingPHP/zipball/a1da305d1c5c0175abf7bc912cb065e906de9500",
|
||||
"reference": "a1da305d1c5c0175abf7bc912cb065e906de9500",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -770,7 +858,7 @@
|
||||
}
|
||||
],
|
||||
"description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.",
|
||||
"time": "2015-01-20 22:24:03"
|
||||
"time": "2015-02-08 23:29:08"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/streams",
|
||||
@ -875,12 +963,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/padraic/mockery.git",
|
||||
"reference": "0bf3f7346cb49a24587a1a6292e7f20fcd80af0a"
|
||||
"reference": "a450aa28455781c7a72e50794b0f9d954cf8decb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/padraic/mockery/zipball/0bf3f7346cb49a24587a1a6292e7f20fcd80af0a",
|
||||
"reference": "0bf3f7346cb49a24587a1a6292e7f20fcd80af0a",
|
||||
"url": "https://api.github.com/repos/padraic/mockery/zipball/a450aa28455781c7a72e50794b0f9d954cf8decb",
|
||||
"reference": "a450aa28455781c7a72e50794b0f9d954cf8decb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -889,8 +977,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"hamcrest/hamcrest-php": "~1.1",
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"satooshi/php-coveralls": "~0.7@dev"
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
@ -933,7 +1020,7 @@
|
||||
"test double",
|
||||
"testing"
|
||||
],
|
||||
"time": "2015-02-05 10:30:00"
|
||||
"time": "2015-02-18 18:54:04"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
@ -1185,12 +1272,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a"
|
||||
"reference": "5fbd35c52d9ad2a12683a11a138e5c05b31da95a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2e8580deebb7d1ac92ac878595e6bffe01069c2a",
|
||||
"reference": "2e8580deebb7d1ac92ac878595e6bffe01069c2a",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5fbd35c52d9ad2a12683a11a138e5c05b31da95a",
|
||||
"reference": "5fbd35c52d9ad2a12683a11a138e5c05b31da95a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1249,7 +1336,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2015-01-27 16:06:15"
|
||||
"time": "2015-02-09 06:34:32"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
@ -1728,12 +1815,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/BrowserKit.git",
|
||||
"reference": "432c0593d5367b1bb8aa893cb2272172934ad371"
|
||||
"reference": "7b8c4f5e8839122a931f45978c1330749ef9e83a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/432c0593d5367b1bb8aa893cb2272172934ad371",
|
||||
"reference": "432c0593d5367b1bb8aa893cb2272172934ad371",
|
||||
"url": "https://api.github.com/repos/symfony/BrowserKit/zipball/7b8c4f5e8839122a931f45978c1330749ef9e83a",
|
||||
"reference": "7b8c4f5e8839122a931f45978c1330749ef9e83a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1774,7 +1861,7 @@
|
||||
],
|
||||
"description": "Symfony BrowserKit Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-01-09 06:51:41"
|
||||
"time": "2015-02-11 07:17:51"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
@ -1783,12 +1870,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Console.git",
|
||||
"reference": "e30a2778069b48bd1e560e4a2815d15c9ab2f563"
|
||||
"reference": "289113e60aad754d35b50347f66ecd3a4d96d03c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Console/zipball/e30a2778069b48bd1e560e4a2815d15c9ab2f563",
|
||||
"reference": "e30a2778069b48bd1e560e4a2815d15c9ab2f563",
|
||||
"url": "https://api.github.com/repos/symfony/Console/zipball/289113e60aad754d35b50347f66ecd3a4d96d03c",
|
||||
"reference": "289113e60aad754d35b50347f66ecd3a4d96d03c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1831,7 +1918,7 @@
|
||||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-02-05 07:11:58"
|
||||
"time": "2015-02-12 11:03:31"
|
||||
},
|
||||
{
|
||||
"name": "symfony/css-selector",
|
||||
@ -1840,12 +1927,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/CssSelector.git",
|
||||
"reference": "1f8617c67bef17192d28c0f2dda3a04b632629bb"
|
||||
"reference": "e37b4cd8a5ea27d2bd4775a4980f32d39d5daf31"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/1f8617c67bef17192d28c0f2dda3a04b632629bb",
|
||||
"reference": "1f8617c67bef17192d28c0f2dda3a04b632629bb",
|
||||
"url": "https://api.github.com/repos/symfony/CssSelector/zipball/e37b4cd8a5ea27d2bd4775a4980f32d39d5daf31",
|
||||
"reference": "e37b4cd8a5ea27d2bd4775a4980f32d39d5daf31",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1882,7 +1969,7 @@
|
||||
],
|
||||
"description": "Symfony CssSelector Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-01-09 06:51:41"
|
||||
"time": "2015-02-11 07:17:51"
|
||||
},
|
||||
{
|
||||
"name": "symfony/dom-crawler",
|
||||
@ -1891,12 +1978,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/DomCrawler.git",
|
||||
"reference": "49d1657a690eaa6e8fd4f92d828b89bed05dd55d"
|
||||
"reference": "e1355f67898ca94fe18425c3f2d2d4e905ea894f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/49d1657a690eaa6e8fd4f92d828b89bed05dd55d",
|
||||
"reference": "49d1657a690eaa6e8fd4f92d828b89bed05dd55d",
|
||||
"url": "https://api.github.com/repos/symfony/DomCrawler/zipball/e1355f67898ca94fe18425c3f2d2d4e905ea894f",
|
||||
"reference": "e1355f67898ca94fe18425c3f2d2d4e905ea894f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1935,7 +2022,7 @@
|
||||
],
|
||||
"description": "Symfony DomCrawler Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-02-05 06:58:17"
|
||||
"time": "2015-02-11 07:17:51"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
@ -1944,12 +2031,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/EventDispatcher.git",
|
||||
"reference": "e9298668dce8dd219d1ee2290c7f313954f1f984"
|
||||
"reference": "2dc33aff298b20ad099ac456034aebc5055f02fb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e9298668dce8dd219d1ee2290c7f313954f1f984",
|
||||
"reference": "e9298668dce8dd219d1ee2290c7f313954f1f984",
|
||||
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/2dc33aff298b20ad099ac456034aebc5055f02fb",
|
||||
"reference": "2dc33aff298b20ad099ac456034aebc5055f02fb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1993,7 +2080,7 @@
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-02-05 06:58:17"
|
||||
"time": "2015-02-11 07:17:51"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
@ -2002,12 +2089,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Finder.git",
|
||||
"reference": "0c737de96a94d14a51738d285ad426a102baac0e"
|
||||
"reference": "509d125782f31ebbd0bb3cd9824f1ccc1e5d5a18"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Finder/zipball/0c737de96a94d14a51738d285ad426a102baac0e",
|
||||
"reference": "0c737de96a94d14a51738d285ad426a102baac0e",
|
||||
"url": "https://api.github.com/repos/symfony/Finder/zipball/509d125782f31ebbd0bb3cd9824f1ccc1e5d5a18",
|
||||
"reference": "509d125782f31ebbd0bb3cd9824f1ccc1e5d5a18",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2040,7 +2127,7 @@
|
||||
],
|
||||
"description": "Symfony Finder Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-01-09 06:51:41"
|
||||
"time": "2015-02-11 07:17:51"
|
||||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
@ -2049,12 +2136,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Yaml.git",
|
||||
"reference": "02ba3dc638c5d3f0ab3b47ddb74f98c11dcc0c60"
|
||||
"reference": "43aac3461a5679f486f7c96e4d7e780a59fec997"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/02ba3dc638c5d3f0ab3b47ddb74f98c11dcc0c60",
|
||||
"reference": "02ba3dc638c5d3f0ab3b47ddb74f98c11dcc0c60",
|
||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/43aac3461a5679f486f7c96e4d7e780a59fec997",
|
||||
"reference": "43aac3461a5679f486f7c96e4d7e780a59fec997",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2087,7 +2174,7 @@
|
||||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2015-01-25 04:39:35"
|
||||
"time": "2015-02-11 07:17:51"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
@ -1,9 +1,3 @@
|
||||
{
|
||||
/**
|
||||
Ember CLI sends analytics information by default. The data is completely
|
||||
anonymous, but there are times when you might want to disable this behavior.
|
||||
|
||||
Setting `disableAnalytics` to true will prevent any data from being sent.
|
||||
*/
|
||||
"disableAnalytics": false
|
||||
"output-path": "../public"
|
||||
}
|
||||
|
@ -3,35 +3,26 @@ import config from '../config/environment';
|
||||
|
||||
export default Base.extend({
|
||||
|
||||
restore: function(data) {
|
||||
var container = this.container;
|
||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||
Ember.run.next(function() {
|
||||
container.lookup('store:main').find('user', data.userId).then(function(user) {
|
||||
resolve( { token: data.token, userId: data.userId, user: user } );
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
authenticate: function(credentials) {
|
||||
var container = this.container;
|
||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||
Ember.$.ajax({
|
||||
url: config.apiURL+'/auth/login',
|
||||
url: config.baseURL+'login',
|
||||
type: 'POST',
|
||||
data: { identification: credentials.identification, password: credentials.password }
|
||||
}).then(function(response) {
|
||||
container.lookup('store:main').find('user', response.userId).then(function(user) {
|
||||
resolve({ token: response.token, userId: response.userId, user: user });
|
||||
});
|
||||
container.lookup('store:main').find('user', response.userId).then(function(user) {
|
||||
resolve({ token: response.token, userId: response.userId, user: user });
|
||||
});
|
||||
}, function(xhr, status, error) {
|
||||
reject(xhr.responseJSON.errors);
|
||||
reject(xhr.responseJSON.errors);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// invalidate: function(data) {
|
||||
// return new Ember.RSVP.Promise();
|
||||
// }
|
||||
});
|
||||
invalidate: function(data) {
|
||||
return new Ember.RSVP.Promise(function() {
|
||||
window.location = config.baseURL+'logout';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,11 +1,10 @@
|
||||
import Base from 'simple-auth/authorizers/base';
|
||||
|
||||
export default Base.extend({
|
||||
|
||||
authorize: function(jqXHR, requestOptions) {
|
||||
var token = this.get('session.token');
|
||||
if (this.get('session.isAuthenticated') && !Ember.isEmpty(token)) {
|
||||
jqXHR.setRequestHeader('Authorization', 'Token ' + token);
|
||||
}
|
||||
}
|
||||
});
|
||||
authorize: function(jqXHR, requestOptions) {
|
||||
var token = this.get('session.token');
|
||||
if (this.get('session.isAuthenticated') && !Ember.isEmpty(token)) {
|
||||
jqXHR.setRequestHeader('Authorization', 'Token ' + token);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,17 +1,17 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
alerts: [],
|
||||
alerts: [],
|
||||
|
||||
actions: {
|
||||
alert: function(message) {
|
||||
this.get('alerts').pushObject(message);
|
||||
},
|
||||
dismissAlert: function(message) {
|
||||
this.get('alerts').removeObject(message);
|
||||
},
|
||||
clearAlerts: function() {
|
||||
this.get('alerts').clear();
|
||||
}
|
||||
}
|
||||
actions: {
|
||||
alert: function(message) {
|
||||
this.get('alerts').pushObject(message);
|
||||
},
|
||||
dismissAlert: function(message) {
|
||||
this.get('alerts').removeObject(message);
|
||||
},
|
||||
clearAlerts: function() {
|
||||
this.get('alerts').clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -54,6 +54,8 @@ export default Ember.Controller.extend({
|
||||
}
|
||||
}
|
||||
|
||||
// var results = Ember.RSVP.resolve(FLARUM_DATA.discussions);
|
||||
|
||||
return this.store.find('discussion', params).then(function(discussions) {
|
||||
var results = Ember.A();
|
||||
discussions.forEach(function(discussion) {
|
||||
|
@ -4,31 +4,31 @@ import AuthenticationControllerMixin from 'simple-auth/mixins/authentication-con
|
||||
import ModalController from 'flarum/mixins/modal-controller';
|
||||
|
||||
export default Ember.Controller.extend(ModalController, AuthenticationControllerMixin, {
|
||||
authenticator: 'authenticator:flarum',
|
||||
loading: false,
|
||||
authenticator: 'authenticator:flarum',
|
||||
loading: false,
|
||||
|
||||
actions: {
|
||||
authenticate: function() {
|
||||
actions: {
|
||||
authenticate: function() {
|
||||
var data = this.getProperties('identification', 'password');
|
||||
var controller = this;
|
||||
this.set('error', null);
|
||||
this.set('loading', true);
|
||||
return this._super(data).then(function() {
|
||||
controller.send("sessionChanged");
|
||||
controller.send("closeModal");
|
||||
controller.send("sessionChanged");
|
||||
controller.send("closeModal");
|
||||
}, function(errors) {
|
||||
switch(errors[0].code) {
|
||||
case 'invalidLogin':
|
||||
controller.set('error', 'Your login details are incorrect.');
|
||||
break;
|
||||
switch(errors[0].code) {
|
||||
case 'invalidLogin':
|
||||
controller.set('error', 'Your login details are incorrect.');
|
||||
break;
|
||||
|
||||
default:
|
||||
controller.set('error', 'Something went wrong. (Error code: '+errors[0].code+')');
|
||||
}
|
||||
controller.trigger('refocus');
|
||||
default:
|
||||
controller.set('error', 'Something went wrong. (Error code: '+errors[0].code+')');
|
||||
}
|
||||
controller.trigger('refocus');
|
||||
}).finally(function() {
|
||||
controller.set('loading', false);
|
||||
controller.set('loading', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -3,6 +3,19 @@ import Ember from 'ember';
|
||||
import ModalController from 'flarum/mixins/modal-controller';
|
||||
|
||||
export default Ember.Controller.extend(ModalController, {
|
||||
emailProviderName: Ember.computed('welcomeUser.email', function() {
|
||||
if (!this.get('welcomeUser.email')) { return; }
|
||||
return this.get('welcomeUser.email').split('@')[1];
|
||||
}),
|
||||
|
||||
emailProviderUrl: Ember.computed('emailProviderName', function() {
|
||||
return 'http://'+this.get('emailProviderName');
|
||||
}),
|
||||
|
||||
welcomeStyle: Ember.computed('welcomeUser.color', function() {
|
||||
return 'background:'+this.get('welcomeUser.color');
|
||||
}),
|
||||
|
||||
actions: {
|
||||
submit: function() {
|
||||
var data = this.getProperties('username', 'email', 'password');
|
||||
@ -12,15 +25,9 @@ export default Ember.Controller.extend(ModalController, {
|
||||
|
||||
var user = this.store.createRecord('user', data);
|
||||
|
||||
return user.save().then(function() {
|
||||
controller.get('session').authenticate('authenticator:flarum', {
|
||||
identification: data.email,
|
||||
password: data.password
|
||||
}).then(function() {
|
||||
controller.send('closeModal');
|
||||
controller.send('sessionChanged');
|
||||
controller.set('loading', false);
|
||||
});
|
||||
return user.save().then(function(user) {
|
||||
controller.set('welcomeUser', user);
|
||||
controller.set('loading', false);
|
||||
}, function(reason) {
|
||||
controller.set('loading', false);
|
||||
});
|
||||
|
@ -1,9 +1,11 @@
|
||||
import FlarumAuthorizer from 'flarum/authorizers/flarum';
|
||||
import Config from 'flarum/config/environment';
|
||||
|
||||
export default {
|
||||
name: 'authentication',
|
||||
before: 'simple-auth',
|
||||
initialize: function(container) {
|
||||
container.register('authorizer:flarum', FlarumAuthorizer);
|
||||
Config['simple-auth'] = {authorizer: 'authorizer:flarum'};
|
||||
}
|
||||
};
|
||||
|
20
framework/core/ember/app/initializers/preload-data.js
Normal file
20
framework/core/ember/app/initializers/preload-data.js
Normal file
@ -0,0 +1,20 @@
|
||||
import Ember from 'ember';
|
||||
|
||||
export default {
|
||||
name: 'preload-data',
|
||||
after: 'store',
|
||||
initialize: function(container) {
|
||||
var store = container.lookup('store:main');
|
||||
if (!Ember.isEmpty(FLARUM_DATA)) {
|
||||
store.pushPayload(FLARUM_DATA);
|
||||
}
|
||||
if (!Ember.isEmpty(FLARUM_SESSION)) {
|
||||
FLARUM_SESSION.user = store.getById('user', FLARUM_SESSION.userId);
|
||||
container.lookup('simple-auth-session:main').setProperties({
|
||||
isAuthenticated: true,
|
||||
authenticator: 'authenticator:flarum',
|
||||
content: FLARUM_SESSION
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
@ -1,7 +1,15 @@
|
||||
import Ember from 'ember';
|
||||
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
|
||||
|
||||
import AlertMessage from 'flarum/components/ui/alert-message';
|
||||
|
||||
export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||
activate: function() {
|
||||
if (!Ember.isEmpty(FLARUM_ALERT)) {
|
||||
this.controllerFor('alerts').send('alert', AlertMessage.create(FLARUM_ALERT));
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
login: function() {
|
||||
this.controllerFor('login').set('error', null);
|
||||
@ -9,7 +17,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||
},
|
||||
|
||||
signup: function() {
|
||||
this.controllerFor('signup').set('error', null);
|
||||
this.controllerFor('signup').set('error', null).set('welcomeUser', null);
|
||||
this.send('showModal', 'signup');
|
||||
},
|
||||
|
||||
@ -33,7 +41,7 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
|
||||
},
|
||||
|
||||
sessionChanged: function() {
|
||||
this.refresh();
|
||||
this.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
// This files is where our LESS journey begins.
|
||||
|
||||
// We begin by importing our own configuration variables, which are used all
|
||||
// throughout the stylesheets. These pertain to
|
||||
// throughout the stylesheets. These pertain to
|
||||
// @import "config-default.less";
|
||||
@import "config.less";
|
||||
|
||||
@ -25,4 +25,5 @@
|
||||
|
||||
@import "@{flarum-base}index.less";
|
||||
@import "@{flarum-base}discussion.less";
|
||||
@import "@{flarum-base}login.less";
|
||||
@import "@{flarum-base}login.less";
|
||||
@import "@{flarum-base}signup.less";
|
||||
|
23
framework/core/ember/app/styles/flarum/signup.less
Normal file
23
framework/core/ember/app/styles/flarum/signup.less
Normal file
@ -0,0 +1,23 @@
|
||||
.signup-welcome {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
border-radius: @border-radius-base - 1px;
|
||||
padding: 60px;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
|
||||
& .avatar {
|
||||
.avatar-size(64px);
|
||||
.box-shadow(0 0 0 4px #fff);
|
||||
}
|
||||
& h3, & p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
& .btn-default {
|
||||
background: fade(#000, 10%);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
@ -26,3 +26,15 @@
|
||||
</form>
|
||||
</div>
|
||||
{{ui/loading-indicator classNameBindings=":modal-loading loading:active"}}
|
||||
|
||||
{{#if welcomeUser}}
|
||||
<div {{bind-attr class=":signup-welcome :fade" style=welcomeStyle}}>
|
||||
{{user-avatar welcomeUser}}
|
||||
<h3>Welcome, {{welcomeUser.username}}!</h3>
|
||||
|
||||
{{#unless welcomeUser.isConfirmed}}
|
||||
<p>We've sent a confirmation email to <strong>{{welcomeUser.email}}</strong>. If it doesn't arrive soon, check your spam folder.</p>
|
||||
<p><a {{bind-attr href=emailProviderUrl}} class="btn btn-default">Go to {{emailProviderName}}</a></p>
|
||||
{{/unless}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
@ -7,5 +7,13 @@ export default Ember.View.extend(ModalView, {
|
||||
templateName: 'signup',
|
||||
|
||||
didInsertElement: function() {
|
||||
}
|
||||
},
|
||||
|
||||
welcomeUserDidChange: Ember.observer('welcomeUser', function() {
|
||||
if (this.get('welcomeUser')) {
|
||||
Ember.run.scheduleOnce('afterRender', this, function() {
|
||||
this.$('.signup-welcome').addClass('in');
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -3,7 +3,7 @@
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateSessionsTable extends Migration {
|
||||
class CreateAccessTokensTable extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
@ -12,11 +12,10 @@ class CreateSessionsTable extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sessions', function(Blueprint $table)
|
||||
Schema::create('access_tokens', function(Blueprint $table)
|
||||
{
|
||||
$table->string('id')->unique();
|
||||
$table->binary('payload');
|
||||
$table->integer('last_activity');
|
||||
$table->string('id');
|
||||
$table->integer('user_id')->unsigned();
|
||||
});
|
||||
}
|
||||
|
||||
@ -27,7 +26,7 @@ class CreateSessionsTable extends Migration {
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::drop('sessions');
|
||||
Schema::drop('access_tokens');
|
||||
}
|
||||
|
||||
}
|
@ -19,8 +19,8 @@ class CreateUsersTable extends Migration {
|
||||
$table->string('email');
|
||||
$table->boolean('is_confirmed')->default(0);
|
||||
$table->string('confirmation_token')->nullable();
|
||||
$table->boolean('is_activated')->default(0);
|
||||
$table->string('password');
|
||||
$table->string('token');
|
||||
$table->dateTime('join_time')->nullable();
|
||||
$table->dateTime('last_seen_time')->nullable();
|
||||
$table->dateTime('read_time')->nullable();
|
89
framework/core/src/Api/Actions/ApiParams.php
Normal file
89
framework/core/src/Api/Actions/ApiParams.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php namespace Flarum\Api\Actions;
|
||||
|
||||
class ApiParams
|
||||
{
|
||||
protected $params;
|
||||
|
||||
public function __construct(array $params)
|
||||
{
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
return array_get($this->params, $key, $default);
|
||||
}
|
||||
|
||||
public function range($key, $default = null, $min = null, $max = null)
|
||||
{
|
||||
$value = (int) $this->get($key, $default);
|
||||
|
||||
if (! is_null($min)) {
|
||||
$value = max($value, $min);
|
||||
}
|
||||
if (! is_null($max)) {
|
||||
$value = min($value, $max);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function included($available)
|
||||
{
|
||||
$requested = explode(',', $this->get('include'));
|
||||
return array_intersect((array) $available, $requested);
|
||||
}
|
||||
|
||||
// public function explodeIds($ids)
|
||||
// {
|
||||
// return array_unique(array_map('intval', array_filter(explode(',', $ids))));
|
||||
// }
|
||||
|
||||
public function in($key, $options)
|
||||
{
|
||||
$value = $this->get($key);
|
||||
|
||||
if (array_key_exists($key, $options)) {
|
||||
return $options[$key];
|
||||
}
|
||||
if (! in_array($value, $options)) {
|
||||
$value = reset($options);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function sort($options)
|
||||
{
|
||||
$criteria = (string) $this->get('sort', '');
|
||||
$order = null;
|
||||
|
||||
if ($criteria && $criteria[0] == '-') {
|
||||
$order = 'desc';
|
||||
$criteria = substr($criteria, 1);
|
||||
}
|
||||
|
||||
if (! in_array($criteria, $options)) {
|
||||
$criteria = reset($options);
|
||||
}
|
||||
|
||||
if ($criteria && ! $order) {
|
||||
$order = 'asc';
|
||||
}
|
||||
|
||||
return [
|
||||
'field' => $criteria,
|
||||
'order' => $order,
|
||||
'string' => ($order == 'desc' ? '-' : '').$criteria
|
||||
];
|
||||
}
|
||||
|
||||
public function start()
|
||||
{
|
||||
return $this->range('start', 0, 0);
|
||||
}
|
||||
|
||||
public function count($default, $max = 100)
|
||||
{
|
||||
return $this->range('count', $default, 1, $max);
|
||||
}
|
||||
}
|
130
framework/core/src/Api/Actions/BaseAction.php
Normal file
130
framework/core/src/Api/Actions/BaseAction.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php namespace Flarum\Api\Actions;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Tobscure\JsonApi\Document;
|
||||
use Flarum\Core\Support\Actor;
|
||||
use Flarum\Api\Events\CommandWillBeDispatched;
|
||||
use Flarum\Api\Events\WillRespondWithDocument;
|
||||
use Flarum\Web\Actions\Action;
|
||||
use Config;
|
||||
use App;
|
||||
use Response;
|
||||
|
||||
abstract class BaseAction extends Action
|
||||
{
|
||||
abstract protected function run(ApiParams $params);
|
||||
|
||||
public function __construct(Actor $actor, Dispatcher $bus)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->bus = $bus;
|
||||
}
|
||||
|
||||
public function handle(Request $request, $routeParams = [])
|
||||
{
|
||||
$this->registerErrorHandlers(); // @todo convert to middleware and add to route group?
|
||||
|
||||
$params = array_merge($request->all(), $routeParams);
|
||||
|
||||
return $this->call($params);
|
||||
}
|
||||
|
||||
public function call($params = [])
|
||||
{
|
||||
$params = new ApiParams($params);
|
||||
|
||||
return $this->run($params);
|
||||
}
|
||||
|
||||
public function hydrate($object, $params)
|
||||
{
|
||||
foreach ($params as $k => $v) {
|
||||
$object->$k = $v;
|
||||
}
|
||||
}
|
||||
|
||||
protected function dispatch($command, $params)
|
||||
{
|
||||
$this->event(new CommandWillBeDispatched($command, $params));
|
||||
return $this->bus->dispatch($command);
|
||||
}
|
||||
|
||||
protected function event($event)
|
||||
{
|
||||
event($event);
|
||||
}
|
||||
|
||||
public function document()
|
||||
{
|
||||
return new Document;
|
||||
}
|
||||
|
||||
protected function buildUrl($route, $params = [], $input = [])
|
||||
{
|
||||
$url = route('flarum.api.'.$route, $params);
|
||||
$queryString = $input ? '?'.http_build_query($input) : '';
|
||||
|
||||
return $url.$queryString;
|
||||
}
|
||||
|
||||
protected function respondWithoutContent($statusCode = 204, $headers = [])
|
||||
{
|
||||
return Response::make('', $statusCode, $headers);
|
||||
}
|
||||
|
||||
protected function respondWithArray($array, $statusCode = 200, $headers = [])
|
||||
{
|
||||
return Response::json($array, $statusCode, $headers);
|
||||
}
|
||||
|
||||
protected function respondWithDocument($document, $statusCode = 200, $headers = [])
|
||||
{
|
||||
$headers['Content-Type'] = 'application/vnd.api+json';
|
||||
|
||||
$this->event(new WillRespondWithDocument($document, $statusCode, $headers));
|
||||
|
||||
return $this->respondWithArray($document->toArray(), $statusCode, $headers);
|
||||
}
|
||||
|
||||
protected function registerErrorHandlers()
|
||||
{
|
||||
// if (! Config::get('app.debug')) {
|
||||
// App::error(function ($exception, $code) {
|
||||
// return $this->respondWithError('ApplicationError', $code);
|
||||
// });
|
||||
// }
|
||||
|
||||
// App::error(function (ModelNotFoundException $exception) {
|
||||
// return $this->respondWithError('ResourceNotFound', 404);
|
||||
// });
|
||||
|
||||
// App::error(function (ValidationFailureException $exception) {
|
||||
// $errors = [];
|
||||
// foreach ($exception->getErrors()->getMessages() as $field => $messages) {
|
||||
// $errors[] = [
|
||||
// 'code' => 'ValidationFailure',
|
||||
// 'detail' => implode("\n", $messages),
|
||||
// 'path' => $field
|
||||
// ];
|
||||
// }
|
||||
// return $this->respondWithErrors($errors, 422);
|
||||
// });
|
||||
}
|
||||
|
||||
protected function respondWithErrors($errors, $httpCode = 500)
|
||||
{
|
||||
return Response::json(['errors' => $errors], $httpCode);
|
||||
}
|
||||
|
||||
protected function respondWithError($error, $httpCode = 500, $detail = null)
|
||||
{
|
||||
$error = ['code' => $error];
|
||||
|
||||
if ($detail) {
|
||||
$error['detail'] = $detail;
|
||||
}
|
||||
|
||||
return $this->respondWithErrors([$error], $httpCode);
|
||||
}
|
||||
}
|
@ -1,45 +1,41 @@
|
||||
<?php namespace Flarum\Api\Actions\Discussions;
|
||||
|
||||
use Event;
|
||||
|
||||
use Flarum\Core\Discussions\Commands\StartDiscussionCommand;
|
||||
use Flarum\Core\Discussions\Commands\ReadDiscussionCommand;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Core\Commands\StartDiscussionCommand;
|
||||
use Flarum\Core\Commands\ReadDiscussionCommand;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||
|
||||
class Create extends Base
|
||||
class CreateAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Start a new discussion.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run()
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
// By default, the only required attributes of a discussion are the
|
||||
// title and the content. We'll extract these from the request data
|
||||
// title and the content. We'll extract these from the rbaseequest data
|
||||
// and pass them through to the StartDiscussionCommand.
|
||||
$title = $this->input('discussions.title');
|
||||
$content = $this->input('discussions.content');
|
||||
$user = User::current();
|
||||
$command = new StartDiscussionCommand($title, $content, $user);
|
||||
$title = $params->get('discussions.title');
|
||||
$content = $params->get('discussions.content');
|
||||
$user = $this->actor->getUser();
|
||||
|
||||
Event::fire('Flarum.Api.Actions.Discussions.Create.WillExecuteCommand', [$command, $this->document]);
|
||||
|
||||
$discussion = $this->commandBus->execute($command);
|
||||
$command = new StartDiscussionCommand($title, $content, $user, app('flarum.forum'));
|
||||
$discussion = $this->dispatch($command, $params);
|
||||
|
||||
// After creating the discussion, we assume that the user has seen all
|
||||
// of the posts in the discussion; thus, we will mark the discussion
|
||||
// as read if they are logged in.
|
||||
if ($user->exists) {
|
||||
$command = new ReadDiscussionCommand($discussion->id, $user, 1);
|
||||
$this->commandBus->execute($command);
|
||||
$this->dispatch($command, $params);
|
||||
}
|
||||
|
||||
$serializer = new DiscussionSerializer(['posts']);
|
||||
$this->document->setPrimaryElement($serializer->resource($discussion));
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
|
||||
|
||||
return $this->respondWithDocument();
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
23
framework/core/src/Api/Actions/Discussions/DeleteAction.php
Normal file
23
framework/core/src/Api/Actions/Discussions/DeleteAction.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace Flarum\Api\Actions\Discussions;
|
||||
|
||||
use Flarum\Core\Commands\DeleteDiscussionCommand;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
|
||||
class DeleteAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Delete a discussion.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$discussionId = $params->get('id');
|
||||
|
||||
$command = new DeleteDiscussionCommand($discussionId, $this->actor->getUser());
|
||||
$this->dispatch($command, $params);
|
||||
|
||||
return $this->respondWithoutContent();
|
||||
}
|
||||
}
|
81
framework/core/src/Api/Actions/Discussions/IndexAction.php
Normal file
81
framework/core/src/Api/Actions/Discussions/IndexAction.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php namespace Flarum\Api\Actions\Discussions;
|
||||
|
||||
use Flarum\Core\Search\Discussions\DiscussionSearchCriteria;
|
||||
use Flarum\Core\Search\Discussions\DiscussionSearcher;
|
||||
use Flarum\Core\Support\Actor;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||
|
||||
class IndexAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* The discussion searcher.
|
||||
*
|
||||
* @var DiscussionSearcher
|
||||
*/
|
||||
protected $searcher;
|
||||
|
||||
/**
|
||||
* Instantiate the action.
|
||||
*
|
||||
* @param DiscussionSearcher $searcher
|
||||
*/
|
||||
public function __construct(Actor $actor, DiscussionSearcher $searcher)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->searcher = $searcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of discussions.
|
||||
*
|
||||
* @todo custom rate limit for this function? determined by if $key was valid?
|
||||
* @return Response
|
||||
*/
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$query = $params->get('q');
|
||||
$start = $params->start();
|
||||
$include = $params->included(['startPost', 'lastPost', 'relevantPosts']);
|
||||
$count = $params->count(20, 50);
|
||||
$sort = $params->sort(['', 'lastPost', 'replies', 'created']);
|
||||
|
||||
$relations = array_merge(['startUser', 'lastUser'], $include);
|
||||
|
||||
// Set up the discussion finder with our search criteria, and get the
|
||||
// requested range of results with the necessary relations loaded.
|
||||
$criteria = new DiscussionSearchCriteria($this->actor->getUser(), $query, $sort['field'], $sort['order']);
|
||||
$load = array_merge($relations, ['state']);
|
||||
|
||||
$results = $this->searcher->search($criteria, $count, $start, $load);
|
||||
|
||||
$document = $this->document();
|
||||
|
||||
if (($total = $results->getTotal()) !== null) {
|
||||
$document->addMeta('total', $total);
|
||||
}
|
||||
|
||||
// If there are more results, then we need to construct a URL to the
|
||||
// next results page and add that to the metadata. We do this by
|
||||
// compacting all of the valid query parameters which have been
|
||||
// specified.
|
||||
if ($results->areMoreResults()) {
|
||||
$start += $count;
|
||||
$include = implode(',', $include);
|
||||
$sort = $sort['string'];
|
||||
$input = array_filter(compact('query', 'sort', 'start', 'count', 'include'));
|
||||
$moreUrl = $this->buildUrl('discussions.index', [], $input);
|
||||
} else {
|
||||
$moreUrl = '';
|
||||
}
|
||||
$document->addMeta('moreUrl', $moreUrl);
|
||||
|
||||
// Finally, we can set up the discussion serializer and use it to create
|
||||
// a collection of discussion results.
|
||||
$serializer = new DiscussionSerializer($relations);
|
||||
$document->setPrimaryElement($serializer->collection($results->getDiscussions()));
|
||||
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
@ -1,15 +1,24 @@
|
||||
<?php namespace Flarum\Api\Actions\Discussions;
|
||||
|
||||
use Flarum\Core\Discussions\Discussion;
|
||||
use Flarum\Core\Posts\PostRepository;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Core\Support\Actor;
|
||||
use Flarum\Core\Repositories\DiscussionRepositoryInterface as DiscussionRepository;
|
||||
use Flarum\Core\Repositories\PostRepositoryInterface as PostRepository;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\Posts\GetsPostsForDiscussion;
|
||||
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||
|
||||
class Show extends Base
|
||||
class ShowAction extends BaseAction
|
||||
{
|
||||
use GetsPostsForDiscussion;
|
||||
|
||||
/**
|
||||
* The discussion repository.
|
||||
*
|
||||
* @var DiscussionRepository
|
||||
*/
|
||||
protected $discussions;
|
||||
|
||||
/**
|
||||
* The post repository.
|
||||
*
|
||||
@ -22,8 +31,10 @@ class Show extends Base
|
||||
*
|
||||
* @param PostRepository $posts
|
||||
*/
|
||||
public function __construct(PostRepository $posts)
|
||||
public function __construct(Actor $actor, DiscussionRepository $discussions, PostRepository $posts)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->discussions = $discussions;
|
||||
$this->posts = $posts;
|
||||
}
|
||||
|
||||
@ -32,15 +43,15 @@ class Show extends Base
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run()
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$include = $this->included(['startPost', 'lastPost', 'posts']);
|
||||
$include = $params->included(['startPost', 'lastPost', 'posts']);
|
||||
|
||||
$discussion = Discussion::whereCanView()->findOrFail($this->param('id'));
|
||||
$discussion = $this->discussions->findOrFail($params->get('id'), $this->actor->getUser());
|
||||
|
||||
if (in_array('posts', $include)) {
|
||||
$relations = ['user', 'user.groups', 'editUser', 'hideUser'];
|
||||
$discussion->posts = $this->getPostsForDiscussion($this->posts, $discussion->id, $relations);
|
||||
$discussion->posts = $this->getPostsForDiscussion($params, $discussion->id)->load($relations);
|
||||
|
||||
$include = array_merge($include, array_map(function ($relation) {
|
||||
return 'posts.'.$relation;
|
||||
@ -52,8 +63,8 @@ class Show extends Base
|
||||
// relations, we will specify that we want the 'posts' relation to be
|
||||
// linked so that a list of post IDs will show up in the response.
|
||||
$serializer = new DiscussionSerializer($include, ['posts']);
|
||||
$this->document->setPrimaryElement($serializer->resource($discussion));
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
|
||||
|
||||
return $this->respondWithDocument();
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
54
framework/core/src/Api/Actions/Discussions/UpdateAction.php
Normal file
54
framework/core/src/Api/Actions/Discussions/UpdateAction.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php namespace Flarum\Api\Actions\Discussions;
|
||||
|
||||
use Flarum\Core\Commands\EditDiscussionCommand;
|
||||
use Flarum\Core\Commands\ReadDiscussionCommand;
|
||||
use Flarum\Core\Exceptions\PermissionDeniedException;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Serializers\DiscussionSerializer;
|
||||
|
||||
class UpdateAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Edit a discussion. Allows renaming the discussion, and updating its read
|
||||
* state with regards to the current user.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$discussionId = $params->get('id');
|
||||
$user = $this->actor->getUser();
|
||||
|
||||
// First, we will run the EditDiscussionCommand. This will update the
|
||||
// discussion's direct properties; by default, this is just the title.
|
||||
// As usual, however, we will fire an event to allow plugins to update
|
||||
// additional properties.
|
||||
if ($data = array_except($params->get('discussions'), ['readNumber'])) {
|
||||
$command = new EditDiscussionCommand($discussionId, $user);
|
||||
$this->hydrate($command, $params->get('discussions'));
|
||||
$discussion = $this->dispatch($command, $params);
|
||||
}
|
||||
|
||||
// Next, if a read number was specified in the request, we will run the
|
||||
// ReadDiscussionCommand.
|
||||
//
|
||||
// @todo Currently, if the user doesn't have permission to edit a
|
||||
// discussion, they're unable to update their readNumber because a
|
||||
// PermissionsDeniedException is thrown by the
|
||||
// EditDiscussionCommand above. So this needs to be extracted into
|
||||
// its own endpoint.
|
||||
if ($readNumber = $params->get('discussions.readNumber')) {
|
||||
$command = new ReadDiscussionCommand($discussionId, $user, $readNumber);
|
||||
$this->dispatch($command, $params);
|
||||
}
|
||||
|
||||
// Presumably, the discussion was updated successfully. (One of the command
|
||||
// handlers would have thrown an exception if not.) We set this
|
||||
// discussion as our document's primary element.
|
||||
$serializer = new DiscussionSerializer(['addedPosts', 'addedPosts.user']);
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($discussion));
|
||||
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
@ -1,50 +1,47 @@
|
||||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Event;
|
||||
use Flarum\Core\Posts\Commands\PostReplyCommand;
|
||||
use Flarum\Core\Discussions\Commands\ReadDiscussionCommand;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Core\Commands\PostReplyCommand;
|
||||
use Flarum\Core\Commands\ReadDiscussionCommand;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Serializers\PostSerializer;
|
||||
|
||||
class Create extends Base
|
||||
class CreateAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Reply to a discussion.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run()
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$user = User::current();
|
||||
$user = $this->actor->getUser();
|
||||
|
||||
// We've received a request to post a reply. By default, the only
|
||||
// required attributes of a post is the ID of the discussion to post in,
|
||||
// the post content, and the author's user account. Let's set up a
|
||||
// command with this information. We also fire an event to allow plugins
|
||||
// to add data to the command.
|
||||
$discussionId = $this->input('posts.links.discussion');
|
||||
$content = $this->input('posts.content');
|
||||
$discussionId = $params->get('posts.links.discussion');
|
||||
$content = $params->get('posts.content');
|
||||
|
||||
$command = new PostReplyCommand($discussionId, $content, $user);
|
||||
|
||||
Event::fire('Flarum.Api.Actions.Posts.Create.WillExecuteCommand', [$command]);
|
||||
|
||||
$post = $this->commandBus->execute($command);
|
||||
$post = $this->dispatch($command, $params);
|
||||
|
||||
// After replying, we assume that the user has seen all of the posts
|
||||
// in the discussion; thus, we will mark the discussion as read if
|
||||
// they are logged in.
|
||||
if ($user->exists) {
|
||||
$command = new ReadDiscussionCommand($discussionId, $user, $post->number);
|
||||
$this->commandBus->execute($command);
|
||||
$this->dispatch($command, $params);
|
||||
}
|
||||
|
||||
// Presumably, the post was created successfully. (The command handler
|
||||
// would have thrown an exception if not.) We set this post as our
|
||||
// document's primary element.
|
||||
$serializer = new PostSerializer;
|
||||
$this->document->setPrimaryElement($serializer->resource($post));
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($post));
|
||||
|
||||
return $this->respondWithDocument(201);
|
||||
return $this->respondWithDocument($document, 201);
|
||||
}
|
||||
}
|
23
framework/core/src/Api/Actions/Posts/DeleteAction.php
Normal file
23
framework/core/src/Api/Actions/Posts/DeleteAction.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Flarum\Core\Commands\DeletePostCommand;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
|
||||
class DeleteAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Delete a post.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$postId = $params->get('id');
|
||||
|
||||
$command = new DeletePostCommand($postId, $this->actor->getUser());
|
||||
$this->dispatch($command, $params);
|
||||
|
||||
return $this->respondWithoutContent();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||
use Flarum\Core\Models\User;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
|
||||
trait GetsPostsForDiscussion
|
||||
{
|
||||
protected function getPostsForDiscussion(ApiParams $params, $discussionId)
|
||||
{
|
||||
$sort = $params->sort(['time']);
|
||||
$count = $params->count(20, 50);
|
||||
$user = $this->actor->getUser();
|
||||
|
||||
if (($near = $params->get('near')) > 1) {
|
||||
$start = $this->posts->getIndexForNumber($discussionId, $near, $user);
|
||||
$start = max(0, $start - $count / 2);
|
||||
} else {
|
||||
$start = 0;
|
||||
}
|
||||
|
||||
return $this->posts->findByDiscussion(
|
||||
$discussionId,
|
||||
$user,
|
||||
$sort['field'],
|
||||
$sort['order'] ?: 'asc',
|
||||
$count,
|
||||
$start
|
||||
);
|
||||
}
|
||||
}
|
@ -1,29 +1,31 @@
|
||||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Posts\PostRepository;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||
use Flarum\Core\Support\Actor;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Serializers\PostSerializer;
|
||||
|
||||
class Index extends Base
|
||||
class IndexAction extends BaseAction
|
||||
{
|
||||
use GetsPostsForDiscussion;
|
||||
|
||||
/**
|
||||
* The post repository.
|
||||
*
|
||||
* @var PostRepository
|
||||
* @var Post
|
||||
*/
|
||||
protected $posts;
|
||||
|
||||
/**
|
||||
* Instantiate the action.
|
||||
*
|
||||
* @param PostRepository $posts
|
||||
* @param Post $posts
|
||||
*/
|
||||
public function __construct(PostRepository $posts)
|
||||
public function __construct(Actor $actor, PostRepositoryInterface $posts)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->posts = $posts;
|
||||
}
|
||||
|
||||
@ -32,16 +34,17 @@ class Index extends Base
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run()
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$postIds = (array) $this->input('ids');
|
||||
$postIds = (array) $params->get('ids');
|
||||
$include = ['user', 'user.groups', 'editUser', 'hideUser'];
|
||||
$user = $this->actor->getUser();
|
||||
|
||||
if (count($postIds)) {
|
||||
$posts = $this->posts->findMany($postIds, $include);
|
||||
$posts = $this->posts->findByIds($postIds, $user);
|
||||
} else {
|
||||
$discussionId = $this->input('discussions');
|
||||
$posts = $this->getPostsForDiscussion($this->posts, $discussionId, $include);
|
||||
$discussionId = $params->get('discussions');
|
||||
$posts = $this->getPostsForDiscussion($params, $discussionId, $user);
|
||||
}
|
||||
|
||||
if (! count($posts)) {
|
||||
@ -52,8 +55,8 @@ class Index extends Base
|
||||
// a post resource or collection, depending on how many posts were
|
||||
// requested.
|
||||
$serializer = new PostSerializer($include);
|
||||
$this->document->setPrimaryElement($serializer->collection($posts));
|
||||
$document = $this->document()->setPrimaryElement($serializer->collection($posts->load($include)));
|
||||
|
||||
return $this->respondWithDocument();
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
42
framework/core/src/Api/Actions/Posts/ShowAction.php
Normal file
42
framework/core/src/Api/Actions/Posts/ShowAction.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Flarum\Core\Repositories\PostRepositoryInterface;
|
||||
use Flarum\Core\Support\Actor;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Serializers\PostSerializer;
|
||||
|
||||
class ShowAction extends BaseAction
|
||||
{
|
||||
protected $posts;
|
||||
|
||||
public function __construct(Actor $actor, PostRepositoryInterface $posts)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->posts = $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a single post by ID.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$id = $params->get('id');
|
||||
$posts = $this->posts->findOrFail($id, $this->actor->getUser());
|
||||
|
||||
$include = $params->included(['discussion', 'replyTo']);
|
||||
$relations = array_merge(['user', 'editUser', 'hideUser'], $include);
|
||||
$posts->load($relations);
|
||||
|
||||
// Finally, we can set up the post serializer and use it to create
|
||||
// a post resource or collection, depending on how many posts were
|
||||
// requested.
|
||||
$serializer = new PostSerializer($relations);
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($posts->first()));
|
||||
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
@ -1,39 +1,34 @@
|
||||
<?php namespace Flarum\Api\Actions\Posts;
|
||||
|
||||
use Event;
|
||||
|
||||
use Flarum\Core\Posts\Commands\EditPostCommand;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Core\Commands\EditPostCommand;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Serializers\PostSerializer;
|
||||
|
||||
class Update extends Base
|
||||
class UpdateAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Edit a post. Allows revision of content, and hiding/unhiding.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run()
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$postId = $this->param('id');
|
||||
$postId = $params->get('id');
|
||||
|
||||
// EditPost is a single command because we don't want to allow partial
|
||||
// updates (i.e. if we were to run one command and then another, if the
|
||||
// second one failed, the first one would still have succeeded.)
|
||||
$command = new EditPostCommand($postId, User::current());
|
||||
$this->fillCommandWithInput($command, 'posts');
|
||||
|
||||
Event::fire('Flarum.Api.Actions.Posts.Update.WillExecuteCommand', [$command]);
|
||||
|
||||
$post = $this->commandBus->execute($command);
|
||||
$command = new EditPostCommand($postId, $this->actor->getUser());
|
||||
$this->hydrate($command, $params->get('posts'));
|
||||
$post = $this->dispatch($command, $params);
|
||||
|
||||
// Presumably, the post was updated successfully. (The command handler
|
||||
// would have thrown an exception if not.) We set this post as our
|
||||
// document's primary element.
|
||||
$serializer = new PostSerializer;
|
||||
$this->document->setPrimaryElement($serializer->resource($post));
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($post));
|
||||
|
||||
return $this->respondWithDocument();
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
43
framework/core/src/Api/Actions/TokenAction.php
Normal file
43
framework/core/src/Api/Actions/TokenAction.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php namespace Flarum\Api\Actions;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Flarum\Core\Commands\GenerateAccessTokenCommand;
|
||||
use Flarum\Core\Repositories\UserRepositoryInterface;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
|
||||
class TokenAction extends BaseAction
|
||||
{
|
||||
protected $users;
|
||||
|
||||
public function __construct(UserRepositoryInterface $users, Dispatcher $bus)
|
||||
{
|
||||
$this->users = $users;
|
||||
$this->bus = $bus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log in and return a token.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function run(ApiParams $params)
|
||||
{
|
||||
$identification = $params->get('identification');
|
||||
$password = $params->get('password');
|
||||
|
||||
$user = $this->users->findByIdentification($identification);
|
||||
|
||||
if (! $user || ! $user->checkPassword($password)) {
|
||||
return $this->respondWithError('invalidLogin', 401);
|
||||
}
|
||||
|
||||
$command = new GenerateAccessTokenCommand($user->id);
|
||||
$token = $this->dispatch($command, $params);
|
||||
|
||||
return new JsonResponse([
|
||||
'token' => $token->id,
|
||||
'userId' => $user->id
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,39 +1,36 @@
|
||||
<?php namespace Flarum\Api\Actions\Users;
|
||||
|
||||
use Event;
|
||||
use Flarum\Core\Users\Commands\RegisterUserCommand;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Core\Commands\RegisterUserCommand;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Serializers\UserSerializer;
|
||||
|
||||
class Create extends Base
|
||||
class CreateAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Register a user.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run()
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
// We've received a request to register a user. By default, the only
|
||||
// required attributes of a user is the username, email, and password.
|
||||
// Let's set up a command with this information. We also fire an event
|
||||
// to allow plugins to add data to the command.
|
||||
$username = $this->input('users.username');
|
||||
$email = $this->input('users.email');
|
||||
$password = $this->input('users.password');
|
||||
$command = new RegisterUserCommand($username, $email, $password, User::current());
|
||||
$username = $params->get('users.username');
|
||||
$email = $params->get('users.email');
|
||||
$password = $params->get('users.password');
|
||||
|
||||
Event::fire('Flarum.Api.Actions.Users.Create.WillExecuteCommand', [$command]);
|
||||
|
||||
$user = $this->commandBus->execute($command);
|
||||
$command = new RegisterUserCommand($username, $email, $password, $this->actor->getUser());
|
||||
$this->dispatch($command, $params);
|
||||
|
||||
// Presumably, the user was created successfully. (The command handler
|
||||
// would have thrown an exception if not.) We set this post as our
|
||||
// document's primary element.
|
||||
$serializer = new UserSerializer;
|
||||
$this->document->setPrimaryElement($serializer->resource($user));
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($user));
|
||||
|
||||
return $this->respondWithDocument(201);
|
||||
return $this->respondWithDocument($document, 201);
|
||||
}
|
||||
}
|
23
framework/core/src/Api/Actions/Users/DeleteAction.php
Normal file
23
framework/core/src/Api/Actions/Users/DeleteAction.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace Flarum\Api\Actions\Users;
|
||||
|
||||
use Flarum\Core\Commands\DeleteUserCommand;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
|
||||
class DeleteAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Delete a user.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$userId = $params->get('id');
|
||||
|
||||
$command = new DeleteUserCommand($userId, $this->actor->getUser());
|
||||
$this->dispatch($command, $params);
|
||||
|
||||
return $this->respondWithoutContent();
|
||||
}
|
||||
}
|
@ -5,11 +5,11 @@ use Flarum\Core\Users\UserFinder;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Api\Serializers\UserSerializer;
|
||||
|
||||
class Index extends Base
|
||||
class IndexAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* The user finder.
|
||||
*
|
||||
*
|
||||
* @var UserFinder
|
||||
*/
|
||||
protected $finder;
|
38
framework/core/src/Api/Actions/Users/ShowAction.php
Normal file
38
framework/core/src/Api/Actions/Users/ShowAction.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php namespace Flarum\Api\Actions\Users;
|
||||
|
||||
use Flarum\Core\Repositories\UserRepositoryInterface;
|
||||
use Flarum\Core\Support\Actor;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Serializers\UserSerializer;
|
||||
|
||||
class ShowAction extends BaseAction
|
||||
{
|
||||
protected $actor;
|
||||
|
||||
protected $users;
|
||||
|
||||
public function __construct(Actor $actor, UserRepositoryInterface $users)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
$this->users = $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a single user.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function run(ApiParams $params)
|
||||
{
|
||||
$user = $this->users->findOrFail($params->get('id'), $this->actor->getUser());
|
||||
|
||||
// Set up the user serializer, which we will use to create the
|
||||
// document's primary resource. We will specify that we want the
|
||||
// 'groups' relation to be included by default.
|
||||
$serializer = new UserSerializer(['groups']);
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($user));
|
||||
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
<?php namespace Flarum\Api\Actions\Users;
|
||||
|
||||
use Event;
|
||||
|
||||
use Flarum\Core\Users\Commands\EditUserCommand;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Api\Actions\Base;
|
||||
use Flarum\Core\Commands\EditUserCommand;
|
||||
use Flarum\Api\Actions\ApiParams;
|
||||
use Flarum\Api\Actions\BaseAction;
|
||||
use Flarum\Api\Serializers\UserSerializer;
|
||||
|
||||
class Update extends Base
|
||||
class UpdateAction extends BaseAction
|
||||
{
|
||||
/**
|
||||
* Edit a user. Allows renaming the user, changing their email, and setting
|
||||
@ -15,26 +13,23 @@ class Update extends Base
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function run()
|
||||
protected function run(ApiParams $params)
|
||||
{
|
||||
$userId = $this->param('id');
|
||||
$userId = $params->get('id');
|
||||
|
||||
// EditUser is a single command because we don't want to allow partial
|
||||
// updates (i.e. if we were to run one command and then another, if the
|
||||
// second one failed, the first one would still have succeeded.)
|
||||
$command = new EditUserCommand($userId, User::current());
|
||||
$this->fillCommandWithInput($command, 'users');
|
||||
|
||||
Event::fire('Flarum.Api.Actions.Users.Update.WillExecuteCommand', [$command]);
|
||||
|
||||
$user = $this->commandBus->execute($command);
|
||||
$command = new EditUserCommand($userId, $this->actor->getUser());
|
||||
$this->hydrate($command, $params->get('users'));
|
||||
$this->dispatch($command);
|
||||
|
||||
// Presumably, the user was updated successfully. (The command handler
|
||||
// would have thrown an exception if not.) We set this user as our
|
||||
// document's primary element.
|
||||
$serializer = new UserSerializer;
|
||||
$this->document->setPrimaryElement($serializer->resource($user));
|
||||
$document = $this->document()->setPrimaryElement($serializer->resource($user));
|
||||
|
||||
return $this->respondWithDocument();
|
||||
return $this->respondWithDocument($document);
|
||||
}
|
||||
}
|
29
framework/core/src/Api/ApiServiceProvider.php
Normal file
29
framework/core/src/Api/ApiServiceProvider.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php namespace Flarum\Api;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Flarum\Api\Serializers\BaseSerializer;
|
||||
|
||||
class ApiServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
include __DIR__.'/routes.php';
|
||||
|
||||
BaseSerializer::setActor($this->app['Flarum\Core\Support\Actor']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('Flarum\Core\Support\Actor');
|
||||
}
|
||||
}
|
14
framework/core/src/Api/Events/CommandWillBeDispatched.php
Normal file
14
framework/core/src/Api/Events/CommandWillBeDispatched.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php namespace Flarum\Api\Events;
|
||||
|
||||
class CommandWillBeDispatched
|
||||
{
|
||||
public $command;
|
||||
|
||||
public $params;
|
||||
|
||||
public function __construct($command, $params)
|
||||
{
|
||||
$this->command = $command;
|
||||
$this->params = $params;
|
||||
}
|
||||
}
|
17
framework/core/src/Api/Events/SerializeAttributes.php
Normal file
17
framework/core/src/Api/Events/SerializeAttributes.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php namespace Flarum\Api\Events;
|
||||
|
||||
class SerializeAttributes
|
||||
{
|
||||
public $serializer;
|
||||
|
||||
public $model;
|
||||
|
||||
public $attributes;
|
||||
|
||||
public function __construct($serializer, $model, &$attributes)
|
||||
{
|
||||
$this->serializer = $serializer;
|
||||
$this->model = $model;
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
}
|
23
framework/core/src/Api/Events/SerializeRelationship.php
Normal file
23
framework/core/src/Api/Events/SerializeRelationship.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace Flarum\Api\Events;
|
||||
|
||||
class SerializeRelationship
|
||||
{
|
||||
public $serializer;
|
||||
|
||||
public $model;
|
||||
|
||||
public $type;
|
||||
|
||||
public $name;
|
||||
|
||||
public $relations;
|
||||
|
||||
public function __construct($serializer, $model, $type, $name, $relations)
|
||||
{
|
||||
$this->serializer = $serializer;
|
||||
$this->model = $model;
|
||||
$this->type = $type;
|
||||
$this->name = $name;
|
||||
$this->relations = $relations;
|
||||
}
|
||||
}
|
17
framework/core/src/Api/Events/WillRespondWithDocument.php
Normal file
17
framework/core/src/Api/Events/WillRespondWithDocument.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php namespace Flarum\Api\Events;
|
||||
|
||||
class WillRespondWithDocument
|
||||
{
|
||||
public $document;
|
||||
|
||||
public $statusCode;
|
||||
|
||||
public $headers;
|
||||
|
||||
public function __construct($document, &$statusCode, &$headers)
|
||||
{
|
||||
$this->document = $document;
|
||||
$this->statusCode = $statusCode;
|
||||
$this->headers = $headers;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php namespace Flarum\Api\Middleware;
|
||||
|
||||
use Flarum\Core\Models\AccessToken;
|
||||
use Flarum\Core\Support\Actor;
|
||||
use Closure;
|
||||
|
||||
class LoginWithHeaderMiddleware
|
||||
{
|
||||
protected $actor;
|
||||
|
||||
protected $prefix = 'Token ';
|
||||
|
||||
public function __construct(Actor $actor)
|
||||
{
|
||||
$this->actor = $actor;
|
||||
}
|
||||
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$header = $request->headers->get('authorization');
|
||||
if (starts_with($header, $this->prefix) &&
|
||||
($token = substr($header, strlen($this->prefix))) &&
|
||||
($accessToken = AccessToken::where('id', $token)->first())) {
|
||||
$this->actor->setUser($accessToken->user);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
62
framework/core/src/Api/Serializers/BaseSerializer.php
Normal file
62
framework/core/src/Api/Serializers/BaseSerializer.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Tobscure\JsonApi\SerializerAbstract;
|
||||
use Flarum\Api\Events\SerializeAttributes;
|
||||
use Flarum\Api\Events\SerializeRelationship;
|
||||
use Flarum\Core\Support\Actor;
|
||||
|
||||
/**
|
||||
* A base serializer to call Flarum events at common serialization points.
|
||||
*/
|
||||
abstract class BaseSerializer extends SerializerAbstract
|
||||
{
|
||||
/**
|
||||
* The actor who is requesting the serialized objects.
|
||||
*
|
||||
* @var \Flarum\Core\Support\Actor
|
||||
*/
|
||||
protected static $actor;
|
||||
|
||||
/**
|
||||
* Set the actor who is requesting the serialized objects.
|
||||
*
|
||||
* @param \Flarum\Core\Support\Actor $actor
|
||||
* @return void
|
||||
*/
|
||||
public static function setActor(Actor $actor)
|
||||
{
|
||||
static::$actor = $actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an event to allow custom serialization of attributes.
|
||||
*
|
||||
* @param mixed $model The model to serialize.
|
||||
* @param array $attributes Attributes that have already been serialized.
|
||||
* @return array
|
||||
*/
|
||||
protected function attributesEvent($model, $attributes = [])
|
||||
{
|
||||
event(new SerializeAttributes($this, $model, $attributes));
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an event to allow for custom links and includes.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return void
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if ($link = starts_with($name, 'link') || starts_with($name, 'include')) {
|
||||
$model = isset($arguments[0]) ? $arguments[0] : null;
|
||||
$relations = isset($arguments[1]) ? $arguments[1] : null;
|
||||
$type = $link ? 'link' : 'include';
|
||||
$name = substr($name, strlen($type));
|
||||
return event(new SerializeRelationship($this, $model, $type, $name, $relations), null, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,9 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Discussions\Discussion;
|
||||
use Flarum\Core\Models\Discussion;
|
||||
|
||||
class DiscussionBasicSerializer extends BaseSerializer
|
||||
{
|
||||
/**
|
||||
* The name to use for Flarum events.
|
||||
* @var string
|
||||
*/
|
||||
protected static $eventName = 'DiscussionBasic';
|
||||
|
||||
/**
|
||||
* The resource type.
|
||||
* @var string
|
||||
@ -18,7 +12,7 @@ class DiscussionBasicSerializer extends BaseSerializer
|
||||
|
||||
/**
|
||||
* Serialize attributes of a Discussion model for JSON output.
|
||||
*
|
||||
*
|
||||
* @param Discussion $discussion The Discussion model to serialize.
|
||||
* @return array
|
||||
*/
|
||||
@ -35,7 +29,7 @@ class DiscussionBasicSerializer extends BaseSerializer
|
||||
/**
|
||||
* Get the URL templates where this resource and its related resources can
|
||||
* be accessed.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function href()
|
@ -1,16 +1,10 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Discussions\Discussion;
|
||||
use Flarum\Core\Discussions\DiscussionState;
|
||||
use Flarum\Core\Models\Discussion;
|
||||
use Flarum\Core\Models\DiscussionState;
|
||||
|
||||
class DiscussionSerializer extends DiscussionBasicSerializer
|
||||
{
|
||||
/**
|
||||
* The name to use for Flarum events.
|
||||
* @var string
|
||||
*/
|
||||
protected static $eventName = 'Discussion';
|
||||
|
||||
/**
|
||||
* Default relations to include.
|
||||
* @var array
|
||||
@ -27,22 +21,25 @@ class DiscussionSerializer extends DiscussionBasicSerializer
|
||||
{
|
||||
$attributes = parent::attributes($discussion);
|
||||
|
||||
$state = $discussion->state;
|
||||
$user = static::$actor->getUser();
|
||||
$state = $discussion->stateFor($user);
|
||||
|
||||
$attributes += [
|
||||
'commentsCount' => (int) $discussion->comments_count,
|
||||
'startTime' => $discussion->start_time->toRFC3339String(),
|
||||
'lastTime' => $discussion->last_time ? $discussion->last_time->toRFC3339String() : null,
|
||||
'lastPostNumber' => $discussion->last_post_number,
|
||||
'canReply' => $discussion->permission('reply'),
|
||||
'canEdit' => $discussion->permission('edit'),
|
||||
'canDelete' => $discussion->permission('delete'),
|
||||
'canReply' => $discussion->can($user, 'reply'),
|
||||
'canEdit' => $discussion->can($user, 'edit'),
|
||||
'canDelete' => $discussion->can($user, 'delete'),
|
||||
|
||||
'readTime' => $state && $state->read_time ? $state->read_time->toRFC3339String() : null,
|
||||
'readNumber' => $state ? (int) $state->read_number : 0
|
||||
];
|
||||
|
||||
return $this->attributesEvent($discussion, $attributes);
|
||||
$this->attributesEvent($discussion, $attributes);
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +50,9 @@ class DiscussionSerializer extends DiscussionBasicSerializer
|
||||
*/
|
||||
public function linkPosts(Discussion $discussion)
|
||||
{
|
||||
return (new PostBasicSerializer)->collection($discussion->posts()->whereCanView()->orderBy('time', 'asc')->ids());
|
||||
$user = static::$actor->getUser();
|
||||
|
||||
return (new PostBasicSerializer)->collection($discussion->posts()->whereCan($user, 'view')->orderBy('time', 'asc')->ids());
|
||||
}
|
||||
|
||||
/**
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Groups\Group;
|
||||
use Flarum\Core\Models\Group;
|
||||
|
||||
class GroupSerializer extends BaseSerializer
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostBasicSerializer extends BaseSerializer
|
||||
{
|
@ -1,16 +1,10 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\Post;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class PostSerializer extends PostBasicSerializer
|
||||
{
|
||||
/**
|
||||
* The name to use for Flarum events.
|
||||
* @var string
|
||||
*/
|
||||
protected static $eventName = 'Post';
|
||||
|
||||
/**
|
||||
* Default relations to link.
|
||||
* @var array
|
||||
@ -32,7 +26,7 @@ class PostSerializer extends PostBasicSerializer
|
||||
protected function attributes(Post $post)
|
||||
{
|
||||
$attributes = parent::attributes($post);
|
||||
$user = User::current();
|
||||
$user = static::$actor->getUser();
|
||||
|
||||
unset($attributes['content']);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserBasicSerializer extends BaseSerializer
|
||||
{
|
||||
@ -18,7 +18,7 @@ class UserBasicSerializer extends BaseSerializer
|
||||
|
||||
/**
|
||||
* Serialize attributes of a User model for JSON output.
|
||||
*
|
||||
*
|
||||
* @param User $user The User model to serialize.
|
||||
* @return array
|
||||
*/
|
||||
@ -36,7 +36,7 @@ class UserBasicSerializer extends BaseSerializer
|
||||
/**
|
||||
* Get the URL templates where this resource and its related resources can
|
||||
* be accessed.
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function href()
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Api\Serializers;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserSerializer extends UserBasicSerializer
|
||||
{
|
||||
@ -18,7 +18,7 @@ class UserSerializer extends UserBasicSerializer
|
||||
|
||||
/**
|
||||
* Serialize attributes of a User model for JSON output.
|
||||
*
|
||||
*
|
||||
* @param User $user The User model to serialize.
|
||||
* @return array
|
||||
*/
|
||||
@ -26,22 +26,38 @@ class UserSerializer extends UserBasicSerializer
|
||||
{
|
||||
$attributes = parent::attributes($user);
|
||||
|
||||
$actorUser = static::$actor->getUser();
|
||||
$canEdit = $user->can($actorUser, 'edit');
|
||||
|
||||
$attributes += [
|
||||
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
|
||||
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
|
||||
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
|
||||
'discussionsCount' => (int) $user->discussions_count,
|
||||
'postsCount' => (int) $user->posts_count,
|
||||
'canEdit' => $user->permission('edit'),
|
||||
'canDelete' => $user->permission('delete'),
|
||||
'canEdit' => $canEdit,
|
||||
'canDelete' => $user->can($actorUser, 'delete'),
|
||||
];
|
||||
|
||||
if ($canEdit) {
|
||||
$attributes += [
|
||||
'isActivated' => $user->is_activated,
|
||||
'email' => $user->email,
|
||||
'isConfirmed' => $user->is_confirmed
|
||||
];
|
||||
}
|
||||
|
||||
if ($user->id === $actorUser->id) {
|
||||
$attributes += [
|
||||
'readTime' => $user->read_time ? $user->read_time->toRFC3339String() : null,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->attributesEvent($user, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a collection containing a user's groups.
|
||||
*
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $relations
|
||||
* @return Tobscure\JsonApi\Collection
|
@ -2,36 +2,18 @@
|
||||
|
||||
$action = function ($class) {
|
||||
return function () use ($class) {
|
||||
$action = App::make($class);
|
||||
$request = app('request');
|
||||
$parameters = Route::current()->parameters();
|
||||
$action = $this->app->make($class);
|
||||
$request = $this->app['request']->instance();
|
||||
$parameters = $this->app['router']->current()->parameters();
|
||||
return $action->handle($request, $parameters);
|
||||
};
|
||||
};
|
||||
|
||||
// @todo refactor into a unit-testable class
|
||||
Route::filter('attemptLogin', function($route, $request) {
|
||||
$prefix = 'Token ';
|
||||
if (starts_with($request->headers->get('authorization'), $prefix)) {
|
||||
$token = substr($request->headers->get('authorization'), strlen($prefix));
|
||||
if ($user = Flarum\Core\Users\User::where('token', $token)->first()) {
|
||||
Auth::setUser($user);
|
||||
}
|
||||
}
|
||||
});
|
||||
Route::group(['prefix' => 'api', 'middleware' => 'Flarum\Api\Middleware\LoginWithHeaderMiddleware'], function () use ($action) {
|
||||
|
||||
Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($action) {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Auth
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Login
|
||||
Route::post('auth/login', [
|
||||
'as' => 'flarum.api.auth.login',
|
||||
'uses' => $action('Flarum\Api\Actions\Auth\Login')
|
||||
Route::post('token', [
|
||||
'as' => 'flarum.api.token',
|
||||
'uses' => $action('Flarum\Api\Actions\TokenAction')
|
||||
]);
|
||||
|
||||
/*
|
||||
@ -43,31 +25,31 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
||||
// List users
|
||||
Route::get('users', [
|
||||
'as' => 'flarum.api.users.index',
|
||||
'uses' => $action('Flarum\Api\Actions\Users\Index')
|
||||
'uses' => $action('Flarum\Api\Actions\Users\IndexAction')
|
||||
]);
|
||||
|
||||
// Register a user
|
||||
Route::post('users', [
|
||||
'as' => 'flarum.api.users.create',
|
||||
'uses' => $action('Flarum\Api\Actions\Users\Create')
|
||||
'uses' => $action('Flarum\Api\Actions\Users\CreateAction')
|
||||
]);
|
||||
|
||||
// Get a single user
|
||||
Route::get('users/{id}', [
|
||||
'as' => 'flarum.api.users.show',
|
||||
'uses' => $action('Flarum\Api\Actions\Users\Show')
|
||||
'uses' => $action('Flarum\Api\Actions\Users\ShowAction')
|
||||
]);
|
||||
|
||||
// Edit a user
|
||||
Route::put('users/{id}', [
|
||||
'as' => 'flarum.api.users.update',
|
||||
'uses' => $action('Flarum\Api\Actions\Users\Update')
|
||||
'uses' => $action('Flarum\Api\Actions\Users\UpdateAction')
|
||||
]);
|
||||
|
||||
// Delete a user
|
||||
Route::delete('users/{id}', [
|
||||
'as' => 'flarum.api.users.delete',
|
||||
'uses' => $action('Flarum\Api\Actions\Users\Delete')
|
||||
'uses' => $action('Flarum\Api\Actions\Users\DeleteAction')
|
||||
]);
|
||||
|
||||
/*
|
||||
@ -79,13 +61,13 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
||||
// List activity
|
||||
Route::get('activity', [
|
||||
'as' => 'flarum.api.activity.index',
|
||||
'uses' => $action('Flarum\Api\Actions\Activity\Index')
|
||||
'uses' => $action('Flarum\Api\Actions\Activity\IndexAction')
|
||||
]);
|
||||
|
||||
// List notifications for the current user
|
||||
Route::get('notifications', [
|
||||
'as' => 'flarum.api.notifications.index',
|
||||
'uses' => $action('Flarum\Api\Actions\Notifications\Index')
|
||||
'uses' => $action('Flarum\Api\Actions\Notifications\IndexAction')
|
||||
]);
|
||||
|
||||
/*
|
||||
@ -97,31 +79,31 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
||||
// List discussions
|
||||
Route::get('discussions', [
|
||||
'as' => 'flarum.api.discussions.index',
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\Index')
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\IndexAction')
|
||||
]);
|
||||
|
||||
// Create a discussion
|
||||
Route::post('discussions', [
|
||||
'as' => 'flarum.api.discussions.create',
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\Create')
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\CreateAction')
|
||||
]);
|
||||
|
||||
// Show a single discussion
|
||||
Route::get('discussions/{id}', [
|
||||
'as' => 'flarum.api.discussions.show',
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\Show')
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\ShowAction')
|
||||
]);
|
||||
|
||||
// Edit a discussion
|
||||
Route::put('discussions/{id}', [
|
||||
'as' => 'flarum.api.discussions.update',
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\Update')
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\UpdateAction')
|
||||
]);
|
||||
|
||||
// Delete a discussion
|
||||
Route::delete('discussions/{id}', [
|
||||
'as' => 'flarum.api.discussions.delete',
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\Delete')
|
||||
'uses' => $action('Flarum\Api\Actions\Discussions\DeleteAction')
|
||||
]);
|
||||
|
||||
/*
|
||||
@ -133,32 +115,32 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
||||
// List posts, usually for a discussion
|
||||
Route::get('posts', [
|
||||
'as' => 'flarum.api.posts.index',
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\Index')
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\IndexAction')
|
||||
]);
|
||||
|
||||
// Create a post
|
||||
// @todo consider 'discussions/{id}/links/posts'?
|
||||
Route::post('posts', [
|
||||
'as' => 'flarum.api.posts.create',
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\Create')
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\CreateAction')
|
||||
]);
|
||||
|
||||
// Show a single or multiple posts by ID
|
||||
Route::get('posts/{id}', [
|
||||
'as' => 'flarum.api.posts.show',
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\Show')
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\ShowAction')
|
||||
]);
|
||||
|
||||
// Edit a post
|
||||
Route::put('posts/{id}', [
|
||||
'as' => 'flarum.api.posts.update',
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\Update')
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\UpdateAction')
|
||||
]);
|
||||
|
||||
// Delete a post
|
||||
Route::delete('posts/{id}', [
|
||||
'as' => 'flarum.api.posts.delete',
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\Delete')
|
||||
'uses' => $action('Flarum\Api\Actions\Posts\DeleteAction')
|
||||
]);
|
||||
|
||||
/*
|
||||
@ -170,31 +152,31 @@ Route::group(['prefix' => 'api', 'before' => 'attemptLogin'], function () use ($
|
||||
// List groups
|
||||
Route::get('groups', [
|
||||
'as' => 'flarum.api.groups.index',
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\Index')
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\IndexAction')
|
||||
]);
|
||||
|
||||
// Create a group
|
||||
Route::post('groups', [
|
||||
'as' => 'flarum.api.groups.create',
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\Create')
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\CreateAction')
|
||||
]);
|
||||
|
||||
// Show a single group
|
||||
Route::get('groups/{id}', [
|
||||
'as' => 'flarum.api.groups.show',
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\Show')
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\ShowAction')
|
||||
]);
|
||||
|
||||
// Edit a group
|
||||
Route::put('groups/{id}', [
|
||||
'as' => 'flarum.api.groups.update',
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\Update')
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\UpdateAction')
|
||||
]);
|
||||
|
||||
// Delete a group
|
||||
Route::delete('groups/{id}', [
|
||||
'as' => 'flarum.api.groups.delete',
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\Delete')
|
||||
'uses' => $action('Flarum\Api\Actions\Groups\DeleteAction')
|
||||
]);
|
||||
|
||||
});
|
22
framework/core/src/Console/ConsoleServiceProvider.php
Normal file
22
framework/core/src/Console/ConsoleServiceProvider.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace Flarum\Console;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConsoleServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->commands('Flarum\Console\InstallCommand');
|
||||
$this->commands('Flarum\Console\SeedCommand');
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
76
framework/core/src/Console/InstallCommand.php
Normal file
76
framework/core/src/Console/InstallCommand.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php namespace Flarum\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class InstallCommand extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'flarum:install';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Run Flarum\'s installation migrations and seeds.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$path = str_replace($this->laravel['path.base'].'/', '', __DIR__.'/../../migrations');
|
||||
|
||||
$this->call('migrate', ['--path' => $path]);
|
||||
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\ConfigTableSeeder']);
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\GroupsTableSeeder']);
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\PermissionsTableSeeder']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
// ['example', InputArgument::REQUIRED, 'An example argument.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
71
framework/core/src/Console/SeedCommand.php
Normal file
71
framework/core/src/Console/SeedCommand.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php namespace Flarum\Console;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class SeedCommand extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'flarum:seed';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Seed Flarum\'s database with fake data.';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']);
|
||||
$this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\DiscussionsTableSeeder']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command arguments.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
// ['example', InputArgument::REQUIRED, 'An example argument.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return [
|
||||
// ['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Users\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class ConfirmEmailCommand
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Discussions\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class DeleteDiscussionCommand
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Posts\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class DeletePostCommand
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Users\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class DeleteUserCommand
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Discussions\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class EditDiscussionCommand
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Posts\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class EditPostCommand
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Users\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class EditUserCommand
|
||||
{
|
@ -0,0 +1,11 @@
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class GenerateAccessTokenCommand
|
||||
{
|
||||
public $userId;
|
||||
|
||||
public function __construct($userId)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Flarum\Core\Posts\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class PostReplyCommand
|
||||
{
|
||||
{
|
||||
public $discussionId;
|
||||
|
||||
public $content;
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Discussions\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class ReadDiscussionCommand
|
||||
{
|
@ -1,7 +1,9 @@
|
||||
<?php namespace Flarum\Core\Users\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class RegisterUserCommand
|
||||
{
|
||||
public $forum;
|
||||
|
||||
public $user;
|
||||
|
||||
public $username;
|
||||
@ -10,11 +12,12 @@ class RegisterUserCommand
|
||||
|
||||
public $password;
|
||||
|
||||
public function __construct($username, $email, $password, $user)
|
||||
public function __construct($username, $email, $password, $user, $forum)
|
||||
{
|
||||
$this->username = $username;
|
||||
$this->email = $email;
|
||||
$this->password = $password;
|
||||
$this->user = $user;
|
||||
$this->forum = $forum;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php namespace Flarum\Core\Discussions\Commands;
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
class StartDiscussionCommand
|
||||
{
|
||||
@ -8,10 +8,13 @@ class StartDiscussionCommand
|
||||
|
||||
public $user;
|
||||
|
||||
public function __construct($title, $content, $user)
|
||||
public $forum;
|
||||
|
||||
public function __construct($title, $content, $user, $forum)
|
||||
{
|
||||
$this->title = $title;
|
||||
$this->content = $content;
|
||||
$this->user = $user;
|
||||
$this->forum = $forum;
|
||||
}
|
||||
}
|
179
framework/core/src/Core/CoreServiceProvider.php
Normal file
179
framework/core/src/Core/CoreServiceProvider.php
Normal file
@ -0,0 +1,179 @@
|
||||
<?php namespace Flarum\Core;
|
||||
|
||||
use Illuminate\Bus\Dispatcher as Bus;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Flarum\Core\Formatter\FormatterManager;
|
||||
use Flarum\Core\Models\CommentPost;
|
||||
use Flarum\Core\Models\Post;
|
||||
use Flarum\Core\Models\Model;
|
||||
use Flarum\Core\Models\Forum;
|
||||
use Flarum\Core\Models\User;
|
||||
use Flarum\Core\Models\Discussion;
|
||||
use Flarum\Core\Search\GambitManager;
|
||||
|
||||
class CoreServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Dispatcher $events, Bus $bus)
|
||||
{
|
||||
$this->loadViewsFrom(__DIR__.'../../views', 'flarum');
|
||||
|
||||
$this->registerEventHandlers($events);
|
||||
$this->registerPostTypes();
|
||||
$this->registerPermissions();
|
||||
$this->registerGambits();
|
||||
$this->setupModels();
|
||||
|
||||
$bus->mapUsing(function ($command) {
|
||||
return Bus::simpleMapping(
|
||||
$command, 'Flarum\Core\Commands', 'Flarum\Core\Handlers\Commands'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
// Register a singleton entity that represents this forum. This entity
|
||||
// will be used to check for global forum permissions (like viewing the
|
||||
// forum, registering, and starting discussions.)
|
||||
$this->app->singleton('flarum.forum', 'Flarum\Core\Models\Forum');
|
||||
|
||||
// Register the extensions manager object. This manages a list of
|
||||
// available extensions, and provides functionality to enable/disable
|
||||
// them.
|
||||
$this->app->singleton('flarum.extensions', 'Flarum\Core\Support\Extensions\Manager');
|
||||
|
||||
$this->app->bind('flarum.discussionFinder', 'Flarum\Core\Discussions\DiscussionFinder');
|
||||
|
||||
$this->app->singleton('flarum.formatter', function () {
|
||||
$formatter = new FormatterManager($this->app);
|
||||
$formatter->add('basic', 'Flarum\Core\Formatter\BasicFormatter');
|
||||
return $formatter;
|
||||
});
|
||||
|
||||
$this->app->bind(
|
||||
'Flarum\Core\Repositories\DiscussionRepositoryInterface',
|
||||
'Flarum\Core\Repositories\EloquentDiscussionRepository'
|
||||
);
|
||||
$this->app->bind(
|
||||
'Flarum\Core\Repositories\PostRepositoryInterface',
|
||||
'Flarum\Core\Repositories\EloquentPostRepository'
|
||||
);
|
||||
$this->app->bind(
|
||||
'Flarum\Core\Repositories\UserRepositoryInterface',
|
||||
'Flarum\Core\Repositories\EloquentUserRepository'
|
||||
);
|
||||
}
|
||||
|
||||
public function registerGambits()
|
||||
{
|
||||
$this->app->bind('Flarum\Core\Search\GambitManager', function () {
|
||||
$gambits = new GambitManager($this->app);
|
||||
$gambits->add('Flarum\Core\Search\Discussions\Gambits\AuthorGambit');
|
||||
$gambits->add('Flarum\Core\Search\Discussions\Gambits\UnreadGambit');
|
||||
$gambits->setFulltextGambit('Flarum\Core\Search\Discussions\Gambits\FulltextGambit');
|
||||
return $gambits;
|
||||
});
|
||||
}
|
||||
|
||||
public function registerPostTypes()
|
||||
{
|
||||
Post::addType('comment', 'Flarum\Core\Models\CommentPost');
|
||||
Post::addType('renamed', 'Flarum\Core\Models\RenamedPost');
|
||||
|
||||
CommentPost::setFormatter($this->app['flarum.formatter']);
|
||||
}
|
||||
|
||||
public function registerEventHandlers($events)
|
||||
{
|
||||
$events->subscribe('Flarum\Core\Handlers\Events\DiscussionMetadataUpdater');
|
||||
$events->subscribe('Flarum\Core\Handlers\Events\UserMetadataUpdater');
|
||||
$events->subscribe('Flarum\Core\Handlers\Events\RenamedPostCreator');
|
||||
$events->subscribe('Flarum\Core\Handlers\Events\EmailConfirmationMailer');
|
||||
}
|
||||
|
||||
public function setupModels()
|
||||
{
|
||||
Model::setForum($this->app['flarum.forum']);
|
||||
Model::setValidator($this->app['validator']);
|
||||
|
||||
User::setHasher($this->app['hash']);
|
||||
}
|
||||
|
||||
public function registerPermissions()
|
||||
{
|
||||
Forum::grantPermission(function ($grant, $user, $permission) {
|
||||
return $user->hasPermission($permission, 'forum');
|
||||
});
|
||||
|
||||
Post::grantPermission(function ($grant, $user, $permission) {
|
||||
return $user->hasPermission($permission, 'post');
|
||||
});
|
||||
|
||||
// Grant view access to a post only if the user can also view the
|
||||
// discussion which the post is in. Also, the if the post is hidden,
|
||||
// the user must have edit permissions too.
|
||||
Post::grantPermission('view', function ($grant) {
|
||||
$grant->whereCan('view', 'discussion');
|
||||
});
|
||||
|
||||
Post::demandPermission('view', function ($demand) {
|
||||
$demand->whereNull('hide_user_id')
|
||||
->orWhereCan('edit');
|
||||
});
|
||||
|
||||
// Allow a user to edit their own post, unless it has been hidden by
|
||||
// someone else.
|
||||
Post::grantPermission('edit', function ($grant, $user) {
|
||||
$grant->whereCan('editOwn')
|
||||
->where('user_id', $user->id);
|
||||
});
|
||||
|
||||
Post::demandPermission('editOwn', function ($demand, $user) {
|
||||
$demand->whereNull('hide_user_id');
|
||||
if ($user) {
|
||||
$demand->orWhere('hide_user_id', $user->id);
|
||||
}
|
||||
});
|
||||
|
||||
User::grantPermission(function ($grant, $user, $permission) {
|
||||
return $user->hasPermission($permission, 'forum');
|
||||
});
|
||||
|
||||
// Grant view access to a user if the user can view the forum.
|
||||
User::grantPermission('view', function ($grant, $user) {
|
||||
$grant->whereCan('view', 'forum');
|
||||
});
|
||||
|
||||
// Allow a user to edit their own account.
|
||||
User::grantPermission('edit', function ($grant, $user) {
|
||||
$grant->where('id', $user->id);
|
||||
});
|
||||
|
||||
Discussion::grantPermission(function ($grant, $user, $permission) {
|
||||
return $user->hasPermission($permission, 'discussion');
|
||||
});
|
||||
|
||||
// Grant view access to a discussion if the user can view the forum.
|
||||
Discussion::grantPermission('view', function ($grant, $user) {
|
||||
$grant->whereCan('view', 'forum');
|
||||
});
|
||||
|
||||
// Allow a user to edit their own discussion.
|
||||
Discussion::grantPermission('edit', function ($grant, $user) {
|
||||
if ($user->hasPermission('editOwn', 'discussion')) {
|
||||
$grant->where('start_user_id', $user->id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Models\DiscussionState;
|
||||
|
||||
class DiscussionStateWillBeSaved
|
||||
{
|
||||
public $state;
|
||||
|
||||
public $command;
|
||||
|
||||
public function __construct(DiscussionState $state, $command)
|
||||
{
|
||||
$this->state = $state;
|
||||
$this->command = $command;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Discussions\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Discussions\Discussion;
|
||||
use Flarum\Core\Models\Discussion;
|
||||
|
||||
class DiscussionWasDeleted
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Discussions\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Discussions\DiscussionState;
|
||||
use Flarum\Core\Models\DiscussionState;
|
||||
|
||||
class DiscussionWasRead
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Flarum\Core\Discussions\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Discussions\Discussion;
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\Discussion;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class DiscussionWasRenamed
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Discussions\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Discussions\Discussion;
|
||||
use Flarum\Core\Models\Discussion;
|
||||
|
||||
class DiscussionWasStarted
|
||||
{
|
16
framework/core/src/Core/Events/DiscussionWillBeDeleted.php
Normal file
16
framework/core/src/Core/Events/DiscussionWillBeDeleted.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Models\Discussion;
|
||||
|
||||
class DiscussionWillBeDeleted
|
||||
{
|
||||
public $discussion;
|
||||
|
||||
public $command;
|
||||
|
||||
public function __construct(Discussion $discussion, $command)
|
||||
{
|
||||
$this->discussion = $discussion;
|
||||
$this->command = $command;
|
||||
}
|
||||
}
|
16
framework/core/src/Core/Events/DiscussionWillBeSaved.php
Normal file
16
framework/core/src/Core/Events/DiscussionWillBeSaved.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Models\Discussion;
|
||||
|
||||
class DiscussionWillBeSaved
|
||||
{
|
||||
public $discussion;
|
||||
|
||||
public $command;
|
||||
|
||||
public function __construct(Discussion $discussion, $command)
|
||||
{
|
||||
$this->discussion = $discussion;
|
||||
$this->command = $command;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Posts\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostWasDeleted
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Posts\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostWasHidden
|
||||
{
|
@ -1,8 +1,8 @@
|
||||
<?php namespace Flarum\Core\Posts\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class ReplyWasPosted
|
||||
class PostWasPosted
|
||||
{
|
||||
public $post;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Posts\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostWasRestored
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Posts\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Posts\Post;
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostWasRevised
|
||||
{
|
16
framework/core/src/Core/Events/PostWillBeDeleted.php
Normal file
16
framework/core/src/Core/Events/PostWillBeDeleted.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostWillBeDeleted
|
||||
{
|
||||
public $post;
|
||||
|
||||
public $command;
|
||||
|
||||
public function __construct(Post $post, $command)
|
||||
{
|
||||
$this->post = $post;
|
||||
$this->command = $command;
|
||||
}
|
||||
}
|
16
framework/core/src/Core/Events/PostWillBeSaved.php
Normal file
16
framework/core/src/Core/Events/PostWillBeSaved.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostWillBeSaved
|
||||
{
|
||||
public $post;
|
||||
|
||||
public $command;
|
||||
|
||||
public function __construct(Post $post, $command)
|
||||
{
|
||||
$this->post = $post;
|
||||
$this->command = $command;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Users\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class EmailWasChanged
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Users\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class EmailWasConfirmed
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Users\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class PasswordWasChanged
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Users\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserWasActivated
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Users\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserWasDeleted
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Users\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserWasRegistered
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php namespace Flarum\Core\Users\Events;
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserWasRenamed
|
||||
{
|
16
framework/core/src/Core/Events/UserWillBeDeleted.php
Normal file
16
framework/core/src/Core/Events/UserWillBeDeleted.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Core\Events;
|
||||
|
||||
use Flarum\Core\Models\User;
|
||||
|
||||
class UserWillBeDeleted
|
||||
{
|
||||
public $user;
|
||||
|
||||
public $command;
|
||||
|
||||
public function __construct(User $user, $command)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->command = $command;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user