Fixed : Thread Names if recipients are > 3

Fixed : send message twice if clicked on send message button
This commit is contained in:
Arslan Hassan 2013-01-06 21:36:07 +00:00
parent 9b195e5b6e
commit b615932c58
5 changed files with 38 additions and 23 deletions

View file

@ -769,8 +769,8 @@ switch ($mode)
{
$uid = userid();
$requests = $userquery->get_friend_requests($uid, array('seen' => 'no'));
$userquery->mark_requests_seen($uid);
$userquery->read_notification($uid, 'friends');
//$userquery->mark_requests_seen($uid);
//$userquery->read_notification($uid, 'friends');
if ($requests)
{

View file

@ -705,10 +705,11 @@ class cb_pm
{
$default_values = array(
'userid' => userid(),
'subject' => "",
'thread_type' => 'private',
'recipients' => array()
);
$data = array_merge($default_values, $params);
$the_data = array(); //Keep only specific indexes
foreach ($default_values as $key => $value)
@ -739,7 +740,7 @@ class cb_pm
if($subject)
$subject = strip_tags(replacer($subject));
$recipients_imploded = implode('|', $recipients);
$recipient_md5 = md5($recipients_imploded);
@ -753,7 +754,7 @@ class cb_pm
}
$thread_id = $this->get_thread_from_md5($recipient_md5);
if (!$thread_id)
{
$insert_array = array(

View file

@ -4,26 +4,27 @@ function list_thread_recipients($thread)
{
$total_recipients = $thread['total_recipients'];
$recipients = json_decode($thread['main_recipients'],true);
$recipients = json_decode($thread['main_recipients'], true);
$list = "";
switch ($total_recipients)
{
case 2:
{
foreach ($recipients as $user)
{
if ($user['userid'] == userid())
{
//if($list)
// $list .=" and ";
//$list .= lang("You");
//Just show other recipient
}else
}
else
{
if($list)
if ($list)
$list .=" and ";
$list .=name($user);
}
@ -32,20 +33,20 @@ function list_thread_recipients($thread)
break;
case 3:
{
$count=0;
$count = 0;
foreach ($recipients as $user)
{
if($count==1)
if ($count == 1)
$list .=", ";
if($count==2)
if ($count == 2)
$list .=" and ";
if ($user['userid'] == userid())
$list .= lang("You");
else
$list .=name($user);
$count++;
}
}
@ -53,37 +54,50 @@ function list_thread_recipients($thread)
case ($total_recipients > 3) :
{
$count = 0;
foreach ($recipients as $user)
{
if ($count == 1)
$list .=", ";
if ($count == 2)
$list .=" , ";
if ($user['userid'] == userid())
$list .= lang("You");
else
$list .=name($user);
$count++;
}
$others = $thread['total_recipients'] - 3;
if($others>1)
$list .= sprintf(" and %d others");
else
$list .= sprintf(" and 1 other");
}
break;
}
return $list;
}
/**
* Get thread link
*/
function get_thread_link($thread)
{
return BASEURL.'/private_message.php?mode=inbox&thread_id='.$thread['thread_id'];
return BASEURL . '/private_message.php?mode=inbox&thread_id=' . $thread['thread_id'];
}
/**
* Function applies on a message..
*/
function message($in)
{
return nl2br($in);
}
?>

View file

@ -194,7 +194,7 @@ switch ($mode)
if($mid)
{
$message_details = $cbpm->get_message($mid);
pr($message_details,true);
//pr($message_details,true);
//$tid = thread id
$tid = $message_details['thread_id'];
//Redirect to thread..@todo work on this section

View file

@ -71,7 +71,7 @@
<div class="new_msg_actions">
<span class="label label-important display-none" id="send-message-error"></span>
<button class="btn btn-primary" id="send_message_btn"
data-loading-text="Sending.." onclick="cb_send_message('#thread_message',this)">Send</button>
data-loading-text="Sending.." >Send</button>
</div>
</form>
</div>