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

98 lines
3.4 KiB
PHP
Raw Normal View History

<?php
/**
* Holds the base settings controller.
* @package Sakura
*/
namespace Sakura\Controllers\Settings;
2016-03-31 20:03:25 +00:00
use Sakura\ActiveUser;
use Sakura\Controllers\Controller as BaseController;
2016-03-31 20:03:25 +00:00
use Sakura\Perms\Site;
use Sakura\Router;
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-03-31 20:03:25 +00:00
if (ActiveUser::$user->permission(Site::ALTER_PROFILE)) {
2016-08-02 20:35:12 +00:00
$nav["Account"]["Profile"] = Router::route('settings.account.profile');
}
if (ActiveUser::$user->permission(Site::CHANGE_EMAIL)) {
$nav["Account"]["E-mail address"] = Router::route('settings.account.email');
}
if (ActiveUser::$user->permission(Site::CHANGE_USERNAME)) {
$nav["Account"]["Username"] = Router::route('settings.account.username');
}
if (ActiveUser::$user->permission(Site::CHANGE_USERTITLE)) {
$nav["Account"]["Title"] = Router::route('settings.account.title');
}
if (ActiveUser::$user->permission(Site::CHANGE_PASSWORD)) {
$nav["Account"]["Password"] = Router::route('settings.account.password');
}
if (ActiveUser::$user->permission(Site::ALTER_RANKS)) {
$nav["Account"]["Ranks"] = Router::route('settings.account.ranks');
2016-03-31 20:03:25 +00:00
}
// Friends
if (ActiveUser::$user->permission(Site::MANAGE_FRIENDS)) {
$nav["Friends"]["Listing"] = Router::route('settings.friends.listing');
$nav["Friends"]["Requests"] = Router::route('settings.friends.requests');
}
// Notifications
$nav["Notifications"]["History"] = Router::route('settings.notifications.history');
// Appearance
if (ActiveUser::$user->permission(Site::CHANGE_AVATAR)) {
$nav["Appearance"]["Avatar"] = Router::route('settings.appearance.avatar');
}
if (ActiveUser::$user->permission(Site::CHANGE_BACKGROUND)) {
$nav["Appearance"]["Background"] = Router::route('settings.appearance.background');
}
if (ActiveUser::$user->permission(Site::CHANGE_HEADER)) {
$nav["Appearance"]["Header"] = Router::route('settings.appearance.header');
}
if ((
ActiveUser::$user->page
&& ActiveUser::$user->permission(Site::CHANGE_USERPAGE)
) || ActiveUser::$user->permission(Site::CREATE_USERPAGE)) {
$nav["Appearance"]["Userpage"] = Router::route('settings.appearance.userpage');
}
if (ActiveUser::$user->permission(Site::CHANGE_SIGNATURE)) {
$nav["Appearance"]["Signature"] = Router::route('settings.appearance.signature');
}
// Advanced
if (ActiveUser::$user->permission(Site::MANAGE_SESSIONS)) {
$nav["Advanced"]["Sessions"] = Router::route('settings.advanced.sessions');
}
if (ActiveUser::$user->permission(Site::DEACTIVATE_ACCOUNT)) {
$nav["Advanced"]["Deactivate"] = Router::route('settings.advanced.deactivate');
}
return $nav;
}
}