Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75c31f0506 | |||
| 9738b133d2 | |||
| cf5d107fd5 | |||
| 148d85121a |
@@ -2,7 +2,8 @@
|
|||||||
"bundle": {
|
"bundle": {
|
||||||
"js/admin": {
|
"js/admin": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"uf-tweaks/js/handlebars-helpers.js"
|
"uf-tweaks/js/handlebars-helpers.js",
|
||||||
|
"uf-tweaks/js/modal-error-handler.js"
|
||||||
],
|
],
|
||||||
"options": {
|
"options": {
|
||||||
"sprinkle": {
|
"sprinkle": {
|
||||||
|
|||||||
16
assets/uf-tweaks/js/modal-error-handler.js
Normal file
16
assets/uf-tweaks/js/modal-error-handler.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Default handling of UF modal error
|
||||||
|
*
|
||||||
|
* This script depends on uf-modal.js
|
||||||
|
*
|
||||||
|
* Target page: *
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
const handleModalError = function() {
|
||||||
|
$(this).ufModal('destroy');
|
||||||
|
$('body').on('renderError.ufModal', handleModalError);
|
||||||
|
}
|
||||||
|
$('body').on('renderError.ufModal', handleModalError);
|
||||||
|
});
|
||||||
@@ -43,10 +43,40 @@ class ServicesProvider
|
|||||||
$container->extend('classMapper', function ($classMapper, $c) {
|
$container->extend('classMapper', function ($classMapper, $c) {
|
||||||
$classMapper->setClassMapping('activity_sprunje', 'UserFrosting\Sprinkle\UFTweaks\Sprunje\ActivitySprunje');
|
$classMapper->setClassMapping('activity_sprunje', 'UserFrosting\Sprinkle\UFTweaks\Sprunje\ActivitySprunje');
|
||||||
$classMapper->setClassMapping('user', 'UserFrosting\Sprinkle\UFTweaks\Database\Models\User');
|
$classMapper->setClassMapping('user', 'UserFrosting\Sprinkle\UFTweaks\Database\Models\User');
|
||||||
|
$classMapper->setClassMapping('user_sprunje', 'UserFrosting\Sprinkle\Organisations\Sprunje\UserSprunje');
|
||||||
|
|
||||||
return $classMapper;
|
return $classMapper;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a callback that forwards to dashboard if user is already logged in.
|
||||||
|
*
|
||||||
|
* @return callable
|
||||||
|
*/
|
||||||
|
$container['redirect.onAlreadyLoggedIn'] = function ($c) {
|
||||||
|
/*
|
||||||
|
* This method is invoked when a user attempts to perform certain public actions when they are already logged in.
|
||||||
|
*
|
||||||
|
* @todo Forward to user's landing page or last visited page
|
||||||
|
* @param \Psr\Http\Message\ServerRequestInterface $request
|
||||||
|
* @param \Psr\Http\Message\ResponseInterface $response
|
||||||
|
* @param array $args
|
||||||
|
* @return \Psr\Http\Message\ResponseInterface
|
||||||
|
*/
|
||||||
|
return function (Request $request, Response $response, array $args) use ($c) {
|
||||||
|
/** @var \UserFrosting\Sprinkle\Account\Authorize\AuthorizationManager */
|
||||||
|
$authorizer = $c->authorizer;
|
||||||
|
|
||||||
|
$currentUser = $c->authenticator->user();
|
||||||
|
|
||||||
|
if ($authorizer->checkAccess($currentUser, 'uri_dashboard')) {
|
||||||
|
return $response->withRedirect($c->router->pathFor('dashboard'));
|
||||||
|
} else {
|
||||||
|
return $response->withRedirect($c->router->pathFor('index'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a callback that handles setting the `UF-Redirect` header after a successful login.
|
* Returns a callback that handles setting the `UF-Redirect` header after a successful login.
|
||||||
*
|
*
|
||||||
|
|||||||
48
src/Sprunje/UserSprunje.php
Normal file
48
src/Sprunje/UserSprunje.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* AVSDev UF Tweaks (https://avsdev.uk)
|
||||||
|
*
|
||||||
|
* @link https://git.avsdev.uk/avsdev/sprinkle-uf-tweaks
|
||||||
|
* @license https://git.avsdev.uk/avsdev/sprinkle-uf-tweaks/blob/master/LICENSE.md (LGPL-3.0 License)
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace UserFrosting\Sprinkle\UFTweaks\Sprunje;
|
||||||
|
|
||||||
|
use Illuminate\Database\Schema\Builder;
|
||||||
|
use UserFrosting\Sprinkle\Admin\Sprunje\UserSprunje as UFUserSprunje;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UserSprunje.
|
||||||
|
*
|
||||||
|
* Extends User sprunje to make name filtering case-insensitive and include username
|
||||||
|
*
|
||||||
|
* @author Craig Williams (https://avsdev.uk)
|
||||||
|
*/
|
||||||
|
class UserSprunje extends UFUserSprunje
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Filter LIKE the first name, last name, or email.
|
||||||
|
*
|
||||||
|
* @param Builder $query
|
||||||
|
* @param mixed $value
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
protected function filterName($query, $value)
|
||||||
|
{
|
||||||
|
// Split value on separator for OR queries
|
||||||
|
$values = explode($this->orSeparator, $value);
|
||||||
|
$query->where(function ($query) use ($values) {
|
||||||
|
foreach ($values as $value) {
|
||||||
|
$likeValue = '%' . mb_strtolower($value) . '%';
|
||||||
|
$query->orWhereRaw('LOWER(first_name) LIKE ?', $likeValue)
|
||||||
|
->orWhereRaw('LOWER(last_name) LIKE ?', $likeValue)
|
||||||
|
->orWhereRaw('LOWER(email) LIKE ?', $likeValue)
|
||||||
|
->orWhereRaw('LOWER(user_name) LIKE ?', $likeValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user