/** * run the rewrite rules */ function run() { $urlm = new url_manager($this->vars['site_id']); $urlm->update_rewrites(); // if a page was just deleted, lets also clear the nav cache for the site if ($this->vars['type_id'] == id_of('minisite_page')) { reason_include_once('classes/object_cache.php'); $cache = new ReasonObjectCache($this->vars['site_id'] . '_navigation_cache'); $cache->clear(); } }
function init() { $this->admin_page->set_show('leftbar', false); if (empty($this->admin_page->id)) { $this->_not_undeletable_reason = 'no_id_provided'; return false; } if (!reason_user_has_privs($this->admin_page->user_id, 'publish')) { $this->_not_undeletable_reason = 'insufficient_privileges'; return false; } $item = new entity($this->admin_page->id); $user = new entity($this->admin_page->user_id); if (!$item->user_can_edit_field('state', $user)) { $this->_not_undeletable_reason = 'state_field_locked'; return false; } if ($item->get_value('state') != 'Deleted') { $this->_not_undeletable_reason = 'not_deleted_yet'; return false; } reason_update_entity($this->admin_page->id, $this->admin_page->user_id, array('state' => 'Live'), false); if ($this->admin_page->type_id == id_of('minisite_page')) { // zap nav cache so it reappears. reason_include_once('classes/object_cache.php'); $cache = new ReasonObjectCache($this->admin_page->site_id . '_navigation_cache'); $cache->clear(); } $manager_site_id = $this->admin_page->site_id; if ($item->get_value('type') == id_of('site')) { $manager_site_id = $item->id(); } //Updates the rewrites to prevent infinite redirection loop. reason_include_once('classes/url_manager.php'); $urlm = new url_manager($manager_site_id); $urlm->update_rewrites(); $link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'Lister', 'id' => '', 'state' => 'deleted'))); header('Location: ' . $link); die; }
/** * After we save the title change we also need to destroy the navigation cache for the site. */ function process_editable(&$disco) { $page = new entity($this->page_id); $values['name'] = trim(strip_tags($disco->get_value('page_title'))); if ($page->get_value('name') != $values['name']) { $user_id = get_user_id(reason_check_authentication()); reason_update_entity($this->page_id, $user_id, $values, true); // clear nav cache reason_include_once('classes/object_cache.php'); $cache = new ReasonObjectCache($this->site_id . '_navigation_cache'); $cache->clear(); } }
function clear_cache() { $cache = new ReasonObjectCache($this->get_cache_id()); $cache->clear(); }
function process() { if ($this->get_value('chosen_action') == '0') { $items = array(); foreach ($this->get_element_names() as $name) { if (preg_match("/^sortOrder_/i", $name)) { $order = $this->get_value($name); $name = preg_replace("/^sortOrder_/i", "", $name); $items[$name] = $order; } } asort($items); $sort_order = 1; foreach ($items as $k => $v) { $items[$k] = $sort_order; $sort_order++; } $changed_something = false; if (!empty($items)) { foreach ($items as $id => $order) { $result = reason_update_entity($id, $this->user_id, array($this->sorter->get_field() => $order), false); if ($result) { $changed_something = true; } } } // if we have changed sort order of pages, lets try to drop the nav cache for the active site. if ($changed_something && $this->type_id == id_of('minisite_page')) { reason_include_once('classes/object_cache.php'); $cache = new ReasonObjectCache($this->site_id . '_navigation_cache'); $cache->clear(); } } }
function clear_excluded() { $id = $this->_get_cache_id(); $cache = new ReasonObjectCache($id); $cache->clear(); }
/** * If the form submission was just completed - we should have a valid submission_key passed in the request */ function form_submission_is_complete() { if (!isset($this->_form_submission_is_complete)) { $submission_key = $this->get_form_submission_key(); $sk_cache = new ReasonObjectCache($submission_key); $this->_form_submission_is_complete = ($sk_cache->fetch()); if ($sk_cache->fetch()) $sk_cache->clear(); } return $this->_form_submission_is_complete; }
function show_reinstate() { if (!isset($this->history[$this->admin_page->request['archive_id']])) { echo '<p>This version was not found. <a href="' . $this->admin_page->make_link(array()) . '">Return</a></p>' . "\n"; } elseif (empty($this->_locks[$this->admin_page->request['archive_id']])) { $id = $this->admin_page->request['archive_id']; $e = new entity($id); $values = $e->get_values(); $old_id = $this->admin_page->id; $old = new entity($old_id); $old_values = $old->get_values(); if (isset($values['id'])) { unset($values['id']); } if (isset($values['last_modified'])) { unset($values['last_modified']); } $values['state'] = 'Live'; reason_update_entity($this->admin_page->id, $this->admin_page->user_id, $values); // if this is a page, lets check a few things - we may have to run rewrites or clear the nav cache if ($this->admin_page->type_id == id_of('minisite_page')) { // do we need to clear the nav cache? if ($values['url_fragment'] != $old_values['url_fragment'] || $values['name'] != $old_values['name'] || $values['link_name'] != $old_values['link_name'] || $values['nav_display'] != $old_values['nav_display'] || $values['sort_order'] != $old_values['sort_order'] || $old_values['state'] != 'Live') { reason_include_once('classes/object_cache.php'); $cache = new ReasonObjectCache($this->admin_page->site_id . '_navigation_cache'); $cache->clear(); } // if the page was formerly pending or the url_fragment has changed, run rewrites. if ($old_values['state'] == 'Pending' || $values['url_fragment'] != $old_values['url_fragment']) { reason_include_once('classes/url_manager.php'); $urlm = new url_manager($this->admin_page->site_id); $urlm->update_rewrites(); } } header('Location: ' . unhtmlentities($this->admin_page->make_link(array('id' => $this->admin_page->id)))); die; } else { echo '<p>This version cannot be reinstated becase doing so would change a locked field. <a href="' . $this->admin_page->make_link(array()) . '">Return</a></p>' . "\n"; } }
/** * This method will clear the news item cache generated by this module for a site and page * @todo implement something to call this */ function clear_cache($site_id = '', $page_id = '') { $site_id = ($site_id) ? $site_id : $this->site_id; $page_id = ($page_id) ? $page_id : $this->page_id; if ($site_id && $page_id) { $cache = new ReasonObjectCache($this->get_cache_id($site_id, $page_id)); $cache->clear(); } else trigger_error('clear_cache needs a site_id and page_id'); }
function run_job() { reason_include_once('classes/object_cache.php'); $site_ids = $this->config('site_ids'); foreach ($site_ids as $site_id) { $cache = new ReasonObjectCache($site_id . '_navigation_cache'); $cache->clear(); } $this->set_report('Zapped the navigation cache for site id(s) ' . implode(', ', $site_ids) . '.'); return true; }