Advertisement:

Author Topic: Private message warning  (Read 2867 times)

Offline margarett

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,761
  • Gender: Male
Private message warning
« on: May 16, 2007, 06:43:09 PM »
Hi all.

Is there a way to have on index.template.php (or BoardIndex.template.php) a warning if the user is reaching is limit of PMs?

For instance, a usergroup has 20 PMs limit, and I would like to warn them on 18 or more PMs.

Thanks ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

Quote
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline kerrang!

  • Jr. Member
  • **
  • Posts: 106
Re: Private message warning
« Reply #1 on: May 16, 2007, 09:29:01 PM »
I've seen this feature although I haven't found it myself either. If anyone knows how to do this I would be very greatful if you could point me in the right direction.

Kerrang =)
I'm my own worst enemy! :P

Css Help <--Having difficulty matching the look of the code function with the style of "quote".. =)

Offline margarett

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,761
  • Gender: Male
Re: Private message warning
« Reply #2 on: May 25, 2007, 07:58:41 AM »
Hi all.

Well, I made some coding experiences, and I *THINK* I know how to do it, just need to test it better.

My problem is, using firefox I can open the page, and find no major delay, but using IE the page takes forever to load, until it stops with an "excess memory allocated" error. I know this is a server limitation, but why does it only happens on IE?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

Quote
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Offline margarett

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,761
  • Gender: Male
Re: Private message warning
« Reply #3 on: June 15, 2007, 04:52:21 AM »
Hi again.

I finally managed to get this to work. If someone wishes to make this a MOD, you are welcome.
Anyway, I picked a function from "PersonalMessages.php", modified it a bit, and then all what's needed is a very small amount of code.

So, here it goes:

Find:
Code: [Select]
/* Show sticky and lock status seperate from topic icons? Leave true, icons don't exist for false.*/
$settings['seperate_sticky_lock'] = true;
}

After, add:
Code: [Select]
function PMIndex()
{
global $txt, $scripturl, $sourcedir, $context, $user_info, $user_settings, $db_prefix, $ID_MEMBER;


// Load up the members maximum message capacity.
if (!$user_info['is_admin'])
{
// !!! Why do we do this?  It seems like if they have any limit we should use it.
$request = db_query("
SELECT MAX(maxMessages) AS topLimit, MIN(maxMessages) AS bottomLimit
FROM {$db_prefix}membergroups
WHERE ID_GROUP IN (" . implode(', ', $user_info['groups']) . ')', __FILE__, __LINE__);
list ($maxMessage, $minMessage) = mysql_fetch_row($request);
mysql_free_result($request);

$context['message_limit'] = $minMessage == 0 ? 0 : $maxMessage;
}
else
$context['message_limit'] = 0;
}

Find:
Code: [Select]
<body>';
After, add:

Code: [Select]
PMIndex();

if ($context['user']['is_logged'] && $context['allow_pm'] && $context['message_limit'] > 0)
{
$aux_calc = $context['message_limit'] - $context['user']['messages'];
if (($aux_calc <= 2) && ($aux_calc != 0))
echo' <div align="center"; style="font-size: 20pt; color: #ffffff">PM BOX ALMOST FULL</div>';
elseif ($aux_calc == 0 )
echo' <div align="center"; style="font-size: 20pt; color: #ffffff">PM BOX FULL!</div>';

}

You can add those text strings to languages, etc etc... In my case, I do not need different languages, so I made it this way.

This was tested in IE6 and FF, but I belive it should work everywhere.

As for the previous error with IE and that excess memory error, in this new hosting it is not a problem.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

Quote
Over 90% of all computer problems can be traced back to the interface between the keyboard and the chair