1: <?php
2: /*
3: * You may not change or alter any portion of this comment or credits
4: * of supporting developers from this source code or any supporting source code
5: * which is considered copyrighted (c) material of the original comment or credit authors.
6: *
7: * This program is distributed in the hope that it will be useful,
8: * but WITHOUT ANY WARRANTY; without even the implied warranty of
9: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: /**
13: * @copyright XOOPS Project https://xoops.org/
14: * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15: * @package
16: * @since
17: * @author XOOPS Development Team
18: */
19:
20: /*
21: * Smarty plugin
22: * -------------------------------------------------------------
23: * Type: function
24: * Name: xoMemberInfo
25: * Version: 1.0
26: * Author: DuGris
27: * Purpose: Get member information
28: * Input: infos = list of vars in XoopsUser to be fetched delimited by a '|'
29: * if infos is not specified the default will be:
30: * 'uname|name|email|user_avatar|url|user_icq|user_aim|user_yim|user_msnm|posts|user_from|user_occ|user_intrest|bio|user_sig'
31: *
32: * assign = smarty variable to be initialized for the templates
33: *
34: * Examples:
35: * Get all fields
36: * <{xoMemberInfo assign=member_info}>
37: *
38: * Get uname, avatar and email
39: * <{xoMemberInfo assign=memberInfo infos="uname|email|avatar"}>
40: * Hello <{$memberInfo.uname}>.
41: * -------------------------------------------------------------
42: */
43:
44: /**
45: * @param string[] $params
46: * @param Smarty $smarty
47: *
48: * @return void
49: */
50: function smarty_function_xoMemberInfo($params, $smarty)
51: {
52: global $xoopsUser, $xoopsConfig;
53:
54: $member_info = array();
55: if (!isset($xoopsUser) || !is_object($xoopsUser)) {
56: $member_info['uname'] = $xoopsConfig['anonymous'];
57: } else {
58: if (@empty($params['infos'])) {
59: $params['infos'] = 'uname|name|email|user_avatar|url|user_icq|user_aim|user_yim|user_msnm|posts|user_from|user_occ|user_intrest|bio|user_sig';
60: }
61: $infos = explode('|', $params['infos']);
62:
63: foreach ($infos as $info) {
64: $value = $xoopsUser->getVar($info, 'E');
65: if (null !== $value) {
66: $member_info[$info] = $value;
67: }
68: }
69: }
70: if (!@empty($params['assign'])) {
71: $smarty->assign($params['assign'], $member_info);
72: }
73: }
74: