Beispiel #1
0
function artefact_get_parents_for_cache($artefactid, &$parentids = false)
{
    $current = $artefactid;
    if (empty($parentids)) {
        // first call
        $parentids = array();
    }
    while (true) {
        if (!($parent = get_record('artefact', 'id', $current))) {
            break;
        }
        // get any blog posts it may be attached to
        if (($parent->artefacttype == 'file' || $parent->artefacttype == 'image') && ($associated = ArtefactType::attached_id_list($parent->id))) {
            foreach ($associated as $a) {
                $parentids[$a] = 1;
                artefact_get_parents_for_cache($a, $parentids);
            }
        }
        if (!$parent->parent) {
            break;
        }
        $parentids[$parent->parent] = 1;
        $current = $parent->parent;
    }
    return $parentids;
}