/**
 * Translate an old into a new GUID
 * @param integer old GUID
 * @param boolean set AntiCycle
 */
function translateXmlGUID($oldId)
{
    global $db, $provider, $c;
    if ($oldId < 1000) {
        // System data.
        $out = $oldId;
    } else {
        if (strtoupper($provider) == strtoupper($c["provider"])) {
            // own data.
            $out = $oldId;
        } else {
            $provider = strtoupper(parseSQL($provider));
            resetDBCache();
            $out = getDBCell("syndication", "OUT_ID", "IN_ID = {$oldId} AND PROVIDER = '{$provider}'");
            if ($out == "") {
                $out = nextGUID();
                $sql = "INSERT INTO syndication (IN_ID, OUT_ID, PROVIDER) VALUES ({$oldId}, {$out}, '{$provider}')";
                $query = new query($db, $sql);
                $query->free();
            }
        }
    }
    return $out;
}
/**
 * Checks, whether a resource has once been imported or not.
 * @param integer GUID of the Resource to import
 */
function syndicateImported($guid)
{
    global $imported;
    resetDBCache();
    $trans = translateXmlGUID($guid);
    if (getTypeByGUID($trans) != "") {
        return true;
    }
    $imported++;
    return false;
}
Example #3
0
	/**
	 * Creates a new unique name for a copied item by adding an incrementing number to the name.
	 *
	 * @param string Name of table in which row shall be copied
	 * @param string Column in which the name shall be looked for
	 * @param string new name for the item
	 * @param string SQL-Where-Clause compatible filter
	 * @param string prefix to add to the beginning of the new name
	 * @param boolean specifies if the prefix is added also if $newName is already unique
	 */
	function makeCopyName($table, $nameColumn, $newName, $filter = "1", $prefix = "", $forceprefix = true) {
		if ($filter != "")
			$filter = $filter . " AND ";
		if ($forceprefix)
			$newName = $prefix . $newName;
		$tryName = $newName;
		$count = 2;
		resetDBCache();
		while (getDBCell($table, $nameColumn, $filter . $nameColumn . " = '$tryName'") != "") {
			$tryName = $prefix . $newName . " ($count)";
			$count++;
		}
		$newName = $tryName;
		return $newName;
	}