Changeset 19873

Show
Ignore:
Timestamp:
12/18/08 15:48:14 (2 years ago)
Author:
rambo
Message:

make it possible to check objects parents approval only, check (parent) approvals for parameters and attachments, refs #497

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/thor/midcom/midcom.helper.replicator/config/config.inc

    r18844 r19873  
    66    'midcom_core_login_session_db', 
    77    'midcom_core_temporary_object_db', 
    8 ), 
     8),  
    99'exporter_staging2live_delete_unapproved' => false, // Upon explicit un-approve, do we wish to delete from live ?? 
     10// TODO: http://trac.midgard-project.org/ticket/558 
    1011'exporter_staging2live_check_approvals_for' => array 
    1112( 
    12     'midgard_topic', 
    13     'midgard_article', 
    14     'midgard_style', 
    15     'midgard_element', // Style-elements 
    16     'midgard_snippetdir', 
    17     'midgard_snippet', 
    18     'net_nemein_calendar_event', 
     13    'midgard_parameter' => 'parent', 
     14    'midgard_attachment' => 'parent', 
     15    'midgard_topic' => 'object', 
     16    'midgard_article' => 'object', 
     17    'midgard_style' => 'object', 
     18    'midgard_element' => 'object', // Style-elements 
     19    'midgard_snippetdir' => 'object', 
     20    'midgard_snippet' => 'object', 
     21    'net_nemein_calendar_event' => 'object', 
     22    'org_routamc_positioning_location' => 'parent', 
    1923), 
    2024'exporter_staging2live_typefilter_pass_types' => array 
  • branches/thor/midcom/midcom.helper.replicator/exporter/mirror.php

    r17649 r19873  
    263263         
    264264        // Traverse parent tree as well 
    265         $parent = $object->get_parent(); 
     265        $parent = midcom_helper_reflector_tree::get_parent($object); 
    266266        if (is_object($parent)) 
    267267        { 
  • branches/thor/midcom/midcom.helper.replicator/exporter/staging2live.php

    r18462 r19873  
    245245        /* Objects to check approvals for */ 
    246246        $approvals_check_continue = false; 
    247         foreach ($this->check_approvals_for as $class) 
    248         { 
     247        $approvals_check_type = 'object'; 
     248        foreach ($this->check_approvals_for as $class => $check_type) 
     249        { 
     250            // Safety for old format config 
     251            if (is_numeric($class)) 
     252            { 
     253                debug_push_class(__CLASS__, __FUNCTION__); 
     254                debug_add('Old format "exporter_staging2live_check_approvals_for" -configuration detected, please reconfigure according to example from config.inc', MIDCOM_LOG_WARN); 
     255                debug_pop(); 
     256                unset($this->check_approvals_for[$class]); 
     257                $class = $check_type; 
     258                $this->check_approvals_for[$class] = 'object'; 
     259                $check_type = $this->check_approvals_for[$class]; 
     260            } 
    249261            if (is_a($object, $class)) 
    250262            { 
    251263                $approvals_check_continue = true; 
     264                $approvals_check_type = $check_type; 
    252265                break; 
    253266            } 
     
    256269        { 
    257270            $object_class = get_class($object); 
    258             $msg = "Not checking approvals for class {$object_class}"; 
     271            $msg = "Not checking any approvals for class {$object_class}"; 
    259272            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, $msg); 
    260273            debug_add($msg); 
     
    263276        } 
    264277 
     278        // Workaround a corner case 
    265279        if (   is_a($object, 'midgard_article') 
    266280            && !empty($object->up)) 
    267281        { 
    268             // Child articles don't currently have any approval UI, skip approval for them (but do check parent below) 
     282            // Child articles don't currently have sensible approval UI, skip approval for them (but do check parent below) 
    269283            $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Reply article, not checking approval status', MIDCOM_LOG_INFO); 
     284            // PONDER: Is this really neccessary ? 
    270285            $this->exportability[$object->guid] = true; 
    271286        } 
    272         elseif ($object->metadata->revised > $object->metadata->approved) 
    273         { 
    274             // FIXME: use metadata service (?) 
    275             // Not approved since last update 
    276             $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Object could not be exported for replication because it\'s not approved', MIDCOM_LOG_INFO); 
    277             $this->exportability[$object->guid] = false; 
     287        else 
     288        { 
     289            switch ($approvals_check_type) 
     290            { 
     291                case 'parent': 
     292                    $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Checking only parent approval', MIDCOM_LOG_INFO); 
     293                    // PONDER: Is this really neccessary ? 
     294                    $this->exportability[$object->guid] = true; 
     295                    break; 
     296                default: 
     297                case 'object': 
     298                    if ($object->metadata->revised > $object->metadata->approved) 
     299                    { 
     300                        // FIXME: use metadata service (?) 
     301                        // Not approved since last update 
     302                        $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Object could not be exported for replication because it\'s not approved', MIDCOM_LOG_INFO); 
     303                        $this->exportability[$object->guid] = false; 
     304                    } 
     305                    break; 
     306            } 
    278307        } 
    279308 
     
    281310        { 
    282311            // Check the parent also, as that may be unapproved 
    283             $parent = $object->get_parent(); 
     312            $parent = midcom_helper_reflector_tree::get_parent($object); 
    284313            if (   is_object($parent) 
    285314                && isset($parent->guid) 
     
    294323                    if (empty($parent_check_stack)) 
    295324                    { 
    296                         // Empty stack means we're  not inside parent recursion, thus we can raise an UIMessage 
    297                         $ref = new midcom_helper_reflector($object); 
    298                         $_MIDCOM->uimessages->add 
    299                         ( 
    300                             $this->_l10n->get('midcom.helper.replicator'), 
    301                             sprintf 
     325                        if ($approvals_check_type !== 'parent') 
     326                        { 
     327                            // Empty stack means we're  not inside parent recursion, thus we can raise an UIMessage 
     328                            $ref = new midcom_helper_reflector($object); 
     329                            $_MIDCOM->uimessages->add 
    302330                            ( 
    303                                 $this->_l10n->get('%s %s could not be exported for replication because one of its parents is not approved'),  
    304                                 $ref->get_class_label(), 
    305                                 $ref->get_object_label($object) 
    306                             ), 
    307                             'warning' 
    308                         ); 
    309                         unset($ref); 
     331                                $this->_l10n->get('midcom.helper.replicator'), 
     332                                sprintf 
     333                                ( 
     334                                    $this->_l10n->get('%s %s could not be exported for replication because one of its parents is not approved'),  
     335                                    $ref->get_class_label(), 
     336                                    $ref->get_object_label($object) 
     337                                ), 
     338                                'warning' 
     339                            ); 
     340                            unset($ref); 
     341                        } 
    310342                        $GLOBALS['midcom_helper_replicator_logger']->log_object($object, 'Object could not be exported for replication because one of its parents is not approved', MIDCOM_LOG_WARN); 
    311343                    }