Esempio n. 1
0
	/** 
	 * Launch a sitepage-variation.
	 * @param integer ID of the sitepage to launch.
	 * @param integer ID of the level to launch to.
	 * @param integer ID of the Variation to launch.
	 */
	function launchSitepage($in, $level, $variation) {
		global $db, $c;
		$out = translateState($in, $level);

		//removeDynamicCache();		
		delExpired ($out);
		$sql = "SELECT * FROM sitepage WHERE SPID = $in";
		$query = new query($db, $sql);
		$query->getrow();
		$spm = $query->field("SPM_ID");
		$menu = $query->field("MENU_ID");
		$cln = $query->field("CLNID");
		$posi = $query->field("POSITION");
		$ldate = "'" . $query->field("LAUNCH_DATE"). "'";
		$edate = "'" . $query->field("EXPIRE_DATE"). "'";
		$pwp   = $query->field("PASSWORD_PROTECTED");
		if ($ldate == "''")
			$ldate = "NULL";

		if ($edate == "''")
			$edate = "NULL";

		$spmTrans = launchSitepageMaster($spm, $level, $variation);
		$clnTrans = launchCluster($cln, $level, $variation);
		$menuTrans = launchSitemap($menu, $level, $variation);
		launchSitepageOwner($in, $level);
		launchSitepageName($in, $level, $variation);
		$sql = "DELETE FROM sitepage WHERE SPID = $out";
		$query = new query($db, $sql);
		$sql = "INSERT INTO sitepage (SPID, SPM_ID, MENU_ID, POSITION, CLNID, LAUNCH_DATE, EXPIRE_DATE, DELETED, VERSION, PASSWORD_PROTECTED) VALUES ";
		$sql .= "($out, $spmTrans, $menuTrans, $posi, $clnTrans, $ldate, $edate, 0, $level, $pwp)";
		$query = new query($db, $sql);
		$query->free();

		// rebuild menu-structure...
		rebuildMenuStructure ($menu);

		// cache rebuild
	
		global $JPCACHE_ON;
		if ($JPCACHE_ON) {
		  @unlink($c["dyncachepath"]."dyncache-".jpcacheFilename($out, $variation));	
		}

	
		$cached = getDBCell("sitemap", "IS_CACHED", "MENU_ID = " . $menuTrans);
		if ($cached == 1) {
			if ($JPCACHE_ON  && !$c["renderstatichtml"]) {
		 		  @unlink($c["dyncachepath"]."dyncache-".jpcacheFilename($out, $variation));	
			}	else if ($c["renderstatichtml"]) {
			    @unlink($c["cachepath"]."static/dyncache-".jpcacheFilename($out, $variation));				
			}		
		}
	}
Esempio n. 2
0
/**
* Launch a Cluster-Variation
* @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 launchClusterVariation($in, $level, $variation)
{
    global $db, $auth;
    $out = translateState($in, $level);
    $sql = "SELECT CLID, LAST_CHANGED, CREATED_AT FROM cluster_variations WHERE CLNID = {$in} AND VARIATION_ID = {$variation}";
    $query = new query($db, $sql);
    $query->getrow();
    $clid = $query->field("CLID");
    $createdAt = $query->field("CREATED_AT");
    $lastChanged = $query->field("LAST_CHANGED");
    if ($clid == "" && $variation != 1) {
        $sql = "SELECT CLID, LAST_CHANGED, CREATED_AT FROM cluster_variations WHERE CLNID = {$in} AND VARIATION_ID = 1";
        $query = new query($db, $sql);
        $query->getrow();
        $clid = $query->field("CLID");
        $lastChanged = $query->field("LAST_CHANGED");
        $createdAt = $query->field("CREATED_AT");
        $variation = 1;
    }
    if ($lastChanged == "") {
        $lastChanged = "NULL";
    }
    if ($createdAt == "") {
        $createdAt = "NULL";
    }
    if ($clid != "") {
        $clidTrans = translateState($clid, $level, false);
        delExpired($clidTrans);
        $sql = "DELETE FROM cluster_variations WHERE CLID = {$clidTrans} AND VARIATION_ID = {$variation}";
        $query = new query($db, $sql);
        $sql = "INSERT INTO cluster_variations (CLNID, VARIATION_ID, CLID, DELETED, LAST_CHANGED, CREATED_AT) VALUES ";
        $sql .= "({$out}, {$variation}, {$clidTrans}, 0, {$lastChanged}, {$createdAt})";
        $query = new query($db, $sql);
        // delete the old cluster content
        $sql = "DELETE FROM cluster_content WHERE CLID = {$clidTrans}";
        $query = new query($db, $sql);
        // launch the content now.
        $sql = "SELECT CLCID FROM cluster_content WHERE CLID = {$clid}";
        $query = new query($db, $sql);
        while ($query->getrow()) {
            launchClusterContent($query->field("CLCID"), $level, $variation);
        }
        $query->free();
        $sql = "UPDATE cluster_variations SET LAUNCHED_AT = NOW()+0, LAUNCH_USER = '******' WHERE CLID = {$clid}";
        $query = new query($db, $sql);
        $query->free();
    }
    return $out;
}