Removed legacy functions

This commit is contained in:
Marcin Kurczewski 2014-05-15 10:32:53 +02:00
parent 22b18bfbc9
commit e84f8096bd
79 changed files with 211 additions and 223 deletions

View file

@ -1,6 +1,6 @@
<?php <?php
require_once 'src/core.php'; require_once 'src/core.php';
$config = getConfig(); $config = Core::getConfig();
$fontsPath = TextHelper::absolutePath($config->main->mediaPath . DS . 'fonts'); $fontsPath = TextHelper::absolutePath($config->main->mediaPath . DS . 'fonts');
$libPath = TextHelper::absolutePath($config->main->mediaPath . DS . 'lib'); $libPath = TextHelper::absolutePath($config->main->mediaPath . DS . 'lib');

View file

@ -2,12 +2,12 @@
require_once '../src/core.php'; require_once '../src/core.php';
$query = rtrim($_SERVER['REQUEST_URI'], '/'); $query = rtrim($_SERVER['REQUEST_URI'], '/');
$context = getContext(); $context = Core::getContext();
$context->query = $query; $context->query = $query;
function renderView() function renderView()
{ {
$context = getContext(); $context = Core::getContext();
\Chibi\View::render($context->layoutName, $context); \Chibi\View::render($context->layoutName, $context);
} }
@ -16,7 +16,7 @@ $context->simpleActionName = null;
\Chibi\Router::setObserver(function($route, $args) \Chibi\Router::setObserver(function($route, $args)
{ {
$context = getContext(); $context = Core::getContext();
$context->route = $route; $context->route = $route;
list ($className, $methodName) = $route->destination; list ($className, $methodName) = $route->destination;
@ -36,7 +36,7 @@ $context->simpleActionName = null;
$context->simpleActionName); $context->simpleActionName);
}); });
Assets::setTitle($config->main->title); Assets::setTitle(Core::getConfig()->main->title);
$context->handleExceptions = false; $context->handleExceptions = false;
$context->json = isset($_GET['json']); $context->json = isset($_GET['json']);

View file

@ -7,7 +7,7 @@ class Access
public static function init() public static function init()
{ {
self::$privileges = []; self::$privileges = [];
foreach (getConfig()->privileges as $key => $minAccessRankName) foreach (Core::getConfig()->privileges as $key => $minAccessRankName)
{ {
if (strpos($key, '.') === false) if (strpos($key, '.') === false)
$key .= '.'; $key .= '.';

View file

@ -47,6 +47,6 @@ class AddCommentJob extends AbstractJob
public function isConfirmedEmailRequired() public function isConfirmedEmailRequired()
{ {
return getConfig()->registration->needEmailForCommenting; return Core::getConfig()->registration->needEmailForCommenting;
} }
} }

View file

@ -6,7 +6,7 @@ class ListCommentsJob extends AbstractJob implements IPagedJob
public function __construct() public function __construct()
{ {
$this->pager = new JobPager($this); $this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->comments->commentsPerPage); $this->pager->setPageSize(Core::getConfig()->comments->commentsPerPage);
} }
public function getPager() public function getPager()

View file

@ -53,6 +53,6 @@ class PreviewCommentJob extends AbstractJob
public function isConfirmedEmailRequired() public function isConfirmedEmailRequired()
{ {
return getConfig()->registration->needEmailForCommenting; return Core::getConfig()->registration->needEmailForCommenting;
} }
} }

View file

@ -6,7 +6,7 @@ class GetLogJob extends AbstractJob implements IPagedJob
public function __construct() public function __construct()
{ {
$this->pager = new JobPager($this); $this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->logsPerPage); $this->pager->setPageSize(Core::getConfig()->browsing->logsPerPage);
} }
public function getPager() public function getPager()
@ -26,7 +26,7 @@ class GetLogJob extends AbstractJob implements IPagedJob
//parse input //parse input
$page = max(1, intval($page)); $page = max(1, intval($page));
$name = str_replace(['/', '\\'], '', $name); //paranoia mode $name = str_replace(['/', '\\'], '', $name); //paranoia mode
$path = TextHelper::absolutePath(dirname(getConfig()->main->logsPath) . DS . $name); $path = TextHelper::absolutePath(dirname(Core::getConfig()->main->logsPath) . DS . $name);
if (!file_exists($path)) if (!file_exists($path))
throw new SimpleNotFoundException('Specified log doesn\'t exist'); throw new SimpleNotFoundException('Specified log doesn\'t exist');

View file

