Kyberia v2.0
[mirrors/Kyberia-bloodline.git] / inc / smarty / node_methodz / function.get_mail.php
1 <?
2 function smarty_function_get_mail($params, &$smarty) {
3 global $db, $node;
4 $user_id=$_SESSION['user_id'];
5 if (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount'];
6 else $listing_amount=23;
7 if (is_numeric($params['offset'])) $offset=$params['offset'];
8 else $offset=0;
9
10 if (!empty($params['search'])) {
11 if ($params['search_type']=='mail_text') $sql_type.=" and mail_text like '%".addslashes($params['search'])."%' ";
12 else {
13 $q2="select user_id from users where login='".addslashes($params['search'])."'";
14 $userset=$db->query($q2);
15 $userset->next();
16 $id=$userset->getString('user_id');
17 $sql_type=" and ".$params['search_type']."='$id'";
18 }
19 }
20
21 $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
22 userfrom.user_action as locationfrom_action,
23 userfrom.user_action_id as locationfrom_action_id,
24 userto.user_action as locationto_action,
25 userto.user_action_id as locationto_action_id,
26 userto.login as mail_to_name, userfrom.login as mail_from_name,
27 mail.* from mail left join users as userfrom on
28 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
29 where mail_user='$user_id' ";
30 if ($sql_type) $query.=$sql_type;
31 $query.=" order by mail_id desc limit $offset,$listing_amount";
32
33 $set = $db->query($query);
34
35 while($set->next()) {
36 $get_mail[] = $set->getRecord();
37 }
38
39 $smarty->assign('get_mail', $get_mail);
40
41 }
42
43 ?>
This page took 0.298072 seconds and 4 git commands to generate.