. */ require_once dirname(__FILE__) . "/IRundaily.php"; require_once dirname(__FILE__) . "/../include/numparticipants_func.php"; require_once dirname(__FILE__) . "/../include/functions.php"; require_once dirname(__FILE__) . "/../include/deadline.php"; require_once dirname(__FILE__) . "/../include/Mail.php"; class CheckPartTypeRundaily implements IRundaily { private $messages; public function __construct() { $this->messages = array(); } public function run() { $queryBuilder = new QueryBuilder($GLOBALS['DB'], "ab_bodies"); $queryBuilder->addField(array("bodycode", "bodyname", "email", "bodystatus", "bodycategory", "bodycategoryorder", "nodelegates", "noenvoys", "novisitors", "noobservers")); if( $GLOBALS['DB']->select($queryBuilder->toQuery()) > 0 ) { while( $body = $GLOBALS['DB']->fetchAssoc() ) { $this->checkParticipantTypeForBody($body); } } } public function isEnabled() { global $setup; return $setup['EventDateStart'] != "" && is_before_ex("EventDateStart") && $setup['SetupBoardApproval'] == "yes"; } public function getTitle() { return "Checking for errors in participant type / order"; } public function getMessages() { return $this->messages; } private function addMessage($message) { $this->messages[] = $message; } private function checkParticipantTypeForBody($body) { $queryBuilder = new QueryBuilder($GLOBALS['DB'], "applications"); $queryBuilder->addField(array("id", "firstname", "lastname", "email", "participanttype", "participantorder")); $queryBuilder->addWhereEquals("bodycode", $body['bodycode']); $queryBuilder->addWhereNotEquals("participanttype", "-"); if( $GLOBALS['DB']->select2($queryBuilder->toQuery()) > 0 ) { $numberOfPlaces = getParticipantNum($body); $typeOrder = array(); while( $participant = $GLOBALS['DB']->fetchAssoc2() ) { if( $this->checkDuplicateParticipantType($body, $participant, $typeOrder) ) { $this->checkInvalidParticipantType($body, $participant, $numberOfPlaces); } } } } private function checkDuplicateParticipantType($body, $participant, &$typeOrder) { global $setup; if( isset($typeOrder[ $participant['participanttype'] ][ $participant['participantorder'] ]) ) { $this->addMessage($body['bodyname'] . " (" . $body['bodycode'] . "): duplicate participant type/order for " . $typeOrder[ $participant['participanttype'] ][ $participant['participantorder'] ] . " and " . $participant['firstname'] . " " . $participant['lastname'] . ". Last one will be removed."); $updates = array(); $updates['participanttype'] = "-"; $updates['participantorder'] = NULL; $updates['log'] = new DBMethodConcat("log", "\n" . date("Y-m-d H:i:s") . ": removed participant type by rundaily (duplicate entry)"); if( $GLOBALS['DB']->update("applications", $participant['id'], $updates) ) { $message = "Dear board of " . $body['bodyname'] . ",\n\n"; $message .= "We found out that there are 2 participants for your body with the same "; $message .= "participant type and participant order. The applications for which this was "; $message .= "the case:\n\n"; $message .= "\t- " . $typeOrder[ $participant['participanttype'] ][ $participant['participantorder'] ] . "\n"; $message .= "\t- " . $participant['firstname'] . " " . $participant['lastname'] . "\n\n"; $message .= "The last one has been put back to the waiting list.\n\n"; $message .= "In case of a move between bodies of a participant, it can happen that a participant has a participant type that is not available for the body he/she has been moved "; $message .= "to. It is also possible that due to the move, 2 participants are on exactly the same place. This problem has been solved by removing the participant type of one "; $message .= "participant. Please assign a new participant type (and possible move some other people to another place). This removal of participant type does not change the "; $message .= "accepted status of this person (so, if this person was already accepted, this does not change), but it will prevent this person to be accepted in case he/she was "; $message .= "not accepted yet.\n\n"; $message .= "To assign this person a new participant type, you'll have to go to https://" . FULL_URL . "board.php?login and login with your " . $GLOBALS['ldap']->getSystemName() . " account. There you'll find "; $message .= "this person on the list of people without a participant type. Simply select a participant type for this person, click save and you have solved the problem.\n\n"; $message .= "Greetings,\n\n"; $message .= "The webmaster\n"; $mail = new Mail($setup['MailReturnpath'], $body['email']); $mail->setSubject("Error in participant list found (double booking)"); $mail->addHeader("To", "\"".Mail::encodeHeader("Board ".$body['bodyname'])."\" <".$body['email'].">"); $mail->addHeader("From", "\"".$setup['SetupEventType']." Application Mailer\" <".$setup['EventApplFromEmail'].">"); $mail->addHeader("Auto-Submitted", "auto-generated"); $mail->addHeader("X-Content", "typeordererror to board"); $mail->addHeader("X-BodyCode", $body['bodycode']); $mail->addHeader("X-Signature", get_signature("typeordererror to board", $body['bodycode'])); $mail->setMessage($message); $mail->send(true); }else { $this->addMessage("!!! Failed removing the participant type/order !!!"); } return false; }else { $typeOrder[ $participant['participanttype'] ][ $participant['participantorder'] ] = $participant['firstname'] . " " . $participant['lastname']; return true; } } private function checkInvalidParticipantType($body, $participant, $numberOfPlaces) { global $setup; $toHighOnDelegate = $participant['participanttype'] == "delegate" && $participant['participantorder'] > $numberOfPlaces['NoDelegates']; $toHighOnEnvoy = $participant['participanttype'] == "envoy" && $participant['participantorder'] > $numberOfPlaces['NoEnvoys']; $toHighOnVisitor = $participant['participanttype'] == "visitor" && $participant['participantorder'] > $numberOfPlaces['NoVisitors']; $toHighOnObserver = $participant['participanttype'] == "observer" && $participant['participantorder'] > $numberOfPlaces['NoObservers']; if( $toHighOnDelegate || $toHighOnEnvoy || $toHighOnVisitor || $toHighOnObserver ) { // This participant has a type/order combination that is not allowed for this body $this->addMessage($body['bodyname'] . " (" . $body['bodycode'] . "): invalid participant type/order for " . $participant['firstname'] . " " . $participant['lastname'] . ". Invalid values: ParticipantType=" . $participant['participanttype'] . "; ParticipantOrder=" . $participant['participantorder']); $updates = array(); $updates['participanttype'] = "-"; $updates['participantorder'] = NULL; $updates['log'] = new DBMethodConcat("log", "\n" . date("Y-m-d H:i:s") . ": removed participant type by rundaily (invalid type/order)"); if( $GLOBALS['DB']->update("applications", $participant['id'], $updates) ) { $message = "Dear board of " . $body['bodyname'] . ",\n\n"; $message .= "We found out that there is a participant for your body with a participant "; $message .= "type and participant order that is not available for your body. The application "; $message .= "for which this was the case:\n\n"; $message .= "\t- " . $participant['firstname'] . " " . $participant['lastname'] . "\n\n"; $message .= "This person has no participant type (delegate, envoy, observer or visitor) any more.\n\n"; $message .= "Normally, this is caused by the upgrading/downgrading of your local.\n\n"; $message .= "For every type of local (Contact, Contact Antenna or Antenna) there is a certain number of delegate, envoy, observer and visitor places available. With the "; $message .= "upgrading or downgrading, this number can change. People that were placed on a place that is not available any more, will have cleared participant type. This "; $message .= "does NOT change their accepted status. So, if the person was accepted already when the participant was removed, the person will stay accepted. But, participants "; $message .= "without a participant type will not be moved from the waiting list to the participants list, so it is important to assign a new participant type to this person. "; $message .= "Also people that are already accepted should get a new participant type, as otherwise they will not be able to register at the ".$setup['SetupEventType'].".\n\n"; $message .= "To assign this person a new participant type, you'll have to go to https://" . FULL_URL . "board.php?login and login with your " . $GLOBALS['ldap']->getSystemName() . " account. There you'll find "; $message .= "this person on the list of people without a participant type. Simply select a participant type for this person, click save and you have solved the problem.\n\n"; $message .= "Greetings,\n\n"; $message .= "The webmaster\n"; $mail = new Mail($setup['MailReturnpath'], $body['email']); $mail->setSubject("Error in participant list found (place not available)"); $mail->addHeader("To", "\"".Mail::encodeHeader("Board ".$body['bodyname'])."\" <".$body['email'].">"); $mail->addHeader("From", "\"".$setup['SetupEventType']." Application Mailer\" <".$setup['EventApplFromEmail'].">"); $mail->addHeader("Auto-Submitted", "auto-generated"); $mail->addHeader("X-Content", "typeordererror to board", $participant['id']); $mail->addHeader("X-BodyCode", $body['bodycode']); $mail->addHeader("X-Signature", get_signature("typeordererror to board", $body['bodycode'])); $mail->setMessage($message); $mail->send(true); }else { $this->addMessage("!!! Failed removing the participant type/order !!!"); } } } } ?>