function execute( $param ) { global $wgOut, $wgContLang; global $wgUser; # commented out, ignored by FF 3+ anyway # $wgOut->enableClientCache( false ); if ( !$wgUser->isAllowed( 'edit' ) ) { $wgOut->permissionRequired('edit'); return; } if ( is_string( $this->initUser ) ) { # not enough priviledges to run this method $wgOut->addHTML( $this->initUser ); return; } if ( !$wgUser->isAnon() ) { WikiSyncSetup::$remote_wiki_user = $wgUser->getName(); } WikiSyncSetup::headScripts( $wgOut, $wgContLang->isRTL() ); $wgOut->setPagetitle( wfMsgHtml( 'wikisync' ) ); $this->initPageTpl(); $wgOut->addHTML( "\n" ); $wgOut->addHTML( _QXML::toText( $this->page_tpl, 4 ) ); }
/** * @param $args array of AJAX arguments call * @param $min_args minimal number of $args method requires * @return true on success; false on error * @modifies self::$json_result, self::$remoteContextJSON, self::$client_params, self::$directionToLocal */ static function initClient( $args, $min_args, $client_name ) { # use default IIS / Apache execution time limit which is much larger than default PHP limit set_time_limit( 300 ); self::$json_result = new WikiSyncJSONresult(); if ( count( $args ) < $min_args ) { self::$json_result->setCode( 'init_client', 'Not enough number of parameters in ' . __METHOD__ ); return false; } # remote context; used for remote API calls self::$remoteContextJSON = $args[0]; self::$client_params = FormatJson::decode( $args[1], true ); if ( ($check_result = self::checkClientParameters( $client_name )) !== true ) { self::$json_result->setCode( 'init_client', $check_result ); return false; } if ( !isset( self::$client_params['direction_to_local'] ) ) { self::$json_result->setCode( 'init_client', 'direction_to_local was not passed for ' . $client_name ); return false; } self::$directionToLocal = self::$client_params['direction_to_local']; if ( is_string( $iu = WikiSyncSetup::initUser( self::$directionToLocal ) ) ) { # not enough priviledges to run this method self::$json_result->setCode( 'noaccess', $iu ); return false; } return true; }
/** * should not be called from LocalSettings.php * should be called only when the wiki is fully initialized * @param $direction defines the direction of synchronization * true - from remote to local wiki * false - from local to remote wiki * null - direction is undefined yet (any direction) * @return true, when the current user has access to synchronization; * string error message, when the current user has no access */ static function initUser( $direction = null ) { global $wgUser, $wgRequest; self::$user = is_object( $wgUser ) ? $wgUser : new User(); self::$response = $wgRequest->response(); self::$cookie_prefix = 'WikiSync_' . md5( self::$user->getName() ) . '_'; if ( self::$user->getName() !== self::WIKISYNC_BOT_NAME ) { return wfMsg( 'wikisync_unsupported_user', self::WIKISYNC_BOT_NAME ); } if ( $direction === true ) { return self::checkUserMembership( self::$rtl_access_groups ); } elseif ( $direction === false ) { return self::checkUserMembership( self::$ltr_access_groups ); } elseif ( $direction === null ) { $groups = array_merge( self::$rtl_access_groups, self::$ltr_access_groups ); return self::checkUserMembership( $groups ); } return 'Bug: direction should be boolean or null, value (' . $direction . ') given in ' . __METHOD__; }