<%init>
  my $CONFIG = {
                NESTED => 1,
                ROLE =>
                {
                    '' =>
                    {
                        MENU => "anonymous_menu"
                    },
                    'User' =>
                    {
                        MENU => "anonymous_menu"
                    },
                    'RA Operator' =>
                    {
                        MENU => "ra_op_menu"
                    },
                    'CA Operator' =>
                    {
                        MENU => "ca_op_menu"
                    }
                },
                MENU =>
                {
                    "anonymous_menu" =>
                    [
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_CA_INFO",
                                   "ca_info"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_CREATE_CSR",
                                   "create_csr"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_SEARCH_CERT",
                                   "cert_search"],
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_LANGUAGE",
                                   "language"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_LOGOUT",
                                   "logout"]
                    ],
                    "ra_op_menu" =>
                    [
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_CA_INFO",      "ca_info"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_CREATE_CSR",   "create_csr"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_SMARTCARD", "smartcard_personalization"],
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_WORKFLOW",     "workflow"],
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_DATAEXCHANGE", "dataexchange"],
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_LANGUAGE",     "language"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_LOGOUT",       "logout"]
                    ],
                    "ca_op_menu" =>
                    [
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_KEY_LIST", "key_list"],
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_CA_INFO",  "ca_info"],
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_WORKFLOW", "workflow"],
                        ["MENU",   "I18N_OPENXPKI_HTML_MENU_LANGUAGE", "language"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_LOGOUT",   "logout"]
                    ],
                    "ca_info" =>
                    [
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_PKI_REALM_INFO",
                                   "pki_realm_info"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_LIST_ISSUER",
                                   "issuer_list"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_LIST_CRL",
                                   "crl_list"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_LIST_POLICY",
                                   "policy_list"]
                    ],
                    "workflow" =>
                    [
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_WORKFLOW_LIST_TYPES",
                                   "workflow_list_types"],
                        ## please be really sure what you do if you uncomment this
                        ## why? not having a menu entry does not protect against entering the URL manually! (Alex, 2006-09-05)
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_WORKFLOW_CREATE_INSTANCE",
                                    "workflow_create_instance"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_WORKFLOW_LIST_INSTANCES",
                                   "workflow_list_instances"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_WORKFLOW_SEARCH_INSTANCES",
                                   "workflow_search_instances"],
                    ],
                    "dataexchange" =>
                    [
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_DATAEXCHANGE_EXPORT",
                                   "dataexchange_export"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_DATAEXCHANGE_IMPORT",
                                   "dataexchange_import"],
                    ],
                    "language" =>
                    [
                        ["ACTION", "English",
                                   "set_language_en_gb"],
                        ["ACTION", "Deutsch",
                                   "set_language_de_de"],
                        ["ACTION", "Русский",
                                   "set_language_ru_ru"],
                    ],
                    "edit_certs" =>
                    [
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_VALID_CERTS",   "edit_valid_certs"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_EXPIRED_CERTS", "edit_expired_certs"],
                        ["ACTION", "I18N_OPENXPKI_HTML_MENU_REVOKED_CERTS", "edit_revoked_certs"],
                    ]
                },
                ACTION =>
                {
                    "create_csr" =>
                    {
                        CMD => "service/create_csr/index.html"
                    },
                    "smartcard_personalization" =>
                    {
                        CMD => "service/smartcard_personalization/index.html"
                    },
                    "workflow_list_types" =>
                    {
                        CMD => "service/workflow/list_types.html"
                    },
                    "workflow_list_instances" =>
                    {
                        CMD => "service/workflow/list_instances.html"
                    },
                    ## please be really sure what you do if you uncomment this
                    ## cf. above (Alex)
                    "workflow_create_instance" =>
                     {
                         CMD => "service/workflow/create_instance.html"
                     },
                    'workflow_search_instances' =>
                     {
                         CMD => 'service/workflow/search_instances.html'
                     },
                    "dataexchange_export" =>
                    {
                         CMD    => "service/workflow/start_data_exchange_export.html",
                    },
                    "dataexchange_import" =>
                    {
                         CMD    => "service/workflow/create_instance.html",
                         PARAMS => {"type" => "I18N_OPENXPKI_WF_TYPE_DATAEXCHANGE_IMPORT"}
                    },
                    "set_language_en_gb" =>
                    {
                        CMD    => "service/index.html",
                        PARAMS => { "__language" => "en_GB" }
                    },
                    "set_language_de_de" =>
                    {
                        CMD    => "service/index.html",
                        PARAMS => { "__language" => "de_DE" }
                    },
                    "set_language_ru_ru" =>
                    {
                        CMD    => "service/index.html",
                        PARAMS => { "__language" => "ru_RU" }
                    },
                    "edit_valid_certs" =>
                    {
                        CMD => "service/cert_list.html",
                        PARAMS =>
                        {
                            "STATUS"        => "VALID",
                            "REVOKE_BUTTON" => "YES",
                            "RENEW_BUTTON"  => "YES"
                        }
                    },
                    "edit_expired_certs" =>
                    {
                        CMD => "service/cert_list.html",
                        PARAMS =>
                        {
                            "STATUS"        => "VALID",
                            "REVOKE_BUTTON" => "YES",
                            "RENEW_BUTTON"  => "YES"
                        }
                    },
                    "edit_revoked_certs" =>
                    {
                        CMD => "service/cert_list.html",
                        PARAMS =>
                        {
                            "STATUS"        => "REVOKED",
                            "REVOKE_BUTTON" => "NO",
                            "RENEW_BUTTON"  => "NO"
                        }
                    },
                    "pki_realm_info" =>
                    {
                        CMD => "service/api/pki_realm_info.html"
                    },
                    "cert_search" =>
                    {
                        CMD => "service/api/cert_search.html"
                    },
                    "issuer_list" =>
                    {
                        CMD => "service/api/issuer_list.html"
                    },
                    "crl_list" =>
                    {
                        CMD => "service/api/crl_list.html"
                    },
                    "policy_list" =>
                    {
                        CMD => "service/api/policy_list.html"
                    },
                    "key_list" =>
                    {
                        CMD => "service/api/key_list.html"
                    },
                    "logout" =>
                    {
                        CMD => "service/logout.html"
                    }
                }
               };

  my %params = ( MASON  => $m,
                 CONFIG => $CONFIG,
                 ACTION => "/service/info",
                 COMP   => $m->request_comp()->title() );

  foreach my $key ("ROLE", "SESSION_ID", "LANGUAGE")
  {
      $params{$key} = $context->{lc $key} if (exists $context->{lc $key});
  }
  $context->{menu} = OpenXPKI::Client::HTML::Mason::Menu->new(\%params);
</%init>
<% $context->{menu}->get() | n %>
<%flags>
  inherit => '/syshandler'
</%flags>
