30 lines
558 B
PHP
30 lines
558 B
PHP
function getCurrentUser() {
|
|
var user = $('#current_user').html();
|
|
return (typeof(user) != 'undefined') ? user : false;
|
|
}
|
|
|
|
function isConnected() {
|
|
return getCurrentUser() ? true : false;
|
|
}
|
|
|
|
function hasRole(str) {
|
|
return checkRole('admin') ? true : checkRole(str);
|
|
}
|
|
|
|
function checkRole(str) {
|
|
return (global.roles.indexOf(str) == -1 ) ? false : true;
|
|
}
|
|
|
|
function isAdmin() {
|
|
return hasRole('admin');
|
|
}
|
|
|
|
function hasPermission(str) {
|
|
if (isAdmin()) {
|
|
return true;
|
|
} else {
|
|
return (global.permissions.indexOf(str) == -1 ) ? false : true;
|
|
}
|
|
}
|
|
|