<?php
/**
 * Smarty plugin
 *
 * @category Smarty
 * @license /_licenses/untermStrich/agb_normal.pdf
 * @author Christian Wengg
 * @copyright 2009 untermStrich
 * @package Smarty
 * @subpackage plugins
 * @version $Id$
*/

/**
 * Smarty security view function plugin
 *
 * Purpose:  Create the view for security fields
 *
 * @param   array   $params Parameters:
 *                  <ul>
 *                      <li>value   integer     The variable</li>
 *                  </ul>
 * @return  string  The field source
 */
function smarty_function_security(array $params)
{
    if (isset($params['value'])) {
        $value = intval($params['value']);
        $valid_types = array(0,1,2,3,99,100);
        if (in_array($value, $valid_types)) {
            $CI = CI_Controller::get_instance();
            $title = $CI->lang->line('rights_r'.$value);
            $msg = '<span class="dialog_make_btn14 right'.$value.'" title="'.$title.'"></span>';
            
            if (isset($params['add_title']) && $params['add_title']) { 
                return $msg.' '.$title;
            } else {
                return $msg;
            }
        } else {
            return '';
        }
    } else {
        return '';
    }
}

