-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_post_receive.module
More file actions
54 lines (49 loc) · 1.42 KB
/
Copy pathgithub_post_receive.module
File metadata and controls
54 lines (49 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Implements hook_menu().
*/
function github_post_receive_menu() {
$items['admin/config/services/github'] = array(
'title' => t('Github Post Recieve admin settings form'),
'page callback' => 'drupal_get_form',
'page arguments' => array('github_post_receive_admin_settings'),
'file' => 'github_post_receive.include.admin.inc',
'access arguments' => array('administer github post receive'),
'type' => MENU_SUGGESTED_ITEM,
);
$items['github'] = array(
'page callback' => 'github_post_receive_execute',
'access callback' => 'github_post_receive_access',
'type' => MENU_CALLBACK,
);
return $items;
}
function github_post_receive_access() {
if($ip_restriction = variable_get('github_post_receive_ip_restriction','127.0.0.1')) {
preg_replace('/s','',$ip_restriction);
$ip_list = explode(',',$ip_restriction);
if (!in_array(ip_address(),$ip_list)) {
return FALSE;
}
}
return TRUE;
}
/**
* Implements hook_permission().
*/
function github_post_receive_permission() {
return array(
'administer github post receive' => array(
'title' => t('Administer github post receive'),
'description' => t('Perform administration tasks for Github integration.'),
),
);
}
function github_post_receive_execute() {
if(isset($_POST)){
drupal_json_output(array('post data' => $_POST));
}
else {
drupal_json_output(array('error' => 'No Post Data'));
}
}