/** * Handle the creation phase * * @param String $handler_id Name of the request handler * @param array $args Variable arguments * @param array &$data Public request data, passed by reference */ public function _handler_create($handler_id, array $args, array &$data) { // Get the root event $this->_root_event = org_openpsa_calendar_interface::find_root_event(); // ACL handling: require create privileges $this->_root_event->require_do('midgard:create'); if (isset($args[0])) { $this->_person = new midcom_db_person($args[0]); } if (isset($args[1])) { $this->_requested_time = (int) $args[1]; } // Load the controller instance $data['controller'] = $this->get_controller('create'); // Process form switch ($data['controller']->process_form()) { case 'save': $indexer = new org_openpsa_calendar_midcom_indexer($this->_topic); $indexer->index($data['controller']->datamanager); //FALL-THROUGH //FALL-THROUGH case 'cancel': midcom::get('head')->add_jsonload('window.opener.location.reload();'); midcom::get('head')->add_jsonload('window.close();'); break; } // Add toolbar items org_openpsa_helpers::dm2_savecancel($this); // Hide the ROOT style midcom::get()->skip_page_style = true; }
/** * Handle the editing phase * * @param String $handler_id Name of the request handler * @param array $args Variable arguments * @param array &$data Public request data, passed by reference */ public function _handler_edit($handler_id, array $args, array &$data) { // Get the event $this->_event = new org_openpsa_calendar_event_dba($args[0]); $this->_event->require_do('midgard:update'); // Load schema database $schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb')); // Load the controller $data['controller'] = midcom_helper_datamanager2_controller::create('simple'); $data['controller']->schemadb = $schemadb; $data['controller']->set_storage($this->_event); if (!$data['controller']->initialize()) { throw new midcom_error("Failed to initialize a DM2 controller instance for article {$this->_article->id}."); } switch ($data['controller']->process_form()) { case 'save': $indexer = new org_openpsa_calendar_midcom_indexer($this->_topic); $indexer->index($data['controller']->datamanager); //FALL-THROUGH //FALL-THROUGH case 'cancel': midcom::get('head')->add_jsonload('window.opener.location.reload();'); midcom::get('head')->add_jsonload('window.close();'); // This will _midcom_stop_request(well, in a way...) } // Add toolbar items org_openpsa_helpers::dm2_savecancel($this); }
/** * Prepare the indexer client */ public function _on_reindex($topic, $config, &$indexer) { $root_event = self::find_root_event(); $qb = org_openpsa_calendar_event_dba::new_query_builder(); $qb->add_constraint('up', '=', $root_event->id); $schemadb = midcom_helper_datamanager2_schema::load_database($config->get('schemadb')); $indexer = new org_openpsa_calendar_midcom_indexer($topic, $indexer); $indexer->add_query('events', $qb, $schemadb); return $indexer; }