function setUp()
 {
     $this->db =& db_factory::instance();
     $this->_clean_up();
     $this->_init_site_object();
     $this->object->set_attribute('controller_name', 'site_object_controller');
     $controller_id = site_object_controller::get_id('site_object_controller');
     $this->object->set_attribute('controller_id', $controller_id);
     debug_mock::init($this);
     $user =& user::instance();
     $user->_set_id(10);
     $tree =& tree::instance();
     $values['identifier'] = 'root';
     $values['object_id'] = 100;
     $this->root_node_id = $tree->create_root_node($values, false, true);
     $class_id = $this->object->get_class_id();
     $this->db->sql_insert('sys_site_object', array('id' => 100, 'class_id' => $class_id, 'current_version' => 1));
     $values['identifier'] = 'ru';
     $values['object_id'] = 1;
     $this->parent_node_id = $tree->create_sub_node($this->root_node_id, $values);
     $this->db->sql_insert('sys_site_object', array('id' => 1, 'class_id' => $class_id, 'current_version' => 1));
     $values['identifier'] = 'document';
     $values['object_id'] = 10;
     $this->sub_node_id = $tree->create_sub_node($this->parent_node_id, $values);
     $this->db->sql_insert('sys_site_object', array('id' => 10, 'class_id' => $class_id, 'current_version' => 1));
 }
 function init(&$object)
 {
     $this->class_id = $object->get_class_id();
     $this->controller_id = site_object_controller::get_id(get_class($object) . '_controller');
     $this->_insert_sys_site_object_records();
     $this->_insert_fake_sys_site_object_records();
 }
 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 _valid_perform(&$request, &$response)
 {
     $node_id = $this->dataspace->get('id');
     if (!($object = wrap_with_site_object(fetch_one_by_node_id($node_id)))) {
         $request->set_status(REQUEST_STATUS_FAILURE);
         return;
     }
     $object->set_attribute('controller_id', site_object_controller::get_id($this->dataspace->get('controller_name')));
     $object->update(false);
     $request->set_status(REQUEST_STATUS_SUCCESS);
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request));
     }
 }
 function _get_controller_id()
 {
     $controller_name = $this->_define_controller_name();
     return site_object_controller::get_id($controller_name);
 }
Exemplo n.º 6
0
*
* $Id$
*
***********************************************************************************/
if (isset($argv[1])) {
    $project_dir = $argv[1];
} else {
    die('project dir required');
}
require_once $project_dir . '/setup.php';
require_once LIMB_DIR . '/core/lib/db/db_table_factory.class.php';
require_once LIMB_DIR . '/core/controllers/site_object_controller.class.php';
$site_object_db_table = db_table_factory::create('sys_site_object');
$class_db_table = db_table_factory::create('sys_class');
$action_access_db_table = db_table_factory::create('sys_action_access');
$group_object_access_template_db_table = db_table_factory::create('sys_group_object_access_template');
$user_object_access_template_db_table = db_table_factory::create('sys_user_object_access_template');
$classes = $class_db_table->get_list();
foreach ($classes as $class) {
    $class_id = $class['id'];
    $controller_name = $class['class_name'] . '_controller';
    $controller_id = site_object_controller::get_id($controller_name);
    $conditions['class_id'] = $class_id;
    $row['controller_id'] = $controller_id;
    $site_object_db_table->update($row, $conditions);
    $action_access_db_table->update($row, $conditions);
    $group_object_access_template_db_table->update($row, $conditions);
    $user_object_access_template_db_table->update($row, $conditions);
    echo $class['class_name'] . " objects updated...\n";
}
echo 'done';
 function get_controller_id()
 {
   if($controller_name = $this->get_controller_name())
     return site_object_controller :: get_id($controller_name);
   else
     return null;
 }
  function setUp()
  {
    parent :: setUp();

    $this->fetcher =& new fetcher();

    $this->fetcher->set_jip_status(true);

    $user_id = 10;

    $this->_login_user($user_id, array(103 => 'visitors', 104 => 'admin'));

    $controller_id = site_object_controller :: get_id('fetching_test_controller_test_version');

    $obj1 = site_object_factory :: create('fetching_object1_test_version');
    $obj2 = site_object_factory :: create('fetching_object2_test_version');

    $obj1->set_identifier('root');
    $obj1->set_title('Root');
    $obj1->set_attribute('controller_id', $controller_id);
    $obj2->set_attribute('controller_name', 'fetching_test_controller_test_version');
    $obj1->create(true);
    $access[$obj1->get_id()] = array($user_id => 1);
    $this->root_node_id = $obj1->get_node_id();
    $this->_add_object($obj1);

    $obj1->set_parent_node_id($this->root_node_id);
    $obj1->set_identifier('articles');
    $obj1->set_title('Articles');
    $obj2->set_attribute('controller_name', 'fetching_test_controller_test_version');
    $obj1->set_attribute('controller_id', $controller_id);
    $obj1->create();
    $access[$obj1->get_id()] = array($user_id => 1);
    $this->_add_object($obj1);

    $this->articles_object = $obj1;

    $obj2->set_parent_node_id($obj1->get_node_id());
    $obj2->set_identifier('article1');
    $obj2->set_title('Article1');
    $obj2->set_attribute('controller_name', 'fetching_test_controller_test_version');
    $obj2->set_attribute('controller_id', $controller_id);
    $obj2->create();
    $access[$obj2->get_id()] = array($user_id => 1);
    $this->child_node_ids[] = $obj2->get_node_id();
    $this->_add_object($obj2);

    $this->article_object = $obj2;

    $obj2->set_parent_node_id($obj1->get_node_id());
    $obj2->set_identifier('article2');
    $obj2->set_title('Article2');
    $obj2->set_attribute('controller_id', $controller_id);
    $obj2->set_attribute('controller_name', 'fetching_test_controller_test_version');
    $obj2->create();
    $access[$obj2->get_id()] = array($user_id => 1);
    $this->child_node_ids[] = $obj2->get_node_id();
    $this->_add_object($obj2);

    $obj2->set_parent_node_id($obj1->get_node_id());
    $obj2->set_identifier('article3');
    $obj2->set_title('Article3');
    $obj2->set_attribute('controller_id', $controller_id);
    $obj2->set_attribute('controller_name', 'fetching_test_controller_test_version');
    $obj2->create();
    $access[$obj2->get_id()] = array($user_id => 0);
    $this->child_node_ids[] = $obj2->get_node_id();
    $this->_add_object($obj2);

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

    $this->access_policy->save_object_access($access, ACCESSOR_TYPE_USER);

    $actions = array(
      $user_id => array(
          'display' => 1,
      ),
    );

    $this->access_policy->save_action_access($obj1->get_class_id(), $actions, ACCESSOR_TYPE_USER);
    $this->access_policy->save_action_access($obj2->get_class_id(), $actions, ACCESSOR_TYPE_USER);
  }
  function _create_node($identifier)
  {
    static $object_id = 1;

    $tree =& tree :: instance();

    $values['identifier'] = $identifier;
    $values['object_id'] = ++$object_id;
    $tree->create_sub_node($this->parent_node_id, $values);

    $controller_id = site_object_controller :: get_id('site_object_controller');
    $this->object->set_attribute('controller_id', $controller_id);

    $class_id = $this->object->get_class_id();
    $this->db->sql_insert('sys_site_object',
      array('id' => $object_id, 'class_id' => $class_id, 'current_version' => 1, 'controller_id' => $controller_id));
  }