Пример #1
0
 public function updateEveMail()
 {
     if (2048 & $this->accessMask and 1024 & $this->accessMask) {
         // Starting the Message Header pulls
         $userid = $this->keyID;
         $vcode = $this->vCode;
         $pheal = new Pheal($userid, $vcode, 'char');
         try {
             $response = $pheal->MailMessages(array("characterID" => $this->characterID));
             // Setting up the message ID list for later message body pulls
             $messageIDList = '';
             // Looping through the messages
             foreach ($response->messages as $mail) {
                 $phealLookup = new Pheal($userid, $vcode, 'eve');
                 $phealCharLookup = new Pheal($userid, $vcode, 'char');
                 // Categorizing the evemails
                 if ($mail->senderID == $this->characterID) {
                     // This is a sent evemail, so we will get the character names and set them as the receiver
                     $evemail_type = 'Sent';
                 } elseif (strpos($mail->toCharacterIDs, $this->characterID) !== FALSE or $mail->toAllianceIDs = '' and $mail->toCorporationIDs = '') {
                     $evemail_type = "Inbox";
                 } elseif (strpos($mail->toCorpOrAllianceID, $this->corporationID) !== FALSE or $mail->toCharacterIDs = '' and $mail->toAllianceIDs = '') {
                     $evemail_type = 'Corporation';
                 } elseif (strpos($mail->toCorpOrAllianceID, $this->allianceID) !== FALSE or $mail->toCharacterIDs = '' and $mail->toCorporationIDs = '') {
                     $evemail_type = 'Alliance';
                 } else {
                     $evemail_type = 'Mailing List';
                 }
                 $evemail_receiver = rtrim(mailAffiliation(implode(',', array($mail->toCharacterIDs, $mail->toCorpOrAllianceID, $mail->toListID)), $phealLookup), ', ');
                 $messageID = $mail->messageID;
                 $senderID = $mail->senderID;
                 $sentDate = $mail->sentDate;
                 $title = $mail->title;
                 $messageIDList = $messageIDList . $messageID . ',';
                 $lookupResponse = $phealLookup->CharacterAffiliation(array('ids' => $senderID));
                 $senderName = $lookupResponse->characters[0]->characterName;
                 // Adding the message to the DB
                 $sql = "INSERT INTO user_evemail (message_id,uid,gid,character_id,evemail_sender,sent_date,evemail_title,evemail_type,evemail_receiver) VALUES (?,?,?,?,?,?,?,?,?)" . " ON DUPLICATE KEY UPDATE message_id=VALUES(message_id)";
                 $stmt = $this->db->prepare($sql);
                 $stmt->execute(array($messageID, $this->uid, $this->gid, $this->characterID, $senderName, $sentDate, $title, $evemail_type, trim($evemail_receiver)));
             }
             $this->updateMailBodies($messageIDList);
             return TRUE;
         } catch (\Pheal\Exceptions\PhealException $phealException) {
             // Putting the pheal exception through our test function to determine if it's a key failure, or an API server failure.
             $this->testAPIKeyStatus($phealException);
             return FALSE;
         }
     } else {
         // Does not support Evemail
         return FALSE;
     }
 }