51ff3226 |
1 | <?php |
2 | function smarty_function_get_moods($params,&$smarty) { |
3 | global $db; |
4 | error_reporting(1); |
5 | $user_id = $params['user_id']; |
6 | $set = $db->query(sprintf('select moods from users where user_id = %d', $user_id)); |
7 | $set->next(); |
8 | $moods_db = $set->getString('moods'); |
9 | $moods_expl = explode(";",$moods_db); |
10 | |
11 | // moodlist [array] |
12 | for ($i = 0;$i < count($moods_expl)-1;$i++) { |
13 | $set = $db->query(sprintf('select node_id,node_name from nodes where node_id = %d', $moods_expl[$i])); |
14 | $set->next(); |
15 | $moods[$i]['node_id'] = $set->getString('node_id'); |
16 | $moods_str[$i] = $set->getString('node_id'); |
17 | $moods[$i]['node_name'] = $set->getString('node_name'); |
18 | } |
19 | |
20 | // moodlist [string] |
21 | $moods_string = implode(";",$moods_str); |
22 | |
23 | // momentalne nastaveny mood |
24 | if (is_numeric($moods_expl[count($moods_expl)-1])) { |
25 | $set = $db->query(sprintf('select node_id, node_name, node_content from nodes where node_id = %d', $moods_expl[count($moods_expl)-1])); |
26 | $set->next(); |
27 | $mood['node_id'] = $set->getString('node_id'); |
28 | $mood['node_name'] = strip_tags($set->getString('node_name')); |
29 | $mood['node_content'] = addslashes(substr(strip_tags($set->getString('node_content')),0,223)); |
30 | } |
31 | else { |
32 | $mood['node_id'] = ''; |
33 | $mood['node_name'] = ''; |
34 | $mood['node_content'] = ''; |
35 | } |
36 | |
37 | $smarty->assign('get_moods',$moods); |
38 | $smarty->assign('get_moods_string',$moods_string); |
39 | $smarty->assign('get_moods_mood',$mood); |
40 | } |
41 | ?> |