Пример #1
0
 /**
  * Saves an account to the db. If the id exists the given dataset will be updated
  * @param \Account\Model\Account $account
  *
  * @throws \Exception
  */
 public function saveAccount(Account $account)
 {
     $data = ['name' => $account->getName(), 'password' => $account->getPassword(), 'userhash' => $account->getUserHash(), 'email' => $account->getEmail(), 'role' => $account->getRole(), 'avatar' => $account->getAvatar(), 'date_registered' => $account->getDateRegistered(), 'mini' => $account->getMini()];
     if (!$account->getId()) {
         $data['password'] = hash('sha256', $account->getPassword()) . Constants::SALT;
         $this->tableGateway->insert($data);
     } else {
         if ($this->getAccount($account->getId())) {
             $this->tableGateway->update($data, ['id' => $account->getId()]);
         } else {
             throw new \Exception('Account id does not exist');
         }
     }
 }
Пример #2
0
 private function sendAssignmentMail(Account $account, array $assignments, string $strategy)
 {
     $target_main = implode(',', array_keys($assignments, strtolower($account->getName())));
     $target_mini = implode(',', array_keys($assignments, strtolower($account->getMini())));
     $text = 'Hello ' . $account->getName() . ". Your targets are:\n";
     if ($target_main) {
         $text .= $account->getName() . ': ' . $target_main . "\n";
     }
     if ($target_mini) {
         $text .= $account->getMini() . ': ' . $target_mini . "\n";
     }
     $text .= 'War Strategy: ' . $strategy . "\n\n";
     $text .= 'Good Luck. Further information can be found under ' . $_SERVER['SERVER_NAME'] . '/warclaim/';
     $this->appMailService->sendMail($account->getEmail(), 'A new war has started!', $text);
 }