1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8//this script may only be included - so its better to die if called directly. 9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) { 10 header("location: index.php"); 11 exit; 12} 13 14/* 15 * Smarty plugin 16 * ------------------------------------------------------------- 17 * Type: modifier 18 * Name: avatarize 19 * Purpose: show avatar for a given user name 20 * ------------------------------------------------------------- 21 */ 22function smarty_modifier_avatarize($user, $float = '', $default = '', $show_tag = 'y') 23{ 24 if (! $user) { 25 return ''; 26 } 27 28 $avatar = TikiLib::lib('tiki')->get_user_avatar($user, $float); 29 30 if (! $avatar && $default) { 31 $smarty = TikiLib::lib('smarty'); 32 $smarty->loadPlugin('smarty_function_icon'); 33 $name = TikiLib::lib('user')->clean_user($user); 34 $avatar = smarty_function_icon(['_id' => $default, 'title' => $name], $smarty->getEmptyInternalTemplate()); 35 } 36 37 if ($avatar != '' && $show_tag == 'y') { 38 $avatar = TikiLib::lib('user')->build_userinfo_tag($user, $avatar); 39 } 40 return $avatar; 41} 42