function run(&$filter_chain, &$request, &$response) { debug :: add_timing_point('locale filter started'); if(!$node = map_request_to_node($request)) { define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID); define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID); $locale =& locale :: instance(); $locale->setlocale(); $filter_chain->next(); return; } if($object_locale_id = site_object :: get_locale_by_id($node['object_id'])) define('CONTENT_LOCALE_ID', $object_locale_id); else define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID); $user = user :: instance(); if($user_locale_id = $user->get_locale_id()) define('MANAGEMENT_LOCALE_ID', $user_locale_id); else define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID); debug :: add_timing_point('locale filter finished'); $locale =& locale :: instance(); $locale->setlocale(); $filter_chain->next(); }
function & get_dataset(&$counter, $params=array()) { $counter = 0; $mapped_node = map_request_to_node(); $links_manager = new links_manager(); $groups = array(); if(isset($params['group_identifier'])) { if($group = $links_manager->fetch_group_by_identifier($params['group_identifier'])) $groups[$group['id']] = $group; } else $groups = $links_manager->fetch_groups(); if (!is_array($groups) || !count($groups)) return new empty_dataset(); if(isset($params['back_links']) && $params['back_links']) $links = $links_manager->fetch_back_links($mapped_node['id'], array_keys($groups)); else $links = $links_manager->fetch_target_links($mapped_node['id'], array_keys($groups)); if (!is_array($links) || !count($links)) return new array_dataset($groups); $target_node_ids = complex_array :: get_column_values('target_node_id', $links); if (!is_array($target_node_ids) || !count($target_node_ids)) return new array_dataset($groups); $site_object_class_name = isset($params['loader_class_name']) ? $params['loader_class_name'] : 'site_object'; $objects =& fetch_by_node_ids($target_node_ids, $site_object_class_name, $counter, array( 'restrict_by_class' => false )); $result = array(); foreach($groups as $group_id => $group) { $groups[$group_id]['links'] = array(); foreach($links as $link_id => $link) { if ($link['group_id']!= $group_id) continue; //if (!isset($objects[$link['target_node_id']])) // continue; $link_data = array_merge($objects[$link['target_node_id']], $link); $groups[$group_id]['links'][$link_id] = $link_data; } } return new array_dataset($groups); }
function run(&$filter_chain, &$request, &$response) { debug::add_timing_point('authentication filter started'); if (!($object_data = fetch_requested_object($request))) { if (!($node = map_request_to_node($request))) { if (defined('ERROR_DOCUMENT_404')) { $response->redirect(ERROR_DOCUMENT_404); } else { $response->header("HTTP/1.1 404 Not found"); } return; } $response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI'])); return; } $object =& wrap_with_site_object($object_data); $site_object_controller =& $object->get_controller(); if (($action = $site_object_controller->determine_action($request)) === false) { debug::write_error('"' . $action . '" action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); if (defined('ERROR_DOCUMENT_404')) { $response->redirect(ERROR_DOCUMENT_404); } else { $response->header("HTTP/1.1 404 Not found"); } debug::add_timing_point('authentication filter finished'); $filter_chain->next(); return; } $actions = $object->get_attribute('actions'); if (!isset($actions[$action])) { $response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI'])); } debug::add_timing_point('authentication filter finished'); $filter_chain->next(); }
function run(&$filter_chain, &$request, &$response) { debug :: add_timing_point('authentication filter started'); if(!$object_data = fetch_requested_object($request)) { if(!$node = map_request_to_node($request)) { if(defined('ERROR_DOCUMENT_404')) $response->redirect(ERROR_DOCUMENT_404); else $response->header("HTTP/1.1 404 Not found"); return; } $response->redirect('/root/login?redirect='. urlencode($request->to_string())); return; } $object =& wrap_with_site_object($object_data); $site_object_controller =& $object->get_controller(); if(($action = $site_object_controller->determine_action($request)) === false) { debug :: write_error('"'. $action . '" action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); if(defined('ERROR_DOCUMENT_404')) $response->redirect(ERROR_DOCUMENT_404); else $response->header("HTTP/1.1 404 Not found"); debug :: add_timing_point('authentication filter finished'); $filter_chain->next(); return; } $actions = $object->get_attribute('actions'); if(!isset($actions[$action])) { $redirect_path = $site_object_controller->get_action_property($action, 'inaccessible_redirect'); if(!$redirect_path) $redirect_path = '/root/login'; $redirect_strategy =& $this->_get_redirect_strategy($site_object_controller, $action); $response->set_redirect_strategy($redirect_strategy); $response->redirect($redirect_path . '?redirect='. urlencode($request->to_string())); } debug :: add_timing_point('authentication filter finished'); $filter_chain->next(); }
function get_node_id() { if (!$this->node_id) { if($this->request_path) { $request = request :: instance(); $node_path = $request->get_attribute($this->request_path); if(!$node = map_url_to_node($node_path)) $node = map_request_to_node(); } else $node = map_request_to_node(); $this->node_id = $node['id']; } return $this->node_id; }
function run(&$filter_chain, &$request, &$response) { debug :: add_timing_point('authentication filter started'); if(!$object_data = fetch_requested_object($request)) { if(!$node = map_request_to_node($request)) { if(defined('ERROR_DOCUMENT_404')) $response->redirect(ERROR_DOCUMENT_404); else $response->header("HTTP/1.1 404 Not found"); return; } $user =& user :: instance(); if (!$user->is_logged_in()) { $tree = tree :: instance(); $response->redirect('/root/login?redirect='. $tree->get_path_to_node($node)); return; } else { debug :: write_error('content object not allowed or retrieved', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); if(defined('ERROR_DOCUMENT_403')) $response->redirect(ERROR_DOCUMENT_403); else $response->header("HTTP/1.1 403 Access denied"); return; } } $object =& wrap_with_site_object($object_data); $site_object_controller =& $object->get_controller(); if(($action = $site_object_controller->determine_action($request)) === false) { debug :: write_error('"'. $action . '" action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); if(defined('ERROR_DOCUMENT_404')) $response->redirect(ERROR_DOCUMENT_404); else $response->header("HTTP/1.1 404 Not found"); debug :: add_timing_point('authentication filter finished'); $filter_chain->next(); return; } $actions = $object->get_attribute('actions'); if(!isset($actions[$action])) { debug :: write_error('"'. $action . '" action is not accessible', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); if (debug :: is_console_enabled()) echo debug :: parse_html_console(); if(defined("ERROR_DOCUMENT_403")) $response->redirect(ERROR_DOCUMENT_403); else $response->header("HTTP/1.1 403 Access denied"); return; } debug :: add_timing_point('authentication filter finished'); $filter_chain->next(); }