1
martyras
News-block module
  • 2004/12/6 21:39

  • martyras

  • Just popping in

  • Posts: 37

  • Since: 2004/11/1


Hi all.

I have used the News-block module (xoops2_block_news-block_1.zip available here at xoops.org). Everything goes as expected with one exception. It seems that this module doesn't look if a news post is expired or has set to be shown at a specific date and it shows them too. Anyone has a fix for that?

Tha code of the module it this:

<?php
// ######################################################################
// # News-block:                                                        #
// # v1  10/02/2004  FOR XOOPS v2                                       #
// # Ported by: Sylvain B. (sylvain@123rando.com)                       #
// # http://123rando.com                                                #
// #                                                                    #
// ######################################################################
// # PHP-Nuke                                                           #
// #====================================================================#
// # Copyright (c) 2003 - Francisco Burzi                               #
// # http://phpnuke.org/                                                #
// #====================================================================#
// # Paladin's block-Articles_Info for PHP-Nuke 6.5                     #
// #====================================================================#
// # Copyright (c) 2003 - Darren Poulton (paladin@intaleather.com.au)   #
// # http://paladin.intaleather.com.au/                                 #
// #====================================================================#
// # Use of this program is goverened by the terms of the GNU General   #
// # Public License (GPL - version 1 or 2) as published by the          #
// # Free Software Foundation (http://www.gnu.org/)                     #
// ######################################################################

function block_articles_info ($options) {

global 
$xoopsDB$xoopsUser;

        
$block = array();
        
$block['title'] = _MB_ARTICLE_INF;

        
$block['content'] = "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=1 WIDTH=100%><TR><TD WIDTH=100% ALIGN=right VALIGN=TOP CLASS="odd">";
        
$block['content'] .= "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>";
        
$block['content'] .= "<TR><TD WIDTH=100% ALIGN=left CLASS="itemHead"><TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>";
        
$block['content'] .= "<tr><th ALIGN=left WIDTH=10%><B>"._MB_LDCAT."</B></th>";
        
$block['content'] .= "<th ALIGN=left WIDTH=80%><B>"._MB_LDTITLE."</B></th><th align=left WIDTH=5%><B>"._MB_LDCOUNTER."</B></th>";
        
//$block['content'] .= "<th align=left WIDTH=5%><B>"._MB_LDCOMTOTAL."</B></th>";
        
        
        
$limit $options[0];
        
$color $bgcolor3;
        
$sql "SELECT t.topic_title, s.storyid, s.topicid, s.title, s.comments, s.counter
                        FROM "
.$xoopsDB->prefix("stories")." s, ".$xoopsDB->prefix("topics")." t
                        WHERE s.topicid=t.topic_id  
                        ORDER BY s.storyid DESC LIMIT 
$limit";
        
$result $xoopsDB->query($sql);
        while (list(
$cat$sid$topicid$title$comtotal$counter) = $xoopsDB->fetchRow($result)) {
        
$block['content'] .= "<tr><td ALIGN=left WIDTH="80" CLASS="odd"><A HREF="".XOOPS_URL."/modules/news/index.php?storytopic=$topicid"><I>$cat</I></A>";
        
$block['content'] .= "</TD><TD CLASS="odd"><a href="".XOOPS_URL."/modules/news/article.php?storyid=$sid">$title</a></td>";
        
$block['content'] .= "<td align=right width ="5" CLASS="odd">$counter</td>";
        
//$block['content'] .= "<td align=right width ="5" CLASS="odd">$comtotal</td></tr>";
        
}
        
        
$block['content'] .= "</TABLE></TD></TR></TABLE>";
        
//$block['content'] .= "<CENTER>|[ <A HREF="".XOOPS_URL."/modules/news/index.php">"._MB_MORELINK."</A> ]";
        //if ($options[1] == 1) {
        //$block['content'] .= "|[ <A HREF="".XOOPS_URL."/modules/news/index.php">"._MB_TOPICLINK."</A> ]"; 
        //}
        //if ($options[2] == 1) { 
        //$block['content'] .= "|[ <A HREF="".XOOPS_URL."/modules/news/archive.php">"._MB_ARCHIVELINK."</A> ]";
        //}
        //if ($options[3] == 1) {
        //        if (empty($xoopsUser))
        //        {
        //            $block['content'] .= "";
        //        } else {
        //                $block['content'] .= "|[ <A HREF="".XOOPS_URL."/modules/news/submit.php">"._MB_SUBMITLINK."</A> ]";
        //        }
        //}
        //$block['content'] .= "|</CENTER></TD></TR></TABLE>";
        
$block['content'] .= "</TD></TR></TABLE>";
        return 
$block;
}



function 
b_articles_info_edit($options) {
        
$tabletag1='<tr><td>';
        
$tabletag2='</td><td>';

        
$form "<table border='0'>";
        
$form .= $tabletag1._MB_ARTICLE_DISPLAY.$tabletag2;
        
$form .= "<input type='text' name='options[]' value='".$options[0]."' size='4'>&nbsp;"._MB_ARTICLES."</td></tr>";
        
$form .= $tabletag1._MB_TOPICLINK.$tabletag2;
        
$form .= mk_chkbox($options,1);
        
$form .= $tabletag1._MB_ARCHIVELINK.$tabletag2;
        
$form .= mk_chkbox($options,2);
        
$form .= $tabletag1._MB_SUBMITLINK.$tabletag2;
        
$form .= mk_chkbox($options,3);
        
$form .= "</table>";
        return 
$form;
}

function 
mk_chkbox($options$number) {
    
$chk   "";
    if (
$options[$number] == 0) {
        
$chk " checked='checked'";
    }
    
$chkbox"<input type='radio' name='options[$number]' value='0'".$chk." />&nbsp;"._NO."&nbsp;&nbsp;";
    
$chk   "";
    if (
$options[$number] == 1) {
        
$chk " checked='checked'";
    }
    
$chkbox .= "<input type='radio' name='options[$number]' value='1'".$chk." />&nbsp;"._YES."</td></tr>";
    RETURN 
$chkbox;
}
?>

2
martyras
Re: News-block module
  • 2004/12/7 16:23

  • martyras

  • Just popping in

  • Posts: 37

  • Since: 2004/11/1


Hmm, maybe i was too drunk that night...

Anyway found it.

Just change this:
$sql "SELECT t.topic_title, s.storyid, s.topicid, s.title, s.comments, s.counter
                        FROM "
.$xoopsDB->prefix("stories")." s, ".$xoopsDB->prefix("topics")." t
                        WHERE s.topicid=t.topic_id  
                        ORDER BY s.storyid DESC LIMIT 
$limit";


Into this:
$sql "SELECT t.topic_title, s.storyid, s.topicid, s.title, s.comments, s.counter, s.published, s.expired
                        FROM "
.$xoopsDB->prefix("stories")." s, ".$xoopsDB->prefix("topics")." t
                        WHERE s.topicid=t.topic_id AND s.published < "
.time()." AND s.published > 0 AND (s.expired = 0 OR s.expired > ".time().")  
                        ORDER BY s.storyid DESC LIMIT 
$limit";


Happy xooping!

Login

Who's Online

145 user(s) are online (78 user(s) are browsing Support Forums)


Members: 0


Guests: 145


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits