support delete of test accounts
authorDave Cohen
Thu, 17 Mar 2011 18:06:08 +0000 (11:06 -0700)
committerDave Cohen
Thu, 17 Mar 2011 18:06:08 +0000 (11:06 -0700)
contrib/fb_test.module

index 1ebb645..0d10455 100644 (file)
@@ -43,7 +43,7 @@ function fb_test_create_form(&$form, &$form_state, $fb_app) {
 
   // Which permissions?
   $perms = array();
-  drupal_alter('fb_required_perms', $perms);
+  drupal_alter('fb_required_perms', $perms); // @TODO pass fb_app to this function.
   if (count($perms)) {
     $default_perms = implode(',', $perms);
   }
@@ -105,7 +105,7 @@ function fb_test_accounts_form($form, &$form_state, $fb_app) {
 
       $options[$test_account['id']] = $markup;
     }
-    if (count($options)) {
+    if (!empty($options)) {
       $form['checkboxes'] = array(
         '#type' => 'checkboxes',
         '#options' => $options,
@@ -174,6 +174,18 @@ function fb_test_accounts_form_submit($form, &$form_state) {
         }
       }
     }
+    elseif ($values['operation'] == 'delete') {
+      foreach ($values['checkboxes'] as $fbu => $selected) {
+        if ($selected) {
+          $result = $fb->api($fbu, 'DELETE', array('access_token' => fb_get_token($fb)));
+          if ($result) {
+            drupal_set_message(t('Deleted test account %fbu', array(
+                                   '%fbu' => $fbu,
+                                 )));
+          }
+        }
+      }
+    }
     else {
       dpm("Operation $values[operation] not implemented.", __FUNCTION__); // debug
     }