This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/app/Controllers/Settings/Controller.php

91 lines
3 KiB
PHP
Raw Normal View History

<?php
/**
* Holds the base settings controller.
* @package Sakura
*/
namespace Sakura\Controllers\Settings;
use Sakura\Controllers\Controller as BaseController;
2016-08-07 14:10:27 +00:00
use Sakura\CurrentSession;
2016-03-31 20:03:25 +00:00
use Sakura\Perms\Site;
2016-04-01 21:44:31 +00:00
use Sakura\Template;
/**
* Base controller (which other controllers should extend on).
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Controller extends BaseController
{
2016-08-05 02:35:37 +00:00
/**
* Constructor.
*/
public function __construct()
{
2016-08-02 20:35:12 +00:00
Template::vars(['navigation' => $this->navigation()]);
}
2016-08-05 02:35:37 +00:00
/**
* Generates the navigation.
* @return array
*/
2016-03-31 20:03:25 +00:00
public function navigation()
{
$nav = [];
2016-08-02 20:35:12 +00:00
// Account
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::ALTER_PROFILE)) {
2016-09-08 21:32:33 +00:00
$nav["Account"]["Profile"] = route('settings.account.profile');
2016-08-02 20:35:12 +00:00
}
2016-09-08 21:32:33 +00:00
if (CurrentSession::$user->permission(Site::CHANGE_EMAIL)
|| CurrentSession::$user->permission(Site::CHANGE_USERNAME)
|| CurrentSession::$user->permission(Site::CHANGE_USERTITLE)
|| CurrentSession::$user->permission(Site::CHANGE_PASSWORD)) {
$nav["Account"]["Details"] = route('settings.account.details');
2016-08-02 20:35:12 +00:00
}
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::ALTER_RANKS)) {
2016-09-08 21:32:33 +00:00
$nav["Account"]["Ranks"] = route('settings.account.ranks');
2016-03-31 20:03:25 +00:00
}
// Friends
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::MANAGE_FRIENDS)) {
2016-09-08 21:32:33 +00:00
$nav["Friends"]["Listing"] = route('settings.friends.listing');
$nav["Friends"]["Requests"] = route('settings.friends.requests');
2016-03-31 20:03:25 +00:00
}
// Notifications
2016-09-08 21:32:33 +00:00
$nav["Notifications"]["History"] = route('settings.notifications.history');
2016-03-31 20:03:25 +00:00
// Appearance
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::CHANGE_AVATAR)) {
2016-09-08 21:32:33 +00:00
$nav["Appearance"]["Avatar"] = route('settings.appearance.avatar');
2016-03-31 20:03:25 +00:00
}
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::CHANGE_BACKGROUND)) {
2016-09-08 21:32:33 +00:00
$nav["Appearance"]["Background"] = route('settings.appearance.background');
2016-03-31 20:03:25 +00:00
}
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::CHANGE_HEADER)) {
2016-09-08 21:32:33 +00:00
$nav["Appearance"]["Header"] = route('settings.appearance.header');
2016-03-31 20:03:25 +00:00
}
if ((
2016-08-07 14:10:27 +00:00
CurrentSession::$user->page
&& CurrentSession::$user->permission(Site::CHANGE_USERPAGE)
) || CurrentSession::$user->permission(Site::CREATE_USERPAGE)) {
2016-09-08 21:32:33 +00:00
$nav["Appearance"]["Userpage"] = route('settings.appearance.userpage');
2016-03-31 20:03:25 +00:00
}
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::CHANGE_SIGNATURE)) {
2016-09-08 21:32:33 +00:00
$nav["Appearance"]["Signature"] = route('settings.appearance.signature');
2016-03-31 20:03:25 +00:00
}
// Advanced
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::MANAGE_SESSIONS)) {
2016-09-08 21:32:33 +00:00
$nav["Advanced"]["Sessions"] = route('settings.advanced.sessions');
2016-03-31 20:03:25 +00:00
}
2016-08-07 14:10:27 +00:00
if (CurrentSession::$user->permission(Site::DEACTIVATE_ACCOUNT)) {
2016-09-08 21:32:33 +00:00
$nav["Advanced"]["Deactivate"] = route('settings.advanced.deactivate');
2016-03-31 20:03:25 +00:00
}
return $nav;
}
}