@ -3,7 +3,7 @@ class ListLogsJob extends AbstractJob
{ {
public function execute() public function execute()
{ {
$path = TextHelper::absolutePath(getConfig()->main->logsPath); $path = TextHelper::absolutePath(Core::getConfig()->main->logsPath);
$logs = []; $logs = [];
foreach (glob(dirname($path) . DS . '*.log') as $log) foreach (glob(dirname($path) . DS . '*.log') as $log)

View file

@ -31,7 +31,7 @@ class AddPostJob extends AbstractJob
PostModel::save($post); PostModel::save($post);
Logger::log('{user} added {post} (tags: {tags}, safety: {safety}, source: {source})', [ Logger::log('{user} added {post} (tags: {tags}, safety: {safety}, source: {source})', [
'user' => ($anonymous and !getConfig()->misc->logAnonymousUploads) 'user' => ($anonymous and !Core::getConfig()->misc->logAnonymousUploads)
? TextHelper::reprUser(UserModel::getAnonymousName()) ? TextHelper::reprUser(UserModel::getAnonymousName())
: TextHelper::reprUser(Auth::getCurrentUser()), : TextHelper::reprUser(Auth::getCurrentUser()),
'post' => TextHelper::reprPost($post), 'post' => TextHelper::reprPost($post),
@ -56,6 +56,6 @@ class AddPostJob extends AbstractJob
public function isConfirmedEmailRequired() public function isConfirmedEmailRequired()
{ {
return getConfig()->registration->needEmailForUploading; return Core::getConfig()->registration->needEmailForUploading;
} }
} }

View file

@ -11,7 +11,7 @@ class GetPostContentJob extends AbstractJob
public function execute() public function execute()
{ {
$post = $this->postRetriever->retrieve(); $post = $this->postRetriever->retrieve();
$config = getConfig(); $config = Core::getConfig();
$path = $post->tryGetWorkingFullPath(); $path = $post->tryGetWorkingFullPath();
if (!$path) if (!$path)

View file

@ -30,7 +30,7 @@ class GetPostThumbJob extends AbstractJob
if (!$path) if (!$path)
{ {
$path = getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'; $path = Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg';
$path = TextHelper::absolutePath($path); $path = TextHelper::absolutePath($path);
} }
} }

View file

@ -6,7 +6,7 @@ class ListPostsJob extends AbstractJob implements IPagedJob
public function __construct() public function __construct()
{ {
$this->pager = new JobPager($this); $this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->postsPerPage); $this->pager->setPageSize(Core::getConfig()->browsing->postsPerPage);
} }
public function getPager() public function getPager()

View file

@ -6,7 +6,7 @@ class ListRelatedTagsJob extends AbstractJob implements IPagedJob
public function __construct() public function __construct()
{ {
$this->pager = new JobPager($this); $this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->tagsRelated); $this->pager->setPageSize(Core::getConfig()->browsing->tagsRelated);
} }
public function getPager() public function getPager()

View file

@ -6,7 +6,7 @@ class ListTagsJob extends AbstractJob implements IPagedJob
public function __construct() public function __construct()
{ {
$this->pager = new JobPager($this); $this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->tagsPerPage); $this->pager->setPageSize(Core::getConfig()->browsing->tagsPerPage);
} }
public function getPager() public function getPager()

View file

@ -54,7 +54,7 @@ class ActivateUserEmailJob extends AbstractJob
public static function sendEmail($user) public static function sendEmail($user)
{ {
$regConfig = getConfig()->registration; $regConfig = Core::getConfig()->registration;
if (!$regConfig->confirmationEmailEnabled) if (!$regConfig->confirmationEmailEnabled)
{ {

View file

@ -10,7 +10,7 @@ class EditUserEmailJob extends AbstractJob
public function execute() public function execute()
{ {
if (getConfig()->registration->needEmailForRegistering) if (Core::getConfig()->registration->needEmailForRegistering)
if (!$this->hasArgument(JobArgs::ARG_NEW_EMAIL) or empty($this->getArgument(JobArgs::ARG_NEW_EMAIL))) if (!$this->hasArgument(JobArgs::ARG_NEW_EMAIL) or empty($this->getArgument(JobArgs::ARG_NEW_EMAIL)))
throw new SimpleException('E-mail address is required - you will be sent confirmation e-mail.'); throw new SimpleException('E-mail address is required - you will be sent confirmation e-mail.');

View file

@ -6,7 +6,7 @@ class ListUsersJob extends AbstractJob implements IPagedJob
public function __construct() public function __construct()
{ {
$this->pager = new JobPager($this); $this->pager = new JobPager($this);
$this->pager->setPageSize(getConfig()->browsing->usersPerPage); $this->pager->setPageSize(Core::getConfig()->browsing->usersPerPage);
} }
public function getPager() public function getPager()

View file

@ -58,7 +58,7 @@ class PasswordResetJob extends AbstractJob
public static function sendEmail($user) public static function sendEmail($user)
{ {
$regConfig = getConfig()->registration; $regConfig = Core::getConfig()->registration;
$mail = new Mail(); $mail = new Mail();
$mail->body = $regConfig->passwordResetEmailBody; $mail->body = $regConfig->passwordResetEmailBody;

View file

@ -10,8 +10,8 @@ class Auth
public static function login($name, $password, $remember) public static function login($name, $password, $remember)
{ {
$config = getConfig(); $config = Core::getConfig();
$context = getContext(); $context = Core::getContext();
$user = UserModel::tryGetByEmail($name); $user = UserModel::tryGetByEmail($name);
if ($user === null) if ($user === null)

View file

@ -10,7 +10,7 @@ class AuthController
public function loginAction() public function loginAction()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'auth-login'; $context->viewName = 'auth-login';
$context->handleExceptions = true; $context->handleExceptions = true;
@ -33,7 +33,7 @@ class AuthController
return; return;
if (\Chibi\Util\Headers::getCode() != 200) if (\Chibi\Util\Headers::getCode() != 200)
return; return;
$context = getContext(); $context = Core::getContext();
if ($context->simpleControllerName == 'auth') if ($context->simpleControllerName == 'auth')
return; return;
$_SESSION['login-redirect-url'] = $context->query; $_SESSION['login-redirect-url'] = $context->query;

View file

@ -9,7 +9,7 @@ class CommentController
JobArgs::ARG_PAGE_NUMBER => $page, JobArgs::ARG_PAGE_NUMBER => $page,
]); ]);
$context = getContext(); $context = Core::getContext();
$context->transport->posts = $ret->entities; $context->transport->posts = $ret->entities;
$context->transport->paginator = $ret; $context->transport->paginator = $ret;
} }
@ -25,7 +25,7 @@ class CommentController
JobArgs::ARG_NEW_TEXT => InputHelper::get('text') JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]); ]);
getContext()->transport->textPreview = $comment->getTextMarkdown(); Core::getContext()->transport->textPreview = $comment->getTextMarkdown();
} }
Api::run( Api::run(
@ -38,7 +38,7 @@ class CommentController
public function editView($id) public function editView($id)
{ {
getContext()->transport->comment = CommentModel::getById($id); Core::getContext()->transport->comment = CommentModel::getById($id);
} }
public function editAction($id) public function editAction($id)
@ -52,7 +52,7 @@ class CommentController
JobArgs::ARG_NEW_TEXT => InputHelper::get('text') JobArgs::ARG_NEW_TEXT => InputHelper::get('text')
]); ]);
getContext()->transport->textPreview = $comment->getTextMarkdown(); Core::getContext()->transport->textPreview = $comment->getTextMarkdown();
} }
Api::run( Api::run(

View file

@ -4,12 +4,12 @@ class LogController
public function listView() public function listView()
{ {
$ret = Api::run(new ListLogsJob(), []); $ret = Api::run(new ListLogsJob(), []);
getContext()->transport->logs = $ret; Core::getContext()->transport->logs = $ret;
} }
public function logView($name, $page = 1, $filter = '') public function logView($name, $page = 1, $filter = '')
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'log-view'; $context->viewName = 'log-view';
//redirect requests in form of ?query=... to canonical address //redirect requests in form of ?query=... to canonical address

View file

@ -3,7 +3,7 @@ class PostController
{ {
public function listView($query = null, $page = 1, $source = 'posts', $additionalInfo = null) public function listView($query = null, $page = 1, $source = 'posts', $additionalInfo = null)
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'post-list-wrapper'; $context->viewName = 'post-list-wrapper';
$context->source = $source; $context->source = $source;
$context->additionalInfo = $additionalInfo; $context->additionalInfo = $additionalInfo;
@ -116,7 +116,7 @@ class PostController
$post = Api::run(new GetPostJob(), [ $post = Api::run(new GetPostJob(), [
JobArgs::ARG_POST_ID => $id]); JobArgs::ARG_POST_ID => $id]);
$context = getContext()->transport->post = $post; $context = Core::getContext()->transport->post = $post;
} }
public function editAction($id) public function editAction($id)
@ -217,7 +217,7 @@ class PostController
public function genericView($id) public function genericView($id)
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'post-view'; $context->viewName = 'post-view';
$post = Api::run(new GetPostJob(), [ $post = Api::run(new GetPostJob(), [
@ -257,7 +257,7 @@ class PostController
{ {
$ret = Api::run(new GetPostContentJob(), [JobArgs::ARG_POST_NAME => $name]); $ret = Api::run(new GetPostContentJob(), [JobArgs::ARG_POST_NAME => $name]);
$context = getContext(); $context = Core::getContext();
$context->transport->cacheDaysToLive = 14; $context->transport->cacheDaysToLive = 14;
$context->transport->customFileName = $ret->fileName; $context->transport->customFileName = $ret->fileName;
$context->transport->mimeType = $ret->mimeType; $context->transport->mimeType = $ret->mimeType;
@ -271,7 +271,7 @@ class PostController
{ {
$ret = Api::run(new GetPostThumbJob(), [JobArgs::ARG_POST_NAME => $name]); $ret = Api::run(new GetPostThumbJob(), [JobArgs::ARG_POST_NAME => $name]);
$context = getContext(); $context = Core::getContext();
$context->transport->cacheDaysToLive = 365; $context->transport->cacheDaysToLive = 365;
$context->transport->customFileName = $ret->fileName; $context->transport->customFileName = $ret->fileName;
$context->transport->mimeType = 'image/jpeg'; $context->transport->mimeType = 'image/jpeg';

View file

@ -3,7 +3,7 @@ class StaticPagesController
{ {
public function mainPageView() public function mainPageView()
{ {
$context = getContext(); $context = Core::getContext();
$context->transport->postCount = PostModel::getCount(); $context->transport->postCount = PostModel::getCount();
$context->viewName = 'static-main'; $context->viewName = 'static-main';
$context->transport->postSpaceUsage = PostModel::getSpaceUsage(); $context->transport->postSpaceUsage = PostModel::getSpaceUsage();
@ -21,8 +21,8 @@ class StaticPagesController
public function helpView($tab = null) public function helpView($tab = null)
{ {
$config = getConfig(); $config = Core::getConfig();
$context = getContext(); $context = Core::getContext();
if (empty($config->help->paths) or empty($config->help->title)) if (empty($config->help->paths) or empty($config->help->title))
throw new SimpleException('Help is disabled'); throw new SimpleException('Help is disabled');

View file

@ -10,7 +10,7 @@ class TagController
JobArgs::ARG_QUERY => $filter, JobArgs::ARG_QUERY => $filter,
]); ]);
$context = getContext(); $context = Core::getContext();
$context->viewName = 'tag-list-wrapper'; $context->viewName = 'tag-list-wrapper';
$context->highestUsage = TagSearchService::getMostUsedTag()->getPostCount(); $context->highestUsage = TagSearchService::getMostUsedTag()->getPostCount();
$context->filter = $filter; $context->filter = $filter;
@ -30,7 +30,7 @@ class TagController
JobArgs::ARG_PAGE_NUMBER => 1, JobArgs::ARG_PAGE_NUMBER => 1,
]); ]);
$context = getContext(); $context = Core::getContext();
$context->transport->tags = $context->transport->tags =
array_values(array_map( array_values(array_map(
function($tag) function($tag)
@ -55,7 +55,7 @@ class TagController
JobArgs::ARG_PAGE_NUMBER => 1 JobArgs::ARG_PAGE_NUMBER => 1
]); ]);
$context = getContext(); $context = Core::getContext();
$context->transport->tags = $context->transport->tags =
array_values(array_map( array_values(array_map(
function($tag) function($tag)
@ -69,13 +69,13 @@ class TagController
public function mergeView() public function mergeView()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'tag-list-wrapper'; $context->viewName = 'tag-list-wrapper';
} }
public function mergeAction() public function mergeAction()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'tag-list-wrapper'; $context->viewName = 'tag-list-wrapper';
$context->handleExceptions = true; $context->handleExceptions = true;
@ -91,13 +91,13 @@ class TagController
public function renameView() public function renameView()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'tag-list-wrapper'; $context->viewName = 'tag-list-wrapper';
} }
public function renameAction() public function renameAction()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'tag-list-wrapper'; $context->viewName = 'tag-list-wrapper';
$context->handleExceptions = true; $context->handleExceptions = true;
@ -113,7 +113,7 @@ class TagController
public function massTagRedirectView() public function massTagRedirectView()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'tag-list-wrapper'; $context->viewName = 'tag-list-wrapper';
Access::assert(new Privilege(Privilege::MassTag)); Access::assert(new Privilege(Privilege::MassTag));

View file

@ -10,7 +10,7 @@ class UserController
JobArgs::ARG_QUERY => $filter, JobArgs::ARG_QUERY => $filter,
]); ]);
$context = getContext(); $context = Core::getContext();
$context->filter = $filter; $context->filter = $filter;
$context->transport->users = $ret->entities; $context->transport->users = $ret->entities;
@ -45,7 +45,7 @@ class UserController
elseif ($tab == 'edit' and !(new EditUserJob)->canEditAnything(Auth::getCurrentUser())) elseif ($tab == 'edit' and !(new EditUserJob)->canEditAnything(Auth::getCurrentUser()))
Access::fail(); Access::fail();
$context = getContext(); $context = Core::getContext();
$context->flagged = $flagged; $context->flagged = $flagged;
$context->transport->tab = $tab; $context->transport->tab = $tab;
$context->transport->user = $user; $context->transport->user = $user;
@ -87,7 +87,7 @@ class UserController
] ]
], $identifier)); ], $identifier));
getContext()->transport->user = $user; Core::getContext()->transport->user = $user;
if ($user->getId() == Auth::getCurrentUser()->getId()) if ($user->getId() == Auth::getCurrentUser()->getId())
Auth::setCurrentUser($user); Auth::setCurrentUser($user);
@ -194,7 +194,7 @@ class UserController
public function registrationView() public function registrationView()
{ {
$context = getContext(); $context = Core::getContext();
$context->handleExceptions = true; $context->handleExceptions = true;
//check if already logged in //check if already logged in
@ -219,7 +219,7 @@ class UserController
JobArgs::ARG_NEW_EMAIL => InputHelper::get('email'), JobArgs::ARG_NEW_EMAIL => InputHelper::get('email'),
]); ]);
if (!getConfig()->registration->needEmailForRegistering and !getConfig()->registration->staffActivation) if (!Core::getConfig()->registration->needEmailForRegistering and !Core::getConfig()->registration->staffActivation)
{ {
Auth::setCurrentUser($user); Auth::setCurrentUser($user);
} }
@ -228,10 +228,10 @@ class UserController
if (Mailer::getMailCounter() > 0) if (Mailer::getMailCounter() > 0)
{ {
$message .= ' Please wait for activation e-mail.'; $message .= ' Please wait for activation e-mail.';
if (getConfig()->registration->staffActivation) if (Core::getConfig()->registration->staffActivation)
$message .= ' After this, your registration must be confirmed by staff.'; $message .= ' After this, your registration must be confirmed by staff.';
} }
elseif (getConfig()->registration->staffActivation) elseif (Core::getConfig()->registration->staffActivation)
$message .= ' Your registration must be now confirmed by staff.'; $message .= ' Your registration must be now confirmed by staff.';
Messenger::message($message); Messenger::message($message);
@ -239,14 +239,14 @@ class UserController
public function activationView() public function activationView()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'user-select'; $context->viewName = 'user-select';
Assets::setSubTitle('account activation'); Assets::setSubTitle('account activation');
} }
public function activationAction($tokenText) public function activationAction($tokenText)
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'message'; $context->viewName = 'message';
Assets::setSubTitle('account activation'); Assets::setSubTitle('account activation');
$identifier = InputHelper::get('identifier'); $identifier = InputHelper::get('identifier');
@ -265,25 +265,25 @@ class UserController
JobArgs::ARG_TOKEN => $tokenText ]); JobArgs::ARG_TOKEN => $tokenText ]);
$message = 'Activation completed successfully.'; $message = 'Activation completed successfully.';
if (getConfig()->registration->staffActivation) if (Core::getConfig()->registration->staffActivation)
$message .= ' However, your account still must be confirmed by staff.'; $message .= ' However, your account still must be confirmed by staff.';
Messenger::message($message); Messenger::message($message);
if (!getConfig()->registration->staffActivation) if (!Core::getConfig()->registration->staffActivation)
Auth::setCurrentUser($user); Auth::setCurrentUser($user);
} }
} }
public function passwordResetView() public function passwordResetView()
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'user-select'; $context->viewName = 'user-select';
Assets::setSubTitle('password reset'); Assets::setSubTitle('password reset');
} }
public function passwordResetAction($tokenText) public function passwordResetAction($tokenText)
{ {
$context = getContext(); $context = Core::getContext();
$context->viewName = 'message'; $context->viewName = 'message';
Assets::setSubTitle('password reset'); Assets::setSubTitle('password reset');
$identifier = InputHelper::get('identifier'); $identifier = InputHelper::get('identifier');
@ -310,7 +310,7 @@ class UserController
private function requirePasswordConfirmation() private function requirePasswordConfirmation()
{ {
$user = getContext()->transport->user; $user = Core::getContext()->transport->user;
if (Auth::getCurrentUser()->getId() == $user->getId()) if (Auth::getCurrentUser()->getId() == $user->getId())
{ {
$suppliedPassword = InputHelper::get('current-password'); $suppliedPassword = InputHelper::get('current-password');

View file

@ -220,7 +220,7 @@ class TextHelper
public static function encrypt($text) public static function encrypt($text)
{ {
$salt = getConfig()->main->salt; $salt = Core::getConfig()->main->salt;
$alg = MCRYPT_RIJNDAEL_256; $alg = MCRYPT_RIJNDAEL_256;
$mode = MCRYPT_MODE_CBC; $mode = MCRYPT_MODE_CBC;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($alg, $mode), MCRYPT_RAND); $iv = mcrypt_create_iv(mcrypt_get_iv_size($alg, $mode), MCRYPT_RAND);
@ -231,7 +231,7 @@ class TextHelper
{ {
try try
{ {
$salt = getConfig()->main->salt; $salt = Core::getConfig()->main->salt;
list ($iv, $hash) = explode('|', $text, 2); list ($iv, $hash) = explode('|', $text, 2);
$iv = base64_decode($iv); $iv = base64_decode($iv);
$hash = base64_decode($hash); $hash = base64_decode($hash);
@ -262,7 +262,7 @@ class TextHelper
public static function absolutePath($path) public static function absolutePath($path)
{ {
if ($path{0} != DS) if ($path{0} != DS)
$path = getConfig()->rootDir . DS . $path; $path = Core::getConfig()->rootDir . DS . $path;
$path = self::cleanPath($path); $path = self::cleanPath($path);
return $path; return $path;

View file

@ -145,7 +145,7 @@ class ThumbnailHelper
throw new SimpleException('Invalid thumbnail file type'); throw new SimpleException('Invalid thumbnail file type');
} }
$config = getConfig(); $config = Core::getConfig();
switch ($config->browsing->thumbStyle) switch ($config->browsing->thumbStyle)
{ {
case 'outside': case 'outside':

View file

@ -51,7 +51,7 @@ class Logger
public static function getLogPath() public static function getLogPath()
{ {
return TextHelper::absolutePath( return TextHelper::absolutePath(
TextHelper::replaceTokens(getConfig()->main->logsPath, [ TextHelper::replaceTokens(Core::getConfig()->main->logsPath, [
'yyyy' => date('Y'), 'yyyy' => date('Y'),
'mm' => date('m'), 'mm' => date('m'),
'dd' => date('d')])); 'dd' => date('d')]));

View file

@ -6,7 +6,7 @@ class Messenger
if (empty($message)) if (empty($message))
return; return;
$context = getContext(); $context = Core::getContext();
if (!preg_match('/[.?!]$/', $message)) if (!preg_match('/[.?!]$/', $message))
$message .= '.'; $message .= '.';

View file

@ -22,7 +22,7 @@ final class CommentEntity extends AbstractEntity implements IValidatable
public function validate() public function validate()
{ {
$config = getConfig(); $config = Core::getConfig();
if (strlen($this->getText()) < $config->comments->minLength) if (strlen($this->getText()) < $config->comments->minLength)
throw new SimpleException('Comment must have at least %d characters', $config->comments->minLength); throw new SimpleException('Comment must have at least %d characters', $config->comments->minLength);

View file

@ -66,7 +66,7 @@ final class PostEntity extends AbstractEntity implements IValidatable
$this->getSafety()->validate(); $this->getSafety()->validate();
$maxSourceLength = getConfig()->posts->maxSourceLength; $maxSourceLength = Core::getConfig()->posts->maxSourceLength;
if (strlen($this->getSource()) > $maxSourceLength) if (strlen($this->getSource()) > $maxSourceLength)
throw new SimpleException('Source must have at most %d characters', $maxSourceLength); throw new SimpleException('Source must have at most %d characters', $maxSourceLength);
} }
@ -351,7 +351,7 @@ final class PostEntity extends AbstractEntity implements IValidatable
public function setCustomThumbnailFromPath($srcPath) public function setCustomThumbnailFromPath($srcPath)
{ {
$config = getConfig(); $config = Core::getConfig();
$mimeType = mime_content_type($srcPath); $mimeType = mime_content_type($srcPath);
if (!in_array($mimeType, ['image/gif', 'image/png', 'image/jpeg'])) if (!in_array($mimeType, ['image/gif', 'image/png', 'image/jpeg']))
@ -366,8 +366,8 @@ final class PostEntity extends AbstractEntity implements IValidatable
public function generateThumb() public function generateThumb()
{ {
$width = getConfig()->browsing->thumbWidth; $width = Core::getConfig()->browsing->thumbWidth;
$height = getConfig()->browsing->thumbHeight; $height = Core::getConfig()->browsing->thumbHeight;
$dstPath = $this->getThumbPath($width, $height); $dstPath = $this->getThumbPath($width, $height);
if (file_exists($this->getThumbCustomSourcePath())) if (file_exists($this->getThumbCustomSourcePath()))

View file

@ -21,9 +21,9 @@ final class TagEntity extends AbstractEntity implements IValidatable
public function validate() public function validate()
{ {
$minLength = getConfig()->tags->minLength; $minLength = Core::getConfig()->tags->minLength;
$maxLength = getConfig()->tags->maxLength; $maxLength = Core::getConfig()->tags->maxLength;
$regex = getConfig()->tags->regex; $regex = Core::getConfig()->tags->regex;
$name = $this->getName(); $name = $this->getName();

View file

@ -60,7 +60,7 @@ final class UserEntity extends AbstractEntity implements IValidatable
private function validateUserName() private function validateUserName()
{ {
$userName = $this->getName(); $userName = $this->getName();
$config = getConfig(); $config = Core::getConfig();
$otherUser = UserModel::tryGetByName($userName); $otherUser = UserModel::tryGetByName($userName);
if ($otherUser !== null and $otherUser->getId() != $this->getId()) if ($otherUser !== null and $otherUser->getId() != $this->getId())
@ -90,7 +90,7 @@ final class UserEntity extends AbstractEntity implements IValidatable
if (!$this->_passwordChanged) if (!$this->_passwordChanged)
return; return;
$config = getConfig(); $config = Core::getConfig();
$passMinLength = intval($config->registration->passMinLength); $passMinLength = intval($config->registration->passMinLength);
$passRegex = $config->registration->passRegex; $passRegex = $config->registration->passRegex;
@ -131,7 +131,7 @@ final class UserEntity extends AbstractEntity implements IValidatable
private function throwDuplicateUserError($otherUser, $reason) private function throwDuplicateUserError($otherUser, $reason)
{ {
$config = getConfig(); $config = Core::getConfig();
if (!$otherUser->getConfirmedEmail() if (!$otherUser->getConfirmedEmail()
and isset($config->registration->needEmailForRegistering) and isset($config->registration->needEmailForRegistering)

View file

@ -277,7 +277,7 @@ final class PostModel extends AbstractCrudModel
private static function getThumbPathTokenized($text, $name) private static function getThumbPathTokenized($text, $name)
{ {
return TextHelper::absolutePath(TextHelper::replaceTokens($text, [ return TextHelper::absolutePath(TextHelper::replaceTokens($text, [
'fullpath' => getConfig()->main->thumbsPath . DS . $name])); 'fullpath' => Core::getConfig()->main->thumbsPath . DS . $name]));
} }
public static function tryGetWorkingFullPath($name) public static function tryGetWorkingFullPath($name)
@ -291,7 +291,7 @@ final class PostModel extends AbstractCrudModel
public static function getFullPath($name) public static function getFullPath($name)
{ {
return TextHelper::absolutePath(getConfig()->main->filesPath . DS . $name); return TextHelper::absolutePath(Core::getConfig()->main->filesPath . DS . $name);
} }
@ -303,7 +303,7 @@ final class PostModel extends AbstractCrudModel
return PropertyModel::get(PropertyModel::PostSpaceUsage); return PropertyModel::get(PropertyModel::PostSpaceUsage);
$totalBytes = 0; $totalBytes = 0;
$paths = [getConfig()->main->filesPath, getConfig()->main->thumbsPath]; $paths = [Core::getConfig()->main->filesPath, Core::getConfig()->main->thumbsPath];
foreach ($paths as $path) foreach ($paths as $path)
{ {
@ -332,7 +332,7 @@ final class PostModel extends AbstractCrudModel
public static function featureRandomPostIfNecessary() public static function featureRandomPostIfNecessary()
{ {
$config = getConfig(); $config = Core::getConfig();
$featuredPostRotationTime = $config->misc->featuredPostMaxDays * 24 * 3600; $featuredPostRotationTime = $config->misc->featuredPostMaxDays * 24 * 3600;
$featuredPostId = PropertyModel::get(PropertyModel::FeaturedPostId); $featuredPostId = PropertyModel::get(PropertyModel::FeaturedPostId);

View file

@ -9,7 +9,7 @@ class PostSearchParser extends AbstractSearchParser
protected function processSetup(&$tokens) protected function processSetup(&$tokens)
{ {
$config = getConfig(); $config = Core::getConfig();
$this->tags = []; $this->tags = [];
$crit = new Sql\ConjunctionFunctor(); $crit = new Sql\ConjunctionFunctor();

View file

@ -188,7 +188,7 @@ final class UserModel extends AbstractCrudModel
public static function hashPassword($pass, $salt2) public static function hashPassword($pass, $salt2)
{ {
$salt1 = getConfig()->main->salt; $salt1 = Core::getConfig()->main->salt;
return sha1($salt1 . $salt2 . $pass); return sha1($salt1 . $salt2 . $pass);
} }
} }

View file

@ -111,13 +111,13 @@ class UserSettings implements IValidatable
$this->set(self::SETTING_SAFETY, (new PostSafety(PostSafety::Safe))->toInteger()); $this->set(self::SETTING_SAFETY, (new PostSafety(PostSafety::Safe))->toInteger());
if ($this->get(self::SETTING_HIDE_DISLIKED_POSTS) === null) if ($this->get(self::SETTING_HIDE_DISLIKED_POSTS) === null)
$this->set(self::SETTING_HIDE_DISLIKED_POSTS, !(bool) getConfig()->browsing->showDislikedPostsDefault); $this->set(self::SETTING_HIDE_DISLIKED_POSTS, !(bool) Core::getConfig()->browsing->showDislikedPostsDefault);
if ($this->get(self::SETTING_POST_TAG_TITLES) === null) if ($this->get(self::SETTING_POST_TAG_TITLES) === null)
$this->set(self::SETTING_POST_TAG_TITLES, (bool) getConfig()->browsing->showPostTagTitlesDefault); $this->set(self::SETTING_POST_TAG_TITLES, (bool) Core::getConfig()->browsing->showPostTagTitlesDefault);
if ($this->get(self::SETTING_ENDLESS_SCROLLING) === null) if ($this->get(self::SETTING_ENDLESS_SCROLLING) === null)
$this->set(self::SETTING_ENDLESS_SCROLLING, (bool) getConfig()->browsing->endlessScrollingDefault); $this->set(self::SETTING_ENDLESS_SCROLLING, (bool) Core::getConfig()->browsing->endlessScrollingDefault);
} }
private function ensureCorrectTypes() private function ensureCorrectTypes()

View file

@ -20,7 +20,7 @@ Assets::setSubTitle('comments');
<?php <?php
$this->context->post = $post; $this->context->post = $post;
$comments = array_reverse($post->getComments()); $comments = array_reverse($post->getComments());
$commentsToDisplay = array_slice($comments, 0, getConfig()->comments->maxCommentsInList); $commentsToDisplay = array_slice($comments, 0, Core::getConfig()->comments->maxCommentsInList);
?> ?>
<?php \Chibi\View::render('post-small', $this->context) ?> <?php \Chibi\View::render('post-small', $this->context) ?>
</div> </div>

View file

@ -41,7 +41,7 @@ Assets::addScript('core.js');
<hr/> <hr/>
<div class="left"> <div class="left">
<span> <span>
<a href="<?= getConfig()->misc->githubLink ?>"> <a href="<?= Core::getConfig()->misc->githubLink ?>">
szurubooru&nbsp;<?= PropertyModel::get(PropertyModel::EngineVersion) ?> szurubooru&nbsp;<?= PropertyModel::get(PropertyModel::EngineVersion) ?>
</a> </a>
</span> </span>
@ -59,7 +59,7 @@ Assets::addScript('core.js');
</div> </div>
</footer> </footer>
<?php if (getConfig()->misc->debugQueries): ?> <?php if (Core::getConfig()->misc->debugQueries): ?>
<?= \Chibi\View::render('debug', $this->context) ?> <?= \Chibi\View::render('debug', $this->context) ?>
<?php endif ?> <?php endif ?>

View file

@ -29,7 +29,7 @@ if (!function_exists('pageUrl'))
{ {
function pageUrl($page) function pageUrl($page)
{ {
$context = getContext(); $context = Core::getContext();
$destination = $context->route->destination; $destination = $context->route->destination;
$page = max(1, min($context->transport->paginator->pageCount, $page)); $page = max(1, min($context->transport->paginator->pageCount, $page));
$params = $context->route->arguments; $params = $context->route->arguments;

View file

@ -2,7 +2,7 @@
Assets::setSubtitle('help'); Assets::setSubtitle('help');
Assets::addStylesheet('static-help.css'); Assets::addStylesheet('static-help.css');
$tabs = getConfig()->help->subTitles; $tabs = Core::getConfig()->help->subTitles;
$firstTab = !empty($tabs) ? array_keys($tabs)[0] : null; $firstTab = !empty($tabs) ? array_keys($tabs)[0] : null;
$showTabs = count($tabs) > 1; $showTabs = count($tabs) > 1;
?> ?>

View file

@ -4,7 +4,7 @@ Assets::addStylesheet('static-main.css');
?> ?>
<div id="welcome"> <div id="welcome">
<h1><?= getConfig()->main->title ?></h1> <h1><?= Core::getConfig()->main->title ?></h1>
<p> <p>
<span> <span>
<?php printf('serving %d posts (%s)', <?php printf('serving %d posts (%s)',

View file

@ -85,10 +85,10 @@
\Chibi\Router::linkTo(['AuthController', 'logoutAction'])); \Chibi\Router::linkTo(['AuthController', 'logoutAction']));
} }
if (!empty(getConfig()->help->title)) if (!empty(Core::getConfig()->help->title))
{ {
$registerNavItem( $registerNavItem(
getConfig()->help->title, Core::getConfig()->help->title,
\Chibi\Router::linkTo(['StaticPagesController', 'helpView']), \Chibi\Router::linkTo(['StaticPagesController', 'helpView']),
$activeController == 'static-pages' and $activeAction == 'help'); $activeController == 'static-pages' and $activeAction == 'help');
} }

View file

@ -14,7 +14,7 @@ Assets::addStylesheet('user-list.css');
'order:date,desc' => 'Sort new&rarr;old', 'order:date,desc' => 'Sort new&rarr;old',
]; ];
if (getConfig()->registration->staffActivation) if (Core::getConfig()->registration->staffActivation)
$filters['pending'] = 'Pending staff review'; $filters['pending'] = 'Pending staff review';
?> ?>

View file

@ -104,7 +104,7 @@ Assets::addStylesheet('user-view.css');
if (Access::check(new Privilege(Privilege::AcceptUserRegistration)) if (Access::check(new Privilege(Privilege::AcceptUserRegistration))
and !$this->context->transport->user->isStaffConfirmed() and !$this->context->transport->user->isStaffConfirmed()
and getConfig()->registration->staffActivation) and Core::getConfig()->registration->staffActivation)
{ {
$options []= $options []=
[ [

View file

@ -37,7 +37,6 @@ final class Core
static function prepareConfig($testEnvironment) static function prepareConfig($testEnvironment)
{ {
//load config manually //load config manually
global $config;
global $rootDir; global $rootDir;
$configPaths = []; $configPaths = [];
@ -178,16 +177,5 @@ final class Core
} }
} }
//legacy
function getConfig()
{
return Core::getConfig();
}
function getContext()
{
return Core::getContext();
}
Core::prepareConfig(false); Core::prepareConfig(false);
Core::prepareEnvironment(false); Core::prepareEnvironment(false);

View file

@ -10,7 +10,7 @@ class TestSupport
public function getPath($assetName) public function getPath($assetName)
{ {
return TextHelper::absolutePath(getConfig()->rootDir . DS . 'tests' . DS . 'Files' . DS . $assetName); return TextHelper::absolutePath(Core::getConfig()->rootDir . DS . 'tests' . DS . 'Files' . DS . $assetName);
} }
public function assertTagNames($post, $tags) public function assertTagNames($post, $tags)

View file

@ -19,7 +19,7 @@ abstract class AbstractFullApiTest extends AbstractTest
protected function getAllJobs() protected function getAllJobs()
{ {
$pathToJobs = getConfig()->rootDir . DS . 'src' . DS . 'Api' . DS . 'Jobs'; $pathToJobs = Core::getConfig()->rootDir . DS . 'src' . DS . 'Api' . DS . 'Jobs';
$directory = new RecursiveDirectoryIterator($pathToJobs); $directory = new RecursiveDirectoryIterator($pathToJobs);
$iterator = new RecursiveIteratorIterator($directory); $iterator = new RecursiveIteratorIterator($directory);
$regex = new RegexIterator($iterator, '/^.+Job\.php$/i'); $regex = new RegexIterator($iterator, '/^.+Job\.php$/i');

View file

@ -33,13 +33,13 @@ class AbstractTest
protected function grantAccess($privilege) protected function grantAccess($privilege)
{ {
getConfig()->privileges->$privilege = 'anonymous'; Core::getConfig()->privileges->$privilege = 'anonymous';
Access::init(); Access::init();
} }
protected function revokeAccess($privilege) protected function revokeAccess($privilege)
{ {
getConfig()->privileges->$privilege = 'nobody'; Core::getConfig()->privileges->$privilege = 'nobody';
Access::init(); Access::init();
} }
} }

View file

@ -60,7 +60,7 @@ class ApiAuthTest extends AbstractFullApiTest
public function testAuthEnforcing() public function testAuthEnforcing()
{ {
getConfig()->registration->needEmailForCommenting = false; Core::getConfig()->registration->needEmailForCommenting = false;
$this->grantAccess('addComment'); $this->grantAccess('addComment');
$comment = $this->commentMocker->mockSingle(); $comment = $this->commentMocker->mockSingle();

View file

@ -3,8 +3,8 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
{ {
public function testRegularEmailRequirements() public function testRegularEmailRequirements()
{ {
getConfig()->registration->needEmailForCommenting = true; Core::getConfig()->registration->needEmailForCommenting = true;
getConfig()->registration->needEmailForUploading = true; Core::getConfig()->registration->needEmailForUploading = true;
$this->testRegularEmailRequirement(new AcceptUserRegistrationJob()); $this->testRegularEmailRequirement(new AcceptUserRegistrationJob());
$this->testRegularEmailRequirement(new ActivateUserEmailJob()); $this->testRegularEmailRequirement(new ActivateUserEmailJob());
@ -68,10 +68,10 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
{ {
$this->testedJobs []= $job; $this->testedJobs []= $job;
getConfig()->registration->needEmailForCommenting = false; Core::getConfig()->registration->needEmailForCommenting = false;
$this->assert->areEqual(false, $job->isConfirmedEmailRequired()); $this->assert->areEqual(false, $job->isConfirmedEmailRequired());
getConfig()->registration->needEmailForCommenting = true; Core::getConfig()->registration->needEmailForCommenting = true;
$this->assert->areEqual(true, $job->isConfirmedEmailRequired()); $this->assert->areEqual(true, $job->isConfirmedEmailRequired());
} }
@ -81,10 +81,10 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
$this->testedJobs []= $job; $this->testedJobs []= $job;
getConfig()->registration->needEmailForUploading = false; Core::getConfig()->registration->needEmailForUploading = false;
$this->assert->areEqual(false, $job->isConfirmedEmailRequired()); $this->assert->areEqual(false, $job->isConfirmedEmailRequired());
getConfig()->registration->needEmailForUploading = true; Core::getConfig()->registration->needEmailForUploading = true;
$this->assert->areEqual(true, $job->isConfirmedEmailRequired()); $this->assert->areEqual(true, $job->isConfirmedEmailRequired());
} }
@ -92,7 +92,7 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
{ {
$this->grantAccess('addComment'); $this->grantAccess('addComment');
$this->login($this->userMocker->mockSingle()); $this->login($this->userMocker->mockSingle());
getConfig()->registration->needEmailForCommenting = true; Core::getConfig()->registration->needEmailForCommenting = true;
$this->assert->throws(function() $this->assert->throws(function()
{ {
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();

View file

@ -195,7 +195,7 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->assert->throws(function() $this->assert->throws(function()
{ {
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
getConfig()->registration->needEmailForCommenting = false; Core::getConfig()->registration->needEmailForCommenting = false;
return Api::run( return Api::run(
new AddCommentJob(), new AddCommentJob(),
[ [

View file

@ -3,7 +3,7 @@ class ActivateUserEmailJobTest extends AbstractTest
{ {
public function testSending() public function testSending()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -35,7 +35,7 @@ class ActivateUserEmailJobTest extends AbstractTest
public function testConfirming() public function testConfirming()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -74,7 +74,7 @@ class ActivateUserEmailJobTest extends AbstractTest
public function testUsingTokenTwice() public function testUsingTokenTwice()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();

View file

@ -31,7 +31,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->minLength)); $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength));
}); });
} }
@ -40,7 +40,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->maxLength)); $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength));
}); });
} }
@ -49,7 +49,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->throws(function() $this->assert->throws(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->minLength - 1)); $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1));
}, 'Comment must have at least'); }, 'Comment must have at least');
} }
@ -58,7 +58,7 @@ class AddCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->throws(function() $this->assert->throws(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1)); $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1));
}, 'Comment must have at most'); }, 'Comment must have at most');
} }
@ -109,7 +109,7 @@ class AddCommentJobTest extends AbstractTest
protected function prepare() protected function prepare()
{ {
getConfig()->registration->needEmailForCommenting = false; Core::getConfig()->registration->needEmailForCommenting = false;
$this->grantAccess('addComment'); $this->grantAccess('addComment');
$this->login($this->userMocker->mockSingle()); $this->login($this->userMocker->mockSingle());
} }

View file

@ -154,6 +154,6 @@ class AddPostJobTest extends AbstractTest
protected function prepare() protected function prepare()
{ {
getConfig()->registration->needEmailForUploading = false; Core::getConfig()->registration->needEmailForUploading = false;
} }
} }

View file

@ -45,14 +45,14 @@ class AddUserJobTest extends AbstractTest
new AddUserJob(), new AddUserJob(),
[ [
JobArgs::ARG_NEW_USER_NAME => 'dummy', JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1), JobArgs::ARG_NEW_PASSWORD => str_repeat('s', Core::getConfig()->registration->passMinLength - 1),
]); ]);
}, 'Password must have at least'); }, 'Password must have at least');
} }
public function testSkippingMailingUponFailing() //yo dog public function testSkippingMailingUponFailing() //yo dog
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());
@ -64,7 +64,7 @@ class AddUserJobTest extends AbstractTest
new AddUserJob(), new AddUserJob(),
[ [
JobArgs::ARG_NEW_USER_NAME => 'dummy', JobArgs::ARG_NEW_USER_NAME => 'dummy',
JobArgs::ARG_NEW_PASSWORD => str_repeat('s', getConfig()->registration->passMinLength - 1), JobArgs::ARG_NEW_PASSWORD => str_repeat('s', Core::getConfig()->registration->passMinLength - 1),
JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov', JobArgs::ARG_NEW_EMAIL => 'godzilla@whitestar.gov',
]); ]);
}, 'Password must have at least'); }, 'Password must have at least');
@ -89,7 +89,7 @@ class AddUserJobTest extends AbstractTest
$this->assert->isTrue(strlen($user->getPasswordHash()) < 100); $this->assert->isTrue(strlen($user->getPasswordHash()) < 100);
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$this->assert->doesNotThrow(function() use ($pass) $this->assert->doesNotThrow(function() use ($pass)
{ {
Auth::login('dummy', $pass, false); Auth::login('dummy', $pass, false);
@ -143,11 +143,11 @@ class AddUserJobTest extends AbstractTest
public function testEmailsMixedConfirmation() public function testEmailsMixedConfirmation()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'admin'; Core::getConfig()->privileges->changeUserEmailNoConfirm = 'admin';
$this->grantAccess('registerAccount'); $this->grantAccess('registerAccount');
$user1 = $this->assert->doesNotThrow(function() $user1 = $this->assert->doesNotThrow(function()
@ -185,11 +185,11 @@ class AddUserJobTest extends AbstractTest
public function testEmailsEveryoneMustConfirm() public function testEmailsEveryoneMustConfirm()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'nobody'; Core::getConfig()->privileges->changeUserEmailNoConfirm = 'nobody';
$this->grantAccess('registerAccount'); $this->grantAccess('registerAccount');
$user1 = $this->assert->doesNotThrow(function() $user1 = $this->assert->doesNotThrow(function()
@ -225,11 +225,11 @@ class AddUserJobTest extends AbstractTest
public function testEmailsEveryoneSkipConfirm() public function testEmailsEveryoneSkipConfirm()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
$this->grantAccess('registerAccount'); $this->grantAccess('registerAccount');
$user1 = $this->assert->doesNotThrow(function() $user1 = $this->assert->doesNotThrow(function()
@ -265,7 +265,7 @@ class AddUserJobTest extends AbstractTest
public function testEmailsTwoUsersSameMail() public function testEmailsTwoUsersSameMail()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());

View file

@ -28,7 +28,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own'); $this->grantAccess('editComment.own');
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->minLength)); $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength));
}); });
} }
@ -38,7 +38,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own'); $this->grantAccess('editComment.own');
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->maxLength)); $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength));
}); });
} }
@ -48,7 +48,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own'); $this->grantAccess('editComment.own');
$this->assert->throws(function() $this->assert->throws(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->minLength - 1)); $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1));
}, 'Comment must have at least'); }, 'Comment must have at least');
} }
@ -58,7 +58,7 @@ class EditCommentJobTest extends AbstractTest
$this->grantAccess('editComment.own'); $this->grantAccess('editComment.own');
$this->assert->throws(function() $this->assert->throws(function()
{ {
$this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1)); $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1));
}, 'Comment must have at most'); }, 'Comment must have at most');
} }

