function _init_dataspace(&$request)
  {
    $access_policy =& access_policy :: instance();
    $data['policy'] = $access_policy->get_object_access_by_ids($this->object_ids, ACCESSOR_TYPE_GROUP);

    $this->dataspace->merge($data);
  }
 function _valid_perform(&$request, &$response)
 {
     $data = $this->dataspace->export();
     $access_policy =& access_policy::instance();
     $access_policy->save_group_object_access($data['policy']);
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
 }
 function _valid_perform()
 {
     $tree =& tree::instance();
     $params = array();
     $params['identifier'] = $this->dataspace->get('identifier');
     $params['parent_path'] = $this->dataspace->get('parent_path');
     $params['class'] = $this->dataspace->get('class_name');
     $params['title'] = $this->dataspace->get('title');
     $object =& site_object_factory::create($params['class']);
     $is_root = false;
     if (!($parent_data = fetch_one_by_path($params['parent_path']))) {
         if ($params['parent_path'] == '/') {
             $is_root = true;
         } else {
             error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
         }
     }
     if (!$is_root) {
         $params['parent_node_id'] = $parent_data['node_id'];
     } else {
         $params['parent_node_id'] = 0;
     }
     $object->import_attributes($params);
     if (!$object->create($is_root)) {
         error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     if (!$is_root) {
         $parent_object =& site_object_factory::instance($parent_data['class_name']);
         $parent_object->import_attributes($parent_data);
         $access_policy =& access_policy::instance();
         $access_policy->save_object_access($object, $parent_object);
     }
     return new close_popup_response(RESPONSE_STATUS_FORM_SUBMITTED);
 }
 function _valid_perform()
 {
     $data = $this->dataspace->export();
     $access_policy =& access_policy::instance();
     $access_policy->save_group_object_access($data['policy']);
     return new response(RESPONSE_STATUS_FORM_SUBMITTED);
 }
  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 _valid_perform()
 {
     $data = $this->_export();
     $access_policy =& access_policy::instance();
     $access_policy->save_group_object_access($data['policy']);
     return true;
 }
 function _apply_access_policy($object, $action)
 {
     $access_policy =& access_policy::instance();
     if (!$access_policy->save_object_access_for_action($object, $action)) {
         error('access template for action not defined', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('action' => $action));
     }
 }
 function _valid_perform(&$request, &$response)
 {
     $tree =& tree::instance();
     $params = array();
     $params['identifier'] = $this->dataspace->get('identifier');
     $params['class'] = $this->dataspace->get('class_name');
     $params['title'] = $this->dataspace->get('title');
     $params['parent_node_id'] = $this->dataspace->get('parent_node_id');
     $params['controller_id'] = site_object_controller::get_id($this->dataspace->get('controller_name'));
     $object =& site_object_factory::create($params['class']);
     if (!($parent_data = fetch_one_by_node_id($params['parent_node_id']))) {
         error("parent wasn't retrieved", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $object->merge_attributes($params);
     if (!$object->create()) {
         error("object wasn't registered", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $parent_object =& site_object_factory::create($parent_data['class_name']);
     $parent_object->merge_attributes($parent_data);
     $access_policy =& access_policy::instance();
     $access_policy->save_initial_object_access($object, $parent_object);
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request));
     }
 }
 function perform()
 {
     $access_policy =& access_policy::instance();
     $data['policy'] = $access_policy->get_group_object_access();
     $this->dataspace->import($data);
     return parent::perform();
 }
 function _write_create_access_policy()
 {
     $parent_data =& $this->_load_parent_object_data();
     $parent_object =& site_object_factory::instance($parent_data['class_name']);
     $parent_object->import_attributes($parent_data);
     $access_policy =& access_policy::instance();
     $access_policy->save_object_access($this->object, $parent_object);
 }
 function _write_create_access_policy(&$object)
 {
     $parent_data =& fetch_mapped_by_url();
     $parent_object =& site_object_factory::instance($parent_data['class_name']);
     $parent_object->import_attributes($parent_data);
     $access_policy =& access_policy::instance();
     $access_policy->save_object_access($object, $parent_object);
 }
 function perform()
 {
     if (!parent::perform()) {
         return false;
     }
     $access_policy =& access_policy::instance();
     $data['policy'] = $access_policy->get_group_object_access();
     $this->_import($data);
     return true;
 }
	function perform(&$request, &$response)
	{				
		$access_policy =& access_policy :: instance();
	
		$data['policy'] = $access_policy->get_group_object_access();

		$this->dataspace->import($data);
		
		parent :: perform($request, $response);
	}
 function _valid_perform()
 {
     if (!isset($_REQUEST['class_id'])) {
         return false;
     }
     $data = $this->_export();
     $access_policy =& access_policy::instance();
     $access_policy->save_group_action_access_template($_REQUEST['class_id'], $data['template']);
     close_popup_no_parent_reload();
 }
 function _valid_perform()
 {
     if (!isset($_REQUEST['class_id'])) {
         return false;
     }
     $data = $this->_export();
     $access_policy =& access_policy::instance();
     $access_policy->save_group_action_access($_REQUEST['class_id'], $data['policy']);
     close_popup();
 }
 function _valid_perform()
 {
     if (!isset($_REQUEST['class_id'])) {
         error('class_id not defined', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $data = $this->dataspace->export();
     $access_policy =& access_policy::instance();
     $access_policy->save_group_action_access_template($_REQUEST['class_id'], $data['template']);
     return new close_popup_no_reload_response(RESPONSE_STATUS_FORM_SUBMITTED);
 }
 function _valid_perform(&$request, &$response)
 {
     $data = $this->dataspace->export();
     if ($groups = $this->dataspace->get('filter_groups')) {
         session::set('filter_groups', $groups);
     }
     if (isset($data['update']) && isset($data['policy'])) {
         $access_policy =& access_policy::instance();
         $access_policy->save_group_object_access($data['policy'], $groups);
     }
     $this->_set_template_tree();
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
 }
 function _valid_perform(&$request, &$response)
 {
     if (!($class_id = $request->get_attribute('class_id'))) {
         error('class_id not defined', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
     }
     $data = $this->dataspace->export();
     $access_policy =& access_policy::instance();
     $access_policy->save_group_action_access_template($class_id, $data['template']);
     $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_no_parent_reload_response());
     }
 }
 function setUp()
 {
     parent::setUp();
     $this->ac =& access_policy::instance();
     $this->object =& new Mocksite_object($this);
     $this->parent_object =& new Mocksite_object($this);
     $this->parent_object_controller =& new Mocksite_object_controller($this);
     $this->object->expectOnce('get_id');
     $this->parent_object->expectOnce('get_id');
     $this->parent_object->expectOnce('get_class_id');
     $this->parent_object->expectOnce('get_controller');
     $this->parent_object->setReturnReference('get_controller', $this->parent_object_controller);
 }
 function set_publish_status($status)
 {
     $object_data = fetch_mapped_by_url();
     $object_data['status'] = $status;
     $object =& site_object_factory::create($object_data['class_name']);
     $object->import_attributes($object_data);
     $access_policy =& access_policy::instance();
     $site_object_controller =& $object->get_controller();
     $action = $site_object_controller->determine_action();
     if (!$access_policy->save_object_access_for_action($object, $action)) {
         return false;
     }
     return $object->update(false, false);
 }
 function set_publish_status($status)
 {
     $object_data = fetch_mapped_by_url();
     $object_data['status'] = $status;
     $object =& site_object_factory::create($object_data['class_name']);
     $object->import_attributes($object_data);
     $access_policy =& access_policy::instance();
     $site_object_controller =& $object->get_controller();
     $action = $site_object_controller->determine_action();
     if (!$access_policy->save_object_access_for_action($object, $action)) {
         error('access template for action not defined', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('action' => $action));
     }
     return $object->update(false, false);
 }
  function _valid_perform(&$request, &$response)
  {
    if (!$controller_id = $request->get_attribute('controller_id'))
    {
      error('controller_id not defined',
       __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__);
    }

    $data = $this->dataspace->export();
    $access_policy =& access_policy :: instance();

    $access_policy->save_action_access($controller_id, $data['policy'], ACCESSOR_TYPE_GROUP);

    $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);

    if($request->has_attribute('popup'))
      $response->write(close_popup_no_parent_reload_response());
  }
 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 count_accessible_children($node, $add_sql=array())
  {
    if (!($parent = $this->get_node($node)))
      return false;

    if(!$this->_is_table_joined('sys_site_object', $add_sql))
      $add_sql['join'][] = ', sys_site_object as sso ';

    if(!$this->_is_table_joined('sys_object_access', $add_sql))
      $add_sql['join'][] = ', sys_object_access as soa ';

    $add_sql['append'][] = ' AND sso.id = ' . $this->_node_table . '.object_id AND sso.id = soa.object_id AND soa.access = 1';

    $access_policy =& access_policy :: instance();
    $accessor_ids = implode(',', $access_policy->get_accessor_ids());

    $add_sql['append'][] = " AND soa.accessor_id IN ({$accessor_ids})";
    $add_sql['group'][] = ' GROUP BY ' . $this->_node_table . '.id';

    $sql = sprintf('SELECT count(*) as counter FROM %s %s
                    WHERE %s.root_id=%s AND %s.parent_id=%s %s %s',
                    $this->_node_table,
                    $this->_add_sql($add_sql, 'join'),
                    $this->_node_table,
                    $parent['root_id'],
                    $this->_node_table,
                    $parent['id'],
                    $this->_add_sql($add_sql, 'append'),
                    $this->_add_sql($add_sql, 'group')
                  );

    $this->_db->sql_exec($sql);

    return count($this->_db->get_array());
  }
 function setUp()
 {
     parent::setUp();
     $this->ac =& access_policy::instance();
 }
Exemplo n.º 26
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 & search_fetch_by_ids($object_ids, $loader_class_name, &$counter, $params = array(), $fetch_method = 'fetch_by_ids')
	{
		if (!$this->_query_object)
		{
			 debug :: write_error('search_query is empty',
    		 __FILE__ . ' : ' . __LINE__ . ' : ' .  __FUNCTION__, 
    		array()
    	);
    	return array();
    }	

		$search =& new full_text_search();
		$search_result = $search->find_by_ids($object_ids, $this->_query_object);

		if(!count($search_result))
			return array();
		
		$counter = 0;
		$count_method = $fetch_method . '_count';
		
		$site_object =& site_object_factory :: instance($loader_class_name);
		$counter = $site_object->$count_method(array_keys($search_result), $params);
		$fetched_objects =& $site_object->$fetch_method(array_keys($search_result),$params);

		if(!count($fetched_objects))
			return array();
		
		foreach($search_result as $key => $score)
			if (isset($fetched_objects[$key]))
			{
				$result[$key] = $fetched_objects[$key];
				$result[$key]['score'] = $score;
			}	
		
		$access_policy = access_policy :: instance();
		$access_policy->assign_actions_to_objects($result);

		$this->_assign_paths($result);
		$this->_assign_search_paths($result, isset($params['offset']) ? $params['offset'] : 0);
		
		return $result;
	}
 function count_accessible_children($id, $add_sql = array())
 {
     if (!($parent = $this->get_node($id))) {
         debug::write_error('node not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('id' => $id));
         return false;
     }
     if (!$this->_is_table_joined('sys_site_object', $add_sql)) {
         $add_sql['join'][] = ', sys_site_object as sso ';
     }
     if (!$this->_is_table_joined('sys_object_access', $add_sql)) {
         $add_sql['join'][] = ', sys_object_access as soa ';
     }
     $add_sql['append'][] = ' AND sso.id = ' . $this->_node_table . '.object_id AND sso.id = soa.object_id AND soa.r = 1';
     $access_policy =& access_policy::instance();
     $accessor_ids = implode(',', $access_policy->get_accessor_ids());
     $add_sql['append'][] = " AND soa.accessor_id IN ({$accessor_ids})";
     $add_sql['group'][] = ' GROUP BY ' . $this->_node_table . '.id';
     $sql = sprintf('SELECT count(*) as counter FROM %s %s
                 WHERE %s.root_id=%s AND %s.parent_id=%s %s %s', $this->_node_table, $this->_add_sql($add_sql, 'join'), $this->_node_table, $parent['root_id'], $this->_node_table, $id, $this->_add_sql($add_sql, 'append'), $this->_add_sql($add_sql, 'group'));
     $this->_db->sql_exec($sql);
     return count($this->_db->get_array());
 }
Exemplo n.º 29
0
	function & _get_access_policy()
	{
	  include_once(LIMB_DIR . 'core/model/access_policy.class.php');
	  $access_policy =& access_policy :: instance();
	  return $access_policy;
	}
 function _init_dataspace(&$request)
 {
     $access_policy =& access_policy::instance();
     $data['policy'] = $access_policy->get_group_object_access_by_ids($this->object_ids);
     $this->dataspace->merge($data);
 }