<?php

class ModuleManager extends CAccessControlFilter
{

    public static function getIconForModule($moduleName, $size = '2x', $cssClass = '')
    {
        $icon = 'frown';
        $modules = ModuleManager::modules();
        if (!empty($modules[$moduleName]['icon'])) {
            $icon = $modules[$moduleName]['icon'];
        }
        return "<i class='icon-$icon icon-$size $cssClass'></i>";
    }

    public static function moduleAvailable($name)
    {
        return array_key_exists($name, Yii::app()->getModules());
    }

    public static function getCalendarModules()
    {
        $calendars = Calendar::model()->findAll();
        $calendarModules = array();
        foreach ($calendars as $calendar) {

            $calendarModules['calender' . $calendar->id] = array(
                'section' => 'calendar',
                'uiModule' => true,
                'title' => 'test', //'DASHBOARD_SECTION_TITLE',
                'description' => 'test', // 'DASHBOARD_SECTION_DESCRIPTION',
            );
        }
        return $calendarModules;
    }

    public static function getDeclaredModules()
    {
        $modules = self::modules();
        $moduleDirPath = __DIR__ . "/../modules/";
        foreach ($modules as $modulDirName => $module) {

            if (!is_dir($moduleDirPath . $modulDirName) && !isset($module['type'])) {
                unset($modules[$modulDirName]);
            }
        }
        return $modules;
    }

