support for listing and revoking openid trust relationships
smbaker [Tue, 12 Feb 2013 01:38:32 +0000 (17:38 -0800)]
apps/gacksadmin/action.php
apps/gacksadmin/gacks_functions.php
apps/gacksadmin/user_openid.php [new file with mode: 0644]

index e8ef4c3..7fe09ac 100644 (file)
@@ -42,7 +42,10 @@ if (!$action) {
   }
 }
 
-$person_id = $_POST['person_id'];       // usually needed
+// find person roles
+$_person= $plc->person;\r
+$_person_id = $plc->person['person_id'];\r
+$_roles= $_person['role_ids'];
 
 if ( ! $action ) {
   drupal_set_message ("actions.php: action not set or not in known_actions");\r
@@ -360,7 +363,7 @@ try {
             break;
         }
 
-        case 'download-nodelist':
+        case 'download-nodelist': {
             $account_name = get_query_arg('account_name');
             $slices=$api->GetSlices($account_name);
             if ($slices) {
@@ -374,6 +377,7 @@ try {
                 exit();
             }
             break;
+        }
 
         case 'set-advanced': {
             $value = get_query_arg("value");
@@ -386,6 +390,24 @@ try {
             break;
         }
 
+        case 'forget-trust': {
+            $tags = $api->GetPersonTags(array("person_id" => $_person_id, "tagname" => "allow_trust_root"));
+            $trust_root = get_query_arg("trust_root");
+            if ($tags) {
+                $tag = $tags[0];
+                $trust_roots = explode(",",$tag["value"]);
+                if (in_array($trust_root, $trust_roots)) {
+                    $index = array_search($trust_root, $trust_roots);
+                    unset($trust_roots[$index]);
+                    $value = implode(",", $trust_roots);
+                    $api->UpdatePersonTag($tag["person_tag_id"], $value);
+                    drupal_set_message ('Trust association removed');
+                }
+                plc_redirect("/db/gacks/user_openid.php");
+            }
+            break;
+        }
+
         default: {
             plc_error ("Unknown action $action in actions.php");\r
             return;\r
index d53a2c4..e7778b5 100644 (file)
@@ -43,6 +43,7 @@ function l_gacks_add_reservation() { return "/db/gacks/user_add_reservation.php"
 function l_gacks_persons()         { return "/db/gacks/user_persons.php"; }
 function l_gacks_advanced($value, $url)        { $eurl=urlencode($url); return "/db/gacks/action.php?action=set-advanced&value=$value&url=$eurl"; }
 function l_gacks_summary()         { return "/db/gacks/user_summary.php"; }
+function l_gacks_forget_trust($trust_root) { return "/db/gacks/action.php?action=forget-trust&trust_root=" . $trust_root; }
 
 function gacksid($x) { return "gacksid:" . $x; }
 
diff --git a/apps/gacksadmin/user_openid.php b/apps/gacksadmin/user_openid.php
new file mode 100644 (file)
index 0000000..19b63f4
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+// this must occur before linetabs.php, or linetabs won't work. I have no idea why.
+drupal_add_js("misc/popup.js");
+
+// Require login
+require_once 'plc_login.php';
+
+// Get session and API handles
+require_once 'plc_session.php';
+global $plc, $api, $adm;
+
+// Common functions
+require_once 'plc_functions.php';
+require_once 'plc_peers.php';
+require_once 'gacks_functions.php';
+require_once 'gacksclient.php';
+require_once 'linetabs.php';
+require_once 'table.php';
+require_once 'details.php';
+require_once 'toggle.php';
+require_once 'form.php';
+require_once 'nifty.php';
+
+// find person roles
+$_person= $plc->person;
+$_person_id = $plc->person['person_id'];
+$_roles= $_person['role_ids'];
+
+// Print header
+require_once 'plc_drupal.php';
+drupal_set_title('Manage Authorized Access');
+include 'plc_header.php';
+
+$headers=array();
+$headers['site']='string';
+$headers['action']='string';
+$table=new PlekitTable('Connected Sites, Apps, and Services',$headers,'0');
+
+$tags = $api->GetPersonTags(array("person_id" => $_person_id, "tagname" => "allow_trust_root"));
+if ($tags) {
+    $value = $tags[0]["value"];
+    if ($value) {
+        $trust_roots = explode(",",$tags[0]["value"]);
+        $table->start();
+        foreach ($trust_roots as $trust_root) {
+            $table->row_start();
+            $table->cell($trust_root . " - Sign in using your Vicci account");
+            $table->cell(href(l_gacks_forget_trust($trust_root), "revoke"));
+            $table->row_end();
+        }
+        $table->end();
+    }
+}
+
+include 'plc_footer.php';
+
+?>
+
+