Jump to content

Recommended Posts

Posted

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!

  • Administrators
Posted

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');
}

Posted

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

  • Administrators
Posted

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.

  • Administrators
Posted

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.

  • 1 month later...
  • 2 weeks later...
  • 1 year later...
Posted

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

  • Administrators
Posted

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/

  • 2 months later...
Posted

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!

  • Administrators
Posted

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

  • 1 year later...
Posted

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));   

  • 1 month later...
Posted
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...

  • Moderators
Posted
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 

  • 2 weeks later...
  • 7 months later...
Posted (edited)

[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
  • 1 month later...
Posted

I get this

Notice: The template file "/storage/ssd5/341/1107341/public_html//core/templates/mail/mail_menu.tpl" doesn't exist in /storage/ssd5/341/1107341/public_html/core/classes/TemplateSet.class.php on line 248

I am quite sure that the file which seems to be missing is actually present. Any leads?

  • 5 months later...
Posted
On 3/13/2017 at 4:22 PM, 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...

Did this problem get solved? And how?

 

Regards,


Cor

  • 2 weeks later...
  • 2 weeks later...
Posted

Hi everyone, someone has a pop-up form or modal window to share to view incoming emails. I found this on the net but I could not change it

 

<div class="container">

  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">EMAIL</h4>
        </div>
        <div class="modal-body">
          <p><?php MainController::Run('Mail', 'checkmail'); ?></p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>
    </div>
  </div>
</div>
<?php
    $show_modal=false;
    $id = $_SESSION["id"];
    $sql = "select count(*) as ct from messages where `readdate`='0000-00-00 00:00:00' and user_to=$id and status!=3";
    if (!$result = $db->query($sql)) {
        die('There was an error running the query  [' . $db->error . ']');
    }
    while ($row = $result->fetch_assoc()) {
        if ($row['ct']>0)
            $show_modal=true;
    }
if($show_modal):?>
      <script> $('#myModal').modal('show');</script>
<?php endif;?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...