public function CreateTournament($request) { $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']); if (!valid_id($mundane_id)) { return NoAuthorization(); } logtrace("CreateTournament() :1", $request); $this->Tournament->clear(); $this->Tournament->kingdom_id = $request['KingdomId']; $this->Tournament->park_id = $request['ParkId']; $this->Tournament->event_calendardetail_id = $request['EventCalendarDetailId']; $detail = new yapo($this->db, DB_PREFIX . 'event_calendardetail'); $detail->event_calendardetail_id = $request['EventCalendarDetailId']; if ($detail->find()) { $this->Tournament->event_id = $detail->event_id; } else { if (valid_id($request['EventCalendarDetailId'])) { return InvalidParameter(); } } $this->Tournament->name = $request['Name']; $this->Tournament->description = strip_tags($request['Description'], "<p><br><ul><li><b><i>"); $this->Tournament->date_time = $request['When']; $this->Tournament->save(); return Success($this->Tournament->tournament_id); }
public function index($principality_id = null) { $this->load_model('Reports'); $this->data['park_summary'] = $this->Principality->get_park_summary($principality_id); $this->data['event_summary'] = $this->Principality->get_kingdom_events($principality_id); $this->data['principality_info'] = $this->Principality->get_principality_shortinfo($principality_id); $this->data['kingdom_tournaments'] = $this->Reports->get_tournaments(null, $principality_id); logtrace("index({$kingdom_id} = null)", $this->data['kingdom_tournaments']); }
public static function Geocode($address, $city, $state, $postal_code, $geocode = null) { logtrace("Geocode", [$address, $city, $state, $postal_code, $geocode]); if (strlen($geocode) > 0) { $latlng = urlencode(str_replace(' ', '', $geocode)); $geocodeURL = signUrl("http://maps.googleapis.com/maps/api/geocode/json?latlng={$latlng}&sensor=false", GOOGLE_MAPS_API_KEY); } else { $address = urlencode($address . ', ' . $city . ', ' . $state . ', ' . $postal_code); $geocodeURL = signUrl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false", GOOGLE_MAPS_API_KEY); } $ch = curl_init($geocodeURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $details = []; logtrace("Geocode: Processing.", null); if ($httpCode == 200) { $geocode = json_decode($result); logtrace("Geocode: Processing.", $geocode); $lat = $geocode->results[0]->geometry->location->lat; $lng = $geocode->results[0]->geometry->location->lng; $formatted_address = $geocode->results[0]->formatted_address; $details['Address'] = $formatted_address; $geo_status = $geocode->status; $location_type = $geocode->results[0]->geometry->location_type; $details['Geocode'] = $result; $details['Location'] = json_encode($geocode->results[0]->geometry); if (is_array($geocode->results[0]->address_components)) { foreach ($geocode->results[0]->address_components as $k => $component) { switch ($component->types[0]) { case 'locality': if ($component->types[1] == 'political') { $details['City'] = $component->long_name; } break; case 'administrative_area_level_1': if ($component->types[1] == 'political') { $details['Province'] = $component->long_name; } break; case 'postal_code': $details['PostalCode'] = $component->long_name; break; } } } logtrace("Geocode: Details.", $details); return $details; } else { logtrace("Geocode: failed.", []); return false; } }
public function view() { $V = null; if (is_null($this->view)) { logtrace("Controller: view(): {$this->template}, " . $this->controller_class() . ", {$this->method}, {$this->action}", null); $V = new View($this->template, $this->controller_class(), $this->method, $this->action); $V->__setttings = $this->settings; } else { logtrace("Controller: view(): {$this->template}, " . $this->controller_class() . ", {$this->method}, {$this->action}", null); $V = new View($this->template, $this->controller_class(), $this->method, $this->action); $V->__setttings = $this->settings; } logtrace("Controller view(): data, {$this->kingdom}", $this->data); $CONTENT = $V->view($this->data, $this->kingdom); return $CONTENT; }
function del_unit_auth($request) { logtrace("del_unit_auth()", $request); $this->Authorization->RemoveAuthorization($request); }
function __construct() { logtrace('Settings', $this); }
public function IsAuthorized($token) { logtrace("IsAuthorized({$token})", null); if ($this->IsLocalCall() || true) { $response = $this->IsAuthorized_h($token); } else { $response = $this->IsAuthorized_app($token); } logtrace("Authorization():", $response); return $response; }
public function event($p) { $params = explode('/', $p); $event_id = $params[0]; $detail_id = $params[1]; if (count($params) > 2) { $action = $params[2]; } if (count($params) > 3) { $del_id = $params[3]; } $this->data['DetailId'] = $detail_id; $this->data['EventId'] = $event_id; $this->data['Id'] = $event_id; // Legacy reference ... christ $this->data['DefaultAttendanceCredits'] = 1; $this->data['DefaultParkName'] = $this->session->park_name; $this->data['DefaultParkId'] = $this->session->park_id; $this->data['DefaultKingdomName'] = $this->session->kingdom_name; $this->data['DefaultKingdomId'] = $this->session->kingdom_id; if (strlen($action) > 0) { $this->request->save('Attendance_event', true); $r = array('Status' => 0); if (!isset($this->session->user_id)) { //header( 'Location: '.UIR."Login/login/Attendance/event/$event_id/$detail_id" ); } else { switch ($action) { case 'new': $r = $this->Attendance->add_attendance($this->session->token, $this->request->Attendance_event->AttendanceDate, null, $detail_id, $this->request->Attendance_event->MundaneId, $this->request->Attendance_event->ClassId, $this->request->Attendance_event->Credits); break; case 'delete': $r = $this->Attendance->delete_attendance($this->session->token, $del_id); break; } if ($r['Status'] == 0) { $this->data['AttendanceDate'] = $this->request->Attendance_event->AttendanceDate; $this->data['DefaultParkName'] = $this->request->Attendance_event->ParkName; $this->data['DefaultParkId'] = $this->request->Attendance_event->ParkId; $this->data['DefaultKingdomName'] = $this->request->Attendance_event->KingdomName; $this->data['DefaultKingdomId'] = $this->request->Attendance_event->KingdomId; $this->data['DefaultAttendanceCredits'] = $this->request->Attendance_event->Credits; $this->request->clear('Attendance_event'); } else { if ($r['Status'] == 5) { //header( 'Location: '.UIR."Login/login/Attendance/event/$event_id/$detail_id" ); } else { $this->data['Error'] = $r['Error'] . ':<p>' . $r['Detail']; } } } } $this->data['EventDetailInfo'] = $this->Attendance->get_eventdetail_info($detail_id); $this->data['EventInfo'] = $this->Attendance->get_event_info($event_id); logtrace('Attendance->event()', array($params, $this->request)); $this->data['AttendanceReport'] = $this->Attendance->get_attendance_for_event($event_id, $detail_id); if ($this->request->exists('Attendance_event')) { $this->data['Attendance_event'] = $this->request->Attendance_event->Request; } $this->data['Classes'] = $this->Attendance->get_classes(); if ($this->data['Classes']['Status']['Status'] != 0) { $this->data['Error'] = $this->data['Classes']['Status']['Error']; } }
function create_park($request) { logtrace("create_park", $request); $r = $this->Park->CreatePark($request); return $r; }
logtrace("Index: Route(2): {$class}({$call})", null); $C = new $class($call); $C->{$call}(); } else { if (count($route) == 3) { logtrace("Index: Route(3): {$class}({$call},{$action})", null); $C = new $class($call, $action); $C->{$call}($action); } else { if (count($route) > 3) { $action = implode('/', array_slice($route, 2)); logtrace("Index: Route(3+): {$class}({$call},{$action})", null); $C = new $class($call, $action); $C->{$call}($action); } } } } } else { $C = new Controller("index"); $C->index(); } Ork3::$Lib->session->times['Route Complete'] = time(); $CONTENT = $C->view(); Ork3::$Lib->session->times['Composite'] = time(); echo $CONTENT; logtrace("Timing Information", Ork3::$Lib->session->times); if (DUMPTRACE) { logtrace('Session', $_SESSION); dumplogtrace(); }
public function SetParkDetails($request) { logtrace("SetParkDetails", $request); $response = array(); $this->park->clear(); if (trimlen($request['Name']) > 0) { $this->park->name = trim($request['Name']); if ($this->park->find()) { if ($this->park->park_id != $request['ParkId']) { return InvalidParameter('This park name already exists.'); } } } $this->park->clear(); $this->park->park_id = $request['ParkId']; if ($this->park->find()) { if (($mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token'])) > 0 && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_PARK, $request['ParkId'], AUTH_EDIT)) { $this->log->Write('Park', $mundane_id, LOG_EDIT, $request); $this->park->modified = date("Y-m-d H:i:s", time()); if (Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_KINGDOM, $this->park->kingdom_id, AUTH_EDIT)) { $this->park->name = trimlen($request['Name']) == 0 ? $this->park->name : $request['Name']; $this->park->abbreviation = trimlen($request['Abbreviation']) == 0 ? $this->park->abbreviation : $request['Abbreviation']; $parktitle = new yapo($this->db, DB_PREFIX . 'parktitle'); $parktitle->clear(); if (isset($request['ParkTitleId']) && $request['ParkTitleId'] != $this->park->parktitle_id) { $parktitle->parktitle_id = $request['ParkTitleId']; if ($parktitle->find()) { $this->park->parktitle_id = $request['ParkTitleId']; } } $this->park->active = trimlen($request['Active']) == 0 ? $this->park->active : $request['Active']; } $address_change = false; if (isset($request['Address']) && ($this->park->address != $request['Address'] || trimlen($this->park->location) == 0)) { $address_change = true; } $this->park->url = isset($request['Url']) ? $request['Url'] : $this->park->url; $this->park->address = isset($request['Address']) ? $request['Address'] : $this->park->address; $this->park->city = isset($request['City']) ? $request['City'] : $this->park->city; $this->park->province = isset($request['Province']) ? $request['Province'] : $this->park->province; $this->park->postal_code = isset($request['PostalCode']) ? $request['PostalCode'] : $this->park->postal_code; $this->park->directions = isset($request['Directions']) ? $request['Directions'] : $this->park->directions; $this->park->description = isset($request['Description']) ? $request['Description'] : $this->park->description; $this->park->map_url = isset($request['MapUrl']) ? $request['MapUrl'] : $this->park->map_url; $this->park->save(); $this->park->clear(); $this->park->park_id = $request['ParkId']; if ($this->park->find()) { if ($address_change) { if (isset($request['GeoCode']) && trimlen($request['GeoCode']) > 0) { $this->park_geocode_h($request['GeoCode']); } else { $this->park_geocode_h(); } } $response = Success(); if ($request['KingdomId'] > 0 && $this->park->kingdom_id != $request['KingdomId']) { // Seriously? You couldn't work it out somehow? // AKA Blackspire Code, AKA Golden Plains Exception if (Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_ADMIN, $request['KingdomId'], AUTH_ADMIN)) { $this->park->kingdom_id = $request['KingdomId']; } else { $response = Warning('You do not have permissions to move this Park [' . $this->park->park_id . ', ' . $this->park->kingdom_id . '] to another Kingdom [' . $request['KingdomId'] . '].'); } } if (strlen($request['Heraldry'])) { Ork3::$Lib->heraldry->SetParkHeraldry($request); } $this->park->save(); $response = Success($this->park->park_id); } else { $response = InvalidParameter('ParkId could not be found.'); } } else { $response = NoAuthorization('You do not have permissions to perform this action: ' . $mundane_id); } } else { $response = InvalidParameter('ParkId could not be found.'); } return $response; }
public function RemoveAward($request) { logtrace("RemoveAward()", $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)) { $awards->delete(); } else { return NoAuthorization(); } } else { return InvalidParameter(); } }
public function GetActivePlayers($request) { if (strlen($request['MinimumWeeklyAttendance']) == 0) { $request['MinimumWeeklyAttendance'] = 0; } if (strlen($request['MinimumDailyAttendance']) == 0) { $request['MinimumDailyAttendance'] = 6; } if (strlen($request['MonthlyCreditMaximum']) == 0) { $request['MonthlyCreditMaximum'] = 6; } if (strlen($request['MinimumCredits']) == 0) { $request['MinimumCredits'] = 9; } if (strlen($request['PerWeeks']) == 0 && strlen($request['PerMonths']) == 0) { $request['PerMonths'] = 6; } if (strlen($request['ReportFromDate']) == 0) { $request['ReportFromDate'] = 'curdate()'; } if (strlen($request['PerWeeks']) > 0) { $per_period = mysql_real_escape_string($request['PerWeeks']) . ' week'; } else { $per_period = mysql_real_escape_string($request['PerMonths']) . ' month'; } if (valid_id($request['ParkId'])) { $location = " and m.park_id = '" . mysql_real_escape_string($request['ParkId']) . "'"; $duesclause = "a.park_id = '" . mysql_real_escape_string($request['ParkId']) . "'"; if (valid_id($request['ByLocalPark'])) { $park_comparator = " and a.park_id = '" . mysql_real_escape_string($request['ParkId']) . "' "; } } else { if (strlen($request['KingdomId']) > 0 && $request['KingdomId'] > 0) { $location = " and m.kingdom_id = '" . mysql_real_escape_string($request['KingdomId']) . "'"; $duesclause = "a.kingdom_id = '" . mysql_real_escape_string($request['KingdomId']) . "'"; if (valid_id($request['ByKingdom'])) { $park_list = Ork3::$Lib->Kingdom->GetParks($request); $parks = array(); foreach ($park_list['Parks'] as $p => $park) { $parks[] = $p['ParkId']; } $park_comparator = " and a.park_id in (" . implode($parks) . ") "; } } else { $park_comparator = ""; } } if ($request['KingdomId'] > 0 || $request['ParkId'] > 0) { if ($request['DuesPaid']) { $has_dues = "and s.is_dues = 1"; } $duespaid_clause = "\n\t\t\t\t\tleft join \n\t\t\t\t\t\t(select distinct case split_id when null then 0 else 1 end as split_id, src_mundane_id \n\t\t\t\t\t\t\tfrom " . DB_PREFIX . "split s \n\t\t\t\t\t\t\tleft join " . DB_PREFIX . "account a on s.account_id = a.account_id \n\t\t\t\t\t\t\t\tand {$duesclause}\n\t\t\t\t\t\t\t\t{$has_dues}\n\t\t\t\t\t\t\twhere s.dues_through > curdate()) dues on attendance_summary.mundane_id = dues.src_mundane_id\n\t\t\t"; $duespaid_field = ', ifnull(split_id,0) as duespaid'; $duespaid_order = 'duespaid desc, '; } if (trimlen($request['Peerage']) > 0) { $peerage = "\n left join\n (select distinct awards.mundane_id, award.peerage \n from " . DB_PREFIX . "awards awards\n left join " . DB_PREFIX . "kingdomaward ka on ka.kingdomaward_id = awards.kingdomaward_id\n left join " . DB_PREFIX . "award award on ka.award_id = award.award_id\n left join " . DB_PREFIX . "mundane m on awards.mundane_id = m.mundane_id\n where award.peerage = '" . mysql_real_escape_string($request['Peerage']) . "' and awards.mundane_id > 0 {$location}\n group by awards.mundane_id\n ) peers on attendance_summary.mundane_id = peers.mundane_id\n "; $peerage_clause = "and peers.peerage = '" . mysql_real_escape_string($request['Peerage']) . "'"; $peer_field = 'peers.peerage, '; } if ($request['Waivered']) { $waiver_clause = ' and m.waivered = 1'; } else { if ($request['UnWaivered']) { $waiver_clause = ' and m.waivered = 0'; } } $sql = "\n select main_summary.*, total_monthly_credits, credit_counts.daily_credits, credit_counts.rop_limited_credits\n from\n (select \n \t\t\t\t\t\t{$peer_field} count(week) as weeks_attended, sum(weekly_attendance) as park_days_attended, sum(daily_attendance) as days_attended, sum(credits_earned) total_credits, attendance_summary.mundane_id, \n \t\t\t\t\t\t\tmundane.persona, kingdom.kingdom_id, park.park_id, kingdom.name kingdom_name, kingdom.parent_kingdom_id, park.name park_name, attendance_summary.waivered {$duespaid_field}\n \t\t\t\t\tfrom\n \t\t\t\t\t\t(select \n \t\t\t\t\t\t\t\ta.park_id > 0 as weekly_attendance, count(a.park_id > 0) as daily_attendance, a.mundane_id, \n week(a.date,3) as week, year(a.date) as year, a.kingdom_id, a.park_id, max(credits) as credits_earned, m.waivered \n \t\t\t\t\t\t\tfrom " . DB_PREFIX . "attendance a\n \t\t\t\t\t\t\t\tleft join " . DB_PREFIX . "mundane m on a.mundane_id = m.mundane_id\n \t\t\t\t\t\t\twhere \n date > adddate(curdate(), interval -{$per_period}) {$park_comparator} {$location} {$waiver_clause}\n \t\t\t\t\t\t\tgroup by week(date,3), year(date), mundane_id) attendance_summary \n \t\t\t\t\tleft join " . DB_PREFIX . "mundane mundane on mundane.mundane_id = attendance_summary.mundane_id\n \t\t\t\t\t\tleft join " . DB_PREFIX . "kingdom kingdom on kingdom.kingdom_id = mundane.kingdom_id\n \t\t\t\t\t\tleft join " . DB_PREFIX . "park park on park.park_id = mundane.park_id\n \t\t\t\t\t{$duespaid_clause}\n {$peerage}\n \t\t\t\t\tgroup by mundane_id\n \t\t\t\t\thaving\n \t\t\t\t\t\tweeks_attended >= '" . mysql_real_escape_string($request['MinimumWeeklyAttendance']) . "'\n and days_attended >= '" . mysql_real_escape_string($request['MinimumDailyAttendance']) . "'\n and total_credits >= '" . mysql_real_escape_string($request['MinimumCredits']) . "'\n {$peerage_clause}\n \t\t\t\t\torder by {$duespaid_order} kingdom_name, park_name, persona) main_summary\n left join\n (select mundane_id, sum(monthly_credits) as total_monthly_credits\n from\n (select \n \t\t\t\t\t\t\tleast(sum(credits), " . mysql_real_escape_string($request['MonthlyCreditMaximum']) . ") as monthly_credits, a.mundane_id\n \t\t\t\t\t\t\tfrom ork_attendance a\n \t\t\t\t\t\t\t\tleft join ork_mundane m on a.mundane_id = m.mundane_id\n \t\t\t\t\t\t\twhere \n date > adddate(curdate(), interval -{$per_period}) {$location} {$waiver_clause}\n \t\t\t\t\t\t\tgroup by month(date), year(date), mundane_id) monthly_list\n group by monthly_list.mundane_id) monthly_summary on main_summary.mundane_id = monthly_summary.mundane_id\n left join\n (select mundane_id, sum(daily_credits) as daily_credits, sum(rop_limited_credits) as rop_limited_credits\n from \n (select least(" . mysql_real_escape_string($request['MonthlyCreditMaximum']) . ", sum(daily_credits)) as daily_credits, least(" . mysql_real_escape_string($request['MonthlyCreditMaximum']) . ", sum(rop_credits)) rop_limited_credits, mundane_id\n from\n (select \n \t\t\t\t\t\t\tmax(credits) as daily_credits, 1 as rop_credits, a.mundane_id, a.date\n \t\t\t\t\t\t\tfrom ork_attendance a\n \t\t\t\t\t\t\t\tleft join ork_mundane m on a.mundane_id = m.mundane_id\n \t\t\t\t\t\t\twhere \n date > adddate(curdate(), interval -{$per_period}) {$location} {$waiver_clause}\n \t\t\t\t\t\t\tgroup by dayofyear(date), year(date), mundane_id) credit_list_source\n \t\t\t\t\t group by mundane_id, month(`date`)) credit_list\n group by credit_list.mundane_id) credit_counts on main_summary.mundane_id = credit_counts.mundane_id\n\t\t\t\t\t"; // For last join, need to limit monthly credits to monthly credit maximum per kingdom config logtrace('Report: GetActivePlayers', array($request, $sql)); $r = $this->db->query($sql); $report = array(); if ($r !== false && $r->size() > 0) { do { $report[] = array('KingdomName' => $r->kingdom_name, 'KingdomId' => $r->kingdom_id, 'ParentKingdomId' => $r->parent_kingodm_id, 'ParkName' => $r->park_name, 'ParkId' => $r->park_id, 'Persona' => $r->persona, 'MundaneId' => $r->mundane_id, 'TotalCredits' => $r->total_credits, 'TotalMonthlyCredits' => $r->total_monthly_credits, 'WeeksAttended' => $r->weeks_attended, 'ParkDaysAttended' => $r->park_days_attended, 'DaysAttended' => $r->days_attended, 'DailyCredits' => $r->daily_credits, 'RopLimitedCredits' => $r->rop_limited_credits, 'DuesPaid' => $r->duespaid, 'Waivered' => $r->waivered); } while ($r->next()); } $response = array('Status' => Success(), 'ActivePlayerSummary' => $report); return $response; }
function get_event_info($event_id) { $r = $this->Search->Event(null, null, null, null, null, null, $event_id); logtrace("get_event_info({$event_id})", $r); return $r; }
public function createpark($params = null) { $params = explode('/', $params); if ('submit' == $params[0]) { $post = 'submit'; $this->data['KingdomId'] = $this->session->kingdom_id; } else { if ('park' == $params[0]) { $park_id = $params[1]; $this->data['ParkId'] = $park_id; $this->data['KingdomId'] = $this->session->kingdom_id; } else { if ('kingdom' == $params[0]) { $kingdom_id = $params[1]; $this->data['KingdomId'] = $kingdom_id; } } } logtrace('createpark', $params); if (strlen($post) > 0) { $this->request->save('Admin_createpark', true); if (!isset($this->session->user_id)) { header('Location: ' . UIR . 'Login/login/Admin/createpark' . ($post != null ? '/' . $post : '')); } else { if (trimlen($this->request->Admin_createpark->Name) == 0) { $this->data['Error'] = "Park must have a name."; } else { if (trimlen($this->request->Admin_createpark->Abbreviation) == 0) { $this->data['Error'] = "Park must have an abbreviation."; } else { if (!valid_id($this->request->Admin_createpark->kingdom_id)) { $this->data['Error'] = "Somehow, a Kingdom was not selected. Good luck with that."; } else { if (!valid_id($this->request->Admin_createpark->ParkTitleId)) { $this->data['Error'] = "Parks must have a title."; } else { $r = $this->Park->create_park(['Token' => $this->session->token, 'Name' => $this->request->Admin_createpark->Name, 'Abbreviation' => $this->request->Admin_createpark->Abbreviation, 'KingdomId' => $this->session->kingdom_id, 'ParkTitleId' => $this->request->Admin_createpark->ParkTitleId]); if ($r['Status'] == 0) { $this->request->clear('Admin_createpark'); //header( 'Location: '.UIR.'Park/index/'.$r['Detail'] ); } else { if ($r['Status'] == 5) { header('Location: ' . UIR . 'Login/login/Admin/createpark' . ($post != null ? '/' . $post : '')); } else { $this->data['Error'] = $r['Error'] . ':<p>' . $r['Detail']; } } } } } } } } $this->data['ParkTitleId_options'] = []; $r = $this->Kingdom->get_kingdom_details($this->session->kingdom_id); foreach ($r['ParkTitles'] as $key => $detail) { $this->data['ParkTitleId_options'][$detail['ParkTitleId']] = $detail['Title']; } if ($this->request->exists('Admin_createpark')) { $this->data['Admin_createpark'] = $this->request->Admin_createpark->Request; } }
function update_event($token, $event_id, $kingdom_id, $park_id, $mundane_id, $unit_id, $name, $heraldry, $type) { $r = $this->Event->SetEvent(array('Token' => $token, 'EventId' => $event_id, 'KingdomId' => $kingdom_id, 'ParkId' => $park_id, 'MundaneId' => $mundane_id, 'UnitId' => $unit_id, 'Name' => $name, 'Heraldry' => $heraldry, 'HeraldryMimeType' => $type)); logtrace("update_event({$token}, {$event_id}, {$kingdom_id}, {$park_id}, {$mundane_id}, {$unit_id}, {$name})", array($r)); return $r; }
public function record_transaction($trn, $splits, $trx_date = null) { logtrace('record_transaction', array($trn, $splits, $trx_date)); $trx_date = is_null($trx_date) ? date('Y-m-d') : date('Y-m-d', strtotime($trx_date)); $authority = false; foreach ($splits as $s => $split) { $authority |= $this->has_account_authority($trn['RecordedBy'], $split['AccountId']); $this->account->clear(); $this->account->account_id = $split['AccountId']; if (!$this->account->find()) { return InvalidParameter(print_r(array($split['AccountId'], true))); } else { $splits[$s]['AccountType'] = $this->account->type; } } if (!$authority) { return NoAuthorization(print_r(array($trn['RecordedBy'], $split['AccountId']), true)); } $this->transaction->clear(); $this->transaction->recorded_by = $trn['RecordedBy']; $this->transaction->date_created = date("Y-m-d H:i:s"); $this->transaction->description = $trn['Description']; $this->transaction->memo = $trn['Memo']; $this->transaction->transaction_date = $trx_date; $this->transaction->save(); $debit = 0.0; $credit = 0.0; foreach ($splits as $s => $split) { $this->split->clear(); $this->split->transaction_id = $this->transaction->transaction_id; $this->split->account_id = $split['AccountId']; $this->split->is_dues = $split['IsDues']; $this->split->src_mundane_id = $split['SrcMundaneId']; $this->split->dues_through = strlen($split['DuesThrough']) > 0 ? $split['DuesThrough'] : null; $this->split->amount = round($split['DrCr'] == $this->dr_cr_sign_convention($split['AccountType'], $split['Amount']) ? $split['Amount'] : -$split['Amount'], 3); $this->split->save(); if ($this->dr_cr_sign_convention($split['AccountType'], $split['Amount']) == TreasuryDrCr::Dr) { $debit += $this->split->amount; } else { $credit += $this->split->amount; } } if (abs($debit - $credit) > 0.005) { $this->account->clear(); $this->account->account_id = $this->split->account_id; $this->account->find(); $k = $this->account->kingdom_id; $idt = $this->DetermineAuthType() . '_id'; $id = $this->account->{$idt}; $this->account->clear(); $this->account->kingdom_id = $k; $this->account->{$idt} = $id; $this->account->type = TreasuryAccountType::Imbalance; if ($this->account->find()) { $this->split->clear(); $this->split->transaction_id = $this->transaction->transaction_id; $this->split->account_id = $split['AccountId']; $this->split->is_dues = 0; $this->split->src_mundane_id = $split['SrcMundaneId']; $this->split->amount = $credit - $debit; $this->split->save(); } else { // crap return InvalidParameter('Canno record split.'); } } }
public function SetEvent($request) { $mundane_id = Ork3::$Lib->authorization->IsAuthorized($request['Token']); if (valid_id($mundane_id) && Ork3::$Lib->authorization->HasAuthority($mundane_id, AUTH_EVENT, $request['EventId'], AUTH_EDIT)) { $this->event->clear(); $this->event->event_id = $request['EventId']; $response = array(); if (valid_id($request['EventId']) && $this->event->find()) { if (is_numeric($request['KingdomId'])) { $this->event->kingdom_id = $request['KingdomId']; } if (is_numeric($request['ParkId'])) { $this->event->park_id = $request['ParkId']; $p = Ork3::$Lib->park->GetParkShortInfo(array('ParkId' => $request['ParkId'])); if ($p['Status']['Status'] != 0) { return $p['Status']; } else { $this->event->kingdom_id = $p['KingdomId']; } } if (is_numeric($request['MundaneId'])) { $this->event->mundane_id = $request['MundaneId']; } if (is_numeric($request['UnitId'])) { $this->event->unit_id = $request['UnitId']; } if (trimlen($request['Name'])) { $this->event->name = $request['Name']; } $this->event->save(); Ork3::$Lib->heraldry->SetEventHeraldry($request); logtrace("SetEvent", array($request, $this->event)); return Success(); } else { return InvalidParameter('Event Id is not a valid id.'); } } else { return NoAuthorization(); } }
function active_players($type, $id, $period_type, $period, $minimum_weekly_attendance, $minimum_credits, $duespaid = false, $waivered = null, $minimum_daily_attendance = null, $montly_credit_maximum = null, $peerage = null) { $request = array('ReportFromDate' => null, 'MinimumWeeklyAttendance' => null == $minimum_weekly_attendance ? null : $minimum_weekly_attendance, 'MinimumCredits' => null == $minimum_credits ? null : $minimum_credits, 'PerWeeks' => null, 'PerMonths' => null, 'KingdomId' => null, 'ParkId' => null, 'DuesPaid' => $duespaid, 'Waivered' => !is_null($waivered) && $waivered ? true : false, 'UnWaivered' => !is_null($waivered) && !$waivered ? true : false, 'MinimumDailyAttendance' => null == $minimum_daily_attendance ? null : $minimum_daily_attendance, 'MonthlyCreditMaximum' => null == $montly_credit_maximum ? null : $montly_credit_maximum, 'Peerage' => $peerage); switch ($type) { case 'Kingdom': $request['KingdomId'] = $id; break; case 'Park': $request['ParkId'] = $id; break; } switch ($period_type) { case 'Months': $request['PerWeeks'] = $period; break; case 'Weeks': $request['PerMonths'] = $period; break; } logtrace('Model_Reports: active_players()', $request); $r = $this->Report->GetActivePlayers($request); return $r['ActivePlayerSummary']; }
public function RemoveAttendance($request) { logtrace("Attendance->RemoveAttendance()", $request); if ($this->AttendanceAuthority($request) === false) { return NoAuthorization(); } $this->attendance->clear(); $this->attendance->attendance_id = $request['AttendanceId']; if (!valid_id($request['AttendanceId']) || !$this->attendance->find()) { return InvalidParameter(); } $this->attendance->delete(); return Success($this->attendance->attendance_id); }
public function add_member_h($request) { logtrace("add_member_h", $request); $this->unit->clear(); $this->unit->type = 'Company'; $this->unit->unit_id = $request['UnitId']; if ($this->unit->find()) { $this->members->clear(); $this->members->unit_id = $request['UnitId']; $this->members->mundane_id = $request['MundaneId']; $this->members->active = 'Active'; if ($this->members->find()) { return InvalidParameter('Player is already an active member of this company.'); } $this->members->clear(); $this->members->mundane_id = $request['MundaneId']; $this->members->unit_id = $request['UnitId']; $this->members->active = 'Retired'; if ($this->members->find()) { $this->members->active = 'Active'; $this->members->save(); return Success($this->members->unit_mundane_id); } } $this->members->clear(); $this->members->unit_id = $request['UnitId']; $this->members->mundane_id = $request['MundaneId']; $this->members->role = $request['Role']; $this->members->title = $request['Title']; $this->members->active = $request['Active']; $this->members->save(); return Success($this->members->unit_mundane_id); }
function view($data, $__kingdom = null) { /********************************************** * Language * .../language/<theme>/<language>/<controller>.tpl * .../language/<theme>/<language>/<controller>_<request>.tpl * .../language/<theme>/<language>/<controller>_<request>_<action>.tpl * *********************************************/ $_ = array(); if (file_exists(DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '.lang')) { include_once DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '.lang'; logtrace('View: Language', DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '.lang'); if (!is_null($this->__request) && strlen($this->__request) > 0 && file_exists(DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '_' . $this->__request . '.lang')) { include_once DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '_' . $this->__request . '.lang'; logtrace('View: Language', DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '_' . $this->__request . '.lang'); if (!is_null($this->__action) && strlen($this->__action) > 0 && file_exists(DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '_' . $this->__request . '_' . $this->__action . '.lang')) { include_once DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '_' . $this->__request . '_' . $this->__action . '.lang'; logtrace('View: Language', DIR_LANGUAGE . $this->__settings->theme . '/' . $this->__settings->language . '/' . $this->__controller . '_' . $this->__request . '_' . $this->__action . '.lang'); } } } extract($_); /********************************************** * Request/Action View * .../template/<theme>/<kingdom>/<template> * .../template/<theme>/<template> * .../template/<theme>/<kingdom>/<controller>_<request>_<action> * .../template/<theme>/<kingdom>/<controller>_<request> * .../template/<theme>/<kingdom>/<controller> * .../template/<theme>/<controller>_<request>_<action> * .../template/<theme>/<controller>_<request> * .../template/<theme>/default.tpl * *********************************************/ extract($data); ob_start(); if (!is_null($this->__template) && strlen($this->__template) > 0 && !is_null($__kingdom) && file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__template)) { $template = DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__template; } else { if (!is_null($this->__template) && strlen($this->__template) > 0 && file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__template)) { $template = DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__template; } else { if (!is_null($__kingdom) && strlen($__kingdom) > 0 && !is_null($__kingdom) && file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__controller . '_' . $this->__request . '_' . $this->__action . '.tpl')) { $template = DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__controller . '_' . $this->__request . '_' . $this->__action . '.tpl'; } else { if (!is_null($__kingdom) && strlen($__kingdom) > 0 && !is_null($__kingdom) && file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__controller . '_' . $this->__request . '.tpl')) { $template = DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__controller . '_' . $this->__request . '.tpl'; } else { if (file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__controller . '_' . $this->__request . '_' . $this->__action . '.tpl')) { $template = DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__controller . '_' . $this->__request . '_' . $this->__action . '.tpl'; } else { if (file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__controller . '_' . $this->__request . '.tpl')) { $template = DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__controller . '_' . $this->__request . '.tpl'; } else { $template = DIR_TEMPLATE . $this->__settings->theme . '/default.tpl'; } } } } } } include_once $template; logtrace('View: Template', $template); $TEMPLATE_CONTENTS = ob_get_contents(); ob_end_clean(); /********************************************** * Controller-level theme * .../template/<theme>/<kingdom>/<controller> * .../template/<theme>/<controller> * .../template/<theme>/Controller.tpl * *********************************************/ ob_start(); if (file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__controller . '.tpl') && !is_null($__kingdom)) { $controller_template = DIR_TEMPLATE . $this->__settings->theme . '/' . $__kingdom . '/' . $this->__controller . '.tpl'; } else { if (file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__controller . '.tpl')) { $controller_template = DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__controller . '.tpl'; } else { $controller_template = DIR_TEMPLATE . $this->__settings->theme . '/Controller.tpl'; } } require_once $controller_template; logtrace('View: Controller Template', $controller_template); $CONTROLLER_CONTENTS .= ob_get_contents(); ob_end_clean(); /********************************************** * Application-level theme * .../template/<theme>/<theme_template> * Bail out ... * *********************************************/ ob_start(); if (!is_null($this->__settings->theme_template) && strlen($this->__settings->theme_template) > 0 && file_exists(DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__settings->theme_template . '.theme')) { $theme = DIR_TEMPLATE . $this->__settings->theme . '/' . $this->__settings->theme_template . '.theme'; logtrace('View: Theme, Include Theme', $theme); include_once $theme; } else { logtrace('View: Theme, No Theme', $theme); $THEME_CONTENTS = $CONTROLLER_CONTENTS; } logtrace('View: Theme', $theme); $THEME_CONTENTS .= ob_get_contents(); ob_end_clean(); return $THEME_CONTENTS; }
function create_kingdom($request) { logtrace("create_kingdom", $request); $r = $this->Kingdom->CreateKingdom($request); return $r; }