Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Removing Web Links navigation for casual users
  • Posted: 17.12.2005, 21:41
     
    jgross42
    rank:
    Softmore Softmore
    registered:
     December 2003
    Status:
    offline
    last visit:
    16.01.07
    Posts:
    70
    The navigation at the top of your web links pages can interfere with other forms of navigation you provide. In my case, for example, I use the Menu Express tree menus extensively, and I don't want my users clicking on the web links folder icons as it takes them out of the Menu Express hierarchy I have created and, most importantly, confuses them. To remove the Web Links navigation, you can just delete the relevant lines in wl-viewlinks.php and wl-navigation.php, or you can use your permissions. To restrict visibility to administrators, for example, find the relevant blocks and put the following lines around them, like this.

    if (pnSecAuthAction(0, 'Web Links::', '::', ACCESS_ADMIN)) {
    LINES OF CODE
    LINES OF CODE
    }

    This is wl-viewlink.php with the Category: Start /Subcategory trail and the category folders hidden, but leaving the Sort By menu on view to all. Under that is wl-navigation.php with everything hidden.


    Code

    <?php
    // File: $Id: wl-viewlink.php,v 1.45 2005/07/26 22:45:23 markwest Exp $
    // ----------------------------------------------------------------------
    // PostNuke Content Management System
    // Copyright (C) 2001 by the PostNuke Development Team.
    // http://www.postnuke.com/
    // ----------------------------------------------------------------------
    // Based on:
    // PHP-NUKE Web Portal System - http://phpnuke.org/
    // Thatware - http://thatware.org/
    // ----------------------------------------------------------------------
    // LICENSE
    //
    // This program is free software; you can redistribute it and/or
    // modify it under the terms of the GNU General Public License (GPL)
    // as published by the Free Software Foundation; either version 2
    // of the License, or (at your option) any later version.
    //
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // To read the license please visit http://www.gnu.org/copyleft/gpl.html
    // ----------------------------------------------------------------------
    // Original Author of file: Francisco Burzi
    // Purpose of file:
    // ----------------------------------------------------------------------
    // 11-30-2001:ahumphr - created file as part of modularistation
    // 10-15-2002:skooter      - Cross Site Scripting security fixes and also using
    //                           pnAPI for displaying data.

    /**
     * sortLinksByMenu
     * generates the sort links by menu
     */

    function sortLinksByMenu($cid, $orderbyTrans)
    {
      echo '<div style="text-align:center">'._SORTLINKSBY.": "
            ._TITLE." ( <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=titleA\" title=\""._TITLEAZ."\">+</a> | <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=titleD\" title=\""._TITLEZA."\">-</a> ) "
            ._DATE." ( <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=dateA\" title=\""._DATE1."\">+</a> | <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=dateD\" title=\""._DATE2."\">-</a> ) "
            ._RATING." ( <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=ratingA\" title=\""._RATING1."\">+</a> | <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=ratingD\" title=\""._RATING2."\">-</a> ) "
            ._POPULARITY." ( <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=hitsA\" title=\""._POPULARITY1."\">+</a> | <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".pnVarPrepForDisplay($cid)."&amp;orderby=hitsD\" title=\""._POPULARITY2."\">-</a> )"
            ."<br /><strong>"._SITESSORTED.": ".pnVarPrepForDisplay($orderbyTrans)."</strong><br /></div>";
    }

    /**
     * viewlink
     */

    function viewlink($cid, $min, $orderby, $show)
    {

        list($cid, $min, $orderby, $show) = pnVarCleanFromInput('cid', 'min', 'orderby', 'show');
       
        //global $datetime;
        include('header.php');

        $dbconn =& pnDBGetConn(true);
        $pntable =& pnDBGetTables();
        $column = &$pntable['links_categories_column'];

        //if (empty($perpage)||!is_numeric($perpage)) $perpage=pnConfigGetVar('perpage');
        $perpage = pnConfigGetVar('perpage');
        $locale = pnConfigGetVar('locale');
        $linkresults = pnConfigGetVar('linksresults');

        // check if this or parent category is accessible to user
        $result =& $dbconn->Execute("SELECT $column[parent_id], $column[title]
                                    FROM $pntable[links_categories]
                                    WHERE $column[cat_id]='"
    .(int)pnVarPrepForStore($cid)."'");
        list($parent_id, $title) = $result->fields;
        $result_par =& $dbconn->Execute("SELECT $column[title]
                                        FROM $pntable[links_categories]
                                        WHERE $column[cat_id]='"
    .(int)pnVarPrepForStore($parent_id)."'");
        list($parent_title) = $result_par->fields;
        if (!pnSecAuthAction(0, 'Web Links::Category', "$title::$cid" , ACCESS_READ)
            || !pnSecAuthAction(0, 'Web Links::Category', "$parent_title::$parent_id" , ACCESS_READ)) {
            echo _BADAUTHKEY;
            include 'footer.php';
            return;
        }
       
        if (empty($min) || !is_numeric($min)) $min=0;
        if (empty($show) || !is_numeric($show)) $show="";
        if (empty($max) || !is_numeric($max)) $max=$min+$perpage;
        if(!empty($orderby)) {
            $orderby = convertorderbyin($orderby);
        } else {
            $orderby = convertorderbyin("titleA");
        }
        if ($show!="") {
            $perpage = $show;
        } else {
            $show=$perpage;
        }
        menu(1);

        OpenTable();
        $sql = "SELECT $column[title] , $column[cdescription]
                FROM $pntable[links_categories]
                WHERE $column[cat_id]='"
    .(int)pnVarPrepForStore($cid)."'";
        $result =& $dbconn->Execute($sql);
        list($title, $description) = $result->fields;
    if (pnSecAuthAction(0, 'Web Links::', '::', ACCESS_ADMIN)) {
        echo '<div style="text-align:center"><h2>'._CATEGORY.": ".CatPath($cid,1,1,0).'</h2>';
        if ($description <> "") {
            echo "".pnVarPrepHTMLDisplay($description).'<br />';
        }
        echo '</div>';
    }

        //$carrytitle = $title;

        $column = &$pntable['links_categories_column'];
        $subsql = "SELECT $column[cat_id], $column[title]
                    FROM $pntable[links_categories]
                    WHERE $column[parent_id]='"
    .(int)pnVarPrepForStore($cid)."'
                    ORDER BY $column[title]"
    ;
        $subresult =& $dbconn->Execute($subsql);
        $numrows = $subresult->PO_RecordCount();
    if (pnSecAuthAction(0, 'Web Links::', '::', ACCESS_ADMIN)) {
        if ($numrows != 0) {
            echo '<div style="text-align:center">'._LALSOAVAILABLE." ".pnVarPrepForDisplay($title)." "._SUBCATEGORIES.':<br />';
            $count = 0;
            while(list($sid, $title) = $subresult->fields) {
                $subresult->MoveNext();
                if (pnSecAuthAction(0, 'Web Links::Category', "$title::$sid" , ACCESS_READ)) {
                    echo "&nbsp;<img src=\"modules/Web_Links/images/folder.gif\" height=\"13\" width=\"15\" alt=\"\" /> <a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".(int)pnVarPrepForStore($sid)."\">"
                        .pnVarPrepForDisplay($title)."</a> (".CountSubLinks($sid).")&nbsp;";
                    subcategorynewlinkgraphic($sid);
                    echo "&nbsp;";
                }

                $scount++;
                if ($scount==3) {
                    echo '<br />';
                    $scount = 0;
                }
            }
            echo '</div><br />';
        }
    }
        $orderbyTrans = convertorderbytrans($orderby);

        sortLinksByMenu($cid, $orderbyTrans);
            echo "<br />";
        $column = &$pntable['links_links_column'];
        $fullcountresult =& $dbconn->Execute("SELECT count(*)
                                            FROM $pntable[links_links]
                                            WHERE $column[cat_id]='"
    .(int)pnVarPrepForStore($cid)."'");
        list($totalselectedlinks) = $fullcountresult->fields;

        $query = "SELECT $column[lid],
                            $column[title],
                            $column[description],
                            $column[date],
                            $column[hits],
                            $column[linkratingsummary],
                            $column[totalvotes],
                            $column[totalcomments]
                    FROM $pntable[links_links]
                    WHERE $column[cat_id]='"
    .(int)pnVarPrepForStore($cid)."'
                    ORDER BY $orderby"
    ;
        $result = $dbconn->SelectLimit($query, $linkresults, (int)$min);
       
        while(list($lid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=$result->fields) {

            $result->MoveNext();
            if (pnSecAuthAction(0, 'Web Links::Link', ":$title:$lid", ACCESS_READ)) {
                    $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
                    echo "<h3><a href=\"".$GLOBALS['modurl']."&amp;req=visit&amp;lid=".(int)$lid."\">".pnVarPrepForDisplay($title)."</a>";
                    newlinkgraphic($datetime, $time);
                    popgraphic($hits);
                    echo '</h3>';
                    //transform hooks
                    list($description) = pnModCallHooks('item', 'transform', '', array($description));
                    if (pnSecAuthAction(0, 'Web Links::', '::', ACCESS_ADMIN)) {
                        echo "<a href=\"admin.php?module=Web_Links&amp;op=LinksModLink&amp;lid=$lid\"><img src=\"modules/Web_Links/images/editicon.gif\" alt=\""._EDITTHISLINK."\" /></a>";
                    }
                    echo "".pnVarPrepHTMLDisplay($description).'<br />';
                    ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
                    $datetime = ml_ftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
                    $datetime = ucfirst($datetime);
                    echo ""._ADDEDON.": ".pnVarPrepForDisplay($datetime)." | "._HITS.": ".(int)$hits;
                    /* voting & comments stats */
                    if ($totalvotes == 1) {
                        $votestring = _VOTE;
                    } else {
                        $votestring = _VOTES;
                    }
                    if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
                        echo " | "._RATING.": ".pnVarPrepForDisplay($linkratingsummary)." (".(int)$totalvotes." ".pnVarPrepForDisplay($votestring).")";
                        //removed show star flag need to replace with config var - skooter
                        //if ($web_links_show_star) {
                            echo '<br />'.web_links_rateMakeStar($linkratingsummary, 10);
                        //}
                    }
                    $transfertitle = str_replace (" ", "_", $title);
                    LinksBottomMenu($lid, $transfertitle, $totalvotes, $totalcomments);
                    detecteditorial($lid, $transfertitle);
                    echo '<br /><br />';
                    }
        }
        $orderby = convertorderbyout($orderby);
        /* Calculates how many pages exist. Which page one should be on, etc... */
        $linkpagesint = ($totalselectedlinks / $perpage);
        $linkpageremainder = ($totalselectedlinks % $perpage);
        if ($linkpageremainder != 0) {
            $linkpages = ceil($linkpagesint);
            if ($totalselectedlinks < $perpage) {
                $linkpageremainder = 0;
            }
        } else {
            $linkpages = $linkpagesint;
        }
        /* Page Numbering */
        if ($linkpages > 1) {
            echo '<br />';
            echo _SELECTPAGE.": ";
            $prev=$min-$perpage;
            if ($prev>=0) {
                echo "&nbsp;&nbsp;<a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".(int)$cid."&amp;min=".(int)$prev."&amp;orderby=".pnVarPrepForDisplay($orderby)."&amp;show=".pnVarPrepForDisplay($show)."\">";
                echo " &lt;&lt; "._PREVIOUS."</a>&nbsp;&nbsp;&nbsp;";
            }
            $counter = 1;
            $currentpage = ($max / $perpage);
            while ($counter<=$linkpages ) {
                $cpage = $counter;
                $mintemp = ($perpage * $counter) - $perpage;
                if ($counter == $currentpage) {
                    echo "".(int)$counter."&nbsp";
                } else {
                    echo "<a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".(int)$cid."&amp;min=".(int)$mintemp."&amp;orderby=".pnVarPrepForDisplay($orderby)."&amp;show=".pnVarPrepForDisplay($show)."\">".(int)$counter."</a> ";
                }
                $counter++;
            }
            $next=$min+$perpage;
            if ($currentpage < $linkpages) {
                echo "&nbsp;&nbsp;&nbsp;<a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=".(int)$cid."&amp;min=".(int)$max."&amp;orderby=".pnVarPrepForDisplay($orderby)."&amp;show=".pnVarPrepForDisplay($show)."\">";
                echo " "._NEXT." &gt;&gt;</a>";
            }
        }
        CloseTable();
        include('footer.php');
    }
    ?>


    Code

    <?php
    // File: $Id: wl-navigation.php,v 1.43 2005/07/26 22:45:23 markwest Exp $
    // ----------------------------------------------------------------------
    // PostNuke Content Management System
    // Copyright (C) 2001 by the PostNuke Development Team.
    // http://www.postnuke.com/
    // ----------------------------------------------------------------------
    // Based on:
    // PHP-NUKE Web Portal System - http://phpnuke.org/
    // Thatware - http://thatware.org/
    // ----------------------------------------------------------------------
    // LICENSE
    //
    // This program is free software; you can redistribute it and/or
    // modify it under the terms of the GNU General Public License (GPL)
    // as published by the Free Software Foundation; either version 2
    // of the License, or (at your option) any later version.
    //
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    //
    // To read the license please visit http://www.gnu.org/copyleft/gpl.html
    // ----------------------------------------------------------------------
    // Original Author of file: Francisco Burzi
    // Purpose of file:
    // ----------------------------------------------------------------------
    // 11-30-2001:ahumphr - created file as part of modularistation

    /**
     * index
     * Display the main links categories
     */

    function index()
    {
        $dbconn =& pnDBGetConn(true);
        $pntable =& pnDBGetTables();

        include('header.php');
        $mainlink = 0;

        if (!pnSecAuthAction(0, 'Web Links::', '::', ACCESS_READ)) {
            echo _WEBLINKSNOAUTH;
            include 'footer.php';
            exit;
        }

        $column = &$pntable['links_categories_column'];
        $result =& $dbconn->Execute("select $column[cat_id], $column[title], $column[cdescription]
                                  from $pntable[links_categories]
                                  WHERE $column[parent_id]=0
                                  ORDER BY $column[title]"
    );
        $numcats = $result->PO_RecordCount();
        if ($numcats == 0) {
            echo _LINKSNOCATS;
            include 'footer.php';
        } else {

            menu($mainlink);

            OpenTable();

            echo '<h2>'._LINKSMAINCAT.'</h2>';
    //This table can be deleted
            echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"10\" width=\"98%\" summary=\""._LINKSMAINCAT."\">";

            $count = 0;
            while(list($cat_id, $title, $cdescription) = $result->fields)
            {
                $result->MoveNext();
                /* Hide this web link if have no access to it */
                if (!pnSecAuthAction(0, 'Web Links::Category', "$title::$cat_id", ACCESS_READ)) {
                    continue;
                }
                if ($count == 0) {
                    // we need to start a row
                    echo "<tr>";
                }
                $count++;
                $cnumrows = CountSubLinks($cat_id);
    //The next six lines can be deleted
                echo "<td valign=\"top\" style=\"width:50%\"><h3>"
                    ."<img src=\"modules/Web_Links/images/folder.gif\" height=\"13\" width=\"15\" alt=\"\" />&nbsp;&nbsp;"
                    ."<a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=$cat_id\">".pnVarPrepForDisplay($title)."</a>"
                    ." ($cnumrows)";
                categorynewlinkgraphic($cat_id);
                echo '</h3>';
       
                if ($cdescription) {
                    echo pnVarPrepHTMLDisplay($cdescription).'<br />';
                }

                $column = &$pntable['links_categories_column'];
                $result2 =& $dbconn->Execute("SELECT $column[cat_id], $column[title] FROM $pntable[links_categories] WHERE $column[parent_id]='".pnVarPrepForStore($cat_id)."' ORDER BY $column[title]");

                while(list($scat_id, $stitle) = $result2->fields) {

                    $result2->MoveNext();
                    if (!pnSecAuthAction(0, 'Web Links::Category', "$stitle::$scat_id", ACCESS_READ)) {
                        continue;
                    }
                    echo "&nbsp;&nbsp;&nbsp;"
                        ."<img src=\"modules/Web_Links/images/folder.gif\" height=\"13\" width=\"15\" alt=\"\" />&nbsp;&nbsp;"
                        ."<a href=\"".$GLOBALS['modurl']."&amp;req=viewlink&amp;cid=$scat_id\">".pnVarPrepForDisplay($stitle)."</a>";
                    subcategorynewlinkgraphic($scat_id);
                    echo '<br />';
                }

                if ($count==1) {
                    // next table cell
                    echo "</td>";
                }

                if ($count==2) {
                    // two entries, start the next table row
                    echo "</td></tr>";
                    $count = 0;
                }
            } //While
           
            if ($count == 1) {
                // we need
                echo "<td>&nbsp;</td></tr>";
            }
           
            echo "</table>";
    //The previous line is the end of the table
             $result =& $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_links]");
            list($numrows) = $result->fields;

            $result =& $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_categories]");
            list($catnum) = $result->fields;

            echo "<br /><div style=\"text-align:center\">"._THEREARE." <strong>$numrows</strong> "._LINKS." "._AND." <strong>$catnum</strong> "._CATEGORIES." "._INDB."</div>";
            CloseTable();
            include('footer.php');
        }
    }

    /**
     * menu
     * builds the standard navigation menu
     * @param mainlink  integer switch. 1 means show _LINKSMAIN, 0 not.
     */

    function menu($mainlink) {
        //$query = pnVarCleanFromInput('query');
    //Inserted to prevent user access
    if (pnSecAuthAction(0, 'Web Links::', '::', ACCESS_ADMIN)) {
        OpenTable();
        //patch [ #471 ] Web Module Fix Wil Schultz (xwil)
        echo '<div style="text-align:center"><h1>'._LINKPAGETITLE."</h1>";
        //echo "<div style=\"text-align:center\"><a  href=\"".$GLOBALS['modurl']."\">"._LINKPAGETITLE."</a><br />";
        echo "<form action=\"".$GLOBALS['modurl']."&amp;req=search\" method=\"post\" name=\""._LINKS."\"><div>"
            ."<label for=\"query\">"._LINKS."</label>"
            ." <input type=\"text\" size=\"25\" name=\"query\" id=\"query\" tabindex=\"0\"
                                            value=\""
    ._SEARCH_KEYWORDS."\"
                                            onblur=\"if(this.value=='')this.value='"
    ._SEARCH_KEYWORDS."';\"
                                            onfocus=\"if(this.value=='"
    ._SEARCH_KEYWORDS."')this.value='';\" /> "
            ." <input type=\"submit\" value=\""._SEARCH."\" />"
            .'</div>'
            ."</form>";
        echo "[ ";
        if ($mainlink>0) {
            echo "<a  href=\"".$GLOBALS['modurl']."\">"._LINKSMAIN."</a> | ";
        }
        if (pnSecAuthAction(0, 'Web Links::Category', '::', ACCESS_COMMENT) || pnConfigGetVar('links_anonaddlinklock')) {
            echo "<a href=\"".$GLOBALS['modurl']."&amp;req=AddLink\">"._ADDLINK."</a> | ";
        }
        echo " <a href=\"".$GLOBALS['modurl']."&amp;req=NewLinks\">"._NEW."</a>"
            ." | <a href=\"".$GLOBALS['modurl']."&amp;req=MostPopular\">"._POPULAR."</a>"
            ." | <a href=\"".$GLOBALS['modurl']."&amp;req=TopRated\">"._TOPRATED."</a>"
            ." | <a href=\"".$GLOBALS['modurl']."&amp;req=RandomLink\">"._RANDOM."</a> ]"
            .'</div>';
        CloseTable();
    }
    }

    ?>


    --
    John Ross

    Spain and Portugal for Visitors

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula