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

/*
Module Name: Integrity Pact
Description: Integrity Pact (Annual) with HOD witness step
Version: 1.0.0
Requires at least: 2.3.*
*/

define('INTEGRITY_PACT_MODULE_NAME', 'integrity_pact');

hooks()->add_action('admin_init', 'integrity_pact_init_menu_items');
hooks()->add_action('admin_init', 'integrity_pact_permissions');


register_activation_hook(INTEGRITY_PACT_MODULE_NAME, 'integrity_module_activation_hook');
register_uninstall_hook(INTEGRITY_PACT_MODULE_NAME, 'integrity_module_uninstall_hook');

function integrity_module_activation_hook()
{
    require_once(__DIR__ . '/install.php');
}
function integrity_module_uninstall_hook()
{
    require_once(__DIR__ . '/uninstall.php');
}

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

    if (has_permission('integrity_pact', '', 'view') || has_permission('integrity_pact', '', 'view_own')) {
        $CI->app_menu->add_sidebar_children_item('staff_declaration', [
            'slug' => 'integrity_pact',
            'name'     => _l('staff_integrity'),
            'href'     => admin_url('integrity_pact/manage'),
            //'icon'     => 'fa fa-shield',
            'position' => 35,
        ]);
    }

    // if (is_admin()) {
    //     $CI->app_menu->add_sidebar_children_item('staff_declaration', [
    //         'slug' => 'integrity_pact_settings',
    //         'name' => 'Settings',
    //         'href' => admin_url('integrity_pact/settings'),
    //         'position' => 99,
    //     ]);
    // }
}

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

    register_staff_capabilities('integrity_pact', $capabilities, 'Integrity Pact');
}
register_language_files(INTEGRITY_PACT_MODULE_NAME, ['integrity_pact']);