Skip to content
This repository was archived by the owner on Dec 6, 2019. It is now read-only.

Commit 4e97aac

Browse files
author
nshahzad
committed
fixed issues with core and db, speed fixes
git-svn-id: file:///var/svn/phpvms/trunk@921 e188d3d8-5a48-0410-b2de-ed2772025908
1 parent b1e4514 commit 4e97aac

34 files changed

+432
-569
lines changed

Diff for: action.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
Template::Set('MODULE_NAV_INC', $NAVBAR);
5858
Template::Set('MODULE_HEAD_INC', $HTMLHead);
5959

60-
MainController::RunAllActions(Config::Get('RUN_MODULE'));
60+
MainController::RunAllActions();
6161

6262
# Force connection close
6363
DB::close();

Diff for: admin/action.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@
5555
}
5656

5757
Template::SetTemplatePath(dirname(__FILE__).'/templates');
58-
//$modules = MainController::getModulesFromPath(dirname(__FILE__).'/modules');
59-
//MainController::loadModules($modules);
60-
61-
MainController::RunAllActions();
58+
MainController::runAllActions();
6259

6360
# Force connection close
6461
DB::close();

Diff for: admin/index.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
flush();
8484

85-
MainController::RunAllActions(Config::Get('RUN_MODULE'));
85+
MainController::runAllActions();
8686

8787
$BaseTemplate->Show('footer.tpl');
8888

Diff for: admin/modules/Operations/Operations.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ public function editairline()
131131

132132
public function calculatedistance($depicao='', $arricao='')
133133
{
134+
cndebug(print_r($this->get, true));
134135
if($depicao == '')
135136
$depicao = $this->get->depicao;
136137

137138
if($arricao == '')
138139
$arricao = $this->get->arricao;
139140

140-
141141
echo OperationsData::getAirportDistance($depicao, $arricao);
142142
}
143143

Diff for: admin/modules/PilotAdmin/PilotAdmin.php

+89-2
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,100 @@ public function pilotawards()
286286
$this->set('allawards', AwardsData::GetPilotAwards($_REQUEST['pilotid']));
287287
$this->render('pilots_awards.tpl');
288288
}
289-
289+
290290
protected function ShowPilotsList()
291291
{
292-
$this->set('allpilots', PilotData::GetAllPilots(Vars::GET('letter')));
293292
$this->render('pilots_list.tpl');
294293
}
295294

295+
public function getpilotsjson()
296+
{
297+
$page = $this->get->page; // get the requested page
298+
$limit = $this->get->rows; // get how many rows we want to have into the grid
299+
$sidx = $this->get->sidx; // get index row - i.e. user click to sort
300+
$sord = $this->get->sord; // get the direction
301+
if(!$sidx) $sidx =1;
302+
303+
/* Do the search using jqGrid */
304+
$where = array();
305+
if($this->get->_search == 'true')
306+
{
307+
$searchstr = jqgrid::strip($this->get->filters);
308+
$where_string = jqgrid::constructWhere($searchstr);
309+
310+
# Append to our search, add 1=1 since it comes with AND
311+
# from above
312+
$where[] = "1=1 {$where_string}";
313+
}
314+
315+
Config::Set('PILOT_ORDER_BY', "{$sidx} {$sord}");
316+
317+
# Do a search without the limits so we can find how many records
318+
$count = count(PilotData::findPilots($where));
319+
320+
if($count > 0)
321+
{
322+
$total_pages = ceil($count/$limit);
323+
}
324+
else
325+
{
326+
$total_pages = 0;
327+
}
328+
329+
if ($page > $total_pages)
330+
{
331+
$page = $total_pages;
332+
}
333+
334+
$start = $limit * $page - $limit; // do not put $limit*($page - 1)
335+
if ($start < 0)
336+
{
337+
$start = 0;
338+
}
339+
340+
# And finally do a search with the limits
341+
$allpilots = PilotData::findPilots($where, $limit, $start);
342+
343+
# Form the json header
344+
$json = array(
345+
'page' => $page,
346+
'total' => $total_pages,
347+
'records' => $count,
348+
'rows' => array()
349+
);
350+
351+
# Add each row to the above array
352+
foreach($allpilots as $row)
353+
{
354+
$status = ($row->retired==0) ? 'Active' : 'Retired';
355+
$location = '<img src="'.Countries::getCountryImage($row->location).'" alt="'.$row->location.'" />';
356+
$edit = '<a href="'.adminurl('/pilotadmin/viewpilots?action=viewoptions&pilotid='.$row->pilotid).'">Edit</a>';
357+
358+
$tmp = array(
359+
'id' => $row->id,
360+
'cell' => array(
361+
# Each column, in order
362+
$row->id,
363+
$row->firstname,
364+
$row->lastname,
365+
$row->email,
366+
$location,
367+
$status,
368+
$row->rank,
369+
$row->totalflights,
370+
$row->totalhours,
371+
$row->lastip,
372+
$edit,
373+
),
374+
);
375+
376+
$json['rows'][] = $tmp;
377+
}
378+
379+
header("Content-type: text/x-json");
380+
echo json_encode($json);
381+
}
382+
296383
protected function ViewPilotDetails()
297384
{
298385
//This is for the main tab

Diff for: admin/templates/ops_scheduleform.tpl

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
</tr>
3030
<tr>
3131
<td width="3%" nowrap><strong>Departure Airport:</strong></td>
32-
<td><input name="depicao" class="airport_select" value="<?php echo $schedule->depicao;?>" onclick="" />
32+
<td><input id="depicao" name="depicao" class="airport_select" value="<?php echo $schedule->depicao;?>" onclick="" />
3333
</td>
3434
</tr>
3535
<tr>
3636
<td><strong>Arrival Airport:</strong></td>
37-
<td><input name="arricao" class="airport_select" value="<?php echo $schedule->arricao;?>" onclick="" />
37+
<td><input id="arricao" name="arricao" class="airport_select" value="<?php echo $schedule->arricao;?>" onclick="" />
3838
</td>
3939
</tr>
4040
<tr>
@@ -174,9 +174,7 @@ $(".preview").click(function()
174174
+"&arricao="+arricao
175175
+"&route="+route;
176176
177-
$('#jqmdialog').jqm({
178-
ajax: url
179-
}).jqmShow();
177+
$('#jqmdialog').jqm({ajax: url}).jqmShow();
180178
181179
return false;
182180
});

