Spike PHPCoverage Details: system.module

Line #FrequencySource Line
1 <?php
2 // $Id: system.module,v 1.594 2008/04/01 20:05:15 dries Exp $
3 
4 /**
5  * @file
6  * Configuration system that lets administrators modify the workings of the site.
7  */
8 
9 /**
10  * The current system version.
11  */
12 define('VERSION', '7.0-dev');
13 
14 /**
15  * Core API compatibility.
16  */
17 define('DRUPAL_CORE_COMPATIBILITY', '7.x');
18 
19 /**
20  * Minimum supported version of PHP.
21  */
22 define('DRUPAL_MINIMUM_PHP',    '5.2.0');
23 
24 /**
25  * Minimum recommended value of PHP memory_limit.
26  */
27 define('DRUPAL_MINIMUM_PHP_MEMORY_LIMIT',    '16M');
28 
29 /**
30  * Minimum supported version of MySQL, if it is used.
31  */
32 define('DRUPAL_MINIMUM_MYSQL',  '5.0');
33 
34 /**
35  * Minimum supported version of PostgreSQL, if it is used.
36  */
37 define('DRUPAL_MINIMUM_PGSQL',  '7.4');
38 
39 /**
40  * Maximum age of temporary files in seconds.
41  */
42 define('DRUPAL_MAXIMUM_TEMP_FILE_AGE', 1440);
43 
44 /**
45  * Implementation of hook_help().
46  */
47 function system_help($path, $arg) {
48   global $base_url;
49 
50   switch ($path) {
51     case 'admin/help#system':
52       $output = '<p>'. t('The system module is at the foundation of your Drupal website, and provides basic but extensible functionality for use by other modules and themes. Some integral elements of Drupal are contained in and managed by the system module, including caching, enabling or disabling of modules and themes, preparing and displaying the administrative page, and configuring fundamental site settings. A number of key system maintenance operations are also part of the system module.') .'</p>';
53       $output .= '<p>'. t('The system module provides:') .'</p>';
54       $output .= '<ul><li>'. t('support for enabling and disabling <a href="@modules">modules</a>. Drupal comes packaged with a number of core modules; each module provides a discrete set of features and may be enabled depending on the needs of your site. A wide array of additional modules contributed by members of the Drupal community are available for download at the <a href="@drupal-modules">Drupal.org module page</a>.', array('@modules' => url('admin/build/modules'), '@drupal-modules' => 'http://drupal.org/project/modules')) .'</li>';
55       $output .= '<li>'. t('support for enabling and disabling <a href="@themes">themes</a>, which determine the design and presentation of your site. Drupal comes packaged with several core themes and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/build/themes'), '@drupal-themes' => 'http://drupal.org/project/themes')) .'</li>';
56       $output .= '<li>'. t('a robust <a href="@cache-settings">caching system</a> that allows the efficient re-use of previously-constructed web pages and web page components. Drupal stores the pages requested by anonymous users in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, Drupal\'s caching system may significantly increase the speed of your site.', array('@cache-settings' => url('admin/settings/performance'))) .'</li>';
57       $output .= '<li>'. t('a set of routine administrative operations that rely on a correctly-configured <a href="@cron">cron maintenance task</a> to run automatically. A number of other modules, including the feed aggregator, and search also rely on <a href="@cron">cron maintenance tasks</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>.', array('@cron' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron')) .'</li>';
58       $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
59       $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
60       return $output;
61     case 'admin':
62       return '<p>'. t('Welcome to the administration section. Here you may control how your site functions.') .'</p>';
63     case 'admin/by-module':
64       return '<p>'. t('This page shows you all available administration tasks for each module.') .'</p>';
65     case 'admin/build/themes':
66       $output = '<p>'. t('Select which themes are available to your users and specify the default theme. To configure site-wide display settings, click the "configure" task above. Alternatively, to override these settings in a specific theme, click the "configure" link for that theme. Note that different themes may have different regions available for displaying content; for consistency in presentation, you may wish to enable only one theme.') .'</p>';
67       $output .= '<p>'. t('To change the appearance of your site, a number of <a href="@themes">contributed themes</a> are available.', array('@themes' => 'http://drupal.org/project/themes')) .'</p>';
68       return $output;
69     case 'admin/build/themes/settings/'. $arg[4]:
70       $reference = explode('.', $arg[4], 2);
71       $theme = array_pop($reference);
72       return '<p>'. t('These options control the display settings for the <code>%template</code> theme. When your site is displayed using this theme, these settings will be used. By clicking "Reset to defaults," you can choose to use the <a href="@global">global settings</a> for this theme.', array('%template' => $theme, '@global' => url('admin/build/themes/settings'))) .'</p>';
73     case 'admin/build/themes/settings':
74       return '<p>'. t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') .'</p>';
75     case 'admin/build/modules':
76       $output = '<p>'. t('Modules are plugins that extend Drupal\'s core functionality. Enable modules by selecting the <em>Enabled</em> checkboxes below and clicking the <em>Save configuration</em> button. Once a module is enabled, new <a href="@permissions">permissions</a> may be available. To reduce server load, modules with their <em>Throttle</em> checkbox selected are temporarily disabled when your site becomes extremely busy. (Note that the <em>Throttle</em> checkbox is only available if the Throttle module is enabled.)', array('@permissions' => url('admin/user/permissions')));
77       if (module_exists('throttle')) {
78         $output .= ' '. t('The auto-throttle functionality must be enabled on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.', array('@throttle' => url('admin/settings/throttle')));
79       }
80       $output .= '</p>';
81       $output .= '<p>'. t('It is important that <a href="@update-php">update.php</a> is run every time a module is updated to a newer version.', array('@update-php' => $base_url .'/update.php')) .'</p>';
82       $output .= '<p>'. t('You can find all administration tasks belonging to a particular module on the <a href="@by-module">administration by module page</a>.', array('@by-module' => url('admin/by-module'))) .'</p>';
83       $output .= '<p>'. t('To extend the functionality of your site, a number of <a href="@modules">contributed modules</a> are available.', array('@modules' => 'http://drupal.org/project/modules')) .'</p>';
84       return $output;
85     case 'admin/build/modules/uninstall':
86       return '<p>'. t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it. Not all modules support this feature.') .'</p>';
87     case 'admin/build/block/configure':
88       if ($arg[4] == 'system' && $arg[5] == 0) {
89         return '<p>'. t('The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') .'</p>';
90       }
91       break;
92     case 'admin/settings/actions':
93     case 'admin/settings/actions/manage':
94       $output = '<p>'. t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the trigger module, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions.') .'</p>';
95       $output .= '<p>'. t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions can do more than simple actions; for example, send an e-mail to a specified address, or check for certain words within a piece of content. These actions need to be created and configured first before they may be used. To create an advanced action, select the action from the drop-down below and click the <em>Create</em> button.') .'</p>';
96       if (module_exists('trigger')) {
97         $output .= '<p>'. t('You may proceed to the <a href="@url">Triggers</a> page to assign these actions to system events.', array('@url' => url('admin/build/trigger'))) .'</p>';
98       }
99       return $output;
100     case 'admin/settings/actions/configure':
101       return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").');
102     case 'admin/reports/status':
103       return '<p>'. t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") .'</p>';
104   }
105 }
106 
107 /**
108  * Implementation of hook_theme().
109  */
110 function system_theme() {
111   return array_merge(drupal_common_theme(), array(
112     'system_theme_select_form' => array(
113       'arguments' => array('form' => NULL),
114       'file' => 'system.admin.inc',
115     ),
116     'system_themes_form' => array(
117       'arguments' => array('form' => NULL),
118       'file' => 'system.admin.inc',
119     ),
120     'system_modules' => array(
121       'arguments' => array('form' => NULL),
122       'file' => 'system.admin.inc',
123     ),
124     'system_modules_uninstall' => array(
125       'arguments' => array('form' => NULL),
126       'file' => 'system.admin.inc',
127     ),
128     'status_report' => array(
129       'arguments' => array('requirements' => NULL),
130       'file' => 'system.admin.inc',
131     ),
132     'admin_page' => array(
133       'arguments' => array('blocks' => NULL),
134       'file' => 'system.admin.inc',
135     ),
136     'admin_block' => array(
137       'arguments' => array('block' => NULL),
138       'file' => 'system.admin.inc',
139     ),
140     'admin_block_content' => array(
141       'arguments' => array('content' => NULL),
142       'file' => 'system.admin.inc',
143     ),
144     'system_admin_by_module' => array(
145       'arguments' => array('menu_items' => NULL),
146       'file' => 'system.admin.inc',
147     ),
148     'system_powered_by' => array(
149       'arguments' => array('image_path' => NULL),
150     ),
151     'system_compact_link' => array(),
152   ));
153 }
154 
155 /**
156  * Implementation of hook_perm().
157  */
158 function system_perm() {
159   return array(
160     'administer site configuration' => t('Configure site-wide settings such as module or theme administration settings.'),
161     'access administration pages' => t('View the administration panel and browse the help system.'),
162     'administer actions' => t('Manage the actions defined for your site.'),
163     'access site reports' => t('View reports from system logs and other status information.'),
164     'select different theme' => t('Select a theme other than the default theme set by the site administrator.'),
165     'administer files' => t('Manage user-uploaded files.'),
166   );
167 }
168 
169 /**
170  * Implementation of hook_elements().
171  */
172 function system_elements() {
173   // Top level form
174   $type['form'] = array(
175     '#method' => 'post',
176     '#action' => request_uri(),
177   );
178 
179   /**
180    * Input elements.
181    */
182   $type['submit'] = array(
183     '#input' => TRUE,
184     '#name' => 'op',
185     '#button_type' => 'submit',
186     '#executes_submit_callback' => TRUE,
187     '#process' => array('form_expand_ahah'),
188   );
189 
190   $type['button'] = array(
191     '#input' => TRUE,
192     '#name' => 'op',
193     '#button_type' => 'submit',
194     '#executes_submit_callback' => FALSE,
195     '#process' => array('form_expand_ahah'),
196   );
197 
198   $type['image_button'] = array(
199     '#input' => TRUE,
200     '#button_type' => 'submit',
201     '#executes_submit_callback' => TRUE,
202     '#process' => array('form_expand_ahah'),
203     '#return_value' => TRUE,
204     '#has_garbage_value' => TRUE,
205     '#src' => NULL,
206   );
207 
208   $type['textfield'] = array(
209     '#input' => TRUE,
210     '#size' => 60,
211     '#maxlength' => 128,
212     '#autocomplete_path' => FALSE,
213     '#process' => array('form_expand_ahah'),
214   );
215 
216   $type['password'] = array(
217     '#input' => TRUE,
218     '#size' => 60,
219     '#maxlength' => 128,
220     '#process' => array('form_expand_ahah'),
221   );
222 
223   $type['password_confirm'] = array(
224     '#input' => TRUE,
225     '#process' => array('expand_password_confirm'),
226   );
227 
228   $type['textarea'] = array(
229     '#input' => TRUE,
230     '#cols' => 60,
231     '#rows' => 5,
232     '#resizable' => TRUE,
233     '#process' => array('form_expand_ahah'),
234   );
235 
236   $type['radios'] = array(
237     '#input' => TRUE,
238     '#process' => array('expand_radios'),
239   );
240 
241   $type['radio'] = array(
242     '#input' => TRUE,
243     '#default_value' => NULL,
244     '#process' => array('form_expand_ahah'),
245   );
246 
247   $type['checkboxes'] = array(
248     '#input' => TRUE,
249     '#tree' => TRUE,
250     '#process' => array('expand_checkboxes'),
251   );
252 
253   $type['checkbox'] = array(
254     '#input' => TRUE,
255     '#return_value' => 1,
256     '#process' => array('form_expand_ahah'),
257   );
258 
259   $type['select'] = array(
260     '#input' => TRUE,
261     '#size' => 0,
262     '#multiple' => FALSE,
263     '#process' => array('form_expand_ahah'),
264   );
265 
266   $type['weight'] = array(
267     '#input' => TRUE,
268     '#delta' => 10,
269     '#default_value' => 0,
270     '#process' => array('process_weight', 'form_expand_ahah'),
271   );
272 
273   $type['date'] = array(
274     '#input' => TRUE,
275     '#element_validate' => array('date_validate'),
276     '#process' => array('expand_date'),
277   );
278 
279   $type['file'] = array(
280     '#input' => TRUE,
281     '#size' => 60,
282   );
283 
284 
285   /**
286    * Form structure.
287    */
288   $type['item'] = array(
289     '#value' => '',
290   );
291 
292   $type['hidden'] = array(
293     '#input' => TRUE,
294     '#process' => array('form_expand_ahah'),
295   );
296 
297   $type['value'] = array(
298     '#input' => TRUE,
299   );
300 
301   $type['markup'] = array(
302     '#prefix' => '',
303     '#suffix' => '',
304   );
305 
306   $type['fieldset'] = array(
307     '#collapsible' => FALSE,
308     '#collapsed' => FALSE,
309     '#value' => NULL,
310     '#process' => array('form_expand_ahah'),
311   );
312 
313   $type['token'] = array(
314     '#input' => TRUE,
315   );
316 
317   return $type;
318 }
319 
320 /**
321  * Implementation of hook_menu().
322  */
323 function system_menu() {
324   $items['system/files'] = array(
3251    'title' => 'File download',
326     'page callback' => 'file_download',
327     'access callback' => TRUE,
328     'type' => MENU_CALLBACK,
329   );
330   $items['admin'] = array(
3311    'title' => 'Administer',
332     'access arguments' => array('access administration pages'),
333     'page callback' => 'system_main_admin_page',
334     'weight' => 9,
335     'file' => 'system.admin.inc',
336   );
337   $items['admin/compact'] = array(
3381    'title' => 'Compact mode',
339     'page callback' => 'system_admin_compact_page',
340     'type' => MENU_CALLBACK,
341     'file' => 'system.admin.inc',
342   );
343   $items['admin/by-task'] = array(
3441    'title' => 'By task',
345     'page callback' => 'system_main_admin_page',
346     'file' => 'system.admin.inc',
347     'type' => MENU_DEFAULT_LOCAL_TASK,
348   );
349   $items['admin/by-module'] = array(
3501    'title' => 'By module',
351     'page callback' => 'system_admin_by_module',
352     'file' => 'system.admin.inc',
353     'type' => MENU_LOCAL_TASK,
354     'weight' => 2,
355   );
356   $items['admin/content'] = array(
3571    'title' => 'Content management',
358     'description' => "Manage your site's content.",
359     'position' => 'left',
360     'weight' => -10,
361     'page callback' => 'system_admin_menu_block_page',
362     'file' => 'system.admin.inc',
363   );
364 
365   // menu items that are basically just menu blocks
366   $items['admin/settings'] = array(
3671    'title' => 'Site configuration',
368     'description' => 'Adjust basic site configuration options.',
369     'position' => 'right',
370     'weight' => -5,
371     'page callback' => 'system_settings_overview',
372     'file' => 'system.admin.inc',
373   );
374   $items['admin/build'] = array(
3751    'title' => 'Site building',
376     'description' => 'Control how your site looks and feels.',
377     'position' => 'right',
378     'weight' => -10,
379     'page callback' => 'system_admin_menu_block_page',
380     'file' => 'system.admin.inc',
381   );
382   $items['admin/settings/admin'] = array(
3831    'title' => 'Administration theme',
384     'description' => 'Settings for how your administrative pages should look.',
385     'position' => 'left',
386     'page callback' => 'drupal_get_form',
387     'page arguments' => array('system_admin_theme_settings'),
388     'access arguments' => array('administer site configuration'),
389     'block callback' => 'system_admin_theme_settings',
390     'file' => 'system.admin.inc',
391   );
392   // Themes:
393   $items['admin/build/themes'] = array(
3941    'title' => 'Themes',
395     'description' => 'Change which theme your site uses or allows users to set.',
396     'page callback' => 'drupal_get_form',
397     'page arguments' => array('system_themes_form', NULL),
398     'access arguments' => array('administer site configuration'),
399     'file' => 'system.admin.inc',
400   );
401   $items['admin/build/themes/select'] = array(
4021    'title' => 'List',
403     'description' => 'Select the default theme.',
404     'type' => MENU_DEFAULT_LOCAL_TASK,
405     'weight' => -1,
406   );
407   $items['admin/build/themes/settings'] = array(
4081    'title' => 'Configure',
409     'page arguments' => array('system_theme_settings'),
410     'type' => MENU_LOCAL_TASK,
411   );
412   // Theme configuration subtabs
413   $items['admin/build/themes/settings/global'] = array(
4141    'title' => 'Global settings',
415     'type' => MENU_DEFAULT_LOCAL_TASK,
416     'weight' => -1,
417   );
418 
4191  foreach (list_themes() as $theme) {
4201    $items['admin/build/themes/settings/'. $theme->name] = array(
421       'title' => $theme->info['name'],
422       'page arguments' => array('system_theme_settings', $theme->name),
423       'type' => MENU_LOCAL_TASK,
424       'access callback' => '_system_themes_access',
425       'access arguments' => array($theme),
426     );
427   }
428 
429   // Modules:
430   $items['admin/build/modules'] = array(
4311    'title' => 'Modules',
432     'description' => 'Enable or disable add-on modules for your site.',
433     'page callback' => 'drupal_get_form',
434     'page arguments' => array('system_modules'),
435     'access arguments' => array('administer site configuration'),
436     'file' => 'system.admin.inc',
437   );
438   $items['admin/build/modules/list'] = array(
4391    'title' => 'List',
440     'type' => MENU_DEFAULT_LOCAL_TASK,
441   );
442   $items['admin/build/modules/list/confirm'] = array(
4431    'title' => 'List',
444     'type' => MENU_CALLBACK,
445   );
446   $items['admin/build/modules/uninstall'] = array(
4471    'title' => 'Uninstall',
448     'page arguments' => array('system_modules_uninstall'),
449     'type' => MENU_LOCAL_TASK,
450   );
451   $items['admin/build/modules/uninstall/confirm'] = array(
4521    'title' => 'Uninstall',
453     'type' => MENU_CALLBACK,
454   );