Fixed mail: column mail_name does not exists in sql
authorniekt0 <niekt0@kyberia.cz>
Sun, 24 Oct 2010 20:35:38 +0000 (22:35 +0200)
committerniekt0 <niekt0@kyberia.cz>
Sun, 24 Oct 2010 20:35:38 +0000 (22:35 +0200)
wwwroot/inc/ubik.inc
wwwroot/nodes.php

index edb1b4c06e4c8eda07b47b89d7397f1464818ebb..0b896bbbd576f0e092b17a28ee1d05ad58d14895 100644 (file)
@@ -30,12 +30,13 @@ class ubik {
                else return false;
                if (!empty($params['mail_text'])) $mail_text=addslashes($params['mail_text']);
                else return false;
-               $q="insert into mail set mail_from='".UBIK_ID."',mail_to='$mail_to',mail_user='$mail_to',mail_timestamp=NOW(),mail_text='$mail_text'";
-               $db->query($q);
-               $db->query("update users set
-user_mail_name='ubik',user_mail_id=".UBIK_ID.",user_mail=user_mail+1 where
-user_id='$mail_to'");
 
+
+       $q_i = sprintf('insert into mail set mail_user = %2$d, mail_from = %1$d, mail_to = %2$d, mail_timestamp = NOW(), mail_text = "%3$s"'
+               ,UBIK_ID, $mail_to, $mail_text);
+       $db->update($q_i);
+       $q_u = sprintf('update users set user_mail = user_mail + 1, user_mail_id = %1$d where user_id = %2$d', UBIK_ID, $mail_to);
+       $db->update($q_u);
        }
 }
 
index 3757485ad36f744e148939a62d4afcbfc4fd65d3..427603f538c00a0e49b2fdb3653709f35e01f2ec 100644 (file)
@@ -343,17 +343,32 @@ if ($user_id=$_SESSION['user_id']) {
        $smarty->assign('bookstyl',$_SESSION['bookstyl']);
        $smarty->assign('fook',$_SESSION['fook']);
        $smarty->assign('user_id',$_SESSION['user_id']);
-       if (!empty($_SESSION['cube_vector'])) $smarty->assign('cube_vector',$_SESSION['cube_vector']);
+       if (!empty($_SESSION['cube_vector'])) 
+               $smarty->assign('cube_vector',$_SESSION['cube_vector']);
         $smarty->assign('friends',$_SESSION['friends']); //req by freezy, done by darkaural
        $smarty->assign('user_quota',$_SESSION['user_quota']);
-       $newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'");
+
+       $newmail_q = sprintf('select u.user_mail_id
+                               , u.user_k
+                               , u.k_wallet
+                               , u.user_mail
+                               , ms.user_id as mail_sender_id
+                               , ms.login as mail_sender
+                               from users u
+                               left join users ms on ms.user_id = u.user_mail_id
+                               where u.user_id = %d',
+                               $user_id);
+       $newmailset = $db->query($newmail_q);
+
+#      $newmailset=$db->query("select user_mail,user_mail_name,user_k,k_wallet from users where user_id='$user_id'");
+
        $newmailset->next();
        $new_mail=$newmailset->getString('user_mail');
        $newmailset2 = $db->query("select users.user_mail_id,mailsender.login
  from users left join users as mailsender on users.user_mail_id = mailsender.user_id where users.user_id = '$user_id'");
        $newmailset2->next();
        $smarty->assign('new_mail',$new_mail);
-       $smarty->assign('new_mail_name',$newmailset->getString('user_mail_name'));
+       $smarty->assign('new_mail_name',$newmailset->getString('mail_sender'));
        $smarty->assign('new_mail_name2',$newmailset2->getString('login'));
        $user_k=$newmailset->getString('user_k');
        $smarty->assign('user_k',$user_k);
This page took 0.117537 seconds and 4 git commands to generate.