Diff for: admin/templates/pilots_list.tpl

+41-56
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,43 @@
11
<h3>Pilots List</h3>
2-
<div align="center">
3-
Find by Last Name: <a href="?admin=viewpilots&letter=">View All</a>
4-
<?php
5-
for($i=65;$i<91;$i++)
6-
{
7-
echo '<a href="'.SITE_URL.'/admin/index.php/pilotadmin/viewpilots?letter='.chr($i).'">'.chr($i).'</a> ';
8-
}
9-
?>
10-
</div>
2+
3+
<table id="grid"></table>
4+
<div id="pager"></div>
115
<br />
12-
<?php
13-
if(!$allpilots)
14-
{
15-
echo '<p>There are no pilots!</p>';
16-
return;
17-
}
18-
?>
19-
<table id="tabledlist" class="tablesorter">
20-
<thead>
21-
<tr>
22-
<th width="1%">Pilot ID</th>
23-
<th>Pilot Name</th>
24-
<th>Email</th>
25-
<th>Location</th>
26-
<th>Status</th>
27-
<th nowrap="nowrap" align="center">Rank</th>
28-
<th nowrap="">Total Flights</th>
29-
<th nowrap="">Total Hours</th>
30-
<th>Last IP</th>
31-
<th>Options</th>
32-
</tr>
33-
</thead>
34-
<tbody>
35-
<?php
36-
foreach($allpilots as $pilot)
37-
{
38-
?>
39-
<tr>
40-
<td nowrap><?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid);?> </td>
41-
<td width="1%" nowrap><a href="<?php echo SITE_URL?>/admin/index.php/pilotadmin/viewpilots?action=viewoptions&pilotid=<?php echo $pilot->pilotid;?>"><?php echo $pilot->firstname . ' ' . $pilot->lastname; ?></a></td>
42-
<td align="left"><?php echo $pilot->email; ?></td>
43-
<td align="center" width="1%"><img src="<?php echo Countries::getCountryImage($pilot->location);?>" </td>
44-
<td align="center" width="1%"><?php echo ($pilot->retired==0) ? 'Active' : 'Retired'; ?></td>
45-
<td align="center" width="1%" nowrap=""><?php echo $pilot->rank; ?></td>
46-
<td align="center" width="1%"><?php echo $pilot->totalflights; ?></td>
47-
<td align="center" width="1%"><?php echo $pilot->totalhours; ?></td>
48-
<td align="center" width="1%"><?php echo $pilot->lastip; ?></td>
49-
<td align="center" width="1%" nowrap>
50-
<button class="{button:{icons:{primary:'ui-icon-wrench'}}}"
51-
onclick="window.location='<?php echo SITE_URL?>/admin/index.php/pilotadmin/viewpilots?action=viewoptions&pilotid=<?php echo $pilot->pilotid;?>';">
52-
Edit</button></td>
53-
</tr>
54-
<?php
55-
}
56-
?>
57-
</tbody>
58-
</table>
6+
7+
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo fileurl('/lib/js/jqgrid/css/ui.jqgrid.css');?>" />
8+
<script src="<?php echo fileurl('/lib/js/jqgrid/js/i18n/grid.locale-en.js');?>" type="text/javascript"></script>
9+
<script src="<?php echo fileurl('/lib/js/jqgrid/js/jquery.jqGrid.min.js');?>" type="text/javascript"></script>
10+
11+
<script type="text/javascript">
12+
$("#grid").jqGrid({
13+
url: '<?php echo adminaction('/pilotadmin/getpilotsjson');?>',
14+
datatype: 'json',
15+
mtype: 'GET',
16+
colNames: ['','First', 'Last', 'Email', 'Location', 'Status', 'Rank', 'Flights', 'Hours', 'IP', 'Edit'],
17+
colModel : [
18+
{index: 'id', name: 'id', hidden: true, search: false },
19+
{index: 'firstname', name : 'firstname',sortable : true, align: 'left', search: 'true', searchoptions:{sopt:['in']}},
20+
{index: 'lastname', name : 'lastname', sortable : true, align: 'left', searchoptions:{sopt:['in']}},
21+
{index: 'email', name : 'email', sortable : true, align: 'left',searchoptions:{sopt:['li']}},
22+
{index: 'location', name : 'location', sortable : true, align: 'center',searchoptions:{sopt:['eq','ne']}},
23+
{index: 'status', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}},
24+
{index: 'rank', name : 'rank', sortable : true, align: 'center', searchoptions:{sopt:['eq','ne']}},
25+
{index: 'totalflights', name : 'totalflights', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}},
26+
{index: 'totalhours', name : 'totalhours', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}},
27+
{index: 'lastip', name : 'lastip', sortable : true, align: 'center', searchoptions:{sopt:['in']}},
28+
{index: '', name : '', sortable : true, align: 'center', search: false}
29+
],
30+
pager: '#pager', rowNum: 25,
31+
sortname: 'lastname', sortorder: 'asc',
32+
viewrecords: true, autowidth: true,
33+
height: '100%'
34+
});
35+
36+
jQuery("#grid").jqGrid('navGrid','#pager',
37+
{edit:false,add:false,del:false,search:true,refresh:true},
38+
{}, // edit
39+
{}, // add
40+
{}, //del
41+
{multipleSearch:true} // search options
42+
);
43+
</script>

