Changeset 17689

Show
Ignore:
Timestamp:
09/25/08 13:32:41 (2 months ago)
Author:
rambo
Message:

forward port r17688, but keep the difference in score logic, just making it more explicit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.admin.folder/handler/order.php

    r17488 r17689  
    6868            { 
    6969                // Set the score reversed: the higher the value, the higher the rank 
    70                 $score = $count - $i; 
     70                $score = (int)$i; 
     71                $score_r = (int)($count - $i); 
    7172 
    7273                // Use the DB Factory to resolve the class and to get the object 
     
    8283                } 
    8384 
    84                 // Get the original approval status 
    85                 $metadata =& midcom_helper_metadata::retrieve($identificator); 
     85                // Get the original approval status and update metadata reference 
     86                $metadata =& midcom_helper_metadata::retrieve($object); 
     87                if (!is_object($metadata)) 
     88                { 
     89                    $_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Couild not fetch metadata for object {$guid}"); 
     90                    // This will exit 
     91                } 
     92                // Make sure this is reference to correct direction (from our point of view) 
     93                $metadata->object =& $object; 
     94 
     95                // Get the approval status if metadata object is available 
    8696                $approval_status = false; 
    87  
    88                 // Get the approval status if metadata object is available 
    89                 if (   is_object($metadata) 
    90                     && $metadata->is_approved()) 
     97                if ($metadata->is_approved()) 
    9198                { 
    9299                    $approval_status = true; 
    93100                } 
    94101 
     102                /**  
     103                 * WARNING: Score handling is different from branch-28, we carefull when backporting 
     104                 */ 
    95105                // Store the old-fashioned score as well 
    96106                if (isset($object->score)) 
    97107                { 
    98                     $object->score = $score; 
    99                 } 
    100  
    101                 $object->metadata->score = $score; 
    102  
    103                 // Show an error message on an update failure 
     108                    $object->score = $score_r; 
     109                } 
     110                $object->metadata->score = $score_r; 
     111 
     112                /* 
    104113                if (!$object->update()) 
    105                 { 
    106                     // Some heuristics for the update logging 
    107                     if (   isset($object->title) 
    108                         && $object->title) 
    109                     { 
    110                         $title = $object->title; 
    111                     } 
    112                     elseif (isset($object->extra) 
    113                         && $object->extra) 
    114                     { 
    115                         $title = $object->extra; 
    116                     } 
    117                     elseif (isset($object->name) 
    118                         && $object->name) 
    119                     { 
    120                         $title = $object->name; 
    121                     } 
    122                     else 
    123                     { 
    124                         $title = sprintf("{$object->guid} %s", get_class($object)); 
    125                     } 
    126  
     114                $metadata->set() calls update *AND* updates the metadata cache correctly, thus we use that in stead of raw update 
     115                */ 
     116                if (!$metadata->set('score', $object->metadata->score)) 
     117                { 
     118                    // Show an error message on an update failure 
     119                    $_MIDCOM->load_library('midcom.helper.reflector'); 
     120                    $reflector =& midcom_helper_reflector::get($object); 
     121                    $title = $reflector->get_class_label() . ' ' . $reflector->get_object_label($object); 
    127122                    $_MIDCOM->uimessages->add($this->_l10n->get('midcom.admin.folder'), sprintf($this->_l10n->get('failed to update %s due to: %s'), $title, mgd_errstr()), 'error'); 
    128123                    $success = false;