-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformezauth.module
153 lines (125 loc) · 4.04 KB
/
formezauth.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
<?php
/**
* Include main API functions.
*/
module_load_include('inc', 'formezauth', 'formezauth_admin');
module_load_include('inc', 'formezauth', 'formezauth_block');
module_load_include('inc', 'formezauth', 'formezauth_user');
define('FORMEZAUTH_DEBUG_VERBOSE', false);
/**
* Implements hook_menu().
*
* @see formezauth_form()
*/
function formezauth_menu() {
$items = array();
$items['admin/config/services/formezauth'] = array(
'title' => 'FormezAuth',
'description' => 'Configurazione dell\'autenticazione tramite FormezAuth',
'page callback' => '_formezauth_hello',
'access arguments' => array('access administration pages'),
'weight'=>0,
'type' => MENU_NORMAL_ITEM,
);
$items['admin/config/services/formezauth/init'] = array(
'title' => 'Variabili FormezAuth',
'description' => 'Variabili',
'page callback' => 'drupal_get_form',
'page arguments' => array('formezauth_form'),
'access arguments' => array('access administration pages'),
'weight'=>5,
'type' => MENU_LOCAL_TASK,
);
$items['admin/config/services/formezauth/map'] = array(
'title' => 'Mappatura campi',
'description' => 'Mappatura dei campi FormezAuth con i campi resi disponibili sul server',
'page callback' => 'drupal_get_form',
'page arguments' => array('formezauth_form2'),
'access arguments' => array('access administration pages'),
'weight'=>10,
'type' => MENU_LOCAL_TASK,
);
/*
$items['admin/config/services/formezauth/test'] = array(
'title' => 'Test',
'description' => 'Pagina di test',
'page callback' => '_formezauth_test_page1',
'access arguments' => array('access administration pages'),
'weight'=>30,
'type' => MENU_LOCAL_TASK,
);
*/
$items['admin/config/services/formezauth/fields'] = array(
'title' => 'Campi disponibili',
'description' => 'Documentazione dei campi disponibili dal server, tramite interrogazione al file doc/fields',
'page callback' => '_formezauth_server_fields',
'access arguments' => array('access administration pages'),
'weight'=>20,
'type' => MENU_LOCAL_TASK,
);
$items['admin/config/services/formezauth/refresh_fields'] = array(
'title' => 'Campi disponibili',
'description' => 'Aggiornamento e documentazione dei campi disponibili dal server, tramite interrogazione al file doc/fields',
'page callback' => '_formezauth_refresh_server_fields',
'access arguments' => array('access administration pages'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Pagina di test: non serve a nulla se non in fase di sviluppo
* per testare cose.
*/
function _formezauth_test_page1(){
global $user;
//$provider=oauthconnector_provider_load('formezauth');
if(function_exists('profile2_load_by_user')){
$profile=profile2_load_by_user($user);
}
dsm($profile);
dsm($user);
$u = user_load($user->uid);
dsm($u);
$out="";
$uuid_user = entity_uuid_load('user', array($user->uuid));
dsm($uuid_user);
return $out;
}
/**
*
* Questa non sembra funzionare...
**/
function formezauth_form_profile2_form_alter(&$form, &$form_state) {
// Your alterations.
}
/**
* Implements oauthconnector_fetch_field_value
* Aggiunge una creazione di sessione che sarà poi utilizzata in fase di login
* @see formezauth_user_login()
*/
function formezauth_oauthconnector_fetch_field_value_alter($a, $b, $c){
$_SESSION['oauth_user_data']=$b;
}
/**
* Implements hook_connector_action_alter().
* We change the default connector to redirect to our own action.
*/
function formezauth_connector_action_alter(&$connector_actions) {
/*
$fp=fopen('/tmp/debug.fa.log', "w");
fwrite($fp, json_encode($connector_actions));
fclose($fp);
*/
$connector_actions['default']['create account callback'] = '_formezauth_create_account';
}
/**
* Carica il javascript che apre l'autenticazione nel popup
*
*/
function formezauth_init($all_pages=true){
// Check for front page
if(drupal_is_front_page() || $all_pages){
drupal_add_js( drupal_get_path('module', 'formezauth') . '/formezauth.js');
}
}
// fine --