skala
Laurent Opprecht 14 years ago
commit 9d02882e7a
  1. 89
      main/auth/sso/sso_server_test.php
  2. 21
      main/chat/chat_functions.lib.php
  3. 103
      main/inc/lib/javascript/skills.js
  4. 28
      main/webservices/test.php

@ -0,0 +1,89 @@
<?php
/*
SSO sample
This is the "server" of my institution/university authentification "code"
1. Active all the SSO option in your Chamilo installation: main/admin/settings.php?category=Security
2. Make sure this script is located in the index page of the server you fill in the "Domain of the Single Sign On server" Chamilo setting
For example this script must be located in example.com/index.php if you set the "Domain of the Single Sign On server" = example.com
3. Create a user in chamilo and in your external system with login = "joe" and password = "doe"
4. Remember this is just a sample! Check the chamilo drupal extension for more information:
http://drupal.org/node/817682
5. See the main/auth/sso.class.php library for more details
*/
//This page will be loaded when entering to the Chamilo site if the SSO option was set in step 1.
//Getting the chamilo server
$my_chamilo_server = filter_xss($_SERVER['HTTP_HOST']);
//Correct user values - we asume that this user exists in both systems
$correct_user = 'john';
$correct_pass = 'doe';
$account = array();
if (isset($_SESSION['my_server_user_session'])) {
//validate if the user is already logged in my external system in order to redirect to chamilo
}
//Login process
if (isset($_POST['user']) && isset($_POST['password'])) {
if ($_POST['user'] == $correct_user && $_POST['password'] == $correct_pass) {
// You have to add here your server validations
$account['name'] = 'john';
$account['pass'] = 'doe';
$master_auth_uri = $my_chamilo_server . '?q=user';
// Creating an array cookie that will be sent to Chamilo
$sso = array(
'username' => $account['name'],
'secret' => sha1($account['pass']),
'master_domain' => $my_chamilo_server,
'master_auth_uri' => $master_auth_uri,
'lifetime' => time() + 3600,
'target' => filter_xss($_GET['sso_target']),
);
$cookie = base64_encode(serialize($sso));
$url = chamilo_sso_protocol() . $master_auth_uri;
$params = 'sso_referer='. urlencode($url) .'&sso_cookie='. urlencode($cookie);
$final_url = filter_xss($_GET['sso_referer']) .'?'. $params;
//If your user exists redirect to chamilo and set the account in a session to check it later
$_SESSION['my_server_user_session'] = $account;
//Redirect to chamilo
header('Location: '.$final_url);
} else {
echo '<h2>Wrong parameters</h2>';
}
}
if (isset($_POST['logout'])) {
//echo do something to logout
}
function filter_xss($val) {
//do some cleaning
return $val;
}
function chamilo_sso_protocol() {
//get the sso_protocol from chamilo using webservices
return 'http://';
}
?>
<html>
<form method="post">
User <input name="user" value="<?php echo $correct_user; ?>">
Pass <input name="password" value="<?php echo $correct_pass; ?>">
<input type="submit" value="Login">
</form>
</html>

