/**
  * runs when the API is called with "clicktracking", takes in "eventid" and an edit token given to the user, "token"
  * @see includes/api/ApiBase#execute()
  */
 public function execute()
 {
     global $wgUser, $wgTitle, $wgClickTrackContribGranularity1, $wgClickTrackContribGranularity2, $wgClickTrackContribGranularity3;
     $params = $this->extractRequestParams();
     $this->validateParams($params);
     $eventid_to_lookup = $params['eventid'];
     $session_id = $params['token'];
     // Event ID lookup table
     // FIXME: API should already have urldecode()d
     $event_id = ClickTrackingHooks::getEventIDFromName(urldecode($eventid_to_lookup));
     $is_logged_in = $wgUser->isLoggedIn();
     $now = time();
     $granularity1 = $is_logged_in ? ClickTrackingHooks::getEditCountSince($now - $wgClickTrackContribGranularity1) : 0;
     $granularity2 = $is_logged_in ? ClickTrackingHooks::getEditCountSince($now - $wgClickTrackContribGranularity2) : 0;
     $granularity3 = $is_logged_in ? ClickTrackingHooks::getEditCountSince($now - $wgClickTrackContribGranularity3) : 0;
     ClickTrackingHooks::trackEvent($session_id, $is_logged_in, $wgTitle->getNamespace(), $event_id, $is_logged_in ? $wgUser->getEditCount() : 0, $granularity1, $granularity2, $granularity3);
     // For links that go off the page, redirect the user
     // FIXME: The API should have a proper infrastructure for this
     if (!is_null($params['redirectto'])) {
         global $wgOut;
         $wgOut->enable();
         $wgOut->redirect($params['redirectto']);
         $wgOut->output();
     }
 }