diff --git a/include/message.php b/include/message.php index f3bc61465..756baf15e 100644 --- a/include/message.php +++ b/include/message.php @@ -123,7 +123,7 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=' } -function private_messages_list($uid, $mailbox = '', $order = 'created desc', $start = 0, $numitems = 0) { +function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) { $where = ''; $limit = ''; @@ -143,8 +143,10 @@ function private_messages_list($uid, $mailbox = '', $order = 'created desc', $st $where = " and sender_xchan = '" . dbesc($x[0]['channel_hash']) . "' "; } + // For different orderings, consider applying usort on the results. We thought of doing that + // inside this function or having some preset sorts, but don't wish to limit app developers. - $r = q("SELECT * from mail WHERE channel_id = %d $where order by $order $limit", + $r = q("SELECT * from mail WHERE channel_id = %d $where order by created desc $limit", intval(local_user()) ); if(! $r) { @@ -168,6 +170,7 @@ function private_messages_list($uid, $mailbox = '', $order = 'created desc', $st $r[$k]['to'] = find_xchan_in_array($rr['to_xchan'],$c); $r[$k]['seen'] = (($rr['mail_flags'] & MAIL_SEEN) ? 1 : 0); } + return $r; } diff --git a/mod/invite.php b/mod/invite.php index 5eb5f6646..336e20164 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -14,6 +14,18 @@ function invite_post(&$a) { return; } + check_form_security_token_redirectOnErr('/', 'send_invite'); + + $max_invites = intval(get_config('system','max_invites')); + if(! $max_invites) + $max_invites = 50; + + $current_invites = intval(get_pconfig(local_user(),'system','sent_invites')); + if($current_invites > $max_invites) { + notice( t('Total invitation limit exceeded.') . EOL); + return; + }; + $recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array()); $message = ((x($_POST,'message')) ? notags(trim($_POST['message'])) : ''); @@ -64,6 +76,12 @@ function invite_post(&$a) { if($res) { $total ++; + $current_invites ++; + set_pconfig(local_user(),'system','sent_invites',$current_invites); + if($current_invites > $max_invites) { + notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL); + return; + } } else { notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL); @@ -108,6 +126,7 @@ function invite_content(&$a) { } $o = replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("send_invite"), '$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'), diff --git a/mod/message.php b/mod/message.php index dd892b2a5..98a1067ed 100644 --- a/mod/message.php +++ b/mod/message.php @@ -4,6 +4,7 @@ require_once('include/acl_selectors.php'); require_once('include/message.php'); require_once('include/zot.php'); require_once("include/bbcode.php"); +require_once('include/Contact.php'); function message_aside(&$a) { @@ -299,9 +300,8 @@ function message_content(&$a) { // private_messages_list() can do other more complicated stuff, for now keep it simple - $order = 'created desc'; - $r = private_messages_list(local_user(), '', $order, $a->pager['start'], $a->pager['itemspage']); + $r = private_messages_list(local_user(), '', $a->pager['start'], $a->pager['itemspage']); if(! $r) { info( t('No messages.') . EOL); diff --git a/view/tpl/invite.tpl b/view/tpl/invite.tpl index a47ef0162..e00d27d4a 100644 --- a/view/tpl/invite.tpl +++ b/view/tpl/invite.tpl @@ -1,4 +1,7 @@