Beispiel #1
0
 public function DuesPaidToPark($request)
 {
     logtrace('DuesPaidToPark', $request);
     if (($player = Ork3::$Lib->player->player_info($request['MundaneId'])) === false) {
         return InvalidParameter('Player could not be found.');
     }
     if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $player['ParkId'], AUTH_EDIT)) {
         $park_info = Ork3::$Lib->park->GetParkShortInfo(array('ParkId' => $player['ParkId']));
         if ($park_info['Status']['Status'] > 0) {
             return InvalidParameter('Park information could not be fetched.');
         }
         $configuration = Common::get_configs($park_info['ParkInfo']['KingdomId']);
         if (!isset($configuration['DuesAmount']) || !isset($configuration['KingdomDuesTake'])) {
             return ProcessingError('Kingdom is missing DuesAmount or KingdomDuesTake configuration.');
         }
         $full_name = $player['GivenName'] . ' ' . $player['Surname'];
         if (false !== ($pointers = $this->fetch_account_pointers(AUTH_PARK, $player['ParkId']))) {
             logtrace('record_transaction is free to enter dues', null);
             $duestart = $this->dues_through($request['MundaneId'], $player['ParkId'], $request['TransactionDate']);
             $throughdate = date("Y-m-d H:i:s", strtotime('+' . 6 * ceil($request['Semesters']) . ' months', strtotime($duestart)));
             $r = $this->record_transaction(array('RecordedBy' => $mundane_id, 'Description' => 'Dues Paid for ' . $full_name, 'Memo' => 'Dues Paid for ' . $full_name), array(array('AccountId' => $pointers['DuesPaid'], 'IsDues' => 1, 'SrcMundaneId' => $request['MundaneId'], 'DrCr' => TreasuryDrCr::Cr, 'Amount' => $configuration['DuesAmount']['Value'] * $request['Semesters'], 'DuesThrough' => $throughdate), array('AccountId' => $pointers['Cash'], 'IsDues' => 0, 'SrcMundaneId' => $request['MundaneId'], 'DrCr' => TreasuryDrCr::Dr, 'Amount' => $configuration['DuesAmount']['Value'] * $request['Semesters']), array('AccountId' => $pointers['DuesOwed'], 'IsDues' => 0, 'SrcMundaneId' => $request['MundaneId'], 'DrCr' => TreasuryDrCr::Cr, 'Amount' => $configuration['KingdomDuesTake']['Value'] * $request['Semesters']), array('AccountId' => $pointers['KingdomTake'], 'IsDues' => 0, 'SrcMundaneId' => $request['MundaneId'], 'DrCr' => TreasuryDrCr::Dr, 'Amount' => $configuration['KingdomDuesTake']['Value'] * $request['Semesters'])), $request['TransactionDate']);
             logtrace('Recording info: ', $r);
             return $r;
         } else {
             logtrace('Dues not paid: -EINVAL');
             return InvalidParameter();
         }
     } else {
         logtrace('Dues not paid: no authority; ', 0);
         return NoAuthorization('You lack authoratah.');
     }
 }
Beispiel #2
0
 public function remove_auth_h($request)
 {
     logtrace('remove_auth_h', $request);
     $this->auth->clear();
     $this->auth->authorization_id = $request['AuthorizationId'];
     if (valid_id($request['AuthorizationId']) && $this->auth->find()) {
         $this->log->Write('Authorization', $requester_id, LOG_REMOVE, $request);
         $this->auth->delete();
         $response = Success();
     } else {
         $response = ProcessingError();
     }
     return $response;
 }
Beispiel #3
0
 public function DeleteEventDetail($request)
 {
     $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']);
     $this->detail->clear();
     $this->detail->event_calendardetail_id = $request['EventCalendarDetailId'];
     if (valid_id($request['EventCalendarDetailId']) && $this->detail->find()) {
         $event_id = $this->detail->event_id;
     } else {
         return InvalidParameter();
     }
     if ($mundane_id > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_EVENT, $event_id, AUTH_CREATE)) {
         $this->detail->clear();
         $this->detail->event_calendardetail_id = $request['EventCalendarDetailId'];
         if ($this->detail->find()) {
             $this->detail->delete();
             return Success();
         } else {
             return ProcessingError('Event Calendar Detail is missing after it was found.  Race conditions eminent!');
         }
     }
 }