function & _fetch(&$counter, $params)
	{
		if(!$result =& parent :: _fetch($counter, $params))
			return $result;
		
		$user_ids = complex_array :: get_column_values('user_id', $result);

		$fetcher =& fetcher :: instance();
		
		$params = array(
			'restrict_by_class' => false
		);
		
		$user_counter = 0;
		$users =& $fetcher->fetch_by_ids($user_ids, 'user_object', $user_counter, $params, 'fetch_by_ids');

		foreach($result as $key => $data)
		{
			if (!isset($users[$data['user_id']]))
				continue;
				
			$customer_data = $users[$data['user_id']];
			$result[$key]['user_name'] = $customer_data['name'];
			$result[$key]['user_lastname'] = $customer_data['lastname'];
			$result[$key]['user_secondname'] = $customer_data['secondname'];
			$result[$key]['user_email'] = $customer_data['email'];
			$result[$key]['user_phone'] = $customer_data['phone'];
		}	

		return $result;
	}
  function _process_loaded_items(& $items)
  {
    if (!count($items))
      return $items;

    $parent_node_ids = array();

    foreach($items as $key => $data)
      if (!isset($parent_node_ids[$data['parent_node_id']]))
      {
        $parent_node_ids[$data['parent_node_id']] = $data['parent_node_id'];
      }

    $fetcher =& fetcher :: instance();
    $access_policy =& access_policy :: instance();

    $params = array(
      'restrict_by_class' => false
    );

    $parents =& $fetcher->fetch_by_node_ids($parent_node_ids, 'site_object', $parents_counter, $params, 'fetch_by_ids');

    foreach($items as $key => $data)
    {
      $parent_data = $parents[$data['parent_node_id']];
      $items[$key]['parent_title'] = $parent_data['title'];
      $items[$key]['parent_path'] = $parent_data['path'];
    }
  }
	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);

	  fetcher :: flush_cache();
	}
 public function fetchEvents($resources)
 {
     $start = new \DateTime('NOW');
     $this->info("[{$start->format('Y-m-d g:i:s')}] Started fetching new Facebook events.");
     foreach ($resources as $resource) {
         try {
             $this->info("Fetching events for {$resource->name} ({$resource->id})...");
             $this->fetcher->storeEvents($resource);
         } catch (\Exception $e) {
             $this->error("Error fetching events for {$resource->name}: {$e->getMessage()} ({$e->getLine()})");
         }
         sleep(1);
     }
     $finish = new \DateTime('NOW');
     $this->info("[{$finish->format('Y-m-d g:i:s')}] Finished fetching new Facebook events.");
 }
