Changeset 5795

Show
Ignore:
Timestamp:
04/24/07 12:19:26 (2 years ago)
Author:
rambo
Message:

consodilate the most common exportability checks to one separate method

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/midcom.helper.replicator/exporter.php

    r5711 r5795  
    434434    function is_exportable(&$object) 
    435435    { 
    436         if (!array_key_exists($object->guid, $this->exportability)) 
    437         { 
    438             // This is where the exporter should check whether to export 
    439             if ($object->sitegroup != $_MIDGARD['sitegroup']) 
    440             { 
     436        if (isset($this->exportability[$object->guid])) 
     437        { 
     438            // expotability is set, return early 
     439            return $this->exportability[$object->guid]; 
     440        } 
     441 
     442        // Basic export checks (SG limits, limited objects) 
     443        return $this->is_exportable_baseline($object); 
     444    } 
     445 
     446    function is_exportable_baseline(&$object) 
     447    { 
     448        switch (true) 
     449        { 
     450            // Never replicate login sessions 
     451            case (is_a($object, 'midcom_core_login_session_db')): 
     452            // Never replicate across SG borders 
     453            case ($object->sitegroup != $_MIDGARD['sitegroup']): 
    441454                $this->exportability[$object->guid] = false; 
    442             } 
    443             else 
    444             { 
     455                break; 
     456            // Replicate everything else by default 
     457            default: 
    445458                $this->exportability[$object->guid] = true; 
    446             } 
    447         } 
     459                break; 
     460        } 
     461 
    448462        return $this->exportability[$object->guid]; 
    449463    } 
  • trunk/src/midcom.helper.replicator/exporter/mirror.php

    r5762 r5795  
    9797 
    9898        // Otherwise start checking... 
    99         if ($object->sitegroup != $_MIDGARD['sitegroup']) 
    100         { 
    101             $this->exportability[$object->guid] = false; 
     99        // Check baseline checks first 
     100        if (!$this->is_exportable_baseline($object)) 
     101        { 
    102102            return false; 
    103         } 
    104         else 
    105         { 
    106             $this->exportability[$object->guid] = true; 
    107103        } 
    108104 
  • trunk/src/midcom.helper.replicator/exporter/staging2live.php

    r5759 r5795  
    5555        } 
    5656 
    57         // We might see SG0 content as well, make sure not to include that 
    58         if ($object->sitegroup != $_MIDGARD['sitegroup']) 
    59         { 
    60             $GLOBALS['midcom_helper_replicator_logger']->push_prefix('exporter'); 
    61             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, "Sitegroup mismatch: \$_MIDGARD['sitegroup']={$_MIDGARD['sitegroup']} != {$object->sitegroup}", MIDCOM_LOG_ERROR); 
    62             $GLOBALS['midcom_helper_replicator_logger']->pop_prefix(); 
    63             $this->exportability[$object->guid] = false; 
    64             return false; 
    65         } 
    66  
    6757        $GLOBALS['midcom_helper_replicator_logger']->push_prefix('exporter'); 
    6858 
    6959        // Otherwise start checking... 
     60        // we need AT service 
    7061        if (!class_exists('midcom_services_at_interface')) 
    7162        { 
     
    7566            return $this->exportability[$object->guid]; 
    7667        } 
    77         // Default to true 
     68 
     69        // Check baseline checks first 
     70        if (!$this->is_exportable_baseline($object)) 
     71        { 
     72            return false; 
     73        } 
     74 
     75        // Then default to true 
    7876        $this->exportability[$object->guid] = true; 
    7977