<?php defined('BASEPATH') or exit('No direct script access allowed');

/*
Module Name: Staff External Engagement
Description: INCEIF Staff External Engagement Form (dynamic rows, files, PDF, Excel, notifications)
Version: 1.0.0
Requires at least: 3.4.0
*/

define('ANNUAL_EXTERNAL_ENGAGEMENT_MODULE_NAME', 'annual_external_engagement');

hooks()->add_action('admin_init', 'aee_register_permissions');
hooks()->add_action('admin_init', 'aee_init_menu_items');

register_activation_hook(ANNUAL_EXTERNAL_ENGAGEMENT_MODULE_NAME, 'aee_module_activation_hook');
register_uninstall_hook(ANNUAL_EXTERNAL_ENGAGEMENT_MODULE_NAME, 'aee_module_uninstall_hook');

function aee_module_activation_hook()
{
    require_once(__DIR__ . '/install.php');
}
function aee_module_uninstall_hook()
{
    require_once(__DIR__ . '/uninstall.php');
}

function aee_register_permissions()
{
    $capabilities = [];
    $capabilities['capabilities'] = [
        'view'     => _l('permission_view'),
        'view_own' => _l('permission_view_own'),
        'create'   => _l('permission_create'),
        'edit'     => _l('permission_edit'),
        'delete'   => _l('permission_delete'),
    ];

    register_staff_capabilities('annual_external_engagement', $capabilities, _l('annual_external_engagement'));
}

function aee_init_menu_items()
{
    $CI = &get_instance();

    if (staff_can('view', 'annual_external_engagement') || staff_can('view_own', 'annual_external_engagement')) {
        $CI->app_menu->add_sidebar_children_item('staff_declaration', [
            'slug'     => 'annual_external_engagement',
            'name'     => _l('annual_external_engagement'),
            'href'     => admin_url('annual_external_engagement'),
            'position' => 56,
            'badge'    => [],
        ]);
    }
}

// language
register_language_files(ANNUAL_EXTERNAL_ENGAGEMENT_MODULE_NAME, ['annual_external_engagement']);
