<?php

/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     modifier
 * Name:     xoops_user_avatarize
 * Purpose:  Return avatar url by $uid.
 * Input:    uid: user id
 * -------------------------------------------------------------
 */
function smarty_modifier_xoops_user_avatarize($uid, $key)
{
	$handler=&xoops_gethandler('user');
	$user=&$handler->get(intval($uid));
	if(is_object($user)&&$user->isActive()) {
		if(file_exists(XOOPS_UPLOAD_PATH."/".$user->getVar('avatar'))) {
			return XOOPS_UPLOAD_URL."/".$user->getVar('avatar');
		}
	}

	return XOOPS_UPLOAD_URL."/blank.gif";
}

?>
