| 
					
				 | 
			
			
				@@ -0,0 +1,357 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<?php 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * MaterioIndustrialUserMigration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ *  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class MaterioIndustrialUserMigration extends MaterioBasicMigration { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public function __construct() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    parent::__construct(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->description = t('Migrate Materio Industrials Users'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// provide better description for source fields 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// and add new field source not from sql 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $source_fields = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'id_industrial' => t('Industrial id from source') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  $query = db_select(MIG_MAT_SRC_DB .'.industrial_id', 'iid'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->join(MIG_MAT_SRC_DB .'.industrial_account', 'ind_ac', 'iid.id_industrial = ind_ac.id_industrial'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->join(MIG_MAT_SRC_DB .'.industrial_info', 'iinf', 'iid.id_industrial = iinf.id_industrial'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->fields('iid', array('id_industrial', 'date_creation', 'date_modif')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->fields('ind_ac', array('login', 'password')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->fields('iinf', array('email_general')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->orderBy('id_industrial', 'DESC'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->groupBy('iid.id_industrial'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  $this->source = new MigrateSourceSQL($query, $source_fields); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->destination = new MigrateDestinationUser(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->map = new MigrateSQLMap($this->machineName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'id_industrial' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'type' => 'int', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'unsigned' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'not null' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'description' => 'OLD Unique industrial ID', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'alias' => 'iid', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      MigrateDestinationUser::getKeySchema() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // Make the mappings 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('name', 'login'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('pass', 'password'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('mail', 'email_general'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('language')->defaultValue(''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('theme')->defaultValue(''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('signature')->defaultValue(''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('signature_format')->defaultValue('filtered_html'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 	$this->addFieldMapping('created', 'date_creation'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('access', 'date_modif'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('login')->defaultValue(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('status')->defaultValue(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('picture')->defaultValue(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('init', 'email_general'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('timezone')->defaultValue(NULL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  // $this->addFieldMapping('path')->issueGroup(t('DNM')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  $this->addFieldMapping('pathauto')->defaultValue(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$this->addFieldMapping('roles')->defaultValue(array(5)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	$this->addFieldMapping('is_new')->defaultValue(TRUE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// $this->addFieldMapping('contact', 'contact_list') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//      ->separator(',') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//      ->arguments(array('source_type' => 'tid')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	// public function prepareRow($current_row) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//     return TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//     // return FALSE if you wish to skip a particular row 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * MaterioIndustrialProfile2Migration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class MaterioIndustrialProfile2Migration extends MaterioBasicMigration { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  public function __construct() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    parent::__construct(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		global $user; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->description = t('Migrate Materio Industrials Profiles2'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// provide better description for source fields 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// and add new field source not from sql 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $source_fields = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'id_industrial' => t('Industrial id from source'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'department'=> t('en-fr department implemented on prepare'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'contact_quality'=> t('en-fr contat quality implemented on prepare'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'admin_quality'=> t('en-fr admin quality implemented on prepare'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'language'=> t('en-fr langauge description, used in prepare'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'tels_contact'=>'', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'ccodes_contact'=>'', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'tels_admin' => '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'ccodes_admin' => '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  $query = db_select(MIG_MAT_SRC_DB .'.industrial_id', 'iid'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->join(MIG_MAT_SRC_DB .'.industrial_info', 'iinf', 'iid.id_industrial = iinf.id_industrial'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$ilfr_select = db_select(MIG_MAT_SRC_DB .'.industrial_lang', 'ilfr_select') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->fields('ilfr_select')->condition('ilfr_select.id_locale',1)->orderBy('ilfr_select.id_industrial', 'DESC')->distinct(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->join($ilfr_select, 'ilfr', 'iid.id_industrial = ilfr.id_industrial'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$ilen_select = db_select(MIG_MAT_SRC_DB .'.industrial_lang', 'ilen_select') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->fields('ilen_select')->condition('ilen_select.id_locale',2)->orderBy('ilen_select.id_industrial', 'ASC')->distinct(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->join($ilen_select, 'ilen', 'iid.id_industrial = ilen.id_industrial');  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->fields('iid', array('id_industrial', 'memo')) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->fields('iinf', array('company', 'address', 'city', 'zip', 'web', 'email_general', 'contact', 'contact_title', 'email_contact', 'tel1_contact', 'ccode1_contact', 'tel2_contact', 'ccode2_contact', 'admin', 'admin_title', 'email_admin', 'tel1_admin', 'ccode1_admin', 'tel2_admin', 'ccode2_admin', 'email_sample')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilfr', 'department', 'department_fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilfr', 'country', 'country_fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilfr', 'contact_quality', 'contact_quality_fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilfr', 'admin_quality', 'admin_quality_fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilen', 'department', 'department_en'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilen', 'country', 'country_en'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilen', 'contact_quality', 'contact_quality_en'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->addField('ilen', 'admin_quality', 'admin_quality_en'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$query->groupBy('id_industrial') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->orderBy('id_industrial', 'DESC'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  $this->source = new MigrateSourceSQL($query, $source_fields); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $this->dependencies = array('MaterioIndustrialUser'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->destination = new MigrateDestinationProfile2('contact_operationnel'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $this->map = new MigrateSQLMap($this->machineName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        'id_industrial' => array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'type' => 'int', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'unsigned' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'not null' => TRUE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'description' => 'OLD Unique industrial ID', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          'alias' => 'iid', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      MigrateDestinationProfile2::getKeySchema() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  // Connecting the profile2 to the user: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  $this->addFieldMapping('uid', 'id_industrial') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	    ->sourceMigration('MaterioIndustrialUser')  // If your user migration class was named 'MyUserMigration', the string is 'MyUser' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	    ->description(t('The assignment of profile2-items to the respective user')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('revision_uid', 'id_industrial') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->sourceMigration('MaterioIndustrialUser'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	  // Make the mappings 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('language')->defaultValue(''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_company', 'company') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->arguments(array('create_term' => TRUE)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// see on prepareRow() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_department', 'department');		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_department:language', 'language');		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'department_en'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'department_fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$arguments = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // 'name_line' => array('source_field' => 'name'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'thoroughfare' => array('source_field' => 'address'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'locality' => array('source_field' => 'city'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      'postal_code' => array('source_field' => 'zip'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_public_address', 'country_en') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->arguments($arguments); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'address'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'city'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'zip'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'country_fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $this->addFieldMapping('field_website', 'web'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// ->arguments(array('url'=>array("source_field"=>'web'))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$arguments = MigrateLinkFieldHandler::arguments(array('source_field' => 'web_title')); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_website', 'web') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->arguments($arguments); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_presentation')->defaultValue(''); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_public_name', 'contact'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_public_name_title', 'contact_title'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_public_email', 'email_contact'); // http://drupal.org/node/1232028 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$arguments = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'number' => array('source_field' => 'tel1_contact'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 'extension' => array('source_field' => 'ccode1_contact'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_public_phone', 'ccode1_contact') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->arguments($arguments); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'tel1_contact'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $this->addFieldMapping(NULL, 'ccode1_contact'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'tel2_contact'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'ccode2_contact'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		/* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			TODO  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			multiple field phone number ?? tel2_contact ccode2_contact 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// see on prepareRow() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_public_quality', 'contact_quality');		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_public_quality:language', 'language');		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'contact_quality_en'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'contact_quality_fr');	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_private_name', 'admin'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_private_name_title', 'admin_title'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_private_email', 'email_admin'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// see on prepareRow() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_private_quality', 'admin_quality');		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_private_quality:language', 'language'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'admin_quality_en'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'admin_quality_fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$arguments = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'number' => array('source_field' => 'tel1_admin'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 'extension' => array('source_field' => 'ccode1_admin'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_private_phone', 'ccode1_admin') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->arguments($arguments); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'tel1_admin'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $this->addFieldMapping(NULL, 'ccode1_admin'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'tel2_admin'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'ccode2_admin'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		/* 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		TODO  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		multiple field phone number ?? tel2_admin ccode2_admin 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_private_other_emails', 'email_sample') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			->separator(','); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping(NULL, 'email_general'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_note')->defaultValue(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$this->addFieldMapping('field_memo', 'memo'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public function prepareRow($current_row) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->address = preg_replace('/\\n/', ', ', $current_row->address); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->city = preg_replace('/\\n/', ' ', $current_row->city); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->department = array($current_row->department_en, $current_row->department_fr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->contact_quality = array($current_row->contact_quality_en, $current_row->contact_quality_fr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->admin_quality = array($current_row->admin_quality_en, $current_row->admin_quality_fr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->language = array('en', 'fr'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->web_title = str_replace('http://', '', $current_row->web); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$current_row->web = 'http://' . $current_row->web_title; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($current_row->email_general != "") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$current_row->email_sample .= ','.$current_row->email_general; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$ccs = cck_phone_countrycodes(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$match = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			foreach ($ccs as $cc => $cc_values) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if('+'.$current_row->ccode1_contact == $cc_values['code']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$current_row->ccode1_contact = $cc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$match++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if('+'.$current_row->ccode2_contact == $cc_values['code']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$current_row->ccode2_contact = $cc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$match++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if('+'.$current_row->ccode1_admin == $cc_values['code']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$current_row->ccode1_admin = $cc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$match++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if('+'.$current_row->ccode2_admin == $cc_values['code']){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$current_row->ccode2_admin = $cc; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					$match++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if($match == 4)  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($current_row->tel2_contact != ''){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$cc = cck_phone_countrycodes($current_row->ccode2_contact); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$current_row->memo .= "\n".'tel2 contact : '. $cc['country'] . ' (' . $cc['code'] . ')' .' '. $current_row->tel2_contact; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if($current_row->tel2_admin != ''){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$cc = cck_phone_countrycodes($current_row->ccode2_admin); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				$current_row->memo .= "\n".'tel2 admin : '. $cc['country'] . ' (' . $cc['code'] . ')' .' '. $current_row->tel2_admin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// $current_row->tels_contact = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// $current_row->ccodes_contact = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// if($current_row->tel1_contact != ''){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->tels_contact[] = $current_row->tel1_contact; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->ccodes_contact[] = $current_row->ccode1_contact; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	$current_row->tels_contact[] = drupal_json_encode(array('counry_code'=>$current_row->ccode1_contact, 'number'=>$current_row->tel1_contact)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// if($current_row->tel2_contact != ''){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->tels_contact[] = $current_row->tel2_contact; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->ccodes_contact[] = $current_row->ccode2_contact; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	$current_row->tels_contact[] = drupal_json_encode(array('counry_code'=>$current_row->ccode2_contact, 'number'=>$current_row->tel2_contact)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// $current_row->tels_admin = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// $current_row->ccodes_admin = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// if($current_row->tel1_admin != ''){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->tels_admin[] = $current_row->tel1_admin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->ccodes_admin[] = $current_row->ccode1_admin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	$current_row->tels_admin[] = drupal_json_encode(array('counry_code'=>$current_row->ccode1_admin, 'number'=>$current_row->tel1_admin)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// if($current_row->tel2_admin != ''){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->tels_admin[] = $current_row->tel2_admin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	// $current_row->ccodes_admin[] = $current_row->ccode2_admin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 	$current_row->tels_admin[] = drupal_json_encode(array('counry_code'=>$current_row->ccode2_admin, 'number'=>$current_row->tel2_admin)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			dsm($current_row, '- - - - $current_row - - - -'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	    return TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	    // return FALSE if you wish to skip a particular row 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public function prepare($node, stdClass $row) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// dsm('-- prepare --'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// dsm($node, '$node'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// dsm($row, '$row'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $node->field_public_email = array('und'=>array($row->email_contact)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |