Jump to content
  • Announcements

    • Parkho

      New Website Skin   11/17/17

      Hello Guys, I have changed my website's skin to bootstrap version. Please check it out here and let me know if your need the skin. Regards Parkho
simpilot

AirMail 3.0

Recommended Posts

Ariel    134

Here's a quick piece of code which will display the user's mailbox on their profile, however with just the date, subject and who from:

1. First, create the file mail_profile.tpl in core/templates/mail and paste the following code:

<table width="100%" cellpadding="2">
<?php if(!$mail){
 echo '<tr><td align="center" colspan="3">No NOTAMs available</td></tr>';
 }
 else {
	 foreach($mail as $data) {
 ?>
	 <?php $user = PilotData::GetPilotData($data->who_from);?>
	 <tr>
	 <td width="25%" align="center"><?php echo date(DATE_FORMAT.' H:i', strtotime($data->date)); ?></td>
	 <td><?php echo $user->firstname.' '.$user->lastname;?></td>
	 <td>
	 <?php
	 if ($data->read_state=='0') { ?>
 <b><a href="http://www.freshjetvirtual.com/index.php/Mail/item/<?php echo $data->thread_id;?>"><?php echo $data->subject; ?></a></b>
 <?php
 }
 else
 {
 ?>
 <a href="http://www.freshjetvirtual.com/index.php/Mail/item/<?php echo $data->thread_id;?>"><?php echo $data->subject; ?></a>
 <?php
 }
 ?>
 </td>
 </tr>
<?php
}

}
?>
</table>

2. Add the following code to core/modules/Mail/Mail.php :

public function GetProfileMail(){
 $pid = Auth::$userinfo->pilotid;
 $this->set('mail', MailData::getallmail($pid));
 $this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
 $this->show('mail/mail_profile.tpl');
 }

3. In your profile_main.tpl (or wherever else you want):

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

The number at the end can be changed to suit how many items you wish to display as per usual.

Enjoy :)

everything worked up in till the point of changing the number. It actually displays my whole inbox instead of just 5 items and i have more than 10 in my inbox! Help Please!

Share this post


Link to post
Share on other sites
simpilot    2128

I am assuming that you are using the latest version of AirMail - The MailData::getallmail function has no limit parameter.

public static function getallmail($pid) {
if(Auth::$userinfo->pilotid != $pid){
throw new Exception("This mailbox does not belong to you. If you are accessing this via an Administration module, this feature is still in development");
}
$query = "SELECT *
FROM `".TABLE_PREFIX."airmail`
WHERE `who_to`='$pid'
AND `deleted_state`='0'
AND `receiver_folder`='0'
ORDER BY `date` ASC";

$results = DB::get_results($query);

$code = DB::errno();
if ($code != 0){
$message = DB::error();
throw new Exception($message, $code);
}

return $results;
}

It will have to be updated to include the limit, maybe something like this (using 10 as a default limit);

public static function getallmail($pid, $limit = '10') {
if(Auth::$userinfo->pilotid != $pid){
throw new Exception("This mailbox does not belong to you. If you are accessing this via an Administration module, this feature is still in development");
}
$query = "SELECT *
FROM `".TABLE_PREFIX."airmail`
WHERE `who_to`='$pid'
AND `deleted_state`='0'
AND `receiver_folder`='0'
ORDER BY `date` ASC
LIMIT '$limit'";

$results = DB::get_results($query);

$code = DB::errno();
if ($code != 0){
$message = DB::error();
throw new Exception($message, $code);
}

return $results;
}

You will also have to update the module code to pass the limit parameter;


public function GetProfileMail($limit){
$pid = Auth::$userinfo->pilotid;
$this->set('mail', MailData::getallmail($pid, $limit));
$this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
$this->show('mail/mail_profile.tpl');
}

Share this post


Link to post
Share on other sites
Ariel    134

I am assuming that you are using the latest version of AirMail - The MailData::getallmail function has no limit parameter.

