Changeset 14462

Show
Ignore:
Timestamp:
01/17/08 13:20:14 (11 months ago)
Author:
rambo
Message:

do not hardcode SG constraints

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.reflector/reflector.php

    r14461 r14462  
    343343    function get_create_icon($type) 
    344344    { 
     345        // FIXME make 1. smarter 2. configurable 
    345346        switch ($type) 
    346347        { 
     
    401402                        $icon = $obj->get_icon(); 
    402403                        break; 
     404            // FIXME make 1. smarter 2. configurable 
    403405            case (is_a($obj, 'midgard_person')): 
    404406            case (is_a($obj, 'org_openpsa_person')): 
  • trunk/midcom/midcom.helper.reflector/reflector_tree.php

    r14461 r14462  
    2020class midcom_helper_reflector_tree extends midcom_helper_reflector 
    2121{ 
     22    var $show_sg0_objects = true; 
     23    var $sg_context = false; 
    2224 
    2325    function midcom_helper_reflector_tree($src) 
    2426    { 
     27        $this->sg_context = $_MIDGARD['sitegroup']; 
    2528        parent::midcom_helper_reflector($src); 
    2629    } 
     
    115118        } 
    116119 
    117         if ($_MIDGARD['sitegroup']) 
    118         { 
    119             $qb->add_constraint('sitegroup', '=', $_MIDGARD['sitegroup']); 
    120         } 
     120        $this->_sg_constraints($qb); 
    121121 
    122122        // Figure out constraint to use to get root level objects 
     
    146146 
    147147    /** 
     148     * Sets sitegroup constraints to QB/MC instance 
     149     */ 
     150    function _sg_constraints(&$qb) 
     151    { 
     152        $sgs_to_show = array( 0 => &$this->sg_context ); 
     153        if ($this->show_sg0_objects) 
     154        { 
     155            $sgs_to_show[] = 0; 
     156        } 
     157        $qb->add_constraint('sitegroup', 'IN', $sgs_to_show); 
     158    } 
     159 
     160    /** 
    148161     * Get count of "root" objects for the class this reflector was instantiated for 
    149162     * 
     
    520533        } 
    521534 
    522         if ($_MIDGARD['sitegroup']) 
    523         { 
    524             $qb->add_constraint('sitegroup', '=', $_MIDGARD['sitegroup']); 
    525         } 
     535        $this->_sg_constraints($qb); 
    526536 
    527537        // Figure out constraint to use to get child objects