/**
	 * @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;
	}
Пример #2
0
	function __construct() {
		parent::__construct( 'WikiSync', 'edit' );
		$this->initUser = WikiSyncSetup::initUser();
	}