function run_job() { reason_include_once('minisite_templates/nav_classes/default.php'); $page_ids = $this->config('page_ids'); $id = reset($page_ids); $page = new entity($id); $site = $page->get_owner(); // lets make and get the page tree $page_tree = new MinisiteNavigation(); $page_tree->order_by = 'sortable.sort_order'; $page_tree->init($site->id(), id_of('minisite_page')); foreach ($page_ids as $page_id) { $children = $page_tree->children($page_id); $diff = array_diff($children, $page_ids); // are we trying to move a page without its children? if (!empty($diff)) { $problem[] = 'Cannot move page id ' . $page_id . ' without also moving child pages with ids (' . implode(", ", $diff) . ')'; } } if (isset($problem)) { $report = 'Blocking any further jobs. When moving pages you need to move entire branches'; $report .= '<ul>'; $report .= '<li>' . implode("</li><li>", $problem) . '</li>'; $report .= '</ul>'; $this->set_report($report); $this->block_jobs(); return false; } else { $this->set_report('Verified that the page tree integrity is preserved with this move.'); } return true; }