    public static function modules()
    {
        $modules = array(
            /////////////Home Section:
            'home' => array(
                'type' => 'main', // add this attribute with this value for webGuiPermissions in each MainSection
                'mainSectionModule' => true,
                'section' => 'home',
                'sectionTitle' => 'DASHBOARD_MODULE_LABEL',
                'icon' => 'dashboard',
            ),
            'homeUCItem' => array(
                //'mainSectionModule' => false,
                'section' => 'home',
                // 'sectionTitle' => 'DASHBOARD_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'DASHBOARD_SECTION_TITLE',
                'description' => 'DASHBOARD_SECTION_DESCRIPTION',
                'icon' => 'homeUCItem',
            ),
            'addressbookAddresses' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'addressbook',
                'sectionTitle' => 'ADDRESSBOOK_ADDRESSES_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'ADDRESSBOOK_ADDRESSES_SECTION_TITLE',
                'description' => 'ADDRESSBOOK_ADDRESSES_SECTION_DESCRIPTION',
                'icon' => 'book',
            ),
            'addressbookImportExport' => array(
                'sectionTitle' => 'ADDRESSBOOK_ADDRESSES_MODULE_LABEL',
                'section' => 'addressbookImportExport',
                'uiModule' => false,
                'title' => 'IMPORT_EXPORT_SECTION_TITLE',
                'description' => 'IMPORT_EXPORT_SECTION_DESCRIPTION',
                'icon' => 'addressbookImportExport',
            ),
            ///////calendar Section:
            'calendar' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'calendar',
                'sectionTitle' => 'CALENDAR_MODULE_LABEL',
                'title' => 'CALENDAR_SECTION_TITLE',
                'description' => 'CALENDAR_SECTION_DESCRIPTION',
                'icon' => 'calendar',
            ),
            'calendarGeneral' => array(
                'section' => 'calendar',
                'uiModule' => true,
                'title' => 'CALENDAR_SECTION_TITLE',
                'description' => 'CALENDAR_SECTION_DESCRIPTION',
                'icon' => 'calendarGeneral',
            ),
            ///////Analytics Section:
            'analytics' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'analytics',
                'sectionTitle' => 'ANALYTICS_MODULE_LABEL',
                'title' => 'ANALYTICS_SECTION_TITLE',
                'description' => 'ANALYTICS_SECTION_DESCRIPTION',
                'icon' => 'bar-chart',
            ),
            'analyticsDailyReport' => array(
                'section' => 'analytics',
                'uiModule' => true,
                'title' => 'ANALYTICS_DAILY_REPORT_MODULE_LABEL',
                'description' => 'ANALYTICS_DAILY_REPORT_SECTION_DESCRIPTION',
                'icon' => 'bar-chart',
            ),
            'analyticsQueueReport' => array(
                'section' => 'analytics',
                'uiModule' => true,
                'title' => 'ANALYTICS_QUEUE_REPORT_MODULE_LABEL',
                'description' => 'ANALYTICS_QUEUE_REPORT_SECTION_DESCRIPTION',
                'icon' => 'signal',
            ),
            'analyticsAdvancedQueueReport' => array(
                'section' => 'analytics',
                'uiModule' => true,
                'title' => 'ANALYTICS_ADVANCED_QUEUE_REPORT_MODULE_LABEL',
                'description' => 'ANALYTICS_ADVANCED_QUEUE_REPORT_SECTION_DESCRIPTION',
                'icon' => 'table',
            ),
            /* 'analyticsChannelReport'=>array(
              'section' =>'analytics',
              'uiModule' => true,
              'title' => 'ANALYTICS_CHANEL_REPORT_MODULE_LABEL',
              'description' => 'ANALYTICS_CHANEL_REPORT_SECTION_DESCRIPTION',
              'icon'=>'analyticsChannelReport',
              ), */


            //             'analyticsRoutingReport'=>array(
            //                     'section' =>'analytics',
            //                     'uiModule' => true,
            //                     'title' => 'ANALYTICS_ROUTING_REPORT_MODULE_LABEL',
            //                     'description' => 'ANALYTICS_ROUTING_REPORT_SECTION_DESCRIPTION',
            //             ),
            //             'analyticsLocationReport'=>array(
            //                     'section' =>'analytics',
            //                     'uiModule' => true,
            //                     'title' => 'ANALYTICS_LOCATION_REPORT_MODULE_LABEL',
            //                     'description' => 'ANALYTICS_LOCATION_REPORT_SECTION_DESCRIPTION',
            //             ),
            ///////phonesettings Section:
            'phonesettings' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'phonesettings',
                'sectionTitle' => 'PHONESETTINGS_PHONEKEYS_MODULE_LABEL',
                'title' => 'PHONESETTINGS_PHONEKEYS_SECTION_TITLE',
                'description' => 'PHONESETTINGS_PHONEKEYS_SECTION_DESCRIPTION',
                'icon' => 'cog',
            ),
            'phonesettingsMyPhones' => array(
                //'mainSectionModule' => true,
                'section' => 'phonesettings',
                //'sectionTitle' => 'PHONESETTINGS_PHONEKEYS_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_MY_PHONES_SECTION_TITLE',
                'description' => 'PHONESETTINGS_MY_PHONES_SECTION_DESCRIPTION',
                'icon' => 'picture',
            ),
            'phonesettingsPhoneKey' => array(
                //'mainSectionModule' => true,
                'section' => 'phonesettings',
                //'sectionTitle' => 'PHONESETTINGS_PHONEKEYS_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_PHONEKEYS_SECTION_TITLE',
                'description' => 'PHONESETTINGS_PHONEKEYS_SECTION_DESCRIPTION',
                'icon' => 'list',
            ),
            'phonesettingsSpeedDial' => array(
                //'mainSectionModule' => true,
                'section' => 'phonesettings',
                //'sectionTitle' => 'PHONESETTINGS_PHONEKEYS_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_SPEED_DIAL_SECTION_TITLE',
                'description' => 'PHONESETTINGS_SPEED_DIAL_SECTION_DESCRIPTION',
                'icon' => 'th',
            ),
            'phonesettingsAudioFiles' => array(
                //'mainSectionModule' => true,
                'section' => 'phonesettings',
                //'sectionTitle' => 'Phonesettings',
                'uiModule' => true,
                'title' => 'AUDIOFILES_SECTION_TITLE',
                'description' => 'AUDIOFILES_SECTION_DESCRIPTION',
                'icon' => 'volume-up',
            ),
            'phonesettingsUser' => array(
                'section' => 'phonesettings',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_USER_SECTION_TITLE',
                'description' => 'PHONESETTINGS_USER_SECTION_DESCRIPTION',
                'icon' => 'building',
            ),
            'phonesettingsTones' => array(
                'section' => 'phonesettings',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_TONES_SECTION_TITLE',
                'description' => 'PHONESETTINGS_TONES_SECTION_DESCRIPTION',
                'icon' => 'headphones',
            ),
            'phonesettingsNotifications' => array(
                'section' => 'phonesettings',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_NOTIFICATIONS_SECTION_TITLE',
                'description' => 'PHONESETTINGS_NOTIFICATIONS_SECTION_DESCRIPTION',
                'icon' => 'envelope',
            ),
            'phonesettingsCredentials' => array(
                'section' => 'phonesettings',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_CREDENTIALS_SECTION_TITLE',
                'description' => 'PHONESETTINGS_CREDENTIALS_SECTION_DESCRIPTION',
                'icon' => 'lock',
            ),
            'phonesettingsThirdPartyCredentials' => array(
                'section' => 'phonesettings',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_THIRD_PARTY_CREDENTIALS_SECTION_TITLE',
                'description' => 'PHONESETTINGS_THIRD_PARTY_CREDENTIALS_SECTION_DESCRIPTION',
                'icon' => 'exchange',
            ),
            'phonesettingsCallforward' => array(
                'section' => 'phonesettings',
                'uiModule' => true,
                'title' => 'PHONESETTINGS_CALLFORWARD_SECTION_TITLE',
                'description' => 'PHONESETTINGS_CALLFORWARD_SECTION_DESCRIPTION',
                'icon' => 'retweet',
            ),
            /*      'statsCallVolume'=>array(
              'mainSectionModule' => true,
              'section' => 'stats',
              'sectionTitle' => 'Statistik',
              'uiModule' => true,
              'title' => 'Call Trafic',
              'description' => 'Amount and duration',
              ),
             */
            /*      'statsGeneral'=>array(
              'section' => 'stats',
              'uiModule' => true,
              'title' => 'General statistics',
              'description' => 'Success rate, duration',
              ),
             */
            /*      'statsGrouped'=>array(
              'section' => 'stats',
              'uiModule' => true,
              'title' => 'Coworker statistics',
              'description' => 'Statistics of coworkers',
              ),
             */
            /*        'faxInbox'=>array(
              'mainSectionModule' => true,
              'section' => 'fax',
              'sectionTitle' => 'Fax',
              'uiModule' => true,
              'title' => 'Inbox',
              'description' => 'Received faxes',
              ),
              'faxOutbox'=>array(
              'section' => 'fax',
              'uiModule' => true,
              'title' => 'Outbox',
              'description' => 'Fax status',
              ),
              'faxSend'=>array(
              'section' => 'fax',
              'uiModule' => true,
              'title' => 'Send',
              'description' => 'Send new fax',
              ),
             */
            ///////Admin Section :
            'admin' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'admin',
                'sectionTitle' => 'ADMIN_USER_MODULE_LABEL',
                'title' => 'ADMIN_USER_SECTION_TITLE',
                'description' => 'ADMIN_USER_SECTION_DESCRIPTION',
                'icon' => 'group',
            ),
            'adminUsers' => array(
                //'mainSectionModule' => true,
                'section' => 'admin',
                //'sectionTitle' => 'ADMIN_USER_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'ADMIN_USER_SECTION_TITLE',
                'description' => 'ADMIN_USER_SECTION_DESCRIPTION',
                'icon' => 'user',
            ),
            'adminGroups' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'ADMIN_GROUPS_SECTION_TITLE',
                'description' => 'ADMIN_GROUPS_SECTION_DESCRIPTION',
                'icon' => 'group',
            ),
            'routingQueueMonitor' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'ROUTING_QUEUEMONITOR_SECTION_TITLE',
                'description' => 'ROUTING_QUEUEMONITOR_SECTION_DESCRIPTION',
                'icon' => 'desktop',
            ),
            'addressbookGeneral' => array(
                'mainSectionModule' => false,
                'section' => 'admin',
                'sectionTitle' => 'ADDRESSBOOK_GENERAL_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'ADDRESSBOOK_GENERAL_SECTION_TITEL',
                'description' => 'ADDRESSBOOK_GENERAL_SECTION_DESCRIPTION',
                'icon' => 'book',
            ),
            'adminCalendar' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'CALENDAR_SECTION_TITLE',
                'description' => 'CALENDAR_SECTION_DESCRIPTION',
                'icon' => 'calendar'
            ),
            'adminSipAccounts' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'SIP_ACCOUNTS_SECTION_TITLE',
                'description' => 'SIP_ACCOUNTS_SECTION_DESCRIPTION',
                'icon' => 'cloud',
            ),
            'adminWebGuiPermissions' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'WEB_GUI_PERMISSIONS_SECTION_TITLE',
                'description' => 'WEB_GUI_PERMISSIONS_SECTION_DESCRIPTION',
                'icon' => 'key',
            ),
            'adminCallForwardingSets' => array(
                //'mainSectionModule' => true,
                'section' => 'admin',
                //'sectionTitle' => 'ADMIN_USER_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'ADMIN_CALL_FORWARDING_SETS_SECTION_TITLE',
                'description' => 'ADMIN_CALL_FORWARDING_SETS_DESCRIPTION',
                'icon' => 'retweet',
            ),
            'adminBilling' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'ADMIN_BILLING_SECTION_TITLE',
                'description' => 'ADMIN_BILLING_SECTION_DESCRIPTION',
                'icon' => 'money',
            ),
            'adminLdapInterface' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'ADMIN_LDAP_INTERFACE_SECTION_TITLE',
                'description' => 'ADMIN_LDAP_INTERFACE_SECTION_DESCRIPTION',
                'icon' => 'unlink',
            ),
            'adminSpeedDialList' => array(
                'section' => 'admin',
                'uiModule' => true,
                'title' => 'ADMIN_SPEED_DIAL_LIST_TITLE',
                'description' => 'PHONESETTINGS_SPEED_DIAL_SECTION_DESCRIPTION',
                'icon' => 'th',
            ),
