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

class ModDownloadCategory extends Module {
    protected $_filters = array(
        'check_login' => '{dclist}'
    );
    
    public function dclist() {
        $curr_locale = trim(SessionHolder::get('_LOCALE'));
        $user_role = trim(SessionHolder::get('user/s_role', '{guest}'));
        
        $o_dc = new DownloadCategory();
        if ($user_role == '{admin}') {
	        $dcs = $o_dc->findAll("published='1' AND s_locale=?", 
	        				array($curr_locale), 
	                        "ORDER BY `id` DESC");
        } else {
	        $dcs = $o_dc->findAll("published='1' AND for_roles LIKE ? AND s_locale=?", 
	        				array('%'.$user_role.'%', $curr_locale), 
	                        "ORDER BY `id` DESC");
        }
        $this->assign('dcs', $dcs);
    }
}
?>