12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- function materio_user_registerblock(){
- $return = array();
- $block = block_load('materio_user','user_createaccount');
- $return['block'] = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
- drupal_json_output($return);
- }
- function materio_user_loginandregisterblock(){
- $return = array();
- $block = block_load('materio_user','user_register');
- $return['block'] = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));
- drupal_json_output($return);
- }
- 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']);
- }else{
- $messages = drupal_get_messages('status');
- // $return['messages'] = $messages;
- drupal_set_message(t("Congratulations, you juste created your free materiO' account, welcome !"), 'status');
- foreach ($messages['status'] as $msg) {
- drupal_set_message($msg, 'status');
- }
- }
- // 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);
- }
|