@ -14,8 +14,8 @@ function exit_of_chat($user_id) {
$list_course = array();
$list_course = CourseManager::get_courses_list_by_user_id($user_id);
$group_id = intval($_SESSION['id_group']);
$session_id = intval($_SESSION['id_session']);
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$extra_condition = '';
if (!empty($group_id)) {
@ -24,11 +24,12 @@ function exit_of_chat($user_id) {
$extra_condition = api_get_session_condition($session_id);
}
$extra_condition.= " AND course_id = $course_id";
foreach ($list_course as $courses) {
$tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE);
foreach ($list_course as $course) {
$response = user_connected_in_chat($user_id);
if ($response === true) {
$tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE);
$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE user_id='.$user_id.$extra_condition;
$sql = 'DELETE FROM '.$tbl_chat_connected.' WHERE c_id = '.$course['real_id'].' AND user_id='.$user_id.$extra_condition;
Database::query($sql);
}
}
@ -43,8 +44,9 @@ function exit_of_chat($user_id) {
function user_connected_in_chat ($user_id) {
$tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE);
$group_id = intval($_SESSION['id_group']);
$session_id = intval($_SESSION['id_session']);
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$user_id = intval($user_id);
$course_id = api_get_course_int_id();
@ -105,8 +107,9 @@ function users_list_in_chat() {
$tbl_chat_connected = Database::get_course_table(CHAT_CONNECTED_TABLE);
$course_id = api_get_course_int_id();
$group_id = intval($_SESSION['id_group']);
$session_id = intval($_SESSION['id_session']);
$session_id = api_get_session_id();
$group_id = api_get_group_id();
$extra_condition = '';
if (!empty($group_id)) {
$extra_condition = " WHERE to_group_id = '$group_id'";

@ -34,7 +34,6 @@ var editEndpointOptions = {
connector:"Straight"
};
//Student arrows
// If user completed the skill
@ -71,17 +70,7 @@ function open_parent(parent_id, id) {
console.log("open_parent call : id " + id + " parent_id:" + parent_id);
var numeric_parent_id = parent_id.split('_')[1];
var numeric_id = id.split('_')[1];
$('#'+id).css('top', '0px');
// @todo move this in a function
var final_left =0;
var normal_width = 0;
$('.skill_child').each( function(){
normal_width = $(this).width();
return true;
});
load_parent(numeric_parent_id, numeric_id);
}
@ -95,7 +84,7 @@ function open_block(id, load_user_data, create_root) {
var numeric_id = id.split('_')[1];
for (var i = 0; i < skills.length; i++) {
for (var i = 0; i < skills.length; i++) {ranc
//Remove everything except parents
if (jQuery.inArray(skills[i].element, parents) == -1) {
//if (debug) console.log('deleting this skill '+ skills[i].element + " id: " + i);
@ -104,24 +93,6 @@ function open_block(id, load_user_data, create_root) {
$("#"+skills[i].element).remove();
}
}
/*/Modifying current block position
pos = $('#'+id).position();
left_value = center_x;
if (parents.length == 2) {
top_value = space_between_blocks_y + offset_y;
} else {
top_value = 100;
}
jsPlumb.animate(id, { left: left_value, top:top_value }, { duration:duration_value });
//Modifying root block position
pos_parent = $('#'+parents[0]).position();
jsPlumb.animate(parents[0], { left: center_x, top:offset_y }, { duration:duration_value });
top_value = 2*space_between_blocks_y +offset_y ; */
load_children(numeric_id, 0, load_user_data, create_root);
}
@ -129,28 +100,29 @@ function load_children(my_id, top_value, load_user_data, create_root) {
if (debug) console.log("load_children : my_id " + my_id + ", top_value:" + top_value +", load_user_data: "+load_user_data+", create_root: "+create_root);
//Fix the block vertical position
//$('#block_'+my_id).css('top', '150px');
my_top_root = 150;
my_top_children = 250;
console.log('Loading root info by ajax '+my_id);
var skill = null;
$.ajax({
async: false,//very important other wise it would not work
url: url+'&a=get_skill_info&id='+my_id,
success: function(json) {
skill = jQuery.parseJSON(json);
}
});
//Creating the root
if (create_root == 1) {
//Loading children for the first time
my_top_root = 0;
my_top_children = 150;
if (my_id == 1) {
$('#skill_tree').append('<div id="block_'+my_id+'" class="skill_root first_window" >Root </div>');
} else {
console.log('Loading root info by ajax '+my_id);
$.ajax({
async: false,//very important other wise it would not work
url: url+'&a=get_skill_info&id='+my_id,
success: function(json) {
var skill = jQuery.parseJSON(json);
$('#skill_tree').append('<div id="block_'+my_id+'" class="skill_root open_block first_window" >' +skill.name+'</div>');
console.log('Adding root block: '+my_id);
}
});
}
//Adding to the skill list
@ -184,8 +156,26 @@ function load_children(my_id, top_value, load_user_data, create_root) {
console.log('getJSON result: ' + result.success);
//console.log('getJSON json: ' + json);
//Fixing the root position in the organigram
var final_left =0;
var normal_width = 0;
$('.skill_child').each( function(){
normal_width = $(this).width();
return true;
});
//normal_width = $('.skill_child :first').width();
final_left = $('body').width() / 2 - normal_width/2;
console.log('normal_width -----> '+normal_width);
console.log('body.width -----> '+$('body').width());
console.log('final_left -----> '+final_left);
$('#block_'+my_id).css('left', final_left+'px');
$.each(json,function(i, item) {
if (debug) console.log('Loading children: #' + item.id + " " +item.name);
//if (debug) console.log('Loading children: #' + item.id + " " +item.name);
//item.name = '<a href="#" class="edit_block" id="edit_block_'+item.id+'">'+item.name+'</a>';
item.name = '<a href="#" class="edit_block" id="edit_block_'+item.id+'">'+item.name+'</a>';
@ -202,7 +192,13 @@ function load_children(my_id, top_value, load_user_data, create_root) {
//Fix the block vertical position
$('#block_'+item.id).css('top', my_top_children+'px');
if (debug) console.log('Append block: '+item.id);
if (create_root == 0) {
}
//if (debug) console.log('Append block: '+item.id);
endpoint = jsPlumb.makeTarget("block_" + item.id, my_edit_point_options);
@ -211,32 +207,13 @@ function load_children(my_id, top_value, load_user_data, create_root) {
skills.push({
element: "block_" + item.id, endp:endpoint
});
console.log('added to array skills id: ' + item.id+" - name: "+item.name);
//console.log('added to array skills id: ' + item.id+" - name: "+item.name);
});
jsPlumb.draggable(jsPlumb.getSelector(".skill_child"));
//jsPlumb.draggable(jsPlumb.getSelector(".skill_root"));
console.log('draggable');
//Fixing the root position in the organigram
var final_left =0;
var normal_width = 0;
$('.skill_child').each( function(){
normal_width = $(this).width();
return true;
});
//normal_width = $('.skill_child :first').width();
final_left = $('body').width() / 2 - normal_width/2;
console.log('normal_width -----> '+normal_width);
console.log('body.width -----> '+$('body').width());
console.log('final_left -----> '+final_left);
jsPlumb.animate('block_'+my_id, { left: final_left, top:my_top_root }, { duration: 100 });
console.log('setting animate for block_'+my_id);
console.log('final parents '+parents);
} //result

@ -1,17 +1,23 @@
<?php
die(); //remove to enable - incomplete script anyway
exit;
require_once '../inc/global.inc.php';
require_once '../inc/lib/nusoap/nusoap.php';
require_once '../inc/conf/configuration.php';
?>
<html>
<body>
<div class="results">
<?php
$server = $_configuration['root_web'].'main/webservices/';
$serversys = $_configuration['root_sys'].'main/webservices/';
$server = api_get_path(WEB_CODE_PATH).'webservices/';
$serversys = api_get_path(SYS_CODE_PATH).'webservices/';
//$script = 'registration.soap.php';
$script = $_POST['script'];
$script = isset($_POST['script']) ? $_POST['script'] : false;
$function = isset($_POST['function']) ? $_POST['function'] : false;
$contact= $server.$script.'?wsdl';
$client = new nusoap_client($contact);
$err = $client->getError();
if ($err) {
@ -20,12 +26,15 @@ if ($err) {
// At this point, you know the call that follows will fail
}
$response = array();
if (!empty($_POST['function'])) {
$response = $client->call($_POST['function']);
echo '<pre>#';
if (!empty($function)) {
$response = $client->call($function);
echo '<pre>';
print_r($response);
echo '#</pre>';
} else {
echo "empty function $function";
}
$list = scandir($serversys);
$scripts = array();
foreach ($list as $item) {
@ -36,6 +45,7 @@ foreach ($list as $item) {
}
?>
</div>
<form method="POST" action="">
<label for="script">Script</label>
<select name="script">
@ -46,8 +56,8 @@ foreach ($scripts as $script) {
?>
</select><br />
<label for="function">Function</label>
<input type="text" name="function" value="<?php echo $_POST['function'];?>"></input><br />
<input type="text" name="function" value="<?php echo $function;?>"></input><br />
<label for="param[0]">Param 0</label>
<input type="text" name="param[0]" value="<?php echo $_POST['param'][0];?>"></input><br />
<input type="text" name="param[0]" ></input><br />
<input type="submit" name="submit" value="Send"/>
</form>

Loading…
Cancel
Save