//            'adminConfigurationOverview'=>array(
//                'section' => 'admin',
//                'uiModule' => true,
//                'title' => 'ADMIN_CONFIGURATION_OVERVIEW_SECTION_TITLE',
//                'description' => 'ADMIN_CONFIGURATION_OVERVIEW_SECTION_DESCRIPTION',
//                'icon'=>'adminConfigurationOverview',
//            ),
            /*
              'adminSubscriptions'=>array(
              'section' => 'admin',
              'uiModule' => true,
              'title' => 'SIP-Subscriptions',
              'description' => 'MWI/Dialog Ressources',
              ), */

            /////////Provisioning Section:
            'provisioning' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'provisioning',
                'sectionTitle' => 'PROVISIONING_GENERAL_MODULE_LABEL',
                'title' => 'PROVISIONING_GENERAL_SECTION_TITLE',
                'description' => 'PROVISIONING_GENERAL_SECTION_DESCRIPTION',
                'icon' => 'phone',
            ),
            'provisioningGeneral' => array(
                //'mainSectionModule' => true,
                'section' => 'provisioning',
                //'sectionTitle' => 'PROVISIONING_GENERAL_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'PROVISIONING_GENERAL_SECTION_TITLE',
                'description' => 'PROVISIONING_GENERAL_SECTION_DESCRIPTION',
                'icon' => 'phone',
            ),
            'provisioningFirmware' => array(
                //'mainSectionModule' => true,
                'section' => 'provisioning',
                //'sectionTitle' => 'PROVISIONING_FIRMWRE_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'PROVISIONING_FIRMWARE_SECTION_TITLE',
                'description' => 'PROVISIONING_FIRMWARE_SECTION_DESCRIPTION',
                'icon' => 'medkit',
            ),
            'provisioningProfile' => array(
                //'mainSectionModule' => true,
                'section' => 'provisioning',
                //'sectionTitle' => 'PROVISIONING_FIRMWRE_MODULE_LABEL',
                'uiModule' => true,
                'title' => 'PROVISIONING_PROFILE_SECTION_TITLE',
                'description' => 'PROVISIONING_PROFILE_SECTION_DESCRIPTION',
                'icon' => 'reorder'
            ),
            'provisioningKeyProfile' => array(
                'section' => 'provisioning',
                'uiModule' => true,
                'title' => 'PROVISIONING_KEY_PROFILE_SECTION_TITLE',
                'description' => 'PROVISIONING_KEY_PROFILE_SECTION_DESCRIPTION',
                'icon' => 'list',
            ),
            'provisioningRingtones' => array(
                'section' => 'provisioning',
                'uiModule' => true,
                'title' => 'PROVISIONING_RINGTONES_SECTION_TITLE',
                'description' => 'PROVISIONING_RINGTONES_SECTION_DESCRIPTION',
                'icon' => 'bell-alt',
            ),
            //             'routing'=>array(
            //                 //                         'mainSectionModule' => false,
            //                 //                         'section' => 'routing',
            //                 'sectionTitle' => 'ROUTING_MODULE_LABEL',
            //                 'uiModule' => false,
            //                 'title' => 'ROUTING_SECTION_TITLE',
            //                 'description' => 'ROUTING_SECTION_DESCRIPTION',
            //                 'icon'=>'routing',
            //             ),
            /////////Routing Section:
            'routing' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'sectionTitle' => 'ROUTING_GATEWAYS_MODULE_LABEL',
                'section' => 'routing',
                // 'uiModule' => true,
                'title' => 'ROUTING_GATEWAYS_SECTION_TITLE',
                'description' => 'ROUTING_GATEWAYS_SECTION_DESCRIPTION',
                'icon' => 'random',
            ),
            'routingGateways' => array(
                //'mainSectionModule' => false,
                //'sectionTitle' => 'ROUTING_GATEWAYS_MODULE_LABEL',
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'ROUTING_GATEWAYS_SECTION_TITLE',
                'description' => 'ROUTING_GATEWAYS_SECTION_DESCRIPTION',
                'icon' => 'road',
            ),
            'routingOutbound' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'ROUTING_OUTBOUND_SECTION_TITLE',
                'description' => 'ROUTING_OUTBOUND_SECTION_DESCRIPTION',
                'icon' => 'level-up',
            ),
            'routingInbound' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'ROUTING_INBOUND_SECTION_TITLE',
                'description' => 'ROUTING_INBOUND_SECTION_DESCRIPTION',
                'icon' => 'level-down',
            ),
            'routingBlacklist' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'BLACKLIST_SECTION_TITLE',
                'description' => 'BLACKLIST_SECTION_DESCRIPTION',
                'icon' => 'ban-circle'
            ),
            'routingIVR' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'IVR_SECTION_TITLE',
                'description' => 'IVR_SECTION_DESCRIPTION',
                'icon' => 'list-ol',
            ),
            'routingConference' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'CONFERECNCE_SECTION_TITLE',
                'description' => 'CONFERECNCE_SECTION_DESCRIPTION',
                'icon' => 'comments',
            ),
            'routingCallGroup' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'ROUTING_CALL_GROUP_SECTION_TITLE',
                'description' => 'ROUTING_CALL_GROUP_SECTION_DESCRIPTION',
                'icon' => 'tasks',
            ),
            'routingQueues' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'QUEUE_SECTION_TITLE',
                'description' => 'QUEUE_SECTION_DESCRIPTION',
                'icon' => 'repeat',
            ),
            'routingExternalAgent' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'EXTERNAL_AGENT_SECTION_TITLE',
                'description' => 'EXTERNAL_AGENT_SECTION_DESCRIPTION',
                'icon' => 'briefcase', // FIXME !
            ),
            'routingExternalHost' => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'EXTERNAL_HOST_SECTION_TITLE',
                'description' => 'EXTERNAL_HOST_SECTION_DESCRIPTION',
                'icon' => 'link',
            ),
            "routingScriptExtension" => array(
                'section' => 'routing',
                'uiModule' => true,
                'title' => 'SCRIPT_EXTENSION_SECTION_TITLE',
                'description' => 'SCRIPT_EXTENSION_SECTION_DESCRIPTION',
                'icon' => 'code', // FIXME
            ),
            /////////SystemGlobalConfig Section:
            'systemGlobalConfigGeneral' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'systemGlobalConfigGeneral',
                'sectionTitle' => 'SYSTEM_GLOBAL_CONFIG_GENERAL_MODULE_LABEL',
                'title' => 'SYSTEM_GLOBAL_CONFIG_SECTION_TITLE',
                'description' => 'SYSTEM_GLOBAL_CONFIG_GENERAL_SECTION_DESCRIPTION',
                'icon' => 'cogs',
            ),
            'systemOverview' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_OVERVIEW_SECTION_TITLE',
                'description' => 'SYSTEM_OVERVIEW_SECTION_DESCRIPTION',
                'icon' => 'lightbulb',
            ),
            'systemTranslationTags' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_TRANSLATION_TAGS_SECTION_TITLE',
                'description' => 'SYSTEM_TRANSLATION_TAGS_SECTION_DESCRIPTION',
                'icon' => 'phonesettingsNotifications',
            ),
            'systemGlobalConfig' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_GLOBAL_CONFIG_SECTION_TITLE',
                'description' => 'SYSTEM_GLOBAL_CONFIG_SECTION_DESCRIPTION',
                'icon' => 'wrench',
            ),
            'systemDateTimeProfile' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_DATE_TIME_PROFILE_SECTION_TITLE',
                'description' => 'SYSTEM_DATE_TIME_PROFILE_SECTION_DESCRIPTION',
                'icon' => 'time',
            ),
            'systemAudioFiles' => array(
                //'mainSectionModule' => true,
                'section' => 'systemGlobalConfigGeneral',
                //'sectionTitle' => 'Phonesettings',
                'uiModule' => true,
                'title' => 'SYSTEM_AUDIOFILES_SECTION_TITLE',
                'description' => 'SYSTEM_AUDIOFILES_SECTION_DESCRIPTION',
                'icon' => 'bullhorn',
            ),
            'systemMusicOnHold' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_MUSIC_ON_HOLD_SECTION_TITLE',
                'description' => 'SYSTEM_MUSIC_ON_HOLD_SECTION_DESCRIPTION',
                'icon' => 'music',
            ),
            'systemBackupRestore' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_BACKUP_RESTORE_TITLE',
                'description' => 'SYSTEM_BACKUP_RESTORE_DESCRIPTION',
                'icon' => 'archive',
            ),
            'systemLicence' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_LICENCE_SECTION_TITLE',
                'description' => 'SYSTEM_LICENCE_SECTION_DESCRIPTION',
                'icon' => 'paper-clip',
            ),
            'systemCDR' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_CDR_SECTION_TITLE',
                'description' => 'SYSTEM_CDR_SECTION_DESCRIPTION',
                'icon' => 'random',
            ),
            'systemLogViewer' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_LOGVIEWER_SECTION_TITLE',
                'description' => 'SYSTEM_LOGVIEWER_SECTION_DESCRIPTION',
                'icon' => 'terminal',
            ),
            'systemUpdate' => array(
                'section' => 'systemGlobalConfigGeneral',
                'uiModule' => true,
                'title' => 'SYSTEM_UPDATE_TITLE',
                'description' => 'SYSTEM_UPDATE_DESCRIPTION',
                'icon' => 'tags',
            ),
            /////////Network Section:
            'networkSettingsGeneral' => array(
                'type' => 'main',
                'mainSectionModule' => true,
                'section' => 'networkSettingsGeneral',
                'sectionTitle' => 'NETWORK_SETTINGS_GENERAL_MODULE_LABEL',
                'icon' => 'sitemap',
            ),
            'networkAdapterSettings' => array(
                'section' => 'networkSettingsGeneral',
                'uiModule' => true,
                'title' => 'NETWORK_ADAPTER_SETTINGS_TITLE',
                'description' => 'NETWORK_ADAPTER_SETTINGS_DESCRIPTION',
                'icon' => 'code-fork',
            ),
            'networkFirewall' => array(
                'section' => 'networkSettingsGeneral',
                'uiModule' => true,
                'title' => 'NETWORK_FIREWALL_TITLE',
                'description' => 'NETWORK_FIREWALL_DESCRIPTION',
                'icon' => 'shield',
            ),
            'networkDHCP' => array(
                'section' => 'networkSettingsGeneral',
                'uiModule' => true,
                'title' => 'NETWORK_DHCP_TITLE',
                'description' => 'NETWORK_DHCP_DESCRIPTION',
                'icon' => 'pushpin',
            ),
            'networkDNS' => array(
                'section' => 'networkSettingsGeneral',
                'uiModule' => true,
                'title' => 'NETWORK_DNS_TITLE',
                'description' => 'NETWORK_DNS_DESCRIPTION',
                'icon' => 'puzzle-piece',
            ),
            'networkCertificateSettings' => array(
                'section' => 'networkSettingsGeneral',
                'uiModule' => true,
                'title' => 'NETWORK_CERTIFICATE_SETTINGS_TITLE',
                'description' => 'NETWORK_CERTIFICATE_SETTINGS_DESCRIPTION',
                'icon' => 'certificate',
            ),
            'wizard' => array(
                'uiModule' => false,
            ),
            'avisoApi' => array(
                'uiModule' => false,
            ),
            /*
              'systemNumberTranslator'=>array(
              'section' => 'systemGlobalConfigGeneral',
              'uiModule' => true,
              'title' => 'SYSTEM_NUMBER_TRANSLATOR_SECTION_TITLE',
              'description' => 'SYSTEM_NUMBER_TRANSLATOR_SECTION_DESCRIPTION',
              'icon'=>'systemNumberTranslation',
              ),
             */
            'gii' => array(
                'class' => 'system.gii.GiiModule',
                'password' => 'password',
                // If removed, Gii defaults to localhost only. Edit carefully to taste.
                'ipFilters' => array('127.0.0.1', '::1'),
                'generatorPaths' => array(
                    'bootstrap.gii',
                ),
            ),
        );
        foreach ($modules as $moduleName => $values) {
            if (empty($modules[$moduleName]['icon'])) {
                $modules[$moduleName]['icon'] = 'frown';
            }
        }
        return $modules;
    }

    public static function getModuleTranslationTag($moduleId)
    {
        $module = ModuleManager::getModuleFromID($moduleId);
        $translationTag = '';
        if (isset($module['sectionTitle'])) {
            $translationTag = $module['sectionTitle'];
        }
        return $translationTag;
    }

    public static function getModuleFromID($moduleId)
    {
        $modules = ModuleManager::modules();
        $module = '';
        if ($moduleId !== '') {
            $module = $modules[$moduleId];
            if (!isset($module['mainSectionModule'])) {
                $module = $modules[$module['section']];
            }
        }
        return $module;
    }
}