Diff for: admin/templates/pilots_options.tpl

+13-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,21 @@ if($pilotid != Auth::$userinfo->pilotid)
3030
<dt></dt>
3131
<dd><input type="hidden" name="pilotid" value="<?php echo $pilotid;?>" />
3232
<input type="hidden" name="action" value="deletepilot" />
33-
<input type="submit" name="submit" value="Delete Pilot" /></dd>
33+
<input type="submit" name="submit" onclick="return doublecheck();" value="Delete Pilot" /></dd>
3434
</dl>
3535
</form>
3636
<?php
3737
}
3838
}
39-
?>
39+
?>
40+
<script type="text/javascript">
41+
function doublecheck()
42+
{
43+
var answer = confirm("Are you sure you want to delete?")
44+
if (answer) {
45+
return true;
46+
}
47+
48+
return false;
49+
}
50+
</script>

Diff for: core/app.config.php

-19
Original file line numberDiff line numberDiff line change
@@ -307,36 +307,17 @@
307307
{
308308
Template::SetTemplatePath(SITE_ROOT.'/admin/templates');
309309

310-
Config::Set('RUN_SINGLE_MODULE', true);
311310
Config::Set('MODULES_PATH', SITE_ROOT.'/admin/modules');
312311
Config::Set('DEFAULT_MODULE', 'Dashboard');
313312
Config::Set('MODULES_AUTOLOAD', true);
314-
Config::Set('ACTIVE_MODULES', array());
315-
316-
CodonRewrite::AddRule('default', array('page'));
317313
}
318314
else
319315
{
320316
Template::SetTemplatePath(Config::Get('BASE_TEMPLATE_PATH'));
321317

322-
Config::Set('RUN_SINGLE_MODULE', true);
323318
Config::Set('MODULES_PATH', SITE_ROOT.'/core/modules');
324319
Config::Set('DEFAULT_MODULE', 'Frontpage');
325320
Config::Set('MODULES_AUTOLOAD', true);
326-
Config::Set('ACTIVE_MODULES', array());
327-
328-
/* Deprecated!!!! */
329-
/* Rules for the controllers */
330-
CodonRewrite::AddRule('default', array('page'));
331-
CodonRewrite::AddRule('acars', array('page', 'action'));
332-
CodonRewrite::AddRule('downloads', array('id'));
333-
CodonRewrite::AddRule('login', array('page', 'redir'));
334-
CodonRewrite::AddRule('logout', array('page', 'redir'));
335-
CodonRewrite::AddRule('pireps', array('page', 'id', 'icao'));
336-
CodonRewrite::AddRule('pilots', array('page', 'pilotid'));
337-
CodonRewrite::AddRule('profile', array('page', 'pilotid'));
338-
CodonRewrite::AddRule('schedules', array('page', 'id'));
339-
CodonRewrite::AddRule('xml', array('request'));
340321
}
341322

342323
/* Cache settings */

Diff for: core/bootstrap.inc.php

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ function post_module_load()
7676
}
7777

7878
// @TODO: Clean ACARS records older than one month
79+
if(Config::Get('MAINTENANCE_MODE') == true
80+
&& !Auth::LoggedIn()
81+
&& !PilotGroups::group_has_perm(Auth::$usergroups, FULL_ADMIN))
82+
{
83+
echo '<html><head><title>Down for maintenance - '.SITE_NAME.'</title></head><body>';
84+
Debug::showCritical(Config::Get('MAINTENANCE_MESSAGE'), 'Down for maintenance');
85+
echo '</body></html>';
86+
die();
87+
}
7988

8089
return true;
8190
}

0 commit comments

Comments
 (0)