2016-03-28 01:18:59 +00:00
|
|
|
<?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;
|
|
|
|
use Sakura\Router;
|
2016-04-01 21:44:31 +00:00
|
|
|
use Sakura\Template;
|
2016-03-28 01:18:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-03-28 01:18:59 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2016-08-02 20:35:12 +00:00
|
|
|
Template::vars(['navigation' => $this->navigation()]);
|
2016-03-28 01:18:59 +00:00
|
|
|
}
|
|
|
|
|
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-08-02 20:35:12 +00:00
|
|
|
$nav["Account"]["Profile"] = Router::route('settings.account.profile');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_EMAIL)) {
|
2016-08-02 20:35:12 +00:00
|
|
|
$nav["Account"]["E-mail address"] = Router::route('settings.account.email');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_USERNAME)) {
|
2016-08-02 20:35:12 +00:00
|
|
|
$nav["Account"]["Username"] = Router::route('settings.account.username');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_USERTITLE)) {
|
2016-08-02 20:35:12 +00:00
|
|
|
$nav["Account"]["Title"] = Router::route('settings.account.title');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_PASSWORD)) {
|
2016-08-02 20:35:12 +00:00
|
|
|
$nav["Account"]["Password"] = Router::route('settings.account.password');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::ALTER_RANKS)) {
|
2016-08-02 20:35:12 +00:00
|
|
|
$nav["Account"]["Ranks"] = Router::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-03-31 20:03:25 +00:00
|
|
|
$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
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_AVATAR)) {
|
2016-03-31 20:03:25 +00:00
|
|
|
$nav["Appearance"]["Avatar"] = Router::route('settings.appearance.avatar');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_BACKGROUND)) {
|
2016-03-31 20:03:25 +00:00
|
|
|
$nav["Appearance"]["Background"] = Router::route('settings.appearance.background');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_HEADER)) {
|
2016-03-31 20:03:25 +00:00
|
|
|
$nav["Appearance"]["Header"] = Router::route('settings.appearance.header');
|
|
|
|
}
|
|
|
|
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-03-31 20:03:25 +00:00
|
|
|
$nav["Appearance"]["Userpage"] = Router::route('settings.appearance.userpage');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::CHANGE_SIGNATURE)) {
|
2016-03-31 20:03:25 +00:00
|
|
|
$nav["Appearance"]["Signature"] = Router::route('settings.appearance.signature');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Advanced
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::MANAGE_SESSIONS)) {
|
2016-03-31 20:03:25 +00:00
|
|
|
$nav["Advanced"]["Sessions"] = Router::route('settings.advanced.sessions');
|
|
|
|
}
|
2016-08-07 14:10:27 +00:00
|
|
|
if (CurrentSession::$user->permission(Site::DEACTIVATE_ACCOUNT)) {
|
2016-03-31 20:03:25 +00:00
|
|
|
$nav["Advanced"]["Deactivate"] = Router::route('settings.advanced.deactivate');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $nav;
|
|
|
|
}
|
2016-03-28 01:18:59 +00:00
|
|
|
}
|