示例#1
0
 /**
  * Returns The instance of the website whose page is a root of, or false if page is not a website root
  * Static function.
  *
  * @param CMS_page|integer $root The supposed root page or root page ID
  * @return CMS_website the website whose page is a root, or false
  * @access public
  */
 static function getWebsiteFromRoot($root)
 {
     static $roots;
     if (is_object($root)) {
         $rootID = $root->getID();
     } elseif (sensitiveIO::isPositiveInteger($root)) {
         $rootID = $root;
     } else {
         CMS_grandFather::raiseError('Root must be instance of CMS_page or valid root ID');
         return false;
     }
     if (!isset($roots[$rootID])) {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_web\n\t\t\t\tfrom\n\t\t\t\t\twebsites\n\t\t\t\twhere\n\t\t\t\t\troot_web='" . $rootID . "'\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             $roots[$rootID] = CMS_websitesCatalog::getByID($q->getValue("id_web"));
         } else {
             $roots[$rootID] = false;
         }
     }
     return $roots[$rootID];
 }
示例#2
0
define("MESSAGE_PAGE_TREE_TITLE", 822);
define("MESSAGE_PAGE_TREE_HEADING", 823);
define("MESSAGE_PAGE_FIELD_URL", 819);
define("MESSAGE_PAGE_SAVE_NEWORDER", 1183);
define("MESSAGE_PAGE_SAME_DOMAIN_EXPLANATION", 1352);
define("MESSAGE_PAGE_ACTION_ORDERING_ERROR", 1353);
define("MESSAGE_PAGE_FIELD_CODENAME", 1675);
//checks
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES)) {
    header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id());
    exit;
}
switch ($_POST["cms_action"]) {
    case "delete":
        //delete the website and move all of its pages
        $website = CMS_websitesCatalog::getByID($_POST["website"]);
        if ($website instanceof CMS_website && !$website->isMain()) {
            $log = new CMS_log();
            $log->logMiscAction(CMS_log::LOG_ACTION_WEBSITE_DELETE, $cms_user, "Website : " . $website->getLabel());
            //check for codenames duplications
            //get website codenames
            $websiteCodenames = $website->getAllPagesCodenames();
            //get codenames of parent page for website
            $websiteRoot = $website->getRoot();
            $father = CMS_tree::getFather($websiteRoot, true);
            if ($father && is_object($father) && !$father->hasError()) {
                $fatherWebsite = $father->getWebsite();
                $fatherCodenames = $fatherWebsite->getAllPagesCodenames();
                $codenamesToRemove = array();
                //get duplicated codenames
                foreach ($websiteCodenames as $codename => $pageId) {