/[drupal]/drupal/modules/update/update.api.php
ViewVC logotype

Contents of /drupal/modules/update/update.api.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Sat Aug 22 14:34:23 2009 UTC (3 months ago) by webchick
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, DRUPAL-7-0-UNSTABLE-9, HEAD
Changes since 1.3: +2 -2 lines
File MIME type: text/x-php
#326539 by JohnAlbin, sun, cha0s, ultimateboy, Rob Loach, Damien Tournoud: Convert 'class' attribute to use an array, not a string.
1 <?php
2 // $Id: update.api.php,v 1.3 2009/06/05 01:04:11 webchick Exp $
3
4 /**
5 * @file
6 * Hooks provided by the Update Status module.
7 */
8
9 /**
10 * @addtogroup hooks
11 * @{
12 */
13
14 /**
15 * Alter the list of projects before fetching data and comparing versions.
16 *
17 * Most modules will never need to implement this hook. It is for advanced
18 * interaction with the update status module: mere mortals need not apply.
19 * The primary use-case for this hook is to add projects to the list, for
20 * example, to provide update status data on disabled modules and themes. A
21 * contributed module might want to hide projects from the list, for example,
22 * if there is a site-specific module that doesn't have any official releases,
23 * that module could remove itself from this list to avoid "No available
24 * releases found" warnings on the available updates report. In rare cases, a
25 * module might want to alter the data associated with a project already in
26 * the list.
27 *
28 * @param $projects
29 * Reference to an array of the projects installed on the system. This
30 * includes all the metadata documented in the comments below for each
31 * project (either module or theme) that is currently enabled. The array is
32 * initially populated inside update_get_projects() with the help of
33 * _update_process_info_list(), so look there for examples of how to
34 * populate the array with real values.
35 *
36 * @see update_get_projects()
37 * @see _update_process_info_list()
38 */
39 function hook_update_projects_alter(&$projects) {
40 // Hide a site-specific module from the list.
41 unset($projects['site_specific_module']);
42
43 // Add a disabled module to the list.
44 // The key for the array should be the machine-readable project "short name".
45 $projects['disabled_project_name'] = array(
46 // Machine-readable project short name (same as the array key above).
47 'name' => 'disabled_project_name',
48 // Array of values from the main .info file for this project.
49 'info' => array(
50 'name' => 'Some disabled module',
51 'description' => 'A module not enabled on the site that you want to see in the available updates report.',
52 'version' => '7.x-1.0',
53 'core' => '7.x',
54 // The maximum file change time (the "ctime" returned by the filectime()
55 // PHP method) for all of the .info files included in this project.
56 '_info_file_ctime' => 1243888165,
57 ),
58 // The date stamp when the project was released, if known. If the disabled
59 // project was an officially packaged release from drupal.org, this will
60 // be included in the .info file as the 'datestamp' field. This only
61 // really matters for development snapshot releases that are regenerated,
62 // so it can be left undefined or set to 0 in most cases.
63 'datestamp' => 1243888185,
64 // Any modules (or themes) included in this project. Keyed by machine-
65 // readable "short name", value is the human-readable project name printed
66 // in the UI.
67 'includes' => array(
68 'disabled_project' => 'Disabled module',
69 'disabled_project_helper' => 'Disabled module helper module',
70 'disabled_project_foo' => 'Disabled module foo add-on module',
71 ),
72 // Does this project contain a 'module', 'theme', 'disabled-module', or
73 // 'disabled-theme'?
74 'project_type' => 'disabled-module',
75 );
76 }
77
78 /**
79 * Alter the information about available updates for projects.
80 *
81 * @param $projects
82 * Reference to an array of information about available updates to each
83 * project installed on the system.
84 *
85 * @see update_calculate_project_data()
86 */
87 function hook_update_status_alter(&$projects) {
88 $settings = variable_get('update_advanced_project_settings', array());
89 foreach ($projects as $project => $project_info) {
90 if (isset($settings[$project]) && isset($settings[$project]['check']) &&
91 ($settings[$project]['check'] == 'never' ||
92 (isset($project_info['recommended']) &&
93 $settings[$project]['check'] === $project_info['recommended']))) {
94 $projects[$project]['status'] = UPDATE_NOT_CHECKED;
95 $projects[$project]['reason'] = t('Ignored from settings');
96 if (!empty($settings[$project]['notes'])) {
97 $projects[$project]['extra'][] = array(
98 'class' => array('admin-note'),
99 'label' => t('Administrator note'),
100 'data' => $settings[$project]['notes'],
101 );
102 }
103 }
104 }
105 }
106
107 /**
108 * @} End of "addtogroup hooks".
109 */

  ViewVC Help
Powered by ViewVC 1.1.2