<?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';

$users = array('Usuario' => '',
    'redccu' => 'hospitalaplao');

$usersIds = array('Usuario' => -1, 'redccu' => -1);

$dataSourceRecordPermissions = array();

$grants = array('defaultUser' => 
        array('m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_personal.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_distrito' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc.s7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false))
    ,
    'Usuario' => 
        array('m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_personal.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_distrito' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc.s7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false))
    ,
    'guest' => 
        array('m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_personal.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_distrito' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc.s7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false))
    ,
    'redccu' => 
        array('m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_personal.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false),
        's7_capacitacion.per_cap' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab' => new DataSourceSecurityInfo(false, false, false, false),
        'm_condilab.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_distrito' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento' => new DataSourceSecurityInfo(false, false, false, false),
        'm_establecimiento.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner' => new DataSourceSecurityInfo(false, false, false, false),
        'm_remuner.m_personal' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc' => new DataSourceSecurityInfo(false, false, false, false),
        'm_tipdoc.s7_capacitacion' => new DataSourceSecurityInfo(false, false, false, false))
    );

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

$tableCaptions = array('m_personal' => 'm_personal',
'm_personal.per_cap' => 'm_personal.per_cap',
'per_cap' => 'per_cap',
's7_capacitacion' => 's7_capacitacion',
's7_capacitacion.per_cap' => 's7_capacitacion.per_cap',
'm_condilab' => 'm_condilab',
'm_condilab.m_personal' => 'm_condilab.m_personal',
'm_distrito' => 'm_distrito',
'm_establecimiento' => 'm_establecimiento',
'm_establecimiento.m_personal' => 'm_establecimiento.m_personal',
'm_remuner' => 'm_remuner',
'm_remuner.m_personal' => 'm_remuner.m_personal',
'm_tipdoc' => 'm_tipdoc',
'm_tipdoc.s7_capacitacion' => 'm_tipdoc.s7_capacitacion');

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

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

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

?>