Kyberia v2.3 - 1st revision from SVN (Without patches of kyberia.sk team)
[mirrors/Kyberia-bloodline.git] / inc / smarty / node_methodz / function.get_mail.php
index d90dba0528125d98acfc10d4a2f85c0b7e744423..005043bc9cbebe112c70f0e9ebfd509b250468cb 100644 (file)
@@ -1,24 +1,39 @@
 <?
-       function smarty_function_get_mail($params, &$smarty) {
-               global $db, $node;
-               $user_id=$_SESSION['user_id'];
-               if (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount'];
-                else $listing_amount=23;
-                if (is_numeric($params['offset'])) $offset=$params['offset'];
-                else $offset=0;
-
-                if (!empty($params['search'])) {
-                       if ($params['search_type']=='mail_text') $sql_type.=" and mail_text like '%".addslashes($params['search'])."%' ";
-                       else {
-                               $q2="select user_id from users where login='".addslashes($params['search'])."'";
-                               $userset=$db->query($q2);
-                               $userset->next();
-                               $id=$userset->getString('user_id');
-                               $sql_type=" and ".$params['search_type']."='$id'";
-                       }
+function smarty_function_get_mail($params, &$smarty) {
+       global $db, $node;
+
+       $user_id=$_SESSION['user_id'];
+
+       if (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount'];
+       else $listing_amount=23;
+
+/* zapnut, ked bezime len na jednej masine.. (br)
+                if ($listing_amount > 100)
+                        $listing_amount = 100;
+*/
+
+       if (is_numeric($params['offset'])) $offset=$params['offset'];
+       else $offset=0;
+
+       if (!empty($params['search'])) {
+               if ($params['search_type']=='mail_text') {
+                       $sql_type.=" and mail_text like '%".addslashes($params['search'])."%' ";
+               }
+               elseif ($params['search_type']=='mail_both') {
+                       $userset=$db->query("select user_id from users where login='".addslashes($params['search'])."'");
+                       $userset->next();
+                       $id=$userset->getString('user_id');
+                       $sql_type=" and (mail_to='$id' or mail_from='$id')";
                }
+               else {
+                       $userset=$db->query("select user_id from users where login='".addslashes($params['search'])."'");
+                       $userset->next();
+                       $id=$userset->getString('user_id');
+                       $sql_type=" and ".$params['search_type']."='$id'";
+               }
+       }
 
-               $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
+       $query = "select date_format(mail.mail_timestamp,\"%e.%c. %k:%i:%s\") as cas,
 userfrom.user_action as locationfrom_action,
 userfrom.user_action_id as locationfrom_action_id,
 userto.user_action as locationto_action,
@@ -27,17 +42,14 @@ userto.login as mail_to_name, userfrom.login as mail_from_name,
 mail.* from mail left join users as userfrom on
 mail_from=userfrom.user_id left join users as userto on mail_to=userto.user_id
 where mail_user='$user_id' ";
-               if ($sql_type) $query.=$sql_type;
-               $query.=" order by mail_id desc limit $offset,$listing_amount";
-
-               $set = $db->query($query);
+       if ($sql_type) $query.=$sql_type;
+       $query.=" order by mail_id desc limit $offset,$listing_amount";
 
-               while($set->next()) {
-                       $get_mail[] = $set->getRecord();
-               }
-
-               $smarty->assign('get_mail', $get_mail);
+       $set = $db->query($query);
 
+       while($set->next()) {
+               $get_mail[] = $set->getRecord();
        }
-
+       $smarty->assign('get_mail', $get_mail);
+}
 ?>
This page took 0.134898 seconds and 4 git commands to generate.