JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
update wfpl and templates
[contractor-progress.git] / su.php
1 <?php
2
3 #  Copyright (C) 2008  Jason Woofenden
4 #
5 #  This program is free software: you can redistribute it and/or modify
6 #  it under the terms of the GNU Affero General Public License as published by
7 #  the Free Software Foundation, either version 3 of the License, or
8 #  (at your option) any later version.
9 #
10 #  This program is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU Affero General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Affero General Public License
16 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 require_once('code/wfpl/format.php');
19
20 function su_main() {
21         if(!ever_was_contractor()) {
22                 $GLOBALS['url'] = this_url();
23                 message('You must be logged in as an administrator to access that function');
24                 return 'login';
25         }
26
27         $ret = _su_main();
28         if($ret) {
29                 return $ret;
30         }
31 }
32
33 function _su_main() {
34         $client_id = format_int($_REQUEST['as']);
35         if($client_id) {
36                 session_set('auth_username', $client_id);
37                 message('Switched Login');
38                 return './';
39         }
40
41         $rows = db_get_rows('people', 'id,name,username', 'order by name');
42
43         if($rows) foreach($rows as $row) {
44                 list($id, $name, $username) = $row;
45                 tem_set('client_id', $id);
46                 tem_set('client_name', $name);
47                 tem_set('client_username', $username);
48                 tem_show('su_row');
49         }
50 }
51
52 ?>