Skip to content

Commit

Permalink
Share reply to friend and show shared reply
Browse files Browse the repository at this point in the history
  • Loading branch information
FlazeFy committed Aug 17, 2022
1 parent 9ae56b8 commit bcf664a
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Learnzia/assets/uploads/
17 changes: 17 additions & 0 deletions Learnzia/application/controllers/homeCtrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ public function shareDisc(){
redirect('homeCtrl');
}

//Share reply
public function shareRep(){
$contact = $this->input->post('id_social[]');
for($i = 0; $i < count($contact); $i++){
$data = array(
'id_message' => 'NULL',
'id_social' => $contact[$i],
'id_user_sender' => $this->session->userdata('userIdTrack'),
'message' => $this->input->post('id_reply'),
'message_image' => 'reply',
'datetime' => date("Y/m/d h:i:sa")
);
$this->messageModel->insertMessage($data, 'message');
}
redirect('homeCtrl');
}

//Upvote a discussion
public function upvoteDis(){
$data = array(
Expand Down
194 changes: 190 additions & 4 deletions Learnzia/application/views/contact/chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if (($au['id_user'] == $c['id_user_2'])&&($c['id_user_2'] != $this->session->userdata('userIdTrack'))&&($c['id_user_1'] == $this->session->userdata('userIdTrack'))){
echo "
<div class='modal fade' id='message".$c['id_social']."' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>
<div class='modal-dialog' role='document' style='overflow-y: initial;'>
<div class='modal-dialog modal-lg' role='document' style='overflow-y: initial;'>
<form method='POST' action='homeCtrl/sendRMessage' enctype='multipart/form-data'>
<div class='modal-content' style='background-color:#313436;'>
<div class='modal-header'>
Expand All @@ -25,7 +25,7 @@
</div>
<div class='imessage' style='max-height: calc(80vh - 160px); max-width:auto; overflow-y: auto; height:800px; min-width:100%;'>";
foreach($dataMessage as $msg){
if($msg['message_image'] != 'discussion'){
if(($msg['message_image'] != 'discussion')&&($msg['message_image'] != 'reply')){
if(($msg['id_user_sender'] == $c['id_user_2'])&&($msg['id_social'] == $c['id_social'])){
echo "<p class='from-them'>";
if(($msg['message_image'] != 'null')&&($msg['message_image'] != 'discussion')){
Expand Down Expand Up @@ -150,6 +150,99 @@
}
}
}
} else if($msg['message_image'] == 'reply'){
$i = 0;
if(($msg['id_user_sender'] == $c['id_user_2'])&&($msg['id_social'] == $c['id_social'])){
foreach($dataReply as $rep){
foreach($allDisc as $dis){
if(($msg['message'] == $rep['id_reply'])&&($dis['id_discussion'] == $rep['id_discussion'])){
echo"
<div class='card p-2 my-3 border-0 rounded' style='background-color:#212121; border-top-right-radius: 35px;'>
<div class='card-header' id='headingOne'>
<img src='http://localhost/Learnzia/assets/uploads/user/user_".$rep['imageURL'].".jpg' alt='Card image cap' class='rounded-circle img-fluid mx-2' style='width:45px; float:left;'>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#'><i class='fa-solid fa-ellipsis-vertical'></i></a>";
//Reply header.
if($rep['id_user'] == $this->session->userdata('userIdTrack')){
echo"
<h5 style='font-size:18px;'>You <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
} else {
echo"
<h5 style='font-size:18px;'>".$rep['username']." <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
}
echo "
<h5 id='question_cat'>".$dis['category']."</h5>";
//reply with image.
if ($rep['reply_image'] != 'null'){
echo"
<div class='row mb-3'>
<div class='col-md-4'>
<img src='http://localhost/Learnzia/assets/uploads/reply_".$rep['reply_image'].".jpg' id='question_img'
data-toggle='modal' data-target='#zoom".$rep['id_reply']."'>
<div id='question_alt'><i class='fa-solid fa-magnifying-glass'></i> Zoom Image</div>
</div>
<div class='col-md-6' style=''>
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>
</div>
</div>";
} else {
echo"
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>";
}
echo "
<p style='font-size:14px; color:whitesmoke; font-style:italic; margin-top:-10px;'>Replies from <a style='color:#F1C40F; font-weight:500; text-decoration:underline; cursor:pointer;'>".$dis['question']."</a></p>
<a class='btn btn-primary mx-2 border-0 rounded-pill' id='btn-up' title='up'><i class='fa-solid fa-arrow-up fa-lg'></i> 10</a>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#shareDisc".$rep['id_reply']."' title='forward'><i class='fa-solid fa-paper-plane'></i></a>
</div>
</div>";
}
}
}
} else if(($msg['id_user_sender'] == $this->session->userdata("userIdTrack"))&&($msg['id_social'] == $c['id_social'])){
foreach($dataReply as $rep){
foreach($allDisc as $dis){
if(($msg['message'] == $rep['id_reply'])&&($dis['id_discussion'] == $rep['id_discussion'])){
echo"
<div class='card p-2 my-3 border-0 rounded' style='background-color:#212121; border-top-right-radius: 35px;'>
<div class='card-header' id='headingOne'>
<img src='http://localhost/Learnzia/assets/uploads/user/user_".$rep['imageURL'].".jpg' alt='Card image cap' class='rounded-circle img-fluid mx-2' style='width:45px; float:left;'>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#'><i class='fa-solid fa-ellipsis-vertical'></i></a>";
//Reply header.
if($rep['id_user'] == $this->session->userdata('userIdTrack')){
echo"
<h5 style='font-size:18px;'>You <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
} else {
echo"
<h5 style='font-size:18px;'>".$rep['username']." <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
}
echo "
<h5 id='question_cat'>".$dis['category']."</h5>";
//reply with image.
if ($rep['reply_image'] != 'null'){
echo"
<div class='row mb-3'>
<div class='col-md-4'>
<img src='http://localhost/Learnzia/assets/uploads/reply_".$rep['reply_image'].".jpg' id='question_img'
data-toggle='modal' data-target='#zoom".$rep['id_reply']."'>
<div id='question_alt'><i class='fa-solid fa-magnifying-glass'></i> Zoom Image</div>
</div>
<div class='col-md-6' style=''>
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>
</div>
</div>";
} else {
echo"
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>";
}
echo "
<p style='font-size:14px; color:whitesmoke; font-style:italic; margin-top:-10px;'>Replies from <a style='color:#F1C40F; font-weight:500; text-decoration:underline; cursor:pointer;'>".$dis['question']."</a></p>
<a class='btn btn-primary mx-2 border-0 rounded-pill' id='btn-up' title='up'><i class='fa-solid fa-arrow-up fa-lg'></i> 10</a>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#shareDisc".$rep['id_reply']."' title='forward'><i class='fa-solid fa-paper-plane'></i></a>
</div>
</div>";
}
}
}
}
}
}
if ($count == 0){
Expand Down Expand Up @@ -191,7 +284,7 @@
} else if (($au['id_user'] == $c['id_user_1'])&&($c['id_user_1'] != $this->session->userdata('userIdTrack'))&&($c['id_user_2'] == $this->session->userdata('userIdTrack'))){
echo "
<div class='modal fade' id='message".$c['id_social']."' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>
<div class='modal-dialog' role='document' style='overflow-y: initial;'>
<div class='modal-dialog modal-lg' role='document' style='overflow-y: initial;'>
<form method='POST' action='homeCtrl/sendRMessage' enctype='multipart/form-data'>
<div class='modal-content' style='background-color:#313436;'>
<div class='modal-header'>
Expand All @@ -211,7 +304,7 @@
</div>
<div class='imessage' style='max-height: calc(80vh - 160px); max-width:auto; overflow-y: auto; height:800px; min-width:100%;'>";
foreach($dataMessage as $msg){
if($msg['message_image'] != 'discussion'){
if(($msg['message_image'] != 'discussion')&&($msg['message_image'] != 'reply')){
if(($msg['id_user_sender'] == $c['id_user_1'])&&($msg['id_social'] == $c['id_social'])){
echo "<p class='from-them'>";
if(($msg['message_image'] != 'null')&&($msg['message_image'] != 'discussion')){
Expand Down Expand Up @@ -336,6 +429,99 @@
}
}
}
} else if($msg['message_image'] == 'reply'){
$i = 0;
if(($msg['id_user_sender'] == $c['id_user_2'])&&($msg['id_social'] == $c['id_social'])){
foreach($dataReply as $rep){
foreach($allDisc as $dis){
if(($msg['message'] == $rep['id_reply'])&&($dis['id_discussion'] == $rep['id_discussion'])){
echo"
<div class='card p-2 my-3 border-0 rounded' style='background-color:#212121; border-top-right-radius: 35px;'>
<div class='card-header' id='headingOne'>
<img src='http://localhost/Learnzia/assets/uploads/user/user_".$rep['imageURL'].".jpg' alt='Card image cap' class='rounded-circle img-fluid mx-2' style='width:45px; float:left;'>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#'><i class='fa-solid fa-ellipsis-vertical'></i></a>";
//Reply header.
if($rep['id_user'] == $this->session->userdata('userIdTrack')){
echo"
<h5 style='font-size:18px;'>You <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
} else {
echo"
<h5 style='font-size:18px;'>".$rep['username']." <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
}
echo "
<h5 id='question_cat'>".$dis['category']."</h5>";
//reply with image.
if ($rep['reply_image'] != 'null'){
echo"
<div class='row mb-3'>
<div class='col-md-4'>
<img src='http://localhost/Learnzia/assets/uploads/reply_".$rep['reply_image'].".jpg' id='question_img'
data-toggle='modal' data-target='#zoom".$rep['id_reply']."'>
<div id='question_alt'><i class='fa-solid fa-magnifying-glass'></i> Zoom Image</div>
</div>
<div class='col-md-6' style=''>
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>
</div>
</div>";
} else {
echo"
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>";
}
echo "
<p style='font-size:14px; color:whitesmoke; font-style:italic; margin-top:-10px;'>Replies from <a style='color:#F1C40F; font-weight:500; text-decoration:underline; cursor:pointer;'>".$dis['question']."</a></p>
<a class='btn btn-primary mx-2 border-0 rounded-pill' id='btn-up' title='up'><i class='fa-solid fa-arrow-up fa-lg'></i> 10</a>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#shareDisc".$rep['id_reply']."' title='forward'><i class='fa-solid fa-paper-plane'></i></a>
</div>
</div>";
}
}
}
} else if(($msg['id_user_sender'] == $this->session->userdata("userIdTrack"))&&($msg['id_social'] == $c['id_social'])){
foreach($dataReply as $rep){
foreach($allDisc as $dis){
if(($msg['message'] == $rep['id_reply'])&&($dis['id_discussion'] == $rep['id_discussion'])){
echo"
<div class='card p-2 my-3 border-0 rounded' style='background-color:#212121; border-top-right-radius: 35px;'>
<div class='card-header' id='headingOne'>
<img src='http://localhost/Learnzia/assets/uploads/user/user_".$rep['imageURL'].".jpg' alt='Card image cap' class='rounded-circle img-fluid mx-2' style='width:45px; float:left;'>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#'><i class='fa-solid fa-ellipsis-vertical'></i></a>";
//Reply header.
if($rep['id_user'] == $this->session->userdata('userIdTrack')){
echo"
<h5 style='font-size:18px;'>You <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
} else {
echo"
<h5 style='font-size:18px;'>".$rep['username']." <span style='font-size:10px; padding-top:5px; font-style:italic; color:whitesmoke;'>".$rep['datetime']."</span></h5>";
}
echo "
<h5 id='question_cat'>".$dis['category']."</h5>";
//reply with image.
if ($rep['reply_image'] != 'null'){
echo"
<div class='row mb-3'>
<div class='col-md-4'>
<img src='http://localhost/Learnzia/assets/uploads/reply_".$rep['reply_image'].".jpg' id='question_img'
data-toggle='modal' data-target='#zoom".$rep['id_reply']."'>
<div id='question_alt'><i class='fa-solid fa-magnifying-glass'></i> Zoom Image</div>
</div>
<div class='col-md-6' style=''>
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>
</div>
</div>";
} else {
echo"
<p style='font-size:14px; color:whitesmoke;'>".$rep['replytext']."</p>";
}
echo "
<p style='font-size:14px; color:whitesmoke; font-style:italic; margin-top:-10px;'>Replies from <a style='color:#F1C40F; font-weight:500; text-decoration:underline; cursor:pointer;'>".$dis['question']."</a></p>
<a class='btn btn-primary mx-2 border-0 rounded-pill' id='btn-up' title='up'><i class='fa-solid fa-arrow-up fa-lg'></i> 10</a>
<a class='btn btn-transparent border-0 mx-2 text-white' style='float:right;' data-toggle='modal' data-target='#shareDisc".$rep['id_reply']."' title='forward'><i class='fa-solid fa-paper-plane'></i></a>
</div>
</div>";
}
}
}
}
}
}
if ($count == 0){
Expand Down
Loading

0 comments on commit bcf664a

Please sign in to comment.