Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
charliepage88 committed Mar 6, 2018
1 parent 4cc4d2b commit d68b2ca
Show file tree
Hide file tree
Showing 49 changed files with 4,097 additions and 368 deletions.
2 changes: 1 addition & 1 deletion INSTALL.md
Expand Up @@ -65,7 +65,7 @@ find . -type f -exec chmod 644 {} \; # Change file permissions
Now, if you installed through [**Github**](https://github.com/adaptcms/adaptcms) or [**BitBucket**](https://bitbucket.org/charliepage7/adaptcms), you'll want to run this command so that pull requests are still tied to the main user account on the server:

```
chown root:root -R . # Let the web server be the owner
chown yourusername:www-data -R . # Let the web server be the owner
```

If your account is something different, such as ubuntu if you're on AWS, replace that with root. You should see the username in the path, but if you're unsure just run this:
Expand Down
Expand Up @@ -38,8 +38,6 @@ public function add(Request $request)
]);

$item->name = $request->get('name');
$item->slug = str_slug($item->name, '-');
$item->ord = (ForumCategory::count());

$item->save();

Expand Down Expand Up @@ -73,7 +71,6 @@ public function edit(Request $request, $id)
]);

$item->name = $request->get('name');
$item->slug = str_slug($item->name, '-');

$item->save();