View file

@ -23,7 +23,7 @@ class EditPostSourceJobTest extends AbstractTest
$this->grantAccess('editPostSource.own'); $this->grantAccess('editPostSource.own');
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
$this->runApi(str_repeat('a', getConfig()->posts->maxSourceLength)); $this->runApi(str_repeat('a', Core::getConfig()->posts->maxSourceLength));
}); });
} }
@ -33,7 +33,7 @@ class EditPostSourceJobTest extends AbstractTest
$this->grantAccess('editPostSource.own'); $this->grantAccess('editPostSource.own');
$this->assert->throws(function() $this->assert->throws(function()
{ {
$this->runApi(str_repeat('a', getConfig()->posts->maxSourceLength + 1)); $this->runApi(str_repeat('a', Core::getConfig()->posts->maxSourceLength + 1));
}, 'Source must have at most'); }, 'Source must have at most');
} }

View file

@ -49,7 +49,7 @@ class EditPostTagsJobTest extends AbstractTest
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
$this->grantAccess('editPostTags'); $this->grantAccess('editPostTags');
$newTagNames = [str_repeat('u', getConfig()->tags->minLength - 1)]; $newTagNames = [str_repeat('u', Core::getConfig()->tags->minLength - 1)];
$this->assert->throws(function() use ($post, $newTagNames) $this->assert->throws(function() use ($post, $newTagNames)
{ {
Api::run( Api::run(
@ -66,7 +66,7 @@ class EditPostTagsJobTest extends AbstractTest
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
$this->grantAccess('editPostTags'); $this->grantAccess('editPostTags');
$newTagNames = [str_repeat('u', getConfig()->tags->maxLength + 1)]; $newTagNames = [str_repeat('u', Core::getConfig()->tags->maxLength + 1)];
$this->assert->throws(function() use ($post, $newTagNames) $this->assert->throws(function() use ($post, $newTagNames)
{ {
Api::run( Api::run(

View file

@ -41,7 +41,7 @@ class EditUserAccessRankJobTest extends AbstractTest
public function testHigherThanMyselfDenial() public function testHigherThanMyselfDenial()
{ {
getConfig()->privileges->changeUserAccessRank = 'power-user'; Core::getConfig()->privileges->changeUserAccessRank = 'power-user';
Access::init(); Access::init();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();

View file

@ -3,11 +3,11 @@ class EditUserEmailJobTest extends AbstractTest
{ {
public function testNoConfirmation() public function testNoConfirmation()
{ {
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
$this->grantAccess('changeUserEmail'); $this->grantAccess('changeUserEmail');
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -30,11 +30,11 @@ class EditUserEmailJobTest extends AbstractTest
public function testConfirmation() public function testConfirmation()
{ {
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'admin'; Core::getConfig()->privileges->changeUserEmailNoConfirm = 'admin';
$this->grantAccess('changeUserEmail'); $this->grantAccess('changeUserEmail');
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -57,10 +57,10 @@ class EditUserEmailJobTest extends AbstractTest
public function testInvalidEmail() public function testInvalidEmail()
{ {
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending(); Mailer::mockSending();
getConfig()->privileges->changeUserEmailNoConfirm = 'nobody'; Core::getConfig()->privileges->changeUserEmailNoConfirm = 'nobody';
$this->grantAccess('changeUserEmail'); $this->grantAccess('changeUserEmail');
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -78,11 +78,11 @@ class EditUserEmailJobTest extends AbstractTest
public function testChangingToExistingDenial() public function testChangingToExistingDenial()
{ {
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
Mailer::mockSending(); Mailer::mockSending();
$this->assert->areEqual(0, Mailer::getMailCounter()); $this->assert->areEqual(0, Mailer::getMailCounter());
getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous'; Core::getConfig()->privileges->changeUserEmailNoConfirm = 'anonymous';
$this->grantAccess('changeUserEmail'); $this->grantAccess('changeUserEmail');
list ($user, $otherUser) list ($user, $otherUser)

View file

@ -28,7 +28,7 @@ class EditUserNameJobTest extends AbstractTest
$this->grantAccess('changeUserName'); $this->grantAccess('changeUserName');
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
$newName = str_repeat('a', getConfig()->registration->userNameMinLength - 1); $newName = str_repeat('a', Core::getConfig()->registration->userNameMinLength - 1);
$this->assert->throws(function() use ($user, $newName) $this->assert->throws(function() use ($user, $newName)
{ {
@ -46,7 +46,7 @@ class EditUserNameJobTest extends AbstractTest
$this->grantAccess('changeUserName'); $this->grantAccess('changeUserName');
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
$newName = str_repeat('a', getConfig()->registration->userNameMaxLength + 1); $newName = str_repeat('a', Core::getConfig()->registration->userNameMaxLength + 1);
$this->assert->throws(function() use ($user, $newName) $this->assert->throws(function() use ($user, $newName)
{ {

View file

@ -16,7 +16,7 @@ class EditUserPasswordJobTest extends AbstractTest
$this->grantAccess('changeUserPassword'); $this->grantAccess('changeUserPassword');
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
$newPassword = str_repeat('a', getConfig()->registration->passMinLength - 1); $newPassword = str_repeat('a', Core::getConfig()->registration->passMinLength - 1);
$oldPasswordHash = $user->getPasswordHash(); $oldPasswordHash = $user->getPasswordHash();
$this->assert->throws(function() use ($user, $newPassword) $this->assert->throws(function() use ($user, $newPassword)
@ -51,7 +51,7 @@ class EditUserPasswordJobTest extends AbstractTest
$this->assert->areEqual($newPasswordHash, $user->getPasswordHash()); $this->assert->areEqual($newPasswordHash, $user->getPasswordHash());
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$this->assert->doesNotThrow(function() use ($user, $newPassword) $this->assert->doesNotThrow(function() use ($user, $newPassword)
{ {
Auth::login($user->getName(), $newPassword, false); Auth::login($user->getName(), $newPassword, false);

View file

@ -37,7 +37,7 @@ class GetLogJobTest extends AbstractTest
private function run($args) private function run($args)
{ {
getConfig()->browsing->logsPerPage = 2; Core::getConfig()->browsing->logsPerPage = 2;
$this->grantAccess('viewLog'); $this->grantAccess('viewLog');
Logger::log('line1'); Logger::log('line1');
Logger::log('line2'); Logger::log('line2');

View file

@ -18,7 +18,7 @@ class GetPostThumbJobTest extends AbstractTest
$this->assert->isNotNull($post->tryGetWorkingFullPath()); $this->assert->isNotNull($post->tryGetWorkingFullPath());
$this->assert->areEqual('image/jpeg', $output->mimeType); $this->assert->areEqual('image/jpeg', $output->mimeType);
$this->assert->areNotEqual( $this->assert->areNotEqual(
file_get_contents(getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'), file_get_contents(Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'),
$output->fileContent); $output->fileContent);
} }

View file

@ -44,7 +44,7 @@ class ListCommentJobTest extends AbstractTest
$this->grantAccess('listComments'); $this->grantAccess('listComments');
$this->grantAccess('listPosts'); $this->grantAccess('listPosts');
getConfig()->comments->commentsPerPage = 2; Core::getConfig()->comments->commentsPerPage = 2;
$this->assert->areEqual(0, CommentModel::getCount()); $this->assert->areEqual(0, CommentModel::getCount());

View file

@ -5,12 +5,12 @@ class ListLogsJobTest extends AbstractTest
{ {
$this->grantAccess('listLogs'); $this->grantAccess('listLogs');
getConfig()->main->logsPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/test1.log'); Core::getConfig()->main->logsPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/test1.log');
Logger::init(); Logger::init();
Logger::log('nonsense'); Logger::log('nonsense');
getConfig()->main->logsPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/test2.log'); Core::getConfig()->main->logsPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/test2.log');
Logger::init(); Logger::init();
Logger::log('nonsense'); Logger::log('nonsense');

View file

@ -5,7 +5,7 @@ class ListPostsJobTest extends AbstractTest
{ {
$this->grantAccess('listPosts'); $this->grantAccess('listPosts');
$posts = $this->postMocker->mockMultiple(3); $posts = $this->postMocker->mockMultiple(3);
getConfig()->browsing->postsPerPage = 2; Core::getConfig()->browsing->postsPerPage = 2;
$ret = $this->assert->doesNotThrow(function() $ret = $this->assert->doesNotThrow(function()
{ {

View file

@ -7,7 +7,7 @@ class ListRelatedTagsJobTest extends AbstractTest
$this->grantAccess('listPosts'); $this->grantAccess('listPosts');
$tags = $this->tagMocker->mockMultiple(3); $tags = $this->tagMocker->mockMultiple(3);
getConfig()->browsing->tagsRelated = 1; Core::getConfig()->browsing->tagsRelated = 1;
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
$post->setTags($tags); $post->setTags($tags);

View file

@ -7,7 +7,7 @@ class ListTagsJobTest extends AbstractTest
$this->grantAccess('listPosts'); $this->grantAccess('listPosts');
$tags = $this->tagMocker->mockMultiple(3); $tags = $this->tagMocker->mockMultiple(3);
getConfig()->browsing->tagsPerPage = 2; Core::getConfig()->browsing->tagsPerPage = 2;
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
$post->setTags($tags); $post->setTags($tags);

View file

@ -6,7 +6,7 @@ class ListUsersJobTest extends AbstractTest
$this->grantAccess('listUsers'); $this->grantAccess('listUsers');
$users = $this->userMocker->mockMultiple(3); $users = $this->userMocker->mockMultiple(3);
getConfig()->browsing->usersPerPage = 2; Core::getConfig()->browsing->usersPerPage = 2;
$ret = $this->assert->doesNotThrow(function() $ret = $this->assert->doesNotThrow(function()
{ {

View file

@ -3,7 +3,7 @@ class PasswordResetJobTest extends AbstractTest
{ {
public function testDontSendIfUnconfirmedMail() public function testDontSendIfUnconfirmedMail()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -22,7 +22,7 @@ class PasswordResetJobTest extends AbstractTest
public function testSending() public function testSending()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -54,7 +54,7 @@ class PasswordResetJobTest extends AbstractTest
public function testObtainingNewPassword() public function testObtainingNewPassword()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -94,7 +94,7 @@ class PasswordResetJobTest extends AbstractTest
public function testUsingTokenTwice() public function testUsingTokenTwice()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
Mailer::mockSending(); Mailer::mockSending();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();

View file

@ -26,7 +26,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
return $this->runApi(str_repeat('b', getConfig()->comments->minLength)); return $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength));
}); });
} }
@ -35,7 +35,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
return $this->runApi(str_repeat('b', getConfig()->comments->maxLength)); return $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength));
}); });
} }
@ -44,7 +44,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->throws(function() $this->assert->throws(function()
{ {
return $this->runApi(str_repeat('b', getConfig()->comments->minLength - 1)); return $this->runApi(str_repeat('b', Core::getConfig()->comments->minLength - 1));
}, 'Comment must have at least'); }, 'Comment must have at least');
} }
@ -53,7 +53,7 @@ class PreviewCommentJobTest extends AbstractTest
$this->prepare(); $this->prepare();
$this->assert->throws(function() $this->assert->throws(function()
{ {
return $this->runApi(str_repeat('b', getConfig()->comments->maxLength + 1)); return $this->runApi(str_repeat('b', Core::getConfig()->comments->maxLength + 1));
}, 'Comment must have at most'); }, 'Comment must have at most');
} }
@ -106,7 +106,7 @@ class PreviewCommentJobTest extends AbstractTest
protected function prepare() protected function prepare()
{ {
getConfig()->registration->needEmailForCommenting = false; Core::getConfig()->registration->needEmailForCommenting = false;
$this->grantAccess('addComment'); $this->grantAccess('addComment');
$this->login($this->userMocker->mockSingle()); $this->login($this->userMocker->mockSingle());
} }

View file

@ -28,7 +28,7 @@ class AccessTest extends AbstractTest
public function testAccessRanks2() public function testAccessRanks2()
{ {
getConfig()->privileges->listPosts = 'power-user'; Core::getConfig()->privileges->listPosts = 'power-user';
Access::init(); Access::init();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -50,7 +50,7 @@ class AccessTest extends AbstractTest
public function testSubPrivilegesOnlySub() public function testSubPrivilegesOnlySub()
{ {
getConfig()->privileges->{'listPosts.own'} = 'power-user'; Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
Access::init(); Access::init();
$user = $this->userMocker->mockSingle(); $user = $this->userMocker->mockSingle();
@ -62,16 +62,16 @@ class AccessTest extends AbstractTest
public function testSubPrivilegesSubAndGeneralNormalOrder() public function testSubPrivilegesSubAndGeneralNormalOrder()
{ {
getConfig()->privileges->{'listPosts.own'} = 'power-user'; Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
getConfig()->privileges->{'listPosts'} = 'admin'; Core::getConfig()->privileges->{'listPosts'} = 'admin';
Access::init(); Access::init();
$this->testSubPrivilegesSubAndGeneral(); $this->testSubPrivilegesSubAndGeneral();
} }
public function testSubPrivilegesSubAndGeneralReverseOrder() public function testSubPrivilegesSubAndGeneralReverseOrder()
{ {
getConfig()->privileges->{'listPosts'} = 'admin'; Core::getConfig()->privileges->{'listPosts'} = 'admin';
getConfig()->privileges->{'listPosts.own'} = 'power-user'; Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
Access::init(); Access::init();
$this->testSubPrivilegesSubAndGeneral(); $this->testSubPrivilegesSubAndGeneral();
} }
@ -92,18 +92,18 @@ class AccessTest extends AbstractTest
public function testSubPrivilegesMultipleSubAndGeneralNormalOrder() public function testSubPrivilegesMultipleSubAndGeneralNormalOrder()
{ {
getConfig()->privileges->{'listPosts.own'} = 'power-user'; Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
getConfig()->privileges->{'listPosts.all'} = 'admin'; Core::getConfig()->privileges->{'listPosts.all'} = 'admin';
getConfig()->privileges->{'listPosts'} = 'nobody'; Core::getConfig()->privileges->{'listPosts'} = 'nobody';
Access::init(); Access::init();
$this->testSubPrivilegesMultipleSubAndGeneral(); $this->testSubPrivilegesMultipleSubAndGeneral();
} }
public function testSubPrivilegesMultipleSubAndGeneralReverseOrder() public function testSubPrivilegesMultipleSubAndGeneralReverseOrder()
{ {
getConfig()->privileges->{'listPosts'} = 'nobody'; Core::getConfig()->privileges->{'listPosts'} = 'nobody';
getConfig()->privileges->{'listPosts.own'} = 'power-user'; Core::getConfig()->privileges->{'listPosts.own'} = 'power-user';
getConfig()->privileges->{'listPosts.all'} = 'admin'; Core::getConfig()->privileges->{'listPosts.all'} = 'admin';
Access::init(); Access::init();
$this->testSubPrivilegesMultipleSubAndGeneral(); $this->testSubPrivilegesMultipleSubAndGeneral();
} }

View file

@ -3,8 +3,8 @@ class AuthTest extends AbstractTest
{ {
public function testValidPassword() public function testValidPassword()
{ {
getConfig()->registration->staffActivation = false; Core::getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
UserModel::save($user); UserModel::save($user);
@ -19,8 +19,8 @@ class AuthTest extends AbstractTest
public function testLoginViaEmail() public function testLoginViaEmail()
{ {
getConfig()->registration->staffActivation = false; Core::getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->setConfirmedEmail('godzilla@whitestar.gov'); $user->setConfirmedEmail('godzilla@whitestar.gov');
@ -65,8 +65,8 @@ class AuthTest extends AbstractTest
public function testBanned() public function testBanned()
{ {
getConfig()->registration->staffActivation = false; Core::getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->ban(); $user->ban();
@ -80,8 +80,8 @@ class AuthTest extends AbstractTest
public function testStaffConfirmationEnabledFail() public function testStaffConfirmationEnabledFail()
{ {
getConfig()->registration->staffActivation = true; Core::getConfig()->registration->staffActivation = true;
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->setStaffConfirmed(false); $user->setStaffConfirmed(false);
@ -95,8 +95,8 @@ class AuthTest extends AbstractTest
public function testStaffConfirmationEnabledPass() public function testStaffConfirmationEnabledPass()
{ {
getConfig()->registration->staffActivation = true; Core::getConfig()->registration->staffActivation = true;
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->setStaffConfirmed(true); $user->setStaffConfirmed(true);
@ -112,8 +112,8 @@ class AuthTest extends AbstractTest
public function testStaffConfirmationDisabledPass() public function testStaffConfirmationDisabledPass()
{ {
getConfig()->registration->staffActivation = false; Core::getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->setStaffConfirmed(false); $user->setStaffConfirmed(false);
@ -129,8 +129,8 @@ class AuthTest extends AbstractTest
public function testMailConfirmationEnabledFail1() public function testMailConfirmationEnabledFail1()
{ {
getConfig()->registration->staffActivation = false; Core::getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->setStaffConfirmed(false); $user->setStaffConfirmed(false);
@ -144,8 +144,8 @@ class AuthTest extends AbstractTest
public function testMailConfirmationEnabledFail2() public function testMailConfirmationEnabledFail2()
{ {
getConfig()->registration->staffActivation = false; Core::getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->setStaffConfirmed(false); $user->setStaffConfirmed(false);
@ -160,8 +160,8 @@ class AuthTest extends AbstractTest
public function testMailConfirmationEnabledPass() public function testMailConfirmationEnabledPass()
{ {
getConfig()->registration->staffActivation = false; Core::getConfig()->registration->staffActivation = false;
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
$user = $this->prepareValidUser(); $user = $this->prepareValidUser();
$user->setStaffConfirmed(false); $user->setStaffConfirmed(false);

View file

@ -26,10 +26,10 @@ class LoggerTest extends AbstractTest
public function testPathChanging() public function testPathChanging()
{ {
$logPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/{yyyy}-{mm}-{dd}.log'); $logPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/{yyyy}-{mm}-{dd}.log');
$realLogPath = TextHelper::absolutePath(getConfig()->rootDir . '/tests/logs/' . date('Y-m-d') . '.log'); $realLogPath = TextHelper::absolutePath(Core::getConfig()->rootDir . '/tests/logs/' . date('Y-m-d') . '.log');
getConfig()->main->logsPath = $logPath; Core::getConfig()->main->logsPath = $logPath;
$this->assert->doesNotThrow(function() $this->assert->doesNotThrow(function()
{ {
Logger::init(); Logger::init();

View file

@ -74,7 +74,7 @@ class PostModelTest extends AbstractTest
public function testAutoFeaturingOutdated() public function testAutoFeaturingOutdated()
{ {
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
$minTimestamp = getConfig()->misc->featuredPostMaxDays * 24 * 3600; $minTimestamp = Core::getConfig()->misc->featuredPostMaxDays * 24 * 3600;
$this->assert->isTrue(PostModel::featureRandomPostIfNecessary()); $this->assert->isTrue(PostModel::featureRandomPostIfNecessary());
PropertyModel::set(PropertyModel::FeaturedPostUnixTime, time() - $minTimestamp - 1); PropertyModel::set(PropertyModel::FeaturedPostUnixTime, time() - $minTimestamp - 1);

View file

@ -3,7 +3,7 @@ class UserModelTest extends AbstractTest
{ {
public function testSavingTwoUsersSameNameNoActivation() public function testSavingTwoUsersSameNameNoActivation()
{ {
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
list ($user1, $user2) = $this->prepareTwoUsersWithSameName(); list ($user1, $user2) = $this->prepareTwoUsersWithSameName();
$this->assert->throws(function() use ($user2) $this->assert->throws(function() use ($user2)
{ {
@ -13,7 +13,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameNameEmailActivation() public function testSavingTwoUsersSameNameEmailActivation()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameName(); list ($user1, $user2) = $this->prepareTwoUsersWithSameName();
$this->assert->throws(function() use ($user2) $this->assert->throws(function() use ($user2)
{ {
@ -23,7 +23,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameNameStaffActivation() public function testSavingTwoUsersSameNameStaffActivation()
{ {
getConfig()->registration->staffActivation = true; Core::getConfig()->registration->staffActivation = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameName(); list ($user1, $user2) = $this->prepareTwoUsersWithSameName();
$this->assert->throws(function() use ($user2) $this->assert->throws(function() use ($user2)
{ {
@ -33,7 +33,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameEmailNoActivation() public function testSavingTwoUsersSameEmailNoActivation()
{ {
getConfig()->registration->needEmailForRegistering = false; Core::getConfig()->registration->needEmailForRegistering = false;
list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false); list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false);
$this->assert->throws(function() use ($user2) $this->assert->throws(function() use ($user2)
{ {
@ -43,7 +43,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameEmailEmailActivation() public function testSavingTwoUsersSameEmailEmailActivation()
{ {
getConfig()->registration->needEmailForRegistering = true; Core::getConfig()->registration->needEmailForRegistering = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false); list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false);
$this->assert->throws(function() use ($user2) $this->assert->throws(function() use ($user2)
{ {
@ -53,7 +53,7 @@ class UserModelTest extends AbstractTest
public function testSavingTwoUsersSameEmailStaffActivation() public function testSavingTwoUsersSameEmailStaffActivation()
{ {
getConfig()->registration->staffActivation = true; Core::getConfig()->registration->staffActivation = true;
list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false); list ($user1, $user2) = $this->prepareTwoUsersWithSameEmail(false, false);
$this->assert->throws(function() use ($user2) $this->assert->throws(function() use ($user2)
{ {