Moderators joeri Posted October 19, 2010 Moderators Report Share Posted October 19, 2010 hello all i have a quick question would it be possible to add a line to the massmailer to only mail to active pilots(not inactive in phpvms but retired in the database) as the autoretire function doesn't put the retired pilots it inactive in the admin. gr joeri Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 19, 2010 Report Share Posted October 19, 2010 I had the same problem. So I wrote a script to check all of the pilots and compare to the active/inactive groups. I run this with the cron we run every Sunday. What this does is check each pilot. If that pilot is retired it ensures that he/she is in the inactive pilot group. It then does the same with active pilots but ensures that they are in the active group. The following was added to admin/modules/Maintenance.php public function checkPilotGroups() { $activeGroup = PilotGroups::getGroupID('Active Pilots'); $inactiveGroup = PilotGroups::getGroupID('Inactive'); $params = array( 'retired' => '1', 'groupid' => $activeGroup ); $sql = 'SELECT p.*, p.pilotid as pilotid, p.firstname as firstname, p.lastname as lastname, g.groupid as groupid, g.id as id FROM '.TABLE_PREFIX.'pilots p LEFT JOIN '.TABLE_PREFIX.'groupmembers g ON g.pilotid = p.pilotid'; $sql .= DB::build_where($params); $results = DB::get_results($sql); if($results) { foreach($results as $result) { PilotGroups::RemoveUserFromGroup($result->pilotid, $activeGroup); if(!PilotGroups::CheckUserInGroup($result->pilotid, $inactiveGroup)) PilotGroups::AddUsertoGroup($result->pilotid, $inactiveGroup); echo '<strong>'.$result->firstname.' '.$result->lastname.'</strong> - Removed from Active Group and reassigned to Inactive Group<br/>'; } } else { echo "No retired pilot in Active Group"; } echo "<p></p><p></p>"; $params = array( 'retired' => '0', 'groupid' => $inactiveGroup ); $sql = 'SELECT p.*, p.pilotid as pilotid, p.firstname as firstname, p.lastname as lastname, g.groupid as groupid, g.id as id FROM '.TABLE_PREFIX.'pilots p LEFT JOIN '.TABLE_PREFIX.'groupmembers g ON g.pilotid = p.pilotid'; $sql .= DB::build_where($params); $results = DB::get_results($sql); if($results) { foreach($results as $result) { PilotGroups::RemoveUserFromGroup($result->pilotid, $inactiveGroup); if(!PilotGroups::CheckUserInGroup($result->pilotid, $activeGroup)) PilotGroups::AddUsertoGroup($result->pilotid, $activeGroup); echo '<strong>'.$result->firstname.' '.$result->lastname.'</strong> - Removed from Inactive Group and reassigned to Active Group<br/>'; } } else { echo "No active pilots in Inactive Group"; } } The following was added to /admin/maintenance.php MainController::Run('Maintenance', 'checkPilotGroups'); I also added the following to the /admin/templates/maintenance_options.tpl This allows admin to manually run the script. <tr> <td><strong> <a href="<?php echo adminurl('/maintenance/checkPilotGroups');?>">Check Pilot User Groups</a> </strong> </td> <td>This will update pilots to ensure they are in the proper groups(Active/Inactive).<br /></td> </tr> Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 19, 2010 Report Share Posted October 19, 2010 NOTE - The above posts assumes that the following groups have these group id's Be sure to check first. If the you change the group numbers than you will have problems Active - Group id #2 Inactive - Group id #4 I probably should have put a check group in the beginning. Maybe I will change it to check the groups just in case they change. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 19, 2010 Report Share Posted October 19, 2010 I changed the original code to include a group name check. The names of the groups have to be Active Pilots Inactive Both of these are the default groups that phpVMS installs. If you rename the groups you will need to change the first two lines of code to match your new group names. Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted October 19, 2010 Author Moderators Report Share Posted October 19, 2010 thanks Jeff going to try it lateron on a second hand did you ever recived my email regarding the tnt acars iff not let me know the i can resend it Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted October 19, 2010 Author Moderators Report Share Posted October 19, 2010 thanks Jeff going to try it lateron on a second hand did you ever recived my email regarding the tnt acars iff not let me know the i can resend it ok tried it but getting this error Parse error: syntax error, unexpected T_PUBLIC in /home/tntvirtua/domains/tnt-virtual.be/public_html/admin/modules/Maintenance/Maintenance.php on line 332 i probably do something verry stupid an easy wrong but i cant find it :-) gr joeri Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 19, 2010 Report Share Posted October 19, 2010 Sorry I must not have received it. Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted October 19, 2010 Author Moderators Report Share Posted October 19, 2010 ok no problem will resend it. could you help on the error i am stuck this moment Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 19, 2010 Report Share Posted October 19, 2010 send me the entire file. or post it here will have a looksee. we can then delete the code after we figure it out Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted October 19, 2010 Author Moderators Report Share Posted October 19, 2010 i added it to thissite i commented your pice off code out. thanks in advance joeri Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 19, 2010 Administrators Report Share Posted October 19, 2010 You can also add on this line: http://github.com/nshahzad/phpVMS/blob/master/admin/modules/MassMailer/MassMailer.php#L91 if($pilot->active == '0') { continue; } That will skip adding inactive pilots, no matter the group. Add it before that echo Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted October 19, 2010 Author Moderators Report Share Posted October 19, 2010 ok but the main problem is when a pilot gets retired using the autoretire the inactive/active part off phpvms doesn't take that out the the retire table from the database so when doing a mass mail it sends it to all the pilots in the database and not only to the still active as i did not make them inactive in the admin. gr joeri ps still struggeling on the code i must be missing something verry stupid Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 19, 2010 Report Share Posted October 19, 2010 I cant see anything wrong with the code. it looks the same as what I have and use. Try uncommenting it again and see what happens. I dont see the final closing bracket at the very end but maybe you just forgot to paste that in. Quote Link to comment Share on other sites More sharing options...
Moderators joeri Posted October 19, 2010 Author Moderators Report Share Posted October 19, 2010 wierd now its working thanks jeff machines somethimes you want to kill them when they don't do what you want them to do Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.