JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
added Switch Login page and link
[contractor-progress.git] / su.php
diff --git a/su.php b/su.php
new file mode 100644 (file)
index 0000000..2c3a3d2
--- /dev/null
+++ b/su.php
@@ -0,0 +1,37 @@
+<?php
+
+require_once('code/wfpl/format.php');
+
+function su_main() {
+       if(!logged_in_as_contractor()) {
+               $GLOBALS['url'] = this_url();
+               message('You must be logged in as an administrator to access that function');
+               return 'login';
+       }
+
+       $ret = _su_main();
+       if($ret) {
+               return $ret;
+       }
+       tem_show('main_body');
+}
+
+function _su_main() {
+       $client_id = format_int($_REQUEST['as']);
+       if($client_id) {
+               session_set('auth_username', $client_id);
+               message('Switched Login');
+               return './';
+       }
+
+       $rows = db_get_rows('people', 'id,name');
+
+       if($rows) foreach($rows as $row) {
+               list($id, $name) = $row;
+               tem_set('client_id', $id);
+               tem_set('client_name', $name);
+               tem_show('su_row');
+       }
+}
+
+?>