Skip to content
Snippets Groups Projects
Commit db40cfd3 authored by Bye's avatar Bye
Browse files

Common files update

parent 8ac04153
No related branches found
No related tags found
1 merge request!4Draft: Merge rewrite branch into main
......@@ -72,3 +72,15 @@ function get_user_display_name($userId, $escape = true) {
return $display_name;
}
function requires_auth($redirect = '/auth/login') {
global $path_raw;
if ($_SESSION['auth']) {
return true;
}
http_response_code(307);
header('Location: '.$redirect.'?callback='.urlencode($path_raw));
exit();
}
<?php
function get_string($key="generic.generic") {
function get_string($key="generic.generic", $substitutes=[]) {
global $LANG;
$key_path = explode('.', $key);
......@@ -15,10 +15,20 @@ function get_string($key="generic.generic") {
}
}
if (count($substitutes) > 0) {
foreach ($substitutes as $key => $substitute) {
$re = '/{{('. $key .')}}/';
$subst = $substitute;
$result = preg_replace($re, $subst, $result, 1);
}
}
return $result;
}
function patch_lang($lang="en") {
function patch_lang($lang="en"): void
{
global $LANG, $DOC_ROOT;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment