-
Notifications
You must be signed in to change notification settings - Fork 0
/
moodle_drupal.module
91 lines (73 loc) · 2.22 KB
/
moodle_drupal.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
<?php
print 'heaiudiasbdiasnidasd';
//swarad hello
/**
* Implementation of hook_user().
*/
function moodle_drupal_user($op, &$edit, &$account, $category = NULL) {
//$ses = session_name();
//$ses_cookie = $_COOKIE[$ses];
//print($user);
//print $a;exit;
switch ($op) {
case 'login':
global $user;
watchdog('sid',$user->sid);
watchdog('account',serialize($account));
//setcookie("site_username",$account->name, time()+3600*24, '/', '.localhost.com');
setcookie("site_username",$user->name, time()+3600*24,'/','.devstu_dev.bliss-dev.com');
setcookie("site_pass",$user->pass, time()+3600*24, '/', '.devstu_dev.bliss-dev.com');
break;
case 'logout':
sso_logout($account);
break;
case 'default':
break;
}
//return $temp;
}
/**
* unSets cookies after logout
*/
function sso_logout($account)
{
setcookie("site_username",'',0,'/','.devstu_dev.bliss-dev.com');
setcookie("site_pass",'', 0, '/', '.devstu_dev.bliss-dev.com');
}
/*
function sso_user_login(&$account) {
//include("C:\wamp\www\moodle\sso.php");
watchdog("one","abcd");
//global $user;
watchdog("two",$account->name);
//$s = "stage1";
//$moodlesso_user = moodlesso_get_record($user);
watchdog('asd', $s);
drupal_set_message("Hello");
drupal_set_message($account->name." ".$account->pass);
watchdog("username_drupal",$account->name);
//drupal_set_message($domain);
//drupal_set_message($cookie);
//drupal_set_message($moodlesso_user->moodle_username);
//drupal_moodle_sso($user->name,'prateek');
//setcookie('drupal_username',$user->name);
//require_once('C:\wamp\www\moodle\sso.php');
// Establish a curl connection
$referer = "http://moodle.localhost.com/sso.php?drupal_username=mukesh";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $referer);
curl_exec($ch);
//watchdog("test",serialize($ch));
curl_close($ch);
/*
$referer = "http://moodle.localhost.com/sso.php?drupal_username=".$account->name;
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_exec($ch);
watchdog("test",serialize($ch));
curl_close($ch);*/
//$request ='http://moodle.localhost.com/sso.php?moodle_username='.$user->name;
//watchdog("url",$request);
//$session = curl_init($request);
/* watchdog("session",$session);
}*/