mirror of
https://github.com/typemill/typemill.git
synced 2025-08-08 23:26:34 +02:00
Version 1.1.6 User Role, Fieldsets and Refactoring
This commit is contained in:
34
system/Extensions/TwigUserExtension.php
Normal file
34
system/Extensions/TwigUserExtension.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Typemill\Extensions;
|
||||
|
||||
class TwigUserExtension extends \Twig_Extension
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new \Twig_SimpleFunction('is_role', array($this, 'isRole' )),
|
||||
new \Twig_SimpleFunction('get_username', array($this, 'getUsername' ))
|
||||
];
|
||||
}
|
||||
|
||||
public function isRole($role)
|
||||
{
|
||||
if(isset($_SESSION['role']) && $_SESSION['role'] == $role)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUsername()
|
||||
{
|
||||
if(isset($_SESSION['user']))
|
||||
{
|
||||
return $_SESSION['user'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user