Expand Down Expand Up @@ -121,13 +118,7 @@ public function order(Request $request)
if ($request->getMethod() == 'POST') {
$items = json_decode($request->get('items'), true);

foreach ($items as $index => $id) {
$item = ForumCategory::find($id);

$item->ord = $index;

$item->save();
}
ForumCategory::setNewOrder($items);

return response()->json([
'status' => true
Expand Down
13 changes: 1 addition & 12 deletions app/Modules/Adaptbb/Http/Controllers/Admin/ForumsController.php
Expand Up @@ -55,9 +55,6 @@ public function add(Request $request)

$item->fill($request->except('_token'));

$item->slug = str_slug($item->name, '-');
$item->ord = (Forum::count());

$item->save();

return redirect()
Expand Down Expand Up @@ -93,8 +90,6 @@ public function edit(Request $request, $id)

$item->fill($request->except('_token'));

$item->slug = str_slug($item->name, '-');

$item->save();

return redirect()
Expand Down Expand Up @@ -143,13 +138,7 @@ public function order(Request $request)
if ($request->getMethod() == 'POST') {
$items = json_decode($request->get('items'), true);

foreach ($items as $index => $id) {
$item = Forum::find($id);

$item->ord = $index;

$item->save();
}
Forum::setNewOrder($items);

return response()->json([
'status' => true
Expand Down
37 changes: 37 additions & 0 deletions app/Modules/Adaptbb/Listeners/AdminDashboardListener.php
@@ -0,0 +1,37 @@
<?php

namespace App\Modules\Adaptbb\Listeners;

use App\Modules\Adaptbb\Models\Topic;
use App\Modules\Posts\Events\AdminDashboardEvent;

use Cache;

class AdminDashboardListener
{
/**
* Handle the event.
*
* @param AdminDashboardEvent $event
* @return void
*/
public function handle(AdminDashboardEvent $event)
{
$admin_dashboard_data = json_decode(Cache::get('admin_dashboard_data'), true);

// most recent forum topics
$topics = Topic::with('replies')->where('active', '=', 1)->orderBy('created_at', 'DESC')->take(5)->get();

$admin_dashboard_data['most_recent_forum_topics'] = [
'collection' => collect([]),
'viewPath' => 'adaptbb::Partials/admin_dashboard'
];
foreach($topics as $topic) {
$topic->url = $topic->getUrl();

$admin_dashboard_data['most_recent_forum_topics']['collection']->push($topic);
}

Cache::put('admin_dashboard_data', json_encode($admin_dashboard_data), 15);
}
}
5 changes: 0 additions & 5 deletions app/Modules/Adaptbb/Listeners/InstallSeedListener.php
Expand Up @@ -33,8 +33,6 @@ public function handle(InstallSeedEvent $event)
$model = new ForumCategory;

$model->name = $category['name'];
$model->slug = str_slug($model->name, '-');
$model->ord = $index;

$model->save();
}
Expand All @@ -56,8 +54,6 @@ public function handle(InstallSeedEvent $event)
$model = new Forum;

$model->name = $forum['name'];
$model->slug = str_slug($model->name, '-');
$model->ord = $index;
$model->description = $forum['description'];
$model->meta_description = $forum['description'];
$model->category_id = $forum['category_id'];
Expand All @@ -76,7 +72,6 @@ public function handle(InstallSeedEvent $event)
$model = new Topic;

$model->name = $topic['name'];
$model->slug = str_slug($model->name, '-');
$model->message = $topic['message'];
$model->topic_type = 'normal';
$model->active = 1;
Expand Down
10 changes: 8 additions & 2 deletions app/Modules/Adaptbb/Models/Forum.php
Expand Up @@ -9,9 +9,10 @@
use App\Modules\Adaptbb\Models\Reply;
use App\Modules\Adaptbb\Models\Topic;

class Forum extends Model
class Forum extends Model implements Sortable
{
use Sluggable;
use Sluggable,
SortableTrait;

protected $table = 'plugin_adaptbb_forums';

Expand All @@ -30,6 +31,11 @@ class Forum extends Model
'meta_description'
];

public $sortable = [
'order_column_name' => 'ord',
'sort_when_creating' => true,
];

/**
* Category
*
Expand Down
12 changes: 10 additions & 2 deletions app/Modules/Adaptbb/Models/ForumCategory.php
Expand Up @@ -4,10 +4,13 @@

use Cviebrock\EloquentSluggable\Sluggable;
use Illuminate\Database\Eloquent\Model;
use Spatie\EloquentSortable\Sortable;
use Spatie\EloquentSortable\SortableTrait;

class ForumCategory extends Model
class ForumCategory extends Model implements Sortable
{
use Sluggable;
use Sluggable,
SortableTrait;

protected $table = 'plugin_adaptbb_forum_categories';

Expand All @@ -16,6 +19,11 @@ class ForumCategory extends Model
'ord'
];

public $sortable = [
'order_column_name' => 'ord',
'sort_when_creating' => true,
];

/**
* Forums
*
Expand Down
@@ -0,0 +1,3 @@
<h3>Adaptbb</h3>

<?php print_r($data) ?>
3 changes: 3 additions & 0 deletions app/Modules/Core/Database/Seeds/CoreDatabaseSeeder.php
Expand Up @@ -26,6 +26,9 @@ public function run()
]);
$model->add([
'name' => 'Users'
]);
$model->add([
'name' => 'API'
]);

// create settings
Expand Down
25 changes: 25 additions & 0 deletions app/Modules/Posts/Events/AdminDashboardEvent.php
@@ -0,0 +1,25 @@
<?php

namespace App\Modules\Posts\Events;

use Illuminate\Queue\SerializesModels;

use Cache;

class AdminDashboardEvent
{
use SerializesModels;

public $admin_dashboard_data = [];

/**
* Create a new event instance.
*
* @param Order $order
* @return void
*/
public function __construct()
{

}
}
Expand Up @@ -128,13 +128,7 @@ public function order(Request $request)
if ($request->getMethod() == 'POST') {
$items = json_decode($request->get('items'), true);

foreach($items as $index => $id) {
$item = Category::find($id);

$item->ord = $index;

$item->save();
}
Category::setNewOrder($items);

return response()->json([
'status' => true
Expand Down
10 changes: 2 additions & 8 deletions app/Modules/Posts/Http/Controllers/Admin/FieldsController.php
Expand Up @@ -175,15 +175,9 @@ public function order(Request $request)
$items = Field::orderBy('ord', 'ASC')->get();

if ($request->getMethod() == 'POST') {
$items = json_decode($request->get('items'), true);
$items = json_decode($request->get('items'), true);

foreach($items as $index => $id) {
$item = Field::find($id);

$item->ord = $index;

$item->save();
}
Field::setNewOrder($items);

return response()->json([
'status' => true
Expand Down
29 changes: 21 additions & 8 deletions app/Modules/Posts/Http/Controllers/Admin/PagesController.php
Expand Up @@ -6,9 +6,12 @@
use Illuminate\Validation\Rule;

use App\Http\Controllers\Controller;
use App\Modules\Posts\Events\AdminDashboardEvent;
use App\Modules\Posts\Models\Page;

use Auth;
use Cache;
use Core;
use Storage;
use Validator;

Expand All @@ -21,7 +24,23 @@ class PagesController extends Controller
*/
public function dashboard()
{
return view('posts::Admin/Pages/dashboard');
$data = Cache::get('admin_dashboard_data');

if (!empty($data)) {
$data = json_decode($data, true);
} else {
Core::debugDisable();

Cache::put('admin_dashboard_data', json_encode([]), 15);

event(new AdminDashboardEvent());

$data = json_decode(Cache::get('admin_dashboard_data'), true);

Cache::forget('admin_dashboard_data');
}

return view('posts::Admin/Pages/dashboard', compact('data'));
}

/**
Expand Down Expand Up @@ -175,13 +194,7 @@ public function order(Request $request)
if ($request->getMethod() == 'POST') {
$items = json_decode($request->get('items'), true);

foreach($items as $index => $id) {
$item = Page::find($id);

$item->ord = $index;

$item->save();
}
Page::setNewOrder($items);

return responder()->success()->respond();
}
Expand Down
12 changes: 1 addition & 11 deletions app/Modules/Posts/Http/Controllers/Admin/PostsController.php
Expand Up @@ -30,17 +30,7 @@ class PostsController extends Controller
*/
public function index(Request $request)
{
$items = Post::orderBy('name', 'ASC');

if ($request->get('category_id')) {
$items->where('category_id', '=', $request->get('category_id'));
}

if ($request->get('status', 1) != '') {
$items->where('status', '=', $request->get('status', 1));
}

$items = $items->paginate(15);
$items = Post::filter($request->all())->filterPaginate(15);
$categories = Category::all();

return view('posts::Admin/Posts/index', compact('items', 'categories'));
Expand Down
38 changes: 38 additions & 0 deletions app/Modules/Posts/Listeners/AdminDashboardListener.php
@@ -0,0 +1,38 @@
<?php

namespace App\Modules\Posts\Listeners;

use App\Modules\Posts\Models\Post;
use App\Modules\Posts\Events\AdminDashboardEvent;

use Cache;

class AdminDashboardListener
{
/**
* Handle the event.
*
* @param AdminDashboardEvent $event
* @return void
*/
public function handle(AdminDashboardEvent $event)
{
$admin_dashboard_data = json_decode(Cache::get('admin_dashboard_data'), true);

// posts
$posts = Post::where('status', '=', 0)->get();

$admin_dashboard_data['pending_posts'] = [
'collection' => collect([]),
'viewPath' => 'posts::Partials/admin_dashboard'
];

foreach($posts as $post) {
$post->url = route('posts.view', [ 'slug' => $post->slug ]);

$admin_dashboard_data['pending_posts']['collection']->push($post);
}

Cache::put('admin_dashboard_data', json_encode($admin_dashboard_data), 15);
}
}

0 comments on commit d68b2ca

Please sign in to comment.