/**
 * Launch a Sitepage-MAster
 * @param integer SPM_ID to launch
 * @param integer ID of the level to launch to.
 * @param integer ID of the variation to launch. 
 * @returns integer Translated ID after launch
 */
function launchSitepageMaster($in, $level, $variation)
{
    global $db;
    $out = translateState($in, $level, false);
    $sql = "SELECT * FROM sitepage_master WHERE SPM_ID = {$in}";
    $query = new query($db, $sql);
    $query->getrow();
    $clt = $query->field("CLT_ID");
    $type = $query->field("SPMTYPE_ID");
    $name = addslashes($query->field("NAME"));
    $desc = addslashes($query->field("DESCRIPTION"));
    $path = addslashes($query->field("TEMPLATE_PATH"));
    $cltTrans = launchClusterTemplate($clt, $level, $variation);
    $sql = "DELETE FROM sitepage_master WHERE SPM_ID = {$out}";
    $query = new query($db, $sql);
    $sql = "INSERT INTO sitepage_master (SPM_ID, NAME, DESCRIPTION, TEMPLATE_PATH, CLT_ID, SPMTYPE_ID, DELETED, VERSION) VALUES ";
    $sql .= "({$out}, '{$name}', '{$desc}', '{$path}', {$cltTrans}, {$type}, 0, {$level})";
    $query = new query($db, $sql);
    $query->free();
    // copy template physically.
    global $c;
    if (file_exists($c["devpath"] . $path)) {
        nxDelete($c["livepath"], $path);
        nxCopy($c["devpath"] . $path, $c["livepath"], $path);
    }
    launchSPMVariations($in, $level);
    return $out;
}
예제 #2
0
/**
 * Launch a Cluster
 * @param integer CLNID to launch
 * @param integer ID of the level to launch to.
 * @param integer ID of the variation to launch. 
 * @returns integer Translated ID after launch
 */
function launchCluster($in, $level, $variation)
{
    global $db;
    if (!checkACL($in)) {
        $out = translateState($in, $level);
        $sql = "SELECT * FROM cluster_node WHERE CLNID = {$in}";
        $query = new query($db, $sql);
        $query->getrow();
        $clt = $query->field("CLT_ID");
        $name = addslashes($query->field("NAME"));
        $cltTrans = launchClusterTemplate($clt, $level, $variation);
        $sql = "DELETE FROM cluster_node WHERE CLNID = {$out}";
        $query = new query($db, $sql);
        $sql = "INSERT INTO cluster_node (CLNID, CLT_ID, NAME, DELETED, VERSION) VALUES ";
        $sql .= "({$out}, {$cltTrans}, '{$name}', 0, {$level})";
        $query = new query($db, $sql);
        launchClusterVariation($in, $level, $variation);
        // launch meta
        $sql = "SELECT MID FROM meta WHERE CID = {$in} AND DELETED=0";
        $query = new query($db, $sql);
        while ($query->getrow()) {
            launchMeta($query->field("MID"), $level);
        }
        $query->free();
        return $out;
    } else {
        return translateState($in, $level);
    }
}