--[[ - @author Bruno Massa - @file system.module.lua - The system module coordinates all basic site administration settings ]] --[[ -- Determine if a user is in compact mode. ]] function system_admin_compact_mode() return ajato_choose(user['admin_compact_mode'], user['admin_compact_mode'], ajato_variable_get('admin_compact_mode', false)) end --[[ - Implementation of hook_elements(). ]] function system_elements() local type = {} -- Top level form type['form'] = { ['#action'] = ajato_path_format(sys['get']['q']), ['#method'] = 'post' } -- Inputs type['submit'] = { ['#button_type'] = 'submit', ['#ahah_event'] = 'submit', ['#executes_submit_callback'] = true, ['#input'] = true, ['#name'] = 'op', ['#process'] = {'expand_ahah'} } type['button'] = { ['#ahah_event'] = 'submit', ['#button_type'] = 'submit', ['#executes_submit_callback'] = false, ['#input'] = true, ['#name'] = 'op', ['#process'] = {'expand_ahah'} } type['image_button'] = { ['#ahah_event'] = 'submit', ['#button_type'] = 'submit', ['#executes_submit_callback'] = true, ['#has_garbage_value'] = true, ['#input'] = true, ['#process'] = {'expand_ahah'}, ['#return_value'] = true, ['#src'] = nil } type['textfield'] = { ['#autocomplete_path'] = false, ['#input'] = true, ['#maxlength'] = 128, ['#size'] = 60 } type['password'] = { ['#input'] = true, ['#size'] = 60, ['#maxlength'] = 128 } type['password_confirm'] = { ['#input'] = true, ['#process'] = {'expand_password_confirm'} } type['textarea'] = { ['#cols'] = 60, ['#input'] = true, ['#resizable'] = true, ['#rows'] = 5 } type['radios'] = { ['#input'] = true, ['#process'] = {'expand_radios'} } type['radio'] = { ['#default_value'] = nil, ['#input'] = true } type['checkboxes'] = { ['#input'] = true, ['#process'] = {'expand_checkboxes'}, ['#tree'] = true } type['checkbox'] = { ['#input'] = true, ['#return_value'] = 1 } type['select'] = { ['#input'] = true, ['#multiple'] = false, ['#size'] = 0 } type['weight'] = { ['#default_value'] = 0, ['#delta'] = 10, ['#input'] = true, ['#process'] = {'process_weight'} } type['date'] = { ['#element_validate'] = {'date_validate'}, ['#input'] = true, ['#process'] = {'expand_date'} } type['file'] = { ['#input'] = true, ['#size'] = 60 } -- Form structure type['item'] = { ['#value'] = '' } type['hidden'] = { ['#input'] = true } type['value'] = { ['#input'] = true } type['markup'] = { ['#prefix'] = '', ['#suffix'] = '' } type['fieldset'] = { ['#collapsed'] = false, ['#collapsible'] = false, ['#value'] = nil } type['token'] = { ['#input'] = true } return type end --[[ - Retrieves the current status of an array of files in the system table. - - @param files - Table, all files found on directories - @param plugin_type - String, the type of the plugin wanted ]] function system_get_files_database(files, plugin_type) -- Extract current files from database. local result = db_query([[SELECT path, name, type, status, throttle, schema_version FROM {plugin} WHERE type = %q]], plugin_type) for file in db_rows(result) do if files[file['name']] and type(files[file['name']]) == 'table' then file['old_path'] = file['path'] for key, value in pairs(file) do if not files[file['name']] or not files[file['name']][key] then files[file['name']][key] = value end end end end end --[[ - Implementation of hook_menu(). ]] function system_menu() items = {} items['admin'] = { ['access arguments'] = {'access administration pages'}, ['file'] = 'system.admin.lua', ['page callback'] = 'system_admin_main_page', ['title'] = 'Administer', ['weight'] = 9 } items['admin/build'] = { ['access arguments'] = {'administer site configuration'}, ['description'] = 'Control how your site looks and feels.', ['file'] = 'system.admin.lua', ['page callback'] = 'system_admin_C.MENU_block_page', ['position'] = 'right', ['title'] = 'Site building', ['weight'] = -10, } -- Themes: items['admin/build/themes'] = { ['description'] = 'Change which theme your site uses or allows users to set.', ['page arguments'] = {'system_themes_form', NULL}, ['page callback'] = 'ajato_form_get', ['title'] = 'Themes', } items['admin/build/themes/select'] = { ['description'] = 'Select the default theme.', ['title'] = 'List', ['type'] = C.MENU_DEFAULT_LOCAL_TASK, ['weight'] = -1, } items['admin/build/themes/settings'] = { ['title'] = 'Configure', ['type'] = C.MENU_LOCAL_TASK, } -- Theme configuration subtabs items['admin/build/themes/settings/global'] = { ['title'] = 'Global settings', ['type'] = C.MENU_DEFAULT_LOCAL_TASK, ['weight'] = -1, } -- Modules: items['admin/build/modules'] = { ['description'] = 'Enable or disable add-on modules for your site.', ['file'] = 'system.admin.lua', ['page arguments'] = {'system_modules'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Modules', } items['admin/build/modules/list'] = { ['file'] = 'system.admin.lua', ['title'] = 'List', ['type'] = C.MENU_DEFAULT_LOCAL_TASK, } items['admin/build/modules/list/confirm'] = { ['file'] = 'system.admin.lua', ['title'] = 'List', ['type'] = C.MENU_CALLBACK, } items['admin/build/modules/uninstall'] = { ['file'] = 'system.admin.lua', ['page arguments'] = {'system_modules_uninstall'}, ['title'] = 'Uninstall', ['type'] = C.MENU_LOCAL_TASK, } items['admin/build/modules/uninstall/confirm'] = { ['file'] = 'system.admin.lua', ['title'] = 'Uninstall', ['type'] = C.MENU_CALLBACK, } items['admin/by-module'] = { ['page callback'] = 'system_admin_by_module', ['title'] = 'By module', ['type'] = C.MENU_LOCAL_TASK, ['weight'] = 2, } items['admin/by-task'] = { ['file'] = 'system.admin.lua', ['page callback'] = 'system_main_admin_page', ['title'] = 'By task', ['type'] = C.MENU_DEFAULT_LOCAL_TASK, } items['admin/compact'] = { ['page callback'] = 'system_admin_compact_page', ['title'] = 'Compact mode', ['type'] = C.MENU_CALLBACK, } items['admin/content/rss-publishing'] = { ['access arguments'] = {'administer site configuration'}, ['description'] = 'Configure the number of items per feed and whether feeds should be titles/teasers/full-text.', ['page arguments'] = {'system_rss_feeds_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'RSS publishing', } -- Logs: items['admin/logs'] = { ['description'] = 'View system logs and other status information.', ['file'] = 'system.admin.lua', ['page callback'] = 'system_admin_C.MENU_block_page', ['position'] = 'left', ['title'] = 'Logs', ['weight'] = 5, } items['admin/logs/status'] = { ['access arguments'] = {'administer site configuration'}, ['description'] = "Get a status report about your site's operation and any detected problems.", ['page callback'] = 'system_status', ['title'] = 'Status report', ['weight'] = 10, } items['admin/logs/status/run-cron'] = { ['title'] = 'Run cron', ['page callback'] = 'system_run_cron', ['type'] = C.MENU_CALLBACK, } items['admin/logs/status/sql'] = { ['page callback'] = 'system_sql', ['title'] = 'SQL', ['type'] = C.MENU_CALLBACK, } -- Settings: items['admin/settings'] = { ['access arguments'] = {'administer site configuration'}, ['description'] = 'Adjust basic site configuration options.', ['page callback'] = 'system_settings_overview', ['position'] = 'right', ['title'] = 'Site configuration', ['weight'] = -5, } items['admin/settings/admin'] = { ['block callback'] = 'system_admin_theme_settings', ['description'] = 'Settings for how your administrative pages should look.', ['page arguments'] = {'system_admin_theme_settings'}, ['page callback'] = 'ajato_form_get', ['position'] = 'left', ['title'] = 'Administration theme', } items['admin/settings/clean-urls'] = { ['description'] = 'Enable or disable clean URLs for your site.', ['page arguments'] = {'system_clean_url_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Clean URLs', } items['admin/settings/site-information'] = { ['description'] = 'Change basic site information, such as the site name, slogan, e-mail address, mission, front page and more.', ['page arguments'] = {'system_site_information_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Site information', } items['admin/settings/date-time'] = { ['description'] = "Settings for how Ajato displays date and time, as well as the system's default timezone.", ['page arguments'] = {'system_date_time_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Date and time', } items['admin/settings/date-time/lookup'] = { ['page callback'] = 'system_date_time_lookup', ['title'] = 'Date and time lookup', ['type'] = C.MENU_CALLBACK, } items['admin/settings/error-reporting'] = { ['description'] = 'Control how Ajato deals with errors including 403/404 errors.', ['page arguments'] = {'system_error_reporting_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Error reporting', } items['admin/settings/file-system'] = { ['description'] = 'Tell Ajato where to store uploaded files and how they are accessed.', ['page arguments'] = {'system_file_system_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'File system', } items['admin/settings/image-toolkit'] = { ['description'] = 'Choose which image toolkit to use if you have installed optional toolkits.', ['page arguments'] = {'system_image_toolkit_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Image toolkit', } items['admin/settings/logging'] = { ['description'] = "Settings for logging and alerts modules. Various modules can route Ajato's system events to different destination, such as syslog, database, email, ...etc.", ['page callback'] = 'system_logging_overview', ['title'] = 'Logging and alerts', } items['admin/settings/performance'] = { ['description'] = 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.', ['page arguments'] = {'system_performance_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Performance', } items['admin/settings/site-maintenance'] = { ['description'] = 'Take the site off-line for maintenance or bring it back online.', ['page arguments'] = {'system_site_maintenance_settings'}, ['page callback'] = 'ajato_form_get', ['title'] = 'Site maintenance', } -- Default page for batch operations items['batch'] = { ['access callback'] = true, ['page callback'] = 'system_batch_page', ['type'] = C.MENU_CALLBACK, } items['system/files'] = { ['access callback'] = true, ['page callback'] = 'file_download', ['title'] = 'File download', ['type'] = C.MENU_CALLBACK, } return items end --[[ - Form process callback function to disable check boxes. - - @param form - Table, The structured form - @param edit - - @return - Table, the modified form ]] function system_modules_disable(form, edit) for _, key in pairs(form['#disabled_modules']) do form[key]['#attributes'] = form[key]['#attributes'] or {} form[key]['#attributes']['disabled'] = 'disabled' end end --[[ - Display the site status report. Can also be used as a pure check - - @param check - Boolean, TRUE only returns a boolean whether there are system status errors. ]] function system_status(check) -- Load .install files ajato_include_once('./includes/system.lua') ajato_install_load_updates() -- Check run-time requirements and status information local requirements = ajato_module_hook('requirements', true, 'runtime') if check then return (ajato_install_requirements_severity(requirements) == C.REQUIREMENT_ERROR) end return theme('status_report', requirements) end