<?php

require_once 'components/page.php';
require_once 'components/security/datasource_security_info.php';
require_once 'components/security/security_info.php';
require_once 'components/security/hardcoded_auth.php';
require_once 'components/security/user_grants_manager.php';

include_once 'components/security/user_identity_storage/user_identity_session_storage.php';

$users = array('diremid' => 'k@rolita2016');

$usersIds = array('diremid' => -1);

$dataSourceRecordPermissions = array();

$grants = array('guest' => 
        array()
    ,
    'defaultUser' => 
        array('resolucion' => new DataSourceSecurityInfo(false, false, false, false),
        'resolucion.notificacion' => new DataSourceSecurityInfo(false, false, false, false),
        'numeracion' => new DataSourceSecurityInfo(false, false, false, false),
        'notificacion' => new DataSourceSecurityInfo(false, false, false, false))
    ,
    'guest' => 
        array('resolucion' => new DataSourceSecurityInfo(false, false, false, false),
        'resolucion.notificacion' => new DataSourceSecurityInfo(false, false, false, false),
        'numeracion' => new DataSourceSecurityInfo(false, false, false, false),
        'notificacion' => new DataSourceSecurityInfo(false, false, false, false))
    ,
    'diremid' => 
        array('resolucion' => new DataSourceSecurityInfo(false, false, false, false),
        'resolucion.notificacion' => new DataSourceSecurityInfo(false, false, false, false),
        'numeracion' => new DataSourceSecurityInfo(false, false, false, false),
        'notificacion' => new DataSourceSecurityInfo(false, false, false, false))
    );

$appGrants = array('guest' => new DataSourceSecurityInfo(false, false, false, false),
    'defaultUser' => new DataSourceSecurityInfo(true, false, false, false),
    'guest' => new DataSourceSecurityInfo(false, false, false, false),
    'diremid' => new AdminDataSourceSecurityInfo());

$tableCaptions = array('resolucion' => 'Resolución',
'resolucion.notificacion' => 'Resolución.Notificacion',
'numeracion' => 'Numeración',
'notificacion' => 'Notificacion');

function SetUpUserAuthorization()
{
    global $usersIds;
    global $grants;
    global $appGrants;
    global $dataSourceRecordPermissions;
    $userAuthorizationStrategy = new HardCodedUserAuthorization(new UserIdentitySessionStorage(GetIdentityCheckStrategy()), new HardCodedUserGrantsManager($grants, $appGrants), $usersIds);
    GetApplication()->SetUserAuthorizationStrategy($userAuthorizationStrategy);

GetApplication()->SetDataSourceRecordPermissionRetrieveStrategy(
    new HardCodedDataSourceRecordPermissionRetrieveStrategy($dataSourceRecordPermissions));
}

function GetIdentityCheckStrategy()
{
    global $users;
    return new SimpleIdentityCheckStrategy($users, '');
}

?>