Add logintcc plugin see BT#11068

ofaj
Julio 10 years ago
parent ed81a388d6
commit f5538acfa4
  1. 95
      main/auth/inscription.php
  2. 4
      main/inc/lib/formvalidator/FormValidator.class.php
  3. 79
      plugin/logintcc/LoginTCC.php
  4. 2
      plugin/logintcc/README.md
  5. 1
      plugin/logintcc/index.php
  6. 4
      plugin/logintcc/install.php
  7. 10
      plugin/logintcc/lang/english.php
  8. 5
      plugin/logintcc/plugin.php
  9. 10
      plugin/logintcc/uninstall.php

@ -31,6 +31,9 @@ if ($allowedFieldsConfiguration !== false) {
$allowedFields = $allowedFieldsConfiguration;
}
$webserviceUrl = api_get_plugin_setting('logintcc', 'webservice_url');
$hash = api_get_plugin_setting('logintcc', 'hash');
$htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1');
$htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true" ></script>';
$htmlHeadXtra[] = '<script>
@ -47,6 +50,64 @@ $(document).ready(function() {
myLocation();
return false;
});
$("#search_user").click(function() {
var data = new Object();
data.Mail = $("input[name=\'email\']").val();
data.HashKey = "'.$hash.'";
$.ajax({
url: "'.$webserviceUrl.'/IsExistEmail",
data: JSON.stringify(data),
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
success: function (data, status) {
//console.log(data);
if (data.d.Exist) {
var monU = data.d.User;
$("input[name=\'extra_tcc_user_id\']").val(monU.UserID);
$("input[name=\'extra_tcc_hash_key\']").val(monU.HashKey);
var $radios = $("input:radio[name=\'extra_terms_genre[extra_terms_genre]\']");
if (monU.Genre == "Masculin") {
$radios.filter(\'[value=homme]\').prop(\'checked\', true);
} else {
$radios.filter(\'[value=femme]\').prop(\'checked\', true);
}
$("input[name=\'lastname\']").val(monU.Nom);
$("input[name=\'firstname\']").val(monU.Prenom);
//$("#U_Birthday").val(monU.DateNaissance);
console.log(monU);
if (monU.Langue == "fr-FR") {
$("#language").selectpicker("val", "french");
$("#language").selectpicker(\'render\');
}
if (monU.Langue == "de-DE") {
$("#language").selectpicker("val", "german");
$("#language").selectpicker(\'render\');
}
$("input[name=\'extra_terms_nationalite\']").val(monU.Nationalite);
//$("#U_Pays").val(monU.PaysResidence);
$("input[name=\'address\']").val(monU.Adresse);
$("input[name=\'extra_terms_codepostal\']").val(monU.CP);
//$("#U_Ville").val(monU.Ville);
} else {
alert(\'User inconnu.\');
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
return false;
});
});
function myLocation() {
@ -155,6 +216,16 @@ if (!empty($course_code_redirect)) {
}
if ($user_already_registered_show_terms === false) {
// EMAIL
$form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
if (api_get_setting('registration', 'email') === 'true') {
$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addButtonSearch(get_lang('Search'), 'search', ['id' => 'search_user']);
if (api_is_western_name_order()) {
// FIRST NAME and LAST NAME
$form->addElement('text', 'firstname', get_lang('FirstName'), array('size' => 40));
@ -168,11 +239,6 @@ if ($user_already_registered_show_terms === false) {
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
// EMAIL
$form->addElement('text', 'email', get_lang('Email'), array('size' => 40));
if (api_get_setting('registration', 'email') === 'true') {
$form->addRule('email', get_lang('ThisFieldIsRequired'), 'required');
}
if (api_get_setting('login_is_email') === 'true') {
$form->applyFilter('email', 'trim');
@ -298,7 +364,9 @@ if ($user_already_registered_show_terms === false) {
$form->addElement(
'select_language',
'language',
get_lang('Language')
get_lang('Language'),
[],
['id' => 'language']
);
}
}
@ -418,6 +486,17 @@ if ($user_already_registered_show_terms === false) {
}
}
$form->addElement(
'hidden',
'extra_tcc_user_id'
);
$form->addElement(
'hidden',
'extra_tcc_hash_key'
);
// EXTRA FIELDS
if (in_array('extra_fields', $allowedFields)) {
$extraField = new ExtraField('user');
@ -544,7 +623,7 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
$termActivated = !empty($termValue) && $termValue == 1;
}
}
if ($termActivated === false) {
$blockButton = true;
Display::addFlash(Display::return_message(get_lang('TermActivatedIsNeededDescription'), 'warning'));
@ -556,7 +635,7 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
Display::return_message(get_lang('TermYourProfileIsNotCompleted'), 'warning')
);
}
}
}
}
}
}

@ -471,13 +471,13 @@ EOT;
*
* @return HTML_QuickForm_button
*/
public function addButtonSearch($label = null, $name = 'submit')
public function addButtonSearch($label = null, $name = 'submit', $attributes = array())
{
if (empty($label)) {
$label = get_lang('Search');
}
return $this->addButton($name, $label, 'search', 'default');
return $this->addButton($name, $label, 'search', 'default', null, null, $attributes);
}
/**

@ -0,0 +1,79 @@
<?php
/**
* Class BBBPlugin
*/
class LoginTCC extends Plugin
{
public $isCoursePlugin = false;
/**
* Constructor.
*/
protected function __construct()
{
parent::__construct(
'O.1',
'Julio Montoya',
[
'tool_enable' => 'boolean',
'webservice_url' => 'text',
'sso_url' => 'text',
'hash' => 'text'
]
);
}
/**
* @return LoginTCC|null
*/
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
/**
* Install
*/
public function install()
{
$extraField = new ExtraField('user');
$data = $extraField->get_handler_field_info_by_field_variable('tcc_user_id');
if (empty($data)) {
$params = [
'field_type' => 1,
'variable' => 'tcc_user_id',
'display_text' => 'TCC user id',
'default_value' => 0,
'visible' => false,
'changeable' => true,
'filter' => false
];
$extraField->save($params);
}
$data = $extraField->get_handler_field_info_by_field_variable('tcc_hash_key');
if (empty($data)) {
$params = [
'field_type' => 1,
'variable' => 'tcc_hash_key',
'display_text' => 'TCC hash key',
'default_value' => 0,
'visible' => false,
'changeable' => true,
'filter' => false
];
$extraField->save($params);
}
}
/**
* Uninstall
*/
public function uninstall()
{
}
}

@ -0,0 +1,2 @@
Login TCC Chamilo
===================

@ -0,0 +1,4 @@
<?php
//require_once __DIR__.'/config.php';
LoginTCC::create()->install();

@ -0,0 +1,10 @@
<?php
/**
*
* @copyright (c) 2012 University of Geneva
* @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html
* @author Laurent Opprecht <laurent@opprecht.info>
*/
// Needed in order to show the plugin title
$strings['plugin_title'] = "Login TCC";
$strings['plugin_comment'] = "TCC connection";

@ -0,0 +1,5 @@
<?php
//require_once __DIR__.'/config.php';
$plugin_info = LoginTCC::create()->get_info();

@ -0,0 +1,10 @@
<?php
/**
* This script is included by main/admin/settings.lib.php when unselecting a plugin
* and is meant to remove things installed by the install.php script in both
* the global database and the courses tables
* @package chamilo.plugin.bigbluebutton
*/
//require_once __DIR__.'/config.php';
LoginTCC::create()->uninstall();
Loading…
Cancel
Save