/[drupal]/contributions/modules/update_status_aggregator/update_status_notifier.module
ViewVC logotype

Contents of /contributions/modules/update_status_aggregator/update_status_notifier.module

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


Revision 1.5 - (show annotations) (download) (as text)
Tue Mar 25 19:05:13 2008 UTC (20 months ago) by yrocq
Branch: MAIN
CVS Tags: DRUPAL-5--1-0-RC2, DRUPAL-5--1-1, DRUPAL-5--1-0, DRUPAL-5--1-3, DRUPAL-5--1-2, HEAD
Branch point for: DRUPAL-5--2, DRUPAL-5
Changes since 1.4: +3 -5 lines
File MIME type: text/x-php
Improved style with coder module
1 <?php
2 // $Id: update_status_notifier.module,v 1.4 2008/03/14 19:19:25 yrocq Exp $
3
4 /**
5 * @file
6 * Lets users check a remote site if some module are not up-to-date.
7 *
8 * Adds a text field when a node is displayed
9 * so that authenticated users may make notes.
10 */
11
12 /**
13 * Drupal menu Hook
14 */
15 function update_status_notifier_help($path, $arg=array()) {
16 switch ($path) {
17 case 'admin/help/update_status_notifier':
18 return '<p>'. t('Update Notifier is two modules: a "client" and a "server". The client, to be enabled on all sites that are to report to the central tracker, sends a list of installed modules and their status to the tracking site via xmlrpc when cron is run. This information is taken from the update status module. The server component, enabled on the tracking site, receives these lists from all the clients and creates nodes for each module. These nodes will then get updated everytime the cron is run on the tracked sites. For the tracked sites to have the right to create these nodes, the keys of the tracked sites need to be entered into the tracker site.') .'</p>';
19
20 case 'admin/settings/update_status_notifier':
21 return t('<p>You need to copy this drupal key somewhere because
22 your gona need it later in the configuration of the server module
23 of update notifier.</p><p>Also, you must add the XML-RPC URL of the server/tracker site (e.g. http://trackeRsite.example.com/xmlrpc.php</p>');
24 }
25 }
26
27
28 /**
29 * Drupal menu Hook
30 */
31 function update_status_notifier_menu($may_cache) {
32 $items = array();
33 if ($may_cache) {
34 $items[] = array(
35 'path' => 'admin/settings/update_status_notifier',
36 'title' => t('Update status notifier'),
37 'description' => t('Set the remote site where to send update module.'),
38 'callback' => 'drupal_get_form',
39 'callback arguments' => array('update_status_notifier_settings'),
40 'access' => user_access('administer site configuration')
41 );
42 }
43 return $items;
44 }
45
46
47 /**
48 * Implementation of hook_cron().
49 */
50 function update_status_notifier_cron() {
51 update_status_notifier_xml_status();
52 }
53
54
55 function update_status_notifier_settings() {
56 $form['update_status_notifier_details'] = array(
57 '#value' => t("The MD5sum of your Drupal key is:") ." ". md5(variable_get('drupal_private_key', 0)),
58 );
59 $form['update_notifier_server'] = array(
60 '#type' => 'textfield',
61 '#title' => t('Remote site XML-RPC address'),
62 '#size' => 60,
63 '#maxlength' => 128,
64 '#default_value' => variable_get('update_notifier_server', ''),
65 '#required' => TRUE,
66 );
67
68 return system_settings_form($form);
69 }
70
71 function update_status_notifier_settings_client_submit($form_id, $form_values) {
72 variable_set('update_notifier_server', $form_values['update_notifier_server']);
73 }
74
75 function update_status_notifier_xml_status() {
76 if ($available = update_status_get_available(TRUE)) {
77 $data = update_status_calculate_project_data($available);
78 $pack = array();
79 $pack['key'] = md5(variable_get('drupal_private_key', 0));
80 foreach ($data as $project) {
81 $pack['modules'][$project['short_name']] = $project['status'];
82 }
83
84 $url = variable_get('update_notifier_server', 'localhost');
85 $method_name = 'update_status_aggregator.notify';
86 $result = xmlrpc($url, $method_name, $pack);
87
88 if (xmlrpc_error()) {
89 watchdog('update_status_aggregator', t('Error %errorno : %errormsg', array('%errorno' => xmlrpc_errno(), '%errormsg' => xmlrpc_error_msg())));
90 }
91 else {
92 watchdog('update_status_aggregator', t('Update informations sent to server'));
93 }
94 }
95 }

  ViewVC Help
Powered by ViewVC 1.1.2