Example #1
0
 /**
  * Process the daily routine unpublication part : unpublish page that needs to be
  *
  * @return void
  * @access private
  */
 protected function _dailyRoutineUnpublish()
 {
     $today = new CMS_date();
     $today->setNow();
     //process all pages that are to be unpublished
     $sql = "\n\t\t\tselect\n\t\t\t\tid_pag\n\t\t\tfrom\n\t\t\t\tpages,\n\t\t\t\tresources,\n\t\t\t\tresourceStatuses\n\t\t\twhere\n\t\t\t\tresource_pag=id_res\n\t\t\t\tand status_res=id_rs\n\t\t\t\tand location_rs='" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\tand publication_rs='" . RESOURCE_PUBLICATION_PUBLIC . "'\n\t\t\t\tand\t(publicationDateStart_rs > '" . $today->getDBValue(true) . "'\n\t\t\t\t\tor (publicationDateEnd_rs < '" . $today->getDBValue(true) . "' and publicationDateEnd_rs!='0000-00-00'))\n\t\t";
     $q = new CMS_query($sql);
     $unpublished = array();
     while ($id = $q->getValue("id_pag")) {
         $unpublished[] = $id;
     }
     $regen_pages = array();
     foreach ($unpublished as $page_id) {
         $page = CMS_tree::getPageByID($page_id);
         //calculate the pages to regenerate
         $temp_regen = CMS_linxesCatalog::getLinkers($page);
         if ($temp_regen) {
             $regen_pages = array_merge($regen_pages, $temp_regen);
         }
         $father = CMS_tree::getAncestor($page, 1);
         if ($father) {
             $temp_regen = CMS_linxesCatalog::getWatchers($father);
             if ($temp_regen) {
                 $regen_pages = array_merge($regen_pages, $temp_regen);
             }
         }
         //apply changes on the page
         $page->deleteFiles();
         CMS_linxesCatalog::deleteLinxes($page, true);
         CMS_tree::detachPageFromTree($page, true);
     }
     //regenerate the pages that needs to be, but first pull off the array the ids of the unpublished pages
     $regen_pages = array_unique(array_diff($regen_pages, $unpublished));
     CMS_tree::submitToRegenerator($regen_pages, false);
 }
Example #2
0
 /**
  * Move a page in the tree structure
  * Static function.
  *
  * @param CMS_page $page The page to move
  * @param CMS_page $newFather The new father of the page
  * @param array of CMS_page id $newSiblingOrder The sibling pages to move in the good order
  * @param CMS_profile_user $user The user operating the change.
  * @return string The error string (abbreviated) or false if no error
  * @access public
  */
 static function movePage(&$page, &$newFather, $newSiblingOrder, &$user)
 {
     //check arguments are pages
     if (!is_a($page, "CMS_page") || !is_a($newFather, "CMS_page")) {
         CMS_grandFather::_raiseError("CMS_tree : movePage : ancestor and page must be instances of CMS_page");
         return false;
     }
     //get page current father
     $father = CMS_tree::getAncestor($page, 1);
     //can't move page to the same father (useless...)
     if (is_object($father) && $newFather->getID() == $father->getID()) {
         CMS_grandFather::_raiseError("CMS_tree : movePage : can't move page under the same father (use changePagesOrder instead)");
         return false;
     }
     //check that the page to move ain't the root.
     $root = CMS_tree::getRoot();
     if ($root->getID() == $page->getID()) {
         CMS_grandFather::_raiseError("CMS_tree : movePage : can't move root");
         return false;
     }
     //check that the page to move ain't an ancestor of new father.
     $lineage = CMS_tree::getLineage($page, $newFather);
     if ($lineage) {
         CMS_grandFather::_raiseError("CMS_tree : movePage : can't move a page to a descendant of it");
         return false;
     }
     //detach the page from the edited tree
     CMS_tree::detachPageFromTree($page, false);
     //attach the page to the edited tree under the new father
     CMS_tree::attachPageToTree($page, $newFather, false);
     //set new pages order
     foreach ($newSiblingOrder as $newOrder => $sibling) {
         $newOrder += 1;
         //because array keys start to 0 and sibling number to 1
         //move the siblings order
         $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tlinx_tree_edited\n\t\t\t\tset\n\t\t\t\t\torder_ltr='" . $newOrder . "'\n\t\t\t\twhere\n\t\t\t\t\tsibling_ltr='" . $sibling . "'\n\t\t\t";
         $q = new CMS_query($sql);
     }
     //set the page status editions
     $page->addEdition(RESOURCE_EDITION_MOVE, $user);
     $page->writeToPersistence();
     return true;
 }