Exemplo n.º 5
0
 function setUp()
 {
     parent::setUp();
     $this->fetcher =& fetcher::instance();
     $user_id = 10;
     $this->_login_user($user_id, array(103 => 'visitors', 104 => 'admin'));
     $obj1 = site_object_factory::create('fetching_test_object1');
     $obj2 = site_object_factory::create('fetching_test_object2');
     $obj1->set_identifier('root');
     $obj1->set_title('Root');
     $obj1->create(true);
     $access[$obj1->get_id()] = array($user_id => array('r' => 1, 'w' => 1));
     $this->root_node_id = $obj1->get_node_id();
     $this->_add_object($obj1);
     $obj1->set_parent_id($this->root_node_id);
     $obj1->set_identifier('articles');
     $obj1->set_title('Articles');
     $obj1->create();
     $access[$obj1->get_id()] = array($user_id => array('r' => 1, 'w' => 1));
     $this->_add_object($obj1);
     $this->articles_object = $obj1;
     $obj2->set_parent_id($obj1->get_node_id());
     $obj2->set_identifier('article1');
     $obj2->set_title('Article1');
     $obj2->create();
     $access[$obj2->get_id()] = array($user_id => array('r' => 1, 'w' => 1));
     $this->child_node_ids[] = $obj2->get_node_id();
     $this->_add_object($obj2);
     $this->article_object = $obj2;
     $obj2->set_parent_id($obj1->get_node_id());
     $obj2->set_identifier('article2');
     $obj2->set_title('Article2');
     $obj2->create();
     $access[$obj2->get_id()] = array($user_id => array('r' => 1, 'w' => 1));
     $this->child_node_ids[] = $obj2->get_node_id();
     $this->_add_object($obj2);
     $obj2->set_parent_id($obj1->get_node_id());
     $obj2->set_identifier('article3');
     $obj2->set_title('Article3');
     $obj2->create();
     $access[$obj2->get_id()] = array($user_id => array('r' => 0, 'w' => 0));
     $this->child_node_ids[] = $obj2->get_node_id();
     $this->_add_object($obj2);
     $this->access_policy =& access_policy::instance();
     $this->access_policy->save_user_object_access($access);
     $actions = array($user_id => array('display' => 1));
     $this->access_policy->save_user_action_access($obj1->get_class_id(), $actions);
     $this->access_policy->save_user_action_access($obj2->get_class_id(), $actions);
 }
 function run(&$filter_chain, &$request, &$response)
 {
     debug::add_timing_point('jip filter started');
     $fetcher =& fetcher::instance();
     $fetcher->set_jip_status(false);
     $user =& user::instance();
     if ($user->is_logged_in()) {
         $ini =& get_ini('jip_groups.ini');
         if ($user->is_in_groups(array_keys($ini->get_group('groups')))) {
             $fetcher->set_jip_status(true);
         }
     }
     debug::add_timing_point('jip filter done');
     $filter_chain->next();
 }
 function &_fetch(&$counter, $params)
 {
     $result =& parent::_fetch($counter, $params);
     if (!count($result)) {
         return $result;
     }
     $parent_node_ids = array();
     foreach ($result as $key => $data) {
         if (!isset($parent_node_ids[$data['parent_node_id']])) {
             $parent_node_ids[$data['parent_node_id']] = $data['parent_node_id'];
         }
     }
     $fetcher =& fetcher::instance();
     $access_policy =& access_policy::instance();
     $params = array('restrict_by_class' => false);
     $parents =& $fetcher->fetch_by_node_ids($parent_node_ids, 'site_object', $parents_counter, $params, 'fetch_by_ids');
     foreach ($result as $key => $data) {
         $parent_data = $parents[$data['parent_node_id']];
         $result[$key]['parent_title'] = $parent_data['title'];
         $result[$key]['parent_path'] = $parent_data['path'];
     }
     return $result;
 }
 function _valid_perform(&$request, &$response)
 {
     $object_data =& $this->_load_object_data();
     $data_to_import['id'] = $object_data['id'];
     $data_to_import['node_id'] = $object_data['node_id'];
     $data_to_import['parent_node_id'] = $object_data['parent_node_id'];
     $data_to_import['identifier'] = $object_data['identifier'];
     $data_to_import['title'] = $object_data['title'];
     $this->_valid_perform_prepare_data($data_to_import);
     if (!isset($data_to_import['status'])) {
         $data_to_import['status'] = $object_data['status'];
     }
     $this->object->import_attributes($data_to_import);
     if (!$this->_update_object_operation()) {
         $request->set_status(REQUEST_STATUS_FAILURE);
         return;
     }
     $this->indexer->add($this->object);
     if (isset($data_to_import['identifier']) && $object_data['identifier'] != $data_to_import['identifier']) {
         $this->_handle_changed_identifier($data_to_import['identifier']);
     }
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     fetcher::flush_cache();
 }
 function & _get_fetcher()
 {
   if($this->fetcher)
     return $this->fetcher;
     
   $this->fetcher =& fetcher :: instance();
   return $this->fetcher;
 }
	function search_fetcher()
	{
		parent :: fetcher();
	}
Exemplo n.º 11
0
function & fetch_by_node_ids($node_ids, $loader_class_name, &$counter, $params = array(), $fetch_method = 'fetch_by_ids')
{
	$fetcher =& fetcher :: instance();
	$result =& $fetcher->fetch_by_node_ids($node_ids, $loader_class_name, $counter, $params, $fetch_method);
	return $result;
}