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 http://xoops.org/
14: * @license GNU GPL 2 or later (http://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 informations
28: * Input: infos = informations to be recovered in the profile of the member
29: * if empty uname,name,email,user_avatar,url,user_icq,user_aim,user_yim,user_msnm,user_from,
30: * user_occ, user_intrest, bio, user_sig will be recovered
31: *
32: * assign = variable to be initialized for the templates
33: *
34: * I.e: Get all informations
35: * <{xoMemberInfo assign=member_info}>
36: *
37: * I.e: Get uname, avatar and email
38: * <{xoMemberInfo assign=member_info infos="uname|email|avatar"}>
39: * -------------------------------------------------------------
40: */
41:
42: /**
43: * @param $params
44: * @param $smarty
45: */
46: function smarty_function_xoMemberInfo($params, &$smarty)
47: {
48: global $xoopsUser, $xoopsConfig;
49:
50: $time = time();
51: $member_info = $_SESSION['xoops_member_info'];
52: if (!isset($xoopsUser) || !is_object($xoopsUser)) {
53: $member_info['uname'] = $xoopsConfig['anonymous'];
54: } else {
55: if (@empty($params['infos'])) {
56: $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';
57: }
58: $infos = explode('|', $params['infos']);
59:
60: if (!is_array($member_info)) {
61: $member_info = array();
62: }
63: foreach ($infos as $info) {
64: if (!array_key_exists($info, $member_info) && @$_SESSION['xoops_member_info'][$info . '_expire'] < $time) {
65: $member_info[$info] = $xoopsUser->getVar($info, 'E');
66: $_SESSION['xoops_member_info'][$info] = $member_info[$info];
67: $_SESSION['xoops_member_info'][$info . '_expire'] = $time + 60;
68: }
69: }
70: }
71: if (!@empty($params['assign'])) {
72: $smarty->assign($params['assign'], $member_info);
73: }
74: }
75: