<?php
if (!defined('IN_CONTEXT')) die('access violation error!');

class ModBulletin extends Module {
    protected $_filters = array(
        'check_login' => '{recentbulletins}'
    );

    public function recentbulletins() {
        /*$list_size = trim(ParamHolder::get('bulletin_reclst_size'));
        if (!is_numeric($list_size) || strlen($list_size) == 0) {
            $list_size = '5';
        }*/
        $curr_locale = trim(SessionHolder::get('_LOCALE'));
        $bulletin_type = trim(ParamHolder::get('bulletin_type', '0'));
        
        $o_bulletin = new Bulletin();
        $user_role = trim(SessionHolder::get('user/s_role', '{guest}'));
        if ($user_role == '{admin}') {
        	$bulletins = $o_bulletin->findAll("published='1' AND s_locale=? ", array($curr_locale),
                            "ORDER BY `create_time` DESC");
        } else {
            $bulletins = $o_bulletin->findAll("published='1' AND s_locale=? AND for_roles LIKE ? ", array($curr_locale,'%'.$user_role.'%'),
                        "ORDER BY `create_time` DESC");
        }

        $this->assign('bulletin', $bulletins[0]);
        $this->assign('bulletin_type', $bulletin_type);
        $this->assign("randstr", ToolKit::randomStr());
    }

}
?>
