Esempio n. 1
0
 /**
  * Looks up a product to display.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_edit($handler_id, array $args, array &$data)
 {
     $this->_group = new org_openpsa_products_product_group_dba($args[0]);
     $this->_request_data['controller'] = midcom_helper_datamanager2_controller::create('simple');
     $this->_request_data['controller']->schemadb =& $this->_request_data['schemadb_group'];
     $this->_request_data['controller']->set_storage($this->_group);
     if (!$this->_request_data['controller']->initialize()) {
         throw new midcom_error("Failed to initialize a DM2 controller instance for product {$this->_group->id}.");
     }
     switch ($this->_request_data['controller']->process_form()) {
         case 'save':
             if ($this->_config->get('index_groups')) {
                 // Index the group
                 $indexer = midcom::get('indexer');
                 org_openpsa_products_viewer::index($this->_request_data['controller']->datamanager, $indexer, $this->_topic);
             }
             midcom::get('cache')->invalidate($this->_topic->guid);
         case 'cancel':
             return new midcom_response_relocate("{$this->_group->guid}/");
     }
     $this->_update_breadcrumb_line();
     $this->_prepare_request_data();
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_view_toolbar->bind_to($this->_group);
     midcom::get('metadata')->set_request_metadata($this->_group->metadata->revised, $this->_group->guid);
     midcom::get('head')->set_pagetitle($this->_group->title);
 }
Esempio n. 2
0
 /**
  * Displays an article edit view.
  *
  * Note, that the article for non-index mode operation is automatically determined in the can_handle
  * phase.
  *
  * If create privileges apply, we relocate to the index creation article
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  */
 public function _handler_create($handler_id, array $args, array &$data)
 {
     $this->_request_data['up'] = (int) $args[0];
     if ($this->_request_data['up'] == 0) {
         midcom::get('auth')->require_user_do('midgard:create', null, 'org_openpsa_products_product_group_dba');
     } else {
         $parent = new org_openpsa_products_product_group_dba($data['up']);
         $parent->require_do('midgard:create');
         $data['parent'] = $parent;
     }
     $data['selected_schema'] = $args[1];
     if (!array_key_exists($data['selected_schema'], $data['schemadb_group'])) {
         throw new midcom_error_notfound('Schema ' . $data['selected_schema'] . ' was not found it schemadb');
     }
     $this->_schema =& $data['selected_schema'];
     $data['controller'] = $this->get_controller('create');
     switch ($data['controller']->process_form()) {
         case 'save':
             if ($this->_config->get('index_groups')) {
                 // Index the group
                 $indexer = midcom::get('indexer');
                 org_openpsa_products_viewer::index($data['controller']->datamanager, $indexer, $this->_topic);
             }
             midcom::get('cache')->invalidate($this->_topic->guid);
             return new midcom_response_relocate("{$this->_group->guid}/");
         case 'cancel':
             if ($this->_request_data['up'] == 0) {
                 return new midcom_response_relocate('');
             } else {
                 return new midcom_response_relocate("{$this->_request_data['up']}/");
             }
     }
     $this->_prepare_request_data();
     // Add toolbar items
     org_openpsa_helpers::dm2_savecancel($this);
     $this->_request_data['view_title'] = sprintf($this->_l10n_midcom->get('create %s'), $this->_l10n->get($this->_schemadb[$this->_schema]->description));
     midcom::get('head')->set_pagetitle($this->_request_data['view_title']);
     $this->_update_breadcrumb_line();
 }
Esempio n. 3
0
 public function _on_reindex_tree_iterator(&$indexer, &$dms, &$topic, &$group, &$topic, &$config)
 {
     if ($dms['group']->autoset_storage($group)) {
         if ($config->get('index_groups')) {
             org_openpsa_products_viewer::index($dms['group'], $indexer, $topic, $config);
         }
     } else {
         debug_add("Warning, failed to initialize datamanager for product group {$group->id}. Skipping it.", MIDCOM_LOG_WARN);
     }
     if ($config->get('index_products')) {
         $qb_products = org_openpsa_products_product_dba::new_query_builder();
         $qb_products->add_constraint('productGroup', '=', $group->id);
         $products = $qb_products->execute();
         unset($qb_products);
         if (is_array($products)) {
             foreach ($products as $product) {
                 if (!$dms['product']->autoset_storage($product)) {
                     debug_add("Warning, failed to initialize datamanager for product {$product->id}. Skipping it.", MIDCOM_LOG_WARN);
                     continue;
                 }
                 org_openpsa_products_viewer::index($dms['product'], $indexer, $topic, $config);
                 unset($product);
             }
         }
         unset($products);
     }
     $subgroups = array();
     $qb_groups = org_openpsa_products_product_group_dba::new_query_builder();
     $qb_groups->add_constraint('up', '=', $group->id);
     $subgroups = $qb_groups->execute();
     unset($qb_groups);
     if (!is_array($subgroups)) {
         return true;
     }
     foreach ($subgroups as $subgroup) {
         $this->_on_reindex_tree_iterator($indexer, $dms, $topic, $subgroup, $topic, $config);
         unset($subgroup);
     }
     unset($subgroups);
     return true;
 }