/** * Monitors edit page usage */ public static function onEditForm(EditPage $editPage) { global $wgUser, $wgEditPageTrackingRegistrationCutoff, $wgMemc; // Anonymous users if ($wgUser->isAnon()) { return true; } if ($wgEditPageTrackingRegistrationCutoff && $wgUser->getRegistration() < $wgEditPageTrackingRegistrationCutoff) { // User registered before the cutoff return true; } if (EditPageTracking::getFirstEditPage($wgUser)) { // Already stored. return true; } // Record it $dbw = wfGetDB(DB_MASTER); $title = $editPage->getArticle()->getTitle(); $timestamp = wfTimestampNow(); $row = array('ept_user' => $wgUser->getId(), 'ept_namespace' => $title->getNamespace(), 'ept_title' => $title->getDBkey(), 'ept_timestamp' => $dbw->timestamp($timestamp)); $dbw->insert('edit_page_tracking', $row, __METHOD__); $wgUser->mFirstEditPage = $timestamp; $cacheKey = wfMemcKey('first-edit-page', $wgUser->getId()); $wgMemc->set($cacheKey, $timestamp, 86400); return true; }
/** * Determines whether or not we should show the MoodBar. * * @param $output OutputPage * @param $skin Skin */ public static function shouldShowMoodbar(&$output, &$skin) { // Front-end appends to header elements, which have different // locations and IDs in every skin. // Untill there is some kind of central registry of element-ids // that skins implement, or a fixed name for each of them, just // show it in Vector for now. if ($skin->getSkinName() !== 'vector') { return false; } global $wgUser; $user = $wgUser; if ($user->isAnon()) { return false; } // Only show MoodBar for users registered after a certain time global $wgMoodBarCutoffTime; if ($wgMoodBarCutoffTime && $user->getRegistration() < $wgMoodBarCutoffTime) { return false; } if (class_exists('EditPageTracking')) { return (bool) EditPageTracking::getFirstEditPage($user); } return true; }