/**
  * API clicktracking action
  *
  * Parameters:
  * 		eventid: event name
  * 		token: unique identifier for a user session
  *
  * @see includes/api/ApiBase#execute()
  */
 public function execute()
 {
     global $wgUser, $wgClickTrackContribGranularity1, $wgClickTrackContribGranularity2, $wgClickTrackContribGranularity3;
     $params = $this->extractRequestParams();
     $eventid_to_lookup = $params['eventid'];
     $sessionId = $params['token'];
     $namespace = $params['namespacenumber'];
     $additional = null;
     if (isset($params['additional']) && strlen($params['additional']) > 0) {
         $additional = $params['additional'];
     }
     // FIXME: API should already have urldecode()d
     $eventName = urldecode($eventid_to_lookup);
     $isLoggedIn = $wgUser->isLoggedIn();
     $now = time();
     $granularity1 = $isLoggedIn ? getUserEditCountSince($now - $wgClickTrackContribGranularity1) : 0;
     $granularity2 = $isLoggedIn ? getUserEditCountSince($now - $wgClickTrackContribGranularity2) : 0;
     $granularity3 = $isLoggedIn ? getUserEditCountSince($now - $wgClickTrackContribGranularity3) : 0;
     ClickTrackingHooks::trackEvent($sessionId, $isLoggedIn, (int) $namespace, $eventName, $isLoggedIn ? $wgUser->getEditCount() : 0, $granularity1, $granularity2, $granularity3, $additional);
     // 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'])) {
         $href = $params['redirectto'];
         global $wgOut;
         $wgOut->redirect($params['redirectto']);
         $wgOut->output();
         // Prevent any further output
         $wgOut->disable();
         $this->getMain()->getPrinter()->disable();
     }
 }
 /**
  * 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();
     }
 }
 /**
  * Adds JavaScript
  */
 public static function addJS()
 {
     global $wgClickTrackingStyleVersion;
     // HACK: Only add scripts when they're really needed by not initializing UIH here
     //UsabilityInitiativeHooks::initialize();
     UsabilityInitiativeHooks::addScript('ClickTracking/ClickTracking.js', $wgClickTrackingStyleVersion);
     UsabilityInitiativeHooks::addVariables(array('wgTrackingToken' => ClickTrackingHooks::get_session_id(), 'wgClickTrackingIsThrottled' => ClickTrackingHooks::isUserThrottled()));
     return true;
 }
 *
 * @file
 * @ingroup Extensions
 * @version 0.1.0
 * @author Nimish Gautam
 * @link http://www.mediawiki.org/wiki/Extension:CustomUserSignup Documentation
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 */
if (!defined('MEDIAWIKI')) {
    die('This is not a valid entry point to MediaWiki.');
}
// Extension credits that will show up on Special:Version
$wgExtensionCredits['other'][] = array('path' => __FILE__, 'name' => 'CustomUserSignup', 'author' => 'Nimish Gautam', 'version' => '0.1.0', 'descriptionmsg' => 'customusersignup-desc', 'url' => 'https://www.mediawiki.org/wiki/Extension:CustomUserSignup');
// Autoloading
$dir = dirname(__FILE__) . '/';
$wgAutoloadClasses['CustomUserSignupHooks'] = $dir . 'CustomUserSignup.hooks.php';
$wgAutoloadClasses['CustomUserloginTemplate'] = $dir . 'CustomUserTemplate.php';
$wgAutoloadClasses['CustomUsercreateTemplate'] = $dir . 'CustomUserTemplate.php';
$wgExtensionMessagesFiles['CustomUserSignup'] = $dir . 'CustomUserSignup.i18n.php';
// Hooks
$wgHooks['UserCreateForm'][] = 'CustomUserSignupHooks::userCreateForm';
$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm';
$wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen';
// NOTE: This hook includes JS for the account creation project
$wgHooks['BeforePageDisplay'][] = 'CustomUserSignupHooks::beforePageDisplay';
$wgHooks['AddNewAccount'][] = 'CustomUserSignupHooks::addNewAccount';
$wgCustomUserSignupVersion = 1;
$wgCustomUserSignupSetBuckets = true;
// For Account Creation Project
ClickTrackingHooks::addCampaign($dir . 'modules', 'CustomUserSignup/modules', 'AccountCreationUserBucket');
 public static function addNewAccount($user, $byEmail)
 {
     global $wgRequest, $wgTitle;
     $buckets = ClickTrackingHooks::unpackBucketInfo();
     if (isset($buckets['AccountCreation']) && $buckets['AccountCreation'][0] != "none") {
         // *NOT HTTPONLY* In fact, that's the point of this cookie
         setcookie('acctcreation', $buckets['AccountCreation'][0], time() + 60 * 60 * 24 * 365, '/');
         $session = $wgRequest->getCookie('clicktracking-session', "");
         if ($session !== null) {
             $params = new FauxRequest(array('action' => 'clicktracking', 'eventid' => 'account-created', 'token' => $session, 'info' => 'account-activity', 'namespacenumber' => $wgTitle->getNamespace()));
             $api = new ApiMain($params, true);
             $api->execute();
         }
     }
     return true;
 }