public static function getallmail($pid) {
if(Auth::$userinfo->pilotid != $pid){
throw new Exception("This mailbox does not belong to you. If you are accessing this via an Administration module, this feature is still in development");
}
$query = "SELECT *
FROM `".TABLE_PREFIX."airmail`
WHERE `who_to`='$pid'
AND `deleted_state`='0'
AND `receiver_folder`='0'
ORDER BY `date` ASC";

$results = DB::get_results($query);

$code = DB::errno();
if ($code != 0){
$message = DB::error();
throw new Exception($message, $code);
}

return $results;
}

It will have to be updated to include the limit, maybe something like this (using 10 as a default limit);

public static function getallmail($pid, $limit = '10') {
if(Auth::$userinfo->pilotid != $pid){
throw new Exception("This mailbox does not belong to you. If you are accessing this via an Administration module, this feature is still in development");
}
$query = "SELECT *
FROM `".TABLE_PREFIX."airmail`
WHERE `who_to`='$pid'
AND `deleted_state`='0'
AND `receiver_folder`='0'
ORDER BY `date` ASC
LIMIT '$limit'";

$results = DB::get_results($query);

$code = DB::errno();
if ($code != 0){
$message = DB::error();
throw new Exception($message, $code);
}

return $results;
}

You will also have to update the module code to pass the limit parameter;


public function GetProfileMail($limit){
$pid = Auth::$userinfo->pilotid;
$this->set('mail', MailData::getallmail($pid, $limit));
$this->set('pilotcode', PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid));
$this->show('mail/mail_profile.tpl');
}

No its still showing me all of the inbox instead of the 10 items. I changed the number to 5 and it still shows me more than that. I am using the latest version of AIRMAIL

when i changed the code with what you gave me when i go to inbox i get this

Fatal error: Call to undefined method Mail::inbox() in /home/vdeltaor/public_html/core/modules/Mail/Mail.php on line 40

Share this post


Link to post
Share on other sites
simpilot    2128

Post your files to pastebin or somewhere - there must be something being left out somewhere, this works on my test install without issue.

I also am not sure where this is coming from

Fatal error: Call to undefined method Mail::inbox() in /home/vdeltaor/public_html/core/modules/Mail/Mail.php on line 40

The function is in the file -> https://github.com/D...s/Mail/Mail.php <- on line 58

It is the default function that is called when the module does not know what to do with a request which makes me think that you are calling the module with no specific function, which would default to the index function.

Share this post


Link to post
Share on other sites
simpilot    2128

I tried it on a windows based server and the sql query wanted to be difficult but I chnaged the last line of the query from

LIMIT '$limit'";

to

LIMIT $limit";

With that it works on both playforms I able to test here.

Share this post


Link to post
Share on other sites
elmoussati    8

after installation

this is the error

Notice: The template file "/home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/xxxxxx//core/templates/mail/mail_menu.tpl" doesn't exist in /home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/home/core/classes/TemplateSet.class.php on line 248 Notice: The template file "/home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/xxxxxx//core/templates/mail/mail_inbox.tpl" doesn't exist in /home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/home/core/classes/TemplateSet.class.php on line 248

Share this post


Link to post
Share on other sites
simpilot    2128

after installation

this is the error

Notice: The template file "/home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/xxxxxx//core/templates/mail/mail_menu.tpl" doesn't exist in /home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/home/core/classes/TemplateSet.class.php on line 248 Notice: The template file "/home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/xxxxxx//core/templates/mail/mail_inbox.tpl" doesn't exist in /home/xxxxxx/public_html/royalairmarocvirtual/pilotcenter/home/core/classes/TemplateSet.class.php on line 248

http://forum.phpvms.net/topic/18860-i-have-a-xxxxxxtpl-file-not-found-error/

Share this post


Link to post
Share on other sites
jnascar    44

Is there a way to send AirMail automatically when a pilot registers? So right when they join and are approved they will receive AirMail from the VA instantly, like a welcome message.

Thanks!

Share this post


Link to post
Share on other sites
simpilot    2128

