JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
2c3a3d276eb7a424311d82d46838941dca516d15
[contractor-progress.git] / su.php
1 <?php
2
3 require_once('code/wfpl/format.php');
4
5 function su_main() {
6         if(!logged_in_as_contractor()) {
7                 $GLOBALS['url'] = this_url();
8                 message('You must be logged in as an administrator to access that function');
9                 return 'login';
10         }
11
12         $ret = _su_main();
13         if($ret) {
14                 return $ret;
15         }
16         tem_show('main_body');
17 }
18
19 function _su_main() {
20         $client_id = format_int($_REQUEST['as']);
21         if($client_id) {
22                 session_set('auth_username', $client_id);
23                 message('Switched Login');
24                 return './';
25         }
26
27         $rows = db_get_rows('people', 'id,name');
28
29         if($rows) foreach($rows as $row) {
30                 list($id, $name) = $row;
31                 tem_set('client_id', $id);
32                 tem_set('client_name', $name);
33                 tem_show('su_row');
34         }
35 }
36
37 ?>