Strict but sane Error reporting system
[mirrors/Kyberia-bloodline.git] / wwwroot / inc / smarty / node_methodz / function.get_moods.php
1 <?php
2 function smarty_function_get_moods($params,&$smarty) {
3 global $db;
4 $user_id = $params['user_id'];
5 $set = $db->query(sprintf('select moods from users where user_id = %d', $user_id));
6 $set->next();
7 $moods_db = $set->getString('moods');
8 $moods_expl = explode(";",$moods_db);
9
10 // moodlist [array]
11 for ($i = 0;$i < count($moods_expl)-1;$i++) {
12 $set = $db->query(sprintf('select node_id,node_name from nodes where node_id = %d', $moods_expl[$i]));
13 $set->next();
14 $moods[$i]['node_id'] = $set->getString('node_id');
15 $moods_str[$i] = $set->getString('node_id');
16 $moods[$i]['node_name'] = $set->getString('node_name');
17 }
18
19 // moodlist [string]
20 $moods_string = implode(";",$moods_str);
21
22 // momentalne nastaveny mood
23 if (is_numeric($moods_expl[count($moods_expl)-1])) {
24 $set = $db->query(sprintf('select node_id, node_name, node_content from nodes where node_id = %d', $moods_expl[count($moods_expl)-1]));
25 $set->next();
26 $mood['node_id'] = $set->getString('node_id');
27 $mood['node_name'] = strip_tags($set->getString('node_name'));
28 $mood['node_content'] = addslashes(substr(strip_tags($set->getString('node_content')),0,223));
29 }
30 else {
31 $mood['node_id'] = '';
32 $mood['node_name'] = '';
33 $mood['node_content'] = '';
34 }
35
36 $smarty->assign('get_moods',$moods);
37 $smarty->assign('get_moods_string',$moods_string);
38 $smarty->assign('get_moods_mood',$mood);
39 }
40 ?>
This page took 0.290125 seconds and 4 git commands to generate.