public function AddAward($request) { if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) == 0) { return NoAuthorization(); } $mundane = new yapo($this->db, DB_PREFIX . 'mundane'); $mundane->clear(); $mundane->mundane_id = $mundane_id; if (!$mundane->find()) { return InvalidParameter(); } $authorizer = ['KingdomId' => $mundane->kingdom_id, 'ParkId' => $mundane->park_id]; if (valid_id($request['AwardId'])) { $request['KingdomAwardId'] = Ork3::$Lib->award->LookupAward(['KingdomId' => $recipient['KingdomId'], 'AwardId' => $request['AwardId']]); } else { if (valid_id($request['KingdomAwardId'])) { list($kingdom_id, $request['AwardId']) = Ork3::$Lib->award->LookupKingdomAward(['KingdomAwardId' => $recipient['KingdomAwardId']]); } } if (valid_id($mundane_id) && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $authorizer['ParkId'], AUTH_EDIT)) { if (valid_id($request['GivenById'])) { $given_by = $this->GetPlayer(['MundaneId' => $request['GivenById']]); } if (valid_id($request['ParkId'])) { $Park = new Park(); $park_info = $Park->GetParkShortInfo(['ParkId' => $given_by['Player']['ParkId']]); if ($park_info['Status']['Status'] != 0) { return InvalidParameter('Invalid Parameter 2'); } } if (valid_id($request['AwardId'])) { $request['KingdomAwardId'] = Ork3::$Lib->award->LookupAward(['KingdomId' => $request['KingdomId'], 'AwardId' => $request['AwardId']]); } $awards = new yapo($this->db, DB_PREFIX . 'awards'); $awards->clear(); $awards->kingdomaward_id = $request['KingdomAwardId']; $awards->award_id = $request['AwardId']; $awards->custom_name = $request['CustomName']; $awards->unit_id = $request['RecipientId']; $awards->rank = $request['Rank']; $awards->date = $request['Date']; $awards->given_by_id = $request['GivenById']; $awards->at_park_id = valid_id($request['ParkId']) ? $request['ParkId'] : 0; $awards->at_kingdom_id = valid_id($request['KingdomId']) ? $request['KingdomId'] : 0; $awards->at_event_id = valid_id($request['EventId']) ? $request['EventId'] : 0; $awards->note = $request['Note']; // If no event, then go Park! if (valid_id($request['GivenById'])) { $awards->park_id = valid_id($given_by['Player']['ParkId']) ? $given_by['Player']['ParkId'] : 0; // If no event and valid parkid, go Park! Otherwise, go Kingdom. Unless it's an event. Then go ... ZERO! $awards->kingdom_id = valid_id($given_by['Player']['KingdomId']) ? $given_by['Player']['KingdomId'] : 0; } // Events are awesome. $awards->save(); return Success($awards->awards_id); } else { return NoAuthorization('No Authorization'); } }
public function _park_days($start_date, $period) { $sql = "\n\t\t\t\tselect \n\t\t\t\t\t\tpark.name, park.park_id, recurrence, week_of_month, week_day, month_day, purpose, description, time \n\t\t\t\t\tfrom " . DB_PREFIX . "park park \n\t\t\t\t\t\tleft join " . DB_PREFIX . "parkday parkday on parkday.park_id = park.park_id \n\t\t\t\t\twhere \n\t\t\t\t\t\tpark.active = 'Active' and\n\t\t\t\t\t\trecurrence is not null"; $dates = array(); $parkdays = $this->db->query($sql); switch ($period) { case 'week': $final_date = strtotime("+1 week", $start_date); break; case 'month': $final_date = strtotime("+1 month", $start_date); break; case 'year': $final_date = strtotime("+1 year", $start_date); break; } if ($parkdays !== false && $parkdays->size() > 0) { do { $currdate = $start_date; $moredates = true; $counter = 0; while ($moredates) { $counter++; $date = Park::CalculateNextParkDay($parkdays->recurrence, $parkdays->week_of_month, $parkdays->month_day, $parkdays->week_day, $currdate); switch ($parkdays->recurrence) { case 'weekly': $currdate = strtotime("+1 week", $currdate); break; case 'monthly': case 'week-of-month': $currdate = strtotime("+1 month", $currdate); break; default: $moredates = false; break; } if ($currdate > $final_date) { $moredates = false; } if (strtotime($date) <= $final_date) { $dates[] = array('DateStart' => $date, 'DateEnd' => $date, 'Time' => $parkdays->time, 'Title' => $parkdays->name . " ({$parkdays->purpose})", 'Url' => HTTP_UI . 'Park/index/' . $parkdays->park_id, 'Description' => $parkdays->description); } } } while ($parkdays->next()); } return $dates; }
<?php require_once '../parks_logins.php'; require_once '../Park.php'; require_once '../Input.php'; $errors = []; if(Input::has('name') && Input::has('description') && Input::has('area_in_acres') && Input::has('date_established') && Input::has('location')) { $park = new Park(); try { $park->name = Input::getString('name'); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $park->area_in_acres = Input::getNumber('area_in_acres'); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $park->date_established = Input::getDate('date_established'); } catch (Exception $e) { $errors[] = $e->getMessage(); }
public function UpdateAward($request) { $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']); $awards = new yapo($this->db, DB_PREFIX . 'awards'); $awards->clear(); $awards->awards_id = $request['AwardsId']; if (valid_id($request['AwardsId']) && $awards->find()) { $mundane = $this->player_info($awards->mundane_id); if (valid_id($mundane_id) && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $mundane['ParkId'], AUTH_EDIT)) { if (valid_id($request['ParkId'])) { $Park = new Park(); $info = $Park->GetParkShortInfo(array('ParkId' => $request['ParkId'])); if ($info['Status']['Status'] != 0) { return InvalidParameter(); } } $awards->rank = $request['Rank']; $awards->date = $request['Date']; $awards->given_by_id = $request['GivenById']; $awards->note = $request['Note']; // If no event, then go Park! $awards->park_id = !valid_id($request['EventId']) ? $request['ParkId'] : 0; // If no event and valid parkid, go Park! Otherwise, go Kingdom. Unless it's an event. Then go ... ZERO! $awards->kingdom_id = !valid_id($request['EventId']) ? valid_id($request['ParkId']) ? $info['ParkInfo']['KingdomId'] : $request['KingdomId'] : 0; // Events are awesome. $awards->event_id = valid_id($request['EventId']) ? $request['EventId'] : 0; $awards->save(); return Success($awards->awards_id); } else { return InvalidParamter(); } } else { return NoAuthorization(); } }
<?php die; $DONOTWEBSERVICE = true; include_once 'ParkService.php'; $P = new Park(); $request = array('UserName' => 'kpmone', 'Password' => 'p455w0rd'); $r = Authorize($request); $request = array('Token' => $r['Token'], 'Name' => 'park again', 'Abbreviation' => 'PA', 'KingdomId' => 1); print_r($P->CreatePark($request));
function RestorePark($request) { $K = new Park(); return $K->RestorePark($request); }