Dropdown::getStandardDropdownItemTypes PHP Method

getStandardDropdownItemTypes() static public method

Get the dropdown list name the user is allowed to edit
static public getStandardDropdownItemTypes ( ) : array
return array (group of dropdown) of array (itemtype => localized name)
    static function getStandardDropdownItemTypes()
    {
        global $CFG_GLPI;
        static $optgroup = NULL;
        if (is_null($optgroup)) {
            $optgroup = array(__('Common') => array('Location' => _n('Location', 'Locations', Session::getPluralNumber()), 'State' => _n('Status of items', 'Statuses of items', Session::getPluralNumber()), 'Manufacturer' => _n('Manufacturer', 'Manufacturers', Session::getPluralNumber()), 'Blacklist' => _n('Blacklist', 'Blacklists', Session::getPluralNumber()), 'BlacklistedMailContent' => __('Blacklisted mail content')), __('Assistance') => array('ITILCategory' => _n('Ticket category', 'Ticket categories', Session::getPluralNumber()), 'TaskCategory' => _n('Task category', 'Task categories', Session::getPluralNumber()), 'TaskTemplate' => _n('Task template', 'Task templates', Session::getPluralNumber()), 'SolutionType' => _n('Solution type', 'Solution types', Session::getPluralNumber()), 'RequestType' => _n('Request source', 'Request sources', Session::getPluralNumber()), 'SolutionTemplate' => _n('Solution template', 'Solution templates', Session::getPluralNumber()), 'ProjectState' => _n('Project state', 'Project states', Session::getPluralNumber()), 'ProjectType' => _n('Project type', 'Project types', Session::getPluralNumber()), 'ProjectTaskType' => _n('Project tasks type', 'Project tasks types', Session::getPluralNumber())), _n('Type', 'Types', Session::getPluralNumber()) => array('ComputerType' => _n('Computer type', 'Computers types', Session::getPluralNumber()), 'NetworkEquipmentType' => _n('Networking equipment type', 'Networking equipment types', Session::getPluralNumber()), 'PrinterType' => _n('Printer type', 'Printer types', Session::getPluralNumber()), 'MonitorType' => _n('Monitor type', 'Monitor types', Session::getPluralNumber()), 'PeripheralType' => _n('Devices type', 'Devices types', Session::getPluralNumber()), 'PhoneType' => _n('Phone type', 'Phones types', Session::getPluralNumber()), 'SoftwareLicenseType' => _n('License type', 'License types', Session::getPluralNumber()), 'CartridgeItemType' => _n('Cartridge type', 'Cartridge types', Session::getPluralNumber()), 'ConsumableItemType' => _n('Consumable type', 'Consumable types', Session::getPluralNumber()), 'ContractType' => _n('Contract type', 'Contract types', Session::getPluralNumber()), 'ContactType' => _n('Contact type', 'Contact types', Session::getPluralNumber()), 'DeviceMemoryType' => _n('Memory type', 'Memory types', Session::getPluralNumber()), 'SupplierType' => _n('Third party type', 'Third party types', Session::getPluralNumber()), 'InterfaceType' => _n('Interface type (Hard drive...)', 'Interface types (Hard drive...)', Session::getPluralNumber()), 'DeviceCaseType' => _n('Case type', 'Case types', Session::getPluralNumber()), 'PhonePowerSupply' => _n('Phone power supply type', 'Phones power supply types', Session::getPluralNumber()), 'Filesystem' => _n('File system', 'File systems', Session::getPluralNumber()), 'BudgetType' => _n('Budget type', 'Budget types', Session::getPluralNumber())), __('Model') => array('ComputerModel' => _n('Computer model', 'Computer models', Session::getPluralNumber()), 'NetworkEquipmentModel' => _n('Networking equipment model', 'Networking equipment models', Session::getPluralNumber()), 'PrinterModel' => _n('Printer model', 'Printer models', Session::getPluralNumber()), 'MonitorModel' => _n('Monitor model', 'Monitor models', Session::getPluralNumber()), 'PeripheralModel' => _n('Peripheral model', 'Peripheral models', Session::getPluralNumber()), 'PhoneModel' => _n('Phone model', 'Phone models', Session::getPluralNumber())), _n('Virtual machine', 'Virtual machines', Session::getPluralNumber()) => array('VirtualMachineType' => _n('Virtualization system', 'Virtualization systems', Session::getPluralNumber()), 'VirtualMachineSystem' => _n('Virtualization model', 'Virtualization models', Session::getPluralNumber()), 'VirtualMachineState' => _n('State of the virtual machine', 'States of the virtual machine', Session::getPluralNumber())), __('Management') => array('DocumentCategory' => _n('Document heading', 'Document headings', Session::getPluralNumber()), 'DocumentType' => _n('Document type', 'Document types', Session::getPluralNumber())), __('Tools') => array('KnowbaseItemCategory' => _n('Knowledge base category', 'Knowledge base categories', Session::getPluralNumber())), __('Calendar') => array('Calendar' => _n('Calendar', 'Calendars', Session::getPluralNumber()), 'Holiday' => _n('Close time', 'Close times', Session::getPluralNumber())), _n('Operating system', 'Operating systems', Session::getPluralNumber()) => array('OperatingSystem' => _n('Operating system', 'Operating systems', Session::getPluralNumber()), 'OperatingSystemVersion' => _n('Version of the operating system', 'Versions of the operating system', Session::getPluralNumber()), 'OperatingSystemServicePack' => _n('Service pack', 'Service packs', Session::getPluralNumber()), 'OperatingSystemArchitecture' => _n('Operating system architecture', 'Operating system architectures', Session::getPluralNumber()), 'AutoUpdateSystem' => _n('Update source', 'Update sources', Session::getPluralNumber())), __('Networking') => array('NetworkInterface' => _n('Network interface', 'Network interfaces', Session::getPluralNumber()), 'NetworkEquipmentFirmware' => _n('Firmware', 'Firmwares', Session::getPluralNumber()), 'Netpoint' => _n('Network outlet', 'Network outlets', Session::getPluralNumber()), 'Domain' => _n('Domain', 'Domains', Session::getPluralNumber()), 'Network' => _n('Network', 'Networks', Session::getPluralNumber()), 'Vlan' => __('VLAN')), __('Internet') => array('IPNetwork' => _n('IP network', 'IP networks', Session::getPluralNumber()), 'FQDN' => _n('Internet domain', 'Internet domains', Session::getPluralNumber()), 'WifiNetwork' => _n('Wifi network', 'Wifi networks', Session::getPluralNumber()), 'NetworkName' => _n('Network name', 'Network names', Session::getPluralNumber())), _n('Software', 'Software', 1) => array('SoftwareCategory' => _n('Software category', 'Software categories', Session::getPluralNumber())), __('User') => array('UserTitle' => _n('User title', 'Users titles', Session::getPluralNumber()), 'UserCategory' => _n('User category', 'User categories', Session::getPluralNumber())), __('Authorizations assignment rules') => array('RuleRightParameter' => _n('LDAP criterion', 'LDAP criteria', Session::getPluralNumber())), __('Fields unicity') => array('Fieldblacklist' => _n('Ignored value for the unicity', 'Ignored values for the unicity', Session::getPluralNumber())), __('External authentications') => array('SsoVariable' => _n('Field storage of the login in the HTTP request', 'Fields storage of the login in the HTTP request', Session::getPluralNumber())));
            //end $opt
            $plugdrop = Plugin::getDropdowns();
            if (count($plugdrop)) {
                $optgroup = array_merge($optgroup, $plugdrop);
            }
            foreach ($optgroup as $label => $dp) {
                foreach ($dp as $key => $val) {
                    if ($tmp = getItemForItemtype($key)) {
                        if (!$tmp->canView()) {
                            unset($optgroup[$label][$key]);
                        }
                    } else {
                        unset($optgroup[$label][$key]);
                    }
                }
                if (count($optgroup[$label]) == 0) {
                    unset($optgroup[$label]);
                }
            }
        }
        return $optgroup;
    }

