zikula-modules / FAQ

Frequently Asked Questions
http://code.zikula.org/faq
8 stars 1 forks source link

Waiting FAQs block #1

Open hvorragend opened 13 years ago

hvorragend commented 13 years ago

It would be grate to have a block where an admin can see if there are waiting FAQs. I have create my own. Here the source, if you want

<a href="<!--[pnmodurl modname=FAQ type=admin func=view ]-->">
<strong><!--[$count]--></strong> <!--[gt text="waiting FAQs"]-->
</a>
<?php
/**
 * initialise block
 *
 */
function FAQ_Waitingblock_init()
{

}

/**
 * get information on block
 *
 * @return       array       The block information
 */
function FAQ_Waitingblock_info()
{
    // block informations
    return array('module'         => 'FAQ',
                 'text_type'      => 'FAQ Waiting',
                 'text_type_long' => 'Shows the amount of waiting FAQs',
                 'allow_multiple' => false,
                 'form_content'   => false,
                 'form_refresh'   => false,
                 'show_preview'   => false,
                 'admin_tableless' => true);
}

/**
 * display block
 *
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the rendered bock
 */
function FAQ_Waitingblock_display($blockinfo)
{
    if (!pnModAvailable('FAQ')) {
        return false;
    }
    if (!SecurityUtil::checkPermission( 'FAQ::', '::', ACCESS_EDIT)) {
        return false;
    }    

    pnModLoad("FAQ");

    $where = " WHERE pn_answer = ''";
    $count = DBUtil::selectObjectCount('faqanswer',$where);

    if ($count == 0) {
        return false;
    }

    $pnRender = pnRender::getInstance('FAQ',false);
    $pnRender->assign('count', $count);

    $blockinfo['content'] = $pnRender->fetch('faq_block_waiting.htm');
    return pnBlockThemeBlock($blockinfo);

}