// make a copy of the origional to delete later. if (version_compare(phpversion(), '5.0') < 0) { eval(' function clone($object) { return $object; } '); } $origPartObj = clone $partObj; if ($_REQUEST['site'] == $_SESSION['origSite']) { $keepaddedby = 1; } else { $keepaddedby = 0; } // build a site hash makeSiteHash($_SESSION['origSiteObj']); // Make sure that we have our "NEXT" value set for the object we are copying. if ($_SESSION['type'] == "section") { $GLOBALS['__site_hash']['sections'][$partObj->id] = 'NEXT'; } else { if ($_SESSION['type'] == "page") { $GLOBALS['__site_hash']['pages'][$partObj->id] = 'NEXT'; } else { if ($_SESSION['type'] == "story") { $GLOBALS['__site_hash']['stories'][$partObj->id] = 'NEXT'; } } } if ($_REQUEST['keep_discussions'] == 'no') { $keepDiscussion = FALSE; } else {
function copySite($newName, $clearPermissions = 1, $copyDiscussions = FALSE) { if ($newName == $this->name) { return FALSE; } if ($newName == "" || !$newName) { return FALSE; } $oldName = $this->name; $this->fetchSiteAtOnceForeverAndEverAndDontForgetThePermissionsAsWell_Amen(); // Make a hash array of site, section, and page ids so that makeSiteHash($this); $newSiteObj = $this; $newSiteObj->setSiteName($newName, 1); // Since we are specifying TRUE for the 'copy' option, each // part should add its new id to the global hash $newSiteObj->insertDB(1, 1, 0, $copyDiscussions); // Copy all the media $query = "\n\t\t\tSELECT\n\t\t\t\tmedia_id\n\t\t\tFROM\n\t\t\t\tmedia\n\t\t\t\t\tINNER JOIN\n\t\t\t\tslot\n\t\t\t\t\tON\n\t\t\t\t\t\tmedia.FK_site = slot.FK_site\n\t\t\tWHERE\n\t\t\t\tslot_name='" . addslashes($oldName) . "'\n\t\t\t\tAND \n\t\t\t\tmedia_type != 'other'\n\t\t"; $r = db_query($query); while ($a = db_fetch_assoc($r)) { copy_media($a['media_id'], $newName); } $newSiteObj = NULL; unset($newSiteObj); $newSiteObj = new site($newName); $newSiteObj->fetchSiteAtOnceForeverAndEverAndDontForgetThePermissionsAsWell_Amen(); // Remove the permissions if we are clearing them. if ($clearPermissions) { $editors = $newSiteObj->getEditors(); foreach ($editors as $editor) { $newSiteObj->delEditor($editor); } } // Parse through all the text for links refering to parts of the // old site and update them with the new ids. updateSiteLinksFromHash($newSiteObj, $newSiteObj); $newSiteObj->updateDB(1, 1); // Delete any editors that we wanted to delete. $newSiteObj->deletePendingEditors(); }