Usage Example

Example #1
0
echo _n('GLPI object', 'GLPI objects', 1, 'formcreator');
?>
            </label>
            <label for="dropdown_ldap_auth<?php 
echo $rand;
?>
" id="label_glpi_ldap">
               <?php 
echo _n('LDAP directory', 'LDAP directories', 1);
?>
            </label>
         </td>
         <td>
            <div id="dropdown_values_field">
               <?php 
$optgroup = Dropdown::getStandardDropdownItemTypes();
array_unshift($optgroup, '---');
Dropdown::showFromArray('dropdown_values', $optgroup, array('value' => $question->fields['values'], 'rand' => $rand, 'on_change' => 'change_dropdown();'));
?>
            </div>
            <div id="glpi_objects_field">
               <?php 
$optgroup = array(__("Assets") => array('Computer' => _n("Computer", "Computers", 2), 'Monitor' => _n("Monitor", "Monitors", 2), 'Software' => _n("Software", "Software", 2), 'Networkequipment' => _n("Network", "Networks", 2), 'Peripheral' => _n("Device", "Devices", 2), 'Printer' => _n("Printer", "Printers", 2), 'Cartridgeitem' => _n("Cartridge", "Cartridges", 2), 'Consumableitem' => _n("Consumable", "Consumables", 2), 'Phone' => _n("Phone", "Phones", 2)), __("Assistance") => array('Ticket' => _n("Ticket", "Tickets", 2), 'Problem' => _n("Problem", "Problems", 2), 'TicketRecurrent' => __("Recurrent tickets")), __("Management") => array('Budget' => _n("Budget", "Budgets", 2), 'Supplier' => _n("Supplier", "Suppliers", 2), 'Contact' => _n("Contact", "Contacts", 2), 'Contract' => _n("Contract", "Contracts", 2), 'Document' => _n("Document", "Documents", 2)), __("Tools") => array('Notes' => __("Notes"), 'RSSFeed' => __("RSS feed")), __("Administration") => array('User' => _n("User", "Users", 2), 'Group' => _n("Group", "Groups", 2), 'Entity' => _n("Entity", "Entities", 2), 'Profile' => _n("Profile", "Profiles", 2)));
array_unshift($optgroup, '---');
Dropdown::showFromArray('glpi_objects', $optgroup, array('value' => $question->fields['values'], 'rand' => $rand, 'on_change' => 'change_glpi_objects();'));
?>
            </div>
            <div id="glpi_ldap_field">
            <?php 
$ldap_values = json_decode($question->fields['values']);
Dropdown::show('AuthLDAP', array('name' => 'ldap_auth', 'rand' => $rand, 'value' => isset($ldap_values->ldap_auth) ? $ldap_values->ldap_auth : '', 'on_change' => 'change_LDAP(this)'));
All Usage Examples Of Dropdown::getStandardDropdownItemTypes