library/core/class.plugin.php
public function AutoToggle($Sender, $Redirect = NULL) {
      $PluginName = $this->GetPluginIndex();
      $EnabledKey = "Plugins.{$PluginName}.Enabled";
      $CurrentConfig = C($EnabledKey, FALSE);
      $PassedKey = GetValue(1, $Sender->RequestArgs);
      
      if ($Sender->Form->AuthenticatedPostBack() || Gdn::Session()->ValidateTransientKey($PassedKey)) {
         $CurrentConfig = !$CurrentConfig;
         SaveToConfig($EnabledKey, $CurrentConfig);
      }
      
      if ($Sender->Form->AuthenticatedPostBack())
         $this->Controller_Index($Sender);
      else {
         if ($Redirect === FALSE) return $CurrentConfig;
         if (is_null($Redirect))
            Redirect('plugin/'.strtolower($PluginName));
         else
            Redirect($Redirect);
      }            
      return $CurrentConfig;
   }
public function AutoToggle($Sender, $Redirect = NULL) {
      $PluginName = $this->GetPluginIndex();
      $EnabledKey = "Plugins.{$PluginName}.Enabled";
      $CurrentConfig = C($EnabledKey, FALSE);
      $PassedKey = GetValue(1, $Sender->RequestArgs);
      
      if ($Sender->Form->AuthenticatedPostBack() || Gdn::Session()->ValidateTransientKey($PassedKey)) {
         $CurrentConfig = !$CurrentConfig;
         SaveToConfig($EnabledKey, $CurrentConfig);
      }
      
      if ($Sender->Form->AuthenticatedPostBack())
         $this->Controller_Index($Sender);
      else {
         if ($Redirect === FALSE) return $CurrentConfig;
         if (is_null($Redirect))
            Redirect('plugin/'.strtolower($PluginName));
         else
            Redirect($Redirect);
      }            
      return $CurrentConfig;
   }
public function AutoToggle ( $ Sender , $ Redirect = NULL ) { $ PluginName = $ this -> GetPluginIndex ( ) ; $ EnabledKey = "Plugins.{$PluginName}.Enabled" ; $ CurrentConfig = C ( $ EnabledKey , FALSE ) ; $ PassedKey = GetValue ( 1 , $ Sender -> RequestArgs ) ; if ( $ Sender -> Form -> AuthenticatedPostBack ( ) || Gdn :: Session ( ) -> ValidateTransientKey ( $ PassedKey ) ) { $ CurrentConfig = ! $ CurrentConfig ; SaveToConfig ( $ EnabledKey , $ CurrentConfig ) ; } if ( $ Sender -> Form -> AuthenticatedPostBack ( ) ) $ this -> Controller_Index ( $ Sender ) ; else { if ( $ Redirect === FALSE ) return $ CurrentConfig ; if ( is_null ( $ Redirect ) ) Redirect ( 'plugin/' . strtolower ( $ PluginName ) ) ; else Redirect ( $ Redirect ) ; } return $ CurrentConfig ; }
Automatically handle the toggle effect

@param object $Sender Reference to the invoking controller
@param mixed $Redirect
Automatically handle the toggle effect