<?php

defined('_VALID') or die(RESTRICTED_ACCESS);
include_once('class.modcontrol.php');
$modcontrolObj = new modcontrol($configObj);
$action = $_REQUEST['action'];
$view = $_REQUEST['view'];
$configObj->glTplObj->change_path($configObj->currentModulePath . 'html/templates/');
$configObj->glTplObj->set('configObj', $configObj);
$configObj->glTplObj->set('modcontrolObj', $modcontrolObj);
$configObj->glTplObj->set('modcontrolTab', true);
$modcontrolObj->fk_modules = '2';
$AllAction = $modcontrolObj->getAllAction();
$AllModule = $modcontrolObj->getAllmodule();
$configObj->glTplObj->set('AllAction', $AllAction);
$configObj->glTplObj->set('AllModule', $AllModule);

switch ($action) {
    case 'add':

        if ($_REQUEST['h_save'] == 'T') {
            if ($modcontrolObj->UpdateAssignAction()) {
                $configObj->glLibraryObj->header_redirect('index.php?module=modcontrol&msg=edit');
            }
        } else {

            $configObj->glTplObj->set('actionmodule', $modcontrolObj->selectAllassignAction());
            $modcontrolObj->load_modules();
        }
        exit;
        break;

    default:

        $sql = "select fk_modules,fk_useraction,chr_custom from " . DB_PREFIX . "module_useraction where chr_delete='N'";
        $result = $modcontrolObj->configObj->glDbObj->query($sql);

        while ($row = $modcontrolObj->configObj->glDbObj->fetch_array($result)) {
            $actionmodule[$row[fk_modules]][$row[fk_useraction]][$row['chr_custom']] = $row['fk_modules'] . '-' . $row['fk_useraction'] . '-' . $row['chr_custom'];
        }

        $configObj->glTplObj->set('actionmodule', $actionmodule);
        $modcontrolObj->load_modules();
        break;
}
?>
