예제 #1
0
function doCopy( $dmid_dirty, $dc1_dirty, $dc2_dirty ) {
	$dmid = mysql_real_escape_string( $dmid_dirty );
	$dc1 = mysql_real_escape_string( $dc1_dirty );
	$dc2 = mysql_real_escape_string( $dc2_dirty );

	CopyTools::newCopyTransaction( $dc1, $dc2 );

	$dmc = new DefinedMeaningCopier( $dmid, $dc1, $dc2 );
	$dmc->dup();

	return true; # seems everything went ok.

}
예제 #2
0
	/**
	 * A combination function to handle all the steps needed to check
	 * and copy a Defined Meaning (DM)
	 * So we have a row in the source (dc1) table, which has a column
	 * referring to a defined meaning
	 * Before the row can be stored in the destination dataset, 
	 * we should
	 * - Ensure that at least a stub of this defined meaning exists
	 * - make sure that the row refers to the dmid in the *destination* dataset (dc2),
	 *   instead of the source dataset (dc1).
	 * - returns True if the defined meaning was already_there().
	 * @param &$row : row to operate on, passed by reference
	 * @param $dmid_colum: a column in said row, containing the dmid to operate on
	 * @param $full=false (optional) : if true, does a dup instead of a dup_stub
	 * @return true if the updated dmid already existed in the destination (dc2) dataset before now
	 *	   false if it did not, and we just created it
	 */
	protected function doDM( &$row, $dmid_column, $full = false ) {
		if ( $row[$dmid_column] == 0 or is_null( $row[$dmid_column] ) )
			return true;

		$dmCopier = new DefinedMeaningCopier( $row[$dmid_column], $this->dc1, $this->dc2 );
		if ( $full ) {
			$row[$dmid_column] = $dmCopier->dup();
		} else {
			$row[$dmid_column] = $dmCopier->dup_stub();
		}
		return $dmCopier->already_there();
	}
예제 #3
0
	protected function _doCopy( $dmid_dirty, $dc1_dirty, $dc2_dirty ) {
		global
			$wgCommunityEditPermission, $wgOut, $wgUser, $wgCommunity_dc;
		
		# escape parameters
		$dmid = mysql_real_escape_string( $dmid_dirty );
		$dc1 = mysql_real_escape_string( $dc1_dirty );
		$dc2 = mysql_real_escape_string( $dc2_dirty );

		# check permission
		if ( !( $wgUser->isAllowed( 'wikidata-copy' ) ) or $dc2 != $wgCommunity_dc ) {
			$wgOut->addHTML( wfMsgSc( "Permission_denied" ) );
			return false; # we didn't perform the copy.
		}

		# copy
		CopyTools::newCopyTransaction( $dc1, $dc2 );
		$dmc = new DefinedMeaningCopier( $dmid, $dc1, $dc2 );
		$dmc->dup();

		# For purposes of current "edit copy", 
		# having the dm be already_there() is ok.
		# (hence commented out)
		# if ($dmc->already_there() ) {
		#	$wgOut->addHTML(wfMsgSc("already_there"));
		#	return false;
		# }

		return true; # seems everything went ok.

	}