$oldPageInfo = $sourcePage->get(); $oldpagepid = $oldPageInfo["ID"]; $TargetPageMgr = new PageMgr($targetsite); $rSub = $TargetPageMgr->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $target, "RSUB"); $rDelete = $SourcePageMgr->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $source, "RDELETE"); $rWrite = $SourcePageMgr->permissions->checkInternal(sUserMgr()->getCurrentUserID(), $source, "RWRITE"); if ($rSub && $rDelete && $rWrite) { $copyjobs = $SourcePageMgr->getList($oldpage); $copystarted = false; $idmap = array(); for ($i = 0; $i < count($copyjobs); $i++) { if ($copyjobs[$i]["ID"] == $oldpage) { if ($copystarted === false) { $rootlevel = $copyjobs[$i]["LEVEL"]; $copystarted = true; $newPageID = $TargetPageMgr->add($target); $newPage = $TargetPageMgr->getPage($newPageID); $newPage->copyFrom($sourcePage); $idmap[$oldpage] = $newPageID; // Inherit permissions of the parent of the newly created copy $allPerms = $sourcePage->permissions->getPermissions(); $newPage->permissions->clear(); $newPage->permissions->setPermissions($allPerms, $newPageID); // Copy blind contentblocks $pageInfo = $sourcePage->get(); $contentareas = $templateMgr->getContentareas($pageInfo['TEMPLATEID']); for ($j = 0; $j < count($contentareas); $j++) { $pagelist = $sourcePage->getCblockList($contentareas[$j]['CODE']); for ($x = 0; $x < count($pagelist); $x++) { $coid = $pagelist[$x]['OBJECTID']; // Check if we have a blind contentblock