Completed
Push — master ( 9edb5e...d40969 )
by Ankit
03:51
created
src/Reply.php 1 patch
Braces   +19 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,16 +27,20 @@  discard block
 block discarded – undo
27 27
 
28 28
     public function replyTo($msg)
29 29
     {
30
-        if(!empty($msg))  //checks for the value send
30
+        if(!empty($msg)) {
31
+            //checks for the value send
31 32
         {
32 33
             $userId = $msg->userId;
34
+        }
33 35
             $identifier = $msg->name;
34 36
             $receiverID = $identifier;  //stores id of the person whom message is to be sent
35 37
 
36
-            if($identifier > $userId)    // geneate specific unique code to store messages
38
+            if($identifier > $userId) {
39
+                // geneate specific unique code to store messages
37 40
                 $identifier = $userId . ":" . $identifier;
38
-            else
39
-                $identifier = $identifier . ":" . $userId;
41
+            } else {
42
+                            $identifier = $identifier . ":" . $userId;
43
+            }
40 44
 
41 45
             $reply = addslashes(trim($msg->reply[0])); // stores the message sent by the user.
42 46
 
@@ -50,27 +54,31 @@  discard block
 block discarded – undo
50 54
                 $query = "SELECT * from login where login_id = '$receiverID'";
51 55
 
52 56
                 $result = $this->connect->query($query);
53
-                if($result->num_rows > 0)     // if true
57
+                if($result->num_rows > 0) {
58
+                    // if true
54 59
                 {
55 60
                     //check whether he is sending message for thr first time or he has sent messages before
56 61
                     $query = "SELECT * from total_message where identifier = '$identifier'";
62
+                }
57 63
                     $result = $this->connect->query($query);
58
-                    if($result->num_rows>0)               // if he has sent messages before
64
+                    if($result->num_rows>0) {
65
+                        // if he has sent messages before
59 66
                     {
60 67
                         // Update Total_Message Table
61 68
                         $query = "UPDATE total_message SET total_messages = total_messages+1, time = '$time', unread = 1, id = '$time_id' WHERE identifier = '$identifier'";
69
+                    }
62 70
                         return $this->updateMessages($query, $identifier, $reply, $userId, $time);
63 71
 
64
-                    }
65
-                    else    // if he sends message for the first time
72
+                    } else    // if he sends message for the first time
66 73
                     {
67 74
                         $length = strlen($userId);
68
-                        if(substr($identifier, 0, $length) == $userId) // generate specific unique code
75
+                        if(substr($identifier, 0, $length) == $userId) {
76
+                            // generate specific unique code
69 77
                         {
70 78
                             $user2 = substr($identifier, $length+1);
71
-                            $user1 = $userId;
72 79
                         }
73
-                        else
80
+                            $user1 = $userId;
81
+                        } else
74 82
                         {
75 83
                             $user2 = $userId;
76 84
                             $length = strlen($identifier) - $length-1;
Please login to merge, or discard this patch.