AIRMail beta2

AIRMail beta2

New Features

1 - Drop down of all pilots for “To” field when sending new AIRMail

2 - Option in dropdown of “NOTAM” which sends the AIRmail to all pilots of the airline

3 - Streamlined code to only use pilotid in the db so if a pilot switches airlines or the airline changes it’s code the pilots AIRMail will still be available

4 - Function to delete sent items out of your sent items list

5 - Function to show pilot if there is new AIRMail waiting (With Animated Image!)

6 - Added function to insert “No Subject” in the subject line when an AIRMail is sent so it can still be opened by the receiving pilot(s)

7 - Function added to deny sending AIRmail with the “To” field empty

To Use the “You Have Mail” function place the following code where you would like the notice to appear, it will only appear if the pilot is logged in.

<?php MainController::Run('Mail', 'checkmail'); ?>

To Install

1 - Download the attached package

2 - Unzip the folder and place the files in their appropriate places in your phpVMS install

3 - Run the sql file in your phpVMS database using phpmyadmin or similar

(If you have been testing the first version you will have to drop the existing airmail table and replace it with the new file, many changes have been made since the first beta and the new edition will not work within the old db table)

4 - Create a link on your site for your pilots to access their AIRMail

<a href="<?php echo SITE_URL ?>/index.php/Mail/inbox">AIRMail</a>

Please let me know of any bugs you find and any other additional functions that may be beneficial to the addon.

[AIRMail.zip](< base_url >/applications/core/interface/file/attachment.php?id=71)

Ok This one is working, good job.  I am not sure its a good idea for all pilots to have the ability to mail all.  Not sure if thats a feature for just admins.  Some of code was real sloppy, found quite a few mistakes, this may be an issue for you beginners trying to modify the templates. But over all it functions well. One other issue is you didn’t use the mail_send. tpl this time, I liked it better so I reincorporated it.

Thanks, we will give it a try

Roger has a good point in that only admins should have the option to mail all pilots at one time “NOTAM”. Attached is a new mail_new.tpl file that includes a function to only allow admins to have the NOTAM option in their dropdown when creating a new mail -

If you have already modified the mail_new.tpl file you will want to find -

<option value="all">NOTAM (All Pilots)</option>
<?php

Was on lines 25 and 26 of the original

and replace it with -

<?php if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
{
?>
	<option value="all">NOTAM (All Pilots)</option>
<?php
}

[mail_new.zip](< base_url >/applications/core/interface/file/attachment.php?id=72)

ACCESS_ADMIN will allow anyone who has access to the admin panel. If you use FULL_ADMIN, that will only allow true administrators to do that. But if someone has access to edit schedules, they get ACCESS_ADMIN and EDIT_SCHEDULES, but they’re not a full administrator, so you might want to change that depending on what you want

Could you just email individual pilots?

I could not help but notice, if you send out a message to all pilots, it messages the sender as well. This is not actually necessary and takes up extra sql resources. Is there any way to make it so that it does NOT send a Message to the sender?

Gentle bump here.  ;D

Have been using it actively, its working great.

I have one request: Since im responsible for giving some support, my inbox is big. Adding a archive or custom folders would be great for me.

Gentle bump here.  ;D

I will include an option for this in the next version as I believe that it is a good option for the admin, but some may want to have this return confirmation when a NOTAM is sent.

If you would like to change it now to permenatly not send the copy to the admin sending the NOTAM you can ->

1 - Open Mail.php in the Mail module folder

2 - Find lines 89 through 95

foreach ($everyone as $allpilots)
{
	$sql="INSERT INTO airmail (who_to, who_from, subject, message, date, time, notam)
	VALUES ('$allpilots->pilotid', '$who_from', '$subject', '$newmessage', NOW(), NOW(), '$notam')";
	$notam = $notam+1;
	DB::query($sql);
}

And change that section to

