Quellcode durchsuchen

added some comment on source code

Bachir Soussi Chiadmi vor 10 Jahren
Ursprung
Commit
bf41479abc
1 geänderte Dateien mit 39 neuen und 34 gelöschten Zeilen
  1. 39 34
      materio_user.module

+ 39 - 34
materio_user.module

@@ -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') ){
         // dsm($user, 'user');
         $block['subject'] = '';
-        
+
         $path = 'http://base.materio.com';
-        
+
         if($language->language == 'fr')
           $path .= '/index_fr.html';
 
@@ -157,7 +157,7 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) {
     // dsm($form);
     $form['account']['pass']['#type'] = 'password';
     $form['account']['pass']['#title'] = t('Password');
-    
+
     $form['actions']['#type'] = "container";
     $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" ){
     // dsm($form);
-    
+
     $form['actions']['#type'] = "container";
     // $form['actions']['submit']['#value'] = t('Join');
 
     // if( $_GET['q'] == 'node/11187' ){
-    //   $form['#submit'][] = "materio_user_user_login_form_submit";  
+    //   $form['#submit'][] = "materio_user_user_login_form_submit";
     // }
 
   }
@@ -214,7 +214,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
   //   )
   // );
-  
+
   // $frontlink = l('continue with basic', '<front>');
   // // 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)));
@@ -240,16 +240,16 @@ function materio_user_webform_client_11186_validate($form, &$form_state){
   if ($values['column_left']['membership_options'] == 3) {
     foreach ($values['column_right']['collaborators'] as $collab_key => $coll) {
       foreach ($coll as $field_key => $field_value) {
-        
+
         $form_field = $form['submitted']['column_right']['collaborators'][$collab_key][$field_key];
-        
+
         if($field_value == ''){
           $collab_label = $form['submitted']['column_right']['collaborators'][$collab_key]['#title'];
           $field_label = $form_field['#title'];
           $human_field_name =  $collab_label. " : " .$field_label;
-          form_error($form_field, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));      
+          form_error($form_field, t('You must provide a value for the !name field.', array('!name'=>$human_field_name)));
         }
-        
+
         # validate the emails
         # see https://api.drupal.org/api/drupal/modules!user!user.module/function/user_account_form_validate/7
         if($form_field['#type'] == 'webform_email'){
@@ -266,10 +266,15 @@ function materio_user_webform_client_11186_validate($form, &$form_state){
           }
         }
       }
-    } 
+    }
   }
 }
 
+/**
+* subscription webform (nid : 11186)
+*
+* retreive from the web form info, record them into user profil
+*/
 function materio_user_webform_client_11186_submit($form, &$form_state){
   // dsm($form, 'form');
   // dsm($form_state, 'form_state');
@@ -280,7 +285,7 @@ function materio_user_webform_client_11186_submit($form, &$form_state){
   materio_user_flatenize_form_values($values, $flat_values);
   // dsm($flat_values, 'flat_values');
 
-  # redirect memebership form to checkout with good option selected
+  # redirect membership form to checkout with good option selected
   $subscription_level = $flat_values['membership_options'];
   // http://www.ubercart.org/node/1427
   $form_state['redirect'] = array(
@@ -308,7 +313,7 @@ function materio_user_record_member_profile($values) {
 
   global $user;
   // dsm($user, 'user');
-  
+
   $member_profile = profile2_load_by_user($user, 'adherent');
   if (empty($member_profile)) {
     $member_profile = profile2_create(array("type" => 'adherent', "uid" => $user->uid));
@@ -383,7 +388,7 @@ function materio_user_uc_cart_checkout_form_alter(&$form, &$form_state, $form_id
       // dsm($user, 'user');
       $member_profile = profile2_load_by_user($user, 'adherent');
       // dsm($member_profile, "member_profile");
-    
+
       $location = (object) $member_profile->field_adresse['und'][0];
       // dsm($location, "location");
 
@@ -391,15 +396,15 @@ function materio_user_uc_cart_checkout_form_alter(&$form, &$form_state, $form_id
       $phone = $phone_field ? field_view_value('profile2', $member_profile, 'field_private_phone', $phone_field[0]) : "";
 
       $correspondances = array(
-        "billing_first_name" => $member_profile->field_first_name['und'][0]['value'], 
-        "billing_last_name" => $member_profile->field_name['und'][0]['value'], 
-        "billing_phone" => $phone, 
-        "billing_company" => $member_profile->field_organization['und'][0]['value'], 
-        "billing_street1" => $location->thoroughfare, 
-        "billing_street2" => $location->premise, 
-        "billing_city" => $location->locality, 
+        "billing_first_name" => $member_profile->field_first_name['und'][0]['value'],
+        "billing_last_name" => $member_profile->field_name['und'][0]['value'],
+        "billing_phone" => $phone,
+        "billing_company" => $member_profile->field_organization['und'][0]['value'],
+        "billing_street1" => $location->thoroughfare,
+        "billing_street2" => $location->premise,
+        "billing_city" => $location->locality,
         // "billing_zone" => ,
-        "billing_postal_code" => $location->postal_code, 
+        "billing_postal_code" => $location->postal_code,
         "billing_country" => $location->country,
       );
 
@@ -409,11 +414,11 @@ function materio_user_uc_cart_checkout_form_alter(&$form, &$form_state, $form_id
 
       $form['panes']['billing']['address']['#default_value'] = $order;
     }
-  } 
+  }
 }
 
 /**
- * Implements hook_uc_order(); 
+ * Implements hook_uc_order();
  */
 function materio_user_order($op, $order, $arg2) {
   dsm($op, "matyerio_user_uc_order | op");
@@ -441,7 +446,7 @@ function materio_user_create_collaborators_users(){
       //     $field_name = 'submitted][collaborators]['.$coll_key.']['.$field_key;
       //     // 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(
@@ -459,7 +464,7 @@ function materio_user_create_collaborators_users(){
       // module_invoke_all('user_insert', $edit, $account);
       $i++;
     }
-  } 
+  }
   */
 }
 
@@ -474,7 +479,7 @@ function materio_user_help($path, $arg) {
       if($arg[1] == 11187 ){
         global $user;
         // dsm($user, 'user');
-        
+
         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());
           $content = '<p>' . $message . '</p>';
@@ -513,16 +518,16 @@ function _materio_user_user_update(&$edit, $account, $category){
   // dsm($edit, 'edit');
   // dsm($account, 'account');
   // dsm($category, 'category');
-  
+
   // This is only fired when a user confirms their email address, logintoboggan style
-  if (isset($account->logintoboggan_email_validated) && $account->logintoboggan_email_validated == TRUE) {    
-    $confirmed_rid = materio_user_get_role_by_name(MATERIO_USER_CONFIRMED_USER_ROLE);    
+  if (isset($account->logintoboggan_email_validated) && $account->logintoboggan_email_validated == TRUE) {
+    $confirmed_rid = materio_user_get_role_by_name(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
     $user = $account;
     unset($user->logintoboggan_email_validated);
-    
+
     user_save($user, array('roles' => $roles));
 
     drupal_go_to('user/'.$user->uid.'/edit');
@@ -540,5 +545,5 @@ function _materio_user_user_update(&$edit, $account, $category){
  */
 function materio_user_get_role_by_name($name) {
   return array_search($name, user_roles());
-} 
+}