<?php

/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     function
 * Name:     get_greeting
 * Purpose:  get a greeting for given name/surname
 * -------------------------------------------------------------
 */
/**
 * @param array  $params
 * @param Smarty $smarty
 *
 * @return array
 */
function smarty_function_get_greeting($params, &$smarty)
{
    $name = null;
    $surname = null;
    $prioritize = 'name';

    extract($params);

    if (empty($name) && empty($surname)) {
        echo 'Chybí jméno/příjmení';
    }

    $ret = User::getGreeting($name, $surname, $prioritize);

    if (!empty($assign)) {
        $smarty->assign($assign, $ret);
    } else {
        return $ret;
    }
}
