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 perform(&$request, &$response)
 {
     $request->set_status(REQUEST_STATUS_SUCCESS);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request));
     }
     if (!($object = wrap_with_site_object(fetch_requested_object()))) {
         return;
     }
     $site_object_controller =& $object->get_controller();
     $action = $site_object_controller->determine_action($request);
     switch ($action) {
         case 'publish':
             $status = $this->get_publish_status($object);
             break;
         case 'unpublish':
             $status = $this->get_unpublish_status($object);
             break;
         default:
             return;
             break;
     }
     $object->set_attribute('status', $status);
     $object->update(false);
     $this->_apply_access_policy($object, $action);
     flush_fetcher_cache();
 }
 function _init_dataspace(&$request)
 {
     parent::_init_dataspace($request);
     $parent_object_data =& fetch_requested_object($request);
     $data['subscribe_mail_content'] = $parent_object_data['mail_template'];
     $this->dataspace->import($data);
 }
  function _send_mail()
  {
    $title = $this->get_attribute('title');
    $content = $this->get_attribute('content');
    $author = $this->get_attribute('author');

    $subscribe_email = ADMINISTRATOR_EMAIL; //fix

    $parent_object_data =& fetch_requested_object();

    $recipients = $this->_get_theme_subscribers($parent_object_data['id']);

    if(!count($recipients))
      return false;

    foreach($recipients as $recipient)
    {
      @ send_html_mail(
            array('"' . $recipient['name'].'" <'. $recipient['email'] .'>'),
            '"' . $author.'" <'. $subscribe_email .'>', $title,
            $content);
    }

    return true;
  }
	function _is_home_hit()
	{
		if(!$object_data = fetch_requested_object())
			return false;
			
		return ($object_data['parent_node_id'] == 0);
	}
 function &get_dataset(&$counter, $params = array())
 {
     $object_data = fetch_requested_object();
     if (!count($object_data)) {
         return new array_dataset(array());
     }
     $db_table =& db_table_factory::instance('sys_object_version');
     $arr = $db_table->get_list('object_id=' . $object_data['id'], 'version DESC');
     $result = array();
     $users =& fetch_sub_branch('/root/users', 'user_object', $counter);
     foreach ($arr as $data) {
         $record = $data;
         $user = '';
         if (count($users)) {
             foreach ($users as $user_data) {
                 if ($user_data['id'] == $data['creator_id']) {
                     $user = $user_data;
                     break;
                 }
             }
         }
         if ($user) {
             $record['creator_identifier'] = $user['identifier'];
             $record['creator_email'] = $user['email'];
             $record['creator_name'] = $user['name'];
             $record['creator_lastname'] = isset($user['lastname']) ? $user['lastname'] : '';
         }
         $result[] = $record;
     }
     return new array_dataset($result);
 }
 function save()
 {
     $request =& request::instance();
     $tab_id = session_history_manager::datermine_tab_id();
     if (!($history = session::get('session_history'))) {
         $history = array();
     }
     if (!isset($history[$tab_id])) {
         $history[$tab_id] = array();
     }
     $uri =& $request->get_uri();
     $uri->remove_query_item('rn');
     if ($uri->get_query_item('popup')) {
         return;
     }
     $object_data = fetch_requested_object();
     if ($object_data['class_name'] == 'control_panel') {
         return;
     }
     $history_item = array('title' => $object_data['title'], 'href' => $uri->to_string());
     $first = end($history[$tab_id]);
     if ($first) {
         $latest_uri =& new uri($first['href']);
         if ($uri->compare($latest_uri)) {
             return;
         }
     }
     if (count($history[$tab_id]) >= 10) {
         $history[$tab_id] = array_reverse($history[$tab_id]);
         array_pop($history[$tab_id]);
         $history[$tab_id] = array_reverse($history[$tab_id]);
     }
     array_push($history[$tab_id], $history_item);
     session::set('session_history', $history);
 }
	function & get_dataset($params = array())
	{
		if(!$arr = fetch_requested_object())
			return new array_dataset();
		
		$db_table =& db_table_factory :: instance('sys_class');
		$classes = $db_table->get_list('', 'class_name');
		
		$result = array();
		$params = array();

		foreach($classes as $class_id => $class_data)
		{
			$result[$class_id] = $class_data;
			$result[$class_id]['path'] = $arr['path'];
			$params['class_id'] = $class_id;
			$result[$class_id]['node_id'] = $arr['node_id'];
			
			foreach($arr['actions'] as $action_name => $action_params)
				$arr['actions'][$action_name]['extra'] = $params;

			$result[$class_id]['actions'] = $arr['actions'];
		}
		
		return new array_dataset($result);
	}
 function _is_home_hit()
 {
     if (!($object_data = fetch_requested_object())) {
         return false;
     }
     return $object_data['parent_node_id'] == 0;
 }
  function perform(&$request, &$response)
  {
    $request->set_status(REQUEST_STATUS_DONT_TRACK);
    $object =& fetch_requested_object();

    session :: set('limb_image_select_working_path', $object['path']);

  }
 function get_path()
 {
     if (!$this->path) {
         $object_arr =& fetch_requested_object();
         $this->path = $object_arr['path'];
     }
     return $this->path;
 }
 function _valid_perform(&$request, &$response)
 {
     $object_data =& fetch_requested_object($request);
     $data = $this->dataspace->export();
     $object =& site_object_factory::create('user_object');
     $object->save_membership($object_data['id'], $data['membership']);
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
 }
 function perform(&$request, &$response)
 {
     $object_data =& fetch_requested_object($request);
     $ini =& get_ini('image_variations.ini');
     $image_variations = $ini->get_all();
     foreach ($image_variations as $key => $value) {
         if (array_key_exists($key, $_GET)) {
             $variation = $key;
             break;
         }
     }
     if (empty($variation)) {
         $variation = 'thumbnail';
     }
     $image = $object_data['variations'][$variation];
     if (!$image) {
         $response->header("Content-type: image/gif");
         $response->readfile(SHARED_DIR . 'images/1x1.gif');
         if ($variation == 'original') {
             $request->set_status(REQUEST_STATUS_FAILURE);
             return;
         } else {
             $response->commit();
             //for speed
         }
     }
     if (!file_exists(MEDIA_DIR . $image['media_id'] . '.media')) {
         $response->header("HTTP/1.1 404 Not found");
         if ($variation == 'original') {
             $request->set_status(REQUEST_STATUS_FAILURE);
             return;
         } else {
             $response->commit();
             //for speed
         }
     }
     if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $image['etag']) {
         $response->use_client_cache();
         $response->header("Pragma: public");
         $response->header("Cache-Control: private");
         $response->header("Date: " . date("D, d M Y H:i:s") . " GMT");
         $response->header("Etag: {$image['etag']}");
     } else {
         $response->header("Pragma: public");
         $response->header("Cache-Control: private");
         $response->header("Date: " . date("D, d M Y H:i:s") . " GMT");
         $response->header("Etag: {$image['etag']}");
         $response->header("Content-type: {$image['mime_type']}");
         $response->header("Content-Disposition: filename={$image['file_name']}");
         $response->readfile(MEDIA_DIR . $image['media_id'] . '.media');
     }
     if ($variation == 'original') {
         return;
     } else {
         $response->commit();
         //for speed
     }
 }
 function &get_dataset($params = array())
 {
     if (!fetch_requested_object()) {
         return new array_dataset();
     }
     $db_table =& db_table_factory::instance('sys_controller');
     $controllers = $db_table->get_list('', 'name');
     return new array_dataset($controllers);
 }
  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 & _fetch_object_data()
  {
    $request =& request :: instance();

    if($object_id = $request->get_attribute('object_id'))
      return fetch_one_by_id($object_id);
    else
      return fetch_requested_object();
  }
 function run(&$filter_chain, &$request, &$response)
 {
     $filter_chain->next();
     debug::add_timing_point('logging filter started');
     $object = wrap_with_site_object(fetch_requested_object($request));
     $controller = $object->get_controller();
     include_once LIMB_DIR . 'core/model/stats/stats_register.class.php';
     $stats_register = new stats_register();
     $stats_register->register($object->get_node_id(), $controller->get_action(), $request->get_status());
     debug::add_timing_point('logging filter finished');
 }
 function _update_object_operation()
 {
     if ($file = $this->dataspace->get('file')) {
         $object_data =& fetch_requested_object();
         $this->object->set_attribute('media_id', $object_data['media_id']);
         $this->object->set_attribute('tmp_file_path', $file['tmp_name']);
         $this->object->set_attribute('file_name', $file['name']);
         $this->object->set_attribute('mime_type', $file['type']);
     }
     return parent::_update_object_operation();
 }
 function _init_validator()
 {
     parent::_init_validator();
     if ($object_data =& fetch_requested_object()) {
         $this->validator->add_rule($v1 = array(LIMB_DIR . '/core/lib/validators/rules/unique_user_rule', 'identifier', $object_data['identifier']));
         $this->validator->add_rule($v2 = array(LIMB_DIR . '/core/lib/validators/rules/unique_user_email_rule', 'email', $object_data['email']));
     }
     $this->validator->add_rule($v3 = array(LIMB_DIR . '/core/lib/validators/rules/required_rule', 'name'));
     $this->validator->add_rule($v4 = array(LIMB_DIR . '/core/lib/validators/rules/required_rule', 'email'));
     $this->validator->add_rule($v5 = array(LIMB_DIR . '/core/lib/validators/rules/email_rule', 'email'));
 }
 function run(&$filter_chain, &$request, &$response)
 {
     debug::add_timing_point('site object controller filter started');
     $site_object =& wrap_with_site_object(fetch_requested_object($request));
     $site_object_controller =& $site_object->get_controller();
     $site_object_controller->process($request, $response);
     if ($response->is_empty()) {
         $site_object_controller->display_view();
     }
     debug::add_timing_point('site object controller filter finished');
     $filter_chain->next();
 }
 function _valid_perform(&$request, &$response)
 {
     $object_data =& fetch_requested_object();
     $data = $this->dataspace->export();
     $phpbb_user_data['user_rank'] = $data['rank'];
     $db =& db_factory::instance();
     if ($db->sql_update('phpbb_users', $phpbb_user_data, array('user_id' => $object_data['id']))) {
         $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     } else {
         $request->set_status(REQUEST_STATUS_FAILURE);
     }
 }
  function perform(&$request, &$response)
  {
    $object_data =& fetch_requested_object($request);
    $variation = $this->_get_variation();
    $image = $object_data['variations'][$variation];

    if(!$image)
    {
      $response->header("Content-type: image/gif");
      $response->readfile(SHARED_DIR . 'images/1x1.gif');

      if($variation == 'original')
      {
        $request->set_status(REQUEST_STATUS_FAILURE);
        return;
      }
      else
        $response->commit();//for speed
    }

    if(!file_exists(MEDIA_DIR. $image['media_id'] . '.media'))
    {
      $response->header("HTTP/1.1 404 Not found");

      if($variation == 'original')
      {
        $request->set_status(REQUEST_STATUS_FAILURE);
        return;
      }
      else
        $response->commit();//for speed
    }

    $http_cache = $this->get_http_cache();
    $http_cache->set_last_modified_time($object_data['modified_date']);
    $http_cache->set_cache_time(60*60*24);

    if($http_cache->check_and_write($response))
    {
      $response->header("Content-type: {$image['mime_type']}");
    }
    else
    {
      $response->header("Content-type: {$image['mime_type']}");
      $response->header("Content-Disposition: filename={$image['file_name']}");
      $response->readfile(MEDIA_DIR. $image['media_id'] .'.media');
    }
    if($variation == 'original')
      return;
    else
      $response->commit();//for speed
  }
 function _valid_perform(&$request, &$response)
 {
     $object_data =& fetch_requested_object($request);
     $data = $this->dataspace->export();
     $data['id'] = $object_data['id'];
     $object =& site_object_factory::create('site_object');
     $object->import_attributes($data);
     if (!$object->save_metadata()) {
         $request->set_status(REQUEST_STATUS_FAILURE);
     } else {
         $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     }
 }
 function _valid_perform(&$request, &$response)
 {
     $object =& wrap_with_site_object(fetch_requested_object());
     if (!$object->delete()) {
         message_box::write_notice(strings::get('cant_be_deleted', 'error'));
         $request->set_status(REQUEST_STATUS_FAILURE);
         return;
     }
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request, RELOAD_SELF_URL, true));
     }
 }
  function _get_controller_id()
  {
    $request = request :: instance();
    if($controller_id = $request->get_attribute('controller_id'))
      return $controller_id;

    if($object_id = $request->get_attribute('object_id'))
      $object_data =& fetch_one_by_id($object_id);
    else
      $object_data =& fetch_requested_object();

    return $object_data['controller_id'];
  }  
 function get_current_template_source_link()
 {
     if (!($site_object = wrap_with_site_object(fetch_requested_object()))) {
         return '';
     }
     $site_object_controller = $site_object->get_controller();
     if (($action = $site_object_controller->determine_action()) === false) {
         return '';
     }
     if (!($template_path = $site_object_controller->get_action_property($action, 'template_path'))) {
         return '';
     }
     return '/root/template_source?t[]=' . $template_path;
 }
 function perform(&$request, &$response)
 {
     $chat_room_data =& fetch_requested_object();
     session::destroy('last_message_ids');
     setcookie('chat_room_id', $chat_room_data['object_id'], time() + 365 * 24 * 3600);
     if ($chat_user_data = chat_user::get_chat_user_data()) {
         if ($chat_user_data['chat_room_id'] != $chat_room_data['object_id']) {
             chat_system::leave_chat_room($chat_user_data['id'], $chat_user_data['nickname'], $chat_user_data['chat_room_id']);
             chat_system::enter_chat_room($chat_user_data['id'], $chat_user_data['nickname'], $chat_room_data['object_id']);
         }
         $this->view->set('nickname', $chat_user_data['nickname']);
     }
     parent::perform(&$request, &$response);
 }
 function perform(&$request, &$response)
 {
     $request->set_status(REQUEST_STATUS_SUCCESS);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request));
     }
     if (!($object = wrap_with_site_object(fetch_requested_object()))) {
         return;
     }
     $status = $this->get_status($object);
     $object->set_attribute('status', $status);
     $object->update(false);
     $this->_apply_access_policy($object);
     flush_fetcher_cache();
 }
 function _update_object_operation()
 {
     if (isset($_FILES[$this->name]['tmp_name']['file'])) {
         if ($_FILES[$this->name]['size']['file'] > ini_get('upload_max_filesize') * 1024 * 1024) {
             message_box::write_warning('uploaded file size exceeds limit');
             return false;
         }
         $object_data =& fetch_requested_object();
         $this->object->set_attribute('media_id', $object_data['media_id']);
         $this->object->set_attribute('tmp_file_path', $_FILES[$this->name]['tmp_name']['file']);
         $this->object->set_attribute('file_name', $_FILES[$this->name]['name']['file']);
         $this->object->set_attribute('mime_type', $_FILES[$this->name]['type']['file']);
     }
     return parent::_update_object_operation();
 }
	function perform(&$request, &$response)
	{
		$object_data = fetch_requested_object();
		
		$parent_data = fetch_one_by_node_id($object_data['parent_node_id']);
		$path = $parent_data['path'];
		
		$params = complex_array :: array_merge($_GET, $_POST);

		$sep = '';
		$query = '';
		
		$flat_params = array();
		complex_array :: to_flat_array($params, $flat_params);
		
		foreach ($flat_params as $key => $value)
		{
			$query .= $sep . $key . '=' . urlencode($value);
			$sep = '&';
		} 
		if (!empty($query))
			$path .= '?' . $query;
		
		$response->redirect($path);
	}