disabled submit on registration to avoid duplicate account creation
This commit is contained in:
		@@ -4,7 +4,7 @@
 | 
				
			|||||||
(function($) {
 | 
					(function($) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MaterioUser = function(){
 | 
					MaterioUser = function(){
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
 | 
					  var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function init() {
 | 
					  function init() {
 | 
				
			||||||
@@ -17,7 +17,7 @@ MaterioUser = function(){
 | 
				
			|||||||
    // trace('initAdhesion');
 | 
					    // trace('initAdhesion');
 | 
				
			||||||
    $('.get-link a').bind('click', function(event) {
 | 
					    $('.get-link a').bind('click', function(event) {
 | 
				
			||||||
      // trace('get-link click');
 | 
					      // trace('get-link click');
 | 
				
			||||||
      
 | 
					
 | 
				
			||||||
      // do not show the registration form if already logged-in
 | 
					      // do not show the registration form if already logged-in
 | 
				
			||||||
      if($('body').is('.logged-in'))
 | 
					      if($('body').is('.logged-in'))
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
@@ -29,7 +29,7 @@ MaterioUser = function(){
 | 
				
			|||||||
             href = $this.attr("href"),
 | 
					             href = $this.attr("href"),
 | 
				
			||||||
             destination = href.match('/\?destination=([^,]+)');
 | 
					             destination = href.match('/\?destination=([^,]+)');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      destination = "/" + destination[1].replace('%23', '#');       
 | 
					      destination = "/" + destination[1].replace('%23', '#');
 | 
				
			||||||
      destination = destination.replace('//', '/');
 | 
					      destination = destination.replace('//', '/');
 | 
				
			||||||
      // trace('destination', destination);
 | 
					      // trace('destination', destination);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,7 +55,7 @@ MaterioUser = function(){
 | 
				
			|||||||
  function formLoaded(json, destination){
 | 
					  function formLoaded(json, destination){
 | 
				
			||||||
    //trace('formLoaded | json', json);
 | 
					    //trace('formLoaded | json', json);
 | 
				
			||||||
    var $modal = $('<div>').addClass('modal-content').append(json.block);
 | 
					    var $modal = $('<div>').addClass('modal-content').append(json.block);
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    var id,label, description;
 | 
					    var id,label, description;
 | 
				
			||||||
    $('input.form-text', $modal).each(function(i) {
 | 
					    $('input.form-text', $modal).each(function(i) {
 | 
				
			||||||
      id = $(this).attr('id');
 | 
					      id = $(this).attr('id');
 | 
				
			||||||
@@ -83,11 +83,16 @@ MaterioUser = function(){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
 | 
					    $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
 | 
				
			||||||
      event.preventDefault();
 | 
					      event.preventDefault();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // disable submit button to avoid duplicate user creation
 | 
				
			||||||
 | 
					      // console.log('click', this);
 | 
				
			||||||
 | 
					      $(this).attr('disabled', 'true');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $.ajax({
 | 
					      $.ajax({
 | 
				
			||||||
        type: 'POST',
 | 
					        type: 'POST',
 | 
				
			||||||
        dataType:'json',
 | 
					        dataType:'json',
 | 
				
			||||||
        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
 | 
					        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
 | 
				
			||||||
        data: $('#user-register-form', $modal).serialize(), 
 | 
					        data: $('#user-register-form', $modal).serialize(),
 | 
				
			||||||
        success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
 | 
					        success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
 | 
				
			||||||
        error: function() {trace('error');}
 | 
					        error: function() {trace('error');}
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@@ -100,14 +105,14 @@ MaterioUser = function(){
 | 
				
			|||||||
        type: 'POST',
 | 
					        type: 'POST',
 | 
				
			||||||
        dataType:'json',
 | 
					        dataType:'json',
 | 
				
			||||||
        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
 | 
					        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
 | 
				
			||||||
        data: $('#user-login', $modal).serialize(), 
 | 
					        data: $('#user-login', $modal).serialize(),
 | 
				
			||||||
        success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
 | 
					        success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
 | 
				
			||||||
        error: function() { trace('error'); }
 | 
					        error: function() { trace('error'); }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // google analytics 
 | 
					    // google analytics
 | 
				
			||||||
    // $.event.trigger({
 | 
					    // $.event.trigger({
 | 
				
			||||||
    //   type : "record-stat",
 | 
					    //   type : "record-stat",
 | 
				
			||||||
    //   categorie : 'Search',
 | 
					    //   categorie : 'Search',
 | 
				
			||||||
@@ -120,12 +125,21 @@ MaterioUser = function(){
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function onUserLoginRegisterSubmit($form, data, destination){
 | 
					  function onUserLoginRegisterSubmit($form, data, destination){
 | 
				
			||||||
 | 
					    // console.log('data', data);
 | 
				
			||||||
    cleanModalErrors();
 | 
					    cleanModalErrors();
 | 
				
			||||||
    if(data.errors != null){
 | 
					    if(data.errors != null){
 | 
				
			||||||
      for(field in data.errors){
 | 
					      for(field in data.errors){
 | 
				
			||||||
        $('input[name='+field+']', $form).addClass('error');
 | 
					        $('input[name='+field+']', $form).addClass('error');
 | 
				
			||||||
        $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
 | 
					        $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      (function($form){
 | 
				
			||||||
 | 
					        setTimeout(function(){
 | 
				
			||||||
 | 
					          console.log('enabled');
 | 
				
			||||||
 | 
					          $('input[type=submit]', $form).removeAttr('disabled');
 | 
				
			||||||
 | 
					        }, 0.5*1000);
 | 
				
			||||||
 | 
					      })($form);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }else{
 | 
					    }else{
 | 
				
			||||||
      // trace('destination = '+destination);
 | 
					      // trace('destination = '+destination);
 | 
				
			||||||
      window.location.pathname = destination;
 | 
					      window.location.pathname = destination;
 | 
				
			||||||
@@ -143,5 +157,5 @@ MaterioUser = function(){
 | 
				
			|||||||
$(document).ready(function() {
 | 
					$(document).ready(function() {
 | 
				
			||||||
  var materiouser = new MaterioUser();
 | 
					  var materiouser = new MaterioUser();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
})(jQuery);
 | 
					})(jQuery);
 | 
				
			||||||
							
								
								
									
										30
									
								
								js/materio_user.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										30
									
								
								js/materio_user.min.js
									
									
									
									
										vendored
									
									
								
							@@ -374,7 +374,7 @@ function getElementAngle(x1, y1, x2, y2) {
 | 
				
			|||||||
(function($) {
 | 
					(function($) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MaterioUser = function(){
 | 
					MaterioUser = function(){
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
 | 
					  var _isAdhesion = $('body').is('.page-node-11187') || $('body').is('.page-node-11186');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function init() {
 | 
					  function init() {
 | 
				
			||||||
@@ -387,7 +387,7 @@ MaterioUser = function(){
 | 
				
			|||||||
    // trace('initAdhesion');
 | 
					    // trace('initAdhesion');
 | 
				
			||||||
    $('.get-link a').bind('click', function(event) {
 | 
					    $('.get-link a').bind('click', function(event) {
 | 
				
			||||||
      // trace('get-link click');
 | 
					      // trace('get-link click');
 | 
				
			||||||
      
 | 
					
 | 
				
			||||||
      // do not show the registration form if already logged-in
 | 
					      // do not show the registration form if already logged-in
 | 
				
			||||||
      if($('body').is('.logged-in'))
 | 
					      if($('body').is('.logged-in'))
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
@@ -399,7 +399,7 @@ MaterioUser = function(){
 | 
				
			|||||||
             href = $this.attr("href"),
 | 
					             href = $this.attr("href"),
 | 
				
			||||||
             destination = href.match('/\?destination=([^,]+)');
 | 
					             destination = href.match('/\?destination=([^,]+)');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      destination = "/" + destination[1].replace('%23', '#');       
 | 
					      destination = "/" + destination[1].replace('%23', '#');
 | 
				
			||||||
      destination = destination.replace('//', '/');
 | 
					      destination = destination.replace('//', '/');
 | 
				
			||||||
      // trace('destination', destination);
 | 
					      // trace('destination', destination);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -425,7 +425,7 @@ MaterioUser = function(){
 | 
				
			|||||||
  function formLoaded(json, destination){
 | 
					  function formLoaded(json, destination){
 | 
				
			||||||
    //trace('formLoaded | json', json);
 | 
					    //trace('formLoaded | json', json);
 | 
				
			||||||
    var $modal = $('<div>').addClass('modal-content').append(json.block);
 | 
					    var $modal = $('<div>').addClass('modal-content').append(json.block);
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    var id,label, description;
 | 
					    var id,label, description;
 | 
				
			||||||
    $('input.form-text', $modal).each(function(i) {
 | 
					    $('input.form-text', $modal).each(function(i) {
 | 
				
			||||||
      id = $(this).attr('id');
 | 
					      id = $(this).attr('id');
 | 
				
			||||||
@@ -453,11 +453,16 @@ MaterioUser = function(){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
 | 
					    $("#user-register-form #edit-submit, #user-register-form #edit-submit--2", $modal).click(function(event){
 | 
				
			||||||
      event.preventDefault();
 | 
					      event.preventDefault();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      // disable submit button to avoid duplicate user creation
 | 
				
			||||||
 | 
					      // console.log('click', this);
 | 
				
			||||||
 | 
					      $(this).attr('disabled', 'true');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      $.ajax({
 | 
					      $.ajax({
 | 
				
			||||||
        type: 'POST',
 | 
					        type: 'POST',
 | 
				
			||||||
        dataType:'json',
 | 
					        dataType:'json',
 | 
				
			||||||
        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
 | 
					        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",
 | 
				
			||||||
        data: $('#user-register-form', $modal).serialize(), 
 | 
					        data: $('#user-register-form', $modal).serialize(),
 | 
				
			||||||
        success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
 | 
					        success: function(data) { onUserLoginRegisterSubmit($('#user-register-form'), data, destination);},
 | 
				
			||||||
        error: function() {trace('error');}
 | 
					        error: function() {trace('error');}
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
@@ -470,14 +475,14 @@ MaterioUser = function(){
 | 
				
			|||||||
        type: 'POST',
 | 
					        type: 'POST',
 | 
				
			||||||
        dataType:'json',
 | 
					        dataType:'json',
 | 
				
			||||||
        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
 | 
					        url: Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/login/submit",
 | 
				
			||||||
        data: $('#user-login', $modal).serialize(), 
 | 
					        data: $('#user-login', $modal).serialize(),
 | 
				
			||||||
        success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
 | 
					        success: function(data){ onUserLoginRegisterSubmit($('#user-login'), data, destination); },
 | 
				
			||||||
        error: function() { trace('error'); }
 | 
					        error: function() { trace('error'); }
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // google analytics 
 | 
					    // google analytics
 | 
				
			||||||
    // $.event.trigger({
 | 
					    // $.event.trigger({
 | 
				
			||||||
    //   type : "record-stat",
 | 
					    //   type : "record-stat",
 | 
				
			||||||
    //   categorie : 'Search',
 | 
					    //   categorie : 'Search',
 | 
				
			||||||
@@ -490,12 +495,21 @@ MaterioUser = function(){
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function onUserLoginRegisterSubmit($form, data, destination){
 | 
					  function onUserLoginRegisterSubmit($form, data, destination){
 | 
				
			||||||
 | 
					    // console.log('data', data);
 | 
				
			||||||
    cleanModalErrors();
 | 
					    cleanModalErrors();
 | 
				
			||||||
    if(data.errors != null){
 | 
					    if(data.errors != null){
 | 
				
			||||||
      for(field in data.errors){
 | 
					      for(field in data.errors){
 | 
				
			||||||
        $('input[name='+field+']', $form).addClass('error');
 | 
					        $('input[name='+field+']', $form).addClass('error');
 | 
				
			||||||
        $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
 | 
					        $form.prepend($('<div>').addClass('message-error').html(data.errors[field]));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      (function($form){
 | 
				
			||||||
 | 
					        setTimeout(function(){
 | 
				
			||||||
 | 
					          console.log('enabled');
 | 
				
			||||||
 | 
					          $('input[type=submit]', $form).removeAttr('disabled');
 | 
				
			||||||
 | 
					        }, 0.5*1000);
 | 
				
			||||||
 | 
					      })($form);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }else{
 | 
					    }else{
 | 
				
			||||||
      // trace('destination = '+destination);
 | 
					      // trace('destination = '+destination);
 | 
				
			||||||
      window.location.pathname = destination;
 | 
					      window.location.pathname = destination;
 | 
				
			||||||
@@ -513,5 +527,5 @@ MaterioUser = function(){
 | 
				
			|||||||
$(document).ready(function() {
 | 
					$(document).ready(function() {
 | 
				
			||||||
  var materiouser = new MaterioUser();
 | 
					  var materiouser = new MaterioUser();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
})(jQuery);
 | 
					})(jQuery);
 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
<?php	
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -131,9 +131,9 @@ function materio_user_block_view($delta = '') {
 | 
				
			|||||||
      if( (isset($user->roles[6]) || isset($user->roles[8])) && $user->created < strtotime('01-12-2012') ){
 | 
					      if( (isset($user->roles[6]) || isset($user->roles[8])) && $user->created < strtotime('01-12-2012') ){
 | 
				
			||||||
        // dsm($user, 'user');
 | 
					        // dsm($user, 'user');
 | 
				
			||||||
        $block['subject'] = '';
 | 
					        $block['subject'] = '';
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        $path = 'http://base.materio.com';
 | 
					        $path = 'http://base.materio.com';
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        if($language->language == 'fr')
 | 
					        if($language->language == 'fr')
 | 
				
			||||||
          $path .= '/index_fr.html';
 | 
					          $path .= '/index_fr.html';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -157,7 +157,7 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) {
 | 
				
			|||||||
    // dsm($form);
 | 
					    // dsm($form);
 | 
				
			||||||
    $form['account']['pass']['#type'] = 'password';
 | 
					    $form['account']['pass']['#type'] = 'password';
 | 
				
			||||||
    $form['account']['pass']['#title'] = t('Password');
 | 
					    $form['account']['pass']['#title'] = t('Password');
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    $form['actions']['#type'] = "container";
 | 
					    $form['actions']['#type'] = "container";
 | 
				
			||||||
    $form['actions']['submit']['#value'] = t('Join');
 | 
					    $form['actions']['submit']['#value'] = t('Join');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -172,12 +172,12 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  if($form_id == "user_login" ){
 | 
					  if($form_id == "user_login" ){
 | 
				
			||||||
    // dsm($form);
 | 
					    // dsm($form);
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    $form['actions']['#type'] = "container";
 | 
					    $form['actions']['#type'] = "container";
 | 
				
			||||||
    // $form['actions']['submit']['#value'] = t('Join');
 | 
					    // $form['actions']['submit']['#value'] = t('Join');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // if( $_GET['q'] == 'node/11187' ){
 | 
					    // if( $_GET['q'] == 'node/11187' ){
 | 
				
			||||||
    //   $form['#submit'][] = "materio_user_user_login_form_submit";  
 | 
					    //   $form['#submit'][] = "materio_user_user_login_form_submit";
 | 
				
			||||||
    // }
 | 
					    // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -209,7 +209,7 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) {
 | 
				
			|||||||
  //     'fragment' => $_GET['q'] == 'node/11187' ? 'content-bottom' : '', // if we register from the membership page, then go directly to the form
 | 
					  //     'fragment' => $_GET['q'] == 'node/11187' ? 'content-bottom' : '', // if we register from the membership page, then go directly to the form
 | 
				
			||||||
  //   )
 | 
					  //   )
 | 
				
			||||||
  // );
 | 
					  // );
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  // $frontlink = l('continue with basic', '<front>');
 | 
					  // $frontlink = l('continue with basic', '<front>');
 | 
				
			||||||
  // // drupal_get_messages('status');
 | 
					  // // drupal_get_messages('status');
 | 
				
			||||||
  // drupal_set_message(t('Welcome, you just join materiO\'! now you can choose the membership that\'s right for you, or !link', array('!link'=>$frontlink)));
 | 
					  // drupal_set_message(t('Welcome, you just join materiO\'! now you can choose the membership that\'s right for you, or !link', array('!link'=>$frontlink)));
 | 
				
			||||||
@@ -241,13 +241,13 @@ function materio_user_webform_client_111186_validate($form, &$form_state){
 | 
				
			|||||||
          // TODO : tester si les email ne sont pas deja inscrit sur le site
 | 
					          // TODO : tester si les email ne sont pas deja inscrit sur le site
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));      
 | 
					          form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  } 
 | 
					
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// function materio_user_webform_client_111186_submit($form, &$form_state){
 | 
					// function materio_user_webform_client_111186_submit($form, &$form_state){
 | 
				
			||||||
@@ -263,7 +263,7 @@ function materio_user_webform_client_111186_validate($form, &$form_state){
 | 
				
			|||||||
//       //     $field_name = 'submitted][collaborators]['.$coll_key.']['.$field_key;
 | 
					//       //     $field_name = 'submitted][collaborators]['.$coll_key.']['.$field_key;
 | 
				
			||||||
//       //     // dsm($field_name, 'field_name');
 | 
					//       //     // dsm($field_name, 'field_name');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//       //     form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));      
 | 
					//       //     form_set_error($field_name, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));
 | 
				
			||||||
//       //   }
 | 
					//       //   }
 | 
				
			||||||
//       // }
 | 
					//       // }
 | 
				
			||||||
//       $userinfo = array(
 | 
					//       $userinfo = array(
 | 
				
			||||||
@@ -281,9 +281,9 @@ function materio_user_webform_client_111186_validate($form, &$form_state){
 | 
				
			|||||||
//       // module_invoke_all('user_insert', $edit, $account);
 | 
					//       // module_invoke_all('user_insert', $edit, $account);
 | 
				
			||||||
//       $i++;
 | 
					//       $i++;
 | 
				
			||||||
//     }
 | 
					//     }
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
//   } 
 | 
					
 | 
				
			||||||
 | 
					//   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // enregistrer le type d'adonnement chez les user
 | 
					  // enregistrer le type d'adonnement chez les user
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -299,7 +299,7 @@ function materio_user_help($path, $arg) {
 | 
				
			|||||||
      if($arg[1] == 11187 ){
 | 
					      if($arg[1] == 11187 ){
 | 
				
			||||||
        global $user;
 | 
					        global $user;
 | 
				
			||||||
        // dsm($user, 'user');
 | 
					        // dsm($user, 'user');
 | 
				
			||||||
        
 | 
					
 | 
				
			||||||
        if(isset($user->roles[1])){ // anonyme
 | 
					        if(isset($user->roles[1])){ // anonyme
 | 
				
			||||||
          $message = t('Please create first a free account and join materio or log in with your existing account,<br />then we\'ll provide you our membership form.', array());
 | 
					          $message = t('Please create first a free account and join materio or log in with your existing account,<br />then we\'ll provide you our membership form.', array());
 | 
				
			||||||
          $content = '<p>' . $message . '</p>';
 | 
					          $content = '<p>' . $message . '</p>';
 | 
				
			||||||
@@ -340,16 +340,16 @@ function _materio_user_user_update(&$edit, $account, $category){
 | 
				
			|||||||
  // dsm($edit, 'edit');
 | 
					  // dsm($edit, 'edit');
 | 
				
			||||||
  // dsm($account, 'account');
 | 
					  // dsm($account, 'account');
 | 
				
			||||||
  // dsm($category, 'category');
 | 
					  // dsm($category, 'category');
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  // This is only fired when a user confirms their email address, logintoboggan style
 | 
					  // This is only fired when a user confirms their email address, logintoboggan style
 | 
				
			||||||
  if (isset($account->logintoboggan_email_validated) && $account->logintoboggan_email_validated == TRUE) {    
 | 
					  if (isset($account->logintoboggan_email_validated) && $account->logintoboggan_email_validated == TRUE) {
 | 
				
			||||||
    $confirmed_rid = materio_user_get_role_by_name(MATERIO_USER_CONFIRMED_USER_ROLE);    
 | 
					    $confirmed_rid = materio_user_get_role_by_name(MATERIO_USER_CONFIRMED_USER_ROLE);
 | 
				
			||||||
    $roles = $account->roles + array($confirmed_rid => MATERIO_USER_CONFIRMED_USER_ROLE);
 | 
					    $roles = $account->roles + array($confirmed_rid => MATERIO_USER_CONFIRMED_USER_ROLE);
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    // we have to do this to stop an infinite loop, and also to allow lower weighted modules to possibly do something here
 | 
					    // we have to do this to stop an infinite loop, and also to allow lower weighted modules to possibly do something here
 | 
				
			||||||
    $user = $account;
 | 
					    $user = $account;
 | 
				
			||||||
    unset($user->logintoboggan_email_validated);
 | 
					    unset($user->logintoboggan_email_validated);
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    user_save($user, array('roles' => $roles));
 | 
					    user_save($user, array('roles' => $roles));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    drupal_go_to('user/'.$user->uid.'/edit');
 | 
					    drupal_go_to('user/'.$user->uid.'/edit');
 | 
				
			||||||
@@ -367,5 +367,5 @@ function _materio_user_user_update(&$edit, $account, $category){
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
function materio_user_get_role_by_name($name) {
 | 
					function materio_user_get_role_by_name($name) {
 | 
				
			||||||
  return array_search($name, user_roles());
 | 
					  return array_search($name, user_roles());
 | 
				
			||||||
} 
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
<?php 
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function materio_user_registerblock(){
 | 
					function materio_user_registerblock(){
 | 
				
			||||||
  $return = array();
 | 
					  $return = array();
 | 
				
			||||||
@@ -28,14 +28,14 @@ function materio_user_register_submit(){
 | 
				
			|||||||
    unset ($_SESSION['messages']['error']);
 | 
					    unset ($_SESSION['messages']['error']);
 | 
				
			||||||
  }else{
 | 
					  }else{
 | 
				
			||||||
    $messages = drupal_get_messages('status');
 | 
					    $messages = drupal_get_messages('status');
 | 
				
			||||||
    // $return['messages'] = $messages; 
 | 
					    // $return['messages'] = $messages;
 | 
				
			||||||
    drupal_set_message(t("Congratulations, you juste created your free materiO' account, welcome !"), 'status');
 | 
					    drupal_set_message(t("Congratulations, you juste created your free materiO' account, welcome !"), 'status');
 | 
				
			||||||
    foreach ($messages['status'] as $msg) {
 | 
					    foreach ($messages['status'] as $msg) {
 | 
				
			||||||
      drupal_set_message($msg, 'status');
 | 
					      drupal_set_message($msg, 'status');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  // after registration user is automaticly logged in, thank's to login tobogan module
 | 
					  // after registration user is automaticly logged in, thank's to login tobogan module
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
  drupal_json_output($return);
 | 
					  drupal_json_output($return);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -45,7 +45,7 @@ function materio_user_login_submit(){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  $form_state = array("values"=>$_POST);
 | 
					  $form_state = array("values"=>$_POST);
 | 
				
			||||||
  drupal_form_submit($_POST['form_id'], $form_state);
 | 
					  drupal_form_submit($_POST['form_id'], $form_state);
 | 
				
			||||||
 
 | 
					
 | 
				
			||||||
  $return['errors'] = form_get_errors();
 | 
					  $return['errors'] = form_get_errors();
 | 
				
			||||||
  if($return['errors'])
 | 
					  if($return['errors'])
 | 
				
			||||||
    unset ($_SESSION['messages']['error']);
 | 
					    unset ($_SESSION['messages']['error']);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user