Example #1
0
    function getHistory($id)
    {
        global $UNI_URL, $UNI_NAME_CLEAN;

        $query = "SELECT name, parent_id, resource_id, owner_id
                  FROM resources_objects
                  WHERE resource_id = ?";
        $statement = DBManager::get()->prepare($query);

        $result_arr = array();
        while ($id) {
            $statement->execute(array($id));
            $object = $statement->fetch(PDO::FETCH_ASSOC);
            $statement->closeCursor();

            $result_arr[] = array(
                'id'       => $object['resource_id'],
                'name'     => $object['name'],
                'owner_id' => $object['owner_id']
            );
            $id = $object['parent_id'];
        }

        if (count($result_arr) > 0)
            switch (ResourceObject::getOwnerType($result_arr[count($result_arr)-1]["owner_id"])) {
                case "global":
                    $top_level_name = $UNI_NAME_CLEAN;
                break;
                case "sem":
                    $top_level_name = _("Veranstaltungsressourcen");
                break;
                case "inst":
                    $top_level_name = _("Einrichtungsressourcen");
                break;
                case "fak":
                    $top_level_name = _("Fakultätsressourcen");
                break;
                case "user":
                    $top_level_name = _("persönliche Ressourcen");
                break;
            }

            if (Request::option('view') == 'search') {
                $result  = '<a href="'. URLHelper::getLink('?view=search&quick_view_mode='. Request::option('view_mode') .'&reset=TRUE') .'">';
                $result .=  $top_level_name;
                $result .= '</a>';
            }
                
            for ($i = sizeof($result_arr)-1; $i>=0; $i--) {
                if (Request::option('view')) {
                    $result .= ' &gt; <a href="'.URLHelper::getLink(sprintf('?quick_view='.Request::option('view').'&quick_view_mode='.Request::option('view_mode').'&%s='.$result_arr[$i]["id"],(Request::option('view')=='search') ? "open_level" : "actual_object" ) );
                        
                    $result .= '">'. htmlReady($result_arr[$i]["name"]) .'</a>';
                } else {
                    $result.= sprintf (" &gt; %s", htmlReady($result_arr[$i]["name"]));
                }
            }
        return $result;
    }