JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
added Switch Login page and link
authorJason Woofenden <jason283@herkamire.com>
Sun, 16 Nov 2008 07:09:35 +0000 (02:09 -0500)
committerJason Woofenden <jason283@herkamire.com>
Sun, 16 Nov 2008 07:09:35 +0000 (02:09 -0500)
index.html
index.php
people.php
su.html [new file with mode: 0644]
su.php [new file with mode: 0644]

index d623af8..0e16cec 100644 (file)
@@ -13,7 +13,7 @@
 
   <p>This page is for giving Jason Woofenden work and figuring out the details of the associated tasks, costs and priorities.</p>
 
-  <p><a href="tasks?tasks_new=1">Add a task</a> &bull; <a href="tasks?tasks_new_bug=1">Report a problem</a><!-- &bull; <a href="pay">Pay Jason</a>--></p>
+  <p><a href="tasks?tasks_new=1">Add a task</a> &bull; <a href="tasks?tasks_new_bug=1">Report a problem</a><!--~su_link start~--> &bull; <a href="su">Switch login</a><!--~end~--><!-- &bull; <a href="pay">Pay Jason</a>--></p>
 
   <!--~needs_attention_header start~-->
     <h3>Tasks needing your attention:</h3>
index 91c24ee..b156cb7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -51,6 +51,7 @@ function _index_main() {
        }
 
        if(logged_in_as_contractor()) {
+               tem_show('su_link');
                tem_show('needs_attention_header');
                task_summary('needs_approval', 'where state=%i order by id desc', TASK_WORKING);
                task_summary('needs_fixing', 'where (state=%i || state=%i) || (client_id=1 && state<%i) order by id desc', TASK_NEEDS_QUOTE, TASK_BUG, TASK_QUEUED);
index 1690a4b..9a0f3a4 100644 (file)
@@ -70,7 +70,7 @@ function people_display_listing($where = 'order by username limit 100') {
 }
 
 function people_main() {
-       if(logged_in() != 1) { # FIXME get more sophisticated than first person in database is admin
+       if(!logged_in_as_contractor()) {
                $GLOBALS['url'] = this_url();
                message('You must be logged in as an administrator to access that function');
                return 'login';
diff --git a/su.html b/su.html
new file mode 100644 (file)
index 0000000..5e46932
--- /dev/null
+++ b/su.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+  <title>people entry</title>
+  <link rel="stylesheet" href="style.css" type="text/css" />
+</head>
+
+<body>
+  <!--~main_body start~-->
+  <h2>SU to be logged in as someone else</h2>
+
+  <!--~su_row start~-->
+    <p><a href="su?as=~client_id~">log in as ~client_name~</a></p>
+  <!--~end~-->
+
+<!--~end~-->
+</body>
+</html>
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');
+       }
+}
+
+?>