Is there a way to send AirMail automatically when a pilot registers? So right when they join and are approved they will receive AirMail from the VA instantly, like a welcome message.

Thanks!

The base phpvms system already sends an email upon both user registration and approval. You could add a hook to catch that and add a pre-built airmail to the users new account.

The info for the native event/hook system is here -> http://forum.phpvms.net/page/index.html/_/developers-guides/events-and-listening-for-events-r28

Share this post


Link to post
Share on other sites
Rene    0

After install this error:

Fatal error: Class 'MailData' not found in /home/u166215059/public_html/core/modules/Mail/Mail.php on line 59

 

in Line 59:  $this->set('mail', MailData::getallmail(Auth::$userinfo->pilotid));   

Share this post


Link to post
Share on other sites
Tummi    0
Fatal error: Uncaught exception 'Exception' with message 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's message inbox on 03/13/2017', '2', '1489418110')' at line 2' in /home/oneengin/public_html/core/common/MailData.class.php:92 Stack trace: #0 /home/oneengin/public_html/core/modules/Mail/Mail.php(138): MailData::send_new_mail('2', '1', 'VA Discounts', 'You received a ...', 2, 1489418110) #1 /home/oneengin/public_html/core/modules/Mail/Mail.php(38): Mail->send() #2 [internal function]: Mail->index() #3 /home/oneengin/public_html/core/classes/MainController.class.php(218): call_user_func_array(Array, Array) #4 /home/oneengin/public_html/index.php(70): MainController::RunAllActions() #5 {main} thrown in /home/oneengin/public_html/core/common/MailData.class.php on line 92

 

after sending an airmail to all Pilots...

Share this post


Link to post
Share on other sites
11 hours ago, Tummi said:

Fatal error: Uncaught exception 'Exception' with message 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's message inbox on 03/13/2017', '2', '1489418110')' at line 2' in /home/oneengin/public_html/core/common/MailData.class.php:92 Stack trace: #0 /home/oneengin/public_html/core/modules/Mail/Mail.php(138): MailData::send_new_mail('2', '1', 'VA Discounts', 'You received a ...', 2, 1489418110) #1 /home/oneengin/public_html/core/modules/Mail/Mail.php(38): Mail->send() #2 [internal function]: Mail->index() #3 /home/oneengin/public_html/core/classes/MainController.class.php(218): call_user_func_array(Array, Array) #4 /home/oneengin/public_html/index.php(70): MainController::RunAllActions() #5 {main} thrown in /home/oneengin/public_html/core/common/MailData.class.php on line 92

 

after sending an airmail to all Pilots...

I have the same issue 

Share this post


Link to post
Share on other sites

[SOLVED] , wonderful addon. But sadly it doesn't work on my new project. 
 

Fatal error: Uncaught exception 'Exception' with message 'Table 'tuigroupvirtual_co_uk_tuivam.phpvms_1airmail_folders' doesn't exist' in /customers/a/5/b/tuigroupvirtual.co.uk/httpd.www/core/common/MailData.class.php:364 Stack trace: #0 /customers/a/5/b/tuigroupvirtual.co.uk/httpd.www/core/modules/Mail/Mail.php(67): MailData::checkforfolders('43') #1 /customers/a/5/b/tuigroupvirtual.co.uk/httpd.www/core/modules/Mail/Mail.php(61): Mail->menu() #2 /customers/a/5/b/tuigroupvirtual.co.uk/httpd.www/core/modules/Mail/Mail.php(40): Mail->inbox() #3 [internal function]: Mail->index() #4 /customers/a/5/b/tuigroupvirtual.co.uk/httpd.www/core/classes/MainController.class.php(218): call_user_func_array(Array, Array) #5 /customers/a/5/b/tuigroupvirtual.co.uk/httpd.www/index.php(70): MainController::RunAllActions() #6 {main} thrown in /customers/a/5/b/tuigroupvirtual.co.uk/httpd.www/core/common/MailData.class.php on line 364

Any leads? 

Edited by LeonardIGO4036

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×