Pārlūkot izejas kodu

improved term field restoration batch script

Bachir Soussi Chiadmi 7 gadi atpakaļ
vecāks
revīzija
dee5085c89

+ 4 - 34
sites/all/modules/gui/materiobasemod/materio_admin.module

@@ -254,38 +254,19 @@ function _materio_admin_batch_fixterm_ref($node_type, $target_field, $src_tid, $
       array(
         $nid,
         $src_tid, $target_field,
+        $node_type,
       )
     );
   }
 
-
-
-  // $nodes = taxonomy_select_nodes($src_tid);
-
-  // $k = 0;
-  // foreach ($nodes as $nid) {
-    // $batch['operations'][] = array(
-    //   '_materio_admin_batch_fixterm_ref_op',
-    //   array(
-    //     $nid,
-    //     $src_tid, $target_field,
-    //     $node_type,
-    //   )
-    // );
-    // $k++;
-    // if ($k > 0) {
-    //   break;
-    // }
-  // }
-
   batch_set($batch);
 }
 
-function _materio_admin_batch_fixterm_ref_op($nid, $src_tid, $target_field){
+function _materio_admin_batch_fixterm_ref_op($nid, $src_tid, $target_field, $node_type){
   $context['results']['field_migrated']++;
 
   $node = node_load($nid);
-  // if($node->type == $node_type){
+  if($node->type == $node_type){
     $items = field_get_items('node', $node, $target_field);
     foreach ($items as $key => $item) {
       $flat_items[] = $item['tid'];
@@ -294,19 +275,8 @@ function _materio_admin_batch_fixterm_ref_op($nid, $src_tid, $target_field){
       // $items[] = array('tid'=>$src_tid);
       $node->{$target_field}[LANGUAGE_NONE][] = array('tid'=>$src_tid);
     }
-
-    // $items = array(LANGUAGE_NONE => array());
-    // foreach ($terms as $tid => $name) {
-    //   $items[LANGUAGE_NONE][] = array(
-    //     'showroom_tid' => $tid,
-    //     'location' => $default_tid == $tid ? $src_value : '',
-    //   );
-    // }
-    //
-
     node_save($node);
-
-  // }
+  }
 
   //Simply show the import row count.
   $context['message'] = t('Migrating node !c : %title (%nid)', array(