[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/scripts/ -> remove-multiple-currents.php (source)

   1  <?php
   2  require_once dirname( dirname( __FILE__ ) ) . '/gp-load.php';
   3  
   4  class GP_Script extends GP_CLI {
   5      
   6  	function run() {
   7          $sets = GP::$translation_set->all();
   8          foreach( $sets as $set ) {
   9              echo "Processing set#$set->id...\n";
  10              $translations = GP::$translation->find( array( 'translation_set_id' => $set->id, 'status' => 'current' ), 'original_id ASC' );
  11              $prev_original_id = null;
  12              foreach( $translations as $translation ) {
  13                  if ( $translation->original_id == $prev_original_id ) {
  14                      echo "Duplicate with original_id#$prev_original_id. Translation#$translation->id\n";
  15                      $translation->delete();
  16                  } 
  17                  $prev_original_id = $translation->original_id;
  18              }
  19          }
  20      }
  21  }
  22  
  23  $gp_script = new GP_Script;
  24  $gp_script->run();


Generated: Thu May 24 03:59:35 2012 Hosted by follow the white rabbit.