This repository has been archived by the owner on Jan 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsso_refund_checks.module
executable file
·156 lines (114 loc) · 4.29 KB
/
sso_refund_checks.module
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
// $Id$
/**
* @file
* This file contain functions allow students sso to Sallie Mae Check Refund Site.
*/
/**
* Implement hook_menu
*/
function sso_refund_checks_menu() {
//create menu item to remove page
$items['refunds'] = array(
'title' => 'Sallie Mae Refund Checks',
'menu_name' => 'primary-links',
'page callback' => 'sso_refund_checks_sallie_maeform',
'access callback' => TRUE,
);
//create menu item to remove page
$items['admin/settings/fhchs/sso_refund_checks'] =array(
'title' => 'Sallie Mae SSO Refund Checks Settings',
'description' => 'Configure Sallie Mae SSO Refund Checks Settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('sso_refund_checks_setitings'),
'access arguments' => array('admin sso refund check'),
);
return $items;
}
/**
* Implement hook_permission
*/
function sso_refund_checks_perm() {
return array(
'check refund sso',
'admin sso refund check');
}
/**
* Display function to sing on to Sallie Refund checks site.
*
* @return string Sallie Mae sing on form.
*
*/
function sso_refund_checks_sallie_maeform() {
//Get current user login
global $user;
$testing = 0;
//Get Sallie Mae URL
$sallie_mae_url = variable_get('sso_check_refund_url', '');
if(fhchs_utility_get_user_type($user->name) == 'employee' && ($testing == 1)) {
$employee_soc_sec = sonisweb_integration_api("SonisWeb200.CustomPages.password_changer", "getSonisId", "yes",
array(array('opid', $user->name)));
}
//Check if url is not empty
if ($sallie_mae_url !== '') {
$display = sonisweb_integration_api('CFC.sallie_mae', 'sso_check_refund', 'yes', array(array('sonis_ds', '#sonis.ds#'),
array('url', $sallie_mae_url),
array('account', isset($employee_soc_sec)?$employee_soc_sec:$user->name)
));
}
if (fhchs_utility_get_user_type($user->name) == 'student') {
//submit form to SSO redirect
$display .= '<script type="text/javascript">document.sso.submit();</script>';
} //This is just for testing purposes user testing the environment are goint to be employees
elseif(fhchs_utility_get_user_type($user->name) == 'employee' && ($testing == 1)) {
//Get test user information
$display .= '<script type="text/javascript">document.sso.submit();$</script>';
}
else {
$display = '<br /><br />Hey there, Looks like the page you\'re trying to visit requires you to be logged into my.FHCHS.edu as a student.';
}
//$display = '<br /><br />Oops! Sorry! Due to technical difficulties, the refund sign-up process is off-line. We\'re working hard to make it available again soon.<br /><br />';
//Return form
return $display;
}
function sso_refund_checks_setitings($form_state) {
//Get URL varible
$sallie_mae_url = variable_get('sso_check_refund_url', '');
//give the form a name
$form['#attributes'] = array('name' => 'sso_refund_checks_setitings');
//display the label and the text filed to hold name
$form['sallie_mae_url'] = array(
'#type' => 'textfield',
'#title' => t('Sallie Mae SSO URL'),
'#default_value' => $sallie_mae_url,
'#size' => 100,
'#maxlength' => 100,
'#required' => TRUE,
'#description' => t('This is the URL were the users sign on form will post.'),
'#disabled' => FALSE,
);
//display submit button
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Settings'),
);
return $form;
}
/**
* Implement hook_validate
*/
function sso_refund_checks_setitings_validate($form, &$form_state) {
$good_url = preg_match("#((http|https)://(\S*?\.\S*?))(\s|\;|\)|\]|\[|\{|\}|,|\"|'|:|\<|$|\.\s)#ie",
$form_state['values']['sallie_mae_url'] );
//If is not a valid URL set a form error
if (!$good_url) {
form_set_error('sallie_mae_url', 'The URL is not a valid formed URL.');
}
}
/**
* Implement hook_submit
*/
function sso_refund_checks_setitings_submit($form, &$form_state) {
//Save URL
variable_set('sso_check_refund_url', $form_state['values']['sallie_mae_url']);
}