Changeset 12388

Show
Ignore:
Timestamp:
09/20/07 11:38:30 (1 year ago)
Author:
bergie
Message:

Fix ACL checks for topics that haven't been created yet, refs #146

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/MidCOM_2_8/midcom.core/midcom/baseclasses/database/topic.php

    r4694 r12388  
    3636    function get_parent_guid_uncached() 
    3737    { 
    38         return midcom_baseclasses_database_topic::get_parent_guid_uncached_static($this->guid); 
     38        return midcom_baseclasses_database_topic::_get_parent_guid_uncached_static_topic($this->up); 
    3939    } 
    40  
     40     
    4141    /** 
    4242     * Statically callable method to get parent guid when object guid is given 
     
    7474        $mc_topic_keys = $mc_topic->list_keys(); 
    7575        list ($key, $copy) = each ($mc_topic_keys); 
    76         $parent_id = $mc_topic->get_subkey($key, 'up'); 
     76        $parent_id = (int) $mc_topic->get_subkey($key, 'up'); 
     77        if ($parent_id == 0) 
     78        { 
     79            // Root-level topic 
     80            return null; 
     81        } 
     82        $mc_parent = midcom_baseclasses_database_topic::new_collector('id', $parent_id); 
     83        $mc_parent->add_value_property('guid'); 
     84        if (!$mc_parent->execute()) 
     85        { 
     86            // ErrorA 
     87            return null; 
     88        } 
     89        $mc_parent_keys = $mc_parent->list_keys(); 
     90        $parent_guids = array_keys($mc_parent_keys); 
     91        $parent_guid = $parent_guids[0]; 
     92        if ($parent_guid === false) 
     93        { 
     94            return null; 
     95        } 
     96        return $parent_guid; 
     97    } 
     98     
     99    /** 
     100     * Get topic guid statically 
     101     * 
     102     * used by get_parent_guid_uncached_static 
     103     * 
     104     * @param id $parent_id id of topic to get the guid for 
     105     */ 
     106    function _get_parent_guid_uncached_static_topic($parent_id) 
     107    { 
     108        if (empty($parent_id)) 
     109        { 
     110            return null; 
     111        } 
    77112        $mc_parent = midcom_baseclasses_database_topic::new_collector('id', $parent_id); 
    78113        $mc_parent->add_value_property('guid'); 
     
    83118        } 
    84119        $mc_parent_keys = $mc_parent->list_keys(); 
    85         list ($key2, $copy2) = each ($mc_parent_keys); 
    86         $parent_guid = $mc_parent->get_subkey($key2, 'guid')
     120        $parent_guids = array_keys($mc_parent_keys); 
     121        $parent_guid = $parent_guids[0]
    87122        if ($parent_guid === false) 
    88123        { 
  • branches/MidCOM_2_8/midcom.core/midcom/services/auth.php

    r6088 r12388  
    919919        } 
    920920 
    921         if ($user == 'EVERYONE') 
     921        if (   is_string($user) 
     922            && $user == 'EVERYONE') 
    922923        { 
    923924            $user = null;