').addClass('message-error').html(data.errors[field]));
+ }
+ }else{
+ window.location.pathname = destination;
+ }
+ };
+
+ function cleanModalErrors() {
+ $('.message-error', '.modal-content').remove();
+ $('input', '.modal-content').removeClass('error');
+ }
+
+ init();
+};
+
+$(document).ready(function() {
+ var materiouser = new MaterioUser();
+});
+
+})(jQuery);
\ No newline at end of file
diff --git a/js/materio_user.min.js b/js/materio_user.min.js
new file mode 100755
index 00000000..27620fb8
--- /dev/null
+++ b/js/materio_user.min.js
@@ -0,0 +1 @@
+!function(t){MaterioUser=function(){function e(){a&&r()}function r(){t(".get-link a").bind("click",function(e){e.preventDefault();var r=t(this),a=r.attr("href").match("/?destination=([^,]+)/");return i(a),!1})}function i(){t.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register",function(e){var r,i,a,n=t("
").addClass("modal-content").append(e.block);t("input.form-text",n).each(function(){r=t(this).attr("id"),i=t("label[for="+r+"]").hide().text(),a=t(this).parent().find(".description").hide().text(),t(this).attr("placeholder",i).attr("title",a)}),t("body").append(t("
").addClass("modal-wrapper").append(n)),t.event.trigger("ajax-register-block-loaded"),t("#user-register-form #edit-submit--2").click(function(e){return e.preventDefault(),t.ajax({type:"POST",dataType:"json",url:Drupal.settings.basePath+Drupal.settings.pathPrefix+"materio_user/register/submit",data:t("#user-register-form",n).serialize(),success:function(){},error:function(){}}),!1})})}var a=t("body").is(".page-node-11187")||t("body").is(".page-node-11186");e()},t(document).ready(function(){new MaterioUser})}(jQuery);
\ No newline at end of file
diff --git a/materio_user.module b/materio_user.module
index 04d7f713..03b14c6d 100755
--- a/materio_user.module
+++ b/materio_user.module
@@ -1,6 +1,14 @@
MENU_CALLBACK,
+ 'file' => 'materio_user.pages.inc',
+ );
+
+ $items['materio_user/register'] = $base+array(
+ 'title' => 'Materio base user ajax',
+ 'page callback' => 'materio_user_register',
+ // 'page arguments' => array(),
+ 'access callback' => TRUE,
+ );
+
+ $items['materio_user/register/submit'] = $base+array(
+ 'title' => 'Materio base user ajax',
+ 'page callback' => 'materio_user_register_submit',
+ // 'page arguments' => array(),
+ 'access callback' => TRUE,
+ );
+
+ $items['materio_user/login/submit'] = $base+array(
+ 'title' => 'Materio base user ajax',
+ 'page callback' => 'materio_user_login_submit',
+ // 'page arguments' => array(),
+ 'access callback' => TRUE,
+ );
+
+ return $items;
+}
+
/**
* Implements hook_menu_alter().
*/
@@ -87,7 +127,7 @@ function materio_user_block_view($delta = '') {
/**
* Implements hook_form_alter().
*/
-function materio_user_form_alter(&$form, &$form_state, $form_id) {
+function DISABLED_NOT_FINISHED_materio_user_form_alter(&$form, &$form_state, $form_id) {
// dsm($form_id);
if( $form_id == "user_register_form" && !user_access('administer users') ){
// dsm($form);
@@ -131,60 +171,20 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) {
// }
}
-// function materio_user_element_info() {
-// return array(
-// "new_password_confirm" => array(
-// '#input' => TRUE,
-// '#process' => array('materio_user_process_new_password_confirm'),
-// '#theme_wrappers' => array('form_element'),
-// ),
-// );
-// }
-
-/**
- * Expand a password_confirm field into two text boxes.
- */
-// function materio_user_process_new_password_confirm($element) {
-// $element['pass1'] = array(
-// '#type' => 'password',
-// '#title' => t('New password'),
-// '#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'],
-// '#required' => $element['#required'],
-// '#attributes' => array('class' => array('password-field')),
-// );
-// $element['pass2'] = array(
-// '#type' => 'password',
-// '#title' => t('Confirm password'),
-// '#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'],
-// '#required' => $element['#required'],
-// '#attributes' => array('class' => array('password-confirm')),
-// );
-// $element['#element_validate'] = array('password_confirm_validate');
-// $element['#tree'] = TRUE;
-
-// if (isset($element['#size'])) {
-// $element['pass1']['#size'] = $element['pass2']['#size'] = $element['#size'];
-// }
-
-// return $element;
-// }
-
-
-
function materio_user_user_register_form_submit($form, &$form_state){
// dsm($form, 'form');
// dsm($form_state, 'form_state');
// dsm($_REQUEST, '$_REQUEST');
// dsm($_GET, '$_GET');
- unset($_REQUEST['destination'], $_REQUEST['edit']['destination']);
+ // unset($_REQUEST['destination'], $_REQUEST['edit']['destination']);
- $form_state['redirect'] = array(
- 'node/11187',
- array(
- 'fragment' => $_GET['q'] == 'node/11187' ? 'content-bottom' : '', // if we register from the membership page, then go directly to the form
- )
- );
+ // $form_state['redirect'] = array(
+ // 'node/11187',
+ // array(
+ // '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', '');
// // drupal_get_messages('status');
@@ -206,7 +206,7 @@ function materio_user_webform_client_111186_validate($form, &$form_state){
// dsm($form, 'form');
// dsm($form_state, 'form_state');
$values = $form_state['values']['submitted'];
- if ($values['membership_options'] == 3) {
+ if ($values['column_left']['membership_options'] == 3) {
foreach ($values['collaborators'] as $coll_key => $coll) {
foreach ($coll as $field_key => $field_value) {
if($field_value == ''){
@@ -224,7 +224,6 @@ function materio_user_webform_client_111186_validate($form, &$form_state){
}
-
}
// function materio_user_webform_client_111186_submit($form, &$form_state){
diff --git a/materio_user.pages.inc b/materio_user.pages.inc
new file mode 100644
index 00000000..df8b2697
--- /dev/null
+++ b/materio_user.pages.inc
@@ -0,0 +1,55 @@
+'. t('create your materiO\' account') . '';
+ // $return['block'] .= drupal_render(drupal_get_form('user_register_form'));
+
+ // $block = module_invoke('materio_user', 'block_view', 'user_register');
+ // $return['block'] = render($block);
+
+ $block = block_load('materio_user','user_register');
+
+ $return['block'] = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
+
+ // dsm($block, '$block');
+ drupal_json_output($return);
+ // return 'hello';
+}
+
+function materio_user_register_submit(){
+ $return = array();
+ $return['POST'] = $_POST;
+
+ $form_state = array( "values"=>$_POST);
+ drupal_form_submit($_POST['form_id'], $form_state);
+
+ $return['form_state'] = $form_state;
+
+ $return['errors'] = form_get_errors();
+ if($return['errors'])
+ unset ($_SESSION['messages']['error']);
+
+ // after registration user is automaticly logged in, thank's to login tobogan module
+
+ drupal_json_output($return);
+}
+
+function materio_user_login_submit(){
+ $return = array();
+ $return['POST'] = $_POST;
+
+ $form_state = array("values"=>$_POST);
+ drupal_form_submit($_POST['form_id'], $form_state);
+
+ $return['errors'] = form_get_errors();
+ if($return['errors'])
+ unset ($_SESSION['messages']['error']);
+
+ // if user-login form succed we retreive the user uid on $form_state, then we can effectively loggin the user
+ if($uid = $form_state['uid'])
+ user_login_submit(array(), $form_state);
+
+ drupal_json_output($return);
+}
\ No newline at end of file