Ejemplo n.º 1
0
	/**
	 * Handler for creating a valid contentpage for a site.
	 */
	function createContentPage() {
		global $oid, $db, $variation, $auth;

		$checked = value("createpage");

		if ($checked) {
			$spm = value("sitemap_SPM_ID");

			// determine spm-type
			$type = getDBCell("sitepage_master", "SPMTYPE_ID", "SPM_ID = $spm");
			$clt = getDBCEll("sitepage_master", "CLT_ID", "SPM_ID = $spm");

			if ($type == 1) {
				// create contentpage
				$name = value("sitemap_NAME");

				if ($name == "")
					$name = "Cluster";

				$usename = makeCopyName("cluster_node", "NAME", $name, $filter = "CLT_ID = $clt", "", false);

				$nextId = nextGUID();
				$sql = "INSERT INTO cluster_node (CLNID, CLT_ID, NAME, DELETED) VALUES($nextId, $clt, '$usename', 0)";

				$query = new query($db, $sql);
				$spid = getDBCell("sitepage", "SPID", "MENU_ID = $oid");
				$sql = "UPDATE sitepage SET CLNID = $nextId WHERE SPID = $spid";

				$query = new query($db, $sql);
				$query->free();

				$variations = createDBCArray("sitepage_variations", "VARIATION_ID", "SPM_ID = $spm");

				for ($i = 0; $i < count($variations); $i++) {
					$fk = nextGUID();
					$sql = "INSERT INTO cluster_variations (CLNID, VARIATION_ID, CLID, DELETED, CREATE_USER, CREATED_AT ) VALUES ( $nextId, $variations[$i], $fk, 0, '$auth->userName', Now()+0)";
					$query = new query($db, $sql);
				}

				$query->free();
				global $errors, $sid, $c, $mid;
				if ($errors == "") {
					header ("Location: " . $c["docroot"] . "modules/sitepages/sitepagebrowser.php?sid=$sid&go=update&action=editobject&oid=$spid&mid=$oid");
					exit;
				}				
			}
		}
	}
		if ($action =="") $action = value("acstate");
		$page_action = "UPDATE";

		// Fetch variables
		$view = initValue("view", doc()."view", 1);

		if ($view == "0")
			$view = 1;

		$oid = value("oid", "NUMERIC");

		if ($action == "pproperties" || (value("acstate") == "pproperties")) {
			// oid containes $menuID;
			$menuID = $oid;
			$spm = getDBCell("sitemap", "SPM_ID", "MENU_ID = $menuID");
			$clt = getDBCEll("sitepage_master", "CLT_ID", "SPM_ID = $spm");
			$type = getDBCell("sitepage_master", "SPMTYPE_ID", "SPM_ID = $spm");
			$spid = getDBCell("sitepage", "SPID", "MENU_ID = $menuID");

			if ($type == 1) {
				$clnid = getDBCell("sitepage", "CLNID", "MENU_ID = $menuID");

				if ($clnid != "0" && $clnid != 0) {
					$clid = getDBCell("cluster_variations", "CLID", "CLNID = $clnid AND VARIATION_ID = $variation");
				}
			}
		} else {
			$spid = value("oid", "NUMERIC");

			if ($spid != "") {
				$clnid = getDBCell("sitepage", "CLNID", "SPID = $spid");