foreach ($everyone as $allpilots)
{
	if ($allpilots->pilotid == $who_from)
		{
		}
	else
		{
		$sql="INSERT INTO airmail (who_to, who_from, subject, message, date, time, notam)
		VALUES ('$allpilots->pilotid', '$who_from', '$subject', '$newmessage', NOW(), NOW(), '$notam')";
		$notam = $notam+1;
		DB::query($sql);
		}
}

That should make it so there is no NOTAM sent back to the person sending it, you should still be able to see it in your sent items list.

I will also build in a qualifier to not send any mail to an inactive pilot in the next version as well.

Thanks simpilot. I never thought of it like you pointed out. I guess a bcc is not a bad idea after all.

Thanks for the tip too. 

I could not help but notice, if you send out a message to all pilots, it messages the sender as well. This is not actually necessary and takes up extra sql resources. Is there any way to make it so that it does NOT send a Message to the sender?

That wouldn’t really have an appreciable affect, but it might be good for just having it work that way

Well, I was kind of thinking that since It shows up in the sent messages box then there is no need to have another taking up database room even as minute as it may be. It’s like phpBB sending a private notice to new users and they have never logged in. I allways added the mod to make it only send a pm AFTER they logged in for the first time to save on databse.

There’s that mode of thinking of mine again  ;D  It is hard to shake off.

Well, I was kind of thinking that since It shows up in the sent messages box then there is no need to have another taking up database room even as minute as it may be. It’s like phpBB sending a private notice to new users and they have never logged in. I allways added the mod to make it only send a pm AFTER they logged in for the first time to save on databse.

There’s that mode of thinking of mine again  ;D  It is hard to shake off.

The message showing up in the sent messages box is the same message as you are seeing in the inbox, it is not two seperate lines in the database. The app uses some of the qualifiers in the row in order to show it as both an incoming and outgoing message.

Oh ok I see. well, I am going to leave well enough alone and use it as is. It is a great add on that I am having no issues at all with. 

Hi this looks excellent!  However in my testing I’ve found that if I delete a mail without opening it, the “You Have Mail” still shows, even if there’s nothing in my Inbox.

Also he’s a bit of code that I’ve changed to make the “You have mail” linked back to the Inbox as I’ve put the checkmail function up in the header which you may or may not want to use:

Edit mail_check.tpl, and replace the 2 lines that begin with “echo” with:

?><a href="<?php echo SITE_URL ?>/index.php/Mail/inbox"><?php echo 'You Have New Mail <img src="'.SITE_URL.'/mailimages/new_mail.gif" border="0" />';?></a><?php

Make sure you backup your original file 1st in case you try this and don’t like it.  It’ll also put the mailbox image on the same line as the text rather than above.  If you want to use this and still have the mailbox above the text let me know and I’ll post the code.

EDIT: It appears the mail_new.tpl that enables admins only to send messages breaks new mail functionality in version 700.  I’ve managed to fix it now.  Please note this is for version 700 ONLY, any version with admin groups need not use this:

Using the original mail_new.tpl from beta2, replace the line:

<option value=“all”>NOTAM (All Pilots)</option>

with:

<?php if(Auth::UserInGroup('Administrators'))
{
?>
<option value="all">NOTAM (All Pilots)</option>
<?php
}
?>

Will

Hi this looks excellent!  However in my testing I’ve found that if I delete a mail without opening it, the “You Have Mail” still shows, even if there’s nothing in my Inbox.

Good catch! 

To fix this open MailDataClass.php in core/common and find line 55 ->

$upd = "UPDATE airmail SET deleted_state=1 WHERE id='$mailid'";

and change it to ->

$upd = "UPDATE airmail SET deleted_state=1, read_state=1 WHERE id='$mailid'";

When you now delete an unread mail item it will also show it in the database as a read item and will not trigger the “You Have Mail” function. I will include this change in the next version.

Thanks, was looking for how to set the read status to 1 when on delete, but couldn’t find it!

Another quick problem I’ve seen - when replying to airmail, it inserts “< BR >< BR >”  but doesn’t actually parse it, so all the message is on one line.  Also in a new message it doesn’t take into account carriage returns, so again it shows all on one line.

I had another idea for this.  When someone is sent an airmail, they are notified via the email listed in their account.