1
irmtfan
article 1.0 final: try to create a plugin for waiting & whatsnew module
  • 2007/1/20 13:31

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


if you use the great waiting module for your submissions you really need this plugin.

just save codes as waiting.plugin.php and upload it to modules/article/include:
//
// Article ext waiting plugin
// plugin: irmtfan, http://jadoogaran.org
//

include dirname(__FILE__)."/vars.php";

function 
b_waiting_article()
{
    
$xoopsDB =& Database::getInstance();
    
$ret = array();

    
//     Article articles - submitted
    
$block = array();
    
$result $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix($GLOBALS["ART_DB_PREFIX"]."_article")." WHERE art_time_publish=0 AND art_time_submit!=0");
    if ( 
$result ) {
        
$block['adminlink'] = XOOPS_URL."/modules/".$GLOBALS["artdirname"]."/cp.article.php?type=submitted";
        list(
$block['pendingnum']) = $xoopsDB->fetchRow($result);
        
$block['lang_linkname'] = _PI_WAITING_WAITINGS;
    }
    
$ret[] = $block;

    
// Article articles - registered
    
$block = array();
    
$result $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix($GLOBALS["ART_DB_PREFIX"]."_article")." WHERE art_time_publish=0 AND art_time_submit=0");
    if ( 
$result ) {
        
$block['adminlink'] = XOOPS_URL."/modules/".$GLOBALS["artdirname"]."/cp.article.php?type=registered";
        list(
$block['pendingnum']) = $xoopsDB->fetchRow($result);
        
$block['lang_linkname'] = _PI_WAITING_SUBMITTED;
    }
    
$ret[] = $block;

    return 
$ret;

}
?>

it works well but im not sure about the way i do it.
is this show "submitted" and "registered" articles correctly?

where can i find some docs about differences between "submitted" , "registered" and "published" articles.

@ phppp
especially i need your advise.

2
irmtfan
Re: article 1.0 final: try to create a plugin for waiting & whatsnew module
  • 2007/1/21 9:21

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


also i write a very simple no cloneable and no permission sensitive plugin for whatsnew.

just create a file with the name "data.inc.php"
and upload it in modules/whatsnew/plugins/article:

// $Id: data.inc.php,v 1.4 2005/10/22 08:37:48 ohwada Exp $

// 2005-10-01 K.OHWADA
// category, counter

// 2005-06-20 K.OHWADA
// get and set image width, height

// 2005-06-06 K.OHWADA
// small change for plugin.

//================================================================
// What's New Module
// get aritciles from module
// for Article 1.0 final  (without permission)
// plugin by irmtfan  
//================================================================

include XOOPS_ROOT_PATH."/modules/article/include/vars.php";

function 
article_new($limit=0$offset=0)
{
    global 
$xoopsDB;

    
$myts =& MyTextSanitizer::getInstance();

    
$i 0;
    
$ret  = array();
    
$time time();

// check the showing property

    
$sql "SELECT a.art_id, a.uid, a.art_title as atitle, a.art_summary, t.dohtml, t.dosmiley, t.doxcode, t.doimage, t.dobr, a.art_time_create, a.art_time_submit, a.art_time_publish, a.art_counter, cat.cat_id as catid, cat.cat_title as cattitle FROM ".$xoopsDB->prefix($GLOBALS["ART_DB_PREFIX"]."_article")." a, ".$xoopsDB->prefix($GLOBALS["ART_DB_PREFIX"]."_text")." t, ".$xoopsDB->prefix($GLOBALS["ART_DB_PREFIX"]."_category")." cat WHERE a.art_id=t.art_id AND a.cat_id=cat.cat_id AND a.art_time_publish > 0 AND a.art_time_publish <= $time ORDER BY a.art_time_publish DESC";

    
$URL_MOD XOOPS_URL."/modules/".$GLOBALS["artdirname"];

    
$result $xoopsDB->query($sql$limit$offset);
    while( 
$row $xoopsDB->fetchArray($result) )
    {
           
$id $row['art_id'];
// link
        
$ret[$i]['link']     = $URL_MOD."/view.article.php/".$id;
        
$ret[$i]['pda']      = $URL_MOD."/transfer.php/".$id."/print";
           
$ret[$i]['cat_link'] = $URL_MOD."/view.category.php/".$row['catid'];

// title
        
$ret[$i]['title']    = $row['atitle'];
        
$ret[$i]['cat_name'] = $row['cattitle'];

// counter
           
$ret[$i]['hits'] = $row['art_counter'];

// atom
           
$ret[$i]['id']       = $id;
           
$ret[$i]['uid']      = $row['uid'];
           
$ret[$i]['time']     = $row['art_time_submit'];
        
$ret[$i]['issued']   = $row['art_time_publish'];
        
$ret[$i]['created']  = $row['art_time_create'];

        
$html   0;
        
$smiley 0;
        
$xcode 0;
        
$br     0;
        
$image  0;

        if ( 
$row['dohtml'] )    $html   1;
        if ( 
$row['dosmiley'] )    $smiley 1;
        if ( 
$row['dobr'] )        $br     1;
        if ( 
$row['doxcode'] )    $xcode    1;
        if ( 
$row['doimage'] )    $image    1;

        
$maintext $myts->displayTarea($row['art_summary'], $html$smiley$xcode$image$br);
        
$ret[$i]['description'] = $maintext;

        
$i++;
    }

    return 
$ret;
}

function 
article_num()
{
    global 
$xoopsDB;

    
$sql "SELECT count(*) FROM ".$xoopsDB->prefix($GLOBALS["ART_DB_PREFIX"]."_article")." ORDER BY art_id";
    
$array $xoopsDB->fetchRow$xoopsDB->query($sql) );
    
$num   $array[0];
    if (empty(
$num)) $num 0;

    return 
$num;
}

function 
article_data($limit=0$offset=0)
{
    global 
$xoopsDB;

    
$i 0;
    
$ret = array();

    
$sql "SELECT * FROM ".$xoopsDB->prefix($GLOBALS["ART_DB_PREFIX"]."_article")." ORDER BY art_id";
    
$result $xoopsDB->query($sql,$limit,$offset);

    while(
$myrow $xoopsDB->fetchArray($result))
    {
        
$id $myrow['art_id'];
        
$ret[$i]['id']    = $id;
        
$ret[$i]['link']  = XOOPS_URL."/modules/".$GLOBALS["artdirname"]."/view.article.php/".$id;
        
$ret[$i]['title'] = $myrow['art_title']." ".$myrow['art_summary'];
           
$ret[$i]['time']  = $myrow['art_time_publish'];
        
$i++;
    }

    return 
$ret;
}
?>

i repeat:
1- it use no permission for select articles.
2- it is just for "article" module dirname.

3
irmtfan
Re: article 1.0 final: try to create a plugin for waiting & whatsnew module
  • 2007/1/22 3:31

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


i tried to get it working for cloned "article" module but failed.
can i use $articledirname = basename( dirname( __FILE__ ) ) ;
?

4
irmtfan
Re: article 1.0 final: try to create a plugin for waiting & whatsnew module
  • 2007/1/23 7:04

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


anyone using waiting and/or whatsnew module interested?

Login

Who's Online

239 user(s) are online (100 user(s) are browsing Support Forums)


Members: 0


Guests: 239


more...

Donat-O-Meter

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

Latest GitHub Commits